Skip to content

Commit

Permalink
hotfix: missing erc20 class
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Oct 26, 2024
1 parent d081602 commit ec26bc4
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions crates/katana/primitives/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::da::L1DataAvailabilityMode;
use crate::genesis::allocation::{DevAllocationsGenerator, GenesisAllocation};
use crate::genesis::constant::{
get_fee_token_balance_base_storage_address, DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT,
DEFAULT_ETH_FEE_TOKEN_ADDRESS, DEFAULT_LEGACY_ERC20_CLASS_HASH, DEFAULT_LEGACY_UDC_CASM,
DEFAULT_LEGACY_UDC_CLASS_HASH, DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH,
DEFAULT_ETH_FEE_TOKEN_ADDRESS, DEFAULT_LEGACY_ERC20_CASM, DEFAULT_LEGACY_ERC20_CLASS_HASH,
DEFAULT_LEGACY_UDC_CASM, DEFAULT_LEGACY_UDC_CLASS_HASH, DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH,
DEFAULT_PREFUNDED_ACCOUNT_BALANCE, DEFAULT_STRK_FEE_TOKEN_ADDRESS, DEFAULT_UDC_ADDRESS,
ERC20_DECIMAL_STORAGE_SLOT, ERC20_NAME_STORAGE_SLOT, ERC20_SYMBOL_STORAGE_SLOT,
ERC20_TOTAL_SUPPLY_STORAGE_SLOT,
Expand Down Expand Up @@ -107,29 +107,7 @@ impl ChainSpec {
}

//-- Fee tokens

// -- ETH
add_fee_token(
&mut states,
"Ether",
"ETH",
18,
DEFAULT_ETH_FEE_TOKEN_ADDRESS,
DEFAULT_LEGACY_ERC20_CLASS_HASH,
&self.genesis.allocations,
);

// -- STRK
add_fee_token(
&mut states,
"Starknet Token",
"STRK",
18,
DEFAULT_STRK_FEE_TOKEN_ADDRESS,
DEFAULT_LEGACY_ERC20_CLASS_HASH,
&self.genesis.allocations,
);

add_default_fee_tokens(&mut states, &self.genesis);
// -- UDC
add_default_udc(&mut states);

Expand Down Expand Up @@ -167,6 +145,36 @@ lazy_static! {
};
}

fn add_default_fee_tokens(states: &mut StateUpdatesWithDeclaredClasses, genesis: &Genesis) {
// declare erc20 token contract
states
.declared_compiled_classes
.entry(DEFAULT_LEGACY_ERC20_CLASS_HASH)
.or_insert_with(|| DEFAULT_LEGACY_ERC20_CASM.clone());

// -- ETH
add_fee_token(
states,
"Ether",
"ETH",
18,
DEFAULT_ETH_FEE_TOKEN_ADDRESS,
DEFAULT_LEGACY_ERC20_CLASS_HASH,
&genesis.allocations,
);

// -- STRK
add_fee_token(
states,
"Starknet Token",
"STRK",
18,
DEFAULT_STRK_FEE_TOKEN_ADDRESS,
DEFAULT_LEGACY_ERC20_CLASS_HASH,
&genesis.allocations,
);
}

fn add_fee_token(
states: &mut StateUpdatesWithDeclaredClasses,
name: &str,
Expand Down

0 comments on commit ec26bc4

Please sign in to comment.