From 25b9e9e7bf384f894657a45bc6bcad4d8d434cb2 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Mon, 16 May 2022 07:57:20 +0000 Subject: [PATCH] CORE-345 Remove deprecated methods --- --- a/Cargo.lock +++ b/Cargo.lock @@ -989,9 +989,9 @@ [[package]] name = "camino" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07fd178c5af4d59e83498ef15cf3f154e1a6f9d091270cb86283c65ef44e9ef0" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" dependencies = [ "serde", ] @@ -6090,29 +6090,6 @@ "pallet-evm-coder-substrate", "pallet-nonfungible", "parity-scale-codec 3.1.2", - "scale-info", - "serde_json", - "sp-core", - "sp-runtime", - "sp-std", - "up-data-structs", -] - -[[package]] -name = "pallet-evm-collection" -version = "0.1.0" -dependencies = [ - "ethereum", - "evm-coder", - "fp-evm-mapping", - "frame-support", - "frame-system", - "log", - "pallet-common", - "pallet-evm", - "pallet-evm-coder-substrate", - "pallet-nonfungible", - "parity-scale-codec", "scale-info", "serde-json-core", "sp-core", --- a/pallets/evm-collection/src/eth.rs +++ b/pallets/evm-collection/src/eth.rs @@ -27,8 +27,7 @@ use sp_core::H160; use up_data_structs::{ CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, - MAX_COLLECTION_NAME_LENGTH, OFFCHAIN_SCHEMA_LIMIT, VARIABLE_ON_CHAIN_SCHEMA_LIMIT, - CONST_ON_CHAIN_SCHEMA_LIMIT, + MAX_COLLECTION_NAME_LENGTH, }; use crate::{Config, Pallet}; use frame_support::traits::Get; @@ -48,7 +47,7 @@ } #[derive(ToLog)] -pub enum CollectionEvent { +pub enum EthCollectionEvent { CollectionCreated { #[indexed] owner: address, @@ -95,7 +94,7 @@ let address = pallet_common::eth::collection_id_to_address(collection_id); >::deposit_log( - CollectionEvent::CollectionCreated { + EthCollectionEvent::CollectionCreated { owner: *caller.as_eth(), collection_id: address, } @@ -126,58 +125,6 @@ if !collection.confirm_sponsorship(caller.as_sub()) { return Err(Error::Revert("Caller is not set as sponsor".into())); } - collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?; - Ok(()) - } - - fn set_offchain_schema( - &self, - caller: caller, - collection_address: address, - schema: string, - ) -> Result { - let mut collection = collection_from_address(collection_address, &self.0)?; - check_is_owner(caller, &collection)?; - - let schema = schema - .into_bytes() - .try_into() - .map_err(|_| error_feild_too_long(stringify!(shema), OFFCHAIN_SCHEMA_LIMIT))?; - // collection.offchain_schema = schema; - collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?; - Ok(()) - } - - fn set_variable_on_chain_schema( - &self, - caller: caller, - collection_address: address, - variable: string, - ) -> Result { - let mut collection = collection_from_address(collection_address, &self.0)?; - check_is_owner(caller, &collection)?; - - let variable = variable.into_bytes().try_into().map_err(|_| { - error_feild_too_long(stringify!(variable), VARIABLE_ON_CHAIN_SCHEMA_LIMIT) - })?; - // collection.variable_on_chain_schema = variable; - collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?; - Ok(()) - } - - fn set_const_on_chain_schema( - &self, - caller: caller, - collection_address: address, - const_on_chain: string, - ) -> Result { - let mut collection = collection_from_address(collection_address, &self.0)?; - check_is_owner(caller, &collection)?; - - let const_on_chain = const_on_chain.into_bytes().try_into().map_err(|_| { - error_feild_too_long(stringify!(const_on_chain), CONST_ON_CHAIN_SCHEMA_LIMIT) - })?; - // collection.const_on_chain_schema = const_on_chain; collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?; Ok(()) } --- a/primitives/data-structs/Cargo.toml +++ b/primitives/data-structs/Cargo.toml @@ -40,6 +40,6 @@ "sp-std/std", "pallet-evm/std", ] -serde1 = ["serde"] +serde1 = ["serde/alloc"] limit-testing = [] runtime-benchmarks = [] \ No newline at end of file --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -72,7 +72,6 @@ token: TokenId, ) -> Result; - fn eth_contract_code(account: H160) -> Option>; fn adminlist(collection: CollectionId) -> Result>; fn allowlist(collection: CollectionId) -> Result>; fn allowed(collection: CollectionId, user: CrossAccountId) -> Result; --- a/runtime/opal/src/lib.rs +++ b/runtime/opal/src/lib.rs @@ -50,6 +50,7 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_evm::{ EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall, + Account as EVMAccount, FeeCalculator, GasWeightMapping, }; pub use frame_support::{ construct_runtime, match_types, @@ -79,7 +80,6 @@ }; use smallvec::smallvec; use codec::{Encode, Decode}; -use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall}; use fp_rpc::TransactionStatus; use sp_runtime::{ traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating}, --- a/tests/src/eth/createCollection.test.ts +++ b/tests/src/eth/createCollection.test.ts @@ -78,39 +78,6 @@ expect(collection.sponsorship.isConfirmed).to.be.true; expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor)); }); - - itWeb3('Set offchain schema', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - let result = await helper.methods.create721Collection('Schema collection', '2', '2').send(); - const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const schema = 'Some schema'; - result = await helper.methods.setOffchainSchema(collectionIdAddress, schema).send(); - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection.offchainSchema.toHuman()).to.be.eq(schema); - }); - - itWeb3('Set variable on chain schema', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - let result = await helper.methods.create721Collection('Variable collection', '3', '3').send(); - const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const variable = 'Some variable'; - result = await helper.methods.setVariableOnChainSchema(collectionIdAddress, variable).send(); - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection.variableOnChainSchema.toHuman()).to.be.eq(variable); - }); - - itWeb3('Set const on chain schema', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - let result = await helper.methods.create721Collection('Const collection', '4', '4').send(); - const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const constSchema = 'Some const'; - result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constSchema).send(); - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection.constOnChainSchema.toHuman()).to.be.eq(constSchema); - }); itWeb3('Set limits', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); @@ -245,27 +212,9 @@ const sponsorHelper = collectionHelper(web3, sponsor); await expect(sponsorHelper.methods .confirmSponsorship(collectionAddressWithBadPrefix) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { - const schema = 'Some schema'; - await expect(helper.methods - .setOffchainSchema(collectionAddressWithBadPrefix, schema) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { - const variable = 'Some variable'; - await expect(helper.methods - .setVariableOnChainSchema(collectionAddressWithBadPrefix, variable) .call()).to.be.rejectedWith(EXPECTED_ERROR); } { - const constData = 'Some const'; - await expect(helper.methods - .setConstOnChainSchema(collectionAddressWithBadPrefix, constData) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { const limits = '{"account_token_ownership_limit":1000}'; await expect(helper.methods .setLimits(collectionAddressWithBadPrefix, limits) @@ -293,65 +242,11 @@ .call()).to.be.rejectedWith('Caller is not set as sponsor'); } { - const schema = 'Some schema'; - await expect(helperFromNotOwner.methods - .setOffchainSchema(collectionIdAddress, schema) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { - const variable = 'Some variable'; - await expect(helperFromNotOwner.methods - .setVariableOnChainSchema(collectionIdAddress, variable) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { - const constData = 'Some const'; - await expect(helperFromNotOwner.methods - .setConstOnChainSchema(collectionIdAddress, constData) - .call()).to.be.rejectedWith(EXPECTED_ERROR); - } - { const limits = '{"account_token_ownership_limit":1000}'; await expect(helperFromNotOwner.methods .setLimits(collectionIdAddress, limits) .call()).to.be.rejectedWith(EXPECTED_ERROR); } - }); - - itWeb3('(!negative test!) Set offchain schema (length limit)', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); - const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); - const OFFCHAIN_SCHEMA_LIMIT = 8192; - const schema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1); - await expect(helper.methods - .setOffchainSchema(collectionIdAddress, schema) - .call()).to.be.rejectedWith('schema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT); - }); - - itWeb3('(!negative test!) Set variable on chain schema (length limit)', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); - const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); - const VARIABLE_ON_CHAIN_SCHEMA_LIMIT = 8192; - const variable = 'A'.repeat(VARIABLE_ON_CHAIN_SCHEMA_LIMIT + 1); - await expect(helper.methods - .setVariableOnChainSchema(collectionIdAddress, variable) - .call()).to.be.rejectedWith('variable is too long. Max length is ' + VARIABLE_ON_CHAIN_SCHEMA_LIMIT); - }); - - itWeb3('(!negative test!) Set const on chain schema (length limit)', async ({api, web3}) => { - const owner = await createEthAccountWithBalance(api, web3); - const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); - const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); - const CONST_ON_CHAIN_SCHEMA_LIMIT = 32768; - const constData = 'A'.repeat(CONST_ON_CHAIN_SCHEMA_LIMIT + 1); - await expect(helper.methods - .setConstOnChainSchema(collectionIdAddress, constData) - .call()).to.be.rejectedWith('const_on_chain is too long. Max length is ' + CONST_ON_CHAIN_SCHEMA_LIMIT); }); itWeb3('(!negative test!) Set limits', async ({api, web3}) => { -- gitstuff