diff --git a/packages/marketplace/src/marketplace.gen.ts b/packages/marketplace/src/marketplace.gen.ts index 9a980895a..70690ccbc 100644 --- a/packages/marketplace/src/marketplace.gen.ts +++ b/packages/marketplace/src/marketplace.gen.ts @@ -1,76 +1,76 @@ /* eslint-disable */ -// marketplace-api 5ba59124a7011c1864106b759b26b60a6f55a062 +// marketplace-api 562ae69c8e00898eea9e9e9d38f207f12bb4fafe // -- // Code generated by webrpc-gen@v0.25.4 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=marketplace.ridl -target=typescript -client -out=./clients/marketplace.gen.ts -export const WebrpcHeader = "Webrpc" +export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = "webrpc@v0.25.4;gen-typescript@v0.17.0;marketplace-api@v0.0.0-5ba59124a7011c1864106b759b26b60a6f55a062" +export const WebrpcHeaderValue = + 'webrpc@v0.25.4;gen-typescript@v0.17.0;marketplace-api@v0.0.0-562ae69c8e00898eea9e9e9d38f207f12bb4fafe' // WebRPC description and code-gen version -export const WebRPCVersion = "v1" +export const WebRPCVersion = 'v1' // Schema version of your RIDL schema -export const WebRPCSchemaVersion = "" +export const WebRPCSchemaVersion = '' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "5ba59124a7011c1864106b759b26b60a6f55a062" +export const WebRPCSchemaHash = '562ae69c8e00898eea9e9e9d38f207f12bb4fafe' type WebrpcGenVersions = { - webrpcGenVersion: string; - codeGenName: string; - codeGenVersion: string; - schemaName: string; - schemaVersion: string; -}; + webrpcGenVersion: string + codeGenName: string + codeGenVersion: string + schemaName: string + schemaVersion: string +} export function VersionFromHeader(headers: Headers): WebrpcGenVersions { - const headerValue = headers.get(WebrpcHeader); + const headerValue = headers.get(WebrpcHeader) if (!headerValue) { return { - webrpcGenVersion: "", - codeGenName: "", - codeGenVersion: "", - schemaName: "", - schemaVersion: "", - }; + webrpcGenVersion: '', + codeGenName: '', + codeGenVersion: '', + schemaName: '', + schemaVersion: '' + } } - return parseWebrpcGenVersions(headerValue); + return parseWebrpcGenVersions(headerValue) } function parseWebrpcGenVersions(header: string): WebrpcGenVersions { - const versions = header.split(";"); + const versions = header.split(';') if (versions.length < 3) { return { - webrpcGenVersion: "", - codeGenName: "", - codeGenVersion: "", - schemaName: "", - schemaVersion: "", - }; + webrpcGenVersion: '', + codeGenName: '', + codeGenVersion: '', + schemaName: '', + schemaVersion: '' + } } - const [_, webrpcGenVersion] = versions[0]!.split("@"); - const [codeGenName, codeGenVersion] = versions[1]!.split("@"); - const [schemaName, schemaVersion] = versions[2]!.split("@"); + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion: webrpcGenVersion ?? "", - codeGenName: codeGenName ?? "", - codeGenVersion: codeGenVersion ?? "", - schemaName: schemaName ?? "", - schemaVersion: schemaVersion ?? "", - }; + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' + } } // // Types // - export interface TokenMetadata { tokenId: string name: string @@ -78,8 +78,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 @@ -237,19 +237,19 @@ export enum TransactionCrypto { export enum TransactionNFTCheckoutProvider { unknown = 'unknown', - sardine = 'sardine', - transak = 'transak' + transak = 'transak', + sardine = 'sardine' } export enum TransactionOnRampProvider { unknown = 'unknown', - sardine = 'sardine', - transak = 'transak' + transak = 'transak', + sardine = 'sardine' } export enum TransactionSwapProvider { unknown = 'unknown', - zerox = 'zerox' + lifi = 'lifi' } export enum ExecuteType { @@ -376,7 +376,7 @@ export interface Collection { } export interface CollectionConfig { - lastSynced: {[key: string]: CollectionLastSynced} + lastSynced: { [key: string]: CollectionLastSynced } collectiblesSynced: string activitiesSynced: string activitiesSyncedContinuity: string @@ -532,138 +532,224 @@ export interface Admin { createCurrency(args: CreateCurrencyArgs, headers?: object, signal?: AbortSignal): Promise createCurrencies(args: CreateCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise updateCurrency(args: UpdateCurrencyArgs, headers?: object, signal?: AbortSignal): Promise - listCurrencies(headers?: object, signal?: AbortSignal): Promise + listCurrencies(args: ListCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise deleteCurrency(args: DeleteCurrencyArgs, headers?: object, signal?: AbortSignal): Promise } export interface CreateCollectionArgs { + chainId: string projectId: number contractAddress: string } export interface CreateCollectionReturn { - collection: Collection + collection: Collection } export interface GetCollectionArgs { + chainId: string projectId: number contractAddress: string } export interface GetCollectionReturn { - collection: Collection + collection: Collection } export interface UpdateCollectionArgs { + chainId: string collection: Collection } export interface UpdateCollectionReturn { - collection: Collection + collection: Collection } export interface ListCollectionsArgs { + chainId: string projectId: number page?: Page } export interface ListCollectionsReturn { collections: Array - page?: Page + page?: Page } export interface DeleteCollectionArgs { + chainId: string projectId: number contractAddress: string } export interface DeleteCollectionReturn { - collection: Collection + collection: Collection } export interface SyncCollectionArgs { + chainId: string projectId: number contractAddress: string } export interface SyncCollectionReturn { - collection: Collection + collection: Collection } export interface CreateCurrencyArgs { + chainId: string currency: Currency } export interface CreateCurrencyReturn { - currency: Currency + currency: Currency } export interface CreateCurrenciesArgs { + chainId: string currencies: Array } export interface CreateCurrenciesReturn { - currency: {[key: string]: Currency} + currency: { [key: string]: Currency } } export interface UpdateCurrencyArgs { + chainId: string currency: Currency } export interface UpdateCurrencyReturn { - currency: Currency + currency: Currency } export interface ListCurrenciesArgs { + chainId: string } export interface ListCurrenciesReturn { - currencies: Array + currencies: Array } export interface DeleteCurrencyArgs { - chainId: number + chainId: string contractAddress: string } export interface DeleteCurrencyReturn { - currency: Currency + currency: Currency } export interface Marketplace { - listCurrencies(headers?: object, signal?: AbortSignal): Promise + listCurrencies(args: ListCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise getCollectionDetail(args: GetCollectionDetailArgs, headers?: object, signal?: AbortSignal): Promise getCollectible(args: GetCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getLowestPriceOfferForCollectible(args: GetLowestPriceOfferForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getHighestPriceOfferForCollectible(args: GetHighestPriceOfferForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getLowestPriceListingForCollectible(args: GetLowestPriceListingForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getHighestPriceListingForCollectible(args: GetHighestPriceListingForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - listListingsForCollectible(args: ListListingsForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - listOffersForCollectible(args: ListOffersForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getCountOfListingsForCollectible(args: GetCountOfListingsForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise - getCountOfOffersForCollectible(args: GetCountOfOffersForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise + getLowestPriceOfferForCollectible( + args: GetLowestPriceOfferForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getHighestPriceOfferForCollectible( + args: GetHighestPriceOfferForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getLowestPriceListingForCollectible( + args: GetLowestPriceListingForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getHighestPriceListingForCollectible( + args: GetHighestPriceListingForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listListingsForCollectible( + args: ListListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listOffersForCollectible( + args: ListOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getCountOfListingsForCollectible( + args: GetCountOfListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getCountOfOffersForCollectible( + args: GetCountOfOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use GetLowestPriceOfferForCollectible instead. */ - getCollectibleLowestOffer(args: GetCollectibleLowestOfferArgs, headers?: object, signal?: AbortSignal): Promise + getCollectibleLowestOffer( + args: GetCollectibleLowestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use GetHighestPriceOfferForCollectible instead. */ - getCollectibleHighestOffer(args: GetCollectibleHighestOfferArgs, headers?: object, signal?: AbortSignal): Promise + getCollectibleHighestOffer( + args: GetCollectibleHighestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use GetLowestPriceListingForCollectible instead. */ - getCollectibleLowestListing(args: GetCollectibleLowestListingArgs, headers?: object, signal?: AbortSignal): Promise + getCollectibleLowestListing( + args: GetCollectibleLowestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use GetHighestPriceListingForCollectible instead. */ - getCollectibleHighestListing(args: GetCollectibleHighestListingArgs, headers?: object, signal?: AbortSignal): Promise + getCollectibleHighestListing( + args: GetCollectibleHighestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use ListListingsForCollectible instead. */ - listCollectibleListings(args: ListCollectibleListingsArgs, headers?: object, signal?: AbortSignal): Promise + listCollectibleListings( + args: ListCollectibleListingsArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * @deprecated Please use ListOffersForCollectible instead. */ - listCollectibleOffers(args: ListCollectibleOffersArgs, headers?: object, signal?: AbortSignal): Promise + listCollectibleOffers( + args: ListCollectibleOffersArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * checkout process */ - generateBuyTransaction(args: GenerateBuyTransactionArgs, headers?: object, signal?: AbortSignal): Promise - generateSellTransaction(args: GenerateSellTransactionArgs, headers?: object, signal?: AbortSignal): Promise - generateListingTransaction(args: GenerateListingTransactionArgs, headers?: object, signal?: AbortSignal): Promise - generateOfferTransaction(args: GenerateOfferTransactionArgs, headers?: object, signal?: AbortSignal): Promise - generateCancelTransaction(args: GenerateCancelTransactionArgs, headers?: object, signal?: AbortSignal): Promise + generateBuyTransaction( + args: GenerateBuyTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise + generateSellTransaction( + args: GenerateSellTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise + generateListingTransaction( + args: GenerateListingTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise + generateOfferTransaction( + args: GenerateOfferTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise + generateCancelTransaction( + args: GenerateCancelTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise /** * only used in a case of external transactions ( when we create off-chain transactions ) for instance opensea market */ @@ -672,79 +758,123 @@ export interface Marketplace { * list of collectibles with best order for each collectible, by default this only returns collectibles with an order */ listCollectibles(args: ListCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise - getCountOfAllCollectibles(args: GetCountOfAllCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise - getCountOfFilteredCollectibles(args: GetCountOfFilteredCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise + getCountOfAllCollectibles( + args: GetCountOfAllCollectiblesArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getCountOfFilteredCollectibles( + args: GetCountOfFilteredCollectiblesArgs, + headers?: object, + signal?: AbortSignal + ): Promise getFloorOrder(args: GetFloorOrderArgs, headers?: object, signal?: AbortSignal): Promise - listCollectionActivities(args: ListCollectionActivitiesArgs, headers?: object, signal?: AbortSignal): Promise - listCollectibleActivities(args: ListCollectibleActivitiesArgs, headers?: object, signal?: AbortSignal): Promise - listCollectiblesWithLowestListing(args: ListCollectiblesWithLowestListingArgs, headers?: object, signal?: AbortSignal): Promise - listCollectiblesWithHighestOffer(args: ListCollectiblesWithHighestOfferArgs, headers?: object, signal?: AbortSignal): Promise + listCollectionActivities( + args: ListCollectionActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listCollectibleActivities( + args: ListCollectibleActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listCollectiblesWithLowestListing( + args: ListCollectiblesWithLowestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listCollectiblesWithHighestOffer( + args: ListCollectiblesWithHighestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise syncOrder(args: SyncOrderArgs, headers?: object, signal?: AbortSignal): Promise syncOrders(args: SyncOrdersArgs, headers?: object, signal?: AbortSignal): Promise getOrders(args: GetOrdersArgs, headers?: object, signal?: AbortSignal): Promise - checkoutOptionsMarketplace(args: CheckoutOptionsMarketplaceArgs, headers?: object, signal?: AbortSignal): Promise - checkoutOptionsSalesContract(args: CheckoutOptionsSalesContractArgs, headers?: object, signal?: AbortSignal): Promise - supportedMarketplaces(headers?: object, signal?: AbortSignal): Promise + checkoutOptionsMarketplace( + args: CheckoutOptionsMarketplaceArgs, + headers?: object, + signal?: AbortSignal + ): Promise + checkoutOptionsSalesContract( + args: CheckoutOptionsSalesContractArgs, + headers?: object, + signal?: AbortSignal + ): Promise + supportedMarketplaces( + args: SupportedMarketplacesArgs, + headers?: object, + signal?: AbortSignal + ): Promise } export interface ListCurrenciesArgs { + chainId: string } export interface ListCurrenciesReturn { - currencies: Array + currencies: Array } export interface GetCollectionDetailArgs { + chainId: string contractAddress: string } export interface GetCollectionDetailReturn { - collection: Collection + collection: Collection } export interface GetCollectibleArgs { + chainId: string contractAddress: string tokenId: string } export interface GetCollectibleReturn { - metadata: TokenMetadata + metadata: TokenMetadata } export interface GetLowestPriceOfferForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetLowestPriceOfferForCollectibleReturn { - order: Order + order: Order } export interface GetHighestPriceOfferForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetHighestPriceOfferForCollectibleReturn { - order: Order + order: Order } export interface GetLowestPriceListingForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetLowestPriceListingForCollectibleReturn { - order: Order + order: Order } export interface GetHighestPriceListingForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetHighestPriceListingForCollectibleReturn { - order: Order + order: Order } export interface ListListingsForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter @@ -753,9 +883,10 @@ export interface ListListingsForCollectibleArgs { export interface ListListingsForCollectibleReturn { listings: Array - page?: Page + page?: Page } export interface ListOffersForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter @@ -764,63 +895,70 @@ export interface ListOffersForCollectibleArgs { export interface ListOffersForCollectibleReturn { offers: Array - page?: Page + page?: Page } export interface GetCountOfListingsForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCountOfListingsForCollectibleReturn { - count: number + count: number } export interface GetCountOfOffersForCollectibleArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCountOfOffersForCollectibleReturn { - count: number + count: number } export interface GetCollectibleLowestOfferArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCollectibleLowestOfferReturn { - order?: Order + order?: Order } export interface GetCollectibleHighestOfferArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCollectibleHighestOfferReturn { - order?: Order + order?: Order } export interface GetCollectibleLowestListingArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCollectibleLowestListingReturn { - order?: Order + order?: Order } export interface GetCollectibleHighestListingArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter } export interface GetCollectibleHighestListingReturn { - order?: Order + order?: Order } export interface ListCollectibleListingsArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter @@ -829,9 +967,10 @@ export interface ListCollectibleListingsArgs { export interface ListCollectibleListingsReturn { listings: Array - page?: Page + page?: Page } export interface ListCollectibleOffersArgs { + chainId: string contractAddress: string tokenId: string filter?: OrderFilter @@ -840,9 +979,10 @@ export interface ListCollectibleOffersArgs { export interface ListCollectibleOffersReturn { offers: Array - page?: Page + page?: Page } export interface GenerateBuyTransactionArgs { + chainId: string collectionAddress: string buyer: string marketplace: MarketplaceKind @@ -852,9 +992,10 @@ export interface GenerateBuyTransactionArgs { } export interface GenerateBuyTransactionReturn { - steps: Array + steps: Array } export interface GenerateSellTransactionArgs { + chainId: string collectionAddress: string seller: string marketplace: MarketplaceKind @@ -864,9 +1005,10 @@ export interface GenerateSellTransactionArgs { } export interface GenerateSellTransactionReturn { - steps: Array + steps: Array } export interface GenerateListingTransactionArgs { + chainId: string collectionAddress: string owner: string contractType: ContractType @@ -876,9 +1018,10 @@ export interface GenerateListingTransactionArgs { } export interface GenerateListingTransactionReturn { - steps: Array + steps: Array } export interface GenerateOfferTransactionArgs { + chainId: string collectionAddress: string maker: string contractType: ContractType @@ -888,9 +1031,10 @@ export interface GenerateOfferTransactionArgs { } export interface GenerateOfferTransactionReturn { - steps: Array + steps: Array } export interface GenerateCancelTransactionArgs { + chainId: string collectionAddress: string maker: string marketplace: MarketplaceKind @@ -898,9 +1042,10 @@ export interface GenerateCancelTransactionArgs { } export interface GenerateCancelTransactionReturn { - steps: Array + steps: Array } export interface ExecuteArgs { + chainId: string signature: string method: string endpoint: string @@ -909,9 +1054,10 @@ export interface ExecuteArgs { } export interface ExecuteReturn { - orderId: string + orderId: string } export interface ListCollectiblesArgs { + chainId: string side: OrderSide contractAddress: string filter?: CollectiblesFilter @@ -920,42 +1066,47 @@ export interface ListCollectiblesArgs { export interface ListCollectiblesReturn { collectibles: Array - page?: Page + page?: Page } export interface GetCountOfAllCollectiblesArgs { + chainId: string contractAddress: string } export interface GetCountOfAllCollectiblesReturn { - count: number + count: number } export interface GetCountOfFilteredCollectiblesArgs { + chainId: string side: OrderSide contractAddress: string filter?: CollectiblesFilter } export interface GetCountOfFilteredCollectiblesReturn { - count: number + count: number } export interface GetFloorOrderArgs { + chainId: string contractAddress: string filter?: CollectiblesFilter } export interface GetFloorOrderReturn { - collectible: CollectibleOrder + collectible: CollectibleOrder } export interface ListCollectionActivitiesArgs { + chainId: string contractAddress: string page?: Page } export interface ListCollectionActivitiesReturn { activities: Array - page?: Page + page?: Page } export interface ListCollectibleActivitiesArgs { + chainId: string contractAddress: string tokenId: string page?: Page @@ -963,9 +1114,10 @@ export interface ListCollectibleActivitiesArgs { export interface ListCollectibleActivitiesReturn { activities: Array - page?: Page + page?: Page } export interface ListCollectiblesWithLowestListingArgs { + chainId: string contractAddress: string filter?: CollectiblesFilter page?: Page @@ -973,9 +1125,10 @@ export interface ListCollectiblesWithLowestListingArgs { export interface ListCollectiblesWithLowestListingReturn { collectibles: Array - page?: Page + page?: Page } export interface ListCollectiblesWithHighestOfferArgs { + chainId: string contractAddress: string filter?: CollectiblesFilter page?: Page @@ -983,39 +1136,42 @@ export interface ListCollectiblesWithHighestOfferArgs { export interface ListCollectiblesWithHighestOfferReturn { collectibles: Array - page?: Page + page?: Page } export interface SyncOrderArgs { + chainId: string order: Order } -export interface SyncOrderReturn { -} +export interface SyncOrderReturn {} export interface SyncOrdersArgs { + chainId: string orders: Array } -export interface SyncOrdersReturn { -} +export interface SyncOrdersReturn {} export interface GetOrdersArgs { + chainId: string input: Array page?: Page } export interface GetOrdersReturn { orders: Array - page?: Page + page?: Page } export interface CheckoutOptionsMarketplaceArgs { + chainId: string wallet: string orders: Array additionalFee: number } export interface CheckoutOptionsMarketplaceReturn { - options: CheckoutOptions + options: CheckoutOptions } export interface CheckoutOptionsSalesContractArgs { + chainId: string wallet: string contractAddress: string collectionAddress: string @@ -1023,17 +1179,16 @@ export interface CheckoutOptionsSalesContractArgs { } export interface CheckoutOptionsSalesContractReturn { - options: CheckoutOptions + options: CheckoutOptions } export interface SupportedMarketplacesArgs { + chainId: string } export interface SupportedMarketplacesReturn { - marketplaces: Array + marketplaces: Array } - - // // Client // @@ -1050,163 +1205,172 @@ export class Admin implements Admin { 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 || ''}` }) + } + ) } - + 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 || ''}` }) + } + ) } - + 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 { - collections: >(_data.collections), - page: (_data.page), - } - }) - }, (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 { + collections: >_data.collections, + page: _data.page + } + }) + }, + 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 { - collection: (_data.collection), - } - }) - }, (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 { + collection: _data.collection + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + syncCollection = (args: SyncCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('SyncCollection'), - 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('SyncCollection'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collection: _data.collection + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + createCurrency = (args: CreateCurrencyArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('CreateCurrency'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - currency: (_data.currency), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('CreateCurrency'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currency: _data.currency + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + createCurrencies = (args: CreateCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('CreateCurrencies'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - currency: <{[key: string]: Currency}>(_data.currency), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('CreateCurrencies'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currency: <{ [key: string]: Currency }>_data.currency + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + updateCurrency = (args: UpdateCurrencyArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('UpdateCurrency'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - currency: (_data.currency), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCurrencies = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCurrencies'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - currencies: >(_data.currencies), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('UpdateCurrency'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currency: _data.currency + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCurrencies = (args: ListCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('ListCurrencies'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currencies: >_data.currencies + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + deleteCurrency = (args: DeleteCurrencyArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('DeleteCurrency'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - currency: (_data.currency), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('DeleteCurrency'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currency: _data.currency + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - } export class Marketplace implements Marketplace { protected hostname: string @@ -1221,537 +1385,687 @@ export class Marketplace implements Marketplace { private url(name: string): string { return this.hostname + this.path + name } - - listCurrencies = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCurrencies'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - currencies: >(_data.currencies), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCollectionDetail = (args: GetCollectionDetailArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectionDetail'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - collection: (_data.collection), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + + listCurrencies = (args: ListCurrenciesArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('ListCurrencies'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currencies: >_data.currencies + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCollectionDetail = ( + args: GetCollectionDetailArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectionDetail'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collection: _data.collection + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + getCollectible = (args: GetCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - metadata: (_data.metadata), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getLowestPriceOfferForCollectible = (args: GetLowestPriceOfferForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetLowestPriceOfferForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getHighestPriceOfferForCollectible = (args: GetHighestPriceOfferForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetHighestPriceOfferForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getLowestPriceListingForCollectible = (args: GetLowestPriceListingForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetLowestPriceListingForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getHighestPriceListingForCollectible = (args: GetHighestPriceListingForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetHighestPriceListingForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listListingsForCollectible = (args: ListListingsForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListListingsForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - listings: >(_data.listings), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listOffersForCollectible = (args: ListOffersForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListOffersForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - offers: >(_data.offers), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCountOfListingsForCollectible = (args: GetCountOfListingsForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCountOfListingsForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - count: (_data.count), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCountOfOffersForCollectible = (args: GetCountOfOffersForCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCountOfOffersForCollectible'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - count: (_data.count), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCollectibleLowestOffer = (args: GetCollectibleLowestOfferArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectibleLowestOffer'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCollectibleHighestOffer = (args: GetCollectibleHighestOfferArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectibleHighestOffer'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCollectibleLowestListing = (args: GetCollectibleLowestListingArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectibleLowestListing'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCollectibleHighestListing = (args: GetCollectibleHighestListingArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCollectibleHighestListing'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - order: (_data.order), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectibleListings = (args: ListCollectibleListingsArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectibleListings'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - listings: >(_data.listings), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectibleOffers = (args: ListCollectibleOffersArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectibleOffers'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - offers: >(_data.offers), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - generateBuyTransaction = (args: GenerateBuyTransactionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GenerateBuyTransaction'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - steps: >(_data.steps), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - generateSellTransaction = (args: GenerateSellTransactionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GenerateSellTransaction'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - steps: >(_data.steps), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - generateListingTransaction = (args: GenerateListingTransactionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GenerateListingTransaction'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - steps: >(_data.steps), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - generateOfferTransaction = (args: GenerateOfferTransactionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GenerateOfferTransaction'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - steps: >(_data.steps), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - generateCancelTransaction = (args: GenerateCancelTransactionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GenerateCancelTransaction'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - steps: >(_data.steps), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('GetCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + metadata: _data.metadata + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getLowestPriceOfferForCollectible = ( + args: GetLowestPriceOfferForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetLowestPriceOfferForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getHighestPriceOfferForCollectible = ( + args: GetHighestPriceOfferForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetHighestPriceOfferForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getLowestPriceListingForCollectible = ( + args: GetLowestPriceListingForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetLowestPriceListingForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getHighestPriceListingForCollectible = ( + args: GetHighestPriceListingForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetHighestPriceListingForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listListingsForCollectible = ( + args: ListListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListListingsForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + listings: >_data.listings, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listOffersForCollectible = ( + args: ListOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListOffersForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + offers: >_data.offers, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCountOfListingsForCollectible = ( + args: GetCountOfListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfListingsForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCountOfOffersForCollectible = ( + args: GetCountOfOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfOffersForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCollectibleLowestOffer = ( + args: GetCollectibleLowestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectibleLowestOffer'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCollectibleHighestOffer = ( + args: GetCollectibleHighestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectibleHighestOffer'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCollectibleLowestListing = ( + args: GetCollectibleLowestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectibleLowestListing'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCollectibleHighestListing = ( + args: GetCollectibleHighestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectibleHighestListing'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + order: _data.order + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectibleListings = ( + args: ListCollectibleListingsArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectibleListings'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + listings: >_data.listings, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectibleOffers = ( + args: ListCollectibleOffersArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectibleOffers'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + offers: >_data.offers, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + generateBuyTransaction = ( + args: GenerateBuyTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateBuyTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + generateSellTransaction = ( + args: GenerateSellTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateSellTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + generateListingTransaction = ( + args: GenerateListingTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateListingTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + generateOfferTransaction = ( + args: GenerateOfferTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateOfferTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + generateCancelTransaction = ( + args: GenerateCancelTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateCancelTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + execute = (args: ExecuteArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('Execute'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - orderId: (_data.orderId), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('Execute'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + orderId: _data.orderId + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + listCollectibles = (args: ListCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectibles'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - collectibles: >(_data.collectibles), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCountOfAllCollectibles = (args: GetCountOfAllCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCountOfAllCollectibles'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - count: (_data.count), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - getCountOfFilteredCollectibles = (args: GetCountOfFilteredCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetCountOfFilteredCollectibles'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - count: (_data.count), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('ListCollectibles'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collectibles: >_data.collectibles, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCountOfAllCollectibles = ( + args: GetCountOfAllCollectiblesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfAllCollectibles'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCountOfFilteredCollectibles = ( + args: GetCountOfFilteredCollectiblesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfFilteredCollectibles'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + getFloorOrder = (args: GetFloorOrderArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetFloorOrder'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - collectible: (_data.collectible), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectionActivities = (args: ListCollectionActivitiesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectionActivities'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - activities: >(_data.activities), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectibleActivities = (args: ListCollectibleActivitiesArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectibleActivities'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - activities: >(_data.activities), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectiblesWithLowestListing = (args: ListCollectiblesWithLowestListingArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectiblesWithLowestListing'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - collectibles: >(_data.collectibles), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - listCollectiblesWithHighestOffer = (args: ListCollectiblesWithHighestOfferArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ListCollectiblesWithHighestOffer'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - collectibles: >(_data.collectibles), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('GetFloorOrder'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collectible: _data.collectible + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectionActivities = ( + args: ListCollectionActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectionActivities'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + activities: >_data.activities, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectibleActivities = ( + args: ListCollectibleActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectibleActivities'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + activities: >_data.activities, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectiblesWithLowestListing = ( + args: ListCollectiblesWithLowestListingArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectiblesWithLowestListing'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collectibles: >_data.collectibles, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectiblesWithHighestOffer = ( + args: ListCollectiblesWithHighestOfferArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectiblesWithHighestOffer'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collectibles: >_data.collectibles, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + syncOrder = (args: SyncOrderArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('SyncOrder'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return {} - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('SyncOrder'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return {} + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + syncOrders = (args: SyncOrdersArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('SyncOrders'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return {} - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('SyncOrders'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return {} + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + getOrders = (args: GetOrdersArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetOrders'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - orders: >(_data.orders), - page: (_data.page), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - checkoutOptionsMarketplace = (args: CheckoutOptionsMarketplaceArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('CheckoutOptionsMarketplace'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - options: (_data.options), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - checkoutOptionsSalesContract = (args: CheckoutOptionsSalesContractArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('CheckoutOptionsSalesContract'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - options: (_data.options), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - supportedMarketplaces = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('SupportedMarketplaces'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - marketplaces: >(_data.marketplaces), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('GetOrders'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + orders: >_data.orders, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + checkoutOptionsMarketplace = ( + args: CheckoutOptionsMarketplaceArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('CheckoutOptionsMarketplace'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + options: _data.options + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + checkoutOptionsSalesContract = ( + args: CheckoutOptionsSalesContractArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('CheckoutOptionsSalesContract'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + options: _data.options + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + supportedMarketplaces = ( + args: SupportedMarketplacesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('SupportedMarketplaces'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + marketplaces: >_data.marketplaces + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - } - const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { - const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' } +const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { + const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' } reqHeaders[WebrpcHeader] = WebrpcHeaderValue return { @@ -1767,18 +2081,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 @@ -1960,7 +2274,6 @@ export class WebrpcStreamFinishedError extends WebrpcError { } } - // Schema errors export class UnauthorizedError extends WebrpcError { @@ -2119,7 +2432,6 @@ export class NotImplementedError extends WebrpcError { } } - export enum errors { WebrpcEndpoint = 'WebrpcEndpoint', WebrpcRequestFailed = 'WebrpcRequestFailed', @@ -2143,7 +2455,7 @@ export enum errors { ProjectNotFound = 'ProjectNotFound', InvalidTier = 'InvalidTier', ProjectLimitReached = 'ProjectLimitReached', - NotImplemented = 'NotImplemented', + NotImplemented = 'NotImplemented' } export enum WebrpcErrorCodes { @@ -2169,7 +2481,7 @@ export enum WebrpcErrorCodes { ProjectNotFound = 3002, InvalidTier = 3003, ProjectLimitReached = 3005, - NotImplemented = 9999, + NotImplemented = 9999 } export const webrpcErrorByCode: { [code: number]: any } = { @@ -2195,8 +2507,7 @@ export const webrpcErrorByCode: { [code: number]: any } = { [3002]: ProjectNotFoundError, [3003]: InvalidTierError, [3005]: ProjectLimitReachedError, - [9999]: NotImplementedError, + [9999]: NotImplementedError } export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise -