difftreelog
feat add delete properties
in: master
17 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -117,8 +117,6 @@
/// @param key Property key.
#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {
- self.consume_store_reads_and_writes(1, 1)?;
-
let caller = T::CrossAccountId::from_eth(caller);
let key = <Vec<u8>>::from(key)
.try_into()
@@ -127,6 +125,24 @@
<Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ #[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]
+ fn delete_collection_properties(&mut self, caller: caller, keys: Vec<string>) -> Result<()> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let keys = keys
+ .into_iter()
+ .map(|key| {
+ <Vec<u8>>::from(key)
+ .try_into()
+ .map_err(|_| Error::Revert("key too large".into()))
+ })
+ .collect::<Result<Vec<_>>>()?;
+
+ <Pallet<T>>::delete_collection_properties(self, &caller, keys).map_err(dispatch_to_evm::<T>)
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -146,28 +162,34 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
fn collection_properties(&self, keys: Vec<string>) -> Result<Vec<(string, bytes)>> {
- let mut keys_ = Vec::<PropertyKey>::with_capacity(keys.len());
- for key in keys {
- keys_.push(
+ let keys = keys
+ .into_iter()
+ .map(|key| {
<Vec<u8>>::from(key)
.try_into()
- .map_err(|_| Error::Revert("key too large".into()))?,
- )
- }
- let properties = Pallet::<T>::filter_collection_properties(self.id, Some(keys_))
- .map_err(dispatch_to_evm::<T>)?;
+ .map_err(|_| Error::Revert("key too large".into()))
+ })
+ .collect::<Result<Vec<_>>>()?;
- let mut properties_ = Vec::<(string, bytes)>::with_capacity(properties.len());
- for p in properties {
- let key =
- string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;
- let value = bytes(p.value.to_vec());
- properties_.push((key, value));
- }
- Ok(properties_)
+ let properties = Pallet::<T>::filter_collection_properties(
+ self.id,
+ if keys.is_empty() { None } else { Some(keys) },
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+
+ let properties = properties
+ .into_iter()
+ .map(|p| {
+ let key =
+ string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;
+ let value = bytes(p.value.to_vec());
+ Ok((key, value))
+ })
+ .collect::<Result<Vec<_>>>()?;
+ Ok(properties)
}
/// Set the sponsor of the collection.
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -55,6 +55,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -72,7 +83,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -91,7 +91,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -128,6 +128,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -145,7 +156,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -91,7 +91,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -128,6 +128,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -145,7 +156,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -37,6 +37,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -49,7 +56,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -62,7 +62,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -86,6 +86,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -98,7 +105,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -62,7 +62,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -86,6 +86,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -98,7 +105,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -16,7 +16,7 @@
import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
import {Pallets} from '../util';
-import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
+import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
import {IKeyringPair} from '@polkadot/types/types';
describe('EVM collection properties', () => {
@@ -163,29 +163,89 @@
});
describe('EVM collection property', () => {
- itEth('Set/read properties', async ({helper, privateKey}) => {
- const alice = await privateKey('//Alice');
- const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+ let alice: IKeyringPair;
+
+ before(() => {
+ usingEthPlaygrounds(async (_helper, privateKey) => {
+ alice = await privateKey('//Alice');
+ });
+ });
+
+ async function testSetReadProperties(helper: EthUniqueHelper, mode: TCollectionMode) {
+ const collection = await helper[mode].mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
const sender = await helper.eth.createAccountWithBalance(alice, 100n);
await collection.addAdmin(alice, {Ethereum: sender});
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
- const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', sender);
+ const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);
- const key1 = 'key1';
- const value1 = Buffer.from('value1');
-
- const key2 = 'key2';
- const value2 = Buffer.from('value2');
+ const keys = ['key0', 'key1'];
const writeProperties = [
- [key1, '0x'+value1.toString('hex')],
- [key2, '0x'+value2.toString('hex')],
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
];
await contract.methods.setCollectionProperties(writeProperties).send();
- const readProperties = await contract.methods.collectionProperties([key1, key2]).call();
+ const readProperties = await contract.methods.collectionProperties([keys[0], keys[1]]).call();
expect(readProperties).to.be.like(writeProperties);
+ }
+
+ itEth('Set/read properties ft', async ({helper}) => {
+ await testSetReadProperties(helper, 'ft');
+ });
+ itEth('Set/read properties rft', async ({helper}) => {
+ await testSetReadProperties(helper, 'rft');
+ });
+ itEth('Set/read properties nft', async ({helper}) => {
+ await testSetReadProperties(helper, 'nft');
+ });
+
+ async function testDeleteProperties(helper: EthUniqueHelper, mode: TCollectionMode) {
+ const collection = await helper[mode].mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+ const sender = await helper.eth.createAccountWithBalance(alice, 100n);
+ await collection.addAdmin(alice, {Ethereum: sender});
+
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);
+
+ const keys = ['key0', 'key1', 'key2', 'key3'];
+
+ {
+ const writeProperties = [
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
+ helper.ethProperty.property(keys[2], 'value2'),
+ helper.ethProperty.property(keys[3], 'value3'),
+ ];
+
+ await contract.methods.setCollectionProperties(writeProperties).send();
+ const readProperties = await contract.methods.collectionProperties([keys[0], keys[1], keys[2], keys[3]]).call();
+ expect(readProperties).to.be.like(writeProperties);
+ }
+
+ {
+ const expectProperties = [
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
+ ];
+
+ await contract.methods.deleteCollectionProperties([keys[2], keys[3]]).send();
+ const readProperties = await contract.methods.collectionProperties([]).call();
+ expect(readProperties).to.be.like(expectProperties);
+ }
+ }
+
+ itEth('Delete properties ft', async ({helper}) => {
+ await testDeleteProperties(helper, 'ft');
+ });
+ itEth('Delete properties rft', async ({helper}) => {
+ await testDeleteProperties(helper, 'rft');
});
+ itEth('Delete properties nft', async ({helper}) => {
+ await testDeleteProperties(helper, 'nft');
+ });
+
});
tests/src/eth/fungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -293,6 +293,15 @@
"type": "function"
},
{
+ "inputs": [
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
+ ],
+ "name": "deleteCollectionProperties",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -316,6 +316,15 @@
"type": "function"
},
{
+ "inputs": [
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
+ ],
+ "name": "deleteCollectionProperties",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -298,6 +298,15 @@
"type": "function"
},
{
+ "inputs": [
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
+ ],
+ "name": "deleteCollectionProperties",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -19,3 +19,6 @@
readonly field_0: string,
readonly field_1: string | Uint8Array,
}
+
+export type EthProperty = string[];
+
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
@@ -18,7 +18,7 @@
import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';
-import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent} from './types';
+import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';
// Native contracts ABI
import collectionHelpersAbi from '../../collectionHelpersAbi.json';
@@ -28,6 +28,7 @@
import refungibleTokenAbi from '../../reFungibleTokenAbi.json';
import contractHelpersAbi from './../contractHelpersAbi.json';
import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
+import {TCollectionMode} from '../../../util/playgrounds/types';
class EthGroupBase {
helper: EthUniqueHelper;
@@ -107,7 +108,7 @@
return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});
}
- collection(address: string, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {
+ collection(address: string, mode: TCollectionMode, caller?: string): Contract {
const abi = {
'nft': nonFungibleAbi,
'rft': refungibleAbi,
@@ -336,8 +337,16 @@
normalizeAddress(address: string): string {
return '0x' + address.substring(address.length - 40);
}
-}
+}
+export class EthPropertyGroup extends EthGroupBase {
+ property(key: string, value: string): EthProperty {
+ return [
+ key,
+ '0x'+Buffer.from(value).toString('hex'),
+ ];
+ }
+}
export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
export class EthCrossAccountGroup extends EthGroupBase {
@@ -369,6 +378,7 @@
ethNativeContract: NativeContractGroup;
ethContract: ContractGroup;
ethCrossAccount: EthCrossAccountGroup;
+ ethProperty: EthPropertyGroup;
constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
options.helperBase = options.helperBase ?? EthUniqueHelper;
@@ -379,6 +389,7 @@
this.ethCrossAccount = new EthCrossAccountGroup(this);
this.ethNativeContract = new NativeContractGroup(this);
this.ethContract = new ContractGroup(this);
+ this.ethProperty = new EthPropertyGroup(this);
}
getWeb3(): Web3 {
tests/src/util/playgrounds/types.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IEvent {7 section: string;8 method: string;9 index: [number, number] | string;10 data: any[];11 phase: {applyExtrinsic: number} | 'Initialization',12}1314export interface ITransactionResult {15 status: 'Fail' | 'Success';16 result: {17 dispatchError: any,18 events: {19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',20 event: IEvent;21 }[];22 },23 moduleError?: string;24}2526export interface ISubscribeBlockEventsData {27 number: number;28 hash: string;29 timestamp: number; 30 events: IEvent[];31}3233export interface ILogger {34 log: (msg: any, level?: string) => void;35 level: {36 ERROR: 'ERROR';37 WARNING: 'WARNING';38 INFO: 'INFO';39 [key: string]: string;40 }41}4243export interface IUniqueHelperLog {44 executedAt: number;45 executionTime: number;46 type: 'extrinsic' | 'rpc';47 status: 'Fail' | 'Success';48 call: string;49 params: any[];50 moduleError?: string;51 dispatchError?: any;52 events?: any;53}5455export interface IApiListeners {56 connected?: (...args: any[]) => any;57 disconnected?: (...args: any[]) => any;58 error?: (...args: any[]) => any;59 ready?: (...args: any[]) => any; 60 decorated?: (...args: any[]) => any;61}6263export interface ICrossAccountId {64 Substrate?: TSubstrateAccount;65 Ethereum?: TEthereumAccount;66}6768export interface ICrossAccountIdLower {69 substrate?: TSubstrateAccount;70 ethereum?: TEthereumAccount;71}7273export interface IEthCrossAccountId {74 0: TEthereumAccount;75 1: TSubstrateAccount;76 field_0: TEthereumAccount;77 field_1: TSubstrateAccount;78}7980export interface ICollectionLimits {81 accountTokenOwnershipLimit?: number | null;82 sponsoredDataSize?: number | null;83 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;84 tokenLimit?: number | null;85 sponsorTransferTimeout?: number | null;86 sponsorApproveTimeout?: number | null;87 ownerCanTransfer?: boolean | null;88 ownerCanDestroy?: boolean | null;89 transfersEnabled?: boolean | null;90}9192export interface INestingPermissions {93 tokenOwner?: boolean;94 collectionAdmin?: boolean;95 restricted?: number[] | null;96}9798export interface ICollectionPermissions {99 access?: 'Normal' | 'AllowList';100 mintMode?: boolean;101 nesting?: INestingPermissions;102}103104export interface IProperty {105 key: string;106 value?: string;107}108109export interface ITokenPropertyPermission {110 key: string;111 permission: {112 mutable?: boolean;113 tokenOwner?: boolean;114 collectionAdmin?: boolean;115 }116}117118export interface IToken {119 collectionId: number;120 tokenId: number;121}122123export interface IBlock {124 extrinsics: IExtrinsic[]125 header: {126 parentHash: string,127 number: number,128 };129}130131export interface IExtrinsic {132 isSigned: boolean,133 method: {134 method: string,135 section: string,136 args: any[]137 }138}139140export interface ICollectionCreationOptions {141 name?: string | number[];142 description?: string | number[];143 tokenPrefix?: string | number[];144 mode?: {145 nft?: null;146 refungible?: null;147 fungible?: number;148 }149 permissions?: ICollectionPermissions;150 properties?: IProperty[];151 tokenPropertyPermissions?: ITokenPropertyPermission[];152 limits?: ICollectionLimits;153 pendingSponsor?: TSubstrateAccount;154}155156export interface IChainProperties {157 ss58Format: number;158 tokenDecimals: number[];159 tokenSymbol: string[]160}161162export interface ISubstrateBalance {163 free: bigint,164 reserved: bigint,165 miscFrozen: bigint,166 feeFrozen: bigint167}168169export interface IStakingInfo {170 block: bigint,171 amount: bigint,172}173174export interface ISchedulerOptions {175 priority?: number,176 periodic?: {177 period: number,178 repetitions: number,179 },180}181182export interface IForeignAssetMetadata {183 name?: number | Uint8Array,184 symbol?: string,185 decimals?: number,186 minimalBalance?: bigint,187}188189export interface MoonbeamAssetInfo {190 location: any,191 metadata: {192 name: string,193 symbol: string,194 decimals: number,195 isFrozen: boolean,196 minimalBalance: bigint,197 },198 existentialDeposit: bigint,199 isSufficient: boolean,200 unitsPerSecond: bigint,201 numAssetsWeightHint: number,202}203204export interface AcalaAssetMetadata {205 name: string,206 symbol: string,207 decimals: number,208 minimalBalance: bigint,209}210211export interface DemocracyStandardAccountVote {212 balance: bigint,213 vote: {214 aye: boolean,215 conviction: number,216 },217}218219export type TSubstrateAccount = string;220export type TEthereumAccount = string;221export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';222export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';223export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';224export type TRelayNetworks = 'rococo' | 'westend';225export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;226export type TSigner = IKeyringPair; // | 'string'1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IEvent {7 section: string;8 method: string;9 index: [number, number] | string;10 data: any[];11 phase: {applyExtrinsic: number} | 'Initialization',12}1314export interface ITransactionResult {15 status: 'Fail' | 'Success';16 result: {17 dispatchError: any,18 events: {19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',20 event: IEvent;21 }[];22 },23 moduleError?: string;24}2526export interface ISubscribeBlockEventsData {27 number: number;28 hash: string;29 timestamp: number; 30 events: IEvent[];31}3233export interface ILogger {34 log: (msg: any, level?: string) => void;35 level: {36 ERROR: 'ERROR';37 WARNING: 'WARNING';38 INFO: 'INFO';39 [key: string]: string;40 }41}4243export interface IUniqueHelperLog {44 executedAt: number;45 executionTime: number;46 type: 'extrinsic' | 'rpc';47 status: 'Fail' | 'Success';48 call: string;49 params: any[];50 moduleError?: string;51 dispatchError?: any;52 events?: any;53}5455export interface IApiListeners {56 connected?: (...args: any[]) => any;57 disconnected?: (...args: any[]) => any;58 error?: (...args: any[]) => any;59 ready?: (...args: any[]) => any; 60 decorated?: (...args: any[]) => any;61}6263export interface ICrossAccountId {64 Substrate?: TSubstrateAccount;65 Ethereum?: TEthereumAccount;66}6768export interface ICrossAccountIdLower {69 substrate?: TSubstrateAccount;70 ethereum?: TEthereumAccount;71}7273export interface IEthCrossAccountId {74 0: TEthereumAccount;75 1: TSubstrateAccount;76 field_0: TEthereumAccount;77 field_1: TSubstrateAccount;78}7980export interface ICollectionLimits {81 accountTokenOwnershipLimit?: number | null;82 sponsoredDataSize?: number | null;83 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;84 tokenLimit?: number | null;85 sponsorTransferTimeout?: number | null;86 sponsorApproveTimeout?: number | null;87 ownerCanTransfer?: boolean | null;88 ownerCanDestroy?: boolean | null;89 transfersEnabled?: boolean | null;90}9192export interface INestingPermissions {93 tokenOwner?: boolean;94 collectionAdmin?: boolean;95 restricted?: number[] | null;96}9798export interface ICollectionPermissions {99 access?: 'Normal' | 'AllowList';100 mintMode?: boolean;101 nesting?: INestingPermissions;102}103104export interface IProperty {105 key: string;106 value?: string;107}108109export interface ITokenPropertyPermission {110 key: string;111 permission: {112 mutable?: boolean;113 tokenOwner?: boolean;114 collectionAdmin?: boolean;115 }116}117118export interface IToken {119 collectionId: number;120 tokenId: number;121}122123export interface IBlock {124 extrinsics: IExtrinsic[]125 header: {126 parentHash: string,127 number: number,128 };129}130131export interface IExtrinsic {132 isSigned: boolean,133 method: {134 method: string,135 section: string,136 args: any[]137 }138}139140export interface ICollectionCreationOptions {141 name?: string | number[];142 description?: string | number[];143 tokenPrefix?: string | number[];144 mode?: {145 nft?: null;146 refungible?: null;147 fungible?: number;148 }149 permissions?: ICollectionPermissions;150 properties?: IProperty[];151 tokenPropertyPermissions?: ITokenPropertyPermission[];152 limits?: ICollectionLimits;153 pendingSponsor?: TSubstrateAccount;154}155156export interface IChainProperties {157 ss58Format: number;158 tokenDecimals: number[];159 tokenSymbol: string[]160}161162export interface ISubstrateBalance {163 free: bigint,164 reserved: bigint,165 miscFrozen: bigint,166 feeFrozen: bigint167}168169export interface IStakingInfo {170 block: bigint,171 amount: bigint,172}173174export interface ISchedulerOptions {175 priority?: number,176 periodic?: {177 period: number,178 repetitions: number,179 },180}181182export interface IForeignAssetMetadata {183 name?: number | Uint8Array,184 symbol?: string,185 decimals?: number,186 minimalBalance?: bigint,187}188189export interface MoonbeamAssetInfo {190 location: any,191 metadata: {192 name: string,193 symbol: string,194 decimals: number,195 isFrozen: boolean,196 minimalBalance: bigint,197 },198 existentialDeposit: bigint,199 isSufficient: boolean,200 unitsPerSecond: bigint,201 numAssetsWeightHint: number,202}203204export interface AcalaAssetMetadata {205 name: string,206 symbol: string,207 decimals: number,208 minimalBalance: bigint,209}210211export interface DemocracyStandardAccountVote {212 balance: bigint,213 vote: {214 aye: boolean,215 conviction: number,216 },217}218219export type TSubstrateAccount = string;220export type TEthereumAccount = string;221export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';222export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';223export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';224export type TRelayNetworks = 'rococo' | 'westend';225export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;226export type TSigner = IKeyringPair; // | 'string'227export type TCollectionMode = 'nft' | 'rft' | 'ft';