diff --git a/packages/metadata/src/metadata.gen.ts b/packages/metadata/src/metadata.gen.ts index 2c064bffb..ff6ffd464 100644 --- a/packages/metadata/src/metadata.gen.ts +++ b/packages/metadata/src/metadata.gen.ts @@ -1,23 +1,24 @@ /* eslint-disable */ -// sequence-metadata v0.4.0 594e38ba9f35eba08aac88087660d5f424b6dbda +// sequence-metadata v0.4.0 16b30ae85e42fc4c25342f7c43e04d7070597f21 // -- // Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=metadata.ridl -target=typescript -client -out=./clients/metadata.gen.ts // WebRPC description and code-gen version -export const WebRPCVersion = 'v1' +export const WebRPCVersion = "v1" // Schema version of your RIDL schema -export const WebRPCSchemaVersion = 'v0.4.0' +export const WebRPCSchemaVersion = "v0.4.0" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '594e38ba9f35eba08aac88087660d5f424b6dbda' +export const WebRPCSchemaHash = "16b30ae85e42fc4c25342f7c43e04d7070597f21" // // Types // + export enum ContractType { UNKNOWN = 'UNKNOWN', ERC20 = 'ERC20', @@ -63,14 +64,15 @@ export interface RuntimeStatus { checks: RuntimeChecks } -export interface RuntimeChecks {} +export interface RuntimeChecks { +} export interface ContractIndex { collectionId?: number chainId: number address: string type: ContractType - metadata: { [key: string]: any } + metadata: {[key: string]: any} contentHash: number deployed: boolean bytecodeHash: string @@ -83,7 +85,7 @@ export interface TokenIndex { chainId: number contractAddress: string tokenId: string - metadata: { [key: string]: any } + metadata: {[key: string]: any} notFound?: boolean lastFetched?: string fetchCount?: number @@ -123,8 +125,8 @@ export interface TokenMetadata { image?: string video?: string audio?: string - properties?: { [key: string]: any } - attributes: Array<{ [key: string]: any }> + properties?: {[key: string]: any} + attributes: Array<{[key: string]: any}> image_data?: string external_url?: string background_color?: string @@ -165,8 +167,8 @@ export interface CollectionMetadata { description?: string image?: string external_link?: string - properties?: { [key: string]: any } - attributes?: Array<{ [key: string]: any }> + properties?: {[key: string]: any} + attributes?: Array<{[key: string]: any}> } export interface CollectionBaseURIs { @@ -240,116 +242,54 @@ export interface Metadata { version(headers?: object, signal?: AbortSignal): Promise runtimeStatus(headers?: object, signal?: AbortSignal): Promise getTokenMetadata(args: GetTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise - refreshTokenMetadata( - args: RefreshTokenMetadataArgs, - headers?: object, - signal?: AbortSignal - ): Promise - enqueueTokensForRefresh( - args: EnqueueTokensForRefreshArgs, - headers?: object, - signal?: AbortSignal - ): Promise - getTokenRefreshStatus( - args: GetTokenRefreshStatusArgs, - headers?: object, - signal?: AbortSignal - ): Promise - getTokenRefreshResult( - args: GetTokenRefreshResultArgs, - headers?: object, - signal?: AbortSignal - ): Promise + refreshTokenMetadata(args: RefreshTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise + enqueueTokensForRefresh(args: EnqueueTokensForRefreshArgs, headers?: object, signal?: AbortSignal): Promise + getTokenRefreshStatus(args: GetTokenRefreshStatusArgs, headers?: object, signal?: AbortSignal): Promise + getTokenRefreshResult(args: GetTokenRefreshResultArgs, headers?: object, signal?: AbortSignal): Promise cancelRefreshJob(args: CancelRefreshJobArgs, headers?: object, signal?: AbortSignal): Promise - getTokenMetadataBatch( - args: GetTokenMetadataBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise + getTokenMetadataBatch(args: GetTokenMetadataBatchArgs, headers?: object, signal?: AbortSignal): Promise searchTokenMetadata(args: SearchTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise searchTokenIDs(args: SearchTokenIDsArgs, headers?: object, signal?: AbortSignal): Promise - tokenCollectionFilters( - args: TokenCollectionFiltersArgs, - headers?: object, - signal?: AbortSignal - ): Promise + tokenCollectionFilters(args: TokenCollectionFiltersArgs, headers?: object, signal?: AbortSignal): Promise getContractInfo(args: GetContractInfoArgs, headers?: object, signal?: AbortSignal): Promise - getContractInfoBatch( - args: GetContractInfoBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise + getContractInfoBatch(args: GetContractInfoBatchArgs, headers?: object, signal?: AbortSignal): Promise searchContractInfo(args: SearchContractInfoArgs, headers?: object, signal?: AbortSignal): Promise - searchContractInfoBatch( - args: SearchContractInfoBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise + searchContractInfoBatch(args: SearchContractInfoBatchArgs, headers?: object, signal?: AbortSignal): Promise searchMetadata(args: SearchMetadataArgs, headers?: object, signal?: AbortSignal): Promise - addContractsToTokenDirectory( - args: AddContractsToTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise - removeContractsFromTokenDirectory( - args: RemoveContractsFromTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise - modifyFeatureIndex(args: ModifyFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise - getFeatureIndex(args: GetFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise - listTokenDirectory(args: ListTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise - getNiftyswapTokenQuantity( - args: GetNiftyswapTokenQuantityArgs, - headers?: object, - signal?: AbortSignal - ): Promise - getNiftyswapUnitPrices( - args: GetNiftyswapUnitPricesArgs, - headers?: object, - signal?: AbortSignal - ): Promise - getNiftyswapUnitPricesWithQuantities( - args: GetNiftyswapUnitPricesWithQuantitiesArgs, - headers?: object, - signal?: AbortSignal - ): Promise - addContractToMintMonitor( - args: AddContractToMintMonitorArgs, - headers?: object, - signal?: AbortSignal - ): Promise - removeContractFromMintMonitor( - args: RemoveContractFromMintMonitorArgs, - headers?: object, - signal?: AbortSignal - ): Promise - mintMonitorJobStatus( - args: MintMonitorJobStatusArgs, - headers?: object, - signal?: AbortSignal - ): Promise - mintMonitorTriggerJob( - args: MintMonitorTriggerJobArgs, - headers?: object, - signal?: AbortSignal - ): Promise -} - -export interface PingArgs {} + searchTokens(args: SearchTokensArgs, headers?: object, signal?: AbortSignal): Promise + searchContracts(args: SearchContractsArgs, headers?: object, signal?: AbortSignal): Promise + getNiftyswapTokenQuantity(args: GetNiftyswapTokenQuantityArgs, headers?: object, signal?: AbortSignal): Promise + getNiftyswapUnitPrices(args: GetNiftyswapUnitPricesArgs, headers?: object, signal?: AbortSignal): Promise + getNiftyswapUnitPricesWithQuantities(args: GetNiftyswapUnitPricesWithQuantitiesArgs, headers?: object, signal?: AbortSignal): Promise + addContractToMintMonitor(args: AddContractToMintMonitorArgs, headers?: object, signal?: AbortSignal): Promise + removeContractFromMintMonitor(args: RemoveContractFromMintMonitorArgs, headers?: object, signal?: AbortSignal): Promise + mintMonitorJobStatus(args: MintMonitorJobStatusArgs, headers?: object, signal?: AbortSignal): Promise + mintMonitorTriggerJob(args: MintMonitorTriggerJobArgs, headers?: object, signal?: AbortSignal): Promise + syncContractTokens(args: SyncContractTokensArgs, headers?: object, signal?: AbortSignal): Promise + abortContractSync(args: AbortContractSyncArgs, headers?: object, signal?: AbortSignal): Promise + contractSyncJobStatus(args: ContractSyncJobStatusArgs, headers?: object, signal?: AbortSignal): Promise + directoryGetNetworks(args: DirectoryGetNetworksArgs, headers?: object, signal?: AbortSignal): Promise + directoryGetCollections(args: DirectoryGetCollectionsArgs, headers?: object, signal?: AbortSignal): Promise + directorySearchCollections(args: DirectorySearchCollectionsArgs, headers?: object, signal?: AbortSignal): Promise +} + +export interface PingArgs { +} export interface PingReturn { - status: boolean + status: boolean +} +export interface VersionArgs { } -export interface VersionArgs {} export interface VersionReturn { - version: Version + version: Version +} +export interface RuntimeStatusArgs { } -export interface RuntimeStatusArgs {} export interface RuntimeStatusReturn { - status: RuntimeStatus + status: RuntimeStatus } export interface GetTokenMetadataArgs { chainID: string @@ -358,7 +298,7 @@ export interface GetTokenMetadataArgs { } export interface GetTokenMetadataReturn { - tokenMetadata: Array + tokenMetadata: Array } export interface RefreshTokenMetadataArgs { chainID: string @@ -368,7 +308,7 @@ export interface RefreshTokenMetadataArgs { } export interface RefreshTokenMetadataReturn { - taskId: number + taskId: number } export interface EnqueueTokensForRefreshArgs { chainID: string @@ -378,14 +318,14 @@ export interface EnqueueTokensForRefreshArgs { } export interface EnqueueTokensForRefreshReturn { - taskId: number + taskId: number } export interface GetTokenRefreshStatusArgs { taskId: number } export interface GetTokenRefreshStatusReturn { - status?: TaskStatus + status?: TaskStatus } export interface GetTokenRefreshResultArgs { taskId: number @@ -393,23 +333,23 @@ export interface GetTokenRefreshResultArgs { export interface GetTokenRefreshResultReturn { status?: TaskStatus - tokens: { [key: string]: boolean } - failureReasons: { [key: string]: string } + tokens: {[key: string]: boolean} + failureReasons: {[key: string]: string} } export interface CancelRefreshJobArgs { taskId: number } export interface CancelRefreshJobReturn { - ok: boolean + ok: boolean } export interface GetTokenMetadataBatchArgs { chainID: string - contractTokenMap: { [key: string]: Array } + contractTokenMap: {[key: string]: Array} } export interface GetTokenMetadataBatchReturn { - contractTokenMetadata: { [key: string]: Array } + contractTokenMetadata: {[key: string]: Array} } export interface SearchTokenMetadataArgs { chainID: string @@ -420,7 +360,7 @@ export interface SearchTokenMetadataArgs { export interface SearchTokenMetadataReturn { page: Page - tokenMetadata: Array + tokenMetadata: Array } export interface SearchTokenIDsArgs { chainID: string @@ -431,7 +371,7 @@ export interface SearchTokenIDsArgs { export interface SearchTokenIDsReturn { page: Page - tokenIds: Array + tokenIds: Array } export interface TokenCollectionFiltersArgs { chainID: string @@ -439,7 +379,7 @@ export interface TokenCollectionFiltersArgs { } export interface TokenCollectionFiltersReturn { - filters: Array + filters: Array } export interface GetContractInfoArgs { chainID: string @@ -447,7 +387,7 @@ export interface GetContractInfoArgs { } export interface GetContractInfoReturn { - contractInfo: ContractInfo + contractInfo: ContractInfo } export interface GetContractInfoBatchArgs { chainID: string @@ -455,21 +395,21 @@ export interface GetContractInfoBatchArgs { } export interface GetContractInfoBatchReturn { - contractInfoMap: { [key: string]: ContractInfo } + contractInfoMap: {[key: string]: ContractInfo} } export interface SearchContractInfoArgs { contractAddress: string } export interface SearchContractInfoReturn { - contractInfoList: Array + contractInfoList: Array } export interface SearchContractInfoBatchArgs { contractAddresses: Array } export interface SearchContractInfoBatchReturn { - contractInfoByChain: { [key: string]: Array } + contractInfoByChain: {[key: string]: Array} } export interface SearchMetadataArgs { filter: string @@ -480,48 +420,28 @@ export interface SearchMetadataArgs { export interface SearchMetadataReturn { tokenMetadata: Array - contractInfo: Array -} -export interface AddContractsToTokenDirectoryArgs { - contracts: Array -} - -export interface AddContractsToTokenDirectoryReturn { - ok: boolean + contractInfo: Array } -export interface RemoveContractsFromTokenDirectoryArgs { - chainHandle: string - contracts: Array -} - -export interface RemoveContractsFromTokenDirectoryReturn { - ok: boolean -} -export interface ModifyFeatureIndexArgs { - chainHandle: string - contractAddress: string - featured: number -} - -export interface ModifyFeatureIndexReturn { - ok: boolean -} -export interface GetFeatureIndexArgs { - chainHandle: string - contractAddress: string +export interface SearchTokensArgs { + q: string + chainID?: string + page?: Page } -export interface GetFeatureIndexReturn { - featured: number +export interface SearchTokensReturn { + tokenMetadata: Array + nextPage: Page } -export interface ListTokenDirectoryArgs { +export interface SearchContractsArgs { + q: string chainID?: string + types?: Array page?: Page } -export interface ListTokenDirectoryReturn { - page: Page - contracts: Array +export interface SearchContractsReturn { + contractInfo: Array + nextPage: Page } export interface GetNiftyswapTokenQuantityArgs { chainID: string @@ -530,7 +450,7 @@ export interface GetNiftyswapTokenQuantityArgs { } export interface GetNiftyswapTokenQuantityReturn { - quantity: { [key: string]: string } + quantity: {[key: string]: string} } export interface GetNiftyswapUnitPricesArgs { chainID: string @@ -540,7 +460,7 @@ export interface GetNiftyswapUnitPricesArgs { } export interface GetNiftyswapUnitPricesReturn { - prices: { [key: string]: string } + prices: {[key: string]: string} } export interface GetNiftyswapUnitPricesWithQuantitiesArgs { chainID: string @@ -550,7 +470,7 @@ export interface GetNiftyswapUnitPricesWithQuantitiesArgs { } export interface GetNiftyswapUnitPricesWithQuantitiesReturn { - prices: { [key: string]: GetNiftyswapUnitPricesResponse } + prices: {[key: string]: GetNiftyswapUnitPricesResponse} } export interface AddContractToMintMonitorArgs { chainID: string @@ -558,7 +478,7 @@ export interface AddContractToMintMonitorArgs { } export interface AddContractToMintMonitorReturn { - ok: boolean + ok: boolean } export interface RemoveContractFromMintMonitorArgs { chainID: string @@ -566,7 +486,7 @@ export interface RemoveContractFromMintMonitorArgs { } export interface RemoveContractFromMintMonitorReturn { - ok: boolean + ok: boolean } export interface MintMonitorJobStatusArgs { chainID: string @@ -574,7 +494,7 @@ export interface MintMonitorJobStatusArgs { } export interface MintMonitorJobStatusReturn { - task: Task + task: Task } export interface MintMonitorTriggerJobArgs { chainID: string @@ -582,7 +502,61 @@ export interface MintMonitorTriggerJobArgs { } export interface MintMonitorTriggerJobReturn { - ok: boolean + ok: boolean +} +export interface SyncContractTokensArgs { + chainID: string + contractAddress: string +} + +export interface SyncContractTokensReturn { + taskID: number +} +export interface AbortContractSyncArgs { + taskID: number +} + +export interface AbortContractSyncReturn { + ok: boolean +} +export interface ContractSyncJobStatusArgs { + taskID: number +} + +export interface ContractSyncJobStatusReturn { + refreshTask: Task + syncTask: Task +} +export interface DirectoryGetNetworksArgs { + includeTestnets?: boolean + onlyFeatured?: boolean +} + +export interface DirectoryGetNetworksReturn { + networks: Array +} +export interface DirectoryGetCollectionsArgs { + chainId?: number + includeTestnets?: boolean + onlyFeatured?: boolean + page?: Page +} + +export interface DirectoryGetCollectionsReturn { + collections: Array + page: Page +} +export interface DirectorySearchCollectionsArgs { + query: string + chainId?: number + includeTestnets?: boolean + onlyFeatured?: boolean + page?: Page +} + +export interface DirectorySearchCollectionsReturn { + collections: Array + page: Page } export interface Collections { @@ -593,11 +567,7 @@ export interface Collections { deleteCollection(args: DeleteCollectionArgs, headers?: object, signal?: AbortSignal): Promise publishCollection(args: PublishCollectionArgs, headers?: object, signal?: AbortSignal): Promise unpublishCollection(args: UnpublishCollectionArgs, headers?: object, signal?: AbortSignal): Promise - addDeployedCollectionToTokenDirectory( - args: AddDeployedCollectionToTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise + addDeployedCollectionToTokenDirectory(args: AddDeployedCollectionToTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise createToken(args: CreateTokenArgs, headers?: object, signal?: AbortSignal): Promise getToken(args: GetTokenArgs, headers?: object, signal?: AbortSignal): Promise listTokens(args: ListTokensArgs, headers?: object, signal?: AbortSignal): Promise @@ -615,7 +585,7 @@ export interface CreateCollectionArgs { } export interface CreateCollectionReturn { - collection: Collection + collection: Collection } export interface GetCollectionArgs { projectId?: number @@ -623,7 +593,7 @@ export interface GetCollectionArgs { } export interface GetCollectionReturn { - collection: Collection + collection: Collection } export interface ListCollectionsArgs { projectId?: number @@ -632,7 +602,7 @@ export interface ListCollectionsArgs { export interface ListCollectionsReturn { page: Page - collections: Array + collections: Array } export interface UpdateCollectionArgs { projectId?: number @@ -640,7 +610,7 @@ export interface UpdateCollectionArgs { } export interface UpdateCollectionReturn { - collection: Collection + collection: Collection } export interface DeleteCollectionArgs { projectId?: number @@ -648,7 +618,7 @@ export interface DeleteCollectionArgs { } export interface DeleteCollectionReturn { - status: boolean + status: boolean } export interface PublishCollectionArgs { projectId?: number @@ -657,7 +627,7 @@ export interface PublishCollectionArgs { } export interface PublishCollectionReturn { - collection: Collection + collection: Collection } export interface UnpublishCollectionArgs { projectId?: number @@ -665,7 +635,7 @@ export interface UnpublishCollectionArgs { } export interface UnpublishCollectionReturn { - collection: Collection + collection: Collection } export interface AddDeployedCollectionToTokenDirectoryArgs { projectId?: number @@ -673,10 +643,11 @@ export interface AddDeployedCollectionToTokenDirectoryArgs { chainHandle: string contractAddress: string contractType: ContractType + featured: number } export interface AddDeployedCollectionToTokenDirectoryReturn { - ok: boolean + ok: boolean } export interface CreateTokenArgs { projectId?: number @@ -687,7 +658,7 @@ export interface CreateTokenArgs { export interface CreateTokenReturn { token: TokenMetadata - assets: Array + assets: Array } export interface GetTokenArgs { projectId?: number @@ -697,7 +668,7 @@ export interface GetTokenArgs { export interface GetTokenReturn { token: TokenMetadata - assets: Array + assets: Array } export interface ListTokensArgs { projectId?: number @@ -707,7 +678,7 @@ export interface ListTokensArgs { export interface ListTokensReturn { page: Page - tokens: Array + tokens: Array } export interface UpdateTokenArgs { projectId?: number @@ -718,7 +689,7 @@ export interface UpdateTokenArgs { } export interface UpdateTokenReturn { - token: TokenMetadata + token: TokenMetadata } export interface DeleteTokenArgs { projectId?: number @@ -727,7 +698,7 @@ export interface DeleteTokenArgs { } export interface DeleteTokenReturn { - status: boolean + status: boolean } export interface CreateAssetArgs { projectId?: number @@ -735,7 +706,7 @@ export interface CreateAssetArgs { } export interface CreateAssetReturn { - asset: Asset + asset: Asset } export interface GetAssetArgs { projectId?: number @@ -743,7 +714,7 @@ export interface GetAssetArgs { } export interface GetAssetReturn { - asset: Asset + asset: Asset } export interface UpdateAssetArgs { projectId?: number @@ -751,7 +722,7 @@ export interface UpdateAssetArgs { } export interface UpdateAssetReturn { - asset: Asset + asset: Asset } export interface DeleteAssetArgs { projectId?: number @@ -759,9 +730,62 @@ export interface DeleteAssetArgs { } export interface DeleteAssetReturn { - status: boolean + status: boolean +} + +export interface Admin { + addContractsToTokenDirectory(args: AddContractsToTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise + removeContractsFromTokenDirectory(args: RemoveContractsFromTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise + modifyFeatureIndex(args: ModifyFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise + getFeatureIndex(args: GetFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise + listTokenDirectory(args: ListTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise +} + +export interface AddContractsToTokenDirectoryArgs { + contracts: Array + featureIndexes: Array +} + +export interface AddContractsToTokenDirectoryReturn { + ok: boolean +} +export interface RemoveContractsFromTokenDirectoryArgs { + chainHandle: string + contracts: Array +} + +export interface RemoveContractsFromTokenDirectoryReturn { + ok: boolean +} +export interface ModifyFeatureIndexArgs { + chainHandle: string + contractAddress: string + featured: number +} + +export interface ModifyFeatureIndexReturn { + ok: boolean +} +export interface GetFeatureIndexArgs { + chainHandle: string + contractAddress: string +} + +export interface GetFeatureIndexReturn { + featured: number +} +export interface ListTokenDirectoryArgs { + chainID?: string + page?: Page +} + +export interface ListTokenDirectoryReturn { + page: Page + contracts: Array } + + // // Client // @@ -778,546 +802,482 @@ export class Metadata implements Metadata { private url(name: string): string { return this.hostname + this.path + name } - + ping = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('Ping'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + version = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - version: _data.version - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('Version'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + version: (_data.version), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + runtimeStatus = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('RuntimeStatus'), + createHTTPRequest({}, headers, signal) + ).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getTokenMetadata = (args: GetTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - tokenMetadata: >_data.tokenMetadata - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - refreshTokenMetadata = ( - args: RefreshTokenMetadataArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - taskId: _data.taskId - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - enqueueTokensForRefresh = ( - args: EnqueueTokensForRefreshArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('EnqueueTokensForRefresh'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - taskId: _data.taskId - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getTokenRefreshStatus = ( - args: GetTokenRefreshStatusArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetTokenRefreshStatus'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getTokenRefreshResult = ( - args: GetTokenRefreshResultArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetTokenRefreshResult'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status, - tokens: <{ [key: string]: boolean }>_data.tokens, - failureReasons: <{ [key: string]: string }>_data.failureReasons - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetTokenMetadata'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + tokenMetadata: >(_data.tokenMetadata), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + refreshTokenMetadata = (args: RefreshTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('RefreshTokenMetadata'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + taskId: (_data.taskId), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + enqueueTokensForRefresh = (args: EnqueueTokensForRefreshArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('EnqueueTokensForRefresh'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + taskId: (_data.taskId), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getTokenRefreshStatus = (args: GetTokenRefreshStatusArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetTokenRefreshStatus'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getTokenRefreshResult = (args: GetTokenRefreshResultArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetTokenRefreshResult'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + tokens: <{[key: string]: boolean}>(_data.tokens), + failureReasons: <{[key: string]: string}>(_data.failureReasons), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + cancelRefreshJob = (args: CancelRefreshJobArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('CancelRefreshJob'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getTokenMetadataBatch = ( - args: GetTokenMetadataBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - contractTokenMetadata: <{ [key: string]: Array }>_data.contractTokenMetadata - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - searchTokenMetadata = ( - args: SearchTokenMetadataArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - tokenMetadata: >_data.tokenMetadata - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('CancelRefreshJob'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getTokenMetadataBatch = (args: GetTokenMetadataBatchArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetTokenMetadataBatch'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractTokenMetadata: <{[key: string]: Array}>(_data.contractTokenMetadata), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + searchTokenMetadata = (args: SearchTokenMetadataArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SearchTokenMetadata'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + tokenMetadata: >(_data.tokenMetadata), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + searchTokenIDs = (args: SearchTokenIDsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - tokenIds: >_data.tokenIds - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - tokenCollectionFilters = ( - args: TokenCollectionFiltersArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('TokenCollectionFilters'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - filters: >_data.filters - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('SearchTokenIDs'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + tokenIds: >(_data.tokenIds), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + tokenCollectionFilters = (args: TokenCollectionFiltersArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('TokenCollectionFilters'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + filters: >(_data.filters), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getContractInfo = (args: GetContractInfoArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - contractInfo: _data.contractInfo - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getContractInfoBatch = ( - args: GetContractInfoBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - contractInfoMap: <{ [key: string]: ContractInfo }>_data.contractInfoMap - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - searchContractInfo = ( - args: SearchContractInfoArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - contractInfoList: >_data.contractInfoList - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - searchContractInfoBatch = ( - args: SearchContractInfoBatchArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - contractInfoByChain: <{ [key: string]: Array }>_data.contractInfoByChain - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetContractInfo'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractInfo: (_data.contractInfo), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getContractInfoBatch = (args: GetContractInfoBatchArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetContractInfoBatch'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractInfoMap: <{[key: string]: ContractInfo}>(_data.contractInfoMap), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + searchContractInfo = (args: SearchContractInfoArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SearchContractInfo'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractInfoList: >(_data.contractInfoList), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + searchContractInfoBatch = (args: SearchContractInfoBatchArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SearchContractInfoBatch'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractInfoByChain: <{[key: string]: Array}>(_data.contractInfoByChain), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + searchMetadata = (args: SearchMetadataArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('SearchMetadata'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - tokenMetadata: >_data.tokenMetadata, - contractInfo: >_data.contractInfo - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - addContractsToTokenDirectory = ( - args: AddContractsToTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AddContractsToTokenDirectory'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - removeContractsFromTokenDirectory = ( - args: RemoveContractsFromTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('RemoveContractsFromTokenDirectory'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - modifyFeatureIndex = ( - args: ModifyFeatureIndexArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('ModifyFeatureIndex'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getFeatureIndex = (args: GetFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetFeatureIndex'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - featured: _data.featured - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - listTokenDirectory = ( - args: ListTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('ListTokenDirectory'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - contracts: >_data.contracts - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getNiftyswapTokenQuantity = ( - args: GetNiftyswapTokenQuantityArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - quantity: <{ [key: string]: string }>_data.quantity - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getNiftyswapUnitPrices = ( - args: GetNiftyswapUnitPricesArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - prices: <{ [key: string]: string }>_data.prices - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - getNiftyswapUnitPricesWithQuantities = ( - args: GetNiftyswapUnitPricesWithQuantitiesArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('GetNiftyswapUnitPricesWithQuantities'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - prices: <{ [key: string]: GetNiftyswapUnitPricesResponse }>_data.prices - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - addContractToMintMonitor = ( - args: AddContractToMintMonitorArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AddContractToMintMonitor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - removeContractFromMintMonitor = ( - args: RemoveContractFromMintMonitorArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('RemoveContractFromMintMonitor'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - mintMonitorJobStatus = ( - args: MintMonitorJobStatusArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('MintMonitorJobStatus'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - task: _data.task - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - mintMonitorTriggerJob = ( - args: MintMonitorTriggerJobArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('MintMonitorTriggerJob'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('SearchMetadata'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + tokenMetadata: >(_data.tokenMetadata), + contractInfo: >(_data.contractInfo), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + searchTokens = (args: SearchTokensArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SearchTokens'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + tokenMetadata: >(_data.tokenMetadata), + nextPage: (_data.nextPage), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + searchContracts = (args: SearchContractsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SearchContracts'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + contractInfo: >(_data.contractInfo), + nextPage: (_data.nextPage), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getNiftyswapTokenQuantity = (args: GetNiftyswapTokenQuantityArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetNiftyswapTokenQuantity'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + quantity: <{[key: string]: string}>(_data.quantity), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getNiftyswapUnitPrices = (args: GetNiftyswapUnitPricesArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetNiftyswapUnitPrices'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + prices: <{[key: string]: string}>(_data.prices), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getNiftyswapUnitPricesWithQuantities = (args: GetNiftyswapUnitPricesWithQuantitiesArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetNiftyswapUnitPricesWithQuantities'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + prices: <{[key: string]: GetNiftyswapUnitPricesResponse}>(_data.prices), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + addContractToMintMonitor = (args: AddContractToMintMonitorArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AddContractToMintMonitor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + removeContractFromMintMonitor = (args: RemoveContractFromMintMonitorArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('RemoveContractFromMintMonitor'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + mintMonitorJobStatus = (args: MintMonitorJobStatusArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('MintMonitorJobStatus'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + task: (_data.task), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + mintMonitorTriggerJob = (args: MintMonitorTriggerJobArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('MintMonitorTriggerJob'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + syncContractTokens = (args: SyncContractTokensArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('SyncContractTokens'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + taskID: (_data.taskID), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + abortContractSync = (args: AbortContractSyncArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AbortContractSync'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + contractSyncJobStatus = (args: ContractSyncJobStatusArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('ContractSyncJobStatus'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + refreshTask: (_data.refreshTask), + syncTask: (_data.syncTask), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + directoryGetNetworks = (args: DirectoryGetNetworksArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('DirectoryGetNetworks'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + networks: >(_data.networks), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + directoryGetCollections = (args: DirectoryGetCollectionsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('DirectoryGetCollections'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collections: >(_data.collections), + page: (_data.page), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + directorySearchCollections = (args: DirectorySearchCollectionsArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('DirectorySearchCollections'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collections: >(_data.collections), + page: (_data.page), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } + } export class Collections implements Collections { protected hostname: string @@ -1332,276 +1292,338 @@ export class Collections implements Collections { private url(name: string): string { return this.hostname + this.path + name } - + createCollection = (args: CreateCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - collection: _data.collection - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('CreateCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collection: (_data.collection), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getCollection = (args: GetCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - collection: _data.collection - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collection: (_data.collection), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + listCollections = (args: ListCollectionsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - collections: >_data.collections - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('ListCollections'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + collections: >(_data.collections), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + updateCollection = (args: UpdateCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - collection: _data.collection - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('UpdateCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collection: (_data.collection), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + deleteCollection = (args: DeleteCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('DeleteCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + publishCollection = (args: PublishCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - collection: _data.collection - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - unpublishCollection = ( - args: UnpublishCollectionArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - collection: _data.collection - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) - } - - addDeployedCollectionToTokenDirectory = ( - args: AddDeployedCollectionToTokenDirectoryArgs, - headers?: object, - signal?: AbortSignal - ): Promise => { - return this.fetch(this.url('AddDeployedCollectionToTokenDirectory'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - ok: _data.ok - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('PublishCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collection: (_data.collection), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + unpublishCollection = (args: UnpublishCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('UnpublishCollection'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + collection: (_data.collection), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + addDeployedCollectionToTokenDirectory = (args: AddDeployedCollectionToTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AddDeployedCollectionToTokenDirectory'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + createToken = (args: CreateTokenArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - token: _data.token, - assets: >_data.assets - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('CreateToken'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + token: (_data.token), + assets: >(_data.assets), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getToken = (args: GetTokenArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - token: _data.token, - assets: >_data.assets - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetToken'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + token: (_data.token), + assets: >(_data.assets), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + listTokens = (args: ListTokensArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - page: _data.page, - tokens: >_data.tokens - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('ListTokens'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + tokens: >(_data.tokens), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + updateToken = (args: UpdateTokenArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - token: _data.token - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('UpdateToken'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + token: (_data.token), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + deleteToken = (args: DeleteTokenArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('DeleteToken'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + createAsset = (args: CreateAssetArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - asset: _data.asset - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('CreateAsset'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + asset: (_data.asset), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + getAsset = (args: GetAssetArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - asset: _data.asset - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('GetAsset'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + asset: (_data.asset), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + updateAsset = (args: UpdateAssetArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - asset: _data.asset - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('UpdateAsset'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + asset: (_data.asset), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } - + deleteAsset = (args: DeleteAssetArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers, signal)).then( - res => { - return buildResponse(res).then(_data => { - return { - status: _data.status - } - }) - }, - error => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - } - ) + return this.fetch( + this.url('DeleteAsset'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + status: (_data.status), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) } + } +export class Admin implements Admin { + protected hostname: string + protected fetch: Fetch + protected path = '/rpc/Admin/' + + constructor(hostname: string, fetch: Fetch) { + this.hostname = hostname + this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init) + } -const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { + private url(name: string): string { + return this.hostname + this.path + name + } + + addContractsToTokenDirectory = (args: AddContractsToTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('AddContractsToTokenDirectory'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + removeContractsFromTokenDirectory = (args: RemoveContractsFromTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('RemoveContractsFromTokenDirectory'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + modifyFeatureIndex = (args: ModifyFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('ModifyFeatureIndex'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + ok: (_data.ok), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + getFeatureIndex = (args: GetFeatureIndexArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('GetFeatureIndex'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + featured: (_data.featured), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + + listTokenDirectory = (args: ListTokenDirectoryArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch( + this.url('ListTokenDirectory'), + createHTTPRequest(args, headers, signal)).then((res) => { + return buildResponse(res).then(_data => { + return { + page: (_data.page), + contracts: >(_data.contracts), + } + }) + }, (error) => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + }) + } + +} + + const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { return { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, @@ -1615,18 +1637,18 @@ const buildResponse = (res: Response): Promise => { let data try { data = JSON.parse(text) - } catch (error) { + } catch(error) { let message = '' - if (error instanceof Error) { + if (error instanceof Error) { message = error.message } throw WebrpcBadResponseError.new({ status: res.status, - cause: `JSON.parse(): ${message}: response text: ${text}` - }) + cause: `JSON.parse(): ${message}: response text: ${text}`}, + ) } if (!res.ok) { - const code: number = typeof data.code === 'number' ? data.code : 0 + const code: number = (typeof data.code === 'number') ? data.code : 0 throw (webrpcErrorByCode[code] || WebrpcError).new(data) } return data @@ -1808,6 +1830,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { } } + // Schema errors export class UnauthorizedError extends WebrpcError { @@ -1888,6 +1911,19 @@ export class FailError extends WebrpcError { } } +export class GeoblockedError extends WebrpcError { + constructor( + name: string = 'Geoblocked', + code: number = 1006, + message: string = 'Geoblocked region', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, GeoblockedError.prototype) + } +} + export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', @@ -1927,6 +1963,45 @@ export class RequiredArgumentError extends WebrpcError { } } +export class QueryFailedError extends WebrpcError { + constructor( + name: string = 'QueryFailed', + code: number = 2003, + message: string = 'Query failed', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, QueryFailedError.prototype) + } +} + +export class ValidationFailedError extends WebrpcError { + constructor( + name: string = 'ValidationFailed', + code: number = 2004, + message: string = 'Validation failed', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, ValidationFailedError.prototype) + } +} + +export class RateLimitedError extends WebrpcError { + constructor( + name: string = 'RateLimited', + code: number = 2005, + message: string = 'Rate limited', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, RateLimitedError.prototype) + } +} + export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', @@ -1966,6 +2041,20 @@ export class ChainNotFoundError extends WebrpcError { } } +export class TokenDirectoryDisabledError extends WebrpcError { + constructor( + name: string = 'TokenDirectoryDisabled', + code: number = 4001, + message: string = 'Token Directory is disabled', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, TokenDirectoryDisabledError.prototype) + } +} + + export enum errors { WebrpcEndpoint = 'WebrpcEndpoint', WebrpcRequestFailed = 'WebrpcRequestFailed', @@ -1984,12 +2073,17 @@ export enum errors { MethodNotFound = 'MethodNotFound', RequestConflict = 'RequestConflict', Fail = 'Fail', + Geoblocked = 'Geoblocked', Timeout = 'Timeout', InvalidArgument = 'InvalidArgument', RequiredArgument = 'RequiredArgument', + QueryFailed = 'QueryFailed', + ValidationFailed = 'ValidationFailed', + RateLimited = 'RateLimited', NotFound = 'NotFound', ProjectNotFound = 'ProjectNotFound', - ChainNotFound = 'ChainNotFound' + ChainNotFound = 'ChainNotFound', + TokenDirectoryDisabled = 'TokenDirectoryDisabled', } const webrpcErrorByCode: { [code: number]: any } = { @@ -2010,12 +2104,18 @@ const webrpcErrorByCode: { [code: number]: any } = { [1003]: MethodNotFoundError, [1004]: RequestConflictError, [1005]: FailError, + [1006]: GeoblockedError, [2000]: TimeoutError, [2001]: InvalidArgumentError, [2002]: RequiredArgumentError, + [2003]: QueryFailedError, + [2004]: ValidationFailedError, + [2005]: RateLimitedError, [3000]: NotFoundError, [3002]: ProjectNotFoundError, - [3003]: ChainNotFoundError + [3003]: ChainNotFoundError, + [4001]: TokenDirectoryDisabledError, } export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise +