git.delta.rocks / unique-network / refs/commits / 886d2a88cd00

difftreelog

source

tests/src/interfaces/unique/definitions.ts4.9 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    UpDataStructsCreateCollectionData: {71      mode: 'UpDataStructsCollectionMode',72      access: 'Option<UpDataStructsAccessMode>',73      name: 'Vec<u16>',74      description: 'Vec<u16>',75      tokenPrefix: 'Vec<u8>',76      offchainSchema: 'Vec<u8>',77      schemaVersion: 'Option<UpDataStructsSchemaVersion>',78      pendingSponsor: 'Option<AccountId>',79      limits: 'Option<UpDataStructsCollectionLimits>',80      variableOnChainSchema: 'Vec<u8>',81      constOnChainSchema: 'Vec<u8>',82      metaUpdatePermission: 'Option<UpDataStructsMetaUpdatePermission>',83    },84    UpDataStructsCollectionStats: {85      created: 'u32',86      destroyed: 'u32',87      alive: 'u32',88    },89    UpDataStructsCollectionId: 'u32',90    UpDataStructsTokenId: 'u32',91    PalletNonfungibleItemData: mkDummy('NftItemData'),92    PalletRefungibleItemData: mkDummy('RftItemData'),93    UpDataStructsCollectionMode: {94      _enum: {95        NFT: null,96        Fungible: 'u32',97        ReFungible: null,98      },99    },100    UpDataStructsCreateItemData: mkDummy('CreateItemData'),101    UpDataStructsCollectionLimits: {102      accountTokenOwnershipLimit: 'Option<u32>',103      sponsoredDataSize: 'Option<u32>',104      sponsoredDataRateLimit: 'Option<u32>',105      tokenLimit: 'Option<u32>',106      sponsorTransferTimeout: 'Option<u32>',107      ownerCanTransfer: 'Option<bool>',108      ownerCanDestroy: 'Option<bool>',109      transfersEnabled: 'Option<bool>',110    },111    UpDataStructsMetaUpdatePermission: {112      _enum: ['ItemOwner', 'Admin', 'None'],113    },114    UpDataStructsSponsorshipState: {115      _enum: {116        Disabled: null,117        Unconfirmed: 'AccountId',118        Confirmed: 'AccountId',119      },120    },121    UpDataStructsAccessMode: {122      _enum: ['Normal', 'AllowList'],123    },124    UpDataStructsSchemaVersion: {125      _enum: ['ImageURL', 'Unique'],126    },127128    PalletUnqSchedulerScheduledV2: mkDummy('ScheduledV2'),129    PalletUnqSchedulerCallSpec: mkDummy('CallSpec'),130    PalletUnqSchedulerReleases: mkDummy('Releases'),131  },132};