difftreelog
refactor `collection_limits`, add docs for `CollectionLimits`
in: master
9 files changed
pallets/common/src/erc.rsdiffbeforeafterboth358 ),358 ),359 limits359 limits360 .sponsored_data_rate_limit360 .sponsored_data_rate_limit361 .map(|limit| {361 .and_then(|limit| {362 (363 EvmCollectionLimits::SponsoredDataRateLimit,364 match limit {365 SponsoringRateLimit::Blocks(_) => true,362 if let SponsoringRateLimit::Blocks(blocks) = limit {366 _ => false,363 Some((367 },368 match limit {369 SponsoringRateLimit::Blocks(blocks) => blocks.into(),364 EvmCollectionLimits::SponsoredDataRateLimit,370 _ => Default::default(),365 true,366 blocks.into(),367 ))371 },368 } else {372 )369 None370 }373 })371 })374 .unwrap_or((372 .unwrap_or((375 EvmCollectionLimits::SponsoredDataRateLimit,373 EvmCollectionLimits::SponsoredDataRateLimit,pallets/common/src/eth.rsdiffbeforeafterboth156 }156 }157}157}158159/// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.158#[derive(Debug, Default, Clone, Copy, AbiCoder)]160#[derive(Debug, Default, Clone, Copy, AbiCoder)]159#[repr(u8)]161#[repr(u8)]160pub enum CollectionLimits {162pub enum CollectionLimits {tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth1import {IKeyringPair} from '@polkadot/types/types';1import {IKeyringPair} from '@polkadot/types/types';2import {Pallets} from '../util';2import {Pallets} from '../util';3import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';3import {expect, itEth, usingEthPlaygrounds} from './util';4import {CollectionLimits} from './util/playgrounds/types';45566describe('Can set collection limits', () => {7describe('Can set collection limits', () => {62 // Check limits from eth:63 // Check limits from eth:63 const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});64 const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});64 expect(limitsEvm).to.have.length(9);65 expect(limitsEvm).to.have.length(9);65 expect(limitsEvm[0]).to.deep.eq(['0', true, limits.accountTokenOwnershipLimit.toString()]);66 expect(limitsEvm[0]).to.deep.eq([CollectionLimits.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);66 expect(limitsEvm[1]).to.deep.eq(['1', true, limits.sponsoredDataSize.toString()]);67 expect(limitsEvm[1]).to.deep.eq([CollectionLimits.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);67 expect(limitsEvm[2]).to.deep.eq(['2', true, limits.sponsoredDataRateLimit.toString()]);68 expect(limitsEvm[2]).to.deep.eq([CollectionLimits.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);68 expect(limitsEvm[3]).to.deep.eq(['3', true, limits.tokenLimit.toString()]);69 expect(limitsEvm[3]).to.deep.eq([CollectionLimits.TokenLimit.toString(), true, limits.tokenLimit.toString()]);69 expect(limitsEvm[4]).to.deep.eq(['4', true, limits.sponsorTransferTimeout.toString()]);70 expect(limitsEvm[4]).to.deep.eq([CollectionLimits.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);70 expect(limitsEvm[5]).to.deep.eq(['5', true, limits.sponsorApproveTimeout.toString()]);71 expect(limitsEvm[5]).to.deep.eq([CollectionLimits.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);71 expect(limitsEvm[6]).to.deep.eq(['6', true, limits.ownerCanTransfer.toString()]);72 expect(limitsEvm[6]).to.deep.eq([CollectionLimits.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);72 expect(limitsEvm[7]).to.deep.eq(['7', true, limits.ownerCanDestroy.toString()]);73 expect(limitsEvm[7]).to.deep.eq([CollectionLimits.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);73 expect(limitsEvm[8]).to.deep.eq(['8', true, limits.transfersEnabled.toString()]);74 expect(limitsEvm[8]).to.deep.eq([CollectionLimits.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);74 }));75 }));75});76});7677tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {evmToAddress} from '@polkadot/util-crypto';18import {evmToAddress} from '@polkadot/util-crypto';19import {Pallets, requirePalletsOrSkip} from '../util';19import {Pallets, requirePalletsOrSkip} from '../util';20import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import { CollectionLimits } from './util/playgrounds/types';212222const DECIMALS = 18;23const DECIMALS = 18;2324tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth161617import {evmToAddress} from '@polkadot/util-crypto';17import {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';19import {expect, itEth, usingEthPlaygrounds} from './util';20import { CollectionLimits } from './util/playgrounds/types';2021212222describe('Create NFT collection from EVM', () => {23describe('Create NFT collection from EVM', () => {tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth17import {evmToAddress} from '@polkadot/util-crypto';17import {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets, requirePalletsOrSkip} from '../util';19import {Pallets, requirePalletsOrSkip} from '../util';20import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';20import {expect, itEth, usingEthPlaygrounds} from './util';21import { CollectionLimits } from './util/playgrounds/types';2122222323describe('Create RFT collection from EVM', () => {24describe('Create RFT collection from EVM', () => {tests/src/eth/events.test.tsdiffbeforeafterboth161617import {expect} from 'chai';17import {expect} from 'chai';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {CollectionLimits, EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';21import {Pallets, requirePalletsOrSkip} from '../util';21import {Pallets, requirePalletsOrSkip} from '../util';22import {EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';22import {CollectionLimits, EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';232324let donor: IKeyringPair;24let donor: IKeyringPair;25 25 tests/src/eth/util/index.tsdiffbeforeafterboth26 Allowlisted = 1,26 Allowlisted = 1,27 Generous = 2,27 Generous = 2,28}28}29export enum CollectionLimits {2930 AccountTokenOwnership,31 SponsoredDataSize,32 SponsoredDataRateLimit,33 TokenLimit,34 SponsorTransferTimeout,35 SponsorApproveTimeout,36 OwnerCanTransfer,37 OwnerCanDestroy,38 TransferEnabled39}403041export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {31export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {42 const silentConsole = new SilentConsole();32 const silentConsole = new SilentConsole();tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth25 TokenOwner,25 TokenOwner,26 CollectionAdmin26 CollectionAdmin27}27}28export enum CollectionLimits {29 AccountTokenOwnership,30 SponsoredDataSize,31 SponsoredDataRateLimit,32 TokenLimit,33 SponsorTransferTimeout,34 SponsorApproveTimeout,35 OwnerCanTransfer,36 OwnerCanDestroy,37 TransferEnabled38}39