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

difftreelog

CORE-302 Add EvmCollection Pallet

Trubnikov Sergey2022-04-18parent: #f15380e.patch.diff
in: master

24 files changed

modifiedCargo.lockdiffbeforeafterboth
5504 "pallet-ethereum",5504 "pallet-ethereum",
5505 "pallet-evm",5505 "pallet-evm",
5506 "pallet-evm-coder-substrate",5506 "pallet-evm-coder-substrate",
5507 "pallet-evm-collection",
5507 "pallet-evm-contract-helpers",5508 "pallet-evm-contract-helpers",
5508 "pallet-evm-migration",5509 "pallet-evm-migration",
5509 "pallet-evm-transaction-payment",5510 "pallet-evm-transaction-payment",
6074 "up-data-structs",6075 "up-data-structs",
6075]6076]
6077
6078[[package]]
6079name = "pallet-evm-collection"
6080version = "0.1.0"
6081dependencies = [
6082 "ethereum",
6083 "evm-coder",
6084 "fp-evm-mapping",
6085 "frame-support",
6086 "frame-system",
6087 "log",
6088 "pallet-common",
6089 "pallet-evm",
6090 "pallet-evm-coder-substrate",
6091 "pallet-nonfungible",
6092 "parity-scale-codec",
6093 "scale-info",
6094 "sp-core",
6095 "sp-runtime",
6096 "sp-std",
6097 "up-data-structs",
6098]
60766099
6077[[package]]6100[[package]]
6078name = "pallet-evm-contract-helpers"6101name = "pallet-evm-contract-helpers"
8784 "pallet-ethereum",8807 "pallet-ethereum",
8785 "pallet-evm",8808 "pallet-evm",
8786 "pallet-evm-coder-substrate",8809 "pallet-evm-coder-substrate",
8810 "pallet-evm-collection",
8787 "pallet-evm-contract-helpers",8811 "pallet-evm-contract-helpers",
8788 "pallet-evm-migration",8812 "pallet-evm-migration",
8789 "pallet-evm-transaction-payment",8813 "pallet-evm-transaction-payment",
12845 "pallet-ethereum",12869 "pallet-ethereum",
12846 "pallet-evm",12870 "pallet-evm",
12847 "pallet-evm-coder-substrate",12871 "pallet-evm-coder-substrate",
12872 "pallet-evm-collection",
12848 "pallet-evm-contract-helpers",12873 "pallet-evm-contract-helpers",
12849 "pallet-evm-migration",12874 "pallet-evm-migration",
12850 "pallet-evm-transaction-payment",12875 "pallet-evm-transaction-payment",
modifiedMakefilediffbeforeafterboth
15CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/15CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
16CONTRACT_HELPERS_ABI=./tests/src/eth/util/contractHelpersAbi.json16CONTRACT_HELPERS_ABI=./tests/src/eth/util/contractHelpersAbi.json
17
18COLLECTION_STUBS=./pallets/evm-collection/src/stubs/
19COLLECTION_ABI=./tests/src/eth/collectionAbi.json
1720
18TESTS_API=./tests/src/eth/api/21TESTS_API=./tests/src/eth/api/
1922
32 PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh35 PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
33 PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=$(CONTRACT_HELPERS_STUBS)/$@ ./.maintain/scripts/generate_sol.sh36 PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=$(CONTRACT_HELPERS_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
37
38Collection.sol:
39 PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
40 PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_impl OUTPUT=$(COLLECTION_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
3441
35UniqueFungible: UniqueFungible.sol42UniqueFungible: UniqueFungible.sol
36 INPUT=$(FUNGIBLE_EVM_STUBS)/$< OUTPUT=$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw ./.maintain/scripts/compile_stub.sh43 INPUT=$(FUNGIBLE_EVM_STUBS)/$< OUTPUT=$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw ./.maintain/scripts/compile_stub.sh
44 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh51 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh
45 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_ABI) ./.maintain/scripts/generate_abi.sh52 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_ABI) ./.maintain/scripts/generate_abi.sh
53
54Collection: Collection.sol
55 INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_STUBS)/Collection.raw ./.maintain/scripts/compile_stub.sh
56 INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_ABI) ./.maintain/scripts/generate_abi.sh
4657
47evm_stubs: UniqueFungible UniqueNFT ContractHelpers58evm_stubs: UniqueFungible UniqueNFT ContractHelpers Collection
4859
49.PHONY: _bench60.PHONY: _bench
50_bench:61_bench:
addedpallets/evm-collection/Cargo.tomldiffbeforeafterboth

no changes

addedpallets/evm-collection/src/eth.rsdiffbeforeafterboth

no changes

addedpallets/evm-collection/src/lib.rsdiffbeforeafterboth

no changes

addedpallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterboth

