difftreelog
refactor extract EvmAddressMapping primitive
in: master
10 files changed
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -15,10 +15,10 @@
sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
+up-evm-mapping = { default-features = false, path = '../../primitives/evm-mapping' }
nft-data-structs = { default-features = false, path = '../../primitives/nft' }
pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
serde = { version = "1.0.130", default-features = false }
scale-info = { version = "1.0.0", default-features = false, features = [
@@ -32,6 +32,7 @@
"frame-system/std",
"sp-runtime/std",
"sp-std/std",
+ "up-evm-mapping/std",
"nft-data-structs/std",
"pallet-evm/std",
]
pallets/common/src/account.rsdiffbeforeafterboth--- a/pallets/common/src/account.rs
+++ b/pallets/common/src/account.rs
@@ -2,12 +2,12 @@
use codec::{Encode, EncodeLike, Decode};
use sp_core::H160;
use scale_info::{Type, TypeInfo};
-use sp_core::crypto::AccountId32;
use core::cmp::Ordering;
use serde::{Serialize, Deserialize};
use pallet_evm::AddressMapping;
use sp_std::vec::Vec;
use sp_std::clone::Clone;
+use up_evm_mapping::EvmBackwardsAddressMapping;
pub trait CrossAccountId<AccountId>:
Encode + EncodeLike + Decode + TypeInfo + Clone + PartialEq + Ord + core::fmt::Debug + Default
@@ -174,19 +174,5 @@
} else {
BasicCrossAccountIdRepr::Substrate(v.as_sub().clone())
}
- }
-}
-
-pub trait EvmBackwardsAddressMapping<AccountId> {
- fn from_account_id(account_id: AccountId) -> H160;
-}
-
-/// Should have same mapping as EnsureAddressTruncated
-pub struct MapBackwardsAddressTruncated;
-impl EvmBackwardsAddressMapping<AccountId32> for MapBackwardsAddressTruncated {
- fn from_account_id(account_id: AccountId32) -> H160 {
- let mut out = [0; 20];
- out.copy_from_slice(&(account_id.as_ref() as &[u8])[0..20]);
- H160(out)
}
}
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -141,7 +141,7 @@
pub mod pallet {
use super::*;
use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
- use account::{EvmBackwardsAddressMapping, CrossAccountId};
+ use account::CrossAccountId;
use frame_support::traits::Currency;
use nft_data_structs::TokenId;
use scale_info::TypeInfo;
@@ -153,7 +153,7 @@
type CrossAccountId: CrossAccountId<Self::AccountId>;
type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
- type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
+ type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;
type Currency: Currency<Self::AccountId>;
type CollectionCreationPrice: Get<
pallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -15,6 +15,7 @@
fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" }
+up-evm-mapping = { default-features = false, path = "../../primitives/evm-mapping" }
[dependencies.codec]
default-features = false
@@ -35,4 +36,5 @@
"pallet-ethereum/std",
"fp-evm/std",
"up-sponsorship/std",
+ "up-evm-mapping/std",
]
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -1,6 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
+use up_evm_mapping::EvmBackwardsAddressMapping;
#[frame_support::pallet]
pub mod pallet {
@@ -20,6 +21,7 @@
pub trait Config: frame_system::Config {
type SponsorshipHandler: SponsorshipHandler<H160, (H160, Vec<u8>)>;
type Currency: Currency<Self::AccountId>;
+ type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
}
#[pallet::pallet]
pallets/nft/Cargo.tomldiffbeforeafterboth--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -34,6 +34,7 @@
'fp-evm/std',
'nft-data-structs/std',
'up-sponsorship/std',
+ 'up-evm-mapping/std',
'sp-std/std',
'sp-api/std',
'sp-runtime/std',
@@ -135,7 +136,7 @@
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" }
-
+up-evm-mapping = { default-features = false, path = "../../primitives/evm-mapping" }
evm-coder = { default-features = false, path = "../../crates/evm-coder" }
pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
primitive-types = { version = "0.10.1", default-features = false, features = [
primitives/evm-mapping/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/primitives/evm-mapping/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "up-evm-mapping"
+version = "0.1.0"
+edition = "2018"
+
+[dependencies]
+sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
+frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
+
+[features]
+default = ["std"]
+std = [
+ "sp-core/std",
+ "frame-support/std",
+]
primitives/evm-mapping/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/primitives/evm-mapping/src/lib.rs
@@ -0,0 +1,23 @@
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use frame_support::sp_runtime::AccountId32;
+use sp_core::H160;
+
+/// Transforms substrate addresses to ethereum (Reverse of `EvmAddressMapping`)
+/// pallet_evm doesn't have this, as it only checks if eth address
+/// is owned by substrate via `EnsureAddressOrigin` trait
+///
+/// This trait implementations shouldn't conflict with used `EnsureAddressOrigin`
+pub trait EvmBackwardsAddressMapping<AccountId> {
+ fn from_account_id(account_id: AccountId) -> H160;
+}
+
+/// Should have same mapping as EnsureAddressTruncated
+pub struct MapBackwardsAddressTruncated;
+impl EvmBackwardsAddressMapping<AccountId32> for MapBackwardsAddressTruncated {
+ fn from_account_id(account_id: AccountId32) -> H160 {
+ let mut out = [0; 20];
+ out.copy_from_slice(&(account_id.as_ref() as &[u8])[0..20]);
+ H160(out)
+ }
+}
runtime/Cargo.tomldiffbeforeafterboth1################################################################################2# Package34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Substrate node nft'8edition = '2018'9homepage = 'https://unique.network'10license = 'All Rights Reserved'11name = 'nft-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'13version = '0.9.12'1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['std']20runtime-benchmarks = [21 'hex-literal',22 'frame-benchmarking',23 'frame-support/runtime-benchmarks',24 'frame-system-benchmarking',25 'frame-system/runtime-benchmarks',26 'pallet-evm-migration/runtime-benchmarks',27 'pallet-balances/runtime-benchmarks',28 'pallet-timestamp/runtime-benchmarks',29 'pallet-common/runtime-benchmarks',30 'pallet-fungible/runtime-benchmarks',31 'pallet-refungible/runtime-benchmarks',32 'pallet-nonfungible/runtime-benchmarks',33 'pallet-nft/runtime-benchmarks',34 'pallet-inflation/runtime-benchmarks',35 'pallet-xcm/runtime-benchmarks',36 'sp-runtime/runtime-benchmarks',37 'xcm-builder/runtime-benchmarks',38]39std = [40 'codec/std',41 'cumulus-pallet-aura-ext/std',42 'cumulus-pallet-parachain-system/std',43 'cumulus-pallet-xcm/std',44 'cumulus-pallet-xcmp-queue/std',45 'cumulus-primitives-core/std',46 'cumulus-primitives-utility/std',47 'frame-executive/std',48 'frame-support/std',49 'frame-system/std',50 'frame-system-rpc-runtime-api/std',51 'pallet-aura/std',52 'pallet-balances/std',53 # 'pallet-contracts/std',54 # 'pallet-contracts-primitives/std',55 # 'pallet-contracts-rpc-runtime-api/std',56 # 'pallet-contract-helpers/std',57 'pallet-randomness-collective-flip/std',58 'pallet-sudo/std',59 'pallet-timestamp/std',60 'pallet-transaction-payment/std',61 'pallet-transaction-payment-rpc-runtime-api/std',62 'pallet-treasury/std',63 # 'pallet-vesting/std',64 'pallet-evm/std',65 'pallet-evm-migration/std',66 'pallet-evm-contract-helpers/std',67 'pallet-evm-transaction-payment/std',68 'pallet-evm-coder-substrate/std',69 'pallet-ethereum/std',70 'fp-rpc/std',71 'up-rpc/std',72 'fp-self-contained/std',73 'parachain-info/std',74 'serde',75 'pallet-inflation/std',76 'pallet-common/std',77 'pallet-fungible/std',78 'pallet-refungible/std',79 'pallet-nonfungible/std',80 'pallet-nft/std',81 'pallet-unq-scheduler/std',82 'pallet-nft-charge-transaction/std',83 'nft-data-structs/std',84 'sp-api/std',85 'sp-block-builder/std',86 "sp-consensus-aura/std",87 'sp-core/std',88 'sp-inherents/std',89 'sp-io/std',90 'sp-offchain/std',91 'sp-runtime/std',92 'sp-session/std',93 'sp-std/std',94 'sp-transaction-pool/std',95 'sp-version/std',96 'xcm/std',97 'xcm-builder/std',98 'xcm-executor/std',99100 "orml-vesting/std",101]102limit-testing = ['pallet-nft/limit-testing', 'nft-data-structs/limit-testing']103104################################################################################105# Substrate Dependencies106107[dependencies.codec]108default-features = false109features = ['derive']110package = 'parity-scale-codec'111version = '2.3.0'112113[dependencies.frame-benchmarking]114default-features = false115git = 'https://github.com/paritytech/substrate.git'116optional = true117branch = 'polkadot-v0.9.12'118119[dependencies.frame-executive]120default-features = false121git = 'https://github.com/paritytech/substrate.git'122branch = 'polkadot-v0.9.12'123124[dependencies.frame-support]125default-features = false126git = 'https://github.com/paritytech/substrate.git'127branch = 'polkadot-v0.9.12'128129[dependencies.frame-system]130default-features = false131git = 'https://github.com/paritytech/substrate.git'132branch = 'polkadot-v0.9.12'133134[dependencies.frame-system-benchmarking]135default-features = false136git = 'https://github.com/paritytech/substrate.git'137optional = true138branch = 'polkadot-v0.9.12'139140[dependencies.frame-system-rpc-runtime-api]141default-features = false142git = 'https://github.com/paritytech/substrate.git'143branch = 'polkadot-v0.9.12'144145[dependencies.hex-literal]146optional = true147version = '0.3.3'148149[dependencies.serde]150default-features = false151features = ['derive']152optional = true153version = '1.0.130'154155[dependencies.pallet-aura]156default-features = false157git = 'https://github.com/paritytech/substrate.git'158branch = 'polkadot-v0.9.12'159160[dependencies.pallet-balances]161default-features = false162git = 'https://github.com/paritytech/substrate.git'163branch = 'polkadot-v0.9.12'164165# Contracts specific packages166# [dependencies.pallet-contracts]167# git = 'https://github.com/paritytech/substrate.git'168# default-features = false169# branch = 'polkadot-v0.9.12'170# version = '4.0.0-dev'171172# [dependencies.pallet-contracts-primitives]173# git = 'https://github.com/paritytech/substrate.git'174# default-features = false175# branch = 'polkadot-v0.9.12'176# version = '4.0.0-dev'177178# [dependencies.pallet-contracts-rpc-runtime-api]179# git = 'https://github.com/paritytech/substrate.git'180# default-features = false181# branch = 'polkadot-v0.9.12'182# version = '4.0.0-dev'183184[dependencies.pallet-randomness-collective-flip]185default-features = false186git = 'https://github.com/paritytech/substrate.git'187branch = 'polkadot-v0.9.12'188189[dependencies.pallet-sudo]190default-features = false191git = 'https://github.com/paritytech/substrate.git'192branch = 'polkadot-v0.9.12'193194[dependencies.pallet-timestamp]195default-features = false196git = 'https://github.com/paritytech/substrate.git'197branch = 'polkadot-v0.9.12'198199[dependencies.pallet-transaction-payment]200default-features = false201git = 'https://github.com/paritytech/substrate.git'202branch = 'polkadot-v0.9.12'203204[dependencies.pallet-transaction-payment-rpc-runtime-api]205default-features = false206git = 'https://github.com/paritytech/substrate.git'207branch = 'polkadot-v0.9.12'208209[dependencies.pallet-treasury]210default-features = false211git = 'https://github.com/paritytech/substrate.git'212branch = 'polkadot-v0.9.12'213214# [dependencies.pallet-vesting]215# default-features = false216# git = 'https://github.com/paritytech/substrate.git'217# branch = 'polkadot-v0.9.12'218219[dependencies.sp-arithmetic]220default-features = false221git = 'https://github.com/paritytech/substrate.git'222branch = 'polkadot-v0.9.12'223224[dependencies.sp-api]225default-features = false226git = 'https://github.com/paritytech/substrate.git'227branch = 'polkadot-v0.9.12'228229[dependencies.sp-block-builder]230default-features = false231git = 'https://github.com/paritytech/substrate.git'232branch = 'polkadot-v0.9.12'233234[dependencies.sp-core]235default-features = false236git = 'https://github.com/paritytech/substrate.git'237branch = 'polkadot-v0.9.12'238239[dependencies.sp-consensus-aura]240default-features = false241git = 'https://github.com/paritytech/substrate.git'242branch = 'polkadot-v0.9.12'243244[dependencies.sp-inherents]245default-features = false246git = 'https://github.com/paritytech/substrate.git'247branch = 'polkadot-v0.9.12'248249[dependencies.sp-io]250default-features = false251git = 'https://github.com/paritytech/substrate.git'252branch = 'polkadot-v0.9.12'253254[dependencies.sp-offchain]255default-features = false256git = 'https://github.com/paritytech/substrate.git'257branch = 'polkadot-v0.9.12'258259[dependencies.sp-runtime]260default-features = false261git = 'https://github.com/paritytech/substrate.git'262branch = 'polkadot-v0.9.12'263264[dependencies.sp-session]265default-features = false266git = 'https://github.com/paritytech/substrate.git'267branch = 'polkadot-v0.9.12'268269[dependencies.sp-std]270default-features = false271git = 'https://github.com/paritytech/substrate.git'272branch = 'polkadot-v0.9.12'273274[dependencies.sp-transaction-pool]275default-features = false276git = 'https://github.com/paritytech/substrate.git'277branch = 'polkadot-v0.9.12'278279[dependencies.sp-version]280default-features = false281git = 'https://github.com/paritytech/substrate.git'282branch = 'polkadot-v0.9.12'283284[dependencies.smallvec]285version = '1.6.1'286287################################################################################288# Cumulus dependencies289290[dependencies.parachain-info]291default-features = false292git = 'https://github.com/paritytech/cumulus.git'293branch = 'polkadot-v0.9.12'294295[dependencies.cumulus-pallet-aura-ext]296git = 'https://github.com/paritytech/cumulus.git'297branch = 'polkadot-v0.9.12'298default-features = false299300[dependencies.cumulus-pallet-parachain-system]301git = 'https://github.com/paritytech/cumulus.git'302branch = 'polkadot-v0.9.12'303default-features = false304305[dependencies.cumulus-primitives-core]306git = 'https://github.com/paritytech/cumulus.git'307branch = 'polkadot-v0.9.12'308default-features = false309310[dependencies.cumulus-pallet-xcm]311git = 'https://github.com/paritytech/cumulus.git'312branch = 'polkadot-v0.9.12'313default-features = false314315[dependencies.cumulus-pallet-dmp-queue]316git = 'https://github.com/paritytech/cumulus.git'317branch = 'polkadot-v0.9.12'318default-features = false319320[dependencies.cumulus-pallet-xcmp-queue]321git = 'https://github.com/paritytech/cumulus.git'322branch = 'polkadot-v0.9.12'323default-features = false324325[dependencies.cumulus-primitives-utility]326git = 'https://github.com/paritytech/cumulus.git'327branch = 'polkadot-v0.9.12'328default-features = false329330[dependencies.cumulus-primitives-timestamp]331git = 'https://github.com/paritytech/cumulus.git'332branch = 'polkadot-v0.9.12'333default-features = false334335################################################################################336# Polkadot dependencies337338[dependencies.polkadot-parachain]339git = 'https://github.com/paritytech/polkadot'340branch = 'release-v0.9.12'341default-features = false342343[dependencies.xcm]344git = 'https://github.com/paritytech/polkadot'345branch = 'release-v0.9.12'346default-features = false347348[dependencies.xcm-builder]349git = 'https://github.com/paritytech/polkadot'350branch = 'release-v0.9.12'351default-features = false352353[dependencies.xcm-executor]354git = 'https://github.com/paritytech/polkadot'355branch = 'release-v0.9.12'356default-features = false357358[dependencies.pallet-xcm]359git = 'https://github.com/paritytech/polkadot'360branch = 'release-v0.9.12'361default-features = false362363[dependencies.orml-vesting]364git = "https://github.com/open-web3-stack/open-runtime-module-library"365version = "0.4.1-dev" 366default-features = false367368################################################################################369# local dependencies370371[dependencies]372scale-info = { version = "1.0.0", default-features = false, features = [373 "derive",374] }375derivative = "2.2.0"376pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }377up-rpc = { path = "../primitives/rpc", default-features = false }378pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }379nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }380pallet-common = { default-features = false, path = "../pallets/common" }381pallet-fungible = { default-features = false, path = "../pallets/fungible" }382pallet-refungible = { default-features = false, path = "../pallets/refungible" }383pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }384pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }385# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }386pallet-nft-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }387pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }388pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }389pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }390pallet-evm-coder-substrate = { default-features = false, path = "../pallets/evm-coder-substrate" }391392pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }393pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }394fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }395fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }396397################################################################################398# Build Dependencies399400[build-dependencies.substrate-wasm-builder]401git = 'https://github.com/paritytech/substrate.git'402branch = 'polkadot-v0.9.12'runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -736,7 +736,7 @@
impl pallet_common::Config for Runtime {
type Event = Event;
- type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
@@ -811,6 +811,7 @@
pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,
);
type Currency = Balances;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
}
impl pallet_nft_charge_transaction::Config for Runtime {