git.delta.rocks / unique-network / refs/commits / dd1406bcaf7f

difftreelog

refactor extract EvmAddressMapping primitive

Yaroslav Bolyukin2021-11-18parent: #1e3b702.patch.diff
in: master

10 files changed

modifiedpallets/common/Cargo.tomldiffbeforeafterboth
15sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }15sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
18up-evm-mapping = { default-features = false, path = '../../primitives/evm-mapping' }
18nft-data-structs = { default-features = false, path = '../../primitives/nft' }19nft-data-structs = { default-features = false, path = '../../primitives/nft' }
19pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }20pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
20evm-coder = { default-features = false, path = '../../crates/evm-coder' }21evm-coder = { default-features = false, path = '../../crates/evm-coder' }
32 "frame-system/std",32 "frame-system/std",
33 "sp-runtime/std",33 "sp-runtime/std",
34 "sp-std/std",34 "sp-std/std",
35 "up-evm-mapping/std",
35 "nft-data-structs/std",36 "nft-data-structs/std",
36 "pallet-evm/std",37 "pallet-evm/std",
37]38]
modifiedpallets/common/src/account.rsdiffbeforeafterboth
2use codec::{Encode, EncodeLike, Decode};2use codec::{Encode, EncodeLike, Decode};
3use sp_core::H160;3use sp_core::H160;
4use scale_info::{Type, TypeInfo};4use scale_info::{Type, TypeInfo};
5use sp_core::crypto::AccountId32;
6use core::cmp::Ordering;5use core::cmp::Ordering;
7use serde::{Serialize, Deserialize};6use serde::{Serialize, Deserialize};
8use pallet_evm::AddressMapping;7use pallet_evm::AddressMapping;
9use sp_std::vec::Vec;8use sp_std::vec::Vec;
10use sp_std::clone::Clone;9use sp_std::clone::Clone;
10use up_evm_mapping::EvmBackwardsAddressMapping;
1111
12pub trait CrossAccountId<AccountId>:12pub trait CrossAccountId<AccountId>:
13 Encode + EncodeLike + Decode + TypeInfo + Clone + PartialEq + Ord + core::fmt::Debug + Default13 Encode + EncodeLike + Decode + TypeInfo + Clone + PartialEq + Ord + core::fmt::Debug + Default
177 }177 }
178}178}
179
180pub trait EvmBackwardsAddressMapping<AccountId> {
181 fn from_account_id(account_id: AccountId) -> H160;
182}
183
184/// Should have same mapping as EnsureAddressTruncated
185pub struct MapBackwardsAddressTruncated;
186impl EvmBackwardsAddressMapping<AccountId32> for MapBackwardsAddressTruncated {
187 fn from_account_id(account_id: AccountId32) -> H160 {
188 let mut out = [0; 20];
189 out.copy_from_slice(&(account_id.as_ref() as &[u8])[0..20]);
190 H160(out)
191 }
192}
193179
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
141pub mod pallet {141pub mod pallet {
142 use super::*;142 use super::*;
143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
144 use account::{EvmBackwardsAddressMapping, CrossAccountId};144 use account::CrossAccountId;
145 use frame_support::traits::Currency;145 use frame_support::traits::Currency;
146 use nft_data_structs::TokenId;146 use nft_data_structs::TokenId;
147 use scale_info::TypeInfo;147 use scale_info::TypeInfo;
153 type CrossAccountId: CrossAccountId<Self::AccountId>;153 type CrossAccountId: CrossAccountId<Self::AccountId>;
154154
155 type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;155 type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
156 type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;156 type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;
157157
158 type Currency: Currency<Self::AccountId>;158 type Currency: Currency<Self::AccountId>;
159 type CollectionCreationPrice: Get<159 type CollectionCreationPrice: Get<
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
15fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }15fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
16pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }16pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
17up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 17up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" }
18up-evm-mapping = { default-features = false, path = "../../primitives/evm-mapping" }
1819
19[dependencies.codec]20[dependencies.codec]
20default-features = false21default-features = false
35 "pallet-ethereum/std",36 "pallet-ethereum/std",
36 "fp-evm/std",37 "fp-evm/std",
37 "up-sponsorship/std",38 "up-sponsorship/std",
39 "up-evm-mapping/std",
38]40]
3941
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3pub use pallet::*;3pub use pallet::*;
4use up_evm_mapping::EvmBackwardsAddressMapping;
45
5#[frame_support::pallet]6#[frame_support::pallet]
6pub mod pallet {7pub mod pallet {
20 pub trait Config: frame_system::Config {21 pub trait Config: frame_system::Config {
21 type SponsorshipHandler: SponsorshipHandler<H160, (H160, Vec<u8>)>;22 type SponsorshipHandler: SponsorshipHandler<H160, (H160, Vec<u8>)>;
22 type Currency: Currency<Self::AccountId>;23 type Currency: Currency<Self::AccountId>;
24 type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
23 }25 }
2426
25 #[pallet::pallet]27 #[pallet::pallet]
modifiedpallets/nft/Cargo.tomldiffbeforeafterboth
34 'fp-evm/std',34 'fp-evm/std',
35 'nft-data-structs/std',35 'nft-data-structs/std',
36 'up-sponsorship/std',36 'up-sponsorship/std',
37 'up-evm-mapping/std',
37 'sp-std/std',38 'sp-std/std',
38 'sp-api/std',39 'sp-api/std',
39 'sp-runtime/std',40 'sp-runtime/std',
135sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }136sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }
136137
137up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 138up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" }
138139up-evm-mapping = { default-features = false, path = "../../primitives/evm-mapping" }
139evm-coder = { default-features = false, path = "../../crates/evm-coder" }140evm-coder = { default-features = false, path = "../../crates/evm-coder" }
140pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }141pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
141primitive-types = { version = "0.10.1", default-features = false, features = [142primitive-types = { version = "0.10.1", default-features = false, features = [
addedprimitives/evm-mapping/Cargo.tomldiffbeforeafterboth

no changes

addedprimitives/evm-mapping/src/lib.rsdiffbeforeafterboth

no changes

modifiedruntime/Cargo.tomldiffbeforeafterboth
69 'pallet-ethereum/std',69 'pallet-ethereum/std',
70 'fp-rpc/std',70 'fp-rpc/std',
71 'up-rpc/std',71 'up-rpc/std',
72 'up-evm-mapping/std',
72 'fp-self-contained/std',73 'fp-self-contained/std',
73 'parachain-info/std',74 'parachain-info/std',
74 'serde',75 'serde',
375derivative = "2.2.0"376derivative = "2.2.0"
376pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }377pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
377up-rpc = { path = "../primitives/rpc", default-features = false }378up-rpc = { path = "../primitives/rpc", default-features = false }
379up-evm-mapping = { path = "../primitives/evm-mapping", default-features = false }
378pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }380pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
379nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }381nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }
380pallet-common = { default-features = false, path = "../pallets/common" }382pallet-common = { default-features = false, path = "../pallets/common" }
modifiedruntime/src/lib.rsdiffbeforeafterboth
736736
737impl pallet_common::Config for Runtime {737impl pallet_common::Config for Runtime {
738 type Event = Event;738 type Event = Event;
739 type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;739 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
740 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;740 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
741 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;741 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
742742
811 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,811 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,
812 );812 );
813 type Currency = Balances;813 type Currency = Balances;
814 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
814}815}
815816
816impl pallet_nft_charge_transaction::Config for Runtime {817impl pallet_nft_charge_transaction::Config for Runtime {