Skip to content

Commit d95c4c2

Browse files
authored
Merge pull request #42 from sanjay-del/delegation-balance
Delegation balance
2 parents 686ba60 + 5902e3c commit d95c4c2

File tree

7 files changed

+241
-1
lines changed

7 files changed

+241
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@maestro-org/typescript-sdk",
3-
"version": "1.5.2",
3+
"version": "1.5.4",
44
"description": "TypeScript SDK for the Maestro Dapp Platform",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/api/accounts/helpers.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ import {
1717
TimestampedAccountInfo,
1818
PaginatedAccountReward,
1919
PaginatedAccountUpdate,
20+
PaginatedAccountDelegationHistory,
2021
} from '../type';
2122
import {
2223
AccountAddressesQueryParams,
2324
AccountAssetsQueryParams,
25+
AccountDelegationHistoryQueryParams,
2426
AccountHistoryQueryParams,
2527
AccountRewardsQueryParams,
2628
AccountUpdatesQueryParams,
@@ -275,6 +277,48 @@ export const AccountsApiAxiosParamCreator = (configuration: Configuration) => ({
275277
...options.headers,
276278
};
277279

280+
return {
281+
url: toPathString(localVarUrlObj),
282+
options: localVarRequestOptions,
283+
};
284+
},
285+
/**
286+
* Returns list of delegation actions relating to a stake account
287+
* @summary Stake account delegation history
288+
* @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\')
289+
* @param {AccountDelegationHistoryQueryParams} [localVarQueryParameter] Query parameters.
290+
* @param {*} [options] Override http request option.
291+
* @throws {RequiredError}
292+
*/
293+
accountDelegationHistory: (
294+
stakeAddr: string,
295+
localVarQueryParameter: AccountDelegationHistoryQueryParams = {},
296+
options: AxiosRequestConfig = {},
297+
): RequestArgs => {
298+
// verify required parameter 'stakeAddr' is not null or undefined
299+
assertParamExists('accountDelegationHistory', 'stakeAddr', stakeAddr);
300+
const localVarPath = `/accounts/{stake_addr}/delegations`.replace(
301+
`{${'stake_addr'}}`,
302+
encodeURIComponent(String(stakeAddr)),
303+
);
304+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
305+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
306+
const { baseOptions } = configuration;
307+
308+
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
309+
const localVarHeaderParameter = {} as Record<string, string>;
310+
311+
// authentication api-key required
312+
setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration);
313+
314+
setSearchParams(localVarUrlObj, localVarQueryParameter);
315+
const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
316+
localVarRequestOptions.headers = {
317+
...localVarHeaderParameter,
318+
...headersFromBaseOptions,
319+
...options.headers,
320+
};
321+
278322
return {
279323
url: toPathString(localVarUrlObj),
280324
options: localVarRequestOptions,
@@ -337,6 +381,27 @@ export const AccountsApiFp = (configuration: Configuration) => {
337381
const localVarAxiosArgs = localVarAxiosParamCreator.accountHistory(stakeAddr, queryParams, options);
338382
return createRequestFunction(localVarAxiosArgs, configuration);
339383
},
384+
385+
/**
386+
* Returns list of delegation actions relating to a stake account
387+
* @summary Stake account history
388+
* @param {string} stakeAddr Bech32 encoded stake/reward address (\&#39;stake1...\&#39;)
389+
* @param {AccountDelegationHistoryQueryParams} [queryParams] Query parameters.
390+
* @param {*} [options] Override http request option.
391+
* @throws {RequiredError}
392+
*/
393+
accountDelegationHistory(
394+
stakeAddr: string,
395+
queryParams?: AccountDelegationHistoryQueryParams,
396+
options?: AxiosRequestConfig,
397+
): () => Promise<PaginatedAccountDelegationHistory> {
398+
const localVarAxiosArgs = localVarAxiosParamCreator.accountDelegationHistory(
399+
stakeAddr,
400+
queryParams,
401+
options,
402+
);
403+
return createRequestFunction(localVarAxiosArgs, configuration);
404+
},
340405
/**
341406
* Returns various information regarding a stake account
342407
* @summary Stake account information

src/api/accounts/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
AccountHistoryQueryParams,
88
AccountRewardsQueryParams,
99
AccountUpdatesQueryParams,
10+
AccountDelegationHistoryQueryParams,
1011
} from './type';
1112

1213
/**
@@ -59,6 +60,23 @@ export class AccountsApi extends BaseAPI {
5960
return AccountsApiFp(this.configuration).accountHistory(stakeAddr, queryParams, options)();
6061
}
6162

63+
/**
64+
* * Returns list of delegation actions relating to a stake account
65+
* @summary Stake account history
66+
* @param {string} stakeAddr Bech32 encoded stake/reward address (\&#39;stake1...\&#39;)
67+
* @param {AccountDelegationHistoryQueryParams} [queryParams] Query parameters.
68+
* @param {*} [options] Override http request option.
69+
* @throws {RequiredError}
70+
* @memberof AccountsApi
71+
*/
72+
public accountDelegationHistory(
73+
stakeAddr: string,
74+
queryParams?: AccountDelegationHistoryQueryParams,
75+
options?: AxiosRequestConfig,
76+
) {
77+
return AccountsApiFp(this.configuration).accountDelegationHistory(stakeAddr, queryParams, options)();
78+
}
79+
6280
/**
6381
* Returns various information regarding a stake account
6482
* @summary Stake account information

src/api/accounts/type.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,25 @@ export interface AccountUpdatesQueryParams {
114114
*/
115115
cursor?: string | null;
116116
}
117+
118+
/**
119+
* Query parameters for accountDelegationHistory.
120+
* @export
121+
* @interface AccountDelegationHistoryQueryParams
122+
*
123+
*/
124+
export interface AccountDelegationHistoryQueryParams {
125+
/**
126+
* The max number of results per page.
127+
* @type {number | null}
128+
* @memberof AccountDelegationHistoryQueryParams
129+
*/
130+
count?: number | null;
131+
132+
/**
133+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
134+
* @type {string | null}
135+
* @memberof AccountDelegationHistoryQueryParams
136+
*/
137+
cursor?: string | null;
138+
}

src/api/addresses/helpers.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
PaginatedPaymentCredentialTransaction,
1919
PaginatedUtxoRef,
2020
PaginatedUtxoWithSlot,
21+
AddressBalance,
2122
} from '../type';
2223
import {
2324
TxsByAddressQueryParams,
@@ -71,6 +72,45 @@ export const AddressesApiAxiosParamCreator = (configuration: Configuration) => (
7172
options: localVarRequestOptions,
7273
};
7374
},
75+
76+
/**
77+
* Return total amount of assets, including ADA, in UTxOs controlled by a specific payment credential
78+
* @summary Address Balance
79+
* @param {string} credential Payment credential in bech32 format
80+
* @param {*} [options] Override http request option.
81+
* @throws {RequiredError}
82+
*/
83+
addressBalance: (credential: string, options: AxiosRequestConfig = {}): RequestArgs => {
84+
// verify required parameter 'credential' is not null or undefined
85+
assertParamExists('addressBalance', 'address', credential);
86+
const localVarPath = `/addresses/cred/{credential}/balance`.replace(
87+
`{${'credential'}}`,
88+
encodeURIComponent(String(credential)),
89+
);
90+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
91+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
92+
const { baseOptions } = configuration;
93+
94+
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
95+
const localVarHeaderParameter = {} as Record<string, string>;
96+
const localVarQueryParameter = {} as Record<string, string>;
97+
98+
// authentication api-key required
99+
setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration);
100+
101+
setSearchParams(localVarUrlObj, localVarQueryParameter);
102+
const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
103+
localVarRequestOptions.headers = {
104+
...localVarHeaderParameter,
105+
...headersFromBaseOptions,
106+
...options.headers,
107+
};
108+
109+
return {
110+
url: toPathString(localVarUrlObj),
111+
options: localVarRequestOptions,
112+
};
113+
},
74114
/**
75115
* 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/).
76116
* @summary Address transaction count
@@ -427,6 +467,17 @@ export const AddressesApiFp = (configuration: Configuration) => {
427467
const localVarAxiosArgs = localVarAxiosParamCreator.decodeAddress(address, options);
428468
return createRequestFunction(localVarAxiosArgs, configuration);
429469
},
470+
/**
471+
* Return total amount of assets, including ADA, in UTxOs controlled by a specific payment credential
472+
* @summary Address Balance
473+
* @param {string} credential Payment credential in bech32 format
474+
* @param {*} [options] Override http request option.
475+
* @throws {RequiredError}
476+
*/
477+
addressBalance(credential: string, options?: AxiosRequestConfig): () => Promise<AddressBalance> {
478+
const localVarAxiosArgs = localVarAxiosParamCreator.addressBalance(credential, options);
479+
return createRequestFunction(localVarAxiosArgs, configuration);
480+
},
430481
/**
431482
* 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/).
432483
* @summary Address transaction count

src/api/addresses/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ export class AddressesApi extends BaseAPI {
2828
return AddressesApiFp(this.configuration).decodeAddress(address, options)();
2929
}
3030

31+
/**
32+
* Return total amount of assets, including ADA, in UTxOs controlled by a specific payment credential
33+
* @summary Address Balance
34+
* @param {string} credential Payment credential in bech32 format
35+
* @param {*} [options] Override http request option.
36+
* @throws {RequiredError}
37+
* @memberof AddressesApi
38+
*/
39+
public addressBalance(credential: string, options?: AxiosRequestConfig) {
40+
return AddressesApiFp(this.configuration).addressBalance(credential, options)();
41+
}
42+
3143
/**
3244
* 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/).
3345
* @summary Address transaction count

src/api/type.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ export const AccountAction = {
1515

1616
export type AccountAction = (typeof AccountAction)[keyof typeof AccountAction];
1717

18+
/**
19+
* Per-epoch information about a stake account
20+
* @export
21+
* @interface AccountDelegationHistory
22+
*/
23+
export interface AccountDelegationHistory {
24+
/**
25+
* Epoch number in which the delegation becomes active
26+
* @type {number}
27+
* @memberof AccountDelegationHistory
28+
*/
29+
active_epoch_no: number;
30+
/**
31+
* Bech32 encoded pool ID the account was delegated to
32+
* @type {string}
33+
* @memberof AccountDelegationHistory
34+
*/
35+
pool_id: string;
36+
37+
/**
38+
* Absolute slot of the block which contained the transactio
39+
* @type {number}
40+
* @memberof AccountDelegationHistory
41+
*/
42+
slot: number;
43+
}
44+
1845
/**
1946
* Per-epoch information about a stake account
2047
* @export
@@ -233,6 +260,25 @@ export interface AddressInfo {
233260
staking_cred?: StakingCredential | null;
234261
}
235262

263+
/**
264+
* Current Balance by payment credential
265+
* @export
266+
* @interface AddressBalance
267+
*/
268+
export interface AddressBalance {
269+
/**
270+
*
271+
* @type {object}
272+
* @memberof AddressBalance
273+
*/
274+
assets: object;
275+
/**
276+
*
277+
* @type {string}
278+
* @memberof AddressBalance
279+
*/
280+
lovelace: object;
281+
}
236282
/**
237283
* Transaction which involved a specific address
238284
* @export
@@ -1394,6 +1440,32 @@ export interface PaginatedAccountHistory {
13941440
*/
13951441
next_cursor?: string | null;
13961442
}
1443+
1444+
/**
1445+
* A paginated response. Pass in the `next_cursor` in a subsequent request as the `cursor` query parameter to fetch the next page of results.
1446+
* @export
1447+
* @interface PaginatedAccountDelegationHistory
1448+
*/
1449+
export interface PaginatedAccountDelegationHistory {
1450+
/**
1451+
* Endpoint response data
1452+
* @type {Array<AccountAction>}
1453+
* @memberof PaginatedAccountHistory
1454+
*/
1455+
data: Array<AccountDelegationHistory>;
1456+
/**
1457+
*
1458+
* @type {LastUpdated}
1459+
* @memberof PaginatedAccountDelegationHistory
1460+
*/
1461+
last_updated: LastUpdated;
1462+
/**
1463+
* Pagination cursor
1464+
* @type {string}
1465+
* @memberof PaginatedAccountDelegationHistory
1466+
*/
1467+
next_cursor?: string | null;
1468+
}
13971469
/**
13981470
* A paginated response. Pass in the `next_cursor` in a subsequent request as the `cursor` query parameter to fetch the next page of results.
13991471
* @export

0 commit comments

Comments
 (0)