Skip to content

Commit 5ed9c9d

Browse files
committed
Simplify load_predeployed_contracts
1 parent c367672 commit 5ed9c9d

1 file changed

Lines changed: 2 additions & 28 deletions

File tree

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
11
use crate::{
22
predeployment::erc20::contracts_data::load_erc20_predeployed_contracts,
3-
predeployment::erc20::eth::{ETH_CONTRACT_NAME, ETH_SIERRA_CLASS_HASH},
4-
predeployment::erc20::strk::{STRK_CONTRACT_NAME, STRK_SIERRA_CLASS_HASH},
53
runtime_extensions::forge_runtime_extension::contracts_data::ContractsData,
64
};
7-
use anyhow::{Result, anyhow};
8-
use conversions::string::TryFromHexStr;
5+
use anyhow::Result;
96

107
pub fn load_predeployed_contracts() -> Result<ContractsData> {
118
// In the future, if we have more contracts to predeploy, we can split them into separate functions and merge the results here.
129
let erc20_contracts = load_erc20_predeployed_contracts()?;
1310

14-
let mut contracts_data = ContractsData::try_from(erc20_contracts)?;
15-
16-
// Class hashes for STRK and ETH contract are different on network than the ones
17-
// calculated from their sierras, so we need to update them.
18-
let class_hashes_to_update = vec![
19-
(STRK_CONTRACT_NAME.to_string(), STRK_SIERRA_CLASS_HASH),
20-
(ETH_CONTRACT_NAME.to_string(), ETH_SIERRA_CLASS_HASH),
21-
];
22-
23-
for (contract_name, class_hash) in class_hashes_to_update {
24-
let class_hash = TryFromHexStr::try_from_hex_str(class_hash)?;
25-
26-
contracts_data
27-
.class_hashes
28-
.insert(contract_name.clone(), class_hash);
29-
30-
let contract_data = contracts_data
31-
.contracts
32-
.get_mut(&contract_name)
33-
.ok_or_else(|| anyhow!("contract data for {contract_name} should exist"))?;
34-
contract_data.class_hash = class_hash;
35-
}
36-
37-
Ok(contracts_data)
11+
ContractsData::try_from(erc20_contracts)
3812
}

0 commit comments

Comments
 (0)