0xSpaceShard / starknet-devnet-rs

A local testnet for Starknet... in Rust
https://0xspaceshard.github.io/starknet-devnet-rs/
MIT License
100 stars 56 forks source link

Invalid predeployed ERC20 data #544

Closed tonypony220 closed 1 week ago

tonypony220 commented 1 week ago

Wrong function used https://github.com/0xSpaceShard/starknet-devnet-rs/blob/38aa51eb9951597a22acbeab4a64e33181dbaf7e/crates/starknet-devnet-core/src/starknet/predeployed.rs#L36 it should be not selector but to-cario-stirng or something.

FabijanC commented 1 week ago

If you haven't already prepared a PR, I'll check this out. Thanks for reporting.

FabijanC commented 1 week ago

Well I wrote this test and it seems that the value returned by get_selector_from_name is just alright:

mod test {
    use blockifier::abi::abi_utils::get_storage_var_address;
    use starknet_rs_core::utils::get_selector_from_name;
    use starknet_types::felt::Felt;

    #[test]
    fn compare() {
        assert_eq!(
            Felt::from(get_selector_from_name("ERC20_name").unwrap()),
            Felt::from(get_storage_var_address("ERC20_name", &[]).0),
        );
    }
}

Do you still think it should be changed?

tonypony220 commented 1 week ago
starkli storage 0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7 ERC20_symbol --rpc https://starknet-mainnet.g.alchemy.com/v2/XXXXXXXXXXXXXXXXXXXXXXXX
0x0000000000000000000000000000000000000000000000000000000000455448
starkli storage 0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7 ERC20_symbol --

0x02aebeba3810b1e6b70781f14b2d72c1cb89c0b2b320c43bb67ff79f562f5ff4

it should return ETH in felt but it returns selector("ETH")

FabijanC commented 1 week ago

Ah ok, now I see what you mean; the value assigned to the key is wrong, not the key itself.

FabijanC commented 1 week ago

Feel free to review: https://github.com/0xSpaceShard/starknet-devnet-rs/pull/546