git.delta.rocks / unique-network / refs/commits / 686ae3536232

difftreelog

CORE-302 Refactor collection for eth

Trubnikov Sergey2022-05-24parent: #ad8f1f0.patch.diff
in: master

20 files changed

modifiedCargo.lockdiffbeforeafterboth
54675467
5468[[package]]5468[[package]]
5469name = "once_cell"5469name = "once_cell"
5470version = "1.11.0"5470version = "1.12.0"
5471source = "registry+https://github.com/rust-lang/crates.io-index"5471source = "registry+https://github.com/rust-lang/crates.io-index"
5472checksum = "7b10983b38c53aebdf33f542c6275b0f58a238129d00c4ae0e6fb59738d783ca"5472checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
54735473
5474[[package]]5474[[package]]
5475name = "opal-runtime"5475name = "opal-runtime"
6830 "parity-scale-codec 3.1.2",6830 "parity-scale-codec 3.1.2",
6831 "scale-info",6831 "scale-info",
6832 "serde",6832 "serde",
6833 "serde-json-core",
6834 "sp-core",6833 "sp-core",
6835 "sp-io",6834 "sp-io",
6836 "sp-runtime",6835 "sp-runtime",
10734 "serde_derive",10733 "serde_derive",
10735]10734]
10736
10737[[package]]
10738name = "serde-json-core"
10739version = "0.4.0"
10740source = "registry+https://github.com/rust-lang/crates.io-index"
10741checksum = "8014aeea272bca0f0779778d43253f2f3375b414185b30e6ecc4d3e4a9994781"
10742dependencies = [
10743 "ryu",
10744 "serde",
10745]
1074610735
10747[[package]]10736[[package]]
10748name = "serde_derive"10737name = "serde_derive"
1202512014
12026[[package]]12015[[package]]
12027name = "target-lexicon"12016name = "target-lexicon"
12028version = "0.12.3"12017version = "0.12.4"
12029source = "registry+https://github.com/rust-lang/crates.io-index"12018source = "registry+https://github.com/rust-lang/crates.io-index"
12030checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1"12019checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1"
1203112020
12032[[package]]12021[[package]]
12033name = "tempfile"12022name = "tempfile"
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/unique/src/eth/stubs/
19COLLECTION_ABI=./tests/src/eth/collectionAbi.json
2017
21COLLECTION_HELPER_STUBS=$(COLLECTION_STUBS)18COLLECTION_HELPER_STUBS=$(COLLECTION_STUBS)
22COLLECTION_HELPER_ABI=./tests/src/eth/collectionHelperAbi.json19COLLECTION_HELPER_ABI=./tests/src/eth/collectionHelperAbi.json
2320
24TESTS_API=./tests/src/eth/api/21TESTS_API=./tests/src/eth/api/
2522
26.PHONY: regenerate_solidity23.PHONY: regenerate_solidity
27regenerate_solidity: UniqueFungible.sol UniqueNFT.sol ContractHelpers.sol Collection.sol CollectionHelper.sol24regenerate_solidity: UniqueFungible.sol UniqueNFT.sol ContractHelpers.sol CollectionHelper.sol
2825
29UniqueFungible.sol:26UniqueFungible.sol:
30 PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh27 PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
38 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
39 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
40
41Collection.sol:
42 PACKAGE=pallet-unique NAME=eth::evm_collection::collection_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
43 PACKAGE=pallet-unique NAME=eth::evm_collection::collection_impl OUTPUT=$(COLLECTION_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
4437
45CollectionHelper.sol:38CollectionHelper.sol:
46 PACKAGE=pallet-unique NAME=eth::evm_collection::collection_helper_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh39 PACKAGE=pallet-unique NAME=eth::evm_collection::collection_helper_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
58 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
59 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
60
61Collection: Collection.sol
62 INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_STUBS)/Collection.raw ./.maintain/scripts/compile_stub.sh
63 INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_ABI) ./.maintain/scripts/generate_abi.sh
6453
65CollectionHelper: CollectionHelper.sol54CollectionHelper: CollectionHelper.sol
66 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_STUBS)/CollectionHelper.raw ./.maintain/scripts/compile_stub.sh55 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_STUBS)/CollectionHelper.raw ./.maintain/scripts/compile_stub.sh
67 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_ABI) ./.maintain/scripts/generate_abi.sh56 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_ABI) ./.maintain/scripts/generate_abi.sh
6857
69evm_stubs: UniqueFungible UniqueNFT ContractHelpers Collection CollectionHelper58evm_stubs: UniqueFungible UniqueNFT ContractHelpers CollectionHelper
7059
71.PHONY: _bench60.PHONY: _bench
72_bench:61_bench:
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use evm_coder::{solidity_interface, types::*, execution::Result};17use evm_coder::{solidity_interface, types::*, execution::{Result, Error}};
18pub use pallet_evm::{PrecompileOutput, PrecompileResult, account::CrossAccountId};18pub use pallet_evm::{PrecompileOutput, PrecompileResult, account::CrossAccountId};
19use pallet_evm_coder_substrate::dispatch_to_evm;19use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder};
20use sp_core::{H160, U256};20use sp_core::{H160, U256};
21use sp_std::vec::Vec;21use sp_std::vec::Vec;
22use up_data_structs::Property;22use up_data_structs::Property;
31 fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult>;31 fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult>;
32}32}
3333
34#[solidity_interface(name = "CollectionProperties")]34#[solidity_interface(name = "Collection")]
35impl<T: Config> CollectionHandle<T> {35impl<T: Config> CollectionHandle<T> {
36 fn set_collection_property(&mut self, caller: caller, key: string, value: bytes) -> Result<()> {36 fn set_collection_property(&mut self, caller: caller, key: string, value: bytes) -> Result<()> {
37 let caller = T::CrossAccountId::from_eth(caller);37 let caller = T::CrossAccountId::from_eth(caller);
65 Ok(prop.to_vec())65 Ok(prop.to_vec())
66 }66 }
67
68 fn eth_set_sponsor(
69 &mut self,
70 caller: caller,
71 sponsor: address,
72 ) -> Result<void> {
73 check_is_owner(caller, self)?;
74
75 let sponsor = T::CrossAccountId::from_eth(sponsor);
76 self.set_sponsor(sponsor.as_sub().clone());
77 save(self);
78 Ok(())
79 }
80
81 fn eth_confirm_sponsorship(&mut self, caller: caller) -> Result<void> {
82 let caller = T::CrossAccountId::from_eth(caller);
83 if !self.confirm_sponsorship(caller.as_sub()) {
84 return Err(Error::Revert("Caller is not set as sponsor".into()));
85 }
86 save(self);
87 Ok(())
88 }
89
90 fn set_limits(
91 &self,
92 caller: caller,
93 limits_json: string,
94 ) -> Result<void> {
95 // let mut collection = collection_from_address::<T>(self.contract_address(caller).unwrap(), self.1.gas_left())?;
96 // check_is_owner(caller, &collection)?;
97
98 // let limits = serde_json_core::from_str(limits_json.as_ref())
99 // .map_err(|e| Error::Revert(format!("Parse JSON error: {}", e)))?;
100 // collection.limits = limits.0;
101 // collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
102 Ok(())
103 }
104
105 fn contract_address(&self, _caller: caller) -> Result<address> {
106 Ok(crate::eth::collection_id_to_address(self.id))
107 }
67}108}
68109
110fn collection_from_address<T: Config>(
111 collection_address: address,
112 gas_limit: u64
113) -> Result<CollectionHandle<T>> {
114 let collection_id = crate::eth::map_eth_to_id(&collection_address)
115 .ok_or(Error::Revert("Contract is not an unique collection".into()))?;
116 let recorder = <SubstrateRecorder<T>>::new(gas_limit);
117 let collection =
118 CollectionHandle::new_with_recorder(collection_id, recorder)
119 .ok_or(Error::Revert("Create collection handle error".into()))?;
120 Ok(collection)
121}
122
123fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<()> {
124 let caller = T::CrossAccountId::from_eth(caller);
125 collection
126 .check_is_owner(&caller)
127 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
128 Ok(())
129}
130
131fn save<T: Config>(collection: &CollectionHandle<T>) {
132 <crate::CollectionById<T>>::insert(collection.id, collection.collection.clone());
133}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
2020
21use core::ops::{Deref, DerefMut};21use core::ops::{Deref, DerefMut};
22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
23use sp_std::{vec::Vec, rc::Rc};23use sp_std::vec::Vec;
24use pallet_evm::account::CrossAccountId;24use pallet_evm::account::CrossAccountId;
25use frame_support::{25use frame_support::{
26 dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},26 dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
24use pallet_evm::account::CrossAccountId;24use pallet_evm::account::CrossAccountId;
25use pallet_evm_coder_substrate::{call, dispatch_to_evm};25use pallet_evm_coder_substrate::{call, dispatch_to_evm};
26use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};26use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
27use pallet_common::{CollectionHandle, erc::CollectionPropertiesCall};27use pallet_common::{CollectionHandle, erc::CollectionCall};
2828
29use crate::{29use crate::{
30 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,30 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,
150 is(150 is(
151 ERC20,151 ERC20,
152 ERC20UniqueExtensions,152 ERC20UniqueExtensions,
153 via("CollectionHandle<T>", common_mut, CollectionProperties)153 via("CollectionHandle<T>", common_mut, Collection)
154 )154 )
155)]155)]
156impl<T: Config> FungibleHandle<T> {}156impl<T: Config> FungibleHandle<T> {}
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
26use sp_core::{H160, U256};26use sp_core::{H160, U256};
27use sp_std::vec::Vec;27use sp_std::vec::Vec;
28use pallet_common::{28use pallet_common::{
29 erc::{CommonEvmHandler, PrecompileResult, CollectionPropertiesCall},29 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
30 CollectionHandle,30 CollectionHandle,
31};31};
32use pallet_evm::account::CrossAccountId;32use pallet_evm::account::CrossAccountId;
513 ERC721UniqueExtensions,513 ERC721UniqueExtensions,
514 ERC721Mintable,514 ERC721Mintable,
515 ERC721Burnable,515 ERC721Burnable,
516 via("CollectionHandle<T>", common_mut, CollectionProperties),516 via("CollectionHandle<T>", common_mut, Collection),
517 TokenProperties,517 TokenProperties,
518 )518 )
519)]519)]
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
51 event MintingFinished();51 event MintingFinished();
52}52}
53
54// Selector: 38e33c60
55contract Collection is Dummy, ERC165 {
56 // Selector: setCollectionProperty(string,bytes) 2f073f66
57 function setCollectionProperty(string memory key, bytes memory value)
58 public
59 {
60 require(false, stub_error);
61 key;
62 value;
63 dummy = 0;
64 }
65
66 // Selector: deleteCollectionProperty(string) 7b7debce
67 function deleteCollectionProperty(string memory key) public {
68 require(false, stub_error);
69 key;
70 dummy = 0;
71 }
72
73 // Throws error if key not found
74 //
75 // Selector: collectionProperty(string) cf24fd6d
76 function collectionProperty(string memory key)
77 public
78 view
79 returns (bytes memory)
80 {
81 require(false, stub_error);
82 key;
83 dummy;
84 return hex"";
85 }
86
87 // Selector: ethSetSponsor(address) 8f9af356
88 function ethSetSponsor(address sponsor) public {
89 require(false, stub_error);
90 sponsor;
91 dummy = 0;
92 }
93
94 // Selector: ethConfirmSponsorship() a8580d1a
95 function ethConfirmSponsorship() public {
96 require(false, stub_error);
97 dummy = 0;
98 }
99
100 // Selector: setLimits(string) 72cb345d
101 function setLimits(string memory limitsJson) public view {
102 require(false, stub_error);
103 limitsJson;
104 dummy;
105 }
106
107 // Selector: contractAddress() f6b4dfb4
108 function contractAddress() public view returns (address) {
109 require(false, stub_error);
110 dummy;
111 return 0x0000000000000000000000000000000000000000;
112 }
113}
53114
54// Selector: 41369377115// Selector: 41369377
55contract TokenProperties is Dummy, ERC165 {116contract TokenProperties is Dummy, ERC165 {
330 }391 }
331}392}
332
333// Selector: 9b5e29c5
334contract CollectionProperties is Dummy, ERC165 {
335 // Selector: setCollectionProperty(string,bytes) 2f073f66
336 function setCollectionProperty(string memory key, bytes memory value)
337 public
338 {
339 require(false, stub_error);
340 key;
341 value;
342 dummy = 0;
343 }
344
345 // Selector: deleteCollectionProperty(string) 7b7debce
346 function deleteCollectionProperty(string memory key) public {
347 require(false, stub_error);
348 key;
349 dummy = 0;
350 }
351
352 // Throws error if key not found
353 //
354 // Selector: collectionProperty(string) cf24fd6d
355 function collectionProperty(string memory key)
356 public
357 view
358 returns (bytes memory)
359 {
360 require(false, stub_error);
361 key;
362 dummy;
363 return hex"";
364 }
365}
366393
367// Selector: d74d154f394// Selector: d74d154f
368contract ERC721UniqueExtensions is Dummy, ERC165 {395contract ERC721UniqueExtensions is Dummy, ERC165 {
423 ERC721UniqueExtensions,450 ERC721UniqueExtensions,
424 ERC721Mintable,451 ERC721Mintable,
425 ERC721Burnable,452 ERC721Burnable,
426 CollectionProperties,453 Collection,
427 TokenProperties454 TokenProperties
428{}455{}
429456
modifiedpallets/unique/Cargo.tomldiffbeforeafterboth
20std = [20std = [
21 'codec/std',21 'codec/std',
22 'serde/std',22 'serde/std',
23 'serde-json-core/std',
24 'frame-support/std',23 'frame-support/std',
25 'frame-system/std',24 'frame-system/std',
26 'pallet-evm/std',25 'pallet-evm/std',
43features = ['derive']42features = ['derive']
44version = '1.0.130'43version = '1.0.130'
45
46[dependencies.serde-json-core]
47default-features = false
48version = "0.4"
4944
50[dependencies.ethereum]45[dependencies.ethereum]
51version = "0.12.0"46version = "0.12.0"
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
110 }110 }
111 }111 }
112 112
113 struct EvmCollection<T: Config>(H160, SubstrateRecorder<T>);
114 impl<T: Config> WithRecorder<T> for EvmCollection<T> {
115 fn recorder(&self) -> &SubstrateRecorder<T> {
116 &self.1
117 }
118
119 fn into_recorder(self) -> SubstrateRecorder<T> {
120 self.1
121 }
122 }
123
124 #[derive(ToLog)]113 #[derive(ToLog)]
125 pub enum EthCollectionEvent {114 pub enum EthCollectionEvent {
131 },120 },
132 }121 }
133
134 #[solidity_interface(name = "Collection")]
135 impl<T: Config> EvmCollection<T> {
136 fn set_sponsor(
137 &self,
138 caller: caller,
139 sponsor: address,
140 ) -> Result<void> {
141 let mut collection = collection_from_address::<T>(self.contract_address(caller).unwrap(), self.1.gas_left())?;
142 check_is_owner(caller, &collection)?;
143
144 let sponsor = T::CrossAccountId::from_eth(sponsor);
145 collection.set_sponsor(sponsor.as_sub().clone());
146 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
147 Ok(())
148 }
149
150 fn confirm_sponsorship(&self, caller: caller) -> Result<void> {
151 let mut collection = collection_from_address::<T>(self.contract_address(caller).unwrap(), self.1.gas_left())?;
152 let caller = T::CrossAccountId::from_eth(caller);
153 if !collection.confirm_sponsorship(caller.as_sub()) {
154 return Err(Error::Revert("Caller is not set as sponsor".into()));
155 }
156 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
157 Ok(())
158 }
159
160 fn set_limits(
161 &self,
162 caller: caller,
163 limits_json: string,
164 ) -> Result<void> {
165 let mut collection = collection_from_address::<T>(self.contract_address(caller).unwrap(), self.1.gas_left())?;
166 check_is_owner(caller, &collection)?;
167
168 let limits = serde_json_core::from_str(limits_json.as_ref())
169 .map_err(|e| Error::Revert(format!("Parse JSON error: {}", e)))?;
170 collection.limits = limits.0;
171 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
172 Ok(())
173 }
174
175 fn contract_address(&self, _caller: caller) -> Result<address> {
176 Ok(self.0)
177 }
178 }
179
180 fn error_feild_too_long(feild: &str, bound: u32) -> Error {
181 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))
182 }
183
184 fn collection_from_address<T: Config>(
185 collection_address: address,
186 gas_limit: u64
187 ) -> Result<CollectionHandle<T>> {
188 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)
189 .ok_or(Error::Revert("Contract is not an unique collection".into()))?;
190 let recorder = <SubstrateRecorder<T>>::new(gas_limit);
191 let collection =
192 pallet_common::CollectionHandle::new_with_recorder(collection_id, recorder)
193 .ok_or(Error::Revert("Create collection handle error".into()))?;
194 Ok(collection)
195 }
196
197 fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<()> {
198 let caller = T::CrossAccountId::from_eth(caller);
199 collection
200 .check_is_owner(&caller)
201 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
202 Ok(())
203 }
204122
205 pub struct CollectionHelperOnMethodCall<T: Config>(PhantomData<*const T>);123 pub struct CollectionHelperOnMethodCall<T: Config>(PhantomData<*const T>);
206 impl<T: Config> OnMethodCall<T> for CollectionHelperOnMethodCall<T> {124 impl<T: Config> OnMethodCall<T> for CollectionHelperOnMethodCall<T> {
236 generate_stubgen!(collection_helper_impl, CollectionHelperCall<()>, true);154 generate_stubgen!(collection_helper_impl, CollectionHelperCall<()>, true);
237 generate_stubgen!(collection_helper_iface, CollectionHelperCall<()>, false);155 generate_stubgen!(collection_helper_iface, CollectionHelperCall<()>, false);
238 156
239 pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);
240 impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {
241 fn is_reserved(contract: &sp_core::H160) -> bool {157 fn error_feild_too_long(feild: &str, bound: u32) -> Error {
242 contract == &T::ContractAddress::get()
243 }
244
245 fn is_used(contract: &sp_core::H160) -> bool {
246 contract == &T::ContractAddress::get()
247 }
248
249 fn call(
250 source: &sp_core::H160,
251 target: &sp_core::H160,
252 gas_left: u64,
253 input: &[u8],
254 value: sp_core::U256,
255 ) -> Option<PrecompileResult> {
256 if !pallet_common::eth::is_collection(target) {
257 return None;
258 }
259
260 let helpers = EvmCollection::<T>(*target, SubstrateRecorder::<T>::new(gas_left));
261 pallet_evm_coder_substrate::call(*source, helpers, value, input)
262 }
263
264 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {
265 (contract == &T::ContractAddress::get())158 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))
266 .then(|| include_bytes!("./stubs/Collection.raw").to_vec())
267 }159 }
268 }
269
270 generate_stubgen!(collection_impl, CollectionCall<()>, true);
271 generate_stubgen!(collection_iface, CollectionCall<()>, false);
272}160}
273161
deletedpallets/unique/src/eth/stubs/Collection.rawdiffbeforeafterboth

