|
1 | 1 | use crate::{ |
2 | 2 | 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}, |
5 | 3 | runtime_extensions::forge_runtime_extension::contracts_data::ContractsData, |
6 | 4 | }; |
7 | | -use anyhow::{Result, anyhow}; |
8 | | -use conversions::string::TryFromHexStr; |
| 5 | +use anyhow::Result; |
9 | 6 |
|
10 | 7 | pub fn load_predeployed_contracts() -> Result<ContractsData> { |
11 | 8 | // In the future, if we have more contracts to predeploy, we can split them into separate functions and merge the results here. |
12 | 9 | let erc20_contracts = load_erc20_predeployed_contracts()?; |
13 | 10 |
|
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) |
38 | 12 | } |
0 commit comments