difftreelog
CORE-345 Remove deprecated methods
in: master
6 files changed
Cargo.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",
pallets/evm-collection/src/eth.rsdiffbeforeafterboth1// 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/>.1617use core::marker::PhantomData;18use evm_coder::{abi::AbiWriter, execution::*, generate_stubgen, solidity_interface, types::*, ToLog};19use ethereum as _;20use pallet_common::CollectionById;21use pallet_common::{CollectionHandle};22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};23use pallet_evm::{24 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,25 account::CrossAccountId, Pallet as PalletEvm,26};27use sp_core::H160;28use up_data_structs::{29 CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,30 MAX_COLLECTION_NAME_LENGTH, OFFCHAIN_SCHEMA_LIMIT, VARIABLE_ON_CHAIN_SCHEMA_LIMIT,31 CONST_ON_CHAIN_SCHEMA_LIMIT,32};33use crate::{Config, Pallet};34use frame_support::traits::Get;3536use sp_std::{vec::Vec, rc::Rc};37use alloc::format;3839struct EvmCollection<T: Config>(SubstrateRecorder<T>);40impl<T: Config> WithRecorder<T> for EvmCollection<T> {41 fn recorder(&self) -> &SubstrateRecorder<T> {42 &self.043 }4445 fn into_recorder(self) -> SubstrateRecorder<T> {46 self.047 }48}4950#[derive(ToLog)]51pub enum CollectionEvent {52 CollectionCreated {53 #[indexed]54 owner: address,55 #[indexed]56 collection_id: address,57 },58}5960#[solidity_interface(name = "Collection")]61impl<T: Config> EvmCollection<T> {62 fn create_721_collection(63 &self,64 caller: caller,65 name: string,66 description: string,67 token_prefix: string,68 ) -> Result<address> {69 let caller = T::CrossAccountId::from_eth(caller);70 let name = name71 .encode_utf16()72 .collect::<Vec<u16>>()73 .try_into()74 .map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;75 let description = description76 .encode_utf16()77 .collect::<Vec<u16>>()78 .try_into()79 .map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;80 let token_prefix = token_prefix81 .into_bytes()82 .try_into()83 .map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;8485 let data = CreateCollectionData {86 name,87 description,88 token_prefix,89 ..Default::default()90 };9192 let collection_id =93 <pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)94 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;9596 let address = pallet_common::eth::collection_id_to_address(collection_id);97 <PalletEvm<T>>::deposit_log(98 CollectionEvent::CollectionCreated {99 owner: *caller.as_eth(),100 collection_id: address,101 }102 .to_log(address),103 );104 Ok(address)105 }106107 fn set_sponsor(108 &self,109 caller: caller,110 collection_address: address,111 sponsor: address,112 ) -> Result<void> {113 let mut collection = collection_from_address(collection_address, &self.0)?;114 check_is_owner(caller, &collection)?;115116 let sponsor = T::CrossAccountId::from_eth(sponsor);117 collection.set_sponsor(sponsor.as_sub().clone());118 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;119 Ok(()).map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;120 Ok(())121 }122123 fn confirm_sponsorship(&self, caller: caller, collection_address: address) -> Result<void> {124 let mut collection = collection_from_address(collection_address, &self.0)?;125 let caller = T::CrossAccountId::from_eth(caller);126 if !collection.confirm_sponsorship(caller.as_sub()) {127 return Err(Error::Revert("Caller is not set as sponsor".into()));128 }129 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;130 Ok(())131 }132133 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)?;141142 let schema = schema143 .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 }150151 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)?;159160 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 }167168 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)?;176177 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 }184185 fn set_limits(186 &self,187 caller: caller,188 collection_address: address,189 limits_json: string,190 ) -> Result<void> {191 let mut collection = collection_from_address(collection_address, &self.0)?;192 check_is_owner(caller, &collection)?;193194 let limits = serde_json_core::from_str(limits_json.as_ref())195 .map_err(|e| Error::Revert(format!("Parse JSON error: {}", e)))?;196 collection.limits = limits.0;197 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;198 Ok(())199 }200}201202fn error_feild_too_long(feild: &str, bound: u32) -> Error {203 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))204}205206fn collection_from_address<T: Config>(207 collection_address: address,208 recorder: &SubstrateRecorder<T>,209) -> Result<CollectionHandle<T>> {210 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)211 .ok_or(Error::Revert("Contract is not an unique collection".into()))?;212 let collection =213 pallet_common::CollectionHandle::new_with_gas_limit(collection_id, recorder.gas_left())214 .ok_or(Error::Revert("Create collection handle error".into()))?;215 Ok(collection)216}217218fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<()> {219 let caller = T::CrossAccountId::from_eth(caller);220 collection221 .check_is_owner(&caller)222 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;223 Ok(())224}225226pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);227impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {228 fn is_reserved(contract: &sp_core::H160) -> bool {229 contract == &T::ContractAddress::get()230 }231232 fn is_used(contract: &sp_core::H160) -> bool {233 contract == &T::ContractAddress::get()234 }235236 fn call(237 source: &sp_core::H160,238 target: &sp_core::H160,239 gas_left: u64,240 input: &[u8],241 value: sp_core::U256,242 ) -> Option<PrecompileResult> {243 if target != &T::ContractAddress::get() {244 return None;245 }246247 let helpers = EvmCollection::<T>(SubstrateRecorder::new(gas_left));248 pallet_evm_coder_substrate::call(*source, helpers, value, input)249 }250251 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {252 (contract == &T::ContractAddress::get())253 .then(|| include_bytes!("./stubs/Collection.raw").to_vec())254 }255}256257generate_stubgen!(collection_impl, CollectionCall<()>, true);258generate_stubgen!(collection_iface, CollectionCall<()>, false);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/>.1617use core::marker::PhantomData;18use evm_coder::{abi::AbiWriter, execution::*, generate_stubgen, solidity_interface, types::*, ToLog};19use ethereum as _;20use pallet_common::CollectionById;21use pallet_common::{CollectionHandle};22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};23use pallet_evm::{24 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,25 account::CrossAccountId, Pallet as PalletEvm,26};27use sp_core::H160;28use up_data_structs::{29 CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,30 MAX_COLLECTION_NAME_LENGTH,31};32use crate::{Config, Pallet};33use frame_support::traits::Get;3435use sp_std::{vec::Vec, rc::Rc};36use alloc::format;3738struct EvmCollection<T: Config>(SubstrateRecorder<T>);39impl<T: Config> WithRecorder<T> for EvmCollection<T> {40 fn recorder(&self) -> &SubstrateRecorder<T> {41 &self.042 }4344 fn into_recorder(self) -> SubstrateRecorder<T> {45 self.046 }47}4849#[derive(ToLog)]50pub enum EthCollectionEvent {51 CollectionCreated {52 #[indexed]53 owner: address,54 #[indexed]55 collection_id: address,56 },57}5859#[solidity_interface(name = "Collection")]60impl<T: Config> EvmCollection<T> {61 fn create_721_collection(62 &self,63 caller: caller,64 name: string,65 description: string,66 token_prefix: string,67 ) -> Result<address> {68 let caller = T::CrossAccountId::from_eth(caller);69 let name = name70 .encode_utf16()71 .collect::<Vec<u16>>()72 .try_into()73 .map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;74 let description = description75 .encode_utf16()76 .collect::<Vec<u16>>()77 .try_into()78 .map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;79 let token_prefix = token_prefix80 .into_bytes()81 .try_into()82 .map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;8384 let data = CreateCollectionData {85 name,86 description,87 token_prefix,88 ..Default::default()89 };9091 let collection_id =92 <pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)93 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;9495 let address = pallet_common::eth::collection_id_to_address(collection_id);96 <PalletEvm<T>>::deposit_log(97 EthCollectionEvent::CollectionCreated {98 owner: *caller.as_eth(),99 collection_id: address,100 }101 .to_log(address),102 );103 Ok(address)104 }105106 fn set_sponsor(107 &self,108 caller: caller,109 collection_address: address,110 sponsor: address,111 ) -> Result<void> {112 let mut collection = collection_from_address(collection_address, &self.0)?;113 check_is_owner(caller, &collection)?;114115 let sponsor = T::CrossAccountId::from_eth(sponsor);116 collection.set_sponsor(sponsor.as_sub().clone());117 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;118 Ok(()).map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;119 Ok(())120 }121122 fn confirm_sponsorship(&self, caller: caller, collection_address: address) -> Result<void> {123 let mut collection = collection_from_address(collection_address, &self.0)?;124 let caller = T::CrossAccountId::from_eth(caller);125 if !collection.confirm_sponsorship(caller.as_sub()) {126 return Err(Error::Revert("Caller is not set as sponsor".into()));127 }128 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;129 Ok(())130 }131132 fn set_limits(133 &self,134 caller: caller,135 collection_address: address,136 limits_json: string,137 ) -> Result<void> {138 let mut collection = collection_from_address(collection_address, &self.0)?;139 check_is_owner(caller, &collection)?;140141 let limits = serde_json_core::from_str(limits_json.as_ref())142 .map_err(|e| Error::Revert(format!("Parse JSON error: {}", e)))?;143 collection.limits = limits.0;144 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;145 Ok(())146 }147}148149fn error_feild_too_long(feild: &str, bound: u32) -> Error {150 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))151}152153fn collection_from_address<T: Config>(154 collection_address: address,155 recorder: &SubstrateRecorder<T>,156) -> Result<CollectionHandle<T>> {157 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)158 .ok_or(Error::Revert("Contract is not an unique collection".into()))?;159 let collection =160 pallet_common::CollectionHandle::new_with_gas_limit(collection_id, recorder.gas_left())161 .ok_or(Error::Revert("Create collection handle error".into()))?;162 Ok(collection)163}164165fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<()> {166 let caller = T::CrossAccountId::from_eth(caller);167 collection168 .check_is_owner(&caller)169 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;170 Ok(())171}172173pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);174impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {175 fn is_reserved(contract: &sp_core::H160) -> bool {176 contract == &T::ContractAddress::get()177 }178179 fn is_used(contract: &sp_core::H160) -> bool {180 contract == &T::ContractAddress::get()181 }182183 fn call(184 source: &sp_core::H160,185 target: &sp_core::H160,186 gas_left: u64,187 input: &[u8],188 value: sp_core::U256,189 ) -> Option<PrecompileResult> {190 if target != &T::ContractAddress::get() {191 return None;192 }193194 let helpers = EvmCollection::<T>(SubstrateRecorder::new(gas_left));195 pallet_evm_coder_substrate::call(*source, helpers, value, input)196 }197198 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {199 (contract == &T::ContractAddress::get())200 .then(|| include_bytes!("./stubs/Collection.raw").to_vec())201 }202}203204generate_stubgen!(collection_impl, CollectionCall<()>, true);205generate_stubgen!(collection_iface, CollectionCall<()>, false);primitives/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
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -72,7 +72,6 @@
token: TokenId,
) -> Result<u128>;
- fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;
fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;
fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;
runtime/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},
tests/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}) => {