binary blob — no preview

deletedpallets/unique/src/eth/stubs/Collection.soldiffbeforeafterboth

no changes

modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
307 pallet_evm_migration::OnMethodCall<Self>,307 pallet_evm_migration::OnMethodCall<Self>,
308 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
309 CollectionDispatchT<Self>,309 CollectionDispatchT<Self>,
310 evm_collection::CollectionOnMethodCall<Self>,
311 evm_collection::CollectionHelperOnMethodCall<Self>,310 evm_collection::CollectionHelperOnMethodCall<Self>,
312 );311 );
313 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;312 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
286 pallet_evm_migration::OnMethodCall<Self>,286 pallet_evm_migration::OnMethodCall<Self>,
287 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,287 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
288 CollectionDispatchT<Self>,288 CollectionDispatchT<Self>,
289 evm_collection::CollectionOnMethodCall<Self>,
290 evm_collection::CollectionHelperOnMethodCall<Self>,289 evm_collection::CollectionHelperOnMethodCall<Self>,
291 );290 );
292 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;291 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
291 pallet_evm_migration::OnMethodCall<Self>,291 pallet_evm_migration::OnMethodCall<Self>,
292 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,292 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
293 CollectionDispatchT<Self>,293 CollectionDispatchT<Self>,
294 evm_collection::CollectionOnMethodCall<Self>,
295 evm_collection::CollectionHelperOnMethodCall<Self>,294 evm_collection::CollectionHelperOnMethodCall<Self>,
296 );295 );
297 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;296 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
42 event MintingFinished();42 event MintingFinished();
43}43}
44
45// Selector: 38e33c60
46interface Collection is Dummy, ERC165 {
47 // Selector: setCollectionProperty(string,bytes) 2f073f66
48 function setCollectionProperty(string memory key, bytes memory value)
49 external;
50
51 // Selector: deleteCollectionProperty(string) 7b7debce
52 function deleteCollectionProperty(string memory key) external;
53
54 // Throws error if key not found
55 //
56 // Selector: collectionProperty(string) cf24fd6d
57 function collectionProperty(string memory key)
58 external
59 view
60 returns (bytes memory);
61
62 // Selector: ethSetSponsor(address) 8f9af356
63 function ethSetSponsor(address sponsor) external;
64
65 // Selector: ethConfirmSponsorship() a8580d1a
66 function ethConfirmSponsorship() external;
67
68 // Selector: setLimits(string) 72cb345d
69 function setLimits(string memory limitsJson) external view;
70
71 // Selector: contractAddress() f6b4dfb4
72 function contractAddress() external view returns (address);
73}
4474
45// Selector: 4136937775// Selector: 41369377
46interface TokenProperties is Dummy, ERC165 {76interface TokenProperties is Dummy, ERC165 {
191 function totalSupply() external view returns (uint256);221 function totalSupply() external view returns (uint256);
192}222}
193
194// Selector: 9b5e29c5
195interface CollectionProperties is Dummy, ERC165 {
196 // Selector: setCollectionProperty(string,bytes) 2f073f66
197 function setCollectionProperty(string memory key, bytes memory value)
198 external;
199
200 // Selector: deleteCollectionProperty(string) 7b7debce
201 function deleteCollectionProperty(string memory key) external;
202
203 // Throws error if key not found
204 //
205 // Selector: collectionProperty(string) cf24fd6d
206 function collectionProperty(string memory key)
207 external
208 view
209 returns (bytes memory);
210}
211223
212// Selector: d74d154f224// Selector: d74d154f
213interface ERC721UniqueExtensions is Dummy, ERC165 {225interface ERC721UniqueExtensions is Dummy, ERC165 {
240 ERC721UniqueExtensions,252 ERC721UniqueExtensions,
241 ERC721Mintable,253 ERC721Mintable,
242 ERC721Burnable,254 ERC721Burnable,
243 CollectionProperties,255 Collection,
244 TokenProperties256 TokenProperties
245{}257{}
246258
deletedtests/src/eth/collectionAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
88 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);88 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
89 const sponsor = await createEthAccountWithBalance(api, web3);89 const sponsor = await createEthAccountWithBalance(api, web3);
90 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);90 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
91 result = await collectionEvm.methods.setSponsor(sponsor).send();91 result = await collectionEvm.methods.ethSetSponsor(sponsor).send();
92 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;92 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
93 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;93 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
94 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));94 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
95 await expect(collectionEvm.methods.confirmSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');95 await expect(collectionEvm.methods.ethConfirmSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
96 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);96 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
97 await sponsorCollection.methods.confirmSponsorship().send();97 await sponsorCollection.methods.ethConfirmSponsorship().send();
98 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;98 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
99 expect(collectionSub.sponsorship.isConfirmed).to.be.true;99 expect(collectionSub.sponsorship.isConfirmed).to.be.true;
100 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));100 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
125 "stateMutability": "view",125 "stateMutability": "view",
126 "type": "function"126 "type": "function"
127 },127 },
128 {
129 "inputs": [],
130 "name": "contractAddress",
131 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
132 "stateMutability": "view",
133 "type": "function"
134 },
128 {135 {
129 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],136 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
130 "name": "deleteCollectionProperty",137 "name": "deleteCollectionProperty",
142 "stateMutability": "nonpayable",149 "stateMutability": "nonpayable",
143 "type": "function"150 "type": "function"
144 },151 },
152 {
153 "inputs": [],
154 "name": "ethConfirmSponsorship",
155 "outputs": [],
156 "stateMutability": "nonpayable",
157 "type": "function"
158 },
159 {
160 "inputs": [
161 { "internalType": "address", "name": "sponsor", "type": "address" }
162 ],
163 "name": "ethSetSponsor",
164 "outputs": [],
165 "stateMutability": "nonpayable",
166 "type": "function"
167 },
145 {168 {
146 "inputs": [],169 "inputs": [],
147 "name": "finishMinting",170 "name": "finishMinting",
300 "stateMutability": "nonpayable",323 "stateMutability": "nonpayable",
301 "type": "function"324 "type": "function"
302 },325 },
326 {
327 "inputs": [
328 { "internalType": "string", "name": "limitsJson", "type": "string" }
329 ],
330 "name": "setLimits",
331 "outputs": [],
332 "stateMutability": "view",
333 "type": "function"
334 },
303 {335 {
304 "inputs": [336 "inputs": [
305 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },337 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
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 collectionAbi from '../nonFungibleAbi.json';
32import collectionHelperAbi from '../collectionHelperAbi.json';32import collectionHelperAbi from '../collectionHelperAbi.json';
33import getBalance from '../../substrate/get-balance';33import getBalance from '../../substrate/get-balance';
34import waitNewBlocks from '../../substrate/wait-new-blocks';34import waitNewBlocks from '../../substrate/wait-new-blocks';