From 5aafe0c25b7b090472d3ce3d244b3a52ce31192e Mon Sep 17 00:00:00 2001 From: PraetorP Date: Thu, 24 Nov 2022 08:30:14 +0000 Subject: [PATCH] add contracts consts --- --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -376,6 +376,7 @@ type TreasuryAccountId: Get; /// Address under which the CollectionHelper contract would be available. + #[pallet::constant] type ContractAddress: Get; /// Mapper for token addresses to Ethereum addresses. --- a/pallets/evm-contract-helpers/src/lib.rs +++ b/pallets/evm-contract-helpers/src/lib.rs @@ -47,6 +47,7 @@ type RuntimeEvent: IsType<::RuntimeEvent> + From>; /// Address, under which magic contract will be available + #[pallet::constant] type ContractAddress: Get; /// In case of enabled sponsoring, but no sponsoring rate limit set, --- a/tests/src/apiConsts.test.ts +++ b/tests/src/apiConsts.test.ts @@ -15,6 +15,7 @@ // along with Unique Network. If not, see . import {ApiPromise} from '@polkadot/api'; +import {ApiBase} from '@polkadot/api/base'; import {usingPlaygrounds, itSub, expect} from './util'; @@ -41,6 +42,9 @@ transfersEnabled: true, }; +const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f'; +const HELPERS_CONTRACT_ADDRESS = '0x842899ECF380553E8a4de75bF534cdf6fBF64049'; + describe('integration test: API UNIQUE consts', () => { let api: ApiPromise; @@ -101,6 +105,14 @@ itSub('COLLECTION_ADMINS_LIMIT', () => { checkConst(api.consts.unique.collectionAdminsLimit, COLLECTION_ADMINS_LIMIT); }); + + itSub('HELPERS_CONTRACT_ADDRESS', () => { + expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(HELPERS_CONTRACT_ADDRESS.toLowerCase()); + }); + + itSub('EVM_COLLECTION_HELPERS_ADDRESS', () => { + expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS.toLowerCase()); + }); }); function checkConst(constValue: any, expectedValue: T) { --- 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 { --- 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 = AugmentedConst; @@ -70,6 +70,10 @@ **/ collectionCreationPrice: u128 & AugmentedConst; /** + * Address under which the CollectionHelper contract would be available. + **/ + contractAddress: H160 & AugmentedConst; + /** * Generic const **/ [key: string]: Codec; @@ -82,6 +86,16 @@ **/ [key: string]: Codec; }; + evmContractHelpers: { + /** + * Address, under which magic contract will be available + **/ + contractAddress: H160 & AugmentedConst; + /** + * Generic const + **/ + [key: string]: Codec; + }; inflation: { /** * Number of blocks that pass between treasury balance updates due to inflation --- a/tests/src/interfaces/lookup.ts +++ b/tests/src/interfaces/lookup.ts @@ -2936,13 +2936,13 @@ } }, /** - * Lookup340: pallet_maintenance::pallet::Call + * Lookup338: pallet_maintenance::pallet::Call **/ PalletMaintenanceCall: { _enum: ['enable', 'disable'] }, /** - * Lookup341: pallet_test_utils::pallet::Call + * Lookup339: pallet_test_utils::pallet::Call **/ PalletTestUtilsCall: { _enum: { --- 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; -- gitstuff