difftreelog
fix Return sponsor address in canonical form.
in: master
4 files changed
Cargo.lockdiffbeforeafterboth2345[[package]]2345[[package]]2346name = "fc-consensus"2346name = "fc-consensus"2347version = "2.0.0-dev"2347version = "2.0.0-dev"2348source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2348source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2349dependencies = [2349dependencies = [2350 "async-trait",2350 "async-trait",2351 "fc-db",2351 "fc-db",2364[[package]]2364[[package]]2365name = "fc-db"2365name = "fc-db"2366version = "2.0.0-dev"2366version = "2.0.0-dev"2367source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2367source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2368dependencies = [2368dependencies = [2369 "fp-storage",2369 "fp-storage",2370 "kvdb-rocksdb",2370 "kvdb-rocksdb",2380[[package]]2380[[package]]2381name = "fc-mapping-sync"2381name = "fc-mapping-sync"2382version = "2.0.0-dev"2382version = "2.0.0-dev"2383source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2383source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2384dependencies = [2384dependencies = [2385 "fc-db",2385 "fc-db",2386 "fp-consensus",2386 "fp-consensus",2397[[package]]2397[[package]]2398name = "fc-rpc"2398name = "fc-rpc"2399version = "2.0.0-dev"2399version = "2.0.0-dev"2400source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2400source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2401dependencies = [2401dependencies = [2402 "ethereum",2402 "ethereum",2403 "ethereum-types",2403 "ethereum-types",2437[[package]]2437[[package]]2438name = "fc-rpc-core"2438name = "fc-rpc-core"2439version = "1.1.0-dev"2439version = "1.1.0-dev"2440source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2440source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2441dependencies = [2441dependencies = [2442 "ethereum",2442 "ethereum",2443 "ethereum-types",2443 "ethereum-types",2578[[package]]2578[[package]]2579name = "fp-consensus"2579name = "fp-consensus"2580version = "2.0.0-dev"2580version = "2.0.0-dev"2581source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2581source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2582dependencies = [2582dependencies = [2583 "ethereum",2583 "ethereum",2584 "parity-scale-codec 3.1.5",2584 "parity-scale-codec 3.1.5",2590[[package]]2590[[package]]2591name = "fp-evm"2591name = "fp-evm"2592version = "3.0.0-dev"2592version = "3.0.0-dev"2593source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2593source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2594dependencies = [2594dependencies = [2595 "evm",2595 "evm",2596 "frame-support",2596 "frame-support",2604[[package]]2604[[package]]2605name = "fp-evm-mapping"2605name = "fp-evm-mapping"2606version = "0.1.0"2606version = "0.1.0"2607source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2607source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2608dependencies = [2608dependencies = [2609 "frame-support",2609 "frame-support",2610 "sp-core",2610 "sp-core",2613[[package]]2613[[package]]2614name = "fp-rpc"2614name = "fp-rpc"2615version = "3.0.0-dev"2615version = "3.0.0-dev"2616source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2616source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2617dependencies = [2617dependencies = [2618 "ethereum",2618 "ethereum",2619 "ethereum-types",2619 "ethereum-types",2630[[package]]2630[[package]]2631name = "fp-self-contained"2631name = "fp-self-contained"2632version = "1.0.0-dev"2632version = "1.0.0-dev"2633source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2633source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2634dependencies = [2634dependencies = [2635 "ethereum",2635 "ethereum",2636 "frame-support",2636 "frame-support",2646[[package]]2646[[package]]2647name = "fp-storage"2647name = "fp-storage"2648version = "2.0.0"2648version = "2.0.0"2649source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"2649source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"2650dependencies = [2650dependencies = [2651 "parity-scale-codec 3.1.5",2651 "parity-scale-codec 3.1.5",2652]2652]5445[[package]]5445[[package]]5446name = "pallet-base-fee"5446name = "pallet-base-fee"5447version = "1.0.0"5447version = "1.0.0"5448source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"5448source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"5449dependencies = [5449dependencies = [5450 "fp-evm",5450 "fp-evm",5451 "frame-support",5451 "frame-support",5660[[package]]5660[[package]]5661name = "pallet-ethereum"5661name = "pallet-ethereum"5662version = "4.0.0-dev"5662version = "4.0.0-dev"5663source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"5663source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"5664dependencies = [5664dependencies = [5665 "ethereum",5665 "ethereum",5666 "ethereum-types",5666 "ethereum-types",5689[[package]]5689[[package]]5690name = "pallet-evm"5690name = "pallet-evm"5691version = "6.0.0-dev"5691version = "6.0.0-dev"5692source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#64915c0986fcf2bbe942794b838c0cf359c93c21"5692source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.27#69945f20e8dc06ab9e0dd636848a8db6a408c71c"5693dependencies = [5693dependencies = [5694 "evm",5694 "evm",5695 "fp-evm",5695 "fp-evm",12130source = "registry+https://github.com/rust-lang/crates.io-index"12130source = "registry+https://github.com/rust-lang/crates.io-index"12131checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"12131checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"12132dependencies = [12132dependencies = [12133 "cfg-if 1.0.0",12133 "cfg-if 0.1.10",12134 "digest 0.10.3",12134 "digest 0.10.3",12135 "rand 0.8.5",12135 "rand 0.8.5",12136 "static_assertions",12136 "static_assertions",pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth126 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {126 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {127 let sponsor =127 let sponsor =128 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;128 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;129 let result: (address, uint256) = if sponsor.is_canonical_substrate() {129 let sponsor_sub = pallet_common::eth::convert_cross_account_to_uint256::<T>(&sponsor);130 let sponsor = pallet_common::eth::convert_cross_account_to_uint256::<T>(&sponsor);131 (Default::default(), sponsor)132 } else {130 Ok((*sponsor.as_eth(), sponsor_sub))133 let sponsor = *sponsor.as_eth();134 (sponsor, Default::default())135 };136 Ok(result)131 }137 }132138133 /// Check tat contract has confirmed sponsor.139 /// Check tat contract has confirmed sponsor.runtime/tests/src/lib.rsdiffbeforeafterboth167}167}168168169#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]169#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]170pub struct TestCrossAccountId(u64, sp_core::H160);170pub struct TestCrossAccountId(u64, sp_core::H160, bool);171impl CrossAccountId<u64> for TestCrossAccountId {171impl CrossAccountId<u64> for TestCrossAccountId {172 fn as_sub(&self) -> &u64 {172 fn as_sub(&self) -> &u64 {173 &self.0173 &self.0178 fn from_sub(sub: u64) -> Self {178 fn from_sub(sub: u64) -> Self {179 let mut eth = [0; 20];179 let mut eth = [0; 20];180 eth[12..20].copy_from_slice(&sub.to_be_bytes());180 eth[12..20].copy_from_slice(&sub.to_be_bytes());181 Self(sub, sp_core::H160(eth))181 Self(sub, sp_core::H160(eth), true)182 }182 }183 fn from_eth(eth: sp_core::H160) -> Self {183 fn from_eth(eth: sp_core::H160) -> Self {184 let mut sub_raw = [0; 8];184 let mut sub_raw = [0; 8];185 sub_raw.copy_from_slice(ð.0[0..8]);185 sub_raw.copy_from_slice(ð.0[0..8]);186 let sub = u64::from_be_bytes(sub_raw);186 let sub = u64::from_be_bytes(sub_raw);187 Self(sub, eth)187 Self(sub, eth, false)188 }188 }189 fn conv_eq(&self, other: &Self) -> bool {189 fn conv_eq(&self, other: &Self) -> bool {190 self.as_sub() == other.as_sub()190 self.as_sub() == other.as_sub()191 }191 }192 fn is_canonical_substrate(&self) -> bool {193 self.2194 }192}195}193196194impl Default for TestCrossAccountId {197impl Default for TestCrossAccountId {tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth129 const result = await helpers.methods.getSponsor(flipper.options.address).call();129 const result = await helpers.methods.getSponsor(flipper.options.address).call();130130131 expect(result[0]).to.be.eq(flipper.options.address);131 expect(result[0]).to.be.eq(flipper.options.address);132 const sponsorSub = api.registry.createType('AccountId', '0x' + BigInt(result[1]).toString(16).padStart(64, '0')).toJSON();133 expect(sponsorSub).to.be.eq(evmToAddress(flipper.options.address));132 expect(result[1]).to.be.eq('0');134 });133 });135134136 itWeb3('Get confirmed sponsor', async ({api, web3, privateKeyWrapper}) => {135 itWeb3('Get confirmed sponsor', async ({api, web3, privateKeyWrapper}) => {144 const result = await helpers.methods.getSponsor(flipper.options.address).call();143 const result = await helpers.methods.getSponsor(flipper.options.address).call();145144146 expect(result[0]).to.be.eq(sponsor);145 expect(result[0]).to.be.eq(sponsor);147 const sponsorSub = api.registry.createType('AccountId', '0x' + BigInt(result[1]).toString(16).padStart(64, '0')).toJSON();148 expect(sponsorSub).to.be.eq(evmToAddress(sponsor));146 expect(result[1]).to.be.eq('0');149 });147 });150148151 itWeb3('Sponsor can be removed by the address that deployed the contract', async ({api, web3, privateKeyWrapper}) => {149 itWeb3('Sponsor can be removed by the address that deployed the contract', async ({api, web3, privateKeyWrapper}) => {