Skip to content

Commit d022561

Browse files
authored
Merge pull request #25 from vespr-wallet/alex/utxo_amounts_to_string
Utxo and PoolInfo amounts to string + axios update + new endpoint
2 parents 0aa91a7 + dece7f4 commit d022561

File tree

10 files changed

+131
-30
lines changed

10 files changed

+131
-30
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@
2323
"author": "gomaestro.org",
2424
"license": "Apache-2.0",
2525
"devDependencies": {
26+
"@changesets/cli": "^2.26.2",
2627
"@commitlint/cli": "^17.4.3",
2728
"@commitlint/config-conventional": "^17.4.3",
2829
"@typescript-eslint/eslint-plugin": "^5.59.1",
2930
"@typescript-eslint/parser": "^5.59.1",
3031
"commitlint": "^17.4.3",
31-
"@changesets/cli": "^2.26.2",
32-
"tsup": "^7.2.0",
33-
"typescript": "^5.2.2",
3432
"eslint": "^8.39.0",
3533
"eslint-config-airbnb-base": "^15.0.0",
3634
"eslint-config-prettier": "^8.8.0",
3735
"eslint-import-resolver-typescript": "^3.6.0",
3836
"eslint-plugin-import": "^2.27.5",
3937
"eslint-plugin-prettier": "^4.2.1",
4038
"husky": "^8.0.3",
41-
"prettier": "^2.8.8"
39+
"prettier": "^2.8.8",
40+
"tsup": "^7.2.0",
41+
"typescript": "^5.2.2"
4242
},
4343
"dependencies": {
44-
"axios": "^1.5.0"
44+
"axios": "^1.6.1"
4545
},
4646
"lint-staged": {
4747
"src/**/*.{js,ts,},": [

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/accounts/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
setSearchParams,
88
toPathString,
99
createRequestFunction,
10+
HEADER_AMOUNTS_AS_STRING,
1011
} from '../../common';
1112
import { Configuration } from '../../configuration';
1213
import {
@@ -108,6 +109,7 @@ export const AccountsApiAxiosParamCreator = function (configuration: Configurati
108109
...localVarHeaderParameter,
109110
...headersFromBaseOptions,
110111
...options.headers,
112+
...HEADER_AMOUNTS_AS_STRING,
111113
};
112114

113115
return {

src/api/addresses/helpers.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
toPathString,
99
serializeDataIfNeeded,
1010
createRequestFunction,
11+
HEADER_AMOUNTS_AS_STRING,
1112
} from '../../common';
1213
import { Configuration } from '../../configuration';
1314
import {
@@ -270,6 +271,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
270271
...localVarHeaderParameter,
271272
...headersFromBaseOptions,
272273
...options.headers,
274+
...HEADER_AMOUNTS_AS_STRING,
273275
};
274276

275277
return {
@@ -311,6 +313,7 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
311313
...localVarHeaderParameter,
312314
...headersFromBaseOptions,
313315
...options.headers,
316+
...HEADER_AMOUNTS_AS_STRING,
314317
};
315318
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);
316319

@@ -354,8 +357,52 @@ export const AddressesApiAxiosParamCreator = function (configuration: Configurat
354357
...localVarHeaderParameter,
355358
...headersFromBaseOptions,
356359
...options.headers,
360+
...HEADER_AMOUNTS_AS_STRING,
357361
};
358362

363+
return {
364+
url: toPathString(localVarUrlObj),
365+
options: localVarRequestOptions,
366+
};
367+
},
368+
/**
369+
* Return detailed information on UTxOs which are controlled by some payment credentials in the specified list of payment credentials
370+
* @summary UTxOs at multiple payment credentials
371+
* @param {Array<string>} requestBody
372+
* @param {UtxosByAddressesQueryParams} [localVarQueryParameter] Query parameters.
373+
* @param {*} [options] Override http request option.
374+
* @throws {RequiredError}
375+
*/
376+
utxosByPaymentCreds: async (
377+
requestBody: Array<string>,
378+
localVarQueryParameter: UtxosByAddressesQueryParams = {},
379+
options: AxiosRequestConfig = {},
380+
): Promise<RequestArgs> => {
381+
// verify required parameter 'requestBody' is not null or undefined
382+
assertParamExists('utxosByPaymentCreds', 'requestBody', requestBody);
383+
const localVarPath = `/addresses/cred/utxos`;
384+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
385+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
386+
const { baseOptions } = configuration;
387+
388+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
389+
const localVarHeaderParameter = {} as any;
390+
391+
// authentication api-key required
392+
setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration);
393+
394+
localVarHeaderParameter['Content-Type'] = 'application/json';
395+
396+
setSearchParams(localVarUrlObj, localVarQueryParameter);
397+
const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
398+
localVarRequestOptions.headers = {
399+
...localVarHeaderParameter,
400+
...headersFromBaseOptions,
401+
...options.headers,
402+
...HEADER_AMOUNTS_AS_STRING,
403+
};
404+
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);
405+
359406
return {
360407
url: toPathString(localVarUrlObj),
361408
options: localVarRequestOptions,
@@ -507,6 +554,26 @@ export const AddressesApiFp = function (configuration: Configuration) {
507554
);
508555
return createRequestFunction(localVarAxiosArgs, configuration);
509556
},
557+
/**
558+
* Return detailed information on UTxOs which are controlled by some payment credentials in the specified list of payment credentials
559+
* @summary UTxOs at multiple payment credentials
560+
* @param {Array<string>} requestBody
561+
* @param {UtxosByAddressesQueryParams} [queryParams] Query parameters.
562+
* @param {*} [options] Override http request option.
563+
* @throws {RequiredError}
564+
*/
565+
async utxosByPaymentCreds(
566+
requestBody: Array<string>,
567+
queryParams?: UtxosByAddressesQueryParams,
568+
options?: AxiosRequestConfig,
569+
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedUtxoWithSlot>> {
570+
const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByPaymentCreds(
571+
requestBody,
572+
queryParams,
573+
options,
574+
);
575+
return createRequestFunction(localVarAxiosArgs, configuration);
576+
},
510577
};
511578
};
512579

