Skip to content
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

Added txsByPaymentCreds Endpoint And fixed errors being returned as result #44

Merged
merged 3 commits into from
May 3, 2024
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
60 changes: 60 additions & 0 deletions src/api/addresses/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import {
TxsByAddressQueryParams,
TxsByPaymentCredQueryParams,
TxsByPaymentCredsQueryParams,
UtxoRefsAtAddressQueryParams,
UtxosByAddressQueryParams,
UtxosByAddressesQueryParams,
Expand Down Expand Up @@ -233,6 +234,49 @@ export const AddressesApiAxiosParamCreator = (configuration: Configuration) => (
options: localVarRequestOptions,
};
},
/**
* 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/).
* @summary Payment credentials transactions
* @param {Array<string>} requestBody Payment credentials in bech32 format
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
txsByPaymentCreds: (
requestBody: Array<string>,
localVarQueryParameter: TxsByPaymentCredsQueryParams = {},
options: AxiosRequestConfig = {},
): RequestArgs => {
// verify required parameter 'requestBody' is not null or undefined
assertParamExists('txsByPaymentCreds', 'requestBody', requestBody);
const localVarPath = `/addresses/cred/transactions`;
// 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 Record<string, string>;

// 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,
};
},
/**
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
* @summary UTxO references at an address
Expand Down Expand Up @@ -521,6 +565,22 @@ export const AddressesApiFp = (configuration: Configuration) => {
const localVarAxiosArgs = localVarAxiosParamCreator.txsByPaymentCred(credential, queryParams, options);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* 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/).
* @summary Payment credentials transactions
* @param {Array<string>} requestBody Payment credentials in bech32 format
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
txsByPaymentCreds(
requestBody: Array<string>,
queryParams?: TxsByPaymentCredsQueryParams,
options?: AxiosRequestConfig,
): () => Promise<PaginatedPaymentCredentialTransaction> {
const localVarAxiosArgs = localVarAxiosParamCreator.txsByPaymentCreds(requestBody, queryParams, options);
return createRequestFunction(localVarAxiosArgs, 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
Expand Down
18 changes: 18 additions & 0 deletions src/api/addresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AddressesApiFp } from './helpers';
import {
TxsByAddressQueryParams,
TxsByPaymentCredQueryParams,
TxsByPaymentCredsQueryParams,
UtxosByAddressQueryParams,
UtxosByAddressesQueryParams,
UtxosByPaymentCredQueryParams,
Expand Down Expand Up @@ -82,6 +83,23 @@ export class AddressesApi extends BaseAPI {
return AddressesApiFp(this.configuration).txsByPaymentCred(credential, queryParams, options)();
}

/**
* 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/).
* @summary Payment credentials transactions
* @param {Array<string>} requestBody Payment credentials in bech32 format
* @param {TxsByPaymentCredQueryParams} [localVarQueryParameter] Query parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public async txsByPaymentCreds(
requestBody: Array<string>,
queryParams?: TxsByPaymentCredsQueryParams,
options?: AxiosRequestConfig,
) {
const request = await AddressesApiFp(this.configuration).txsByPaymentCreds(requestBody, queryParams, options);
return request();
}

/**
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
* @summary UTxO references at an address
Expand Down
39 changes: 39 additions & 0 deletions src/api/addresses/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,45 @@ export interface TxsByPaymentCredQueryParams {
cursor?: string | null;
}

/**
* Query parameters for txsByPaymentCreds.
* @export
* @interface TxsByPaymentCredsQueryParams
*
*/
export interface TxsByPaymentCredsQueryParams {
/**
* The max number of results per page.
* @type {number | null}
* @memberof TxsByPaymentCredsQueryParams
*/
count?: number | null;
/**
* The order in which the results are sorted, by transaction age
* @type {TxsByPaymentCredOrderEnum}
* @memberof TxsByPaymentCredsQueryParams
*/
order?: TxsByPaymentCredOrderEnum;
/**
* Return only transactions minted on or after a specific slot
* @type {number | null}
* @memberof TxsByPaymentCredsQueryParams
*/
from?: number | null;
/**
* Return only transactions minted on or before a specific slot
* @type {number | null}
* @memberof TxsByPaymentCredsQueryParams
*/
to?: number | null;
/**
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
* @type {string | null}
* @memberof TxsByPaymentCredsQueryParams
*/
cursor?: string | null;
}

/**
* Query parameters for utxoRefsAtAddress.
* @export
Expand Down
12 changes: 9 additions & 3 deletions src/api/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,16 +1077,22 @@ export interface DelegatorInfo {
export interface EpochInfo {
/**
* Total active stake in the epoch
* @type {number}
* @type {string}
* @memberof EpochInfo
*/
active_stake?: string | null;
/**
* Average reward in the epoch
* @type {number}
* Average block reward in the epoch
* @type {string}
* @memberof EpochInfo
*/
average_reward?: string | null;
/**
* Total rewards in the epoch
* @type {string}
* @memberof EpochInfo
*/
total_rewards?: string | null;
/**
* Total blocks in the epoch
* @type {number}
Expand Down
3 changes: 1 addition & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,5 @@ export const createRequestFunction =
const axiosRequestArgs = { ...axiosArgs.options, url: configuration.baseUrl + axiosArgs.url };
return configuration.axiosInstance
.request<T, AxiosResponse<T>>(axiosRequestArgs)
.then((response) => response.data)
.catch((error) => error);
.then((response) => response.data);
};
Loading