git.delta.rocks / unique-network / refs/commits / 7781ab982a4b

difftreelog

source

tests/src/interfaces/unique/definitions.ts4.3 KiBsourcehistory
1function mkDummy(name: string) {2  return {3    ['dummy' + name]: 'u32',4  };5}67type RpcParam = {8  name: string;9  type: string;10  isOptional?: true;11};1213const CROSS_ACCOUNT_ID_TYPE = 'PalletCommonAccountBasicCrossAccountIdRepr';14const TOKEN_ID_TYPE = 'UpDataStructsTokenId';1516const collectionParam = {name: 'collection', type: 'UpDataStructsCollectionId'};17const tokenParam = {name: 'tokenId', type: TOKEN_ID_TYPE};18const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});19const atParam = {name: 'at', type: 'Hash', isOptional: true};2021const fun = (description: string, params: RpcParam[], type: string) => ({22  description,23  params: [...params, atParam],24  type,25});2627export default {28  rpc: {29    adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),30    allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),3132    accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<UpDataStructsTokenId>'),33    collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<UpDataStructsTokenId>'),3435    lastTokenId: fun('Get last token id', [collectionParam], TOKEN_ID_TYPE),36    accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),37    balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),38    allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),39    tokenOwner: fun('Get token owner', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),40    constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),41    variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),42    tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),43    collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),44    collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),45    allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),46  },47  types: {48    PalletCommonAccountBasicCrossAccountIdRepr: {49      _enum: {50        Substrate: 'AccountId',51        Ethereum: 'H160',52      },53    },54    UpDataStructsCollection: {55      owner: 'AccountId',56      mode: 'UpDataStructsCollectionMode',57      access: 'UpDataStructsAccessMode',58      name: 'Vec<u16>',59      description: 'Vec<u16>',60      tokenPrefix: 'Vec<u8>',61      mintMode: 'bool',62      offchainSchema: 'Vec<u8>',63      schemaVersion: 'UpDataStructsSchemaVersion',64      sponsorship: 'UpDataStructsSponsorshipState',65      limits: 'UpDataStructsCollectionLimits',66      variableOnChainSchema: 'Vec<u8>',67      constOnChainSchema: 'Vec<u8>',68      metaUpdatePermission: 'UpDataStructsMetaUpdatePermission',69    },70    UpDataStructsCollectionStats: {71      created: 'u32',72      destroyed: 'u32',73      alive: 'u32',74    },75    UpDataStructsCollectionId: 'u32',76    UpDataStructsTokenId: 'u32',77    PalletNonfungibleItemData: mkDummy('NftItemData'),78    PalletRefungibleItemData: mkDummy('RftItemData'),79    UpDataStructsCollectionMode: mkDummy('CollectionMode'),80    UpDataStructsCreateItemData: mkDummy('CreateItemData'),81    UpDataStructsCollectionLimits: {82      accountTokenOwnershipLimit: 'Option<u32>',83      sponsoredDataSize: 'Option<u32>',84      sponsoredDataRateLimit: 'Option<u32>',85      tokenLimit: 'Option<u32>',86      sponsorTransferTimeout: 'Option<u32>',87      ownerCanTransfer: 'Option<bool>',88      ownerCanDestroy: 'Option<bool>',89      transfersEnabled: 'Option<bool>',90    },91    UpDataStructsMetaUpdatePermission: {92      _enum: ['ItemOwner', 'Admin', 'None'],93    },94    UpDataStructsSponsorshipState: {95      _enum: {96        Disabled: null,97        Unconfirmed: 'AccountId',98        Confirmed: 'AccountId',99      },100    },101    UpDataStructsAccessMode: {102      _enum: ['Normal', 'AllowList'],103    },104    UpDataStructsSchemaVersion: mkDummy('SchemaVersion'),105106    PalletUnqSchedulerScheduledV2: mkDummy('ScheduledV2'),107    PalletUnqSchedulerCallSpec: mkDummy('CallSpec'),108    PalletUnqSchedulerReleases: mkDummy('Releases'),109  },110};