git.delta.rocks / unique-network / refs/commits / 966149d858c2

difftreelog

source

tests/src/interfaces/unique/definitions.ts5.7 KiBsourcehistory
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/>.1617type RpcParam = {18  name: string;19  type: string;20  isOptional?: true;21};2223const CROSS_ACCOUNT_ID_TYPE = 'PalletEvmAccountBasicCrossAccountIdRepr';2425const collectionParam = {name: 'collection', type: 'u32'};26const tokenParam = {name: 'tokenId', type: 'u32'};27const propertyKeysParam = {name: 'propertyKeys', type: 'Option<Vec<String>>', isOptional: true};28const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});29const atParam = {name: 'at', type: 'Hash', isOptional: true};3031const fun = (description: string, params: RpcParam[], type: string) => ({32  description,33  params: [...params, atParam],34  type,35});3637export default {38  types: {},39  rpc: {40    accountTokens: fun(41      'Get tokens owned by an account in a collection', 42      [collectionParam, crossAccountParam()], 43      'Vec<u32>',44    ),45    collectionTokens: fun(46      'Get tokens contained within a collection', 47      [collectionParam], 48      'Vec<u32>',49    ),50    tokenExists: fun(51      'Check if the token exists', 52      [collectionParam, tokenParam], 53      'bool',54    ),5556    tokenOwner: fun(57      'Get the token owner', 58      [collectionParam, tokenParam], 59      `Option<${CROSS_ACCOUNT_ID_TYPE}>`,60    ),61    topmostTokenOwner: fun(62      'Get the topmost token owner in the hierarchy of a possibly nested token', 63      [collectionParam, tokenParam], 64      `Option<${CROSS_ACCOUNT_ID_TYPE}>`,65    ),66    tokenOwners: fun(67      'Returns 10 tokens owners in no particular order', 68      [collectionParam, tokenParam], 69      `Vec<${CROSS_ACCOUNT_ID_TYPE}>`,70    ),71    tokenChildren: fun(72      'Get tokens nested directly into the token', 73      [collectionParam, tokenParam], 74      'Vec<UpDataStructsTokenChild>',75    ),7677    collectionProperties: fun(78      'Get collection properties, optionally limited to the provided keys',79      [collectionParam, propertyKeysParam],80      'Vec<UpDataStructsProperty>',81    ),82    tokenProperties: fun(83      'Get token properties, optionally limited to the provided keys',84      [collectionParam, tokenParam, propertyKeysParam],85      'Vec<UpDataStructsProperty>',86    ),87    propertyPermissions: fun(88      'Get property permissions, optionally limited to the provided keys',89      [collectionParam, propertyKeysParam],90      'Vec<UpDataStructsPropertyKeyPermission>',91    ),9293    constMetadata: fun(94      'Get token constant metadata', 95      [collectionParam, tokenParam], 96      'Vec<u8>',97    ),98    variableMetadata: fun(99      'Get token variable metadata', 100      [collectionParam, tokenParam], 101      'Vec<u8>',102    ),103104    tokenData: fun(105      'Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT',106      [collectionParam, tokenParam, propertyKeysParam],107      'UpDataStructsTokenData',108    ),109    totalSupply: fun(110      'Get the amount of distinctive tokens present in a collection', 111      [collectionParam], 112      'u32',113    ),114115    accountBalance: fun(116      'Get the amount of any user tokens owned by an account', 117      [collectionParam, crossAccountParam()], 118      'u32',119    ),120    balance: fun(121      'Get the amount of a specific token owned by an account', 122      [collectionParam, crossAccountParam(), tokenParam], 123      'u128',124    ),125    allowance: fun(126      'Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor', 127      [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 128      'u128',129    ),130131    adminlist: fun(132      'Get the list of admin accounts of a collection', 133      [collectionParam], 134      'Vec<PalletEvmAccountBasicCrossAccountIdRepr>',135    ),136    allowlist: fun(137      'Get the list of accounts allowed to operate within a collection', 138      [collectionParam], 139      'Vec<PalletEvmAccountBasicCrossAccountIdRepr>',140    ),141    allowed: fun(142      'Check if a user is allowed to operate within a collection', 143      [collectionParam, crossAccountParam()], 144      'bool',145    ),146147    lastTokenId: fun(148      'Get the last token ID created in a collection', 149      [collectionParam], 150      'u32',151    ),152    collectionById: fun(153      'Get a collection by the specified ID', 154      [collectionParam], 155      'Option<UpDataStructsRpcCollection>',156    ),157    collectionStats: fun(158      'Get chain stats about collections', 159      [], 160      'UpDataStructsCollectionStats',161    ),162163    nextSponsored: fun(164      'Get the number of blocks until sponsoring a transaction is available', 165      [collectionParam, crossAccountParam(), tokenParam], 166      'Option<u64>',167    ),168    effectiveCollectionLimits: fun(169      'Get effective collection limits', 170      [collectionParam], 171      'Option<UpDataStructsCollectionLimits>',172    ),173    totalPieces: fun(174      'Get the total amount of pieces of an RFT', 175      [collectionParam, tokenParam], 176      'Option<u128>',177    ),178    allowanceForAll: fun(179      'Tells whether the given `owner` approves the `operator`.', 180      [collectionParam, crossAccountParam('owner'), crossAccountParam('operator')], 181      'Option<bool>',182    ),183  },184};