Enum Source

Source
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

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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§

§

impl Freeze for Source

§

impl RefUnwindSafe for Source

§

impl Send for Source

§

impl Sync for Source

§

impl Unpin for Source

§

impl UnwindSafe for Source

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> MaybeSendSync for T