difftreelog
add contracts consts
in: master
7 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -376,6 +376,7 @@
type TreasuryAccountId: Get<Self::AccountId>;
/// Address under which the CollectionHelper contract would be available.
+ #[pallet::constant]
type ContractAddress: Get<H160>;
/// Mapper for token addresses to Ethereum addresses.
pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -47,6 +47,7 @@
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
/// Address, under which magic contract will be available
+ #[pallet::constant]
type ContractAddress: Get<H160>;
/// In case of enabled sponsoring, but no sponsoring rate limit set,
tests/src/apiConsts.test.tsdiffbeforeafterboth1// 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/>.1617import {ApiPromise} from '@polkadot/api';18import {usingPlaygrounds, itSub, expect} from './util';192021const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;22const MAX_COLLECTION_NAME_LENGTH = 64n;23const COLLECTION_ADMINS_LIMIT = 5n;24const MAX_COLLECTION_PROPERTIES_SIZE = 40960n;25const MAX_TOKEN_PREFIX_LENGTH = 16n;26const MAX_PROPERTY_KEY_LENGTH = 256n;27const MAX_PROPERTY_VALUE_LENGTH = 32768n;28const MAX_PROPERTIES_PER_ITEM = 64n;29const MAX_TOKEN_PROPERTIES_SIZE = 32768n;30const NESTING_BUDGET = 5n;3132const DEFAULT_COLLETCTION_LIMIT = {33 accountTokenOwnershipLimit: '1,000,000',34 sponsoredDataSize: '2,048',35 sponsoredDataRateLimit: 'SponsoringDisabled',36 tokenLimit: '4,294,967,295',37 sponsorTransferTimeout: '5',38 sponsorApproveTimeout: '5',39 ownerCanTransfer: false,40 ownerCanDestroy: true,41 transfersEnabled: true,42};4344describe('integration test: API UNIQUE consts', () => {45 let api: ApiPromise;46 47 before(async () => {48 await usingPlaygrounds(async (helper) => {49 api = await helper.getApi();50 });51 });52 53 itSub('DEFAULT_NFT_COLLECTION_LIMITS', () => {54 expect(api.consts.unique.nftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);55 });56 57 itSub('DEFAULT_RFT_COLLECTION_LIMITS', () => {58 expect(api.consts.unique.rftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);59 });60 61 itSub('DEFAULT_FT_COLLECTION_LIMITS', () => {62 expect(api.consts.unique.ftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);63 });64 65 itSub('MAX_COLLECTION_NAME_LENGTH', () => {66 checkConst(api.consts.unique.maxCollectionNameLength, MAX_COLLECTION_NAME_LENGTH);67 });68 69 itSub('MAX_COLLECTION_DESCRIPTION_LENGTH', () => {70 checkConst(api.consts.unique.maxCollectionDescriptionLength, MAX_COLLECTION_DESCRIPTION_LENGTH);71 });72 73 itSub('MAX_COLLECTION_PROPERTIES_SIZE', () => {74 checkConst(api.consts.unique.maxCollectionPropertiesSize, MAX_COLLECTION_PROPERTIES_SIZE);75 });7677 itSub('MAX_TOKEN_PREFIX_LENGTH', () => {78 checkConst(api.consts.unique.maxTokenPrefixLength, MAX_TOKEN_PREFIX_LENGTH);79 });8081 itSub('MAX_PROPERTY_KEY_LENGTH', () => {82 checkConst(api.consts.unique.maxPropertyKeyLength, MAX_PROPERTY_KEY_LENGTH);83 });84 85 itSub('MAX_PROPERTY_VALUE_LENGTH', () => {86 checkConst(api.consts.unique.maxPropertyValueLength, MAX_PROPERTY_VALUE_LENGTH);87 });88 89 itSub('MAX_PROPERTIES_PER_ITEM', () => {90 checkConst(api.consts.unique.maxPropertiesPerItem, MAX_PROPERTIES_PER_ITEM);91 });92 93 itSub('NESTING_BUDGET', () => {94 checkConst(api.consts.unique.nestingBudget, NESTING_BUDGET);95 });96 97 itSub('MAX_TOKEN_PROPERTIES_SIZE', () => {98 checkConst(api.consts.unique.maxTokenPropertiesSize, MAX_TOKEN_PROPERTIES_SIZE);99 });100 101 itSub('COLLECTION_ADMINS_LIMIT', () => {102 checkConst(api.consts.unique.collectionAdminsLimit, COLLECTION_ADMINS_LIMIT);103 });104});105106function checkConst<T>(constValue: any, expectedValue: T) {107 expect(constValue.toBigInt()).equal(expectedValue);108}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/>.1617import {ApiPromise} from '@polkadot/api';18import {ApiBase} from '@polkadot/api/base';19import {usingPlaygrounds, itSub, expect} from './util';202122const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;23const MAX_COLLECTION_NAME_LENGTH = 64n;24const COLLECTION_ADMINS_LIMIT = 5n;25const MAX_COLLECTION_PROPERTIES_SIZE = 40960n;26const MAX_TOKEN_PREFIX_LENGTH = 16n;27const MAX_PROPERTY_KEY_LENGTH = 256n;28const MAX_PROPERTY_VALUE_LENGTH = 32768n;29const MAX_PROPERTIES_PER_ITEM = 64n;30const MAX_TOKEN_PROPERTIES_SIZE = 32768n;31const NESTING_BUDGET = 5n;3233const DEFAULT_COLLETCTION_LIMIT = {34 accountTokenOwnershipLimit: '1,000,000',35 sponsoredDataSize: '2,048',36 sponsoredDataRateLimit: 'SponsoringDisabled',37 tokenLimit: '4,294,967,295',38 sponsorTransferTimeout: '5',39 sponsorApproveTimeout: '5',40 ownerCanTransfer: false,41 ownerCanDestroy: true,42 transfersEnabled: true,43};4445const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';46const HELPERS_CONTRACT_ADDRESS = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';4748describe('integration test: API UNIQUE consts', () => {49 let api: ApiPromise;50 51 before(async () => {52 await usingPlaygrounds(async (helper) => {53 api = await helper.getApi();54 });55 });56 57 itSub('DEFAULT_NFT_COLLECTION_LIMITS', () => {58 expect(api.consts.unique.nftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);59 });60 61 itSub('DEFAULT_RFT_COLLECTION_LIMITS', () => {62 expect(api.consts.unique.rftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);63 });64 65 itSub('DEFAULT_FT_COLLECTION_LIMITS', () => {66 expect(api.consts.unique.ftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);67 });68 69 itSub('MAX_COLLECTION_NAME_LENGTH', () => {70 checkConst(api.consts.unique.maxCollectionNameLength, MAX_COLLECTION_NAME_LENGTH);71 });72 73 itSub('MAX_COLLECTION_DESCRIPTION_LENGTH', () => {74 checkConst(api.consts.unique.maxCollectionDescriptionLength, MAX_COLLECTION_DESCRIPTION_LENGTH);75 });76 77 itSub('MAX_COLLECTION_PROPERTIES_SIZE', () => {78 checkConst(api.consts.unique.maxCollectionPropertiesSize, MAX_COLLECTION_PROPERTIES_SIZE);79 });8081 itSub('MAX_TOKEN_PREFIX_LENGTH', () => {82 checkConst(api.consts.unique.maxTokenPrefixLength, MAX_TOKEN_PREFIX_LENGTH);83 });8485 itSub('MAX_PROPERTY_KEY_LENGTH', () => {86 checkConst(api.consts.unique.maxPropertyKeyLength, MAX_PROPERTY_KEY_LENGTH);87 });88 89 itSub('MAX_PROPERTY_VALUE_LENGTH', () => {90 checkConst(api.consts.unique.maxPropertyValueLength, MAX_PROPERTY_VALUE_LENGTH);91 });92 93 itSub('MAX_PROPERTIES_PER_ITEM', () => {94 checkConst(api.consts.unique.maxPropertiesPerItem, MAX_PROPERTIES_PER_ITEM);95 });96 97 itSub('NESTING_BUDGET', () => {98 checkConst(api.consts.unique.nestingBudget, NESTING_BUDGET);99 });100 101 itSub('MAX_TOKEN_PROPERTIES_SIZE', () => {102 checkConst(api.consts.unique.maxTokenPropertiesSize, MAX_TOKEN_PROPERTIES_SIZE);103 });104 105 itSub('COLLECTION_ADMINS_LIMIT', () => {106 checkConst(api.consts.unique.collectionAdminsLimit, COLLECTION_ADMINS_LIMIT);107 });108 109 itSub('HELPERS_CONTRACT_ADDRESS', () => {110 expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(HELPERS_CONTRACT_ADDRESS.toLowerCase());111 });112 113 itSub('EVM_COLLECTION_HELPERS_ADDRESS', () => {114 expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS.toLowerCase());115 });116});117118function checkConst<T>(constValue: any, expectedValue: T) {119 expect(constValue.toBigInt()).equal(expectedValue);120}tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -103,12 +103,12 @@
contractHelpers(caller: string): Contract {
const web3 = this.helper.getWeb3();
- return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, gas: this.helper.eth.DEFAULT_GAS});
+ return new web3.eth.Contract(contractHelpersAbi as any, this.helper.getApi().consts.evmContractHelpers.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});
}
collectionHelpers(caller: string) {
const web3 = this.helper.getWeb3();
- return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});
+ return new web3.eth.Contract(collectionHelpersAbi as any, this.helper.getApi().consts.common.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});
}
collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false): Contract {
tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-consts.ts
+++ b/tests/src/interfaces/augment-api-consts.ts
@@ -8,7 +8,7 @@
import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';
import type { Option, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { Codec } from '@polkadot/types-codec/types';
-import type { Perbill, Permill, Weight } from '@polkadot/types/interfaces/runtime';
+import type { H160, Perbill, Permill, Weight } from '@polkadot/types/interfaces/runtime';
import type { FrameSupportPalletId, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion, SpWeightsRuntimeDbWeight, UpDataStructsCollectionLimits, XcmV1MultiLocation } from '@polkadot/types/lookup';
export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;
@@ -70,6 +70,10 @@
**/
collectionCreationPrice: u128 & AugmentedConst<ApiType>;
/**
+ * Address under which the CollectionHelper contract would be available.
+ **/
+ contractAddress: H160 & AugmentedConst<ApiType>;
+ /**
* Generic const
**/
[key: string]: Codec;
@@ -82,6 +86,16 @@
**/
[key: string]: Codec;
};
+ evmContractHelpers: {
+ /**
+ * Address, under which magic contract will be available
+ **/
+ contractAddress: H160 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
inflation: {
/**
* Number of blocks that pass between treasury balance updates due to inflation
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -2936,13 +2936,13 @@
}
},
/**
- * Lookup340: pallet_maintenance::pallet::Call<T>
+ * Lookup338: pallet_maintenance::pallet::Call<T>
**/
PalletMaintenanceCall: {
_enum: ['enable', 'disable']
},
/**
- * Lookup341: pallet_test_utils::pallet::Call<T>
+ * Lookup339: pallet_test_utils::pallet::Call<T>
**/
PalletTestUtilsCall: {
_enum: {
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -3175,14 +3175,14 @@
readonly type: 'Begin' | 'SetData' | 'Finish' | 'InsertEthLogs' | 'InsertEvents';
}
- /** @name PalletMaintenanceCall (340) */
+ /** @name PalletMaintenanceCall (338) */
interface PalletMaintenanceCall extends Enum {
readonly isEnable: boolean;
readonly isDisable: boolean;
readonly type: 'Enable' | 'Disable';
}
- /** @name PalletTestUtilsCall (341) */
+ /** @name PalletTestUtilsCall (339) */
interface PalletTestUtilsCall extends Enum {
readonly isEnable: boolean;
readonly isSetTestValue: boolean;