pub struct HardHatLoader {
    pub origin: Option<String>,
    pub networks_allow_list: Vec<NetworkEntry>,
    pub networks_deny_list: Vec<NetworkEntry>,
    pub contracts_allow_list: Vec<String>,
    pub contracts_deny_list: Vec<String>,
}
Expand description

Loads hardhat artifacts generated via --export and --export-all.

Limitations

In hardhat, a contract could have different ABIs on different networks. This could happen when deploying test versions of contracts. Ethcontract does not support this. Parsing such artifact will result in an error. You’ll have to rename contracts, or filter out networks with [networks_allow_list].

Another limitation is that hardhat allows having multiple networks with the same chain ID. For example, you can have rinkeby and rinkeby-testing. Both have chain ID of 4, but contract addresses and ABIs can be different. Ethcontract does not support this, so you’ll have to filter such networks. See #545 for more info.

Fields§

§origin: Option<String>

Override for artifact’s origin. If None, origin will be derived automatically.

§networks_allow_list: Vec<NetworkEntry>

List of allowed network names and chain IDs.

When loading a contract, networks with names that aren’t found in this list will be completely ignored. Contracts from these networks will not be loaded. You can use this mechanism to bypass the requirement that a contract must have the same ABI on all networks.

Empty list means that all networks are allowed.

§networks_deny_list: Vec<NetworkEntry>

List of denied network names and chain IDs.

When loading a contract, networks with names that are found in this list will be completely ignored.

Empty list means that no networks are denied.

Deny list takes precedence over allow list. That is, if network appears in both, it will be denied.

§contracts_allow_list: Vec<String>

List of allowed contract names.

When loading artifact, loader will only load contracts if their names are present in this list.

Empty list means that all contracts are allowed.

§contracts_deny_list: Vec<String>

List of denied contract names.

When loading artifact, loader will not load contracts if their names are present in this list.

Empty list means that no contracts are denied.

Deny list takes precedence over allow list. That is, if contract appears in both, it will be denied.

Implementations§

source§

impl HardHatLoader

source

pub fn new() -> Self

Creates a new hardhat loader.

source

pub fn with_origin(origin: impl Into<String>) -> Self

Creates a new hardhat loader and sets an override for artifact’s origins.z

source

pub fn origin(self, origin: impl Into<String>) -> Self

Sets new override for artifact’s origin. See origin for more info.

source

pub fn allow_network_by_chain_id(self, network: impl Into<String>) -> Self

Adds chain id to the list of allowed networks.

source

pub fn allow_network_by_name(self, network: impl Into<String>) -> Self

Adds network name to the list of allowed networks.

source

pub fn deny_network_by_chain_id(self, network: impl Into<String>) -> Self

Adds chain id to the list of denied networks.

source

pub fn deny_network_by_name(self, network: impl Into<String>) -> Self

Adds network name to the list of denied networks.

source

pub fn allow_contract(self, contract: impl Into<String>) -> Self

Adds contract name to the list of allowed contracts.

source

pub fn deny_contract(self, contract: impl Into<String>) -> Self

Adds contract name to the list of denied contracts.

source

pub fn load_from_reader( &self, f: Format, v: impl Read ) -> Result<Artifact, ArtifactError>

Loads an artifact from a JSON value.

source

pub fn load_from_slice( &self, f: Format, v: &[u8] ) -> Result<Artifact, ArtifactError>

Loads an artifact from bytes of JSON text.

source

pub fn load_from_str( &self, f: Format, v: &str ) -> Result<Artifact, ArtifactError>

Loads an artifact from string of JSON text.

source

pub fn load_from_value( &self, f: Format, v: Value ) -> Result<Artifact, ArtifactError>

Loads an artifact from a loaded JSON value.

source

pub fn load_from_file( &self, f: Format, p: impl AsRef<Path> ) -> Result<Artifact, ArtifactError>

Loads an artifact from disk.

source

pub fn load_from_directory( &self, p: impl AsRef<Path> ) -> Result<Artifact, ArtifactError>

Loads an artifact from deployments directory.

Trait Implementations§

source§

impl Default for HardHatLoader

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V