@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
104 lines (100 loc) • 3.32 kB
text/typescript
/**
* Generated by orval v7.21.0 🍺
* Do not edit manually.
* Coinbase Developer Platform APIs
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
* OpenAPI spec version: 2.0.0
*/
import type {
Account,
AccountId,
Asset,
Balance,
CreateAccountRequest,
ListBalances200,
ListBalancesParams,
ListFoundationAccounts200,
ListFoundationAccountsParams,
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
import { cdpApiClient } from "../../cdpApiClient.js";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/**
* List all accounts. The API will return all accounts that the API Key has Permissions to access. You can filter the results by using query parameters, which will be treated as a single conjunction (i.e. AND). Results are sorted by creation date in descending order (newest first).
* @summary List accounts
*/
export const listFoundationAccounts = (
params?: ListFoundationAccountsParams,
options?: SecondParameter<typeof cdpApiClient<ListFoundationAccounts200>>,
) => {
return cdpApiClient<ListFoundationAccounts200>(
{ url: `/v2/accounts`, method: "GET", params },
options,
);
};
/**
* Create an account for your Entity. Support for creating Customer-owned accounts is in development.
* @summary Create account
*/
export const createFoundationAccount = (
createAccountRequest: CreateAccountRequest,
options?: SecondParameter<typeof cdpApiClient<Account>>,
) => {
return cdpApiClient<Account>(
{
url: `/v2/accounts`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: createAccountRequest,
},
options,
);
};
/**
* Get an account by its ID.
* @summary Get account
*/
export const getFoundationAccountById = (
accountId: AccountId,
options?: SecondParameter<typeof cdpApiClient<Account>>,
) => {
return cdpApiClient<Account>({ url: `/v2/accounts/${accountId}`, method: "GET" }, options);
};
/**
* List the balances for an account. Results are sorted by native-fiat equivalent balance in descending order.
* @summary List balances for account
*/
export const listBalances = (
accountId: AccountId,
params?: ListBalancesParams,
options?: SecondParameter<typeof cdpApiClient<ListBalances200>>,
) => {
return cdpApiClient<ListBalances200>(
{ url: `/v2/accounts/${accountId}/balances`, method: "GET", params },
options,
);
};
/**
* Get the balance for an account by asset.
* @summary Get balance for account
*/
export const getBalanceByAsset = (
accountId: AccountId,
asset: Asset,
options?: SecondParameter<typeof cdpApiClient<Balance>>,
) => {
return cdpApiClient<Balance>(
{ url: `/v2/accounts/${accountId}/balances/${asset}`, method: "GET" },
options,
);
};
export type ListFoundationAccountsResult = NonNullable<
Awaited<ReturnType<typeof listFoundationAccounts>>
>;
export type CreateFoundationAccountResult = NonNullable<
Awaited<ReturnType<typeof createFoundationAccount>>
>;
export type GetFoundationAccountByIdResult = NonNullable<
Awaited<ReturnType<typeof getFoundationAccountById>>
>;
export type ListBalancesResult = NonNullable<Awaited<ReturnType<typeof listBalances>>>;
export type GetBalanceByAssetResult = NonNullable<Awaited<ReturnType<typeof getBalanceByAsset>>>;