Struct ethcontract_common::artifact::hardhat::HardHatLoader
source · 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
impl HardHatLoader
sourcepub fn with_origin(origin: impl Into<String>) -> Self
pub fn with_origin(origin: impl Into<String>) -> Self
Creates a new hardhat loader and sets an override for artifact’s origins.z
sourcepub fn origin(self, origin: impl Into<String>) -> Self
pub fn origin(self, origin: impl Into<String>) -> Self
Sets new override for artifact’s origin. See origin for more info.
sourcepub fn allow_network_by_chain_id(self, network: impl Into<String>) -> Self
pub fn allow_network_by_chain_id(self, network: impl Into<String>) -> Self
Adds chain id to the list of allowed networks.
sourcepub fn allow_network_by_name(self, network: impl Into<String>) -> Self
pub fn allow_network_by_name(self, network: impl Into<String>) -> Self
Adds network name to the list of allowed networks.
sourcepub fn deny_network_by_chain_id(self, network: impl Into<String>) -> Self
pub fn deny_network_by_chain_id(self, network: impl Into<String>) -> Self
Adds chain id to the list of denied networks.
sourcepub fn deny_network_by_name(self, network: impl Into<String>) -> Self
pub fn deny_network_by_name(self, network: impl Into<String>) -> Self
Adds network name to the list of denied networks.
sourcepub fn allow_contract(self, contract: impl Into<String>) -> Self
pub fn allow_contract(self, contract: impl Into<String>) -> Self
Adds contract name to the list of allowed contracts.
sourcepub fn deny_contract(self, contract: impl Into<String>) -> Self
pub fn deny_contract(self, contract: impl Into<String>) -> Self
Adds contract name to the list of denied contracts.
sourcepub fn load_from_reader(
&self,
f: Format,
v: impl Read
) -> Result<Artifact, ArtifactError>
pub fn load_from_reader( &self, f: Format, v: impl Read ) -> Result<Artifact, ArtifactError>
Loads an artifact from a JSON value.
sourcepub fn load_from_slice(
&self,
f: Format,
v: &[u8]
) -> Result<Artifact, ArtifactError>
pub fn load_from_slice( &self, f: Format, v: &[u8] ) -> Result<Artifact, ArtifactError>
Loads an artifact from bytes of JSON text.
sourcepub fn load_from_str(
&self,
f: Format,
v: &str
) -> Result<Artifact, ArtifactError>
pub fn load_from_str( &self, f: Format, v: &str ) -> Result<Artifact, ArtifactError>
Loads an artifact from string of JSON text.
sourcepub fn load_from_value(
&self,
f: Format,
v: Value
) -> Result<Artifact, ArtifactError>
pub fn load_from_value( &self, f: Format, v: Value ) -> Result<Artifact, ArtifactError>
Loads an artifact from a loaded JSON value.
sourcepub fn load_from_file(
&self,
f: Format,
p: impl AsRef<Path>
) -> Result<Artifact, ArtifactError>
pub fn load_from_file( &self, f: Format, p: impl AsRef<Path> ) -> Result<Artifact, ArtifactError>
Loads an artifact from disk.
sourcepub fn load_from_directory(
&self,
p: impl AsRef<Path>
) -> Result<Artifact, ArtifactError>
pub fn load_from_directory( &self, p: impl AsRef<Path> ) -> Result<Artifact, ArtifactError>
Loads an artifact from deployments directory.