difftreelog
add `collectionComtractAddress` funtion to `CollectionHelpers` interface
in: master
13 files changed
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/erc.rsdiffbeforeafterboth491 Err("not implemented".into())491 Err("not implemented".into())492 }492 }493 493494 /// @notice Returns collection helper contract address 494 /// @notice Returns collection helper contract address495 fn collection_helper_address(&self) -> Result<address> {495 fn collection_helper_address(&self) -> Result<address> {496 Ok(T::ContractAddress::get())496 Ok(T::ContractAddress::get())497 }497 }pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/erc.rsdiffbeforeafterbothno syntactic changes
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/mod.rsdiffbeforeafterboth28 CollectionById,28 CollectionById,29 dispatch::CollectionDispatch,29 dispatch::CollectionDispatch,30 erc::{CollectionHelpersEvents, static_property::key},30 erc::{CollectionHelpersEvents, static_property::key},31 eth::{map_eth_to_id, collection_id_to_address},31 Pallet as PalletCommon,32 Pallet as PalletCommon,32};33};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};35use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};35use sp_std::vec;36use sp_std::vec;36use up_data_structs::{37use up_data_structs::{37 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,38 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,38 CreateCollectionData,39 CreateCollectionData, CollectionId,39};40};404141use crate::{weights::WeightInfo, Config, SelfWeightOf};42use crate::{weights::WeightInfo, Config, SelfWeightOf};362 Ok(price.into())363 Ok(price.into())363 }364 }365366 /// Returns address of a collection.367 /// @param collectionId - CollectionId of the collection368 /// @return eth mirror address of the collection369 fn collection_address(&self, collection_id: uint32) -> Result<address> {370 Ok(collection_id_to_address(collection_id.into()))371 }372373 /// Returns collectionId of a collection.374 /// @param collectionAddress - Eth address of the collection375 /// @return collectionId of the collection376 fn collection_id(&self, collection_address: address) -> Result<uint32> {377 map_eth_to_id(&collection_address)378 .map(|id| id.0)379 .ok_or(Error::Revert(format!(380 "failed to convert address {} into collectionId.",381 collection_address382 )))383 }364}384}365385366/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]386/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth24}24}252526/// @title Contract, which allows users to operate with collections26/// @title Contract, which allows users to operate with collections27/// @dev the ERC-165 identifier for this interface is 0x7dea03b127/// @dev the ERC-165 identifier for this interface is 0xe65011aa28contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {28contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {29 /// Create an NFT collection29 /// Create an NFT collection30 /// @param name Name of the collection30 /// @param name Name of the collection131 return 0;131 return 0;132 }132 }133134 /// Returns address of a collection.135 /// @param collectionId - CollectionId of the collection136 /// @return eth mirror address of the collection137 /// @dev EVM selector for this function is: 0x2e716683,138 /// or in textual repr: collectionAddress(uint32)139 function collectionAddress(uint32 collectionId) public view returns (address) {140 require(false, stub_error);141 collectionId;142 dummy;143 return 0x0000000000000000000000000000000000000000;144 }145146 /// Returns collectionId of a collection.147 /// @param collectionAddress - Eth address of the collection148 /// @return collectionId of the collection149 /// @dev EVM selector for this function is: 0xb5cb7498,150 /// or in textual repr: collectionId(address)151 function collectionId(address collectionAddress) public view returns (uint32) {152 require(false, stub_error);153 collectionAddress;154 dummy;155 return 0;156 }133}157}134158tests/src/eth/abi/collectionHelpers.jsondiffbeforeafterboth31 "name": "CollectionDestroyed",31 "name": "CollectionDestroyed",32 "type": "event"32 "type": "event"33 },33 },34 {35 "inputs": [36 { "internalType": "uint32", "name": "collectionId", "type": "uint32" }37 ],38 "name": "collectionAddress",39 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],40 "stateMutability": "view",41 "type": "function"42 },34 {43 {35 "inputs": [],44 "inputs": [],36 "name": "collectionCreationFee",45 "name": "collectionCreationFee",37 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],46 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],38 "stateMutability": "view",47 "stateMutability": "view",39 "type": "function"48 "type": "function"40 },49 },50 {51 "inputs": [52 {53 "internalType": "address",54 "name": "collectionAddress",55 "type": "address"56 }57 ],58 "name": "collectionId",59 "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],60 "stateMutability": "view",61 "type": "function"62 },41 {63 {42 "inputs": [64 "inputs": [43 { "internalType": "string", "name": "name", "type": "string" },65 { "internalType": "string", "name": "name", "type": "string" },tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth19}19}202021/// @title Contract, which allows users to operate with collections21/// @title Contract, which allows users to operate with collections22/// @dev the ERC-165 identifier for this interface is 0x7dea03b122/// @dev the ERC-165 identifier for this interface is 0xe65011aa23interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {23interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {24 /// Create an NFT collection24 /// Create an NFT collection25 /// @param name Name of the collection25 /// @param name Name of the collection79 /// or in textual repr: collectionCreationFee()79 /// or in textual repr: collectionCreationFee()80 function collectionCreationFee() external view returns (uint256);80 function collectionCreationFee() external view returns (uint256);8182 /// Returns address of a collection.83 /// @param collectionId - CollectionId of the collection84 /// @return eth mirror address of the collection85 /// @dev EVM selector for this function is: 0x2e716683,86 /// or in textual repr: collectionAddress(uint32)87 function collectionAddress(uint32 collectionId) external view returns (address);8889 /// Returns collectionId of a collection.90 /// @param collectionAddress - Eth address of the collection91 /// @return collectionId of the collection92 /// @dev EVM selector for this function is: 0xb5cb7498,93 /// or in textual repr: collectionId(address)94 function collectionId(address collectionAddress) external view returns (uint32);81}95}8296tests/src/eth/collectionHelperAddress.test.tsdiffbeforeafterboth161617import {itEth, usingEthPlaygrounds, expect} from './util';17import {itEth, usingEthPlaygrounds, expect} from './util';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets} from '../util';192020const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';21const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';212222describe('[eth]CollectionHelerpAddress test: ERC721 ', () => {23describe('[eth]CollectionHelperAddress test: ERC20/ERC721 ', () => {23 let donor: IKeyringPair;24 let donor: IKeyringPair;242525 before(async function() {26 before(async function() {28 });29 });29 });30 });303131 itEth('NFT\\RFT', async ({helper}) => {32 itEth('NFT', async ({helper}) => {32 const owner = await helper.eth.createAccountWithBalance(donor);33 const owner = await helper.eth.createAccountWithBalance(donor);33 34 34 const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');35 const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');35 const nftCollection = helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);36 const nftCollection = helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);36 37 37 const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');38 const rftCollection = helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);39 40 expect((await nftCollection.methods.collectionHelperAddress().call())38 expect((await nftCollection.methods.collectionHelperAddress().call())41 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);39 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);42 43 expect((await rftCollection.methods.collectionHelperAddress().call())44 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);45 });40 });46 41 42 itEth.ifWithPallets('RFT ', [Pallets.ReFungible], async ({helper}) => {43 const owner = await helper.eth.createAccountWithBalance(donor);4445 const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');4647 const rftCollection = helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);48 expect((await rftCollection.methods.collectionHelperAddress().call())49 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);50 });51 47 itEth('FT', async ({helper}) => {52 itEth('FT', async ({helper}) => {48 const owner = await helper.eth.createAccountWithBalance(donor);53 const owner = await helper.eth.createAccountWithBalance(donor);54 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);59 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);55 });60 });56 61 62 itEth('[collectionHelpers] convert collectionId into address', async ({helper}) => {63 const owner = await helper.eth.createAccountWithBalance(donor);64 const collectionId = 7;65 const collectionAddress = helper.ethAddress.fromCollectionId(collectionId);66 const helperContract = helper.ethNativeContract.collectionHelpers(owner);67 68 expect(await helperContract.methods.collectionAddress(collectionId).call()).to.be.equal(collectionAddress);69 expect(parseInt(await helperContract.methods.collectionId(collectionAddress).call())).to.be.equal(collectionId);70 });71 57});72});5873tests/src/interfaces/lookup.tsdiffbeforeafterboth2935 }2935 }2936 }2936 }2937 },2937 },2938 /**2938 /**2939 * Lookup338: pallet_maintenance::pallet::Call<T>2939 * Lookup340: pallet_maintenance::pallet::Call<T>2940 **/2940 **/2941 PalletMaintenanceCall: {2941 PalletMaintenanceCall: {2942 _enum: ['enable', 'disable']2942 _enum: ['enable', 'disable']2943 },2943 },2944 /**2944 /**2945 * Lookup339: pallet_test_utils::pallet::Call<T>2945 * Lookup341: pallet_test_utils::pallet::Call<T>2946 **/2946 **/2947 PalletTestUtilsCall: {2947 PalletTestUtilsCall: {2948 _enum: {2948 _enum: {2949 enable: 'Null',2949 enable: 'Null',tests/src/interfaces/types-lookup.tsdiffbeforeafterboth3175 readonly type: 'Begin' | 'SetData' | 'Finish' | 'InsertEthLogs' | 'InsertEvents';3175 readonly type: 'Begin' | 'SetData' | 'Finish' | 'InsertEthLogs' | 'InsertEvents';3176 }3176 }317731773178 /** @name PalletMaintenanceCall (338) */3178 /** @name PalletMaintenanceCall (340) */3179 interface PalletMaintenanceCall extends Enum {3179 interface PalletMaintenanceCall extends Enum {3180 readonly isEnable: boolean;3180 readonly isEnable: boolean;3181 readonly isDisable: boolean;3181 readonly isDisable: boolean;3182 readonly type: 'Enable' | 'Disable';3182 readonly type: 'Enable' | 'Disable';3183 }3183 }318431843185 /** @name PalletTestUtilsCall (339) */3185 /** @name PalletTestUtilsCall (341) */3186 interface PalletTestUtilsCall extends Enum {3186 interface PalletTestUtilsCall extends Enum {3187 readonly isEnable: boolean;3187 readonly isEnable: boolean;3188 readonly isSetTestValue: boolean;3188 readonly isSetTestValue: boolean;