binary blob — no preview

addedpallets/evm-collection/src/stubs/Collection.soldiffbeforeafterboth

no changes

modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
20use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};20use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
21use pallet_evm::{21use pallet_evm::{
22 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,22 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,
23 account::CrossAccountId, Pallet as PalletEvm23 account::CrossAccountId
24};24};
25use sp_core::H160;25use sp_core::H160;
26use up_data_structs::{
27 CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
28 MAX_COLLECTION_NAME_LENGTH,
29};
30use crate::{26use crate::{
31 AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringRateLimit, SponsoringModeT,27 AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringRateLimit, SponsoringModeT,
32};28};
33use frame_support::traits::Get;29use frame_support::traits::Get;
34use up_sponsorship::SponsorshipHandler;30use up_sponsorship::SponsorshipHandler;
35use sp_std::vec::Vec;31use sp_std::vec::Vec;
36use alloc::format;
3732
38struct ContractHelpers<T: Config>(SubstrateRecorder<T>);33struct ContractHelpers<T: Config>(SubstrateRecorder<T>);
39impl<T: Config> WithRecorder<T> for ContractHelpers<T> {34impl<T: Config> WithRecorder<T> for ContractHelpers<T> {
143 Ok(())138 Ok(())
144 }139 }
145
146 fn create_721_collection(
147 &self,
148 caller: caller,
149 name: string,
150 description: string,
151 token_prefix: string,
152 ) -> Result<address> {
153 let caller = T::CrossAccountId::from_eth(caller);
154 let name = name
155 .encode_utf16()
156 .collect::<Vec<u16>>()
157 .try_into()
158 .map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;
159 let description = description
160 .encode_utf16()
161 .collect::<Vec<u16>>()
162 .try_into()
163 .map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;
164 let token_prefix = token_prefix
165 .into_bytes()
166 .try_into()
167 .map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;
168
169 let data = CreateCollectionData {
170 name,
171 description,
172 token_prefix,
173 ..Default::default()
174 };
175
176 let collection_id =
177 <pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)
178 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
179
180 let address = pallet_common::eth::collection_id_to_address(collection_id);
181
182 <PalletEvm<T>>::deposit_log(
183 ContractHelperEvent::CollectionCreated {
184 owner: *caller.as_eth(),
185 collection_id: address,
186 }
187 .to_log(address),
188 );
189 Ok(address)
190 }
191}140}
192
193fn error_feild_too_long(feild: &str, bound: u32) -> Error {
194 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))
195}
196141
197pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);142pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);
198impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T> {143impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T> {
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
1616
17#![cfg_attr(not(feature = "std"), no_std)]17#![cfg_attr(not(feature = "std"), no_std)]
18
19#[macro_use(format)]
20extern crate alloc;
2118
22use codec::{Decode, Encode, MaxEncodedLen};19use codec::{Decode, Encode, MaxEncodedLen};
23pub use pallet::*;20pub use pallet::*;
addedpallets/evm-contract-helpers/src/stubs/Collection.soldiffbeforeafterboth

no changes

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
21 }21 }
22}22}
2323
24// Selector: ee5467a824// Selector: 7b4866f9
25contract ContractHelpers is Dummy, ERC165 {25contract ContractHelpers is Dummy, ERC165 {
26 // Selector: contractOwner(address) 5152b14c26 // Selector: contractOwner(address) 5152b14c
27 function contractOwner(address contractAddress)27 function contractOwner(address contractAddress)
145 dummy = 0;145 dummy = 0;
146 }146 }
147
148 // Selector: create721Collection(string,string,string) 951c0151
149 function create721Collection(
150 string memory name,
151 string memory description,
152 string memory tokenPrefix
153 ) public view returns (address) {
154 require(false, stub_error);
155 name;
156 description;
157 tokenPrefix;
158 dummy;
159 return 0x0000000000000000000000000000000000000000;
160 }
161}147}
162148
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
74 'pallet-evm/std',74 'pallet-evm/std',
75 'pallet-evm-migration/std',75 'pallet-evm-migration/std',
76 'pallet-evm-contract-helpers/std',76 'pallet-evm-contract-helpers/std',
77 'pallet-evm-collection/std',
77 'pallet-evm-transaction-payment/std',78 'pallet-evm-transaction-payment/std',
78 'pallet-evm-coder-substrate/std',79 'pallet-evm-coder-substrate/std',
79 'pallet-ethereum/std',80 'pallet-ethereum/std',
417pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }418pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
418pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }419pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
419pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }420pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
421pallet-evm-collection = { path = '../../pallets/evm-collection', default-features = false }
420pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }422pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
421pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }423pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
422pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }424pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
49// A few exports that help ease life for downstream crates.49// A few exports that help ease life for downstream crates.
50pub use pallet_balances::Call as BalancesCall;50pub use pallet_balances::Call as BalancesCall;
51pub use pallet_evm::{51pub use pallet_evm::{
52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall,
53};53};
54pub use frame_support::{54pub use frame_support::{
55 construct_runtime, match_types,55 construct_runtime, match_types,
306 pallet_evm_migration::OnMethodCall<Self>,306 pallet_evm_migration::OnMethodCall<Self>,
307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
308 CollectionDispatchT<Self>,308 CollectionDispatchT<Self>,
309 pallet_evm_collection::CollectionOnMethodCall<Self>,
309 );310 );
310 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
311 type ChainId = ChainId;312 type ChainId = ChainId;
975 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,976 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
976 ]);977 ]);
978
979 // 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f
980 pub const EvmCollectionAddress: H160 = H160([
981 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,
982 ]);
977}983}
978984
979impl pallet_evm_contract_helpers::Config for Runtime {985impl pallet_evm_contract_helpers::Config for Runtime {
980 type ContractAddress = HelpersContractAddress;986 type ContractAddress = HelpersContractAddress;
981 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;987 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
982}988}
989
990impl pallet_evm_collection::Config for Runtime {
991 type ContractAddress = EvmCollectionAddress;
992}
983993
984construct_runtime!(994construct_runtime!(
985 pub enum Runtime where995 pub enum Runtime where
1033 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1043 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
1034 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1044 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
1035 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1045 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
1046 EvmCollection: pallet_evm_collection::{Pallet} = 154,
1036 }1047 }
1037);1048);
10381049
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
74 'pallet-evm/std',74 'pallet-evm/std',
75 'pallet-evm-migration/std',75 'pallet-evm-migration/std',
76 'pallet-evm-contract-helpers/std',76 'pallet-evm-contract-helpers/std',
77 'pallet-evm-collection/std',
77 'pallet-evm-transaction-payment/std',78 'pallet-evm-transaction-payment/std',
78 'pallet-evm-coder-substrate/std',79 'pallet-evm-coder-substrate/std',
79 'pallet-ethereum/std',80 'pallet-ethereum/std',
422pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }423pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
423pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }424pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
424pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }425pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
426pallet-evm-collection = { path = '../../pallets/evm-collection', default-features = false }
425pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }427pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
426pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }428pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
427pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }429pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
79};79};
80use smallvec::smallvec;80use smallvec::smallvec;
81use codec::{Encode, Decode};81use codec::{Encode, Decode};
82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
83use fp_rpc::TransactionStatus;83use fp_rpc::TransactionStatus;
84use sp_runtime::{84use sp_runtime::{
85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
278 pallet_evm_migration::OnMethodCall<Self>,278 pallet_evm_migration::OnMethodCall<Self>,
279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
280 CollectionDispatchT<Self>,280 CollectionDispatchT<Self>,
281 pallet_evm_collection::CollectionOnMethodCall<Self>,
281 );282 );
282 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;283 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
283 type ChainId = ChainId;284 type ChainId = ChainId;
952 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,953 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
953 ]);954 ]);
955
956 // 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f
957 pub const EvmCollectionAddress: H160 = H160([
958 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,
959 ]);
954}960}
955961
956impl pallet_evm_contract_helpers::Config for Runtime {962impl pallet_evm_contract_helpers::Config for Runtime {
957 type ContractAddress = HelpersContractAddress;963 type ContractAddress = HelpersContractAddress;
958 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;964 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
959}965}
966
967impl pallet_evm_collection::Config for Runtime {
968 type ContractAddress = EvmCollectionAddress;
969}
960970
961construct_runtime!(971construct_runtime!(
962 pub enum Runtime where972 pub enum Runtime where
1010 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1020 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
1011 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1021 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
1012 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1022 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
1023 EvmCollection: pallet_evm_collection::{Pallet} = 154,
1013 }1024 }
1014);1025);
10151026
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
75 'pallet-evm/std',75 'pallet-evm/std',
76 'pallet-evm-migration/std',76 'pallet-evm-migration/std',
77 'pallet-evm-contract-helpers/std',77 'pallet-evm-contract-helpers/std',
78 'pallet-evm-collection/std',
78 'pallet-evm-transaction-payment/std',79 'pallet-evm-transaction-payment/std',
79 'pallet-evm-coder-substrate/std',80 'pallet-evm-coder-substrate/std',
80 'pallet-ethereum/std',81 'pallet-ethereum/std',
414pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }415pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
415pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }416pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
416pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }417pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
418pallet-evm-collection = { path = '../../pallets/evm-collection', default-features = false }
417pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }419pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
418pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }420pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
419pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }421pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
49// A few exports that help ease life for downstream crates.49// A few exports that help ease life for downstream crates.
50pub use pallet_balances::Call as BalancesCall;50pub use pallet_balances::Call as BalancesCall;
51pub use pallet_evm::{51pub use pallet_evm::{
52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall,
53};53};
54pub use frame_support::{54pub use frame_support::{
55 construct_runtime, match_types,55 construct_runtime, match_types,
282 pallet_evm_migration::OnMethodCall<Self>,282 pallet_evm_migration::OnMethodCall<Self>,
283 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,283 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
284 CollectionDispatchT<Self>,284 CollectionDispatchT<Self>,
285 pallet_evm_collection::CollectionOnMethodCall<Self>,
285 );286 );
286 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;287 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
287 type ChainId = ChainId;288 type ChainId = ChainId;
957 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,958 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
958 ]);959 ]);
960
961 // 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f
962 pub const EvmCollectionAddress: H160 = H160([
963 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,
964 ]);
959}965}
960966
961impl pallet_evm_contract_helpers::Config for Runtime {967impl pallet_evm_contract_helpers::Config for Runtime {
962 type ContractAddress = HelpersContractAddress;968 type ContractAddress = HelpersContractAddress;
963 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;969 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
964}970}
971
972impl pallet_evm_collection::Config for Runtime {
973 type ContractAddress = EvmCollectionAddress;
974}
965975
966construct_runtime!(976construct_runtime!(
967 pub enum Runtime where977 pub enum Runtime where
1015 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1025 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
1016 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1026 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
1017 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1027 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
1028 EvmCollection: pallet_evm_collection::{Pallet} = 154,
1018 }1029 }
1019);1030);
10201031
addedtests/src/eth/api/Collection.soldiffbeforeafterboth