src/api/addresses/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ export class AddressesApi extends BaseAPI {
145145
.utxosByPaymentCred(credential, queryParams, options)
146146
.then((request) => request());
147147
}
148+
149+
/**
150+
* Return detailed information on UTxOs which are controlled by some payment creds in the specified list of payment creds
151+
* @summary UTxOs at multiple payment creds
152+
* @param {Array<string>} requestBody
153+
* @param {UtxosByAddressesQueryParams} [queryParams] Query parameters.
154+
* @param {*} [options] Override http request option.
155+
* @throws {RequiredError}
156+
* @memberof AddressesApi
157+
*/
158+
public utxosByPaymentCreds(
159+
requestBody: Array<string>,
160+
queryParams?: UtxosByAddressesQueryParams,
161+
options?: AxiosRequestConfig,
162+
) {
163+
return AddressesApiFp(this.configuration)
164+
.utxosByPaymentCreds(requestBody, queryParams, options)
165+
.then((request) => request());
166+
}
148167
}
149168

150169
export * from './type';

src/api/pools/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
toPathString,
88
assertParamExists,
99
createRequestFunction,
10+
HEADER_AMOUNTS_AS_STRING,
1011
} from '../../common';
1112
import { Configuration } from '../../configuration';
1213
import {
@@ -216,6 +217,7 @@ export const PoolsApiAxiosParamCreator = function (configuration: Configuration)
216217
...localVarHeaderParameter,
217218
...headersFromBaseOptions,
218219
...options.headers,
220+
...HEADER_AMOUNTS_AS_STRING,
219221
};
220222

221223
return {

src/api/transactions/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
toPathString,
99
serializeDataIfNeeded,
1010
createRequestFunction,
11+
HEADER_AMOUNTS_AS_STRING,
1112
} from '../../common';
1213
import { Configuration } from '../../configuration';
1314
import {
@@ -220,6 +221,7 @@ export const TransactionsApiAxiosParamCreator = function (configuration: Configu
220221
...localVarHeaderParameter,
221222
...headersFromBaseOptions,
222223
...options.headers,
224+
...HEADER_AMOUNTS_AS_STRING,
223225
};
224226
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);
225227

src/api/type.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ export interface AddressTransaction {
271271
export interface Asset {
272272
/**
273273
* Amount of the asset
274-
* @type {number}
274+
* @type {string}
275275
* @memberof Asset
276276
*/
277-
amount: number;
277+
amount: string;
278278
/**
279279
* Asset (either `lovelace` or concatenation of hex encoded policy ID and asset name for native asset)
280280
* @type {string}
@@ -2237,10 +2237,10 @@ export interface PoolInfo {
22372237
active_epoch_no: number;
22382238
/**
22392239
* Active stake
2240-
* @type {number}
2240+
* @type {string}
22412241
* @memberof PoolInfo
22422242
*/
2243-
active_stake?: number | null;
2243+
active_stake?: string | null;
22442244
/**
22452245
* Number of blocks created
22462246
* @type {number}
@@ -2249,10 +2249,10 @@ export interface PoolInfo {
22492249
block_count?: number | null;
22502250
/**
22512251
* Pool fixed cost
2252-
* @type {number}
2252+
* @type {string}
22532253
* @memberof PoolInfo
22542254
*/
2255-
fixed_cost: number;
2255+
fixed_cost: string;
22562256
/**
22572257
* Number of current delegators
22582258
* @type {number}
@@ -2261,10 +2261,10 @@ export interface PoolInfo {
22612261
live_delegators: number;
22622262
/**
22632263
* Account balance of pool owners
2264-
* @type {number}
2264+
* @type {string}
22652265
* @memberof PoolInfo
22662266
*/
2267-
live_pledge?: number | null;
2267+
live_pledge?: string | null;
22682268
/**
22692269
* Live saturation
22702270
* @type {string}
@@ -2273,16 +2273,16 @@ export interface PoolInfo {
22732273
live_saturation?: string | null;
22742274
/**
22752275
* Live stake
2276-
* @type {number}
2276+
* @type {string}
22772277
* @memberof PoolInfo
22782278
*/
2279-
live_stake?: number | null;
2279+
live_stake?: string | null;
22802280
/**
22812281
* Pool margin
2282-
* @type {number}
2282+
* @type {string}
22832283
* @memberof PoolInfo
22842284
*/
2285-
margin: number;
2285+
margin: string;
22862286
/**
22872287
* Hash of the pool metadata
22882288
* @type {string}
@@ -2321,10 +2321,10 @@ export interface PoolInfo {
23212321
owners: Array<string>;
23222322
/**
23232323
* Pool pledge
2324-
* @type {number}
2324+
* @type {string}
23252325
* @memberof PoolInfo
23262326
*/
2327-
pledge: number;
2327+
pledge: string;
23282328
/**
23292329
* Bech32 encoded pool ID
23302330
* @type {string}

src/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import { RequiredError } from './base';
99
*/
1010
export const DUMMY_BASE_URL = 'https://example.com';
1111

12+
/**
13+
* temporary header used by some endpoints to indicate that the amounts
14+
* should be returned as strings instead of numbers
15+
* @export
16+
*/
17+
export const HEADER_AMOUNTS_AS_STRING = {
18+
'amounts-as-string': 'true',
19+
};
20+
1221
/**
1322
*
1423
* @throws {RequiredError}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,10 +979,10 @@ available-typed-arrays@^1.0.5:
979979
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
980980
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==
981981

982-
axios@^1.5.0:
983-
version "1.5.1"
984-
resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f"
985-
integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==
982+
axios@^1.6.0:
983+
version "1.6.1"
984+
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
985+
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
986986
dependencies:
987987
follow-redirects "^1.15.0"
988988
form-data "^4.0.0"

0 commit comments

Comments
 (0)