@coinbase/cdp-sdk 1.5.0 → 1.7.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 +25 -0
- package/README.md +101 -3
- package/_cjs/accounts/evm/toEvmServerAccount.js +21 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +35 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +41 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_cjs/accounts/solana/types.js +3 -0
- package/_cjs/accounts/solana/types.js.map +1 -0
- package/_cjs/actions/evm/getUserOperation.js +36 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -0
- package/_cjs/actions/evm/listTokenBalances.js +33 -0
- package/_cjs/actions/evm/listTokenBalances.js.map +1 -0
- package/_cjs/actions/evm/requestFaucet.js +18 -0
- package/_cjs/actions/evm/requestFaucet.js.map +1 -0
- package/_cjs/actions/evm/sendTransaction.js +29 -0
- package/_cjs/actions/evm/sendTransaction.js.map +1 -0
- package/_cjs/actions/evm/sendUserOperation.js +5 -6
- package/_cjs/actions/evm/sendUserOperation.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +7 -3
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/solana/requestFaucet.js +29 -0
- package/_cjs/actions/solana/requestFaucet.js.map +1 -0
- package/_cjs/actions/solana/signMessage.js +29 -0
- package/_cjs/actions/solana/signMessage.js.map +1 -0
- package/_cjs/actions/solana/signTransaction.js +46 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -0
- package/_cjs/actions/solana/types.js +3 -0
- package/_cjs/actions/solana/types.js.map +1 -0
- package/_cjs/client/evm/evm.js +10 -52
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js +22 -17
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +3 -2
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +1 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +21 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +35 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +38 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_esm/accounts/solana/types.js +2 -0
- package/_esm/accounts/solana/types.js.map +1 -0
- package/_esm/actions/evm/getUserOperation.js +33 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -0
- package/_esm/actions/evm/listTokenBalances.js +30 -0
- package/_esm/actions/evm/listTokenBalances.js.map +1 -0
- package/_esm/actions/evm/requestFaucet.js +15 -0
- package/_esm/actions/evm/requestFaucet.js.map +1 -0
- package/_esm/actions/evm/sendTransaction.js +26 -0
- package/_esm/actions/evm/sendTransaction.js.map +1 -0
- package/_esm/actions/evm/sendUserOperation.js +5 -6
- package/_esm/actions/evm/sendUserOperation.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +7 -3
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/solana/requestFaucet.js +26 -0
- package/_esm/actions/solana/requestFaucet.js.map +1 -0
- package/_esm/actions/solana/signMessage.js +26 -0
- package/_esm/actions/solana/signMessage.js.map +1 -0
- package/_esm/actions/solana/signTransaction.js +43 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -0
- package/_esm/actions/solana/types.js +2 -0
- package/_esm/actions/solana/types.js.map +1 -0
- package/_esm/client/evm/evm.js +10 -52
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +22 -17
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +3 -2
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +1 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/{types.d.ts → evm/types.d.ts} +5 -5
- package/_types/accounts/evm/types.d.ts.map +1 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
- package/_types/accounts/solana/types.d.ts +12 -0
- package/_types/accounts/solana/types.d.ts.map +1 -0
- package/_types/actions/evm/getUserOperation.d.ts +22 -0
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
- package/_types/actions/evm/listTokenBalances.d.ts +76 -0
- package/_types/actions/evm/listTokenBalances.d.ts.map +1 -0
- package/_types/actions/evm/requestFaucet.d.ts +34 -0
- package/_types/actions/evm/requestFaucet.d.ts.map +1 -0
- package/_types/actions/evm/sendTransaction.d.ts +42 -0
- package/_types/actions/evm/sendTransaction.d.ts.map +1 -0
- package/_types/actions/evm/sendUserOperation.d.ts +4 -3
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +3 -3
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +41 -7
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +168 -3
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/requestFaucet.d.ts +23 -0
- package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
- package/_types/actions/solana/signMessage.d.ts +23 -0
- package/_types/actions/solana/signMessage.d.ts.map +1 -0
- package/_types/actions/solana/signTransaction.d.ts +38 -0
- package/_types/actions/solana/signTransaction.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +80 -0
- package/_types/actions/solana/types.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts +6 -3
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +12 -138
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +5 -4
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +8 -11
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +218 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +3 -2
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +1 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +35 -1
- package/accounts/evm/toEvmSmartAccount.ts +63 -1
- package/accounts/{types.ts → evm/types.ts} +5 -5
- package/accounts/solana/toSolanaAccount.ts +59 -0
- package/accounts/solana/types.ts +13 -0
- package/actions/evm/getUserOperation.ts +40 -0
- package/actions/evm/listTokenBalances.ts +107 -0
- package/actions/evm/requestFaucet.ts +46 -0
- package/actions/evm/sendTransaction.ts +73 -0
- package/actions/evm/sendUserOperation.ts +7 -7
- package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +14 -9
- package/actions/evm/transfer/transfer.ts +17 -6
- package/actions/evm/transfer/types.ts +55 -12
- package/actions/evm/types.ts +191 -3
- package/actions/solana/requestFaucet.ts +35 -0
- package/actions/solana/signMessage.ts +36 -0
- package/actions/solana/signTransaction.ts +53 -0
- package/actions/solana/types.ts +87 -0
- package/client/evm/evm.ts +28 -77
- package/client/evm/evm.types.ts +25 -151
- package/client/solana/solana.ts +32 -37
- package/client/solana/solana.types.ts +10 -15
- package/index.ts +1 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +274 -0
- package/openapi-client/generated/index.msw.ts +3 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
- package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
- package/openapi-client/index.ts +1 -0
- package/package.json +1 -1
- package/version.ts +1 -1
- package/_types/accounts/types.d.ts.map +0 -1
- /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
- /package/_esm/accounts/{types.js → evm/types.js} +0 -0
package/client/evm/evm.types.ts
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
EvmAccount as Account,
|
|
3
3
|
EvmServerAccount as ServerAccount,
|
|
4
4
|
EvmSmartAccount as SmartAccount,
|
|
5
|
-
} from "../../accounts/types.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
} from "../../accounts/evm/types.js";
|
|
6
|
+
import type {
|
|
7
|
+
ListTokenBalancesOptions,
|
|
8
|
+
ListTokenBalancesResult,
|
|
9
|
+
} from "../../actions/evm/listTokenBalances.js";
|
|
10
|
+
import type { RequestFaucetOptions, RequestFaucetResult } from "../../actions/evm/requestFaucet.js";
|
|
11
|
+
import type {
|
|
12
|
+
TransactionResult,
|
|
13
|
+
SendTransactionOptions,
|
|
14
|
+
} from "../../actions/evm/sendTransaction.js";
|
|
15
|
+
import type {
|
|
16
|
+
SendUserOperationOptions,
|
|
17
|
+
SendUserOperationReturnType,
|
|
18
|
+
} from "../../actions/evm/sendUserOperation.js";
|
|
19
|
+
import type { SmartAccountActions } from "../../actions/evm/types.js";
|
|
20
|
+
import type {
|
|
9
21
|
EvmUserOperationNetwork,
|
|
10
22
|
EvmUserOperationStatus,
|
|
11
23
|
OpenApiEvmMethods,
|
|
12
|
-
ListEvmTokenBalancesNetwork,
|
|
13
|
-
SendEvmTransactionBodyNetwork,
|
|
14
24
|
} from "../../openapi-client/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import { Address, Hex
|
|
17
|
-
import { WaitOptions } from "../../utils/wait.js";
|
|
25
|
+
import type { Calls } from "../../types/calls.js";
|
|
26
|
+
import type { Address, Hex } from "../../types/misc.js";
|
|
27
|
+
import type { WaitOptions } from "../../utils/wait.js";
|
|
18
28
|
|
|
19
29
|
/**
|
|
20
30
|
* The EvmClient type, where all OpenApiEvmMethods methods are wrapped.
|
|
@@ -50,7 +60,9 @@ export type EvmClientInterface = Omit<
|
|
|
50
60
|
prepareUserOperation: (options: PrepareUserOperationOptions) => Promise<UserOperation>;
|
|
51
61
|
requestFaucet: (options: RequestFaucetOptions) => Promise<RequestFaucetResult>;
|
|
52
62
|
sendTransaction: (options: SendTransactionOptions) => Promise<TransactionResult>;
|
|
53
|
-
sendUserOperation: (
|
|
63
|
+
sendUserOperation: (
|
|
64
|
+
options: SendUserOperationOptions<unknown[]>,
|
|
65
|
+
) => Promise<SendUserOperationReturnType>;
|
|
54
66
|
signHash: (options: SignHashOptions) => Promise<SignatureResult>;
|
|
55
67
|
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
56
68
|
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
@@ -169,7 +181,8 @@ export interface ListServerAccountsOptions {
|
|
|
169
181
|
/**
|
|
170
182
|
* A smart account that only contains the owner address.
|
|
171
183
|
*/
|
|
172
|
-
export interface ReadonlySmartAccount
|
|
184
|
+
export interface ReadonlySmartAccount
|
|
185
|
+
extends Omit<SmartAccount, "owners" | keyof SmartAccountActions> {
|
|
173
186
|
/** The owners of the smart account. */
|
|
174
187
|
owners: Address[];
|
|
175
188
|
}
|
|
@@ -222,67 +235,6 @@ export interface CreateSmartAccountOptions {
|
|
|
222
235
|
idempotencyKey?: string;
|
|
223
236
|
}
|
|
224
237
|
|
|
225
|
-
/**
|
|
226
|
-
* Options for requesting funds from an EVM faucet.
|
|
227
|
-
*/
|
|
228
|
-
export interface RequestFaucetOptions {
|
|
229
|
-
/** The address of the account. */
|
|
230
|
-
address: string;
|
|
231
|
-
/** The network to request funds from. */
|
|
232
|
-
network: "base-sepolia" | "ethereum-sepolia";
|
|
233
|
-
/** The token to request funds for. */
|
|
234
|
-
token: "eth" | "usdc" | "eurc" | "cbbtc";
|
|
235
|
-
/** The idempotency key. */
|
|
236
|
-
idempotencyKey?: string;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* The result of requesting funds from an EVM faucet.
|
|
241
|
-
*/
|
|
242
|
-
export interface RequestFaucetResult {
|
|
243
|
-
/** The transaction hash. */
|
|
244
|
-
transactionHash: Hex;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Options for sending an EVM transaction.
|
|
249
|
-
*/
|
|
250
|
-
export interface SendTransactionOptions {
|
|
251
|
-
/** The address of the account. */
|
|
252
|
-
address: Address;
|
|
253
|
-
/**
|
|
254
|
-
* The transaction to send. The chainId is ignored in favor of the `network` field.
|
|
255
|
-
*
|
|
256
|
-
* This can be either:
|
|
257
|
-
* - An RLP-encoded transaction to sign and send, as a 0x-prefixed hex string, or
|
|
258
|
-
* - An EIP-1559 transaction request object.
|
|
259
|
-
*/
|
|
260
|
-
transaction: Hex | TransactionRequestEIP1559;
|
|
261
|
-
/**
|
|
262
|
-
* The network to send the transaction to.
|
|
263
|
-
* The chainId in the `transaction` field is ignored in favor of this field.
|
|
264
|
-
*/
|
|
265
|
-
network: SendEvmTransactionBodyNetwork;
|
|
266
|
-
/** The idempotency key. */
|
|
267
|
-
idempotencyKey?: string;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Options for sending a user operation.
|
|
272
|
-
*/
|
|
273
|
-
export interface SendUserOperationOptions {
|
|
274
|
-
/** The smart account. */
|
|
275
|
-
smartAccount: SmartAccount;
|
|
276
|
-
/** The network. */
|
|
277
|
-
network: EvmUserOperationNetwork;
|
|
278
|
-
/** The calls. */
|
|
279
|
-
calls: Call[];
|
|
280
|
-
/** The paymaster URL. */
|
|
281
|
-
paymasterUrl?: string;
|
|
282
|
-
/** The idempotency key. */
|
|
283
|
-
idempotencyKey?: string;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
238
|
/**
|
|
287
239
|
* Options for signing an EVM hash.
|
|
288
240
|
*/
|
|
@@ -327,14 +279,6 @@ export interface SignatureResult {
|
|
|
327
279
|
signature: Hex;
|
|
328
280
|
}
|
|
329
281
|
|
|
330
|
-
/**
|
|
331
|
-
* Result of a transaction
|
|
332
|
-
*/
|
|
333
|
-
export interface TransactionResult {
|
|
334
|
-
/** The hash of the transaction. */
|
|
335
|
-
transactionHash: Hex;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
282
|
/**
|
|
339
283
|
* Options for waiting for a user operation.
|
|
340
284
|
*/
|
|
@@ -346,73 +290,3 @@ export interface WaitForUserOperationOptions {
|
|
|
346
290
|
/** The wait options. */
|
|
347
291
|
waitOptions?: WaitOptions;
|
|
348
292
|
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Options for listing EVM token balances.
|
|
352
|
-
*/
|
|
353
|
-
export interface ListTokenBalancesOptions {
|
|
354
|
-
/** The address of the account. */
|
|
355
|
-
address: Address;
|
|
356
|
-
/** The network. */
|
|
357
|
-
network: ListEvmTokenBalancesNetwork;
|
|
358
|
-
/** The page size to paginate through the token balances. */
|
|
359
|
-
pageSize?: number;
|
|
360
|
-
/** The page token to paginate through the token balances. */
|
|
361
|
-
pageToken?: string;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* A token on an EVM network, which is either an ERC-20 or a native token (i.e. ETH).
|
|
366
|
-
*/
|
|
367
|
-
export interface EvmToken {
|
|
368
|
-
/**
|
|
369
|
-
* The contract address of the token. For Ether, the contract address is 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
|
|
370
|
-
* per EIP-7528. For ERC-20 tokens, this is the contract address where the token is deployed.
|
|
371
|
-
*/
|
|
372
|
-
contractAddress: Address;
|
|
373
|
-
/** The network the token is on. */
|
|
374
|
-
network: ListEvmTokenBalancesNetwork;
|
|
375
|
-
/**
|
|
376
|
-
* The symbol of the token, which is optional and non-unique. Note: This field
|
|
377
|
-
* may not be present for most tokens while the API is still under development.
|
|
378
|
-
*/
|
|
379
|
-
symbol?: string;
|
|
380
|
-
/**
|
|
381
|
-
* The name of the token, which is optional and non-unique. Note: This field
|
|
382
|
-
* may not be present for most tokens while the API is still under development.
|
|
383
|
-
*/
|
|
384
|
-
name?: string;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* A token amount on an EVM network.
|
|
389
|
-
*/
|
|
390
|
-
export interface EvmTokenAmount {
|
|
391
|
-
/** The amount of the token in the smallest indivisible unit of the token. */
|
|
392
|
-
amount: bigint;
|
|
393
|
-
/** The number of decimals in the token. */
|
|
394
|
-
decimals: bigint;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* An EVM token balance.
|
|
399
|
-
*/
|
|
400
|
-
export interface EvmTokenBalance {
|
|
401
|
-
/** The token. */
|
|
402
|
-
token: EvmToken;
|
|
403
|
-
/** The amount of the token. */
|
|
404
|
-
amount: EvmTokenAmount;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* The result of listing EVM token balances.
|
|
409
|
-
*/
|
|
410
|
-
export interface ListTokenBalancesResult {
|
|
411
|
-
/** The token balances. */
|
|
412
|
-
balances: EvmTokenBalance[];
|
|
413
|
-
/**
|
|
414
|
-
* The next page token to paginate through the token balances.
|
|
415
|
-
* If undefined, there are no more token balances to paginate through.
|
|
416
|
-
*/
|
|
417
|
-
nextPageToken?: string;
|
|
418
|
-
}
|
package/client/solana/solana.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SolanaClientInterface,
|
|
3
|
-
Account,
|
|
4
2
|
CreateAccountOptions,
|
|
5
3
|
GetAccountOptions,
|
|
4
|
+
GetOrCreateAccountOptions,
|
|
6
5
|
ListAccountsOptions,
|
|
7
|
-
RequestFaucetOptions,
|
|
8
6
|
ListAccountsResult,
|
|
7
|
+
RequestFaucetOptions,
|
|
9
8
|
SignatureResult,
|
|
10
9
|
SignMessageOptions,
|
|
11
10
|
SignTransactionOptions,
|
|
12
|
-
|
|
11
|
+
SolanaClientInterface,
|
|
13
12
|
} from "./solana.types.js";
|
|
13
|
+
import { toSolanaAccount } from "../../accounts/solana/toSolanaAccount.js";
|
|
14
|
+
import { SolanaAccount } from "../../accounts/solana/types.js";
|
|
15
|
+
import { requestFaucet } from "../../actions/solana/requestFaucet.js";
|
|
16
|
+
import { signMessage } from "../../actions/solana/signMessage.js";
|
|
17
|
+
import { signTransaction } from "../../actions/solana/signTransaction.js";
|
|
14
18
|
import { APIError } from "../../openapi-client/errors.js";
|
|
15
19
|
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
16
20
|
|
|
@@ -48,8 +52,12 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
48
52
|
* await cdp.solana.createAccount({ idempotencyKey });
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
|
-
async createAccount(options: CreateAccountOptions = {}): Promise<
|
|
52
|
-
|
|
55
|
+
async createAccount(options: CreateAccountOptions = {}): Promise<SolanaAccount> {
|
|
56
|
+
const account = await CdpOpenApiClient.createSolanaAccount(options, options.idempotencyKey);
|
|
57
|
+
|
|
58
|
+
return toSolanaAccount(CdpOpenApiClient, {
|
|
59
|
+
account,
|
|
60
|
+
});
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
/**
|
|
@@ -77,13 +85,19 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
77
85
|
* });
|
|
78
86
|
* ```
|
|
79
87
|
*/
|
|
80
|
-
async getAccount(options: GetAccountOptions): Promise<
|
|
88
|
+
async getAccount(options: GetAccountOptions): Promise<SolanaAccount> {
|
|
81
89
|
if (options.address) {
|
|
82
|
-
|
|
90
|
+
const account = await CdpOpenApiClient.getSolanaAccount(options.address);
|
|
91
|
+
return toSolanaAccount(CdpOpenApiClient, {
|
|
92
|
+
account,
|
|
93
|
+
});
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
if (options.name) {
|
|
86
|
-
|
|
97
|
+
const account = await CdpOpenApiClient.getSolanaAccountByName(options.name);
|
|
98
|
+
return toSolanaAccount(CdpOpenApiClient, {
|
|
99
|
+
account,
|
|
100
|
+
});
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
throw new Error("Either address or name must be provided");
|
|
@@ -104,7 +118,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
104
118
|
* });
|
|
105
119
|
* ```
|
|
106
120
|
*/
|
|
107
|
-
async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<
|
|
121
|
+
async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<SolanaAccount> {
|
|
108
122
|
try {
|
|
109
123
|
const account = await this.getAccount(options);
|
|
110
124
|
return account;
|
|
@@ -165,7 +179,11 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
165
179
|
});
|
|
166
180
|
|
|
167
181
|
return {
|
|
168
|
-
accounts: solAccounts.accounts
|
|
182
|
+
accounts: solAccounts.accounts.map(account =>
|
|
183
|
+
toSolanaAccount(CdpOpenApiClient, {
|
|
184
|
+
account,
|
|
185
|
+
}),
|
|
186
|
+
),
|
|
169
187
|
nextPageToken: solAccounts.nextPageToken,
|
|
170
188
|
};
|
|
171
189
|
}
|
|
@@ -189,14 +207,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
189
207
|
* ```
|
|
190
208
|
*/
|
|
191
209
|
async requestFaucet(options: RequestFaucetOptions): Promise<SignatureResult> {
|
|
192
|
-
|
|
193
|
-
{ address: options.address, token: options.token },
|
|
194
|
-
options.idempotencyKey,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
signature: signature.transactionSignature,
|
|
199
|
-
};
|
|
210
|
+
return requestFaucet(CdpOpenApiClient, options);
|
|
200
211
|
}
|
|
201
212
|
|
|
202
213
|
/**
|
|
@@ -222,13 +233,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
222
233
|
* ```
|
|
223
234
|
*/
|
|
224
235
|
async signMessage(options: SignMessageOptions): Promise<SignatureResult> {
|
|
225
|
-
return CdpOpenApiClient
|
|
226
|
-
options.address,
|
|
227
|
-
{
|
|
228
|
-
message: options.message,
|
|
229
|
-
},
|
|
230
|
-
options.idempotencyKey,
|
|
231
|
-
);
|
|
236
|
+
return signMessage(CdpOpenApiClient, options);
|
|
232
237
|
}
|
|
233
238
|
|
|
234
239
|
/**
|
|
@@ -265,16 +270,6 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
265
270
|
* ```
|
|
266
271
|
*/
|
|
267
272
|
async signTransaction(options: SignTransactionOptions): Promise<SignatureResult> {
|
|
268
|
-
|
|
269
|
-
options.address,
|
|
270
|
-
{
|
|
271
|
-
transaction: options.transaction,
|
|
272
|
-
},
|
|
273
|
-
options.idempotencyKey,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
return {
|
|
277
|
-
signature: signature.signedTransaction,
|
|
278
|
-
};
|
|
273
|
+
return signTransaction(CdpOpenApiClient, options);
|
|
279
274
|
}
|
|
280
275
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../../openapi-client/index.js";
|
|
1
|
+
import { Account, SolanaAccount } from "../../accounts/solana/types.js";
|
|
2
|
+
import { OpenApiSolanaMethods } from "../../openapi-client/index.js";
|
|
3
|
+
|
|
5
4
|
/**
|
|
6
5
|
* The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
|
|
7
6
|
*/
|
|
@@ -23,10 +22,14 @@ export type SolanaClientInterface = Omit<
|
|
|
23
22
|
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
24
23
|
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
25
24
|
};
|
|
25
|
+
|
|
26
26
|
/**
|
|
27
|
-
* A Solana
|
|
27
|
+
* A Solana signature result.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export interface SignatureResult {
|
|
30
|
+
/** The signature. */
|
|
31
|
+
signature: string;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Options for creating a Solana account.
|
|
@@ -71,7 +74,7 @@ export interface ListAccountsOptions {
|
|
|
71
74
|
*/
|
|
72
75
|
export interface ListAccountsResult {
|
|
73
76
|
/** The accounts. */
|
|
74
|
-
accounts:
|
|
77
|
+
accounts: SolanaAccount[];
|
|
75
78
|
/**
|
|
76
79
|
* The token for the next page of accounts, if any.
|
|
77
80
|
*/
|
|
@@ -113,11 +116,3 @@ export interface SignTransactionOptions {
|
|
|
113
116
|
/** The idempotency key. */
|
|
114
117
|
idempotencyKey?: string;
|
|
115
118
|
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A Solana signature result.
|
|
119
|
-
*/
|
|
120
|
-
export interface SignatureResult {
|
|
121
|
-
/** The signature. */
|
|
122
|
-
signature: string;
|
|
123
|
-
}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { CdpClient } from "./client/cdp.js";
|
|
2
|
-
export type { EvmServerAccount, EvmSmartAccount } from "./accounts/types.js";
|
|
2
|
+
export type { EvmServerAccount, EvmSmartAccount } from "./accounts/evm/types.js";
|