pub enum Source {
    String(String),
    Local(PathBuf),
    Explorer(Explorer, Address),
    Npm(String),
    Http(Url),
}
Expand description

A source of an Ethereum smart contract’s ABI.

See [parse][#method.parse] for more information.

Variants§

§

String(String)

A raw ABI string.

§

Local(PathBuf)

An ABI located on the local file system.

§

Explorer(Explorer, Address)

Available on crate feature online and non-WebAssembly only.

An address of a smart contract address verified at a supported blockchain explorer.

§

Npm(String)

Available on crate feature online and non-WebAssembly only.

The package identifier of an npm package with a path to a Truffle artifact or ABI to be retrieved from unpkg.io.

§

Http(Url)

Available on crate feature online and non-WebAssembly only.

An ABI to be retrieved over HTTP(S).

Implementations§

source§

impl Source

source

pub fn http(url: impl AsRef<str>) -> Result<Self>

Available on crate feature online and non-WebAssembly only.

Creates an HTTP source from a URL.

source

pub fn explorer(chain: Chain, address: Address) -> Result<Self>

Available on crate feature online and non-WebAssembly only.

Creates an Etherscan source from an address string.

source

pub fn npm(package_path: impl Into<String>) -> Self

Available on crate feature online and non-WebAssembly only.

Creates an Etherscan source from an address string.

source§

impl Source

source

pub fn parse(source: impl AsRef<str>) -> Result<Self>

Parses an ABI from a source.

This method accepts the following:

  • { ... } or [ ... ]: A raw or human-readable ABI object or array of objects.

  • relative/path/to/Contract.json: a relative path to an ABI JSON file. This relative path is rooted in the current working directory.

  • /absolute/path/to/Contract.json or file:///absolute/path/to/Contract.json: an absolute path or file URL to an ABI JSON file.

If the online feature is enabled:

  • npm:@org/package@1.0.0/path/to/contract.json: A npmjs package with an optional version and path (defaulting to the latest version and index.js), retrieved through unpkg.io.

  • http://...: an HTTP URL to a contract ABI.
    Note: either the rustls or openssl feature must be enabled to support HTTPS URLs.

  • <name>:<address>, <chain>:<address> or <url>/.../<address>: an address or URL of a verified contract on a blockchain explorer.
    Supported explorers and their respective chain:

    • etherscan -> mainnet
    • bscscan -> bsc
    • polygonscan -> polygon
    • snowtrace -> avalanche
source

pub fn local(path: impl AsRef<str>) -> Result<Self>

Creates a local filesystem source from a path string.

source

pub fn is_string(&self) -> bool

Returns true if self is String.

source

pub fn as_string(&self) -> Option<&String>

Returns self as String.

source

pub fn is_local(&self) -> bool

Returns true if self is Local.

source

pub fn as_local(&self) -> Option<&PathBuf>

Returns self as Local.

source

pub fn get(&self) -> Result<String>

Retrieves the source JSON of the artifact this will either read the JSON from the file system or retrieve a contract ABI from the network depending on the source type.

Trait Implementations§

source§

impl Clone for Source

source§

fn clone(&self) -> Source

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Source

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Source

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl FromStr for Source

§

type Err = Report

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for Source

source§

fn eq(&self, other: &Source) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Source

source§

impl StructuralPartialEq for Source

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T