@coinbase/cdp-sdk 1.24.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/_cjs/accounts/evm/networkToChainResolver.js +68 -0
- package/_cjs/accounts/evm/networkToChainResolver.js.map +1 -0
- package/_cjs/accounts/evm/resolveViemClients.js +3 -30
- package/_cjs/accounts/evm/resolveViemClients.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +10 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +0 -7
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/client/solana/solana.js +39 -0
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +7 -2
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +1 -0
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js +15 -0
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -0
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.msw.js +43 -0
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +3 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/networkToChainResolver.js +31 -0
- package/_esm/accounts/evm/networkToChainResolver.js.map +1 -0
- package/_esm/accounts/evm/resolveViemClients.js +1 -28
- package/_esm/accounts/evm/resolveViemClients.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +10 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +0 -7
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/client/solana/solana.js +39 -0
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +5 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +1 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js +11 -0
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -0
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.msw.js +37 -0
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +3 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/networkToChainResolver.d.ts +14 -0
- package/_types/accounts/evm/networkToChainResolver.d.ts.map +1 -0
- package/_types/accounts/evm/resolveViemClients.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -3
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +36 -3
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +19 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +51 -2
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +61 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts +20 -0
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts.map +1 -0
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.msw.d.ts +6 -0
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +2 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/networkToChainResolver.ts +34 -0
- package/accounts/evm/resolveViemClients.ts +1 -30
- package/accounts/evm/toEvmSmartAccount.ts +18 -2
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +0 -8
- package/accounts/evm/types.ts +3 -3
- package/actions/evm/types.ts +41 -2
- package/client/solana/solana.ts +47 -0
- package/client/solana/solana.types.ts +60 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +71 -0
- package/openapi-client/generated/index.msw.ts +1 -0
- package/openapi-client/generated/solana-token-balances/solana-token-balances.msw.ts +55 -0
- package/openapi-client/generated/solana-token-balances/solana-token-balances.ts +37 -0
- package/openapi-client/index.ts +3 -0
- package/package.json +1 -1
- package/version.ts +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Account, SolanaAccount } from "../../accounts/solana/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ListSolanaTokenBalancesNetwork,
|
|
4
|
+
OpenApiSolanaMethods,
|
|
5
|
+
UpdateSolanaAccountBody,
|
|
6
|
+
} from "../../openapi-client/index.js";
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
|
|
@@ -18,6 +22,7 @@ export type SolanaClientInterface = Omit<
|
|
|
18
22
|
| "exportSolanaAccount" // mapped to exportAccount
|
|
19
23
|
| "exportSolanaAccountByName" // mapped to exportAccount
|
|
20
24
|
| "importSolanaAccount" // mapped to importAccount
|
|
25
|
+
| "listSolanaTokenBalances" // mapped to listTokenBalances
|
|
21
26
|
> & {
|
|
22
27
|
createAccount: (options: CreateAccountOptions) => Promise<Account>;
|
|
23
28
|
exportAccount: (options: ExportAccountOptions) => Promise<string>;
|
|
@@ -29,6 +34,7 @@ export type SolanaClientInterface = Omit<
|
|
|
29
34
|
requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
|
|
30
35
|
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
31
36
|
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
37
|
+
listTokenBalances: (options: ListTokenBalancesOptions) => Promise<ListTokenBalancesResult>;
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
/**
|
|
@@ -164,3 +170,56 @@ export interface ImportAccountOptions {
|
|
|
164
170
|
/** The private key of the account - can be a base58 encoded string or raw bytes. */
|
|
165
171
|
privateKey: string | Uint8Array;
|
|
166
172
|
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Options for listing Solana token balances.
|
|
176
|
+
*/
|
|
177
|
+
export interface ListTokenBalancesOptions {
|
|
178
|
+
/** The address of the account. */
|
|
179
|
+
address: string;
|
|
180
|
+
/** The network to list token balances for. */
|
|
181
|
+
network?: ListSolanaTokenBalancesNetwork;
|
|
182
|
+
/** The page size. */
|
|
183
|
+
pageSize?: number;
|
|
184
|
+
/** The page token. */
|
|
185
|
+
pageToken?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface SolanaTokenAmount {
|
|
189
|
+
/** The amount of the token. */
|
|
190
|
+
amount: bigint;
|
|
191
|
+
/** The number of decimals in the token. */
|
|
192
|
+
decimals: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface SolanaToken {
|
|
196
|
+
/** The token address. */
|
|
197
|
+
mintAddress: string;
|
|
198
|
+
/** The token name. */
|
|
199
|
+
name?: string;
|
|
200
|
+
/** The token symbol. */
|
|
201
|
+
symbol?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A Solana token balance.
|
|
206
|
+
*/
|
|
207
|
+
export interface SolanaTokenBalance {
|
|
208
|
+
/** The amount of the token. */
|
|
209
|
+
amount: SolanaTokenAmount;
|
|
210
|
+
/** The token. */
|
|
211
|
+
token: SolanaToken;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The result of listing Solana token balances.
|
|
216
|
+
*/
|
|
217
|
+
export interface ListTokenBalancesResult {
|
|
218
|
+
/** The token balances. */
|
|
219
|
+
balances: SolanaTokenBalance[];
|
|
220
|
+
/**
|
|
221
|
+
* The next page token to paginate through the token balances.
|
|
222
|
+
* If undefined, there are no more token balances to paginate through.
|
|
223
|
+
*/
|
|
224
|
+
nextPageToken?: string;
|
|
225
|
+
}
|
|
@@ -1432,6 +1432,59 @@ Account names are guaranteed to be unique across all Solana accounts in the deve
|
|
|
1432
1432
|
updatedAt?: string;
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
1435
|
+
/**
|
|
1436
|
+
* The name of the supported Solana networks in human-readable format.
|
|
1437
|
+
*/
|
|
1438
|
+
export type ListSolanaTokenBalancesNetwork =
|
|
1439
|
+
(typeof ListSolanaTokenBalancesNetwork)[keyof typeof ListSolanaTokenBalancesNetwork];
|
|
1440
|
+
|
|
1441
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
1442
|
+
export const ListSolanaTokenBalancesNetwork = {
|
|
1443
|
+
solana: "solana",
|
|
1444
|
+
"solana-devnet": "solana-devnet",
|
|
1445
|
+
} as const;
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Amount of a given Solana token.
|
|
1449
|
+
*/
|
|
1450
|
+
export interface SolanaTokenAmount {
|
|
1451
|
+
/**
|
|
1452
|
+
* The amount is denominated in the smallest indivisible unit of the token. For SOL, the smallest indivisible unit is lamports (10^-9 SOL). For SPL tokens, the smallest unit is defined by the token's decimals configuration.
|
|
1453
|
+
* @pattern ^[0-9]+$
|
|
1454
|
+
*/
|
|
1455
|
+
amount: string;
|
|
1456
|
+
/** 'decimals' is the exponential value N that satisfies the equation `amount * 10^-N = standard_denomination`. The standard denomination is the most commonly used denomination for the token.
|
|
1457
|
+
- For native SOL, `decimals` is 9 (1 SOL = 10^9 lamports). - For SPL tokens, `decimals` is defined in the token's mint configuration. */
|
|
1458
|
+
decimals: number;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* General information about a Solana token. Includes the mint address, and other identifying information.
|
|
1463
|
+
*/
|
|
1464
|
+
export interface SolanaToken {
|
|
1465
|
+
/** The symbol of this token (ex: SOL, USDC, RAY).
|
|
1466
|
+
The token symbol is not unique. It is possible for two different tokens to have the same symbol.
|
|
1467
|
+
For the native SOL token, this symbol is "SOL". For SPL tokens, this symbol is defined in the token's metadata.
|
|
1468
|
+
Not all tokens have a symbol. This field will only be populated when the token has metadata available. */
|
|
1469
|
+
symbol?: string;
|
|
1470
|
+
/** The name of this token (ex: "Solana", "USD Coin", "Raydium").
|
|
1471
|
+
The token name is not unique. It is possible for two different tokens to have the same name.
|
|
1472
|
+
For the native SOL token, this name is "Solana". For SPL tokens, this name is defined in the token's metadata.
|
|
1473
|
+
Not all tokens have a name. This field will only be populated when the token has metadata available. */
|
|
1474
|
+
name?: string;
|
|
1475
|
+
/**
|
|
1476
|
+
* The mint address of the token.
|
|
1477
|
+
For native SOL, the mint address is `So11111111111111111111111111111111111111111`. For SPL tokens, this is the mint address where the token is defined.
|
|
1478
|
+
* @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
|
|
1479
|
+
*/
|
|
1480
|
+
mintAddress: string;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
export interface SolanaTokenBalance {
|
|
1484
|
+
amount: SolanaTokenAmount;
|
|
1485
|
+
token: SolanaToken;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1435
1488
|
/**
|
|
1436
1489
|
* The action of the payment method.
|
|
1437
1490
|
*/
|
|
@@ -2226,6 +2279,24 @@ export type RequestSolanaFaucet200 = {
|
|
|
2226
2279
|
transactionSignature: string;
|
|
2227
2280
|
};
|
|
2228
2281
|
|
|
2282
|
+
export type ListSolanaTokenBalancesParams = {
|
|
2283
|
+
/**
|
|
2284
|
+
* The number of balances to return per page.
|
|
2285
|
+
*/
|
|
2286
|
+
pageSize?: number;
|
|
2287
|
+
/**
|
|
2288
|
+
* The token for the next page of balances. Will be empty if there are no more balances to fetch.
|
|
2289
|
+
*/
|
|
2290
|
+
pageToken?: string;
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
export type ListSolanaTokenBalances200AllOf = {
|
|
2294
|
+
/** The list of Solana token balances. */
|
|
2295
|
+
balances: SolanaTokenBalance[];
|
|
2296
|
+
};
|
|
2297
|
+
|
|
2298
|
+
export type ListSolanaTokenBalances200 = ListSolanaTokenBalances200AllOf & ListResponse;
|
|
2299
|
+
|
|
2229
2300
|
export type GetCryptoRailsParams = {
|
|
2230
2301
|
/**
|
|
2231
2302
|
* Comma separated list of networks to filter the rails by.
|
|
@@ -6,3 +6,4 @@ export * from "./faucets/faucets.msw.js";
|
|
|
6
6
|
export * from "./payments-alpha/payments-alpha.msw.js";
|
|
7
7
|
export * from "./policy-engine/policy-engine.msw.js";
|
|
8
8
|
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
9
|
+
export * from "./solana-token-balances/solana-token-balances.msw.js";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type { ListSolanaTokenBalances200 } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
13
|
+
|
|
14
|
+
export const getListSolanaTokenBalancesResponseMock = (): ListSolanaTokenBalances200 => ({
|
|
15
|
+
...{
|
|
16
|
+
balances: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
17
|
+
() => ({
|
|
18
|
+
amount: {
|
|
19
|
+
amount: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
20
|
+
decimals: faker.number.int({ min: undefined, max: undefined }),
|
|
21
|
+
},
|
|
22
|
+
token: {
|
|
23
|
+
symbol: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
24
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
25
|
+
mintAddress: faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
},
|
|
30
|
+
...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const getListSolanaTokenBalancesMockHandler = (
|
|
34
|
+
overrideResponse?:
|
|
35
|
+
| ListSolanaTokenBalances200
|
|
36
|
+
| ((
|
|
37
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
38
|
+
) => Promise<ListSolanaTokenBalances200> | ListSolanaTokenBalances200),
|
|
39
|
+
) => {
|
|
40
|
+
return http.get("*/v2/solana/token-balances/:network/:address", async info => {
|
|
41
|
+
await delay(0);
|
|
42
|
+
|
|
43
|
+
return new HttpResponse(
|
|
44
|
+
JSON.stringify(
|
|
45
|
+
overrideResponse !== undefined
|
|
46
|
+
? typeof overrideResponse === "function"
|
|
47
|
+
? await overrideResponse(info)
|
|
48
|
+
: overrideResponse
|
|
49
|
+
: getListSolanaTokenBalancesResponseMock(),
|
|
50
|
+
),
|
|
51
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export const getSolanaTokenBalancesMock = () => [getListSolanaTokenBalancesMockHandler()];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
ListSolanaTokenBalances200,
|
|
10
|
+
ListSolanaTokenBalancesNetwork,
|
|
11
|
+
ListSolanaTokenBalancesParams,
|
|
12
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
13
|
+
|
|
14
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
15
|
+
|
|
16
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lists the token balances of a Solana address on a given network. The balances include SPL tokens and the native SOL token. The response is paginated, and by default, returns 20 balances per page.
|
|
20
|
+
|
|
21
|
+
**Note:** This endpoint is still under development and does not yet provide strong availability or freshness guarantees. Freshness and availability of new token balances will improve over the coming weeks.
|
|
22
|
+
* @summary List Solana token balances
|
|
23
|
+
*/
|
|
24
|
+
export const listSolanaTokenBalances = (
|
|
25
|
+
network: ListSolanaTokenBalancesNetwork,
|
|
26
|
+
address: string,
|
|
27
|
+
params?: ListSolanaTokenBalancesParams,
|
|
28
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
29
|
+
) => {
|
|
30
|
+
return cdpApiClient<ListSolanaTokenBalances200>(
|
|
31
|
+
{ url: `/v2/solana/token-balances/${network}/${address}`, method: "GET", params },
|
|
32
|
+
options,
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
export type ListSolanaTokenBalancesResult = NonNullable<
|
|
36
|
+
Awaited<ReturnType<typeof listSolanaTokenBalances>>
|
|
37
|
+
>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
|
4
4
|
export * from "./generated/evm-swaps/evm-swaps.js";
|
|
5
5
|
export * from "./generated/evm-token-balances/evm-token-balances.js";
|
|
6
6
|
export * from "./generated/solana-accounts/solana-accounts.js";
|
|
7
|
+
export * from "./generated/solana-token-balances/solana-token-balances.js";
|
|
7
8
|
export * from "./generated/faucets/faucets.js";
|
|
8
9
|
export * from "./generated/policy-engine/policy-engine.js";
|
|
9
10
|
export * from "./generated/payments-alpha/payments-alpha.js";
|
|
@@ -17,6 +18,7 @@ import * as faucets from "./generated/faucets/faucets.js";
|
|
|
17
18
|
import * as payments from "./generated/payments-alpha/payments-alpha.js";
|
|
18
19
|
import * as policies from "./generated/policy-engine/policy-engine.js";
|
|
19
20
|
import * as solana from "./generated/solana-accounts/solana-accounts.js";
|
|
21
|
+
import * as solanaTokenBalances from "./generated/solana-token-balances/solana-token-balances.js";
|
|
20
22
|
|
|
21
23
|
export const CdpOpenApiClient = {
|
|
22
24
|
...evm,
|
|
@@ -24,6 +26,7 @@ export const CdpOpenApiClient = {
|
|
|
24
26
|
...evmSwaps,
|
|
25
27
|
...evmTokenBalances,
|
|
26
28
|
...solana,
|
|
29
|
+
...solanaTokenBalances,
|
|
27
30
|
...faucets,
|
|
28
31
|
...policies,
|
|
29
32
|
...payments,
|
package/package.json
CHANGED
package/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.26.0";
|