git.delta.rocks / unique-network / refs/commits / 2a0daba54842

difftreelog

source

tests/src/interfaces/unique/definitions.ts2.1 KiBsourcehistory
1import types from '../lookup';23type RpcParam = {4  name: string;5  type: string;6  isOptional?: true;7};89const CROSS_ACCOUNT_ID_TYPE = 'PalletCommonAccountBasicCrossAccountIdRepr';1011const collectionParam = {name: 'collection', type: 'u32'};12const tokenParam = {name: 'tokenId', type: 'u32'};13const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});14const atParam = {name: 'at', type: 'Hash', isOptional: true};1516const fun = (description: string, params: RpcParam[], type: string) => ({17  description,18  params: [...params, atParam],19  type,20});2122export default {23  types,24  rpc: {25    adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),26    allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),2728    accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<u32>'),29    collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),3031    lastTokenId: fun('Get last token id', [collectionParam], 'u32'),32    accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),33    balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),34    allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),35    tokenOwner: fun('Get token owner', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),36    constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),37    variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),38    tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),39    collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),40    collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),41    allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),42  },43};