Struct ethcontract_common::artifact::hardhat::HardHatLoader [−][src]
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
Creates a new hardhat loader and sets an override for artifact’s origins.z
Sets new override for artifact’s origin. See origin
for more info.
Adds chain id to the list of allowed networks
.
Adds network name to the list of allowed networks
.
Adds chain id to the list of denied networks
.
Adds network name to the list of denied networks
.
Adds contract name to the list of allowed contracts
.
Adds contract name to the list of denied contracts
.
Loads an artifact from a JSON value.
Loads an artifact from bytes of JSON text.
Loads an artifact from string of JSON text.
Loads an artifact from a loaded JSON value.
pub 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.
Loads an artifact from deployments
directory.