Skip to content

Commit b2c714f

Browse files
committed
feat: added creds txs api
1 parent 7e44536 commit b2c714f

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

src/api/addresses/helpers.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import {
2424
TxsByAddressQueryParams,
2525
TxsByPaymentCredQueryParams,
26+
TxsByPaymentCredsQueryParams,
2627
UtxoRefsAtAddressQueryParams,
2728
UtxosByAddressQueryParams,
2829
UtxosByAddressesQueryParams,
@@ -233,6 +234,49 @@ export const AddressesApiAxiosParamCreator = (configuration: Configuration) => (
233234
options: localVarRequestOptions,
234235
};
235236
},
237+
/**
238+
* Returns transactions in which the specified payment credentials spent or received funds. Specifically, the transactions where: the payment credentials were 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/).
239+
* @summary Payment credentials transactions
240+
* @param {Array<string>} requestBody Payment credentials in bech32 format
241+
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
242+
* @param {*} [options] Override http request option.
243+
* @throws {RequiredError}
244+
*/
245+
txsByPaymentCreds: (
246+
requestBody: Array<string>,
247+
localVarQueryParameter: TxsByPaymentCredsQueryParams = {},
248+
options: AxiosRequestConfig = {},
249+
): RequestArgs => {
250+
// verify required parameter 'requestBody' is not null or undefined
251+
assertParamExists('txsByPaymentCreds', 'requestBody', requestBody);
252+
const localVarPath = `/addresses/cred/transactions`;
253+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
254+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
255+
const { baseOptions } = configuration;
256+
257+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
258+
const localVarHeaderParameter = {} as Record<string, string>;
259+
260+
// authentication api-key required
261+
setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration);
262+
263+
localVarHeaderParameter['Content-Type'] = 'application/json';
264+
265+
setSearchParams(localVarUrlObj, localVarQueryParameter);
266+
const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
267+
localVarRequestOptions.headers = {
268+
...localVarHeaderParameter,
269+
...headersFromBaseOptions,
270+
...options.headers,
271+
...HEADER_AMOUNTS_AS_STRING,
272+
};
273+
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);
274+
275+
return {
276+
url: toPathString(localVarUrlObj),
277+
options: localVarRequestOptions,
278+
};
279+
},
236280
/**
237281
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
238282
* @summary UTxO references at an address
@@ -521,6 +565,22 @@ export const AddressesApiFp = (configuration: Configuration) => {
521565
const localVarAxiosArgs = localVarAxiosParamCreator.txsByPaymentCred(credential, queryParams, options);
522566
return createRequestFunction(localVarAxiosArgs, configuration);
523567
},
568+
/**
569+
* Returns transactions in which the specified payment credentials spent or received funds. Specifically, the transactions where: the payment credentials were 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/).
570+
* @summary Payment credentials transactions
571+
* @param {Array<string>} requestBody Payment credentials in bech32 format
572+
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
573+
* @param {*} [options] Override http request option.
574+
* @throws {RequiredError}
575+
*/
576+
txsByPaymentCreds(
577+
requestBody: Array<string>,
578+
queryParams?: TxsByPaymentCredsQueryParams,
579+
options?: AxiosRequestConfig,
580+
): () => Promise<PaginatedPaymentCredentialTransaction> {
581+
const localVarAxiosArgs = localVarAxiosParamCreator.txsByPaymentCreds(requestBody, queryParams, options);
582+
return createRequestFunction(localVarAxiosArgs, configuration);
583+
},
524584
/**
525585
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
526586
* @summary UTxO references at an address

src/api/addresses/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AddressesApiFp } from './helpers';
44
import {
55
TxsByAddressQueryParams,
66
TxsByPaymentCredQueryParams,
7+
TxsByPaymentCredsQueryParams,
78
UtxosByAddressQueryParams,
89
UtxosByAddressesQueryParams,
910
UtxosByPaymentCredQueryParams,
@@ -82,6 +83,23 @@ export class AddressesApi extends BaseAPI {
8283
return AddressesApiFp(this.configuration).txsByPaymentCred(credential, queryParams, options)();
8384
}
8485

86+
/**
87+
* Returns transactions in which the specified payment credentials spent or received funds. Specifically, the transactions where: the payment credentials were 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/).
88+
* @summary Payment credentials transactions
89+
* @param {Array<string>} requestBody Payment credentials in bech32 format
90+
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
91+
* @param {*} [options] Override http request option.
92+
* @throws {RequiredError}
93+
*/
94+
public async txsByPaymentCreds(
95+
requestBody: Array<string>,
96+
queryParams?: TxsByPaymentCredsQueryParams,
97+
options?: AxiosRequestConfig,
98+
) {
99+
const request = await AddressesApiFp(this.configuration).txsByPaymentCreds(requestBody, queryParams, options);
100+
return request();
101+
}
102+
85103
/**
86104
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
87105
* @summary UTxO references at an address

src/api/addresses/type.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,45 @@ export interface TxsByPaymentCredQueryParams {
118118
cursor?: string | null;
119119
}
120120

121+
/**
122+
* Query parameters for txsByPaymentCreds.
123+
* @export
124+
* @interface TxsByPaymentCredsQueryParams
125+
*
126+
*/
127+
export interface TxsByPaymentCredsQueryParams {
128+
/**
129+
* The max number of results per page.
130+
* @type {number | null}
131+
* @memberof TxsByPaymentCredsQueryParams
132+
*/
133+
count?: number | null;
134+
/**
135+
* The order in which the results are sorted, by transaction age
136+
* @type {TxsByPaymentCredOrderEnum}
137+
* @memberof TxsByPaymentCredsQueryParams
138+
*/
139+
order?: TxsByPaymentCredOrderEnum;
140+
/**
141+
* Return only transactions minted on or after a specific slot
142+
* @type {number | null}
143+
* @memberof TxsByPaymentCredsQueryParams
144+
*/
145+
from?: number | null;
146+
/**
147+
* Return only transactions minted on or before a specific slot
148+
* @type {number | null}
149+
* @memberof TxsByPaymentCredsQueryParams
150+
*/
151+
to?: number | null;
152+
/**
153+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
154+
* @type {string | null}
155+
* @memberof TxsByPaymentCredsQueryParams
156+
*/
157+
cursor?: string | null;
158+
}
159+
121160
/**
122161
* Query parameters for utxoRefsAtAddress.
123162
* @export

0 commit comments

Comments
 (0)