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
--- 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",
modifiedpallets/evm-collection/src/eth.rsdiffbeforeafterboth
--- 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);
 		<PalletEvm<T>>::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::<T>)?;
-		Ok(())
-	}
-
-	fn set_offchain_schema(
-		&self,
-		caller: caller,
-		collection_address: address,
-		schema: string,
-	) -> Result<void> {
-		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::<T>)?;
-		Ok(())
-	}
-
-	fn set_variable_on_chain_schema(
-		&self,
-		caller: caller,
-		collection_address: address,
-		variable: string,
-	) -> Result<void> {
-		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::<T>)?;
-		Ok(())
-	}
-
-	fn set_const_on_chain_schema(
-		&self,
-		caller: caller,
-		collection_address: address,
-		const_on_chain: string,
-	) -> Result<void> {
-		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::<T>)?;
 		Ok(())
 	}
modifiedprimitives/data-structs/Cargo.tomldiffbeforeafterboth
--- 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
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
before · primitives/rpc/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use up_data_structs::{20	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,21	PropertyKeyPermission, TokenData,22};23use sp_std::vec::Vec;24use codec::Decode;25use sp_runtime::DispatchError;26use sp_core::H160;2728type Result<T> = core::result::Result<T, DispatchError>;2930sp_api::decl_runtime_apis! {31	#[api_version(2)]32	pub trait UniqueApi<CrossAccountId, AccountId> where33		AccountId: Decode,34		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,35	{36		#[changed_in(2)]37		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;3839		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;40		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;41		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4243		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;44		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;4546		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;4748		fn token_properties(49			collection: CollectionId,50			token_id: TokenId,51			properties: Option<Vec<Vec<u8>>>52		) -> Result<Vec<Property>>;5354		fn property_permissions(55			collection: CollectionId,56			properties: Option<Vec<Vec<u8>>>57		) -> Result<Vec<PropertyKeyPermission>>;5859		fn token_data(60			collection: CollectionId,61			token_id: TokenId,62			keys: Option<Vec<Vec<u8>>>63		) -> Result<TokenData<CrossAccountId>>;6465		fn total_supply(collection: CollectionId) -> Result<u32>;66		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;67		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;68		fn allowance(69			collection: CollectionId,70			sender: CrossAccountId,71			spender: CrossAccountId,72			token: TokenId,73		) -> Result<u128>;7475		fn eth_contract_code(account: H160) -> Option<Vec<u8>>;76		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;77		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;78		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;79		fn last_token_id(collection: CollectionId) -> Result<TokenId>;80		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;81		fn collection_stats() -> Result<CollectionStats>;82		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;83		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;84	}85}
after · primitives/rpc/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use up_data_structs::{20	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,21	PropertyKeyPermission, TokenData,22};23use sp_std::vec::Vec;24use codec::Decode;25use sp_runtime::DispatchError;26use sp_core::H160;2728type Result<T> = core::result::Result<T, DispatchError>;2930sp_api::decl_runtime_apis! {31	#[api_version(2)]32	pub trait UniqueApi<CrossAccountId, AccountId> where33		AccountId: Decode,34		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,35	{36		#[changed_in(2)]37		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;3839		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;40		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;41		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4243		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;44		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;4546		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;4748		fn token_properties(49			collection: CollectionId,50			token_id: TokenId,51			properties: Option<Vec<Vec<u8>>>52		) -> Result<Vec<Property>>;5354		fn property_permissions(55			collection: CollectionId,56			properties: Option<Vec<Vec<u8>>>57		) -> Result<Vec<PropertyKeyPermission>>;5859		fn token_data(60			collection: CollectionId,61			token_id: TokenId,62			keys: Option<Vec<Vec<u8>>>63		) -> Result<TokenData<CrossAccountId>>;6465		fn total_supply(collection: CollectionId) -> Result<u32>;66		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;67		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;68		fn allowance(69			collection: CollectionId,70			sender: CrossAccountId,71			spender: CrossAccountId,72			token: TokenId,73		) -> Result<u128>;7475		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;76		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;77		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;78		fn last_token_id(collection: CollectionId) -> Result<TokenId>;79		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;80		fn collection_stats() -> Result<CollectionStats>;81		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;82		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;83	}84}
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- 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},
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- 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}) => {