Skip to content

Utxo and PoolInfo amounts to string + axios update + new endpoint #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
"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",
"eslint-import-resolver-typescript": "^3.6.0",
"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.5.0"
"axios": "^1.6.1"
},
"lint-staged": {
"src/**/*.{js,ts,},": [
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/api/accounts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
setSearchParams,
toPathString,
createRequestFunction,
HEADER_AMOUNTS_AS_STRING,
} from '../../common';
import { Configuration } from '../../configuration';
import {
Expand Down Expand Up @@ -108,6 +109,7 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...HEADER_AMOUNTS_AS_STRING,
};

return {
Expand Down
67 changes: 67 additions & 0 deletions src/api/addresses/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
toPathString,
serializeDataIfNeeded,
createRequestFunction,
HEADER_AMOUNTS_AS_STRING,
} from '../../common';
import { Configuration } from '../../configuration';
import {
Expand Down Expand Up @@ -270,6 +271,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...HEADER_AMOUNTS_AS_STRING,
};

return {
Expand Down Expand Up @@ -311,6 +313,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...HEADER_AMOUNTS_AS_STRING,
};
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);

Expand Down Expand Up @@ -354,8 +357,52 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...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<string>} requestBody
* @param {UtxosByAddressesQueryParams} [localVarQueryParameter] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
utxosByPaymentCreds: async (
requestBody: Array<string>,
localVarQueryParameter: UtxosByAddressesQueryParams = {},
options: AxiosRequestConfig = {},
): Promise<RequestArgs> => {
// 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,
Expand Down Expand Up @@ -507,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<string>} requestBody
* @param {UtxosByAddressesQueryParams} [queryParams] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async utxosByPaymentCreds(
requestBody: Array<string>,
queryParams?: UtxosByAddressesQueryParams,
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedUtxoWithSlot>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByPaymentCreds(
requestBody,
queryParams,
options,
);
return createRequestFunction(localVarAxiosArgs, configuration);
},
};
};

Expand Down
19 changes: 19 additions & 0 deletions src/api/addresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>} requestBody
* @param {UtxosByAddressesQueryParams} [queryParams] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AddressesApi
*/
public utxosByPaymentCreds(
requestBody: Array<string>,
queryParams?: UtxosByAddressesQueryParams,
options?: AxiosRequestConfig,
) {
return AddressesApiFp(this.configuration)
.utxosByPaymentCreds(requestBody, queryParams, options)
.then((request) => request());
}
}

export * from './type';
2 changes: 2 additions & 0 deletions src/api/pools/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
toPathString,
assertParamExists,
createRequestFunction,
HEADER_AMOUNTS_AS_STRING,
} from '../../common';
import { Configuration } from '../../configuration';
import {
Expand Down Expand Up @@ -216,6 +217,7 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration)
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...HEADER_AMOUNTS_AS_STRING,
};

return {
Expand Down
2 changes: 2 additions & 0 deletions src/api/transactions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
toPathString,
serializeDataIfNeeded,
createRequestFunction,
HEADER_AMOUNTS_AS_STRING,
} from '../../common';
import { Configuration } from '../../configuration';
import {
Expand Down Expand Up @@ -220,6 +221,7 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
...HEADER_AMOUNTS_AS_STRING,
};
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);

Expand Down
28 changes: 14 additions & 14 deletions src/api/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ export interface AddressTransaction {
export interface Asset {
/**
* Amount of the asset
* @type {number}
* @type {string}
* @memberof Asset
*/
amount: number;
amount: string;
/**
* Asset (either `lovelace` or concatenation of hex encoded policy ID and asset name for native asset)
* @type {string}
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand Down Expand Up @@ -2321,10 +2321,10 @@ export interface PoolInfo {
owners: Array<string>;
/**
* Pool pledge
* @type {number}
* @type {string}
* @memberof PoolInfo
*/
pledge: number;
pledge: string;
/**
* Bech32 encoded pool ID
* @type {string}
Expand Down
9 changes: 9 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down