Skip to content

Commit

Permalink
Merge pull request #23 from vespr-wallet/alex/configure_axios
Browse files Browse the repository at this point in the history
Feat: Moved axios instance into Configuration and using it as single source of truth
  • Loading branch information
Vardominator authored Nov 2, 2023
2 parents 344f201 + 5cc22d4 commit cbb1924
Show file tree
Hide file tree
Showing 29 changed files with 143 additions and 141 deletions.
14 changes: 7 additions & 7 deletions src/api/accounts/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios';
import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios';
import { RequestArgs } from '../../base';
import {
assertParamExists,
Expand Down Expand Up @@ -420,7 +420,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAddress>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountAddresses(stakeAddr, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns a list of native assets which are owned by addresses with the specified stake key
Expand All @@ -436,7 +436,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAsset>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountAssets(stakeAddr, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns per-epoch history for the specified stake key
Expand All @@ -452,7 +452,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAccountHistory>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountHistory(stakeAddr, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns various information regarding a stake account
Expand All @@ -466,7 +466,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TimestampedAccountInfo>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountInfo(stakeAddr, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`)
Expand All @@ -482,7 +482,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAccountReward>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountRewards(stakeAddr, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`)
Expand All @@ -498,7 +498,7 @@ export const AccountsApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAccountUpdate>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.accountUpdates(stakeAddr, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
};
};
12 changes: 6 additions & 6 deletions src/api/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AccountsApi extends BaseAPI {
) {
return AccountsApiFp(this.configuration)
.accountAddresses(stakeAddr, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -47,7 +47,7 @@ export class AccountsApi extends BaseAPI {
public accountAssets(stakeAddr: string, queryParams?: AccountAssetsQueryParams, options?: AxiosRequestConfig) {
return AccountsApiFp(this.configuration)
.accountAssets(stakeAddr, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -62,7 +62,7 @@ export class AccountsApi extends BaseAPI {
public accountHistory(stakeAddr: string, queryParams?: AccountHistoryQueryParams, options?: AxiosRequestConfig) {
return AccountsApiFp(this.configuration)
.accountHistory(stakeAddr, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -76,7 +76,7 @@ export class AccountsApi extends BaseAPI {
public accountInfo(stakeAddr: string, options?: AxiosRequestConfig) {
return AccountsApiFp(this.configuration)
.accountInfo(stakeAddr, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -91,7 +91,7 @@ export class AccountsApi extends BaseAPI {
public accountRewards(stakeAddr: string, queryParams?: AccountRewardsQueryParams, options?: AxiosRequestConfig) {
return AccountsApiFp(this.configuration)
.accountRewards(stakeAddr, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -106,7 +106,7 @@ export class AccountsApi extends BaseAPI {
public accountUpdates(stakeAddr: string, queryParams?: AccountUpdatesQueryParams, options?: AxiosRequestConfig) {
return AccountsApiFp(this.configuration)
.accountUpdates(stakeAddr, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/api/addresses/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalAxios, { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios';
import { AxiosRequestConfig, AxiosInstance, AxiosPromise } from 'axios';
import { RequestArgs } from '../../base';
import {
assertParamExists,
Expand Down Expand Up @@ -383,7 +383,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AddressInfo>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.decodeAddress(address, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* 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/).
Expand All @@ -397,7 +397,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TimestampedTxCount>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.txCountByAddress(address, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns transactions in which the specified address spent or received funds. Specifically, the 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/).
Expand All @@ -413,7 +413,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedAddressTransaction>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.txsByAddress(address, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns transactions in which the specified payment credential spent or received funds. Specifically, the transactions where: the payment credential was 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/).
Expand All @@ -433,7 +433,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
queryParams,
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Returns references (pair of transaction hash and output index in transaction) for UTxOs controlled by the specified address
Expand All @@ -449,7 +449,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedUtxoRef>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.utxoRefsAtAddress(address, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Return detailed information on UTxOs controlled by an address
Expand All @@ -465,7 +465,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedUtxoWithSlot>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.utxosByAddress(address, queryParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Return detailed information on UTxOs which are controlled by some address in the specified list of addresses
Expand All @@ -485,7 +485,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
queryParams,
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
/**
* Return detailed information on UTxOs controlled by addresses which use the specified payment credential
Expand All @@ -505,7 +505,7 @@ export const AddressesApiFp = function (configuration: Configuration) {
queryParams,
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, configuration);
return createRequestFunction(localVarAxiosArgs, configuration);
},
};
};
Expand Down
16 changes: 8 additions & 8 deletions src/api/addresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AddressesApi extends BaseAPI {
public decodeAddress(address: string, options?: AxiosRequestConfig) {
return AddressesApiFp(this.configuration)
.decodeAddress(address, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -41,7 +41,7 @@ export class AddressesApi extends BaseAPI {
public txCountByAddress(address: string, options?: AxiosRequestConfig) {
return AddressesApiFp(this.configuration)
.txCountByAddress(address, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -56,7 +56,7 @@ export class AddressesApi extends BaseAPI {
public txsByAddress(address: string, queryParams?: TxsByAddressQueryParams, options?: AxiosRequestConfig) {
return AddressesApiFp(this.configuration)
.txsByAddress(address, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -75,7 +75,7 @@ export class AddressesApi extends BaseAPI {
) {
return AddressesApiFp(this.configuration)
.txsByPaymentCred(credential, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -90,7 +90,7 @@ export class AddressesApi extends BaseAPI {
public utxoRefsAtAddress(address: string, queryParams?: TxsByPaymentCredQueryParams, options?: AxiosRequestConfig) {
return AddressesApiFp(this.configuration)
.utxoRefsAtAddress(address, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -105,7 +105,7 @@ export class AddressesApi extends BaseAPI {
public utxosByAddress(address: string, queryParams?: UtxosByAddressQueryParams, options?: AxiosRequestConfig) {
return AddressesApiFp(this.configuration)
.utxosByAddress(address, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -124,7 +124,7 @@ export class AddressesApi extends BaseAPI {
) {
return AddressesApiFp(this.configuration)
.utxosByAddresses(requestBody, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}

/**
Expand All @@ -143,7 +143,7 @@ export class AddressesApi extends BaseAPI {
) {
return AddressesApiFp(this.configuration)
.utxosByPaymentCred(credential, queryParams, options)
.then((request) => request(this.axios));
.then((request) => request());
}
}

Expand Down
Loading

0 comments on commit cbb1924

Please sign in to comment.