Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: add ArtifactId::identifier() #1087

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- name: cargo fmt
run: cargo +nightly-2022-03-20 fmt --all -- --check
- name: cargo clippy
run: cargo +nightly-2022-03-20 clippy --all --all-features -- -D warnings
run: cargo +nightly-2022-03-20 clippy --all-features -- -D warnings

wasm:
name: WASM
Expand Down
9 changes: 9 additions & 0 deletions ethers-solc/src/artifact_output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ pub struct ArtifactId {

impl ArtifactId {
/// Returns a <filename>:<name> slug that identifies an artifact
///
/// Note: This identifier is not necessarily unique. If two contracts have the same name, they
/// will share the same slug. For a unique identifier see [ArtifactId::identifier].
pub fn slug(&self) -> String {
format!("{}.json:{}", self.path.file_stem().unwrap().to_string_lossy(), self.name)
}

/// Returns a <source path>:<name> slug that uniquely identifies an artifact
pub fn identifier(&self) -> String {
format!("{}:{}", self.source.to_string_lossy(), self.name)
}

/// Returns a <filename><version>:<name> slug that identifies an artifact
pub fn slug_versioned(&self) -> String {
format!(
Expand Down