[][src]Enum ethcontract_generate::Source

pub enum Source {
    Local(PathBuf),
    Http(Url),
    Etherscan(Address),
    Npm(String),
}

A source of a Truffle artifact JSON.

Variants

Local(PathBuf)

A Truffle artifact or ABI located on the local file system.

Http(Url)

A truffle artifact or ABI to be retrieved over HTTP(S).

Etherscan(Address)

An address of a mainnet contract that has been verified on Etherscan.io.

Npm(String)

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

Implementations

impl Source[src]

pub fn parse<S>(source: S) -> Result<Self> where
    S: AsRef<str>, 
[src]

Parses an artifact source from a string.

Contract artifacts can be retrieved from the local filesystem or online from etherscan.io, this method parses artifact source URLs and accepts the following:

  • relative/path/to/Contract.json: a relative path to a truffle artifact JSON file. This relative path is rooted in the current working directory. To specify the root for relative paths, use Source::with_root.
  • /absolute/path/to/Contract.json or file:///absolute/path/to/Contract.json: an absolute path or file URL to a truffle artifact JSON file.
  • http(s)://... an HTTP url to a contract ABI or Truffle artifact.
  • etherscan:0xXX..XX or https://etherscan.io/address/0xXX..XX: a address or URL of a verified contract on Etherscan.
  • npm:@org/package@1.0.0/path/to/contract.json an npmjs package with an optional version and path (defaulting to the latest version and index.js). The contract artifact or ABI will be retrieved through unpkg.io.

pub fn with_root<P, S>(root: P, source: S) -> Result<Self> where
    P: AsRef<Path>,
    S: AsRef<str>, 
[src]

Parses an artifact source from a string and a specified root directory for resolving relative paths. See Source::with_root for more details on supported source strings.

pub fn local<P>(path: P) -> Self where
    P: AsRef<Path>, 
[src]

Creates a local filesystem source from a path string.

pub fn http<S>(url: S) -> Result<Self> where
    S: AsRef<str>, 
[src]

Creates an HTTP source from a URL.

pub fn etherscan<S>(address: S) -> Result<Self> where
    S: AsRef<str>, 
[src]

Creates an Etherscan source from an address string.

pub fn npm<S>(package_path: S) -> Self where
    S: Into<String>, 
[src]

Creates an Etherscan source from an address string.

pub fn artifact_json(&self) -> Result<String>[src]

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 dependending on the source type.

Trait Implementations

impl Clone for Source[src]

impl Debug for Source[src]

impl Eq for Source[src]

impl FromStr for Source[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<Source> for Source[src]

impl StructuralEq for Source[src]

impl StructuralPartialEq for Source[src]

Auto Trait Implementations

impl RefUnwindSafe for Source

impl Send for Source

impl Sync for Source

impl Unpin for Source

impl UnwindSafe for Source

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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