--- a/Cargo.lock +++ b/Cargo.lock @@ -2345,7 +2345,7 @@ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "async-trait", "fc-db", @@ -2364,7 +2364,7 @@ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "fp-storage", "kvdb-rocksdb", @@ -2380,7 +2380,7 @@ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "fc-db", "fp-consensus", @@ -2397,7 +2397,7 @@ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "ethereum-types", @@ -2437,7 +2437,7 @@ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "ethereum-types", @@ -2578,7 +2578,7 @@ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "parity-scale-codec 3.1.5", @@ -2590,7 +2590,7 @@ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "evm", "frame-support", @@ -2604,7 +2604,7 @@ [[package]] name = "fp-evm-mapping" version = "0.1.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "frame-support", "sp-core", @@ -2613,7 +2613,7 @@ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "ethereum-types", @@ -2630,7 +2630,7 @@ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "frame-support", @@ -2646,7 +2646,7 @@ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "parity-scale-codec 3.1.5", ] @@ -5445,7 +5445,7 @@ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "fp-evm", "frame-support", @@ -5660,7 +5660,7 @@ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "ethereum", "ethereum-types", @@ -5689,7 +5689,7 @@ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c" dependencies = [ "evm", "fp-evm", @@ -12130,7 +12130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "digest 0.10.3", "rand 0.8.5", "static_assertions", --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -126,8 +126,14 @@ fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> { let sponsor = Pallet::::get_sponsor(contract_address).ok_or("Contract has no sponsor")?; - let sponsor_sub = pallet_common::eth::convert_cross_account_to_uint256::(&sponsor); - Ok((*sponsor.as_eth(), sponsor_sub)) + let result: (address, uint256) = if sponsor.is_canonical_substrate() { + let sponsor = pallet_common::eth::convert_cross_account_to_uint256::(&sponsor); + (Default::default(), sponsor) + } else { + let sponsor = *sponsor.as_eth(); + (sponsor, Default::default()) + }; + Ok(result) } /// Check tat contract has confirmed sponsor. --- a/runtime/tests/src/lib.rs +++ b/runtime/tests/src/lib.rs @@ -167,7 +167,7 @@ } #[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)] -pub struct TestCrossAccountId(u64, sp_core::H160); +pub struct TestCrossAccountId(u64, sp_core::H160, bool); impl CrossAccountId for TestCrossAccountId { fn as_sub(&self) -> &u64 { &self.0 @@ -178,17 +178,20 @@ fn from_sub(sub: u64) -> Self { let mut eth = [0; 20]; eth[12..20].copy_from_slice(&sub.to_be_bytes()); - Self(sub, sp_core::H160(eth)) + Self(sub, sp_core::H160(eth), true) } fn from_eth(eth: sp_core::H160) -> Self { let mut sub_raw = [0; 8]; sub_raw.copy_from_slice(ð.0[0..8]); let sub = u64::from_be_bytes(sub_raw); - Self(sub, eth) + Self(sub, eth, false) } fn conv_eq(&self, other: &Self) -> bool { self.as_sub() == other.as_sub() } + fn is_canonical_substrate(&self) -> bool { + self.2 + } } impl Default for TestCrossAccountId { --- a/tests/src/eth/contractSponsoring.test.ts +++ b/tests/src/eth/contractSponsoring.test.ts @@ -129,8 +129,7 @@ const result = await helpers.methods.getSponsor(flipper.options.address).call(); expect(result[0]).to.be.eq(flipper.options.address); - const sponsorSub = api.registry.createType('AccountId', '0x' + BigInt(result[1]).toString(16).padStart(64, '0')).toJSON(); - expect(sponsorSub).to.be.eq(evmToAddress(flipper.options.address)); + expect(result[1]).to.be.eq('0'); }); itWeb3('Get confirmed sponsor', async ({api, web3, privateKeyWrapper}) => { @@ -144,8 +143,7 @@ const result = await helpers.methods.getSponsor(flipper.options.address).call(); expect(result[0]).to.be.eq(sponsor); - const sponsorSub = api.registry.createType('AccountId', '0x' + BigInt(result[1]).toString(16).padStart(64, '0')).toJSON(); - expect(sponsorSub).to.be.eq(evmToAddress(sponsor)); + expect(result[1]).to.be.eq('0'); }); itWeb3('Sponsor can be removed by the address that deployed the contract', async ({api, web3, privateKeyWrapper}) => {