git.delta.rocks / unique-network / refs/commits / 25b9e9e7bf38

difftreelog

CORE-345 Remove deprecated methods

Trubnikov Sergey2022-05-16parent: #d671502.patch.diff
in: master

6 files changed

modifiedCargo.lockdiffbeforeafterboth
989989
990[[package]]990[[package]]
991name = "camino"991name = "camino"
992version = "1.0.8"992version = "1.0.9"
993source = "registry+https://github.com/rust-lang/crates.io-index"993source = "registry+https://github.com/rust-lang/crates.io-index"
994checksum = "07fd178c5af4d59e83498ef15cf3f154e1a6f9d091270cb86283c65ef44e9ef0"994checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412"
995dependencies = [995dependencies = [
996 "serde",996 "serde",
997]997]
6075 "up-data-structs",6075 "up-data-structs",
6076]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 3.1.2",
6093 "scale-info",
6094 "serde_json",
6095 "sp-core",
6096 "sp-runtime",
6097 "sp-std",
6098 "up-data-structs",
6099]
61006077
6101[[package]]6078[[package]]
6102name = "pallet-evm-collection"6079name = "pallet-evm-collection"
6112 "pallet-evm",6089 "pallet-evm",
6113 "pallet-evm-coder-substrate",6090 "pallet-evm-coder-substrate",
6114 "pallet-nonfungible",6091 "pallet-nonfungible",
6115 "parity-scale-codec",6092 "parity-scale-codec 3.1.2",
6116 "scale-info",6093 "scale-info",
6117 "serde-json-core",6094 "serde-json-core",
6118 "sp-core",6095 "sp-core",
modifiedpallets/evm-collection/src/eth.rsdiffbeforeafterboth
27use sp_core::H160;27use sp_core::H160;
28use up_data_structs::{28use up_data_structs::{
29 CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,29 CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
30 MAX_COLLECTION_NAME_LENGTH, OFFCHAIN_SCHEMA_LIMIT, VARIABLE_ON_CHAIN_SCHEMA_LIMIT,30 MAX_COLLECTION_NAME_LENGTH,
31 CONST_ON_CHAIN_SCHEMA_LIMIT,
32};31};
33use crate::{Config, Pallet};32use crate::{Config, Pallet};
34use frame_support::traits::Get;33use frame_support::traits::Get;
48}47}
4948
50#[derive(ToLog)]49#[derive(ToLog)]
51pub enum CollectionEvent {50pub enum EthCollectionEvent {
52 CollectionCreated {51 CollectionCreated {
53 #[indexed]52 #[indexed]
54 owner: address,53 owner: address,
9594
96 let address = pallet_common::eth::collection_id_to_address(collection_id);95 let address = pallet_common::eth::collection_id_to_address(collection_id);
97 <PalletEvm<T>>::deposit_log(96 <PalletEvm<T>>::deposit_log(
98 CollectionEvent::CollectionCreated {97 EthCollectionEvent::CollectionCreated {
99 owner: *caller.as_eth(),98 owner: *caller.as_eth(),
100 collection_id: address,99 collection_id: address,
101 }100 }
130 Ok(())129 Ok(())
131 }130 }
132
133 fn set_offchain_schema(
134 &self,
135 caller: caller,
136 collection_address: address,
137 schema: string,
138 ) -> Result<void> {
139 let mut collection = collection_from_address(collection_address, &self.0)?;
140 check_is_owner(caller, &collection)?;
141
142 let schema = schema
143 .into_bytes()
144 .try_into()
145 .map_err(|_| error_feild_too_long(stringify!(shema), OFFCHAIN_SCHEMA_LIMIT))?;
146 // collection.offchain_schema = schema;
147 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
148 Ok(())
149 }
150
151 fn set_variable_on_chain_schema(
152 &self,
153 caller: caller,
154 collection_address: address,
155 variable: string,
156 ) -> Result<void> {
157 let mut collection = collection_from_address(collection_address, &self.0)?;
158 check_is_owner(caller, &collection)?;
159
160 let variable = variable.into_bytes().try_into().map_err(|_| {
161 error_feild_too_long(stringify!(variable), VARIABLE_ON_CHAIN_SCHEMA_LIMIT)
162 })?;
163 // collection.variable_on_chain_schema = variable;
164 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
165 Ok(())
166 }
167
168 fn set_const_on_chain_schema(
169 &self,
170 caller: caller,
171 collection_address: address,
172 const_on_chain: string,
173 ) -> Result<void> {
174 let mut collection = collection_from_address(collection_address, &self.0)?;
175 check_is_owner(caller, &collection)?;
176
177 let const_on_chain = const_on_chain.into_bytes().try_into().map_err(|_| {
178 error_feild_too_long(stringify!(const_on_chain), CONST_ON_CHAIN_SCHEMA_LIMIT)
179 })?;
180 // collection.const_on_chain_schema = const_on_chain;
181 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
182 Ok(())
183 }
184131
185 fn set_limits(132 fn set_limits(
186 &self,133 &self,
modifiedprimitives/data-structs/Cargo.tomldiffbeforeafterboth
40 "sp-std/std",40 "sp-std/std",
41 "pallet-evm/std",41 "pallet-evm/std",
42]42]
43serde1 = ["serde"]43serde1 = ["serde/alloc"]
44limit-testing = []44limit-testing = []
45runtime-benchmarks = []45runtime-benchmarks = []
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
72 token: TokenId,72 token: TokenId,
73 ) -> Result<u128>;73 ) -> Result<u128>;
7474
75 fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
76 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;75 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;
77 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;76 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;
78 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;77 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
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 _, OnMethodCall,52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall,
53 Account as EVMAccount, FeeCalculator, GasWeightMapping,
53};54};
54pub use frame_support::{55pub use frame_support::{
55 construct_runtime, match_types,56 construct_runtime, match_types,
79};80};
80use smallvec::smallvec;81use smallvec::smallvec;
81use codec::{Encode, Decode};82use codec::{Encode, Decode};
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},
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
79 expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));79 expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
80 });80 });
81
82 itWeb3('Set offchain schema', async ({api, web3}) => {
83 const owner = await createEthAccountWithBalance(api, web3);
84 const helper = collectionHelper(web3, owner);
85 let result = await helper.methods.create721Collection('Schema collection', '2', '2').send();
86 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
87 const schema = 'Some schema';
88 result = await helper.methods.setOffchainSchema(collectionIdAddress, schema).send();
89 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
90 expect(collection.offchainSchema.toHuman()).to.be.eq(schema);
91 });
92
93 itWeb3('Set variable on chain schema', async ({api, web3}) => {
94 const owner = await createEthAccountWithBalance(api, web3);
95 const helper = collectionHelper(web3, owner);
96 let result = await helper.methods.create721Collection('Variable collection', '3', '3').send();
97 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
98 const variable = 'Some variable';
99 result = await helper.methods.setVariableOnChainSchema(collectionIdAddress, variable).send();
100 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
101 expect(collection.variableOnChainSchema.toHuman()).to.be.eq(variable);
102 });
103
104 itWeb3('Set const on chain schema', async ({api, web3}) => {
105 const owner = await createEthAccountWithBalance(api, web3);
106 const helper = collectionHelper(web3, owner);
107 let result = await helper.methods.create721Collection('Const collection', '4', '4').send();
108 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
109 const constSchema = 'Some const';
110 result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constSchema).send();
111 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
112 expect(collection.constOnChainSchema.toHuman()).to.be.eq(constSchema);
113 });
11481
115 itWeb3('Set limits', async ({api, web3}) => {82 itWeb3('Set limits', async ({api, web3}) => {
116 const owner = await createEthAccountWithBalance(api, web3);83 const owner = await createEthAccountWithBalance(api, web3);
247 .confirmSponsorship(collectionAddressWithBadPrefix)214 .confirmSponsorship(collectionAddressWithBadPrefix)
248 .call()).to.be.rejectedWith(EXPECTED_ERROR);215 .call()).to.be.rejectedWith(EXPECTED_ERROR);
249 }216 }
250 {
251 const schema = 'Some schema';
252 await expect(helper.methods
253 .setOffchainSchema(collectionAddressWithBadPrefix, schema)
254 .call()).to.be.rejectedWith(EXPECTED_ERROR);
255 }
256 {
257 const variable = 'Some variable';
258 await expect(helper.methods
259 .setVariableOnChainSchema(collectionAddressWithBadPrefix, variable)
260 .call()).to.be.rejectedWith(EXPECTED_ERROR);
261 }
262 {
263 const constData = 'Some const';
264 await expect(helper.methods
265 .setConstOnChainSchema(collectionAddressWithBadPrefix, constData)
266 .call()).to.be.rejectedWith(EXPECTED_ERROR);
267 }
268 {217 {
269 const limits = '{"account_token_ownership_limit":1000}';218 const limits = '{"account_token_ownership_limit":1000}';
270 await expect(helper.methods219 await expect(helper.methods
292 .confirmSponsorship(collectionIdAddress)241 .confirmSponsorship(collectionIdAddress)
293 .call()).to.be.rejectedWith('Caller is not set as sponsor');242 .call()).to.be.rejectedWith('Caller is not set as sponsor');
294 }243 }
295 {
296 const schema = 'Some schema';
297 await expect(helperFromNotOwner.methods
298 .setOffchainSchema(collectionIdAddress, schema)
299 .call()).to.be.rejectedWith(EXPECTED_ERROR);
300 }
301 {
302 const variable = 'Some variable';
303 await expect(helperFromNotOwner.methods
304 .setVariableOnChainSchema(collectionIdAddress, variable)
305 .call()).to.be.rejectedWith(EXPECTED_ERROR);
306 }
307 {
308 const constData = 'Some const';
309 await expect(helperFromNotOwner.methods
310 .setConstOnChainSchema(collectionIdAddress, constData)
311 .call()).to.be.rejectedWith(EXPECTED_ERROR);
312 }
313 {244 {
314 const limits = '{"account_token_ownership_limit":1000}';245 const limits = '{"account_token_ownership_limit":1000}';
315 await expect(helperFromNotOwner.methods246 await expect(helperFromNotOwner.methods
318 }249 }
319 });250 });
320
321 itWeb3('(!negative test!) Set offchain schema (length limit)', async ({api, web3}) => {
322 const owner = await createEthAccountWithBalance(api, web3);
323 const helper = collectionHelper(web3, owner);
324 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();
325 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
326 const OFFCHAIN_SCHEMA_LIMIT = 8192;
327 const schema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1);
328 await expect(helper.methods
329 .setOffchainSchema(collectionIdAddress, schema)
330 .call()).to.be.rejectedWith('schema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT);
331 });
332
333 itWeb3('(!negative test!) Set variable on chain schema (length limit)', async ({api, web3}) => {
334 const owner = await createEthAccountWithBalance(api, web3);
335 const helper = collectionHelper(web3, owner);
336 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();
337 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
338 const VARIABLE_ON_CHAIN_SCHEMA_LIMIT = 8192;
339 const variable = 'A'.repeat(VARIABLE_ON_CHAIN_SCHEMA_LIMIT + 1);
340 await expect(helper.methods
341 .setVariableOnChainSchema(collectionIdAddress, variable)
342 .call()).to.be.rejectedWith('variable is too long. Max length is ' + VARIABLE_ON_CHAIN_SCHEMA_LIMIT);
343 });
344
345 itWeb3('(!negative test!) Set const on chain schema (length limit)', async ({api, web3}) => {
346 const owner = await createEthAccountWithBalance(api, web3);
347 const helper = collectionHelper(web3, owner);
348 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();
349 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
350 const CONST_ON_CHAIN_SCHEMA_LIMIT = 32768;
351 const constData = 'A'.repeat(CONST_ON_CHAIN_SCHEMA_LIMIT + 1);
352 await expect(helper.methods
353 .setConstOnChainSchema(collectionIdAddress, constData)
354 .call()).to.be.rejectedWith('const_on_chain is too long. Max length is ' + CONST_ON_CHAIN_SCHEMA_LIMIT);
355 });
356251
357 itWeb3('(!negative test!) Set limits', async ({api, web3}) => {252 itWeb3('(!negative test!) Set limits', async ({api, web3}) => {
358 const owner = await createEthAccountWithBalance(api, web3);253 const owner = await createEthAccountWithBalance(api, web3);