no changes

modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);
13}13}
1414
15// Selector: ee5467a815// Selector: 7b4866f9
16interface ContractHelpers is Dummy, ERC165 {16interface ContractHelpers is Dummy, ERC165 {
17 // Selector: contractOwner(address) 5152b14c17 // Selector: contractOwner(address) 5152b14c
18 function contractOwner(address contractAddress)18 function contractOwner(address contractAddress)
72 bool allowed72 bool allowed
73 ) external;73 ) external;
74
75 // Selector: create721Collection(string,string,string) 951c0151
76 function create721Collection(
77 string memory name,
78 string memory description,
79 string memory tokenPrefix
80 ) external view returns (address);
81}74}
8275
addedtests/src/eth/collectionAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';18import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';
19import {collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';19import {collectionHelper, collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';
2020
21describe('Create collection from EVM', () => {21describe('Create collection from EVM', () => {
22 itWeb3('Create collection', async ({api, web3}) => {22 itWeb3('Create collection', async ({api, web3}) => {
23 const owner = await createEthAccountWithBalance(api, web3);23 const owner = await createEthAccountWithBalance(api, web3);
24 const helpers = contractHelpers(web3, owner);24 const helpers = collectionHelper(web3, owner);
25 const collectionName = 'CollectionEVM';25 const collectionName = 'CollectionEVM';
26 const description = 'Some description';26 const description = 'Some description';
27 const tokenPrefix = 'token prefix';27 const tokenPrefix = 'token prefix';
modifiedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth
39 "stateMutability": "view",39 "stateMutability": "view",
40 "type": "function"40 "type": "function"
41 },41 },
42 {
43 "inputs": [
44 { "internalType": "string", "name": "name", "type": "string" },
45 { "internalType": "string", "name": "description", "type": "string" },
46 { "internalType": "string", "name": "tokenPrefix", "type": "string" }
47 ],
48 "name": "create721Collection",
49 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
50 "stateMutability": "view",
51 "type": "function"
52 },
53 {42 {
54 "inputs": [43 "inputs": [
55 {44 {
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
28import config from '../../config';28import config from '../../config';
29import privateKey from '../../substrate/privateKey';29import privateKey from '../../substrate/privateKey';
30import contractHelpersAbi from './contractHelpersAbi.json';30import contractHelpersAbi from './contractHelpersAbi.json';
31import collectionAbi from '../collectionAbi.json';
31import getBalance from '../../substrate/get-balance';32import getBalance from '../../substrate/get-balance';
32import waitNewBlocks from '../../substrate/wait-new-blocks';33import waitNewBlocks from '../../substrate/wait-new-blocks';
3334
273 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});274 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});
274}275}
276
277/**
278 * pallet evm_collection
279 * @param web3
280 * @param caller - eth address
281 * @returns
282 */
283export function collectionHelper(web3: Web3, caller: string) {
284 return new web3.eth.Contract(collectionAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, ...GAS_ARGS});
285}
275286
276/**287/**
277 * Execute ethereum method call using substrate account288 * Execute ethereum method call using substrate account