From cbf5c7fc5b7ebb9b0f45b81deb85d83def12af08 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 13:57:40 +0800 Subject: [PATCH 01/51] fix: add back type export after refactoring --- src/api/addresses/index.ts | 2 ++ src/api/assets/index.ts | 2 ++ src/api/blocks/type.ts | 0 src/api/index.ts | 1 + src/api/pools/index.ts | 2 ++ 5 files changed, 7 insertions(+) delete mode 100644 src/api/blocks/type.ts diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index e62e9c1..ef9ff99 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -212,3 +212,5 @@ export class AddressesApi extends BaseAPI { .then((request) => request(this.axios)); } } + +export * from './type'; diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 09b602f..8f52e1a 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -244,3 +244,5 @@ export class AssetsApi extends BaseAPI { .then((request) => request(this.axios)); } } + +export * from './type'; diff --git a/src/api/blocks/type.ts b/src/api/blocks/type.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/api/index.ts b/src/api/index.ts index fcb809e..b3de761 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -11,3 +11,4 @@ export * from './scripts'; export * from './transactions'; export * from './transactionManager'; export * from './vesting'; +export * from './type'; diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 3efd44d..9e19036 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -147,3 +147,5 @@ export class PoolsApi extends BaseAPI { .then((request) => request(this.axios)); } } + +export * from './type'; From 827b709679d3a951c256adba05566201fd237384 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 13:58:09 +0800 Subject: [PATCH 02/51] feat: bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a1ef111..1ced47c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.1.1", + "version": "1.1.2", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", From fd4d374fd18b1d5252a4178ff095cecb408d9d7e Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 14:56:24 +0800 Subject: [PATCH 03/51] feat: building first example of the refactoring --- src/api/accounts/helpers.ts | 37 +++++++++---------------------------- src/api/accounts/index.ts | 11 ++++++----- src/api/accounts/type.ts | 10 ++++++++++ 3 files changed, 25 insertions(+), 33 deletions(-) create mode 100644 src/api/accounts/type.ts diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index bba46c2..6fff798 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -17,6 +17,7 @@ import { PaginatedAccountReward, PaginatedAccountUpdate, } from '../type'; +import { AccountAddressesQueryParams } from './type'; /** * AccountsApi - axios parameter creator @@ -28,15 +29,13 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAddressesQueryParams | null} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountAddresses: async ( stakeAddr: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AccountAddressesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'stakeAddr' is not null or undefined @@ -51,19 +50,10 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -353,19 +343,17 @@ export const AccountsApiFactory = function (configuration: Configuration, basePa * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountAddresses( stakeAddr: string, - count?: number | null, - cursor?: string | null, + queryParams: AccountAddressesQueryParams, options?: any, ): AxiosPromise { return localVarFp - .accountAddresses(stakeAddr, count, cursor, options) + .accountAddresses(stakeAddr, queryParams, options) .then((request) => request(axios, basePath)); }, /** @@ -472,23 +460,16 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAddressesQueryParams | null} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async accountAddresses( stakeAddr: string, - count?: number | null, - cursor?: string | null, + queryParams?: AccountAddressesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.accountAddresses( - stakeAddr, - count, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.accountAddresses(stakeAddr, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index 2f4d259..dbc38e7 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -1,6 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AccountsApiFp } from './helpers'; +import { AccountAddressesQueryParams } from './type'; /** * AccountsApi - object-oriented interface @@ -13,20 +14,18 @@ export class AccountsApi extends BaseAPI { * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAddressesQueryParams | null} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi */ public accountAddresses( stakeAddr: string, - count?: number | null, - cursor?: string | null, + queryParams?: AccountAddressesQueryParams, options?: AxiosRequestConfig, ) { return AccountsApiFp(this.configuration) - .accountAddresses(stakeAddr, count, cursor, options) + .accountAddresses(stakeAddr, queryParams, options) .then((request) => request(this.axios)); } @@ -132,3 +131,5 @@ export class AccountsApi extends BaseAPI { .then((request) => request(this.axios)); } } + +export * from './type'; diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts new file mode 100644 index 0000000..c96161c --- /dev/null +++ b/src/api/accounts/type.ts @@ -0,0 +1,10 @@ +/** + * Query parameters for fetching account addresses. + * @param {number | null} [count] - The max number of results per page. + * @param {string | null} [cursor] - Pagination cursor string. + * Use the cursor included in a page of results to fetch the next page. + */ +export interface AccountAddressesQueryParams { + count?: number | null; + cursor?: string | null; +} From 86cb3a29e16971f5d057b8ac5b2d1e704e03a82f Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:10:42 +0800 Subject: [PATCH 04/51] docs: updating docs for accountsAddresses --- src/api/accounts/helpers.ts | 4 ++-- src/api/accounts/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 6fff798..12df849 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -29,7 +29,7 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {AccountAddressesQueryParams | null} [localVarQueryParameter] Query parameters. + * @param {AccountAddressesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -460,7 +460,7 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {AccountAddressesQueryParams | null} [queryParams] Query parameters. + * @param {AccountAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index dbc38e7..1180b92 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -14,7 +14,7 @@ export class AccountsApi extends BaseAPI { * Returns a list of addresses seen on-chain which use the specified stake key * @summary Stake account addresses * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {AccountAddressesQueryParams | null} [queryParams] Query parameters. + * @param {AccountAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi From 970f2509840fdca37d58ac9e93c09120917ef676 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:27:35 +0800 Subject: [PATCH 05/51] docs: updating docs for accountsAddresses --- src/api/accounts/type.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index c96161c..da16c98 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -1,10 +1,20 @@ /** * Query parameters for fetching account addresses. - * @param {number | null} [count] - The max number of results per page. - * @param {string | null} [cursor] - Pagination cursor string. - * Use the cursor included in a page of results to fetch the next page. + * @export + * @interface AccountHistory + * */ export interface AccountAddressesQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AccountAddressesQueryParams + */ count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AccountAddressesQueryParams + */ cursor?: string | null; } From 4c68c129c82116f494b70389b6334cac38ac61d7 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:39:08 +0800 Subject: [PATCH 06/51] feat: refactoring accountAssets --- src/api/accounts/helpers.ts | 271 ++++++++++++++++-------------------- src/api/accounts/index.ts | 16 +-- src/api/accounts/type.ts | 29 +++- 3 files changed, 154 insertions(+), 162 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 12df849..57b8120 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -17,7 +17,7 @@ import { PaginatedAccountReward, PaginatedAccountUpdate, } from '../type'; -import { AccountAddressesQueryParams } from './type'; +import { AccountAddressesQueryParams, AccountAssetsQueryParams } from './type'; /** * AccountsApi - axios parameter creator @@ -71,17 +71,13 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns a list of native assets which are owned by addresses with the specified stake key * @summary Stake account assets * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') - * @param {string | null} [policy] Filter results to only show assets of the specified policy - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAssetsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountAssets: async ( stakeAddr: string, - policy?: string | null, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AccountAssetsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'stakeAddr' is not null or undefined @@ -96,23 +92,10 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (policy !== undefined) { - localVarQueryParameter.policy = policy; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -332,122 +315,122 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati }; }; -/** - * AccountsApi - factory interface - * @export - */ -export const AccountsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = AccountsApiFp(configuration); - return { - /** - * Returns a list of addresses seen on-chain which use the specified stake key - * @summary Stake account addresses - * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {AccountAddressesQueryParams} [queryParams] Query parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountAddresses( - stakeAddr: string, - queryParams: AccountAddressesQueryParams, - options?: any, - ): AxiosPromise { - return localVarFp - .accountAddresses(stakeAddr, queryParams, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of native assets which are owned by addresses with the specified stake key - * @summary Stake account assets - * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') - * @param {string | null} [policy] Filter results to only show assets of the specified policy - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountAssets( - stakeAddr: string, - policy?: string | null, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .accountAssets(stakeAddr, policy, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns per-epoch history for the specified stake key - * @summary Stake account history - * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [epochNo] Fetch result for only a specific epoch - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountHistory( - stakeAddr: string, - epochNo?: number | null, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .accountHistory(stakeAddr, epochNo, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns various information regarding a stake account - * @summary Stake account information - * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountInfo(stakeAddr: string, options?: any): AxiosPromise { - return localVarFp.accountInfo(stakeAddr, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) - * @summary Stake account rewards - * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountRewards( - stakeAddr: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .accountRewards(stakeAddr, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) - * @summary Stake account updates - * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - accountUpdates( - stakeAddr: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .accountUpdates(stakeAddr, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * AccountsApi - factory interface +// * @export +// */ +// export const AccountsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = AccountsApiFp(configuration); +// return { +// /** +// * Returns a list of addresses seen on-chain which use the specified stake key +// * @summary Stake account addresses +// * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') +// * @param {AccountAddressesQueryParams} [queryParams] Query parameters. +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountAddresses( +// stakeAddr: string, +// queryParams: AccountAddressesQueryParams, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .accountAddresses(stakeAddr, queryParams, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of native assets which are owned by addresses with the specified stake key +// * @summary Stake account assets +// * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') +// * @param {string | null} [policy] Filter results to only show assets of the specified policy +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountAssets( +// stakeAddr: string, +// policy?: string | null, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .accountAssets(stakeAddr, policy, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns per-epoch history for the specified stake key +// * @summary Stake account history +// * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') +// * @param {number | null} [epochNo] Fetch result for only a specific epoch +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountHistory( +// stakeAddr: string, +// epochNo?: number | null, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .accountHistory(stakeAddr, epochNo, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns various information regarding a stake account +// * @summary Stake account information +// * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountInfo(stakeAddr: string, options?: any): AxiosPromise { +// return localVarFp.accountInfo(stakeAddr, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) +// * @summary Stake account rewards +// * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountRewards( +// stakeAddr: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .accountRewards(stakeAddr, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) +// * @summary Stake account updates +// * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// accountUpdates( +// stakeAddr: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .accountUpdates(stakeAddr, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// }; +// }; /** * AccountsApi - functional programming interface @@ -476,26 +459,16 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns a list of native assets which are owned by addresses with the specified stake key * @summary Stake account assets * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') - * @param {string | null} [policy] Filter results to only show assets of the specified policy - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAssetsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async accountAssets( stakeAddr: string, - policy?: string | null, - count?: number | null, - cursor?: string | null, + queryParams?: AccountAssetsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.accountAssets( - stakeAddr, - policy, - count, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.accountAssets(stakeAddr, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index 1180b92..e19a0bb 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -1,7 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AccountsApiFp } from './helpers'; -import { AccountAddressesQueryParams } from './type'; +import { AccountAddressesQueryParams, AccountAssetsQueryParams } from './type'; /** * AccountsApi - object-oriented interface @@ -33,22 +33,14 @@ export class AccountsApi extends BaseAPI { * Returns a list of native assets which are owned by addresses with the specified stake key * @summary Stake account assets * @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\') - * @param {string | null} [policy] Filter results to only show assets of the specified policy - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountAssetsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi */ - public accountAssets( - stakeAddr: string, - policy?: string | null, - count?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public accountAssets(stakeAddr: string, queryParams?: AccountAssetsQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) - .accountAssets(stakeAddr, policy, count, cursor, options) + .accountAssets(stakeAddr, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index da16c98..8129de9 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -1,7 +1,7 @@ /** * Query parameters for fetching account addresses. * @export - * @interface AccountHistory + * @interface AccountAddressesQueryParams * */ export interface AccountAddressesQueryParams { @@ -18,3 +18,30 @@ export interface AccountAddressesQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for fetching account assets. + * @export + * @interface AccountAssetsQueryParams + * + */ +export interface AccountAssetsQueryParams { + /** + * Filter results to only show assets of the specified policy + * @type {string | null} + * @memberof AccountAssetsQueryParams + */ + policy?: string | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof AccountAssetsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AccountAssetsQueryParams + */ + cursor?: string | null; +} From 78cae12b17dfd1fde78da6824ac4abd97aabd39f Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:47:42 +0800 Subject: [PATCH 07/51] feat: refactoring accountHistory --- src/api/accounts/helpers.ts | 39 ++++++------------------------------- src/api/accounts/index.ts | 16 ++++----------- src/api/accounts/type.ts | 27 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 57b8120..30b513a 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -17,7 +17,7 @@ import { PaginatedAccountReward, PaginatedAccountUpdate, } from '../type'; -import { AccountAddressesQueryParams, AccountAssetsQueryParams } from './type'; +import { AccountAddressesQueryParams, AccountAssetsQueryParams, AccountHistoryQueryParams } from './type'; /** * AccountsApi - axios parameter creator @@ -113,17 +113,13 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns per-epoch history for the specified stake key * @summary Stake account history * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [epochNo] Fetch result for only a specific epoch - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountHistoryQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountHistory: async ( stakeAddr: string, - epochNo?: number | null, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AccountHistoryQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'stakeAddr' is not null or undefined @@ -138,23 +134,10 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (epochNo !== undefined) { - localVarQueryParameter.epoch_no = epochNo; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -475,26 +458,16 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns per-epoch history for the specified stake key * @summary Stake account history * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [epochNo] Fetch result for only a specific epoch - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async accountHistory( stakeAddr: string, - epochNo?: number | null, - count?: number | null, - cursor?: string | null, + queryParams?: AccountHistoryQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.accountHistory( - stakeAddr, - epochNo, - count, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.accountHistory(stakeAddr, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index e19a0bb..e4571fd 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -1,7 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AccountsApiFp } from './helpers'; -import { AccountAddressesQueryParams, AccountAssetsQueryParams } from './type'; +import { AccountAddressesQueryParams, AccountAssetsQueryParams, AccountHistoryQueryParams } from './type'; /** * AccountsApi - object-oriented interface @@ -48,22 +48,14 @@ export class AccountsApi extends BaseAPI { * Returns per-epoch history for the specified stake key * @summary Stake account history * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [epochNo] Fetch result for only a specific epoch - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi */ - public accountHistory( - stakeAddr: string, - epochNo?: number | null, - count?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public accountHistory(stakeAddr: string, queryParams?: AccountHistoryQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) - .accountHistory(stakeAddr, epochNo, count, cursor, options) + .accountHistory(stakeAddr, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index 8129de9..54ab635 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -45,3 +45,30 @@ export interface AccountAssetsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for fetching account history. + * @export + * @interface AccountHistoryQueryParams + * + */ +export interface AccountHistoryQueryParams { + /** + * Fetch result for only a specific epoch + * @type {string | null} + * @memberof AccountHistoryQueryParams + */ + epochNo?: number | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof AccountHistoryQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AccountHistoryQueryParams + */ + cursor?: string | null; +} From 40e699a2f594c6699d204ff516baa87a845ac4d6 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:52:03 +0800 Subject: [PATCH 08/51] feat: refactoring accountRewards --- src/api/accounts/helpers.ts | 30 +++++++++++------------------- src/api/accounts/index.ts | 19 +++++++++---------- src/api/accounts/type.ts | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 30b513a..458e06d 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -17,7 +17,12 @@ import { PaginatedAccountReward, PaginatedAccountUpdate, } from '../type'; -import { AccountAddressesQueryParams, AccountAssetsQueryParams, AccountHistoryQueryParams } from './type'; +import { + AccountAddressesQueryParams, + AccountAssetsQueryParams, + AccountHistoryQueryParams, + AccountRewardsQueryParams, +} from './type'; /** * AccountsApi - axios parameter creator @@ -193,15 +198,13 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) * @summary Stake account rewards * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountRewardsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountRewards: async ( stakeAddr: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AccountRewardsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'stakeAddr' is not null or undefined @@ -216,19 +219,10 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -488,18 +482,16 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) * @summary Stake account rewards * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountRewardsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async accountRewards( stakeAddr: string, - count?: number | null, - cursor?: string | null, + queryParams?: AccountRewardsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.accountRewards(stakeAddr, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.accountRewards(stakeAddr, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index e4571fd..b053f82 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -1,7 +1,12 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AccountsApiFp } from './helpers'; -import { AccountAddressesQueryParams, AccountAssetsQueryParams, AccountHistoryQueryParams } from './type'; +import { + AccountAddressesQueryParams, + AccountAssetsQueryParams, + AccountHistoryQueryParams, + AccountRewardsQueryParams, +} from './type'; /** * AccountsApi - object-oriented interface @@ -77,20 +82,14 @@ export class AccountsApi extends BaseAPI { * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) * @summary Stake account rewards * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountRewardsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi */ - public accountRewards( - stakeAddr: string, - count?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public accountRewards(stakeAddr: string, queryParams?: AccountRewardsQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) - .accountRewards(stakeAddr, count, cursor, options) + .accountRewards(stakeAddr, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index 54ab635..85948ec 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -72,3 +72,24 @@ export interface AccountHistoryQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for fetching account rewards. + * @export + * @interface AccountRewardsQueryParams + * + */ +export interface AccountRewardsQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AccountRewardsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AccountRewardsQueryParams + */ + cursor?: string | null; +} From 7fc6ed8d7c90c28ba6b0ceaccbe1a3093f785799 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 15:54:58 +0800 Subject: [PATCH 09/51] feat: refactoring accountUpdates --- src/api/accounts/helpers.ts | 24 ++++++------------------ src/api/accounts/index.ts | 13 ++++--------- src/api/accounts/type.ts | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 458e06d..f4eb9e1 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -22,6 +22,7 @@ import { AccountAssetsQueryParams, AccountHistoryQueryParams, AccountRewardsQueryParams, + AccountUpdatesQueryParams, } from './type'; /** @@ -240,15 +241,13 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) * @summary Stake account updates * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountUpdatesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ accountUpdates: async ( stakeAddr: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AccountUpdatesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'stakeAddr' is not null or undefined @@ -263,19 +262,10 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -498,18 +488,16 @@ export const AccountsApiFp = function (configuration: Configuration) { * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) * @summary Stake account updates * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountUpdatesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async accountUpdates( stakeAddr: string, - count?: number | null, - cursor?: string | null, + queryParams?: AccountUpdatesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.accountUpdates(stakeAddr, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.accountUpdates(stakeAddr, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, }; diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index b053f82..e49c65d 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -6,6 +6,7 @@ import { AccountAssetsQueryParams, AccountHistoryQueryParams, AccountRewardsQueryParams, + AccountUpdatesQueryParams, } from './type'; /** @@ -97,20 +98,14 @@ export class AccountsApi extends BaseAPI { * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) * @summary Stake account updates * @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\') - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AccountUpdatesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AccountsApi */ - public accountUpdates( - stakeAddr: string, - count?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public accountUpdates(stakeAddr: string, queryParams?: AccountUpdatesQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) - .accountUpdates(stakeAddr, count, cursor, options) + .accountUpdates(stakeAddr, queryParams, options) .then((request) => request(this.axios)); } } diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index 85948ec..173deaf 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -93,3 +93,24 @@ export interface AccountRewardsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for fetching account updates. + * @export + * @interface AccountUpdatesQueryParams + * + */ +export interface AccountUpdatesQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AccountUpdatesQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AccountUpdatesQueryParams + */ + cursor?: string | null; +} From b95d0a713c24d54fe3e1766a912f0943f382a443 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:05:55 +0800 Subject: [PATCH 10/51] feat: refactoring txsByAddress --- src/api/addresses/helpers.ts | 426 ++++++++++++++++------------------- src/api/addresses/index.ts | 19 +- src/api/addresses/type.ts | 39 ++++ 3 files changed, 234 insertions(+), 250 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 742cf38..b9a9b32 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -20,6 +20,7 @@ import { } from '../type'; import { TxsByAddressOrderEnum, + TxsByAddressQueryParams, TxsByPaymentCredOrderEnum, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, @@ -112,21 +113,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Address transactions * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByAddressOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByAddressQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ txsByAddress: async ( address: string, - count?: number | null, - order?: TxsByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter?: TxsByAddressQueryParams, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'address' is not null or undefined @@ -141,31 +134,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -594,32 +566,16 @@ export const AddressesApiFp = function (configuration: Configuration) { * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Address transactions * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByAddressOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txsByAddress( address: string, - count?: number | null, - order?: TxsByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: TxsByAddressQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.txsByAddress( - address, - count, - order, - from, - to, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.txsByAddress(address, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** @@ -794,188 +750,188 @@ export const AddressesApiFp = function (configuration: Configuration) { }; }; -/** - * AddressesApi - factory interface - * @export - */ -export const AddressesApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = AddressesApiFp(configuration); - return { - /** - * Returns the different information encoded within a Cardano address, including details of the payment and delegation parts of the address - * @summary Decode address - * @param {string} address Address in bech32/hex/base58 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - decodeAddress(address: string, options?: any): AxiosPromise { - return localVarFp.decodeAddress(address, options).then((request) => request(axios, basePath)); - }, - /** - * Returns the number of transactions in which the address spent or received some funds. Specifically, the number of transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). - * @summary Address transaction count - * @param {string} address Address in bech32 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txCountByAddress(address: string, options?: any): AxiosPromise { - return localVarFp.txCountByAddress(address, options).then((request) => request(axios, basePath)); - }, - /** - * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). - * @summary Address transactions - * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByAddressOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txsByAddress( - address: string, - count?: number | null, - order?: TxsByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .txsByAddress(address, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). - * @summary Payment credential transactions - * @param {string} credential Payment credential in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByPaymentCredOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txsByPaymentCred( - credential: string, - count?: number | null, - order?: TxsByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .txsByPaymentCred(credential, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address - * @summary UTxO references at an address - * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {UtxoRefsAtAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - utxoRefsAtAddress( - address: string, - count?: number | null, - order?: UtxoRefsAtAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .utxoRefsAtAddress(address, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Return detailed information on UTxOs controlled by an address - * @summary UTxOs at an address - * @param {string} address Address in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - utxosByAddress( - address: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .utxosByAddress(address, resolveDatums, withCbor, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses - * @summary UTxOs at multiple addresses - * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - utxosByAddresses( - requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .utxosByAddresses(requestBody, resolveDatums, withCbor, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Return detailed information on UTxOs controlled by addresses which use the specified payment credential - * @summary UTxOs by payment credential - * @param {string} credential Payment credential in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByPaymentCredOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - utxosByPaymentCred( - credential: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .utxosByPaymentCred(credential, resolveDatums, withCbor, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * AddressesApi - factory interface +// * @export +// */ +// export const AddressesApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = AddressesApiFp(configuration); +// return { +// /** +// * Returns the different information encoded within a Cardano address, including details of the payment and delegation parts of the address +// * @summary Decode address +// * @param {string} address Address in bech32/hex/base58 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// decodeAddress(address: string, options?: any): AxiosPromise { +// return localVarFp.decodeAddress(address, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the number of transactions in which the address spent or received some funds. Specifically, the number of transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). +// * @summary Address transaction count +// * @param {string} address Address in bech32 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txCountByAddress(address: string, options?: any): AxiosPromise { +// return localVarFp.txCountByAddress(address, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). +// * @summary Address transactions +// * @param {string} address Address in bech32 format +// * @param {number | null} [count] The max number of results per page +// * @param {TxsByAddressOrderEnum} [order] The order in which the results are sorted, by transaction age) +// * @param {number | null} [from] Return only transactions minted on or after a specific slot +// * @param {number | null} [to] Return only transactions minted on or before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txsByAddress( +// address: string, +// count?: number | null, +// order?: TxsByAddressOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .txsByAddress(address, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). +// * @summary Payment credential transactions +// * @param {string} credential Payment credential in bech32 format +// * @param {number | null} [count] The max number of results per page +// * @param {TxsByPaymentCredOrderEnum} [order] The order in which the results are sorted, by transaction age) +// * @param {number | null} [from] Return only transactions minted on or after a specific slot +// * @param {number | null} [to] Return only transactions minted on or before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txsByPaymentCred( +// credential: string, +// count?: number | null, +// order?: TxsByPaymentCredOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .txsByPaymentCred(credential, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address +// * @summary UTxO references at an address +// * @param {string} address Address in bech32 format +// * @param {number | null} [count] The max number of results per page +// * @param {UtxoRefsAtAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) +// * @param {number | null} [from] Return only UTxOs created on or after a specific slot +// * @param {number | null} [to] Return only UTxOs created before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// utxoRefsAtAddress( +// address: string, +// count?: number | null, +// order?: UtxoRefsAtAddressOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .utxoRefsAtAddress(address, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Return detailed information on UTxOs controlled by an address +// * @summary UTxOs at an address +// * @param {string} address Address in bech32 format +// * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes +// * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response +// * @param {number | null} [count] The max number of results per page +// * @param {UtxosByAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) +// * @param {number | null} [from] Return only UTxOs created on or after a specific slot +// * @param {number | null} [to] Return only UTxOs created before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// utxosByAddress( +// address: string, +// resolveDatums?: boolean | null, +// withCbor?: boolean | null, +// count?: number | null, +// order?: UtxosByAddressOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .utxosByAddress(address, resolveDatums, withCbor, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses +// * @summary UTxOs at multiple addresses +// * @param {Array} requestBody +// * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes +// * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// utxosByAddresses( +// requestBody: Array, +// resolveDatums?: boolean | null, +// withCbor?: boolean | null, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .utxosByAddresses(requestBody, resolveDatums, withCbor, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Return detailed information on UTxOs controlled by addresses which use the specified payment credential +// * @summary UTxOs by payment credential +// * @param {string} credential Payment credential in bech32 format +// * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes +// * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response +// * @param {number | null} [count] The max number of results per page +// * @param {UtxosByPaymentCredOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) +// * @param {number | null} [from] Return only UTxOs created on or after a specific slot +// * @param {number | null} [to] Return only UTxOs created on or before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// utxosByPaymentCred( +// credential: string, +// resolveDatums?: boolean | null, +// withCbor?: boolean | null, +// count?: number | null, +// order?: UtxosByPaymentCredOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .utxosByPaymentCred(credential, resolveDatums, withCbor, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index e62e9c1..d140bc6 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -3,6 +3,7 @@ import { BaseAPI } from '../../base'; import { AddressesApiFp } from './helpers'; import { TxsByAddressOrderEnum, + TxsByAddressQueryParams, TxsByPaymentCredOrderEnum, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, @@ -48,26 +49,14 @@ export class AddressesApi extends BaseAPI { * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Address transactions * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByAddressOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ - public txsByAddress( - address: string, - count?: number | null, - order?: TxsByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public txsByAddress(address: string, queryParams?: TxsByAddressQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) - .txsByAddress(address, count, order, from, to, cursor, options) + .txsByAddress(address, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index b2edf56..b28d241 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -39,3 +39,42 @@ export const UtxosByPaymentCredOrderEnum = { } as const; export type UtxosByPaymentCredOrderEnum = (typeof UtxosByPaymentCredOrderEnum)[keyof typeof UtxosByPaymentCredOrderEnum]; + +/** + * Query parameters for fetching transactions by address. + * @export + * @interface TxsByAddressQueryParams + * + */ +export interface TxsByAddressQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof TxsByAddressQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted, by transaction age + * @type {TxsByAddressOrderEnum} + * @memberof TxsByAddressQueryParams + */ + order?: TxsByAddressOrderEnum; + /** + * Return only transactions minted on or after a specific slot + * @type {number | null} + * @memberof TxsByAddressQueryParams + */ + from?: number | null; + /** + * Return only transactions minted on or before a specific slot + * @type {number | null} + * @memberof TxsByAddressQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof TxsByAddressQueryParams + */ + cursor?: string | null; +} From df530075d4d821328e9e551ae251b22fb24bb75a Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:10:26 +0800 Subject: [PATCH 11/51] feat: refactoring txsByPaymentCred --- src/api/addresses/helpers.ts | 52 +++++------------------------------- src/api/addresses/index.ts | 16 +++-------- src/api/addresses/type.ts | 39 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 58 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index b9a9b32..ad6a548 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -22,6 +22,7 @@ import { TxsByAddressOrderEnum, TxsByAddressQueryParams, TxsByPaymentCredOrderEnum, + TxsByPaymentCredQueryParams, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, UtxosByPaymentCredOrderEnum, @@ -155,21 +156,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Payment credential transactions * @param {string} credential Payment credential in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByPaymentCredOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ txsByPaymentCred: async ( credential: string, - count?: number | null, - order?: TxsByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter: TxsByPaymentCredQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'credential' is not null or undefined @@ -184,31 +177,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -582,30 +554,18 @@ export const AddressesApiFp = function (configuration: Configuration) { * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Payment credential transactions * @param {string} credential Payment credential in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByPaymentCredOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByPaymentCredQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txsByPaymentCred( credential: string, - count?: number | null, - order?: TxsByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: TxsByPaymentCredQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txsByPaymentCred( credential, - count, - order, - from, - to, - cursor, + queryParams, options, ); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index d140bc6..3ac0951 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -2,9 +2,9 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AddressesApiFp } from './helpers'; import { - TxsByAddressOrderEnum, TxsByAddressQueryParams, TxsByPaymentCredOrderEnum, + TxsByPaymentCredQueryParams, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, UtxosByPaymentCredOrderEnum, @@ -64,26 +64,18 @@ export class AddressesApi extends BaseAPI { * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). * @summary Payment credential transactions * @param {string} credential Payment credential in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {TxsByPaymentCredOrderEnum} [order] The order in which the results are sorted, by transaction age) - * @param {number | null} [from] Return only transactions minted on or after a specific slot - * @param {number | null} [to] Return only transactions minted on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {TxsByPaymentCredQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ public txsByPaymentCred( credential: string, - count?: number | null, - order?: TxsByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: TxsByPaymentCredQueryParams, options?: AxiosRequestConfig, ) { return AddressesApiFp(this.configuration) - .txsByPaymentCred(credential, count, order, from, to, cursor, options) + .txsByPaymentCred(credential, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index b28d241..cc6dfa4 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -78,3 +78,42 @@ export interface TxsByAddressQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for fetching transactions by payment credential. + * @export + * @interface TxsByPaymentCredQueryParams + * + */ +export interface TxsByPaymentCredQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof TxsByPaymentCredQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted, by transaction age + * @type {TxsByAddressOrderEnum} + * @memberof TxsByPaymentCredQueryParams + */ + order?: TxsByPaymentCredOrderEnum; + /** + * Return only transactions minted on or after a specific slot + * @type {number | null} + * @memberof TxsByPaymentCredQueryParams + */ + from?: number | null; + /** + * Return only transactions minted on or before a specific slot + * @type {number | null} + * @memberof TxsByPaymentCredQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof TxsByPaymentCredQueryParams + */ + cursor?: string | null; +} From dc55751ceed74f52f96ec698a3e7bf55c019ef18 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:17:24 +0800 Subject: [PATCH 12/51] feat: refactoring utxoRefsAtAddress --- src/api/accounts/type.ts | 10 +++---- src/api/addresses/helpers.ts | 56 ++++-------------------------------- src/api/addresses/index.ts | 19 ++---------- src/api/addresses/type.ts | 45 +++++++++++++++++++++++++++-- 4 files changed, 56 insertions(+), 74 deletions(-) diff --git a/src/api/accounts/type.ts b/src/api/accounts/type.ts index 173deaf..e2b9d09 100644 --- a/src/api/accounts/type.ts +++ b/src/api/accounts/type.ts @@ -1,5 +1,5 @@ /** - * Query parameters for fetching account addresses. + * Query parameters for accountAddresses. * @export * @interface AccountAddressesQueryParams * @@ -20,7 +20,7 @@ export interface AccountAddressesQueryParams { } /** - * Query parameters for fetching account assets. + * Query parameters for accountAssets. * @export * @interface AccountAssetsQueryParams * @@ -47,7 +47,7 @@ export interface AccountAssetsQueryParams { } /** - * Query parameters for fetching account history. + * Query parameters for accountHistory. * @export * @interface AccountHistoryQueryParams * @@ -74,7 +74,7 @@ export interface AccountHistoryQueryParams { } /** - * Query parameters for fetching account rewards. + * Query parameters for accountRewards. * @export * @interface AccountRewardsQueryParams * @@ -95,7 +95,7 @@ export interface AccountRewardsQueryParams { } /** - * Query parameters for fetching account updates. + * Query parameters for accountUpdates. * @export * @interface AccountUpdatesQueryParams * diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index ad6a548..a6335be 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -24,6 +24,7 @@ import { TxsByPaymentCredOrderEnum, TxsByPaymentCredQueryParams, UtxoRefsAtAddressOrderEnum, + UtxoRefsAtAddressQueryParams, UtxosByAddressOrderEnum, UtxosByPaymentCredOrderEnum, } from './type'; @@ -198,21 +199,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address * @summary UTxO references at an address * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {UtxoRefsAtAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxoRefsAtAddressQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ utxoRefsAtAddress: async ( address: string, - count?: number | null, - order?: UtxoRefsAtAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter: UtxoRefsAtAddressQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'address' is not null or undefined @@ -227,31 +220,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -574,32 +546,16 @@ export const AddressesApiFp = function (configuration: Configuration) { * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address * @summary UTxO references at an address * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {UtxoRefsAtAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxoRefsAtAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async utxoRefsAtAddress( address: string, - count?: number | null, - order?: UtxoRefsAtAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: UtxoRefsAtAddressQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.utxoRefsAtAddress( - address, - count, - order, - from, - to, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.utxoRefsAtAddress(address, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index 3ac0951..fcbf9a9 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -3,7 +3,6 @@ import { BaseAPI } from '../../base'; import { AddressesApiFp } from './helpers'; import { TxsByAddressQueryParams, - TxsByPaymentCredOrderEnum, TxsByPaymentCredQueryParams, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, @@ -83,26 +82,14 @@ export class AddressesApi extends BaseAPI { * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address * @summary UTxO references at an address * @param {string} address Address in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {UtxoRefsAtAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxoRefsAtAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ - public utxoRefsAtAddress( - address: string, - count?: number | null, - order?: UtxoRefsAtAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public utxoRefsAtAddress(address: string, queryParams?: TxsByPaymentCredQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) - .utxoRefsAtAddress(address, count, order, from, to, cursor, options) + .utxoRefsAtAddress(address, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index cc6dfa4..32c21a2 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -41,7 +41,7 @@ export type UtxosByPaymentCredOrderEnum = (typeof UtxosByPaymentCredOrderEnum)[keyof typeof UtxosByPaymentCredOrderEnum]; /** - * Query parameters for fetching transactions by address. + * Query parameters for txsByAddress. * @export * @interface TxsByAddressQueryParams * @@ -80,7 +80,7 @@ export interface TxsByAddressQueryParams { } /** - * Query parameters for fetching transactions by payment credential. + * Query parameters for txsByPaymentCred. * @export * @interface TxsByPaymentCredQueryParams * @@ -94,7 +94,7 @@ export interface TxsByPaymentCredQueryParams { count?: number | null; /** * The order in which the results are sorted, by transaction age - * @type {TxsByAddressOrderEnum} + * @type {TxsByPaymentCredOrderEnum} * @memberof TxsByPaymentCredQueryParams */ order?: TxsByPaymentCredOrderEnum; @@ -117,3 +117,42 @@ export interface TxsByPaymentCredQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for utxoRefsAtAddress. + * @export + * @interface UtxoRefsAtAddressQueryParams + * + */ +export interface UtxoRefsAtAddressQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof UtxoRefsAtAddressQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by slot at which UTxO was produced) + * @type {UtxoRefsAtAddressOrderEnum} + * @memberof UtxoRefsAtAddressQueryParams + */ + order?: UtxoRefsAtAddressOrderEnum; + /** + * Return only UTxOs created on or after a specific slot + * @type {number | null} + * @memberof UtxoRefsAtAddressQueryParams + */ + from?: number | null; + /** + * Return only UTxOs created before a specific slot + * @type {number | null} + * @memberof UtxoRefsAtAddressQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof UtxoRefsAtAddressQueryParams + */ + cursor?: string | null; +} From 5f5b93fbdb639d1e6d1ddb4c6270dd13987f785a Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:22:19 +0800 Subject: [PATCH 13/51] feat: refactoring utxosByAddress --- src/api/addresses/helpers.ts | 74 +++--------------------------------- src/api/addresses/index.ts | 23 ++--------- src/api/addresses/type.ts | 51 +++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 87 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index a6335be..3782d09 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -26,6 +26,7 @@ import { UtxoRefsAtAddressOrderEnum, UtxoRefsAtAddressQueryParams, UtxosByAddressOrderEnum, + UtxosByAddressQueryParams, UtxosByPaymentCredOrderEnum, } from './type'; @@ -241,25 +242,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Return detailed information on UTxOs controlled by an address * @summary UTxOs at an address * @param {string} address Address in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ utxosByAddress: async ( address: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter?: UtxosByAddressQueryParams, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'address' is not null or undefined @@ -274,39 +263,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (resolveDatums !== undefined) { - localVarQueryParameter.resolve_datums = resolveDatums; - } - - if (withCbor !== undefined) { - localVarQueryParameter.with_cbor = withCbor; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -562,38 +522,16 @@ export const AddressesApiFp = function (configuration: Configuration) { * Return detailed information on UTxOs controlled by an address * @summary UTxOs at an address * @param {string} address Address in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async utxosByAddress( address: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: UtxosByAddressQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByAddress( - address, - resolveDatums, - withCbor, - count, - order, - from, - to, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByAddress(address, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index fcbf9a9..72eb5b6 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -6,6 +6,7 @@ import { TxsByPaymentCredQueryParams, UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, + UtxosByAddressQueryParams, UtxosByPaymentCredOrderEnum, } from './type'; @@ -97,30 +98,14 @@ export class AddressesApi extends BaseAPI { * Return detailed information on UTxOs controlled by an address * @summary UTxOs at an address * @param {string} address Address in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByAddressOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ - public utxosByAddress( - address: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByAddressOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public utxosByAddress(address: string, queryParams?: UtxosByAddressQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) - .utxosByAddress(address, resolveDatums, withCbor, count, order, from, to, cursor, options) + .utxosByAddress(address, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index 32c21a2..b052700 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -156,3 +156,54 @@ export interface UtxoRefsAtAddressQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for utxoRefsAtAddress. + * @export + * @interface UtxosByAddressQueryParams + * + */ +export interface UtxosByAddressQueryParams { + /** + * Try find and include the corresponding datums for datum hashes + * @type {boolean | null} + * @memberof UtxosByAddressQueryParams + */ + resolveDatums?: boolean | null; + /** + * Include the CBOR encodings of the transaction outputs in the response + * @type {boolean | null} + * @memberof UtxosByAddressQueryParams + */ + withCbor?: boolean | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof UtxosByAddressQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by slot at which UTxO was produced) + * @type {UtxosByAddressOrderEnum} + * @memberof UtxosByAddressQueryParams + */ + order?: UtxosByAddressOrderEnum; + /** + * Return only UTxOs created on or after a specific slot + * @type {number | null} + * @memberof UtxosByAddressQueryParams + */ + from?: number | null; + /** + * Return only UTxOs created before a specific slot + * @type {number | null} + * @memberof UtxosByAddressQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof UtxosByAddressQueryParams + */ + cursor?: string | null; +} From f458220aca2be138d9767039c3bfe73e0167bdbd Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:25:48 +0800 Subject: [PATCH 14/51] feat: refactoring utxosByAddresses --- src/api/addresses/helpers.ts | 45 ++++++------------------------------ src/api/addresses/index.ts | 13 ++++------- src/api/addresses/type.ts | 35 +++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 48 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 3782d09..2e74bb1 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -27,6 +27,7 @@ import { UtxoRefsAtAddressQueryParams, UtxosByAddressOrderEnum, UtxosByAddressQueryParams, + UtxosByAddressesQueryParams, UtxosByPaymentCredOrderEnum, } from './type'; @@ -248,7 +249,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat */ utxosByAddress: async ( address: string, - localVarQueryParameter?: UtxosByAddressQueryParams, + localVarQueryParameter: UtxosByAddressQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'address' is not null or undefined @@ -284,19 +285,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses * @summary UTxOs at multiple addresses * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ utxosByAddresses: async ( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: UtxosByAddressesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'requestBody' is not null or undefined @@ -308,27 +303,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (resolveDatums !== undefined) { - localVarQueryParameter.resolve_datums = resolveDatums; - } - - if (withCbor !== undefined) { - localVarQueryParameter.with_cbor = withCbor; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -538,27 +516,18 @@ export const AddressesApiFp = function (configuration: Configuration) { * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses * @summary UTxOs at multiple addresses * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async utxosByAddresses( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - cursor?: string | null, + queryParams?: UtxosByAddressesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByAddresses( requestBody, - resolveDatums, - withCbor, - count, - cursor, + queryParams, options, ); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index 72eb5b6..e2505cd 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -7,6 +7,7 @@ import { UtxoRefsAtAddressOrderEnum, UtxosByAddressOrderEnum, UtxosByAddressQueryParams, + UtxosByAddressesQueryParams, UtxosByPaymentCredOrderEnum, } from './type'; @@ -113,24 +114,18 @@ export class AddressesApi extends BaseAPI { * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses * @summary UTxOs at multiple addresses * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ public utxosByAddresses( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - cursor?: string | null, + queryParams?: UtxosByAddressesQueryParams, options?: AxiosRequestConfig, ) { return AddressesApiFp(this.configuration) - .utxosByAddresses(requestBody, resolveDatums, withCbor, count, cursor, options) + .utxosByAddresses(requestBody, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index b052700..cdf3c91 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -158,7 +158,7 @@ export interface UtxoRefsAtAddressQueryParams { } /** - * Query parameters for utxoRefsAtAddress. + * Query parameters for utxosByAddress. * @export * @interface UtxosByAddressQueryParams * @@ -207,3 +207,36 @@ export interface UtxosByAddressQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for utxosByAddresses. + * @export + * @interface UtxosByAddressesQueryParams + * + */ +export interface UtxosByAddressesQueryParams { + /** + * Try find and include the corresponding datums for datum hashes + * @type {boolean | null} + * @memberof UtxosByAddressesQueryParams + */ + resolveDatums?: boolean | null; + /** + * Include the CBOR encodings of the transaction outputs in the response + * @type {boolean | null} + * @memberof UtxosByAddressesQueryParams + */ + withCbor?: boolean | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof UtxosByAddressesQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof UtxosByAddressesQueryParams + */ + cursor?: string | null; +} From 43a93059bafac23a34f195772647179183df5e5d Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 16:30:05 +0800 Subject: [PATCH 15/51] feat: refactoring utxosByPaymentCred --- src/api/addresses/helpers.ts | 70 ++++-------------------------------- src/api/addresses/index.ts | 19 +++------- src/api/addresses/type.ts | 51 ++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 79 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 2e74bb1..2d53070 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -29,6 +29,7 @@ import { UtxosByAddressQueryParams, UtxosByAddressesQueryParams, UtxosByPaymentCredOrderEnum, + UtxosByPaymentCredQueryParams, } from './type'; /** @@ -327,25 +328,13 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat * Return detailed information on UTxOs controlled by addresses which use the specified payment credential * @summary UTxOs by payment credential * @param {string} credential Payment credential in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByPaymentCredOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByPaymentCredQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ utxosByPaymentCred: async ( credential: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter: UtxosByPaymentCredQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'credential' is not null or undefined @@ -360,39 +349,10 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (resolveDatums !== undefined) { - localVarQueryParameter.resolve_datums = resolveDatums; - } - - if (withCbor !== undefined) { - localVarQueryParameter.with_cbor = withCbor; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -536,36 +496,18 @@ export const AddressesApiFp = function (configuration: Configuration) { * Return detailed information on UTxOs controlled by addresses which use the specified payment credential * @summary UTxOs by payment credential * @param {string} credential Payment credential in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByPaymentCredOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByPaymentCredQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async utxosByPaymentCred( credential: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: UtxosByPaymentCredQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByPaymentCred( credential, - resolveDatums, - withCbor, - count, - order, - from, - to, - cursor, + queryParams, options, ); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index e2505cd..2ab3388 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -9,6 +9,7 @@ import { UtxosByAddressQueryParams, UtxosByAddressesQueryParams, UtxosByPaymentCredOrderEnum, + UtxosByPaymentCredQueryParams, } from './type'; /** @@ -133,30 +134,18 @@ export class AddressesApi extends BaseAPI { * Return detailed information on UTxOs controlled by addresses which use the specified payment credential * @summary UTxOs by payment credential * @param {string} credential Payment credential in bech32 format - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encodings of the transaction outputs in the response - * @param {number | null} [count] The max number of results per page - * @param {UtxosByPaymentCredOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created on or before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {UtxosByPaymentCredQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi */ public utxosByPaymentCred( credential: string, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - count?: number | null, - order?: UtxosByPaymentCredOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: UtxosByPaymentCredQueryParams, options?: AxiosRequestConfig, ) { return AddressesApiFp(this.configuration) - .utxosByPaymentCred(credential, resolveDatums, withCbor, count, order, from, to, cursor, options) + .utxosByPaymentCred(credential, queryParams, options) .then((request) => request(this.axios)); } } diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index cdf3c91..f8d1155 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -240,3 +240,54 @@ export interface UtxosByAddressesQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for utxosByPaymentCred. + * @export + * @interface UtxosByPaymentCredQueryParams + * + */ +export interface UtxosByPaymentCredQueryParams { + /** + * Try find and include the corresponding datums for datum hashes + * @type {boolean | null} + * @memberof UtxosByPaymentCredQueryParams + */ + resolveDatums?: boolean | null; + /** + * Include the CBOR encodings of the transaction outputs in the response + * @type {boolean | null} + * @memberof UtxosByPaymentCredQueryParams + */ + withCbor?: boolean | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof UtxosByPaymentCredQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by slot at which UTxO was produced) + * @type {UtxosByPaymentCredOrderEnum} + * @memberof UtxosByPaymentCredQueryParams + */ + order?: UtxosByPaymentCredOrderEnum; + /** + * Return only UTxOs created on or after a specific slot + * @type {number | null} + * @memberof UtxosByPaymentCredQueryParams + */ + from?: number | null; + /** + * Return only UTxOs created on or before a specific slot + * @type {number | null} + * @memberof UtxosByPaymentCredQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof UtxosByPaymentCredQueryParams + */ + cursor?: string | null; +} From ebffa13e6f627cdbb1d01a7e5af9d604af0dc5a8 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 22:56:05 +0800 Subject: [PATCH 16/51] feat: adding type support for asset in address queries --- src/api/addresses/type.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/addresses/type.ts b/src/api/addresses/type.ts index f8d1155..33ba2e6 100644 --- a/src/api/addresses/type.ts +++ b/src/api/addresses/type.ts @@ -164,6 +164,12 @@ export interface UtxoRefsAtAddressQueryParams { * */ export interface UtxosByAddressQueryParams { + /** + * Return only UTxOs which contain some of a specific asset (asset formatted as concatenation of hex encoded policy and asset name) + * @type {string | null} + * @memberof UtxosByAddressQueryParams + */ + asset?: string | null; /** * Try find and include the corresponding datums for datum hashes * @type {boolean | null} @@ -248,6 +254,12 @@ export interface UtxosByAddressesQueryParams { * */ export interface UtxosByPaymentCredQueryParams { + /** + * Return only UTxOs which contain some of a specific asset (asset formatted as concatenation of hex encoded policy and asset name) + * @type {string | null} + * @memberof UtxosByAddressQueryParams + */ + asset?: string | null; /** * Try find and include the corresponding datums for datum hashes * @type {boolean | null} From bd7f6cd440d11d0f266323152d8b7991e63a1628 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:07:40 +0800 Subject: [PATCH 17/51] feat: refactoring assetAccounts --- src/api/assets/helpers.ts | 478 +++++++++++++++++++------------------- src/api/assets/index.ts | 8 +- src/api/assets/type.ts | 21 ++ 3 files changed, 258 insertions(+), 249 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 32f3230..11031e3 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -22,6 +22,7 @@ import { PaginatedPolicyUtxo, } from '../type'; import { + AssetAccountsQueryParams, AssetTxsOrderEnum, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, @@ -39,15 +40,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding specific asset * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAccountsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ assetAccounts: async ( asset: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AssetAccountsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'asset' is not null or undefined @@ -59,19 +58,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -668,18 +658,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding specific asset * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAccountsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async assetAccounts( asset: string, - count?: number | null, - cursor?: string | null, + queryParams?: AssetAccountsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.assetAccounts(asset, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.assetAccounts(asset, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** @@ -922,230 +910,230 @@ export const AssetsApiFp = function (configuration: Configuration) { }; }; -/** - * AssetsApi - factory interface - * @export - */ -export const AssetsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = AssetsApiFp(configuration); - return { - /** - * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). - * @summary Accounts of addresses holding specific asset - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetAccounts( - asset: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp.assetAccounts(asset, count, cursor, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of addresses which control some amount of the specified asset - * @summary Native asset addresses - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetAddresses( - asset: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp.assetAddresses(asset, count, cursor, options).then((request) => request(axios, basePath)); - }, - /** - * Return a summary of information about an asset - * @summary Native asset information - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetInfo(asset: string, options?: any): AxiosPromise { - return localVarFp.assetInfo(asset, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of transactions in which a transaction input or output contains some of the specified asset - * @summary Native asset transactions - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {AssetTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetTxs( - asset: string, - fromHeight?: number | null, - count?: number | null, - order?: AssetTxsOrderEnum, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .assetTxs(asset, fromHeight, count, order, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of transactions in which some of the specified asset was minted or burned - * @summary Native asset updates - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {AssetUpdatesOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetUpdates( - asset: string, - count?: number | null, - order?: AssetUpdatesOrderEnum, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .assetUpdates(asset, count, order, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO - * @summary Native asset UTxOs - * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {string | null} [address] Return only UTxOs controlled by a specific address (bech32 encoding) - * @param {number | null} [count] The max number of results per page - * @param {AssetUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - assetUtxos( - asset: string, - address?: string | null, - count?: number | null, - order?: AssetUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .assetUtxos(asset, address, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). - * @summary Accounts of addresses holding assets of specific policy - * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - policyAccounts( - policy: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .policyAccounts(policy, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of addresses which hold some of an asset of the specified policy ID - * @summary Addresses holding assets of specific policy - * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - policyAddresses( - policy: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .policyAddresses(policy, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns information about assets of the specified minting policy ID - * @summary Information on assets of specific policy - * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - policyInfo( - policy: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp.policyInfo(policy, count, cursor, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID - * @summary Transactions moving assets of specific policy - * @param {string} policy Hex encoded policy ID - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {PolicyTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - policyTxs( - policy: string, - fromHeight?: number | null, - count?: number | null, - order?: PolicyTxsOrderEnum, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .policyTxs(policy, fromHeight, count, order, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts - * @summary UTxOs containing assets of specific policy - * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {PolicyUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - policyUtxos( - policy: string, - count?: number | null, - order?: PolicyUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .policyUtxos(policy, count, order, from, to, cursor, options) - .then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * AssetsApi - factory interface +// * @export +// */ +// export const AssetsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = AssetsApiFp(configuration); +// return { +// /** +// * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). +// * @summary Accounts of addresses holding specific asset +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetAccounts( +// asset: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp.assetAccounts(asset, count, cursor, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of addresses which control some amount of the specified asset +// * @summary Native asset addresses +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetAddresses( +// asset: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp.assetAddresses(asset, count, cursor, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Return a summary of information about an asset +// * @summary Native asset information +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetInfo(asset: string, options?: any): AxiosPromise { +// return localVarFp.assetInfo(asset, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of transactions in which a transaction input or output contains some of the specified asset +// * @summary Native asset transactions +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {number | null} [fromHeight] Return only transactions after supplied block height +// * @param {number | null} [count] The max number of results per page +// * @param {AssetTxsOrderEnum} [order] The order in which the results are sorted (by block height) +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetTxs( +// asset: string, +// fromHeight?: number | null, +// count?: number | null, +// order?: AssetTxsOrderEnum, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .assetTxs(asset, fromHeight, count, order, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of transactions in which some of the specified asset was minted or burned +// * @summary Native asset updates +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {number | null} [count] The max number of results per page +// * @param {AssetUpdatesOrderEnum} [order] The order in which the results are sorted (by block height) +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetUpdates( +// asset: string, +// count?: number | null, +// order?: AssetUpdatesOrderEnum, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .assetUpdates(asset, count, order, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO +// * @summary Native asset UTxOs +// * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name +// * @param {string | null} [address] Return only UTxOs controlled by a specific address (bech32 encoding) +// * @param {number | null} [count] The max number of results per page +// * @param {AssetUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) +// * @param {number | null} [from] Return only UTxOs created on or after a specific slot +// * @param {number | null} [to] Return only UTxOs created before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// assetUtxos( +// asset: string, +// address?: string | null, +// count?: number | null, +// order?: AssetUtxosOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .assetUtxos(asset, address, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). +// * @summary Accounts of addresses holding assets of specific policy +// * @param {string} policy Hex encoded Policy ID +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// policyAccounts( +// policy: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .policyAccounts(policy, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of addresses which hold some of an asset of the specified policy ID +// * @summary Addresses holding assets of specific policy +// * @param {string} policy Hex encoded Policy ID +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// policyAddresses( +// policy: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .policyAddresses(policy, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns information about assets of the specified minting policy ID +// * @summary Information on assets of specific policy +// * @param {string} policy Hex encoded policy ID +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// policyInfo( +// policy: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp.policyInfo(policy, count, cursor, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID +// * @summary Transactions moving assets of specific policy +// * @param {string} policy Hex encoded policy ID +// * @param {number | null} [fromHeight] Return only transactions after supplied block height +// * @param {number | null} [count] The max number of results per page +// * @param {PolicyTxsOrderEnum} [order] The order in which the results are sorted (by block height) +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// policyTxs( +// policy: string, +// fromHeight?: number | null, +// count?: number | null, +// order?: PolicyTxsOrderEnum, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .policyTxs(policy, fromHeight, count, order, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts +// * @summary UTxOs containing assets of specific policy +// * @param {string} policy Hex encoded policy ID +// * @param {number | null} [count] The max number of results per page +// * @param {PolicyUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) +// * @param {number | null} [from] Return only UTxOs created on or after a specific slot +// * @param {number | null} [to] Return only UTxOs created before a specific slot +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// policyUtxos( +// policy: string, +// count?: number | null, +// order?: PolicyUtxosOrderEnum, +// from?: number | null, +// to?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .policyUtxos(policy, count, order, from, to, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 09b602f..c071298 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -2,6 +2,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { AssetsApiFp } from './helpers'; import { + AssetAccountsQueryParams, AssetTxsOrderEnum, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, @@ -20,15 +21,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding specific asset * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAccountsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public assetAccounts(asset: string, count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public assetAccounts(asset: string, queryParams?: AssetAccountsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .assetAccounts(asset, count, cursor, options) + .assetAccounts(asset, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 7db693a..e4ee478 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -38,3 +38,24 @@ export const PolicyUtxosOrderEnum = { Desc: 'desc', } as const; export type PolicyUtxosOrderEnum = (typeof PolicyUtxosOrderEnum)[keyof typeof PolicyUtxosOrderEnum]; + +/** + * Query parameters for assetAccounts. + * @export + * @interface AssetAccountsQueryParams + * + */ +export interface AssetAccountsQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AssetAccountsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AssetAccountsQueryParams + */ + cursor?: string | null; +} From 546a61f8f88af02cd50173b09e262fd98ca8943b Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:10:36 +0800 Subject: [PATCH 18/51] feat: refactoring assetAddresses --- src/api/assets/helpers.ts | 26 +++++++------------------- src/api/assets/index.ts | 8 ++++---- src/api/assets/type.ts | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 11031e3..ff52624 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -23,6 +23,7 @@ import { } from '../type'; import { AssetAccountsQueryParams, + AssetAddressesQueryParams, AssetTxsOrderEnum, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, @@ -40,7 +41,7 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of the specified asset; in other words, instead of returning the addresses which hold some of the asset, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding specific asset * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {AssetAccountsQueryParams} [queryParams] Query parameters. + * @param {AssetAccountsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -79,15 +80,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of addresses which control some amount of the specified asset * @summary Native asset addresses * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAddressesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ assetAddresses: async ( asset: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: AssetAddressesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'asset' is not null or undefined @@ -99,19 +98,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -674,18 +664,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of addresses which control some amount of the specified asset * @summary Native asset addresses * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async assetAddresses( asset: string, - count?: number | null, - cursor?: string | null, + queryParams?: AssetAddressesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.assetAddresses(asset, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.assetAddresses(asset, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index c071298..e212136 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -3,6 +3,7 @@ import { BaseAPI } from '../../base'; import { AssetsApiFp } from './helpers'; import { AssetAccountsQueryParams, + AssetAddressesQueryParams, AssetTxsOrderEnum, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, @@ -36,15 +37,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of addresses which control some amount of the specified asset * @summary Native asset addresses * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public assetAddresses(asset: string, count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public assetAddresses(asset: string, queryParams?: AssetAddressesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .assetAddresses(asset, count, cursor, options) + .assetAddresses(asset, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index e4ee478..967d003 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -59,3 +59,24 @@ export interface AssetAccountsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for assetAddresses. + * @export + * @interface AssetAddressesQueryParams + * + */ +export interface AssetAddressesQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AssetAddressesQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AssetAddressesQueryParams + */ + cursor?: string | null; +} From a5e02fbd47670bdf46edbe0ed1c364430f5aee8a Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:15:06 +0800 Subject: [PATCH 19/51] feat: refactoring assetTxs --- src/api/assets/helpers.ts | 47 +++++---------------------------------- src/api/assets/index.ts | 17 ++++---------- src/api/assets/type.ts | 33 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 54 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index ff52624..0fac93b 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -25,6 +25,7 @@ import { AssetAccountsQueryParams, AssetAddressesQueryParams, AssetTxsOrderEnum, + AssetTxsQueryParams, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, PolicyTxsOrderEnum, @@ -154,19 +155,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of transactions in which a transaction input or output contains some of the specified asset * @summary Native asset transactions * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {AssetTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetTxsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ assetTxs: async ( asset: string, - fromHeight?: number | null, - count?: number | null, - order?: AssetTxsOrderEnum, - cursor?: string | null, + localVarQueryParameter: AssetTxsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'asset' is not null or undefined @@ -178,27 +173,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (fromHeight !== undefined) { - localVarQueryParameter.from_height = fromHeight; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -694,29 +672,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of transactions in which a transaction input or output contains some of the specified asset * @summary Native asset transactions * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {AssetTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetTxsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async assetTxs( asset: string, - fromHeight?: number | null, - count?: number | null, - order?: AssetTxsOrderEnum, - cursor?: string | null, + queryParams?: AssetTxsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.assetTxs( - asset, - fromHeight, - count, - order, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.assetTxs(asset, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index e212136..ba0bb8d 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -5,6 +5,7 @@ import { AssetAccountsQueryParams, AssetAddressesQueryParams, AssetTxsOrderEnum, + AssetTxsQueryParams, AssetUpdatesOrderEnum, AssetUtxosOrderEnum, PolicyTxsOrderEnum, @@ -66,24 +67,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of transactions in which a transaction input or output contains some of the specified asset * @summary Native asset transactions * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {AssetTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetTxsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public assetTxs( - asset: string, - fromHeight?: number | null, - count?: number | null, - order?: AssetTxsOrderEnum, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public assetTxs(asset: string, queryParams?: AssetTxsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .assetTxs(asset, fromHeight, count, order, cursor, options) + .assetTxs(asset, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 967d003..43a217a 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -80,3 +80,36 @@ export interface AssetAddressesQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for assetTxs. + * @export + * @interface AssetAddressesQueryParams + * + */ +export interface AssetTxsQueryParams { + /** + * Return only transactions after supplied block height + * @type {number | null} + * @memberof AssetTxsQueryParams + */ + fromHeight?: number | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof AssetTxsQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by block height) + * @type {AssetTxsOrderEnum} + * @memberof AssetTxsQueryParams + */ + order?: AssetTxsOrderEnum; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AssetTxsQueryParams + */ + cursor?: string | null; +} From 7eac9f22d0674b78fde30ff392eeb43c5e289134 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:18:54 +0800 Subject: [PATCH 20/51] feat: refactoring assetUpdates --- src/api/addresses/helpers.ts | 5 ----- src/api/addresses/index.ts | 3 --- src/api/assets/helpers.ts | 40 ++++++------------------------------ src/api/assets/index.ts | 15 ++++---------- src/api/assets/type.ts | 29 +++++++++++++++++++++++++- 5 files changed, 38 insertions(+), 54 deletions(-) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 2d53070..9e5b672 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -19,16 +19,11 @@ import { PaginatedUtxoWithSlot, } from '../type'; import { - TxsByAddressOrderEnum, TxsByAddressQueryParams, - TxsByPaymentCredOrderEnum, TxsByPaymentCredQueryParams, - UtxoRefsAtAddressOrderEnum, UtxoRefsAtAddressQueryParams, - UtxosByAddressOrderEnum, UtxosByAddressQueryParams, UtxosByAddressesQueryParams, - UtxosByPaymentCredOrderEnum, UtxosByPaymentCredQueryParams, } from './type'; diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index 2ab3388..f5ddfa4 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -4,11 +4,8 @@ import { AddressesApiFp } from './helpers'; import { TxsByAddressQueryParams, TxsByPaymentCredQueryParams, - UtxoRefsAtAddressOrderEnum, - UtxosByAddressOrderEnum, UtxosByAddressQueryParams, UtxosByAddressesQueryParams, - UtxosByPaymentCredOrderEnum, UtxosByPaymentCredQueryParams, } from './type'; diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 0fac93b..c785e37 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -24,9 +24,8 @@ import { import { AssetAccountsQueryParams, AssetAddressesQueryParams, - AssetTxsOrderEnum, AssetTxsQueryParams, - AssetUpdatesOrderEnum, + AssetUpdatesQueryParams, AssetUtxosOrderEnum, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, @@ -194,17 +193,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of transactions in which some of the specified asset was minted or burned * @summary Native asset updates * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {AssetUpdatesOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUpdatesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ assetUpdates: async ( asset: string, - count?: number | null, - order?: AssetUpdatesOrderEnum, - cursor?: string | null, + localVarQueryParameter: AssetUpdatesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'asset' is not null or undefined @@ -216,23 +211,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -688,26 +670,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of transactions in which some of the specified asset was minted or burned * @summary Native asset updates * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {AssetUpdatesOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUpdatesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async assetUpdates( asset: string, - count?: number | null, - order?: AssetUpdatesOrderEnum, - cursor?: string | null, + queryParams?: AssetUpdatesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.assetUpdates( - asset, - count, - order, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.assetUpdates(asset, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index ba0bb8d..e9c8cd6 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -7,6 +7,7 @@ import { AssetTxsOrderEnum, AssetTxsQueryParams, AssetUpdatesOrderEnum, + AssetUpdatesQueryParams, AssetUtxosOrderEnum, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, @@ -82,22 +83,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of transactions in which some of the specified asset was minted or burned * @summary Native asset updates * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {number | null} [count] The max number of results per page - * @param {AssetUpdatesOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUpdatesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public assetUpdates( - asset: string, - count?: number | null, - order?: AssetUpdatesOrderEnum, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public assetUpdates(asset: string, queryParams?: AssetUpdatesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .assetUpdates(asset, count, order, cursor, options) + .assetUpdates(asset, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 43a217a..ab4dd60 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -84,7 +84,7 @@ export interface AssetAddressesQueryParams { /** * Query parameters for assetTxs. * @export - * @interface AssetAddressesQueryParams + * @interface AssetTxsQueryParams * */ export interface AssetTxsQueryParams { @@ -113,3 +113,30 @@ export interface AssetTxsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for assetUpdates. + * @export + * @interface AssetUpdatesQueryParams + * + */ +export interface AssetUpdatesQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof AssetUpdatesQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by block height) + * @type {AssetUpdatesOrderEnum} + * @memberof AssetUpdatesQueryParams + */ + order?: AssetUpdatesOrderEnum; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AssetUpdatesQueryParams + */ + cursor?: string | null; +} From 711764a9d28e34e998b56f16bc15e085d72b5161 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:23:54 +0800 Subject: [PATCH 21/51] feat: refactoring assetUtxos --- src/api/assets/helpers.ts | 66 ++++----------------------------------- src/api/assets/index.ts | 21 +++---------- src/api/assets/type.ts | 45 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 77 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index c785e37..8957f62 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -26,7 +26,7 @@ import { AssetAddressesQueryParams, AssetTxsQueryParams, AssetUpdatesQueryParams, - AssetUtxosOrderEnum, + AssetUtxosQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -232,23 +232,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO * @summary Native asset UTxOs * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {string | null} [address] Return only UTxOs controlled by a specific address (bech32 encoding) - * @param {number | null} [count] The max number of results per page - * @param {AssetUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUpdatesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ assetUtxos: async ( asset: string, - address?: string | null, - count?: number | null, - order?: AssetUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter: AssetUpdatesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'asset' is not null or undefined @@ -260,35 +250,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (address !== undefined) { - localVarQueryParameter.address = address; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -686,35 +651,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO * @summary Native asset UTxOs * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {string | null} [address] Return only UTxOs controlled by a specific address (bech32 encoding) - * @param {number | null} [count] The max number of results per page - * @param {AssetUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUpdatesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async assetUtxos( asset: string, - address?: string | null, - count?: number | null, - order?: AssetUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: AssetUtxosQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.assetUtxos( - asset, - address, - count, - order, - from, - to, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.assetUtxos(asset, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index e9c8cd6..8190db4 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -9,6 +9,7 @@ import { AssetUpdatesOrderEnum, AssetUpdatesQueryParams, AssetUtxosOrderEnum, + AssetUtxosQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -98,28 +99,14 @@ export class AssetsApi extends BaseAPI { * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO * @summary Native asset UTxOs * @param {string} asset Asset, encoded as concatenation of hex of policy ID and asset name - * @param {string | null} [address] Return only UTxOs controlled by a specific address (bech32 encoding) - * @param {number | null} [count] The max number of results per page - * @param {AssetUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {AssetUtxosQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public assetUtxos( - asset: string, - address?: string | null, - count?: number | null, - order?: AssetUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public assetUtxos(asset: string, queryParams?: AssetUtxosQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .assetUtxos(asset, address, count, order, from, to, cursor, options) + .assetUtxos(asset, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index ab4dd60..d93ad27 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -140,3 +140,48 @@ export interface AssetUpdatesQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for assetUtxos. + * @export + * @interface AssetUtxosQueryParams + * + */ +export interface AssetUtxosQueryParams { + /** + * Return only UTxOs controlled by a specific address (bech32 encoding) + * @type {string | null} + * @memberof AssetUtxosQueryParams + */ + address?: string | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof AssetUtxosQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by slot at which UTxO was produced) + * @type {AssetUtxosOrderEnum} + * @memberof AssetUtxosQueryParams + */ + order?: AssetUtxosOrderEnum; + /** + * Return only UTxOs created on or after a specific slot + * @type {number | null} + * @memberof AssetUtxosQueryParams + */ + from?: number | null; + /** + * Return only UTxOs created before a specific slot + * @type {number | null} + * @memberof AssetUtxosQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof AssetUtxosQueryParams + */ + cursor?: string | null; +} From 5790f5e6493d238c76bc76b6ba8631fd4c2b101e Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:30:26 +0800 Subject: [PATCH 22/51] feat: refactoring policyAccounts --- src/api/assets/helpers.ts | 24 ++++++------------------ src/api/assets/index.ts | 8 ++++---- src/api/assets/type.ts | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 8957f62..bf97083 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -27,6 +27,7 @@ import { AssetTxsQueryParams, AssetUpdatesQueryParams, AssetUtxosQueryParams, + PolicyAccountsQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -271,15 +272,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAccountsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ policyAccounts: async ( policy: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: PolicyAccountsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'policy' is not null or undefined @@ -294,19 +293,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -667,18 +657,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAccountsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async policyAccounts( policy: string, - count?: number | null, - cursor?: string | null, + queryParams?: PolicyAccountsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.policyAccounts(policy, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.policyAccounts(policy, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 8190db4..c4a35b0 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -10,6 +10,7 @@ import { AssetUpdatesQueryParams, AssetUtxosOrderEnum, AssetUtxosQueryParams, + PolicyAccountsQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -114,15 +115,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). * @summary Accounts of addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAccountsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public policyAccounts(policy: string, count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public policyAccounts(policy: string, queryParams?: PolicyAccountsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .policyAccounts(policy, count, cursor, options) + .policyAccounts(policy, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index d93ad27..7ff35a3 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -185,3 +185,24 @@ export interface AssetUtxosQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for policyAccounts. + * @export + * @interface PolicyAccountsQueryParams + * + */ +export interface PolicyAccountsQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof PolicyAccountsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PolicyAccountsQueryParams + */ + cursor?: string | null; +} From 11a7c67b15a6f131c0e9d8abbf276febd0984391 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:32:49 +0800 Subject: [PATCH 23/51] feat: refactoring policyAddresses --- src/api/assets/helpers.ts | 24 ++++++------------------ src/api/assets/index.ts | 13 ++++--------- src/api/assets/type.ts | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index bf97083..935473b 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -28,6 +28,7 @@ import { AssetUpdatesQueryParams, AssetUtxosQueryParams, PolicyAccountsQueryParams, + PolicyAddressesQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -314,15 +315,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of addresses which hold some of an asset of the specified policy ID * @summary Addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAddressesQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ policyAddresses: async ( policy: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: PolicyAddressesQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'policy' is not null or undefined @@ -337,19 +336,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -673,18 +663,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of addresses which hold some of an asset of the specified policy ID * @summary Addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async policyAddresses( policy: string, - count?: number | null, - cursor?: string | null, + queryParams?: PolicyAddressesQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.policyAddresses(policy, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.policyAddresses(policy, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index c4a35b0..1895aba 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -11,6 +11,7 @@ import { AssetUtxosOrderEnum, AssetUtxosQueryParams, PolicyAccountsQueryParams, + PolicyAddressesQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -130,20 +131,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of addresses which hold some of an asset of the specified policy ID * @summary Addresses holding assets of specific policy * @param {string} policy Hex encoded Policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyAddressesQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public policyAddresses( - policy: string, - count?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public policyAddresses(policy: string, queryParams?: PolicyAddressesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .policyAddresses(policy, count, cursor, options) + .policyAddresses(policy, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 7ff35a3..8dc81de 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -206,3 +206,24 @@ export interface PolicyAccountsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for policyAddresses. + * @export + * @interface PolicyAddressesQueryParams + * + */ +export interface PolicyAddressesQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof PolicyAddressesQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PolicyAddressesQueryParams + */ + cursor?: string | null; +} From c8faa880cc19857bb1dfbd63cfaf92a213432dcb Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:35:25 +0800 Subject: [PATCH 24/51] feat: refactoring policyInfo --- src/api/assets/helpers.ts | 24 ++++++------------------ src/api/assets/index.ts | 8 ++++---- src/api/assets/type.ts | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 935473b..cf3ddba 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -29,6 +29,7 @@ import { AssetUtxosQueryParams, PolicyAccountsQueryParams, PolicyAddressesQueryParams, + PolicyInfoQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -357,15 +358,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns information about assets of the specified minting policy ID * @summary Information on assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyInfoQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ policyInfo: async ( policy: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: PolicyInfoQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'policy' is not null or undefined @@ -377,19 +376,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -679,18 +669,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns information about assets of the specified minting policy ID * @summary Information on assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyInfoQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async policyInfo( policy: string, - count?: number | null, - cursor?: string | null, + queryParams?: PolicyInfoQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.policyInfo(policy, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.policyInfo(policy, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 1895aba..fd8cd17 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -12,6 +12,7 @@ import { AssetUtxosQueryParams, PolicyAccountsQueryParams, PolicyAddressesQueryParams, + PolicyInfoQueryParams, PolicyTxsOrderEnum, PolicyUtxosOrderEnum, } from './type'; @@ -146,15 +147,14 @@ export class AssetsApi extends BaseAPI { * Returns information about assets of the specified minting policy ID * @summary Information on assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyInfoQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public policyInfo(policy: string, count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public policyInfo(policy: string, queryParams?: PolicyInfoQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .policyInfo(policy, count, cursor, options) + .policyInfo(policy, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 8dc81de..924af47 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -227,3 +227,24 @@ export interface PolicyAddressesQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for policyInfo. + * @export + * @interface PolicyInfoQueryParams + * + */ +export interface PolicyInfoQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof PolicyInfoQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PolicyInfoQueryParams + */ + cursor?: string | null; +} From 6b254b967c6a192f6974c344f8d4812cf0cbc874 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:38:50 +0800 Subject: [PATCH 25/51] feat: refactoring policyTxs --- src/api/assets/helpers.ts | 47 +++++---------------------------------- src/api/assets/index.ts | 17 ++++---------- src/api/assets/type.ts | 33 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 54 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index cf3ddba..b00ad3d 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -31,6 +31,7 @@ import { PolicyAddressesQueryParams, PolicyInfoQueryParams, PolicyTxsOrderEnum, + PolicyTxsQueryParams, PolicyUtxosOrderEnum, } from './type'; @@ -397,19 +398,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID * @summary Transactions moving assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {PolicyTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyTxsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ policyTxs: async ( policy: string, - fromHeight?: number | null, - count?: number | null, - order?: PolicyTxsOrderEnum, - cursor?: string | null, + localVarQueryParameter: PolicyTxsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'policy' is not null or undefined @@ -424,27 +419,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (fromHeight !== undefined) { - localVarQueryParameter.from_height = fromHeight; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -685,29 +663,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID * @summary Transactions moving assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {PolicyTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyTxsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async policyTxs( policy: string, - fromHeight?: number | null, - count?: number | null, - order?: PolicyTxsOrderEnum, - cursor?: string | null, + queryParams?: PolicyTxsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.policyTxs( - policy, - fromHeight, - count, - order, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.policyTxs(policy, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index fd8cd17..45aef30 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -14,6 +14,7 @@ import { PolicyAddressesQueryParams, PolicyInfoQueryParams, PolicyTxsOrderEnum, + PolicyTxsQueryParams, PolicyUtxosOrderEnum, } from './type'; @@ -162,24 +163,14 @@ export class AssetsApi extends BaseAPI { * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID * @summary Transactions moving assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [fromHeight] Return only transactions after supplied block height - * @param {number | null} [count] The max number of results per page - * @param {PolicyTxsOrderEnum} [order] The order in which the results are sorted (by block height) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyTxsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public policyTxs( - policy: string, - fromHeight?: number | null, - count?: number | null, - order?: PolicyTxsOrderEnum, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public policyTxs(policy: string, queryParams?: PolicyTxsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .policyTxs(policy, fromHeight, count, order, cursor, options) + .policyTxs(policy, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 924af47..160e847 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -248,3 +248,36 @@ export interface PolicyInfoQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for policyTxs. + * @export + * @interface PolicyTxsQueryParams + * + */ +export interface PolicyTxsQueryParams { + /** + * Return only transactions after supplied block height + * @type {number | null} + * @memberof PolicyTxsQueryParams + */ + fromHeight?: number | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof PolicyTxsQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by block height) + * @type {AssetTxsOrderEnum} + * @memberof PolicyTxsQueryParams + */ + order?: AssetTxsOrderEnum; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PolicyTxsQueryParams + */ + cursor?: string | null; +} From 323e1dc7f3f6e28006c05bdf0f54e65227f5965c Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:42:20 +0800 Subject: [PATCH 26/51] feat: refactoring policyUtxos --- src/api/assets/helpers.ts | 58 ++++----------------------------------- src/api/assets/index.ts | 24 +++------------- src/api/assets/type.ts | 43 +++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 74 deletions(-) diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index b00ad3d..3fad126 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -30,9 +30,8 @@ import { PolicyAccountsQueryParams, PolicyAddressesQueryParams, PolicyInfoQueryParams, - PolicyTxsOrderEnum, PolicyTxsQueryParams, - PolicyUtxosOrderEnum, + PolicyUtxosQueryParams, } from './type'; /** @@ -440,21 +439,13 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts * @summary UTxOs containing assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {PolicyUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyUtxosQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ policyUtxos: async ( policy: string, - count?: number | null, - order?: PolicyUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + localVarQueryParameter: PolicyUtxosQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'policy' is not null or undefined @@ -469,31 +460,10 @@ export const AssetsApiAxiosParamCreator = function (configuration: Configuration const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (from !== undefined) { - localVarQueryParameter.from = from; - } - - if (to !== undefined) { - localVarQueryParameter.to = to; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -679,32 +649,16 @@ export const AssetsApiFp = function (configuration: Configuration) { * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts * @summary UTxOs containing assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {PolicyUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyUtxosQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async policyUtxos( policy: string, - count?: number | null, - order?: PolicyUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, + queryParams?: PolicyUtxosQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.policyUtxos( - policy, - count, - order, - from, - to, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.policyUtxos(policy, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, }; diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 45aef30..62cba1e 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -4,18 +4,14 @@ import { AssetsApiFp } from './helpers'; import { AssetAccountsQueryParams, AssetAddressesQueryParams, - AssetTxsOrderEnum, AssetTxsQueryParams, - AssetUpdatesOrderEnum, AssetUpdatesQueryParams, - AssetUtxosOrderEnum, AssetUtxosQueryParams, PolicyAccountsQueryParams, PolicyAddressesQueryParams, PolicyInfoQueryParams, - PolicyTxsOrderEnum, PolicyTxsQueryParams, - PolicyUtxosOrderEnum, + PolicyUtxosQueryParams, } from './type'; /** @@ -178,26 +174,14 @@ export class AssetsApi extends BaseAPI { * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts * @summary UTxOs containing assets of specific policy * @param {string} policy Hex encoded policy ID - * @param {number | null} [count] The max number of results per page - * @param {PolicyUtxosOrderEnum} [order] The order in which the results are sorted (by slot at which UTxO was produced) - * @param {number | null} [from] Return only UTxOs created on or after a specific slot - * @param {number | null} [to] Return only UTxOs created before a specific slot - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PolicyUtxosQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AssetsApi */ - public policyUtxos( - policy: string, - count?: number | null, - order?: PolicyUtxosOrderEnum, - from?: number | null, - to?: number | null, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public policyUtxos(policy: string, queryParams?: PolicyUtxosQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) - .policyUtxos(policy, count, order, from, to, cursor, options) + .policyUtxos(policy, queryParams, options) .then((request) => request(this.axios)); } } diff --git a/src/api/assets/type.ts b/src/api/assets/type.ts index 160e847..17ebccb 100644 --- a/src/api/assets/type.ts +++ b/src/api/assets/type.ts @@ -270,10 +270,10 @@ export interface PolicyTxsQueryParams { count?: number | null; /** * The order in which the results are sorted (by block height) - * @type {AssetTxsOrderEnum} + * @type {PolicyTxsOrderEnum} * @memberof PolicyTxsQueryParams */ - order?: AssetTxsOrderEnum; + order?: PolicyTxsOrderEnum; /** * Pagination cursor string, use the cursor included in a page of results to fetch the next page. * @type {string | null} @@ -281,3 +281,42 @@ export interface PolicyTxsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for policyUtxos. + * @export + * @interface PolicyUtxosQueryParams + * + */ +export interface PolicyUtxosQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof PolicyUtxosQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by slot at which UTxO was produced) + * @type {PolicyUtxosOrderEnum} + * @memberof PolicyUtxosQueryParams + */ + order?: PolicyUtxosOrderEnum; + /** + * Return only UTxOs created on or after a specific slot + * @type {number | null} + * @memberof PolicyUtxosQueryParams + */ + from?: number | null; + /** + * Return only UTxOs created before a specific slot + * @type {number | null} + * @memberof PolicyUtxosQueryParams + */ + to?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PolicyUtxosQueryParams + */ + cursor?: string | null; +} From c845eabaddf6805f48df83cc4f67dc77046a42d2 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:50:21 +0800 Subject: [PATCH 27/51] feat: refactoring listPools --- src/api/pools/helpers.ts | 275 +++++++++++++++++++-------------------- src/api/pools/index.ts | 9 +- src/api/pools/type.ts | 21 +++ 3 files changed, 156 insertions(+), 149 deletions(-) diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index 3e6d762..076daad 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -19,7 +19,7 @@ import { TimestampedPoolRelays, TimestampedPoolUpdates, } from '../type'; -import { PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; +import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; /** * PoolsApi - axios parameter creator @@ -30,14 +30,12 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) /** * Returns a list of currently registered stake pools * @summary List registered stake pools - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {ListPoolsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ listPools: async ( - count?: number | null, - cursor?: string | null, + localVarQueryParameter?: ListPoolsQueryParams, options: AxiosRequestConfig = {}, ): Promise => { const localVarPath = `/pools`; @@ -47,19 +45,10 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -418,17 +407,15 @@ export const PoolsApiFp = function (configuration: Configuration) { /** * Returns a list of currently registered stake pools * @summary List registered stake pools - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {ListPoolsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async listPools( - count?: number | null, - cursor?: string | null, + queryParams?: ListPoolsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.listPools(count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.listPools(queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** @@ -566,128 +553,128 @@ export const PoolsApiFp = function (configuration: Configuration) { }; }; -/** - * PoolsApi - factory interface - * @export - */ -export const PoolsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = PoolsApiFp(configuration); - return { - /** - * Returns a list of currently registered stake pools - * @summary List registered stake pools - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - listPools(count?: number | null, cursor?: string | null, options?: any): AxiosPromise { - return localVarFp.listPools(count, cursor, options).then((request) => request(axios, basePath)); - }, - /** - * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) - * @summary Stake pool blocks - * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolBlocksOrderEnum} [order] The order in which the results are sorted (by block absolute slot) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolBlocks( - poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolBlocksOrderEnum, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .poolBlocks(poolId, epochNo, count, order, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns a list of delegators of the specified pool - * @summary Stake pool delegators - * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolDelegators( - poolId: string, - count?: number | null, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .poolDelegators(poolId, count, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) - * @summary Stake pool history - * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolHistoryOrderEnum} [order] The order in which the results are sorted (by epoch number) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolHistory( - poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolHistoryOrderEnum, - cursor?: string | null, - options?: any, - ): AxiosPromise { - return localVarFp - .poolHistory(poolId, epochNo, count, order, cursor, options) - .then((request) => request(axios, basePath)); - }, - /** - * Returns current information about the specified pool - * @summary Stake pool information - * @param {string} poolId Pool ID in bech32 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolInfo(poolId: string, options?: any): AxiosPromise { - return localVarFp.poolInfo(poolId, options).then((request) => request(axios, basePath)); - }, - /** - * Returns the metadata declared on-chain by the specified stake pool - * @summary Stake pool metadata - * @param {string} poolId Pool ID in bech32 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolMetadata(poolId: string, options?: any): AxiosPromise { - return localVarFp.poolMetadata(poolId, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of relays declared on-chain by the specified stake pool - * @summary Stake pool relays - * @param {string} poolId Pool ID in bech32 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolRelays(poolId: string, options?: any): AxiosPromise { - return localVarFp.poolRelays(poolId, options).then((request) => request(axios, basePath)); - }, - /** - * Returns a list of updates relating to the specified pool - * @summary Stake pool updates - * @param {string} poolId Pool ID in bech32 format - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - poolUpdates(poolId: string, options?: any): AxiosPromise { - return localVarFp.poolUpdates(poolId, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * PoolsApi - factory interface +// * @export +// */ +// export const PoolsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = PoolsApiFp(configuration); +// return { +// /** +// * Returns a list of currently registered stake pools +// * @summary List registered stake pools +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// listPools(count?: number | null, cursor?: string | null, options?: any): AxiosPromise { +// return localVarFp.listPools(count, cursor, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) +// * @summary Stake pool blocks +// * @param {string} poolId Pool ID in bech32 format +// * @param {number | null} [epochNo] Epoch number to fetch results for +// * @param {number | null} [count] The max number of results per page +// * @param {PoolBlocksOrderEnum} [order] The order in which the results are sorted (by block absolute slot) +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolBlocks( +// poolId: string, +// epochNo?: number | null, +// count?: number | null, +// order?: PoolBlocksOrderEnum, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .poolBlocks(poolId, epochNo, count, order, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of delegators of the specified pool +// * @summary Stake pool delegators +// * @param {string} poolId Pool ID in bech32 format +// * @param {number | null} [count] The max number of results per page +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolDelegators( +// poolId: string, +// count?: number | null, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .poolDelegators(poolId, count, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) +// * @summary Stake pool history +// * @param {string} poolId Pool ID in bech32 format +// * @param {number | null} [epochNo] Epoch number to fetch results for +// * @param {number | null} [count] The max number of results per page +// * @param {PoolHistoryOrderEnum} [order] The order in which the results are sorted (by epoch number) +// * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolHistory( +// poolId: string, +// epochNo?: number | null, +// count?: number | null, +// order?: PoolHistoryOrderEnum, +// cursor?: string | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .poolHistory(poolId, epochNo, count, order, cursor, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Returns current information about the specified pool +// * @summary Stake pool information +// * @param {string} poolId Pool ID in bech32 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolInfo(poolId: string, options?: any): AxiosPromise { +// return localVarFp.poolInfo(poolId, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the metadata declared on-chain by the specified stake pool +// * @summary Stake pool metadata +// * @param {string} poolId Pool ID in bech32 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolMetadata(poolId: string, options?: any): AxiosPromise { +// return localVarFp.poolMetadata(poolId, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of relays declared on-chain by the specified stake pool +// * @summary Stake pool relays +// * @param {string} poolId Pool ID in bech32 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolRelays(poolId: string, options?: any): AxiosPromise { +// return localVarFp.poolRelays(poolId, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a list of updates relating to the specified pool +// * @summary Stake pool updates +// * @param {string} poolId Pool ID in bech32 format +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// poolUpdates(poolId: string, options?: any): AxiosPromise { +// return localVarFp.poolUpdates(poolId, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 3efd44d..4851781 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -1,7 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { PoolsApiFp } from './helpers'; -import { PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; +import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; /** * PoolsApi - object-oriented interface @@ -13,15 +13,14 @@ export class PoolsApi extends BaseAPI { /** * Returns a list of currently registered stake pools * @summary List registered stake pools - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {ListPoolsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PoolsApi */ - public listPools(count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public listPools(queryParams?: ListPoolsQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) - .listPools(count, cursor, options) + .listPools(queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/pools/type.ts b/src/api/pools/type.ts index c4ea012..ff5b7dc 100644 --- a/src/api/pools/type.ts +++ b/src/api/pools/type.ts @@ -14,3 +14,24 @@ export const PoolHistoryOrderEnum = { Desc: 'desc', } as const; export type PoolHistoryOrderEnum = (typeof PoolHistoryOrderEnum)[keyof typeof PoolHistoryOrderEnum]; + +/** + * Query parameters for listPools. + * @export + * @interface ListPoolsQueryParams + * + */ +export interface ListPoolsQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof ListPoolsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof ListPoolsQueryParams + */ + cursor?: string | null; +} From bc9abab845962fdc549408dbea08fda4a8bfe2ad Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:55:56 +0800 Subject: [PATCH 28/51] feat: refactoring poolBlocks --- src/api/pools/helpers.ts | 48 +++++----------------------------------- src/api/pools/index.ts | 18 ++++----------- src/api/pools/type.ts | 33 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 56 deletions(-) diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index 076daad..49fe119 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -19,7 +19,7 @@ import { TimestampedPoolRelays, TimestampedPoolUpdates, } from '../type'; -import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; +import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolBlocksQueryParams, PoolHistoryOrderEnum } from './type'; /** * PoolsApi - axios parameter creator @@ -66,19 +66,13 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) * @summary Stake pool blocks * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolBlocksOrderEnum} [order] The order in which the results are sorted (by block absolute slot) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolBlocksQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ poolBlocks: async ( poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolBlocksOrderEnum, - cursor?: string | null, + localVarQueryParameter: PoolBlocksQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'poolId' is not null or undefined @@ -93,27 +87,10 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (epochNo !== undefined) { - localVarQueryParameter.epoch_no = epochNo; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -422,29 +399,16 @@ export const PoolsApiFp = function (configuration: Configuration) { * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) * @summary Stake pool blocks * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolBlocksOrderEnum} [order] The order in which the results are sorted (by block absolute slot) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolBlocksQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async poolBlocks( poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolBlocksOrderEnum, - cursor?: string | null, + queryParams?: PoolBlocksQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.poolBlocks( - poolId, - epochNo, - count, - order, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.poolBlocks(poolId, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 4851781..c4a1b56 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -1,7 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { PoolsApiFp } from './helpers'; -import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolHistoryOrderEnum } from './type'; +import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolBlocksQueryParams, PoolHistoryOrderEnum } from './type'; /** * PoolsApi - object-oriented interface @@ -28,24 +28,14 @@ export class PoolsApi extends BaseAPI { * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) * @summary Stake pool blocks * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolBlocksOrderEnum} [order] The order in which the results are sorted (by block absolute slot) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolBlocksQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PoolsApi */ - public poolBlocks( - poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolBlocksOrderEnum, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public poolBlocks(poolId: string, queryParams?: PoolBlocksQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) - .poolBlocks(poolId, epochNo, count, order, cursor, options) + .poolBlocks(poolId, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/pools/type.ts b/src/api/pools/type.ts index ff5b7dc..8083f98 100644 --- a/src/api/pools/type.ts +++ b/src/api/pools/type.ts @@ -35,3 +35,36 @@ export interface ListPoolsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for poolBlocks. + * @export + * @interface PoolBlocksQueryParams + * + */ +export interface PoolBlocksQueryParams { + /** + * Epoch number to fetch results for + * @type {number | null} + * @memberof PoolBlocksQueryParams + */ + epochNo?: number | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof PoolBlocksQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by block absolute slot) + * @type {PoolBlocksOrderEnum} + * @memberof PoolBlocksQueryParams + */ + order?: PoolBlocksOrderEnum; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PoolBlocksQueryParams + */ + cursor?: string | null; +} From 5cd881ab8fda6b1c84524ab443ba75a3149e66e6 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sat, 7 Oct 2023 23:58:37 +0800 Subject: [PATCH 29/51] feat: refactoring poolDelegators --- src/api/pools/helpers.ts | 31 ++++++++++++------------------- src/api/pools/index.ts | 15 ++++++++++----- src/api/pools/type.ts | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index 49fe119..c8aee5d 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -19,7 +19,13 @@ import { TimestampedPoolRelays, TimestampedPoolUpdates, } from '../type'; -import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolBlocksQueryParams, PoolHistoryOrderEnum } from './type'; +import { + ListPoolsQueryParams, + PoolBlocksOrderEnum, + PoolBlocksQueryParams, + PoolDelegatorsQueryParams, + PoolHistoryOrderEnum, +} from './type'; /** * PoolsApi - axios parameter creator @@ -108,15 +114,13 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) * Returns a list of delegators of the specified pool * @summary Stake pool delegators * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolDelegatorsQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ poolDelegators: async ( poolId: string, - count?: number | null, - cursor?: string | null, + localVarQueryParameter: PoolDelegatorsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'poolId' is not null or undefined @@ -131,19 +135,10 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -415,18 +410,16 @@ export const PoolsApiFp = function (configuration: Configuration) { * Returns a list of delegators of the specified pool * @summary Stake pool delegators * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolDelegatorsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async poolDelegators( poolId: string, - count?: number | null, - cursor?: string | null, + queryParams?: PoolDelegatorsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.poolDelegators(poolId, count, cursor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.poolDelegators(poolId, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index c4a1b56..4fdb75c 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -1,7 +1,13 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { PoolsApiFp } from './helpers'; -import { ListPoolsQueryParams, PoolBlocksOrderEnum, PoolBlocksQueryParams, PoolHistoryOrderEnum } from './type'; +import { + ListPoolsQueryParams, + PoolBlocksOrderEnum, + PoolBlocksQueryParams, + PoolDelegatorsQueryParams, + PoolHistoryOrderEnum, +} from './type'; /** * PoolsApi - object-oriented interface @@ -43,15 +49,14 @@ export class PoolsApi extends BaseAPI { * Returns a list of delegators of the specified pool * @summary Stake pool delegators * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [count] The max number of results per page - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolDelegatorsQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PoolsApi */ - public poolDelegators(poolId: string, count?: number | null, cursor?: string | null, options?: AxiosRequestConfig) { + public poolDelegators(poolId: string, queryParams?: PoolDelegatorsQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) - .poolDelegators(poolId, count, cursor, options) + .poolDelegators(poolId, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/pools/type.ts b/src/api/pools/type.ts index 8083f98..193c70d 100644 --- a/src/api/pools/type.ts +++ b/src/api/pools/type.ts @@ -68,3 +68,24 @@ export interface PoolBlocksQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for poolDelegators. + * @export + * @interface PoolDelegatorsQueryParams + * + */ +export interface PoolDelegatorsQueryParams { + /** + * The max number of results per page. + * @type {number | null} + * @memberof PoolDelegatorsQueryParams + */ + count?: number | null; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PoolDelegatorsQueryParams + */ + cursor?: string | null; +} From 089a7a955be640655275e9465c69a9f202261863 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:00:54 +0800 Subject: [PATCH 30/51] feat: refactoring poolHistory --- src/api/pools/helpers.ts | 47 +++++----------------------------------- src/api/pools/index.ts | 17 ++++----------- src/api/pools/type.ts | 33 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 54 deletions(-) diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index c8aee5d..f9c698b 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -25,6 +25,7 @@ import { PoolBlocksQueryParams, PoolDelegatorsQueryParams, PoolHistoryOrderEnum, + PoolHistoryQueryParams, } from './type'; /** @@ -156,19 +157,13 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) * @summary Stake pool history * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolHistoryOrderEnum} [order] The order in which the results are sorted (by epoch number) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolHistoryQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ poolHistory: async ( poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolHistoryOrderEnum, - cursor?: string | null, + localVarQueryParameter: PoolHistoryQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'poolId' is not null or undefined @@ -183,27 +178,10 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (epochNo !== undefined) { - localVarQueryParameter.epoch_no = epochNo; - } - - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (order !== undefined) { - localVarQueryParameter.order = order; - } - - if (cursor !== undefined) { - localVarQueryParameter.cursor = cursor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -426,29 +404,16 @@ export const PoolsApiFp = function (configuration: Configuration) { * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) * @summary Stake pool history * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolHistoryOrderEnum} [order] The order in which the results are sorted (by epoch number) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async poolHistory( poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolHistoryOrderEnum, - cursor?: string | null, + queryParams?: PoolHistoryQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.poolHistory( - poolId, - epochNo, - count, - order, - cursor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.poolHistory(poolId, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 4fdb75c..1cdc9a3 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -7,6 +7,7 @@ import { PoolBlocksQueryParams, PoolDelegatorsQueryParams, PoolHistoryOrderEnum, + PoolHistoryQueryParams, } from './type'; /** @@ -64,24 +65,14 @@ export class PoolsApi extends BaseAPI { * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) * @summary Stake pool history * @param {string} poolId Pool ID in bech32 format - * @param {number | null} [epochNo] Epoch number to fetch results for - * @param {number | null} [count] The max number of results per page - * @param {PoolHistoryOrderEnum} [order] The order in which the results are sorted (by epoch number) - * @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page + * @param {PoolHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PoolsApi */ - public poolHistory( - poolId: string, - epochNo?: number | null, - count?: number | null, - order?: PoolHistoryOrderEnum, - cursor?: string | null, - options?: AxiosRequestConfig, - ) { + public poolHistory(poolId: string, queryParams?: PoolHistoryQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) - .poolHistory(poolId, epochNo, count, order, cursor, options) + .poolHistory(poolId, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/pools/type.ts b/src/api/pools/type.ts index 193c70d..007175b 100644 --- a/src/api/pools/type.ts +++ b/src/api/pools/type.ts @@ -89,3 +89,36 @@ export interface PoolDelegatorsQueryParams { */ cursor?: string | null; } + +/** + * Query parameters for poolHistory. + * @export + * @interface PoolHistoryQueryParams + * + */ +export interface PoolHistoryQueryParams { + /** + * Epoch number to fetch results for + * @type {number | null} + * @memberof PoolHistoryQueryParams + */ + epochNo?: number | null; + /** + * The max number of results per page. + * @type {number | null} + * @memberof PoolHistoryQueryParams + */ + count?: number | null; + /** + * The order in which the results are sorted (by block absolute slot) + * @type {PoolHistoryOrderEnum} + * @memberof PoolHistoryQueryParams + */ + order?: PoolHistoryOrderEnum; + /** + * Pagination cursor string, use the cursor included in a page of results to fetch the next page. + * @type {string | null} + * @memberof PoolHistoryQueryParams + */ + cursor?: string | null; +} From 12b8fb74eee5979156e163e38dc1857ea8f83092 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:11:07 +0800 Subject: [PATCH 31/51] feat: refactoring txManagerHistory --- src/api/pools/helpers.ts | 9 +- src/api/transactionManager/helpers.ts | 132 ++++++++++++-------------- src/api/transactionManager/index.ts | 8 +- src/api/transactionManager/type.ts | 22 +++++ 4 files changed, 87 insertions(+), 84 deletions(-) create mode 100644 src/api/transactionManager/type.ts diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index f9c698b..5f239af 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -19,14 +19,7 @@ import { TimestampedPoolRelays, TimestampedPoolUpdates, } from '../type'; -import { - ListPoolsQueryParams, - PoolBlocksOrderEnum, - PoolBlocksQueryParams, - PoolDelegatorsQueryParams, - PoolHistoryOrderEnum, - PoolHistoryQueryParams, -} from './type'; +import { ListPoolsQueryParams, PoolBlocksQueryParams, PoolDelegatorsQueryParams, PoolHistoryQueryParams } from './type'; /** * PoolsApi - axios parameter creator diff --git a/src/api/transactionManager/helpers.ts b/src/api/transactionManager/helpers.ts index 7fde6b6..f7bb4e3 100644 --- a/src/api/transactionManager/helpers.ts +++ b/src/api/transactionManager/helpers.ts @@ -11,6 +11,7 @@ import { } from '../../common'; import { Configuration } from '../../configuration'; import { TxManagerState } from '../type'; +import { TxManagerHistoryQueryParams } from './type'; /** * TransactionManagerApi - axios parameter creator @@ -21,14 +22,12 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C /** * Returns the history of submitted transactions * @summary Transactions history - * @param {number} [count] The max number of results per pagination page - * @param {number} [page] Pagination page number to show results for + * @param {TxManagerHistoryQueryParams} [localVarQueryParameter] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ txManagerHistory: async ( - count?: number, - page?: number, + localVarQueryParameter: TxManagerHistoryQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { const localVarPath = `/txmanager/history`; @@ -38,19 +37,10 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (count !== undefined) { - localVarQueryParameter.count = count; - } - - if (page !== undefined) { - localVarQueryParameter.page = page; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -191,17 +181,15 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { /** * Returns the history of submitted transactions * @summary Transactions history - * @param {number} [count] The max number of results per pagination page - * @param {number} [page] Pagination page number to show results for + * @param {TxManagerHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txManagerHistory( - count?: number, - page?: number, + queryParams?: TxManagerHistoryQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerHistory(count, page, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerHistory(queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** @@ -249,57 +237,57 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { }; }; -/** - * TransactionManagerApi - factory interface - * @export - */ -export const TransactionManagerApiFactory = function ( - configuration: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = TransactionManagerApiFp(configuration); - return { - /** - * Returns the history of submitted transactions - * @summary Transactions history - * @param {number} [count] The max number of results per pagination page - * @param {number} [page] Pagination page number to show results for - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txManagerHistory(count?: number, page?: number, options?: any): AxiosPromise> { - return localVarFp.txManagerHistory(count, page, options).then((request) => request(axios, basePath)); - }, - /** - * Returns the most recent state of a transaction - * @summary Transaction state - * @param {string} txHash Hex encoded transaction hash - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txManagerState(txHash: string, options?: any): AxiosPromise { - return localVarFp.txManagerState(txHash, options).then((request) => request(axios, basePath)); - }, - /** - * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). - * @summary Submit transaction - * @param {string} body CBOR encoded transaction - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txManagerSubmit(body: string, options?: any): AxiosPromise { - return localVarFp.txManagerSubmit(body, options).then((request) => request(axios, basePath)); - }, - /** - * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). - * @summary Turbo submit transaction - * @param {string} body CBOR encoded transaction - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txManagerTurboSubmit(body: string, options?: any): AxiosPromise { - return localVarFp.txManagerTurboSubmit(body, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * TransactionManagerApi - factory interface +// * @export +// */ +// export const TransactionManagerApiFactory = function ( +// configuration: Configuration, +// basePath?: string, +// axios?: AxiosInstance, +// ) { +// const localVarFp = TransactionManagerApiFp(configuration); +// return { +// /** +// * Returns the history of submitted transactions +// * @summary Transactions history +// * @param {number} [count] The max number of results per pagination page +// * @param {number} [page] Pagination page number to show results for +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txManagerHistory(count?: number, page?: number, options?: any): AxiosPromise> { +// return localVarFp.txManagerHistory(count, page, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the most recent state of a transaction +// * @summary Transaction state +// * @param {string} txHash Hex encoded transaction hash +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txManagerState(txHash: string, options?: any): AxiosPromise { +// return localVarFp.txManagerState(txHash, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). +// * @summary Submit transaction +// * @param {string} body CBOR encoded transaction +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txManagerSubmit(body: string, options?: any): AxiosPromise { +// return localVarFp.txManagerSubmit(body, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). +// * @summary Turbo submit transaction +// * @param {string} body CBOR encoded transaction +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txManagerTurboSubmit(body: string, options?: any): AxiosPromise { +// return localVarFp.txManagerTurboSubmit(body, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/transactionManager/index.ts b/src/api/transactionManager/index.ts index bb7c17a..5e30c88 100644 --- a/src/api/transactionManager/index.ts +++ b/src/api/transactionManager/index.ts @@ -1,6 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { TransactionManagerApiFp } from './helpers'; +import { TxManagerHistoryQueryParams } from './type'; /** * TransactionManagerApi - object-oriented interface @@ -12,15 +13,14 @@ export class TransactionManagerApi extends BaseAPI { /** * Returns the history of submitted transactions * @summary Transactions history - * @param {number} [count] The max number of results per pagination page - * @param {number} [page] Pagination page number to show results for + * @param {TxManagerHistoryQueryParams} [queryParams] Query parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransactionManagerApi */ - public txManagerHistory(count?: number, page?: number, options?: AxiosRequestConfig) { + public txManagerHistory(queryParams?: TxManagerHistoryQueryParams, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) - .txManagerHistory(count, page, options) + .txManagerHistory(queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/transactionManager/type.ts b/src/api/transactionManager/type.ts new file mode 100644 index 0000000..7e5d175 --- /dev/null +++ b/src/api/transactionManager/type.ts @@ -0,0 +1,22 @@ +/** + * Query parameters for txManagerHistory. + * @export + * @interface TxManagerHistoryQueryParams + * + */ +export interface TxManagerHistoryQueryParams { + // * @param {number} [count] + // * @param {number} [page] + /** + * The max number of results per pagination page + * @type {number | null} + * @memberof TxManagerHistoryQueryParams + */ + count?: number | null; + /** + * Pagination page number to show results for + * @type {string | null} + * @memberof TxManagerHistoryQueryParams + */ + page?: string | null; +} From ecf58cafef4717b4ec68304cb36af704030e3569 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:14:31 +0800 Subject: [PATCH 32/51] feat: adding tx submission standard on turbo submit with docs added --- src/api/pools/index.ts | 9 +-------- src/api/transactionManager/helpers.ts | 19 ++++++++++--------- src/api/transactionManager/index.ts | 6 +++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 1cdc9a3..ae0eff5 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -1,14 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { PoolsApiFp } from './helpers'; -import { - ListPoolsQueryParams, - PoolBlocksOrderEnum, - PoolBlocksQueryParams, - PoolDelegatorsQueryParams, - PoolHistoryOrderEnum, - PoolHistoryQueryParams, -} from './type'; +import { ListPoolsQueryParams, PoolBlocksQueryParams, PoolDelegatorsQueryParams, PoolHistoryQueryParams } from './type'; /** * PoolsApi - object-oriented interface diff --git a/src/api/transactionManager/helpers.ts b/src/api/transactionManager/helpers.ts index f7bb4e3..b0b77a0 100644 --- a/src/api/transactionManager/helpers.ts +++ b/src/api/transactionManager/helpers.ts @@ -95,7 +95,7 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). * @summary Submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -123,7 +123,6 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C ...headersFromBaseOptions, ...options.headers, }; - // localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration); localVarRequestOptions.data = typeof body === 'string' ? Buffer.from(body, 'hex') : Buffer.from(body); return { url: toPathString(localVarUrlObj), @@ -133,11 +132,14 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). * @summary Turbo submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} */ - txManagerTurboSubmit: async (body: string, options: AxiosRequestConfig = {}): Promise => { + txManagerTurboSubmit: async ( + body: string | Uint8Array, + options: AxiosRequestConfig = {}, + ): Promise => { // verify required parameter 'body' is not null or undefined assertParamExists('txManagerTurboSubmit', 'body', body); const localVarPath = `/txmanager/turbosubmit`; @@ -161,8 +163,7 @@ export const TransactionManagerApiAxiosParamCreator = function (configuration: C ...headersFromBaseOptions, ...options.headers, }; - localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration); - + localVarRequestOptions.data = typeof body === 'string' ? Buffer.from(body, 'hex') : Buffer.from(body); return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, @@ -209,7 +210,7 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). * @summary Submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -223,12 +224,12 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). * @summary Turbo submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txManagerTurboSubmit( - body: string, + body: string | Uint8Array, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerTurboSubmit(body, options); diff --git a/src/api/transactionManager/index.ts b/src/api/transactionManager/index.ts index 5e30c88..90bee8f 100644 --- a/src/api/transactionManager/index.ts +++ b/src/api/transactionManager/index.ts @@ -41,7 +41,7 @@ export class TransactionManagerApi extends BaseAPI { /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). * @summary Submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransactionManagerApi @@ -55,12 +55,12 @@ export class TransactionManagerApi extends BaseAPI { /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). * @summary Turbo submit transaction - * @param {string} body CBOR encoded transaction + * @param {string | Uint8Array} body CBOR encoded transaction * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransactionManagerApi */ - public txManagerTurboSubmit(body: string, options?: AxiosRequestConfig) { + public txManagerTurboSubmit(body: string | Uint8Array, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) .txManagerTurboSubmit(body, options) .then((request) => request(this.axios)); From 8adac3a4fb2701dceae4702b7f10981f946a3e4d Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:19:37 +0800 Subject: [PATCH 33/51] feat: refactoring txoByTxoRef --- src/api/transactionManager/helpers.ts | 1 - src/api/transactions/helpers.ts | 176 +++++++++++++------------- src/api/transactions/index.ts | 12 +- src/api/transactions/type.ts | 15 +++ 4 files changed, 110 insertions(+), 94 deletions(-) create mode 100644 src/api/transactions/type.ts diff --git a/src/api/transactionManager/helpers.ts b/src/api/transactionManager/helpers.ts index b0b77a0..2139108 100644 --- a/src/api/transactionManager/helpers.ts +++ b/src/api/transactionManager/helpers.ts @@ -6,7 +6,6 @@ import { setSearchParams, toPathString, assertParamExists, - serializeDataIfNeeded, createRequestFunction, } from '../../common'; import { Configuration } from '../../configuration'; diff --git a/src/api/transactions/helpers.ts b/src/api/transactions/helpers.ts index 4c0ac22..2008a4d 100644 --- a/src/api/transactions/helpers.ts +++ b/src/api/transactions/helpers.ts @@ -17,6 +17,7 @@ import { TimestampedUtxo, PaginatedUtxoWithBytes, } from '../type'; +import { TxoByTxoRefQueryParams } from './type'; /** * TransactionsApi - axios parameter creator @@ -145,14 +146,14 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu * @summary Transaction output by output reference * @param {string} txHash Transaction Hash * @param {number} index Output Index - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxoByTxoRefQueryParams} [localVarQueryParameter] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} */ txoByTxoRef: async ( txHash: string, index: number, - withCbor?: boolean | null, + localVarQueryParameter: TxoByTxoRefQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'txHash' is not null or undefined @@ -168,15 +169,10 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (withCbor !== undefined) { - localVarQueryParameter.with_cbor = withCbor; - } - setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -302,17 +298,17 @@ export const TransactionsApiFp = function (configuration: Configuration) { * @summary Transaction output by output reference * @param {string} txHash Transaction Hash * @param {number} index Output Index - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxoByTxoRefQueryParams} [queryParams] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txoByTxoRef( txHash: string, index: number, - withCbor?: boolean | null, + queryParams?: TxoByTxoRefQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.txoByTxoRef(txHash, index, withCbor, options); + const localVarAxiosArgs = await localVarAxiosParamCreator.txoByTxoRef(txHash, index, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, /** @@ -341,83 +337,83 @@ export const TransactionsApiFp = function (configuration: Configuration) { }; }; -/** - * TransactionsApi - factory interface - * @export - */ -export const TransactionsApiFactory = function ( - configuration: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = TransactionsApiFp(configuration); - return { - /** - * Returns the address which was specified in the given transaction output. Note that if the transaction is invalid this will only return a result for the collateral return output, should one be present in the transaction. If the transaction is valid it will not return a result for the collateral return output. - * @summary Address by transaction output reference - * @param {string} txHash Transaction Hash - * @param {number} index Output Index - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - addressByTxo(txHash: string, index: number, options?: any): AxiosPromise { - return localVarFp.addressByTxo(txHash, index, options).then((request) => request(axios, basePath)); - }, - /** - * Returns hex-encoded CBOR bytes of a transaction - * @summary CBOR bytes of a transaction - * @param {string} txHash Transaction Hash - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txCborByTxHash(txHash: string, options?: any): AxiosPromise { - return localVarFp.txCborByTxHash(txHash, options).then((request) => request(axios, basePath)); - }, - /** - * Returns detailed information about a transaction - * @summary Transaction details - * @param {string} txHash Transaction hash in hex - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txInfo(txHash: string, options?: any): AxiosPromise { - return localVarFp.txInfo(txHash, options).then((request) => request(axios, basePath)); - }, - /** - * Returns the specified transaction output. - * @summary Transaction output by output reference - * @param {string} txHash Transaction Hash - * @param {number} index Output Index - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txoByTxoRef( - txHash: string, - index: number, - withCbor?: boolean | null, - options?: any, - ): AxiosPromise { - return localVarFp.txoByTxoRef(txHash, index, withCbor, options).then((request) => request(axios, basePath)); - }, - /** - * Returns the specified transaction outputs - * @summary Transaction outputs by output references - * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - txosByTxoRefs( - requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, - options?: any, - ): AxiosPromise { - return localVarFp - .txosByTxoRefs(requestBody, resolveDatums, withCbor, options) - .then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * TransactionsApi - factory interface +// * @export +// */ +// export const TransactionsApiFactory = function ( +// configuration: Configuration, +// basePath?: string, +// axios?: AxiosInstance, +// ) { +// const localVarFp = TransactionsApiFp(configuration); +// return { +// /** +// * Returns the address which was specified in the given transaction output. Note that if the transaction is invalid this will only return a result for the collateral return output, should one be present in the transaction. If the transaction is valid it will not return a result for the collateral return output. +// * @summary Address by transaction output reference +// * @param {string} txHash Transaction Hash +// * @param {number} index Output Index +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// addressByTxo(txHash: string, index: number, options?: any): AxiosPromise { +// return localVarFp.addressByTxo(txHash, index, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns hex-encoded CBOR bytes of a transaction +// * @summary CBOR bytes of a transaction +// * @param {string} txHash Transaction Hash +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txCborByTxHash(txHash: string, options?: any): AxiosPromise { +// return localVarFp.txCborByTxHash(txHash, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns detailed information about a transaction +// * @summary Transaction details +// * @param {string} txHash Transaction hash in hex +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txInfo(txHash: string, options?: any): AxiosPromise { +// return localVarFp.txInfo(txHash, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the specified transaction output. +// * @summary Transaction output by output reference +// * @param {string} txHash Transaction Hash +// * @param {number} index Output Index +// * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txoByTxoRef( +// txHash: string, +// index: number, +// withCbor?: boolean | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp.txoByTxoRef(txHash, index, withCbor, options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the specified transaction outputs +// * @summary Transaction outputs by output references +// * @param {Array} requestBody +// * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes +// * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// txosByTxoRefs( +// requestBody: Array, +// resolveDatums?: boolean | null, +// withCbor?: boolean | null, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .txosByTxoRefs(requestBody, resolveDatums, withCbor, options) +// .then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/transactions/index.ts b/src/api/transactions/index.ts index 93b89e8..b62693c 100644 --- a/src/api/transactions/index.ts +++ b/src/api/transactions/index.ts @@ -1,6 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { BaseAPI } from '../../base'; import { TransactionsApiFp } from './helpers'; +import { TxoByTxoRefQueryParams } from './type'; /** * TransactionsApi - object-oriented interface @@ -57,14 +58,19 @@ export class TransactionsApi extends BaseAPI { * @summary Transaction output by output reference * @param {string} txHash Transaction Hash * @param {number} index Output Index - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxoByTxoRefQueryParams} [queryParams] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransactionsApi */ - public txoByTxoRef(txHash: string, index: number, withCbor?: boolean | null, options?: AxiosRequestConfig) { + public txoByTxoRef( + txHash: string, + index: number, + queryParams?: TxoByTxoRefQueryParams, + options?: AxiosRequestConfig, + ) { return TransactionsApiFp(this.configuration) - .txoByTxoRef(txHash, index, withCbor, options) + .txoByTxoRef(txHash, index, queryParams, options) .then((request) => request(this.axios)); } diff --git a/src/api/transactions/type.ts b/src/api/transactions/type.ts new file mode 100644 index 0000000..f29b89b --- /dev/null +++ b/src/api/transactions/type.ts @@ -0,0 +1,15 @@ +/** + * Query parameters for txoByTxoRef. + * @export + * @interface TxoByTxoRefQueryParams + * + */ +export interface TxoByTxoRefQueryParams { + // * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + /** + * Include the CBOR encoding of the transaction output in the response + * @type {boolean | null} + * @memberof TxoByTxoRefQueryParams + */ + withCbor?: boolean | null; +} From 5dc8d913f434294b8d42bcf8b5ce342fe9031e14 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:21:59 +0800 Subject: [PATCH 34/51] feat: refactoring txosByTxoRefs --- src/api/transactions/helpers.ts | 30 ++++++------------------------ src/api/transactions/index.ts | 8 +++----- src/api/transactions/type.ts | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/api/transactions/helpers.ts b/src/api/transactions/helpers.ts index 2008a4d..855dea3 100644 --- a/src/api/transactions/helpers.ts +++ b/src/api/transactions/helpers.ts @@ -17,7 +17,7 @@ import { TimestampedUtxo, PaginatedUtxoWithBytes, } from '../type'; -import { TxoByTxoRefQueryParams } from './type'; +import { TxoByTxoRefQueryParams, TxosByTxoRefsQueryParams } from './type'; /** * TransactionsApi - axios parameter creator @@ -190,15 +190,13 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu * Returns the specified transaction outputs * @summary Transaction outputs by output references * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxosByTxoRefsQueryParams} [localVarQueryParameter] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} */ txosByTxoRefs: async ( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, + localVarQueryParameter: TxosByTxoRefsQueryParams = {}, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'requestBody' is not null or undefined @@ -210,19 +208,10 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); - if (resolveDatums !== undefined) { - localVarQueryParameter.resolve_datums = resolveDatums; - } - - if (withCbor !== undefined) { - localVarQueryParameter.with_cbor = withCbor; - } - localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -315,23 +304,16 @@ export const TransactionsApiFp = function (configuration: Configuration) { * Returns the specified transaction outputs * @summary Transaction outputs by output references * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxosByTxoRefsQueryParams} [queryParams] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} */ async txosByTxoRefs( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, + queryParams?: TxosByTxoRefsQueryParams, options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.txosByTxoRefs( - requestBody, - resolveDatums, - withCbor, - options, - ); + const localVarAxiosArgs = await localVarAxiosParamCreator.txosByTxoRefs(requestBody, queryParams, options); return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); }, }; diff --git a/src/api/transactions/index.ts b/src/api/transactions/index.ts index b62693c..841efe5 100644 --- a/src/api/transactions/index.ts +++ b/src/api/transactions/index.ts @@ -78,20 +78,18 @@ export class TransactionsApi extends BaseAPI { * Returns the specified transaction outputs * @summary Transaction outputs by output references * @param {Array} requestBody - * @param {boolean | null} [resolveDatums] Try find and include the corresponding datums for datum hashes - * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response + * @param {TxosByTxoRefsQueryParams} [queryParams] Query Parameters * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransactionsApi */ public txosByTxoRefs( requestBody: Array, - resolveDatums?: boolean | null, - withCbor?: boolean | null, + queryParams?: TxoByTxoRefQueryParams, options?: AxiosRequestConfig, ) { return TransactionsApiFp(this.configuration) - .txosByTxoRefs(requestBody, resolveDatums, withCbor, options) + .txosByTxoRefs(requestBody, queryParams, options) .then((request) => request(this.axios)); } } diff --git a/src/api/transactions/type.ts b/src/api/transactions/type.ts index f29b89b..7088ead 100644 --- a/src/api/transactions/type.ts +++ b/src/api/transactions/type.ts @@ -5,7 +5,6 @@ * */ export interface TxoByTxoRefQueryParams { - // * @param {boolean | null} [withCbor] Include the CBOR encoding of the transaction output in the response /** * Include the CBOR encoding of the transaction output in the response * @type {boolean | null} @@ -13,3 +12,24 @@ export interface TxoByTxoRefQueryParams { */ withCbor?: boolean | null; } + +/** + * Query parameters for txosByTxoRefs. + * @export + * @interface TxosByTxoRefsQueryParams + * + */ +export interface TxosByTxoRefsQueryParams { + /** + * Try find and include the corresponding datums for datum hashes + * @type {boolean | null} + * @memberof TxosByTxoRefsQueryParams + */ + resolveDatums?: boolean | null; + /** + * Include the CBOR encoding of the transaction output in the response + * @type {boolean | null} + * @memberof TxosByTxoRefsQueryParams + */ + withCbor?: boolean | null; +} From 8b6ae46d1f9cc3a683b86dbcc6197d07592ff4ed Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 8 Oct 2023 00:26:55 +0800 Subject: [PATCH 35/51] feat: bump package version --- package.json | 2 +- src/api/blocks/helpers.ts | 38 ++++++------- src/api/datum/helpers.ts | 38 ++++++------- src/api/ecosystem/helpers.ts | 38 ++++++------- src/api/epochs/helpers.ts | 56 +++++++++---------- src/api/general/helpers.ts | 90 +++++++++++++++---------------- src/api/scripts/helpers.ts | 38 ++++++------- src/api/vesting/helpers.ts | 102 +++++++++++++++++------------------ 8 files changed, 201 insertions(+), 201 deletions(-) diff --git a/package.json b/package.json index a1ef111..1bc35fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.1.1", + "version": "1.2.0", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/api/blocks/helpers.ts b/src/api/blocks/helpers.ts index cc47d6d..2d88c2d 100644 --- a/src/api/blocks/helpers.ts +++ b/src/api/blocks/helpers.ts @@ -82,22 +82,22 @@ export const BlocksApiFp = function (configuration: Configuration) { }; }; -/** - * BlocksApi - factory interface - * @export - */ -export const BlocksApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = BlocksApiFp(configuration); - return { - /** - * Returns information about the specified block including more advanced technical properties - * @summary Block information - * @param {string} hashOrHeight Block height or hex encoded block hash - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - blockInfo(hashOrHeight: string, options?: any): AxiosPromise { - return localVarFp.blockInfo(hashOrHeight, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * BlocksApi - factory interface +// * @export +// */ +// export const BlocksApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = BlocksApiFp(configuration); +// return { +// /** +// * Returns information about the specified block including more advanced technical properties +// * @summary Block information +// * @param {string} hashOrHeight Block height or hex encoded block hash +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// blockInfo(hashOrHeight: string, options?: any): AxiosPromise { +// return localVarFp.blockInfo(hashOrHeight, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/datum/helpers.ts b/src/api/datum/helpers.ts index 4184d1b..4eb0026 100644 --- a/src/api/datum/helpers.ts +++ b/src/api/datum/helpers.ts @@ -82,22 +82,22 @@ export const DatumApiFp = function (configuration: Configuration) { }; }; -/** - * DatumApi - factory interface - * @export - */ -export const DatumApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = DatumApiFp(configuration); - return { - /** - * Returns the datum corresponding to the specified datum hash, if the datum has been seen on-chain - * @summary Datum by datum hash - * @param {string} datumHash Hex encoded datum hash - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - lookupDatum(datumHash: string, options?: any): AxiosPromise { - return localVarFp.lookupDatum(datumHash, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * DatumApi - factory interface +// * @export +// */ +// export const DatumApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = DatumApiFp(configuration); +// return { +// /** +// * Returns the datum corresponding to the specified datum hash, if the datum has been seen on-chain +// * @summary Datum by datum hash +// * @param {string} datumHash Hex encoded datum hash +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// lookupDatum(datumHash: string, options?: any): AxiosPromise { +// return localVarFp.lookupDatum(datumHash, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/ecosystem/helpers.ts b/src/api/ecosystem/helpers.ts index 92a9412..8a24d2d 100644 --- a/src/api/ecosystem/helpers.ts +++ b/src/api/ecosystem/helpers.ts @@ -82,22 +82,22 @@ export const EcosystemApiFp = function (configuration: Configuration) { }; }; -/** - * EcosystemApi - factory interface - * @export - */ -export const EcosystemApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = EcosystemApiFp(configuration); - return { - /** - * Returns the Cardano address corresponding to an ADA Handle - * @summary Resolve ADA Handle - * @param {string} handle Ada Handle to resolve - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - adahandleResolve(handle: string, options?: any): AxiosPromise { - return localVarFp.adahandleResolve(handle, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * EcosystemApi - factory interface +// * @export +// */ +// export const EcosystemApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = EcosystemApiFp(configuration); +// return { +// /** +// * Returns the Cardano address corresponding to an ADA Handle +// * @summary Resolve ADA Handle +// * @param {string} handle Ada Handle to resolve +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// adahandleResolve(handle: string, options?: any): AxiosPromise { +// return localVarFp.adahandleResolve(handle, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/epochs/helpers.ts b/src/api/epochs/helpers.ts index 9f41dfd..1eaedfa 100644 --- a/src/api/epochs/helpers.ts +++ b/src/api/epochs/helpers.ts @@ -126,31 +126,31 @@ export const EpochsApiFp = function (configuration: Configuration) { }; }; -/** - * EpochsApi - factory interface - * @export - */ -export const EpochsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = EpochsApiFp(configuration); - return { - /** - * Returns a summary of information about the current epoch - * @summary Current epoch details - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - currentEpoch(options?: any): AxiosPromise { - return localVarFp.currentEpoch(options).then((request) => request(axios, basePath)); - }, - /** - * Returns a summary of information about a specific epoch - * @summary Specific epoch details - * @param {number} epochNo Epoch number to return information about - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - epochInfo(epochNo: number, options?: any): AxiosPromise { - return localVarFp.epochInfo(epochNo, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * EpochsApi - factory interface +// * @export +// */ +// export const EpochsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = EpochsApiFp(configuration); +// return { +// /** +// * Returns a summary of information about the current epoch +// * @summary Current epoch details +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// currentEpoch(options?: any): AxiosPromise { +// return localVarFp.currentEpoch(options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns a summary of information about a specific epoch +// * @summary Specific epoch details +// * @param {number} epochNo Epoch number to return information about +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// epochInfo(epochNo: number, options?: any): AxiosPromise { +// return localVarFp.epochInfo(epochNo, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/general/helpers.ts b/src/api/general/helpers.ts index ed59009..8c2a11f 100644 --- a/src/api/general/helpers.ts +++ b/src/api/general/helpers.ts @@ -204,48 +204,48 @@ export const GeneralApiFp = function (configuration: Configuration) { }; }; -/** - * GeneralApi - factory interface - * @export - */ -export const GeneralApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = GeneralApiFp(configuration); - return { - /** - * Returns the identifier of the most recently processed block on the network - * @summary Chain tip - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - chainTip(options?: any): AxiosPromise { - return localVarFp.chainTip(options).then((request) => request(axios, basePath)); - }, - /** - * Returns the blockchain era history - * @summary Era history - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - eraHistory(options?: any): AxiosPromise { - return localVarFp.eraHistory(options).then((request) => request(axios, basePath)); - }, - /** - * Returns the current blockchain protocol parameters - * @summary Protocol parameters - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - protocolParams(options?: any): AxiosPromise { - return localVarFp.protocolParams(options).then((request) => request(axios, basePath)); - }, - /** - * Returns the blockchain system start time - * @summary Blockchain system start - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - systemStart(options?: any): AxiosPromise { - return localVarFp.systemStart(options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * GeneralApi - factory interface +// * @export +// */ +// export const GeneralApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = GeneralApiFp(configuration); +// return { +// /** +// * Returns the identifier of the most recently processed block on the network +// * @summary Chain tip +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// chainTip(options?: any): AxiosPromise { +// return localVarFp.chainTip(options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the blockchain era history +// * @summary Era history +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// eraHistory(options?: any): AxiosPromise { +// return localVarFp.eraHistory(options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the current blockchain protocol parameters +// * @summary Protocol parameters +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// protocolParams(options?: any): AxiosPromise { +// return localVarFp.protocolParams(options).then((request) => request(axios, basePath)); +// }, +// /** +// * Returns the blockchain system start time +// * @summary Blockchain system start +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// systemStart(options?: any): AxiosPromise { +// return localVarFp.systemStart(options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/scripts/helpers.ts b/src/api/scripts/helpers.ts index 27b91d1..fdbb069 100644 --- a/src/api/scripts/helpers.ts +++ b/src/api/scripts/helpers.ts @@ -82,22 +82,22 @@ export const ScriptsApiFp = function (configuration: Configuration) { }; }; -/** - * ScriptsApi - factory interface - * @export - */ -export const ScriptsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = ScriptsApiFp(configuration); - return { - /** - * Returns the script corresponding to the specified script hash, if the script has been seen on-chain - * @summary Script by script hash - * @param {string} scriptHash Hex encoded script hash - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - scriptByHash(scriptHash: string, options?: any): AxiosPromise { - return localVarFp.scriptByHash(scriptHash, options).then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * ScriptsApi - factory interface +// * @export +// */ +// export const ScriptsApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = ScriptsApiFp(configuration); +// return { +// /** +// * Returns the script corresponding to the specified script hash, if the script has been seen on-chain +// * @summary Script by script hash +// * @param {string} scriptHash Hex encoded script hash +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// scriptByHash(scriptHash: string, options?: any): AxiosPromise { +// return localVarFp.scriptByHash(scriptHash, options).then((request) => request(axios, basePath)); +// }, +// }; +// }; diff --git a/src/api/vesting/helpers.ts b/src/api/vesting/helpers.ts index b9f5b6c..ca7ec6f 100644 --- a/src/api/vesting/helpers.ts +++ b/src/api/vesting/helpers.ts @@ -213,54 +213,54 @@ export const VestingApiFp = function (configuration: Configuration) { }; }; -/** - * VestingApi - factory interface - * @export - */ -export const VestingApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = VestingApiFp(configuration); - return { - /** - * Collect assets from the vesting contract - * @summary Collect assets - * @param {string} beneficiary Beneficiary\'s bech32 address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - contractsVestingCollectBeneficiaryPost( - beneficiary: string, - options?: any, - ): AxiosPromise { - return localVarFp - .contractsVestingCollectBeneficiaryPost(beneficiary, options) - .then((request) => request(axios, basePath)); - }, - /** - * Lock assets into the vesting contract - * @summary Lock assets - * @param {ContractsVestingLockPostRequest} contractsVestingLockPostRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - contractsVestingLockPost( - contractsVestingLockPostRequest: ContractsVestingLockPostRequest, - options?: any, - ): AxiosPromise { - return localVarFp - .contractsVestingLockPost(contractsVestingLockPostRequest, options) - .then((request) => request(axios, basePath)); - }, - /** - * Detailed list of vesting assets at a beneficiary address - * @summary State of vesting assets - * @param {string} beneficiary Beneficiary bech32 address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - contractsVestingStateBeneficiaryGet(beneficiary: string, options?: any): AxiosPromise { - return localVarFp - .contractsVestingStateBeneficiaryGet(beneficiary, options) - .then((request) => request(axios, basePath)); - }, - }; -}; +// /** +// * VestingApi - factory interface +// * @export +// */ +// export const VestingApiFactory = function (configuration: Configuration, basePath?: string, axios?: AxiosInstance) { +// const localVarFp = VestingApiFp(configuration); +// return { +// /** +// * Collect assets from the vesting contract +// * @summary Collect assets +// * @param {string} beneficiary Beneficiary\'s bech32 address +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// contractsVestingCollectBeneficiaryPost( +// beneficiary: string, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .contractsVestingCollectBeneficiaryPost(beneficiary, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Lock assets into the vesting contract +// * @summary Lock assets +// * @param {ContractsVestingLockPostRequest} contractsVestingLockPostRequest +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// contractsVestingLockPost( +// contractsVestingLockPostRequest: ContractsVestingLockPostRequest, +// options?: any, +// ): AxiosPromise { +// return localVarFp +// .contractsVestingLockPost(contractsVestingLockPostRequest, options) +// .then((request) => request(axios, basePath)); +// }, +// /** +// * Detailed list of vesting assets at a beneficiary address +// * @summary State of vesting assets +// * @param {string} beneficiary Beneficiary bech32 address +// * @param {*} [options] Override http request option. +// * @throws {RequiredError} +// */ +// contractsVestingStateBeneficiaryGet(beneficiary: string, options?: any): AxiosPromise { +// return localVarFp +// .contractsVestingStateBeneficiaryGet(beneficiary, options) +// .then((request) => request(axios, basePath)); +// }, +// }; +// }; From b44688de1165fde7ed2143f9d8016dee5e5d9a89 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Wed, 11 Oct 2023 13:05:19 +0800 Subject: [PATCH 36/51] feat: bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1bc35fb..4539052 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.2.0", + "version": "2.0.0", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", From dad7fe1538298d3418a324dd8284b8629c40d306 Mon Sep 17 00:00:00 2001 From: Varderes Barsegyan Date: Sun, 29 Oct 2023 17:36:28 -0500 Subject: [PATCH 37/51] code of conduct --- CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..10b0bbc --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +support@gomaestro.org. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. From 5cc22d408fec2c728d798a20190e1f2705703e8c Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Wed, 1 Nov 2023 14:34:18 +0200 Subject: [PATCH 38/51] feat: moved axios instance into Configuration and using it as single source of truth --- src/api/accounts/helpers.ts | 14 +++++++------- src/api/accounts/index.ts | 12 ++++++------ src/api/addresses/helpers.ts | 18 +++++++++--------- src/api/addresses/index.ts | 16 ++++++++-------- src/api/assets/helpers.ts | 24 ++++++++++++------------ src/api/assets/index.ts | 22 +++++++++++----------- src/api/blocks/helpers.ts | 4 ++-- src/api/blocks/index.ts | 2 +- src/api/datum/helpers.ts | 4 ++-- src/api/datum/index.ts | 2 +- src/api/ecosystem/helpers.ts | 4 ++-- src/api/ecosystem/index.ts | 2 +- src/api/epochs/helpers.ts | 6 +++--- src/api/epochs/index.ts | 4 ++-- src/api/general/helpers.ts | 10 +++++----- src/api/general/index.ts | 8 ++++---- src/api/pools/helpers.ts | 18 +++++++++--------- src/api/pools/index.ts | 16 ++++++++-------- src/api/scripts/helpers.ts | 4 ++-- src/api/scripts/index.ts | 2 +- src/api/transactionManager/helpers.ts | 10 +++++----- src/api/transactionManager/index.ts | 8 ++++---- src/api/transactions/helpers.ts | 12 ++++++------ src/api/transactions/index.ts | 10 +++++----- src/api/vesting/helpers.ts | 12 ++++++------ src/api/vesting/index.ts | 6 +++--- src/base.ts | 2 +- src/common.ts | 12 ++++-------- src/configuration.ts | 20 +++++++++++++------- 29 files changed, 143 insertions(+), 141 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index f4eb9e1..e6f64bf 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -420,7 +420,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountAddresses(stakeAddr, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of native assets which are owned by addresses with the specified stake key @@ -436,7 +436,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountAssets(stakeAddr, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns per-epoch history for the specified stake key @@ -452,7 +452,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountHistory(stakeAddr, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns various information regarding a stake account @@ -466,7 +466,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountInfo(stakeAddr, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`) @@ -482,7 +482,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountRewards(stakeAddr, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`) @@ -498,7 +498,7 @@ export const AccountsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.accountUpdates(stakeAddr, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/accounts/index.ts b/src/api/accounts/index.ts index e49c65d..7165119 100644 --- a/src/api/accounts/index.ts +++ b/src/api/accounts/index.ts @@ -32,7 +32,7 @@ export class AccountsApi extends BaseAPI { ) { return AccountsApiFp(this.configuration) .accountAddresses(stakeAddr, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -47,7 +47,7 @@ export class AccountsApi extends BaseAPI { public accountAssets(stakeAddr: string, queryParams?: AccountAssetsQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) .accountAssets(stakeAddr, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -62,7 +62,7 @@ export class AccountsApi extends BaseAPI { public accountHistory(stakeAddr: string, queryParams?: AccountHistoryQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) .accountHistory(stakeAddr, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -76,7 +76,7 @@ export class AccountsApi extends BaseAPI { public accountInfo(stakeAddr: string, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) .accountInfo(stakeAddr, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -91,7 +91,7 @@ export class AccountsApi extends BaseAPI { public accountRewards(stakeAddr: string, queryParams?: AccountRewardsQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) .accountRewards(stakeAddr, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -106,7 +106,7 @@ export class AccountsApi extends BaseAPI { public accountUpdates(stakeAddr: string, queryParams?: AccountUpdatesQueryParams, options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration) .accountUpdates(stakeAddr, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 9e5b672..eb12859 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -383,7 +383,7 @@ export const AddressesApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.decodeAddress(address, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the number of transactions in which the address spent or received some funds. Specifically, the number of transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). @@ -397,7 +397,7 @@ export const AddressesApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txCountByAddress(address, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns transactions in which the specified address spent or received funds. Specifically, the transactions where: the address controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). @@ -413,7 +413,7 @@ export const AddressesApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txsByAddress(address, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was used in an address which controlled at least one of the transaction inputs and/or receives one of the outputs AND the transaction is phase-2 valid, OR, the address controlled at least one of the collateral inputs and/or receives the collateral return output AND the transaction is phase-2 invalid. [Read more](https://docs.cardano.org/plutus/collateral-mechanism/). @@ -433,7 +433,7 @@ export const AddressesApiFp = function (configuration: Configuration) { queryParams, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address @@ -449,7 +449,7 @@ export const AddressesApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.utxoRefsAtAddress(address, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Return detailed information on UTxOs controlled by an address @@ -465,7 +465,7 @@ export const AddressesApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByAddress(address, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Return detailed information on UTxOs which are controlled by some address in the specified list of addresses @@ -485,7 +485,7 @@ export const AddressesApiFp = function (configuration: Configuration) { queryParams, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Return detailed information on UTxOs controlled by addresses which use the specified payment credential @@ -505,7 +505,7 @@ export const AddressesApiFp = function (configuration: Configuration) { queryParams, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index 7a45fc6..8dc01e8 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -27,7 +27,7 @@ export class AddressesApi extends BaseAPI { public decodeAddress(address: string, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) .decodeAddress(address, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -41,7 +41,7 @@ export class AddressesApi extends BaseAPI { public txCountByAddress(address: string, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) .txCountByAddress(address, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -56,7 +56,7 @@ export class AddressesApi extends BaseAPI { public txsByAddress(address: string, queryParams?: TxsByAddressQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) .txsByAddress(address, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -75,7 +75,7 @@ export class AddressesApi extends BaseAPI { ) { return AddressesApiFp(this.configuration) .txsByPaymentCred(credential, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -90,7 +90,7 @@ export class AddressesApi extends BaseAPI { public utxoRefsAtAddress(address: string, queryParams?: TxsByPaymentCredQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) .utxoRefsAtAddress(address, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -105,7 +105,7 @@ export class AddressesApi extends BaseAPI { public utxosByAddress(address: string, queryParams?: UtxosByAddressQueryParams, options?: AxiosRequestConfig) { return AddressesApiFp(this.configuration) .utxosByAddress(address, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -124,7 +124,7 @@ export class AddressesApi extends BaseAPI { ) { return AddressesApiFp(this.configuration) .utxosByAddresses(requestBody, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -143,7 +143,7 @@ export class AddressesApi extends BaseAPI { ) { return AddressesApiFp(this.configuration) .utxosByPaymentCred(credential, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 3fad126..8fc29e4 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -501,7 +501,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetAccounts(asset, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of addresses which control some amount of the specified asset @@ -517,7 +517,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetAddresses(asset, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Return a summary of information about an asset @@ -531,7 +531,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetInfo(asset, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of transactions in which a transaction input or output contains some of the specified asset @@ -547,7 +547,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetTxs(asset, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of transactions in which some of the specified asset was minted or burned @@ -563,7 +563,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetUpdates(asset, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns references for UTxOs which contain some of the specified asset, each paired with the amount of the asset contained in the UTxO @@ -579,7 +579,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.assetUtxos(asset, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of accounts (as stake/reward addresses) associated with addresses which control some of an asset of the specified policy; in other words, instead of returning the addresses which hold the assets, the addresses are merged by their delegation part/account. Assets controlled by Byron, enterprise, or pointer addresses are omitted. CAUTION: An asset being associated with a particular stake account does not necessarily mean the owner of that account controls the asset; use \"asset addresses\" unless you are sure you want to work with stake keys. Read more [here]( https://medium.com/adamant-security/multi-sig-concerns-mangled-addresses-and-the-dangers-of-using-stake-keys-in-your-cardano-project-94894319b1d8). @@ -595,7 +595,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.policyAccounts(policy, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of addresses which hold some of an asset of the specified policy ID @@ -611,7 +611,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.policyAddresses(policy, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns information about assets of the specified minting policy ID @@ -627,7 +627,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.policyInfo(policy, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of transactions in which a transaction input or output contains some of at least one asset of the specified minting policy ID @@ -643,7 +643,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.policyTxs(policy, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns UTxO references of UTxOs which contain some of at least one asset of the specified policy ID, each paired with a list of assets of the policy contained in the UTxO and the corresponding amounts @@ -659,7 +659,7 @@ export const AssetsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.policyUtxos(policy, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/assets/index.ts b/src/api/assets/index.ts index 98e2881..e01da88 100644 --- a/src/api/assets/index.ts +++ b/src/api/assets/index.ts @@ -33,7 +33,7 @@ export class AssetsApi extends BaseAPI { public assetAccounts(asset: string, queryParams?: AssetAccountsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetAccounts(asset, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -48,7 +48,7 @@ export class AssetsApi extends BaseAPI { public assetAddresses(asset: string, queryParams?: AssetAddressesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetAddresses(asset, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -62,7 +62,7 @@ export class AssetsApi extends BaseAPI { public assetInfo(asset: string, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetInfo(asset, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -77,7 +77,7 @@ export class AssetsApi extends BaseAPI { public assetTxs(asset: string, queryParams?: AssetTxsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetTxs(asset, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -92,7 +92,7 @@ export class AssetsApi extends BaseAPI { public assetUpdates(asset: string, queryParams?: AssetUpdatesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetUpdates(asset, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -107,7 +107,7 @@ export class AssetsApi extends BaseAPI { public assetUtxos(asset: string, queryParams?: AssetUtxosQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .assetUtxos(asset, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -122,7 +122,7 @@ export class AssetsApi extends BaseAPI { public policyAccounts(policy: string, queryParams?: PolicyAccountsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .policyAccounts(policy, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -137,7 +137,7 @@ export class AssetsApi extends BaseAPI { public policyAddresses(policy: string, queryParams?: PolicyAddressesQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .policyAddresses(policy, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -152,7 +152,7 @@ export class AssetsApi extends BaseAPI { public policyInfo(policy: string, queryParams?: PolicyInfoQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .policyInfo(policy, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -167,7 +167,7 @@ export class AssetsApi extends BaseAPI { public policyTxs(policy: string, queryParams?: PolicyTxsQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .policyTxs(policy, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -182,7 +182,7 @@ export class AssetsApi extends BaseAPI { public policyUtxos(policy: string, queryParams?: PolicyUtxosQueryParams, options?: AxiosRequestConfig) { return AssetsApiFp(this.configuration) .policyUtxos(policy, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/blocks/helpers.ts b/src/api/blocks/helpers.ts index 2d88c2d..ff319ef 100644 --- a/src/api/blocks/helpers.ts +++ b/src/api/blocks/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -77,7 +77,7 @@ export const BlocksApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.blockInfo(hashOrHeight, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/blocks/index.ts b/src/api/blocks/index.ts index e8983b5..c2fa25d 100644 --- a/src/api/blocks/index.ts +++ b/src/api/blocks/index.ts @@ -20,6 +20,6 @@ export class BlocksApi extends BaseAPI { public blockInfo(hashOrHeight: string, options?: AxiosRequestConfig) { return BlocksApiFp(this.configuration) .blockInfo(hashOrHeight, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/datum/helpers.ts b/src/api/datum/helpers.ts index 4eb0026..47460d1 100644 --- a/src/api/datum/helpers.ts +++ b/src/api/datum/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -77,7 +77,7 @@ export const DatumApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.lookupDatum(datumHash, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/datum/index.ts b/src/api/datum/index.ts index bf91e51..f1a39ce 100644 --- a/src/api/datum/index.ts +++ b/src/api/datum/index.ts @@ -20,6 +20,6 @@ export class DatumApi extends BaseAPI { public lookupDatum(datumHash: string, options?: AxiosRequestConfig) { return DatumApiFp(this.configuration) .lookupDatum(datumHash, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/ecosystem/helpers.ts b/src/api/ecosystem/helpers.ts index 8a24d2d..a924ba7 100644 --- a/src/api/ecosystem/helpers.ts +++ b/src/api/ecosystem/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -77,7 +77,7 @@ export const EcosystemApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.adahandleResolve(handle, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/ecosystem/index.ts b/src/api/ecosystem/index.ts index c40a9b3..2850ea0 100644 --- a/src/api/ecosystem/index.ts +++ b/src/api/ecosystem/index.ts @@ -20,6 +20,6 @@ export class EcosystemApi extends BaseAPI { public adahandleResolve(handle: string, options?: AxiosRequestConfig) { return EcosystemApiFp(this.configuration) .adahandleResolve(handle, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/epochs/helpers.ts b/src/api/epochs/helpers.ts index 1eaedfa..d9755d9 100644 --- a/src/api/epochs/helpers.ts +++ b/src/api/epochs/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { DUMMY_BASE_URL, @@ -107,7 +107,7 @@ export const EpochsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.currentEpoch(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a summary of information about a specific epoch @@ -121,7 +121,7 @@ export const EpochsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.epochInfo(epochNo, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/epochs/index.ts b/src/api/epochs/index.ts index b11bb0e..8d04ebc 100644 --- a/src/api/epochs/index.ts +++ b/src/api/epochs/index.ts @@ -19,7 +19,7 @@ export class EpochsApi extends BaseAPI { public currentEpoch(options?: AxiosRequestConfig) { return EpochsApiFp(this.configuration) .currentEpoch(options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -33,6 +33,6 @@ export class EpochsApi extends BaseAPI { public epochInfo(epochNo: number, options?: AxiosRequestConfig) { return EpochsApiFp(this.configuration) .epochInfo(epochNo, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/general/helpers.ts b/src/api/general/helpers.ts index 8c2a11f..a0e14fc 100644 --- a/src/api/general/helpers.ts +++ b/src/api/general/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { DUMMY_BASE_URL, setApiKeyToObject, setSearchParams, toPathString, createRequestFunction } from '../../common'; import { Configuration } from '../../configuration'; @@ -163,7 +163,7 @@ export const GeneralApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.chainTip(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the blockchain era history @@ -175,7 +175,7 @@ export const GeneralApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.eraHistory(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the current blockchain protocol parameters @@ -187,7 +187,7 @@ export const GeneralApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.protocolParams(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the blockchain system start time @@ -199,7 +199,7 @@ export const GeneralApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.systemStart(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/general/index.ts b/src/api/general/index.ts index a47f58f..3d83587 100644 --- a/src/api/general/index.ts +++ b/src/api/general/index.ts @@ -19,7 +19,7 @@ export class GeneralApi extends BaseAPI { public chainTip(options?: AxiosRequestConfig) { return GeneralApiFp(this.configuration) .chainTip(options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -32,7 +32,7 @@ export class GeneralApi extends BaseAPI { public eraHistory(options?: AxiosRequestConfig) { return GeneralApiFp(this.configuration) .eraHistory(options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -45,7 +45,7 @@ export class GeneralApi extends BaseAPI { public protocolParams(options?: AxiosRequestConfig) { return GeneralApiFp(this.configuration) .protocolParams(options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -58,6 +58,6 @@ export class GeneralApi extends BaseAPI { public systemStart(options?: AxiosRequestConfig) { return GeneralApiFp(this.configuration) .systemStart(options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index 5f239af..abffe80 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { DUMMY_BASE_URL, @@ -359,7 +359,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.listPools(queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Return information about blocks minted by a given pool for all epochs (or just for epoch `epoch_no` if provided) @@ -375,7 +375,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolBlocks(poolId, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of delegators of the specified pool @@ -391,7 +391,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolDelegators(poolId, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns per-epoch information about the specified pool (or just for epoch `epoch_no` if provided) @@ -407,7 +407,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolHistory(poolId, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns current information about the specified pool @@ -421,7 +421,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolInfo(poolId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the metadata declared on-chain by the specified stake pool @@ -435,7 +435,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolMetadata(poolId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of relays declared on-chain by the specified stake pool @@ -449,7 +449,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolRelays(poolId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns a list of updates relating to the specified pool @@ -463,7 +463,7 @@ export const PoolsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.poolUpdates(poolId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/pools/index.ts b/src/api/pools/index.ts index 39303b0..096cd8b 100644 --- a/src/api/pools/index.ts +++ b/src/api/pools/index.ts @@ -21,7 +21,7 @@ export class PoolsApi extends BaseAPI { public listPools(queryParams?: ListPoolsQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .listPools(queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -36,7 +36,7 @@ export class PoolsApi extends BaseAPI { public poolBlocks(poolId: string, queryParams?: PoolBlocksQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolBlocks(poolId, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -51,7 +51,7 @@ export class PoolsApi extends BaseAPI { public poolDelegators(poolId: string, queryParams?: PoolDelegatorsQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolDelegators(poolId, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -66,7 +66,7 @@ export class PoolsApi extends BaseAPI { public poolHistory(poolId: string, queryParams?: PoolHistoryQueryParams, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolHistory(poolId, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -80,7 +80,7 @@ export class PoolsApi extends BaseAPI { public poolInfo(poolId: string, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolInfo(poolId, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -94,7 +94,7 @@ export class PoolsApi extends BaseAPI { public poolMetadata(poolId: string, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolMetadata(poolId, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -108,7 +108,7 @@ export class PoolsApi extends BaseAPI { public poolRelays(poolId: string, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolRelays(poolId, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -122,7 +122,7 @@ export class PoolsApi extends BaseAPI { public poolUpdates(poolId: string, options?: AxiosRequestConfig) { return PoolsApiFp(this.configuration) .poolUpdates(poolId, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/scripts/helpers.ts b/src/api/scripts/helpers.ts index fdbb069..fa6bc91 100644 --- a/src/api/scripts/helpers.ts +++ b/src/api/scripts/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -77,7 +77,7 @@ export const ScriptsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.scriptByHash(scriptHash, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/scripts/index.ts b/src/api/scripts/index.ts index c23e0c6..1604e96 100644 --- a/src/api/scripts/index.ts +++ b/src/api/scripts/index.ts @@ -20,6 +20,6 @@ export class ScriptsApi extends BaseAPI { public scriptByHash(scriptHash: string, options?: AxiosRequestConfig) { return ScriptsApiFp(this.configuration) .scriptByHash(scriptHash, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/transactionManager/helpers.ts b/src/api/transactionManager/helpers.ts index 2139108..4fcd830 100644 --- a/src/api/transactionManager/helpers.ts +++ b/src/api/transactionManager/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { DUMMY_BASE_URL, @@ -190,7 +190,7 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerHistory(queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the most recent state of a transaction @@ -204,7 +204,7 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerState(txHash, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [monitored by Maestro](../Dapp%20Platform/Transaction%20Manager). @@ -218,7 +218,7 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerSubmit(body, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Submit a signed and serialized transaction to the network. A transaction submited with this endpoint will be [Turbo Submitted and Monitored by Maestro](../Dapp%20Platform/Turbo%20Transaction). @@ -232,7 +232,7 @@ export const TransactionManagerApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txManagerTurboSubmit(body, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/transactionManager/index.ts b/src/api/transactionManager/index.ts index 90bee8f..e3be02f 100644 --- a/src/api/transactionManager/index.ts +++ b/src/api/transactionManager/index.ts @@ -21,7 +21,7 @@ export class TransactionManagerApi extends BaseAPI { public txManagerHistory(queryParams?: TxManagerHistoryQueryParams, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) .txManagerHistory(queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -35,7 +35,7 @@ export class TransactionManagerApi extends BaseAPI { public txManagerState(txHash: string, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) .txManagerState(txHash, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -49,7 +49,7 @@ export class TransactionManagerApi extends BaseAPI { public txManagerSubmit(body: string | Uint8Array, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) .txManagerSubmit(body, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -63,6 +63,6 @@ export class TransactionManagerApi extends BaseAPI { public txManagerTurboSubmit(body: string | Uint8Array, options?: AxiosRequestConfig) { return TransactionManagerApiFp(this.configuration) .txManagerTurboSubmit(body, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/transactions/helpers.ts b/src/api/transactions/helpers.ts index 855dea3..cde21c9 100644 --- a/src/api/transactions/helpers.ts +++ b/src/api/transactions/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -252,7 +252,7 @@ export const TransactionsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.addressByTxo(txHash, index, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns hex-encoded CBOR bytes of a transaction @@ -266,7 +266,7 @@ export const TransactionsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txCborByTxHash(txHash, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns detailed information about a transaction @@ -280,7 +280,7 @@ export const TransactionsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txInfo(txHash, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the specified transaction output. @@ -298,7 +298,7 @@ export const TransactionsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txoByTxoRef(txHash, index, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Returns the specified transaction outputs @@ -314,7 +314,7 @@ export const TransactionsApiFp = function (configuration: Configuration) { options?: AxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.txosByTxoRefs(requestBody, queryParams, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/transactions/index.ts b/src/api/transactions/index.ts index 841efe5..d3f37c5 100644 --- a/src/api/transactions/index.ts +++ b/src/api/transactions/index.ts @@ -22,7 +22,7 @@ export class TransactionsApi extends BaseAPI { public addressByTxo(txHash: string, index: number, options?: AxiosRequestConfig) { return TransactionsApiFp(this.configuration) .addressByTxo(txHash, index, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -36,7 +36,7 @@ export class TransactionsApi extends BaseAPI { public txCborByTxHash(txHash: string, options?: AxiosRequestConfig) { return TransactionsApiFp(this.configuration) .txCborByTxHash(txHash, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -50,7 +50,7 @@ export class TransactionsApi extends BaseAPI { public txInfo(txHash: string, options?: AxiosRequestConfig) { return TransactionsApiFp(this.configuration) .txInfo(txHash, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -71,7 +71,7 @@ export class TransactionsApi extends BaseAPI { ) { return TransactionsApiFp(this.configuration) .txoByTxoRef(txHash, index, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -90,6 +90,6 @@ export class TransactionsApi extends BaseAPI { ) { return TransactionsApiFp(this.configuration) .txosByTxoRefs(requestBody, queryParams, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/api/vesting/helpers.ts b/src/api/vesting/helpers.ts index ca7ec6f..8e4c04f 100644 --- a/src/api/vesting/helpers.ts +++ b/src/api/vesting/helpers.ts @@ -1,4 +1,4 @@ -import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; +import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios'; import { RequestArgs } from '../../base'; import { assertParamExists, @@ -39,7 +39,7 @@ export const VestingApiAxiosParamCreator = function (configuration: Configuratio const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); const { baseOptions } = configuration; - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options }; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -169,12 +169,12 @@ export const VestingApiFp = function (configuration: Configuration) { async contractsVestingCollectBeneficiaryPost( beneficiary: string, options?: AxiosRequestConfig, - ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + ): Promise<(basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.contractsVestingCollectBeneficiaryPost( beneficiary, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Lock assets into the vesting contract @@ -191,7 +191,7 @@ export const VestingApiFp = function (configuration: Configuration) { contractsVestingLockPostRequest, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, /** * Detailed list of vesting assets at a beneficiary address @@ -208,7 +208,7 @@ export const VestingApiFp = function (configuration: Configuration) { beneficiary, options, ); - return createRequestFunction(localVarAxiosArgs, globalAxios, configuration); + return createRequestFunction(localVarAxiosArgs, configuration); }, }; }; diff --git a/src/api/vesting/index.ts b/src/api/vesting/index.ts index 6ce76c7..2180898 100644 --- a/src/api/vesting/index.ts +++ b/src/api/vesting/index.ts @@ -21,7 +21,7 @@ export class VestingApi extends BaseAPI { public contractsVestingCollectBeneficiaryPost(beneficiary: string, options?: AxiosRequestConfig) { return VestingApiFp(this.configuration) .contractsVestingCollectBeneficiaryPost(beneficiary, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -38,7 +38,7 @@ export class VestingApi extends BaseAPI { ) { return VestingApiFp(this.configuration) .contractsVestingLockPost(contractsVestingLockPostRequest, options) - .then((request) => request(this.axios)); + .then((request) => request()); } /** @@ -52,6 +52,6 @@ export class VestingApi extends BaseAPI { public contractsVestingStateBeneficiaryGet(beneficiary: string, options?: AxiosRequestConfig) { return VestingApiFp(this.configuration) .contractsVestingStateBeneficiaryGet(beneficiary, options) - .then((request) => request(this.axios)); + .then((request) => request()); } } diff --git a/src/base.ts b/src/base.ts index 1ec0f2c..ebe47d6 100644 --- a/src/base.ts +++ b/src/base.ts @@ -18,7 +18,7 @@ export interface RequestArgs { * @class BaseAPI */ export class BaseAPI { - constructor(protected configuration: Configuration, protected axios: AxiosInstance = globalAxios) {} + constructor(protected configuration: Configuration) {} } /** diff --git a/src/common.ts b/src/common.ts index 68f0de0..c059160 100644 --- a/src/common.ts +++ b/src/common.ts @@ -1,4 +1,4 @@ -import type { AxiosInstance, AxiosResponse } from 'axios'; +import type { AxiosResponse } from 'axios'; import type { Configuration } from './configuration'; import type { RequestArgs } from './base'; import { RequiredError } from './base'; @@ -87,13 +87,9 @@ export const toPathString = function (url: URL) { * * @export */ -export const createRequestFunction = function ( - axiosArgs: RequestArgs, - globalAxios: AxiosInstance, - configuration: Configuration, -) { - return >(axios: AxiosInstance = globalAxios) => { +export const createRequestFunction = function (axiosArgs: RequestArgs, configuration: Configuration) { + return >() => { const axiosRequestArgs = { ...axiosArgs.options, url: configuration.baseUrl + axiosArgs.url }; - return axios.request(axiosRequestArgs); + return configuration.axiosInstance.request(axiosRequestArgs); }; }; diff --git a/src/configuration.ts b/src/configuration.ts index e8e56a6..58e2f24 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -1,9 +1,12 @@ +import globalAxios, { AxiosInstance, AxiosRequestConfig } from 'axios'; + export type MaestroSupportedNetworks = 'Mainnet' | 'Preprod' | 'Preview'; export interface ConfigurationParameters { - apiKey: string; - network: MaestroSupportedNetworks; - baseOptions?: any; + readonly apiKey: string; + readonly network: MaestroSupportedNetworks; + readonly baseOptions?: AxiosRequestConfig; + readonly axiosInstance?: AxiosInstance; } export class Configuration { @@ -12,7 +15,7 @@ export class Configuration { * @param name security name * @memberof Configuration */ - apiKey: string; + readonly apiKey: string; /** * base url of network request @@ -20,20 +23,23 @@ export class Configuration { * @type {string} * @memberof Configuration */ - baseUrl: string; + readonly baseUrl: string; /** * base options for axios calls * - * @type {any} + * @type {AxiosRequestConfig} * @memberof Configuration */ - baseOptions?: any; + readonly baseOptions?: AxiosRequestConfig; + + readonly axiosInstance: AxiosInstance; constructor(param: ConfigurationParameters) { this.apiKey = param.apiKey; this.baseUrl = `https://${param.network}.gomaestro-api.org/v1`; this.baseOptions = param.baseOptions; + this.axiosInstance = param.axiosInstance ?? globalAxios; } /** From 0aa91a7dfec81db81ba89a052c8284155d9dfe2b Mon Sep 17 00:00:00 2001 From: Varderes Barsegyan Date: Thu, 2 Nov 2023 11:29:58 +0400 Subject: [PATCH 39/51] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0627271..cbaaedc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.2.2", + "version": "1.2.3", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", From 20eb30f68009b8b5cc77dfd863ae6463eca50fab Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Mon, 13 Nov 2023 11:02:55 +0200 Subject: [PATCH 40/51] feat: header-as-string for api calls returning utxos and updated axios to fix moderate vulnerability --- package.json | 2 +- src/api/accounts/helpers.ts | 1 + src/api/addresses/helpers.ts | 3 +++ src/api/transactions/helpers.ts | 1 + src/api/type.ts | 2 +- yarn.lock | 8 ++++---- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index cbaaedc..90c4ce6 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "prettier": "^2.8.8" }, "dependencies": { - "axios": "^1.5.0" + "axios": "^1.6.0" }, "lint-staged": { "src/**/*.{js,ts,},": [ diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index e6f64bf..27a04c8 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -108,6 +108,7 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; return { diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index eb12859..66513ac 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -270,6 +270,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; return { @@ -311,6 +312,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); @@ -354,6 +356,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; return { diff --git a/src/api/transactions/helpers.ts b/src/api/transactions/helpers.ts index cde21c9..e8892b3 100644 --- a/src/api/transactions/helpers.ts +++ b/src/api/transactions/helpers.ts @@ -220,6 +220,7 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); diff --git a/src/api/type.ts b/src/api/type.ts index 171a55d..d43c6d5 100644 --- a/src/api/type.ts +++ b/src/api/type.ts @@ -274,7 +274,7 @@ export interface Asset { * @type {number} * @memberof Asset */ - amount: number; + amount: string; /** * Asset (either `lovelace` or concatenation of hex encoded policy ID and asset name for native asset) * @type {string} diff --git a/yarn.lock b/yarn.lock index bf0d503..ba3cdba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -979,10 +979,10 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -axios@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f" - integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A== +axios@^1.6.0: + version "1.6.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7" + integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g== dependencies: follow-redirects "^1.15.0" form-data "^4.0.0" From 1f9ceabe696d582a95929297b8bc928e961191b7 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Mon, 13 Nov 2023 11:11:33 +0200 Subject: [PATCH 41/51] feat: amounts-as-string for pool info --- src/api/pools/helpers.ts | 1 + src/api/type.ts | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index abffe80..f5ecd03 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -216,6 +216,7 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, + 'amounts-as-string': 'true', // temporary header until this becomes default behaviour }; return { diff --git a/src/api/type.ts b/src/api/type.ts index d43c6d5..7e72854 100644 --- a/src/api/type.ts +++ b/src/api/type.ts @@ -271,7 +271,7 @@ export interface AddressTransaction { export interface Asset { /** * Amount of the asset - * @type {number} + * @type {string} * @memberof Asset */ amount: string; @@ -2237,10 +2237,10 @@ export interface PoolInfo { active_epoch_no: number; /** * Active stake - * @type {number} + * @type {string} * @memberof PoolInfo */ - active_stake?: number | null; + active_stake?: string | null; /** * Number of blocks created * @type {number} @@ -2249,10 +2249,10 @@ export interface PoolInfo { block_count?: number | null; /** * Pool fixed cost - * @type {number} + * @type {string} * @memberof PoolInfo */ - fixed_cost: number; + fixed_cost: string; /** * Number of current delegators * @type {number} @@ -2261,10 +2261,10 @@ export interface PoolInfo { live_delegators: number; /** * Account balance of pool owners - * @type {number} + * @type {string} * @memberof PoolInfo */ - live_pledge?: number | null; + live_pledge?: string | null; /** * Live saturation * @type {string} @@ -2273,16 +2273,16 @@ export interface PoolInfo { live_saturation?: string | null; /** * Live stake - * @type {number} + * @type {string} * @memberof PoolInfo */ - live_stake?: number | null; + live_stake?: string | null; /** * Pool margin - * @type {number} + * @type {string} * @memberof PoolInfo */ - margin: number; + margin: string; /** * Hash of the pool metadata * @type {string} @@ -2321,10 +2321,10 @@ export interface PoolInfo { owners: Array; /** * Pool pledge - * @type {number} + * @type {string} * @memberof PoolInfo */ - pledge: number; + pledge: string; /** * Bech32 encoded pool ID * @type {string} From 74954f2198cd5186ba0e01d09ee673d9363530f0 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Mon, 13 Nov 2023 11:19:20 +0200 Subject: [PATCH 42/51] feat: moved amounts-as-string header in common file --- src/api/accounts/helpers.ts | 3 ++- src/api/addresses/helpers.ts | 7 ++++--- src/api/pools/helpers.ts | 3 ++- src/api/transactions/helpers.ts | 3 ++- src/common.ts | 9 +++++++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/api/accounts/helpers.ts b/src/api/accounts/helpers.ts index 27a04c8..c484cc1 100644 --- a/src/api/accounts/helpers.ts +++ b/src/api/accounts/helpers.ts @@ -7,6 +7,7 @@ import { setSearchParams, toPathString, createRequestFunction, + HEADER_AMOUNTS_AS_STRING, } from '../../common'; import { Configuration } from '../../configuration'; import { @@ -108,7 +109,7 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; return { diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 66513ac..1bf9f4f 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -8,6 +8,7 @@ import { toPathString, serializeDataIfNeeded, createRequestFunction, + HEADER_AMOUNTS_AS_STRING, } from '../../common'; import { Configuration } from '../../configuration'; import { @@ -270,7 +271,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; return { @@ -312,7 +313,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); @@ -356,7 +357,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; return { diff --git a/src/api/pools/helpers.ts b/src/api/pools/helpers.ts index f5ecd03..99d5294 100644 --- a/src/api/pools/helpers.ts +++ b/src/api/pools/helpers.ts @@ -7,6 +7,7 @@ import { toPathString, assertParamExists, createRequestFunction, + HEADER_AMOUNTS_AS_STRING, } from '../../common'; import { Configuration } from '../../configuration'; import { @@ -216,7 +217,7 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration) ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; return { diff --git a/src/api/transactions/helpers.ts b/src/api/transactions/helpers.ts index e8892b3..08eb7a0 100644 --- a/src/api/transactions/helpers.ts +++ b/src/api/transactions/helpers.ts @@ -8,6 +8,7 @@ import { toPathString, serializeDataIfNeeded, createRequestFunction, + HEADER_AMOUNTS_AS_STRING, } from '../../common'; import { Configuration } from '../../configuration'; import { @@ -220,7 +221,7 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers, - 'amounts-as-string': 'true', // temporary header until this becomes default behaviour + ...HEADER_AMOUNTS_AS_STRING, }; localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); diff --git a/src/common.ts b/src/common.ts index c059160..046c880 100644 --- a/src/common.ts +++ b/src/common.ts @@ -9,6 +9,15 @@ import { RequiredError } from './base'; */ export const DUMMY_BASE_URL = 'https://example.com'; +/** + * temporary header used by some endpoints to indicate that the amounts + * should be returned as strings instead of numbers + * @export + */ +export const HEADER_AMOUNTS_AS_STRING = { + 'amounts-as-string': 'true', +}; + /** * * @throws {RequiredError} From fbfa97dc6492a84d7eb3f3e8f2abcc73e35fdb74 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Mon, 13 Nov 2023 12:49:40 +0200 Subject: [PATCH 43/51] feat: using added utxoByPaymentCreds --- src/api/addresses/helpers.ts | 63 ++++++++++++++++++++++++++++++++++++ src/api/addresses/index.ts | 19 +++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/api/addresses/helpers.ts b/src/api/addresses/helpers.ts index 1bf9f4f..148bba1 100644 --- a/src/api/addresses/helpers.ts +++ b/src/api/addresses/helpers.ts @@ -360,6 +360,49 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat ...HEADER_AMOUNTS_AS_STRING, }; + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Return detailed information on UTxOs which are controlled by some payment credentials in the specified list of payment credentials + * @summary UTxOs at multiple payment credentials + * @param {Array} requestBody + * @param {UtxosByAddressesQueryParams} [localVarQueryParameter] Query parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + utxosByPaymentCreds: async ( + requestBody: Array, + localVarQueryParameter: UtxosByAddressesQueryParams = {}, + options: AxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'requestBody' is not null or undefined + assertParamExists('utxosByPaymentCreds', 'requestBody', requestBody); + const localVarPath = `/addresses/cred/utxos`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + const { baseOptions } = configuration; + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + + // authentication api-key required + setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + ...HEADER_AMOUNTS_AS_STRING, + }; + localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); + return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, @@ -511,6 +554,26 @@ export const AddressesApiFp = function (configuration: Configuration) { ); return createRequestFunction(localVarAxiosArgs, configuration); }, + /** + * Return detailed information on UTxOs which are controlled by some payment credentials in the specified list of payment credentials + * @summary UTxOs at multiple payment credentials + * @param {Array} requestBody + * @param {UtxosByAddressesQueryParams} [queryParams] Query parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async utxosByPaymentCreds( + requestBody: Array, + queryParams?: UtxosByAddressesQueryParams, + options?: AxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByPaymentCreds( + requestBody, + queryParams, + options, + ); + return createRequestFunction(localVarAxiosArgs, configuration); + }, }; }; diff --git a/src/api/addresses/index.ts b/src/api/addresses/index.ts index 8dc01e8..4e5f469 100644 --- a/src/api/addresses/index.ts +++ b/src/api/addresses/index.ts @@ -145,6 +145,25 @@ export class AddressesApi extends BaseAPI { .utxosByPaymentCred(credential, queryParams, options) .then((request) => request()); } + + /** + * Return detailed information on UTxOs which are controlled by some payment creds in the specified list of payment creds + * @summary UTxOs at multiple payment creds + * @param {Array} requestBody + * @param {UtxosByAddressesQueryParams} [queryParams] Query parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AddressesApi + */ + public utxosByPaymentCreds( + requestBody: Array, + queryParams?: UtxosByAddressesQueryParams, + options?: AxiosRequestConfig, + ) { + return AddressesApiFp(this.configuration) + .utxosByPaymentCreds(requestBody, queryParams, options) + .then((request) => request()); + } } export * from './type'; From dece7f451d0b8e489426d3c7d92fabed2e25e27c Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Mon, 13 Nov 2023 16:08:53 +0200 Subject: [PATCH 44/51] feat: updated axios using pnpm --- package.json | 10 +++++----- pnpm-lock.yaml | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 90c4ce6..51f7615 100644 --- a/package.json +++ b/package.json @@ -23,14 +23,12 @@ "author": "gomaestro.org", "license": "Apache-2.0", "devDependencies": { + "@changesets/cli": "^2.26.2", "@commitlint/cli": "^17.4.3", "@commitlint/config-conventional": "^17.4.3", "@typescript-eslint/eslint-plugin": "^5.59.1", "@typescript-eslint/parser": "^5.59.1", "commitlint": "^17.4.3", - "@changesets/cli": "^2.26.2", - "tsup": "^7.2.0", - "typescript": "^5.2.2", "eslint": "^8.39.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.8.0", @@ -38,10 +36,12 @@ "eslint-plugin-import": "^2.27.5", "eslint-plugin-prettier": "^4.2.1", "husky": "^8.0.3", - "prettier": "^2.8.8" + "prettier": "^2.8.8", + "tsup": "^7.2.0", + "typescript": "^5.2.2" }, "dependencies": { - "axios": "^1.6.0" + "axios": "^1.6.1" }, "lint-staged": { "src/**/*.{js,ts,},": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 52c867c..5fd7e04 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: axios: - specifier: ^1.5.0 - version: 1.5.0 + specifier: ^1.6.1 + version: 1.6.1 devDependencies: '@changesets/cli': @@ -1146,10 +1146,10 @@ packages: engines: {node: '>= 0.4'} dev: true - /axios@1.5.0: - resolution: {integrity: sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==} + /axios@1.6.1: + resolution: {integrity: sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==} dependencies: - follow-redirects: 1.15.2 + follow-redirects: 1.15.3 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -2058,8 +2058,8 @@ packages: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} dev: true - /follow-redirects@1.15.2: - resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + /follow-redirects@1.15.3: + resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==} engines: {node: '>=4.0'} peerDependencies: debug: '*' From f060a406acc2cc6eb65880f23bc38e8503e14da1 Mon Sep 17 00:00:00 2001 From: Varderes Barsegyan Date: Mon, 13 Nov 2023 08:15:16 -0600 Subject: [PATCH 45/51] feat: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51f7615..33ce5a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.2.3", + "version": "1.2.4", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", From aecd8c09baa7aa25633f03a8dbeb54c6c6b59017 Mon Sep 17 00:00:00 2001 From: Varderes Barsegyan Date: Mon, 13 Nov 2023 08:21:13 -0600 Subject: [PATCH 46/51] feat: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33ce5a4..6b391cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.2.4", + "version": "1.3.0", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", From b46d3e3c200619dea1d2c26a248603bf87a9e439 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Fri, 1 Dec 2023 22:04:11 +0200 Subject: [PATCH 47/51] feat: fixed amounts-as-strings header typo --- src/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.ts b/src/common.ts index 046c880..872f25d 100644 --- a/src/common.ts +++ b/src/common.ts @@ -15,7 +15,7 @@ export const DUMMY_BASE_URL = 'https://example.com'; * @export */ export const HEADER_AMOUNTS_AS_STRING = { - 'amounts-as-string': 'true', + 'amounts-as-strings': 'true', }; /** From 11aa92e28c1e32f7bd6fe22180273895aa963e8a Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Fri, 1 Dec 2023 22:22:12 +0200 Subject: [PATCH 48/51] feat: moved lookupDatum to non-deprecated url and added lookupDatums --- src/api/datum/helpers.ts | 53 ++++++++++++++++++++++++++++++++++++++-- src/api/datum/index.ts | 20 ++++++++++++--- src/api/type.ts | 19 ++++++++++++++ 3 files changed, 86 insertions(+), 6 deletions(-) diff --git a/src/api/datum/helpers.ts b/src/api/datum/helpers.ts index 47460d1..c6e6fc4 100644 --- a/src/api/datum/helpers.ts +++ b/src/api/datum/helpers.ts @@ -9,7 +9,7 @@ import { createRequestFunction, } from '../../common'; import { Configuration } from '../../configuration'; -import { TimestampedDatum } from '../type'; +import { TimestampedDatum, TimestampedDatums } from '../type'; /** * DatumApi - axios parameter creator @@ -27,7 +27,7 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration) lookupDatum: async (datumHash: string, options: AxiosRequestConfig = {}): Promise => { // verify required parameter 'datumHash' is not null or undefined assertParamExists('lookupDatum', 'datumHash', datumHash); - const localVarPath = `/datum/{datum_hash}`.replace( + const localVarPath = `/datums/{datum_hash}`.replace( `{${'datum_hash'}}`, encodeURIComponent(String(datumHash)), ); @@ -50,6 +50,41 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration) ...options.headers, }; + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain + * @summary Datums by datum hashes + * @param {Array} requestBody Array of hex encoded datum hashes + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + lookupDatums: async (requestBody: Array, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'requestBody' is not null or undefined + assertParamExists('lookupDatums', 'requestBody', requestBody); + const localVarPath = `/datums`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + const { baseOptions } = configuration; + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api-key required + setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, @@ -79,6 +114,20 @@ export const DatumApiFp = function (configuration: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.lookupDatum(datumHash, options); return createRequestFunction(localVarAxiosArgs, configuration); }, + /** + * Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain + * @summary Datums by datum hashes + * @param {Array} requestBody Array of hex encoded datum hashes + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async lookupDatums( + requestBody: Array, + options?: AxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.lookupDatums(requestBody, options); + return createRequestFunction(localVarAxiosArgs, configuration); + }, }; }; diff --git a/src/api/datum/index.ts b/src/api/datum/index.ts index f1a39ce..3c9772a 100644 --- a/src/api/datum/index.ts +++ b/src/api/datum/index.ts @@ -17,9 +17,21 @@ export class DatumApi extends BaseAPI { * @throws {RequiredError} * @memberof DatumApi */ - public lookupDatum(datumHash: string, options?: AxiosRequestConfig) { - return DatumApiFp(this.configuration) - .lookupDatum(datumHash, options) - .then((request) => request()); + public async lookupDatum(datumHash: string, options?: AxiosRequestConfig) { + const request = await DatumApiFp(this.configuration).lookupDatum(datumHash, options); + return request(); + } + + /** + * Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain + * @summary Datums by datum hashes + * @param {Array} requestBody Array of hex encoded datum hashes + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DatumApi + */ + public async lookupDatums(requestBody: Array, options?: AxiosRequestConfig) { + const request = await DatumApiFp(this.configuration).lookupDatums(requestBody, options); + return request(); } } diff --git a/src/api/type.ts b/src/api/type.ts index 7e72854..5007a7d 100644 --- a/src/api/type.ts +++ b/src/api/type.ts @@ -3213,6 +3213,25 @@ export interface TimestampedDatum { */ last_updated: LastUpdated; } +/** + * Timestamped response. Returns the endpoint response data along with the chain-tip of the indexer, which details at which point in the chain\'s history the data was correct as-of. + * @export + * @interface TimestampedDatums + */ +export interface TimestampedDatums { + /** + * Record of Datum by datum hash + * @type {Record} + * @memberof TimestampedDatum + */ + data: Record; + /** + * + * @type {LastUpdated} + * @memberof TimestampedDatum + */ + last_updated: LastUpdated; +} /** * Timestamped response. Returns the endpoint response data along with the chain-tip of the indexer, which details at which point in the chain\'s history the data was correct as-of. * @export From 0005792dcf12f01e3192f5cc2e6c27799d629f24 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Fri, 1 Dec 2023 22:38:59 +0200 Subject: [PATCH 49/51] fix: fixed lookupDatums not adding req body --- src/api/datum/helpers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/datum/helpers.ts b/src/api/datum/helpers.ts index c6e6fc4..595c59a 100644 --- a/src/api/datum/helpers.ts +++ b/src/api/datum/helpers.ts @@ -7,6 +7,7 @@ import { setSearchParams, toPathString, createRequestFunction, + serializeDataIfNeeded, } from '../../common'; import { Configuration } from '../../configuration'; import { TimestampedDatum, TimestampedDatums } from '../type'; @@ -84,6 +85,7 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration) ...headersFromBaseOptions, ...options.headers, }; + localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration); return { url: toPathString(localVarUrlObj), From 369836f77f0a8fdc5178f8c4b44f69427816951c Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Fri, 1 Dec 2023 22:43:37 +0200 Subject: [PATCH 50/51] fix: fixed lookupDatums content type --- src/api/datum/helpers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/datum/helpers.ts b/src/api/datum/helpers.ts index 595c59a..b07c137 100644 --- a/src/api/datum/helpers.ts +++ b/src/api/datum/helpers.ts @@ -78,6 +78,8 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration) // authentication api-key required setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); + localVarHeaderParameter['Content-Type'] = 'application/json'; + setSearchParams(localVarUrlObj, localVarQueryParameter); const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { From 51756b800a42c03cccb8eeba996f09c14d52daa9 Mon Sep 17 00:00:00 2001 From: Alex Dochioiu Date: Sat, 2 Dec 2023 22:00:19 +0200 Subject: [PATCH 51/51] fix: updated epochs info url path and response to include new fields --- src/api/epochs/helpers.ts | 5 +---- src/api/type.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/api/epochs/helpers.ts b/src/api/epochs/helpers.ts index d9755d9..d314644 100644 --- a/src/api/epochs/helpers.ts +++ b/src/api/epochs/helpers.ts @@ -59,10 +59,7 @@ export const EpochsApiAxiosParamCreator = function (configuration: Configuration epochInfo: async (epochNo: number, options: AxiosRequestConfig = {}): Promise => { // verify required parameter 'epochNo' is not null or undefined assertParamExists('epochInfo', 'epochNo', epochNo); - const localVarPath = `/epochs/{epoch_no}/info`.replace( - `{${'epoch_no'}}`, - encodeURIComponent(String(epochNo)), - ); + const localVarPath = `/epochs/{epoch_no}`.replace(`{${'epoch_no'}}`, encodeURIComponent(String(epochNo))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); const { baseOptions } = configuration; diff --git a/src/api/type.ts b/src/api/type.ts index 5007a7d..f073cc8 100644 --- a/src/api/type.ts +++ b/src/api/type.ts @@ -1028,6 +1028,18 @@ export interface DelegatorInfo { * @interface EpochInfo */ export interface EpochInfo { + /** + * Total active stake in the epoch + * @type {number} + * @memberof EpochInfo + */ + active_stake?: string | null; + /** + * Average reward in the epoch + * @type {number} + * @memberof EpochInfo + */ + average_reward?: string | null; /** * Total blocks in the epoch * @type {number}