@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.
Files changed (191) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +101 -3
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +21 -0
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js +35 -0
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  7. package/_cjs/accounts/{types.js.map → evm/types.js.map} +1 -1
  8. package/_cjs/accounts/solana/toSolanaAccount.js +41 -0
  9. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
  10. package/_cjs/accounts/solana/types.js +3 -0
  11. package/_cjs/accounts/solana/types.js.map +1 -0
  12. package/_cjs/actions/evm/getUserOperation.js +36 -0
  13. package/_cjs/actions/evm/getUserOperation.js.map +1 -0
  14. package/_cjs/actions/evm/listTokenBalances.js +33 -0
  15. package/_cjs/actions/evm/listTokenBalances.js.map +1 -0
  16. package/_cjs/actions/evm/requestFaucet.js +18 -0
  17. package/_cjs/actions/evm/requestFaucet.js.map +1 -0
  18. package/_cjs/actions/evm/sendTransaction.js +29 -0
  19. package/_cjs/actions/evm/sendTransaction.js.map +1 -0
  20. package/_cjs/actions/evm/sendUserOperation.js +5 -6
  21. package/_cjs/actions/evm/sendUserOperation.js.map +1 -1
  22. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
  23. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  24. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
  25. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  26. package/_cjs/actions/evm/transfer/transfer.js +7 -3
  27. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  28. package/_cjs/actions/solana/requestFaucet.js +29 -0
  29. package/_cjs/actions/solana/requestFaucet.js.map +1 -0
  30. package/_cjs/actions/solana/signMessage.js +29 -0
  31. package/_cjs/actions/solana/signMessage.js.map +1 -0
  32. package/_cjs/actions/solana/signTransaction.js +46 -0
  33. package/_cjs/actions/solana/signTransaction.js.map +1 -0
  34. package/_cjs/actions/solana/types.js +3 -0
  35. package/_cjs/actions/solana/types.js.map +1 -0
  36. package/_cjs/client/evm/evm.js +10 -52
  37. package/_cjs/client/evm/evm.js.map +1 -1
  38. package/_cjs/client/solana/solana.js +22 -17
  39. package/_cjs/client/solana/solana.js.map +1 -1
  40. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
  41. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  42. package/_cjs/openapi-client/generated/index.msw.js +3 -2
  43. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  44. package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
  45. package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
  46. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
  47. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
  48. package/_cjs/openapi-client/index.js +1 -0
  49. package/_cjs/openapi-client/index.js.map +1 -1
  50. package/_cjs/version.js +1 -1
  51. package/_esm/accounts/evm/toEvmServerAccount.js +21 -0
  52. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  53. package/_esm/accounts/evm/toEvmSmartAccount.js +35 -0
  54. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  55. package/_esm/accounts/{types.js.map → evm/types.js.map} +1 -1
  56. package/_esm/accounts/solana/toSolanaAccount.js +38 -0
  57. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
  58. package/_esm/accounts/solana/types.js +2 -0
  59. package/_esm/accounts/solana/types.js.map +1 -0
  60. package/_esm/actions/evm/getUserOperation.js +33 -0
  61. package/_esm/actions/evm/getUserOperation.js.map +1 -0
  62. package/_esm/actions/evm/listTokenBalances.js +30 -0
  63. package/_esm/actions/evm/listTokenBalances.js.map +1 -0
  64. package/_esm/actions/evm/requestFaucet.js +15 -0
  65. package/_esm/actions/evm/requestFaucet.js.map +1 -0
  66. package/_esm/actions/evm/sendTransaction.js +26 -0
  67. package/_esm/actions/evm/sendTransaction.js.map +1 -0
  68. package/_esm/actions/evm/sendUserOperation.js +5 -6
  69. package/_esm/actions/evm/sendUserOperation.js.map +1 -1
  70. package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
  71. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  72. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
  73. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  74. package/_esm/actions/evm/transfer/transfer.js +7 -3
  75. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  76. package/_esm/actions/solana/requestFaucet.js +26 -0
  77. package/_esm/actions/solana/requestFaucet.js.map +1 -0
  78. package/_esm/actions/solana/signMessage.js +26 -0
  79. package/_esm/actions/solana/signMessage.js.map +1 -0
  80. package/_esm/actions/solana/signTransaction.js +43 -0
  81. package/_esm/actions/solana/signTransaction.js.map +1 -0
  82. package/_esm/actions/solana/types.js +2 -0
  83. package/_esm/actions/solana/types.js.map +1 -0
  84. package/_esm/client/evm/evm.js +10 -52
  85. package/_esm/client/evm/evm.js.map +1 -1
  86. package/_esm/client/solana/solana.js +22 -17
  87. package/_esm/client/solana/solana.js.map +1 -1
  88. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
  89. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  90. package/_esm/openapi-client/generated/index.msw.js +3 -2
  91. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  92. package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
  93. package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
  94. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
  95. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
  96. package/_esm/openapi-client/index.js +1 -0
  97. package/_esm/openapi-client/index.js.map +1 -1
  98. package/_esm/version.js +1 -1
  99. package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
  100. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  101. package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
  102. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  103. package/_types/accounts/{types.d.ts → evm/types.d.ts} +5 -5
  104. package/_types/accounts/evm/types.d.ts.map +1 -0
  105. package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
  106. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
  107. package/_types/accounts/solana/types.d.ts +12 -0
  108. package/_types/accounts/solana/types.d.ts.map +1 -0
  109. package/_types/actions/evm/getUserOperation.d.ts +22 -0
  110. package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
  111. package/_types/actions/evm/listTokenBalances.d.ts +76 -0
  112. package/_types/actions/evm/listTokenBalances.d.ts.map +1 -0
  113. package/_types/actions/evm/requestFaucet.d.ts +34 -0
  114. package/_types/actions/evm/requestFaucet.d.ts.map +1 -0
  115. package/_types/actions/evm/sendTransaction.d.ts +42 -0
  116. package/_types/actions/evm/sendTransaction.d.ts.map +1 -0
  117. package/_types/actions/evm/sendUserOperation.d.ts +4 -3
  118. package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
  119. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
  120. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  121. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
  122. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  123. package/_types/actions/evm/transfer/transfer.d.ts +3 -3
  124. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  125. package/_types/actions/evm/transfer/types.d.ts +41 -7
  126. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  127. package/_types/actions/evm/types.d.ts +168 -3
  128. package/_types/actions/evm/types.d.ts.map +1 -1
  129. package/_types/actions/solana/requestFaucet.d.ts +23 -0
  130. package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
  131. package/_types/actions/solana/signMessage.d.ts +23 -0
  132. package/_types/actions/solana/signMessage.d.ts.map +1 -0
  133. package/_types/actions/solana/signTransaction.d.ts +38 -0
  134. package/_types/actions/solana/signTransaction.d.ts.map +1 -0
  135. package/_types/actions/solana/types.d.ts +80 -0
  136. package/_types/actions/solana/types.d.ts.map +1 -0
  137. package/_types/client/evm/evm.d.ts +6 -3
  138. package/_types/client/evm/evm.d.ts.map +1 -1
  139. package/_types/client/evm/evm.types.d.ts +12 -138
  140. package/_types/client/evm/evm.types.d.ts.map +1 -1
  141. package/_types/client/solana/solana.d.ts +5 -4
  142. package/_types/client/solana/solana.d.ts.map +1 -1
  143. package/_types/client/solana/solana.types.d.ts +8 -11
  144. package/_types/client/solana/solana.types.d.ts.map +1 -1
  145. package/_types/index.d.ts +1 -1
  146. package/_types/index.d.ts.map +1 -1
  147. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +218 -0
  148. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  149. package/_types/openapi-client/generated/index.msw.d.ts +3 -2
  150. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  151. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
  152. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
  153. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
  154. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
  155. package/_types/openapi-client/index.d.ts +1 -0
  156. package/_types/openapi-client/index.d.ts.map +1 -1
  157. package/_types/version.d.ts +1 -1
  158. package/accounts/evm/toEvmServerAccount.ts +35 -1
  159. package/accounts/evm/toEvmSmartAccount.ts +63 -1
  160. package/accounts/{types.ts → evm/types.ts} +5 -5
  161. package/accounts/solana/toSolanaAccount.ts +59 -0
  162. package/accounts/solana/types.ts +13 -0
  163. package/actions/evm/getUserOperation.ts +40 -0
  164. package/actions/evm/listTokenBalances.ts +107 -0
  165. package/actions/evm/requestFaucet.ts +46 -0
  166. package/actions/evm/sendTransaction.ts +73 -0
  167. package/actions/evm/sendUserOperation.ts +7 -7
  168. package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
  169. package/actions/evm/transfer/smartAccountTransferStrategy.ts +14 -9
  170. package/actions/evm/transfer/transfer.ts +17 -6
  171. package/actions/evm/transfer/types.ts +55 -12
  172. package/actions/evm/types.ts +191 -3
  173. package/actions/solana/requestFaucet.ts +35 -0
  174. package/actions/solana/signMessage.ts +36 -0
  175. package/actions/solana/signTransaction.ts +53 -0
  176. package/actions/solana/types.ts +87 -0
  177. package/client/evm/evm.ts +28 -77
  178. package/client/evm/evm.types.ts +25 -151
  179. package/client/solana/solana.ts +32 -37
  180. package/client/solana/solana.types.ts +10 -15
  181. package/index.ts +1 -1
  182. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +274 -0
  183. package/openapi-client/generated/index.msw.ts +3 -2
  184. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
  185. package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
  186. package/openapi-client/index.ts +1 -0
  187. package/package.json +1 -1
  188. package/version.ts +1 -1
  189. package/_types/accounts/types.d.ts.map +0 -1
  190. /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
  191. /package/_esm/accounts/{types.js → evm/types.js} +0 -0
@@ -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 { SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
7
- import { Actions } from "../../actions/evm/types.js";
8
- import {
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 { Call, Calls } from "../../types/calls.js";
16
- import { Address, Hex, TransactionRequestEIP1559 } from "../../types/misc.js";
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: (options: SendUserOperationOptions) => Promise<SendUserOperationReturnType>;
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 extends Omit<SmartAccount, "owners" | keyof Actions> {
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
- }
@@ -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
- GetOrCreateAccountOptions,
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<Account> {
52
- return CdpOpenApiClient.createSolanaAccount(options, options.idempotencyKey);
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<Account> {
88
+ async getAccount(options: GetAccountOptions): Promise<SolanaAccount> {
81
89
  if (options.address) {
82
- return CdpOpenApiClient.getSolanaAccount(options.address);
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
- return CdpOpenApiClient.getSolanaAccountByName(options.name);
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<Account> {
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
- const signature = await CdpOpenApiClient.requestSolanaFaucet(
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.signSolanaMessage(
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
- const signature = await CdpOpenApiClient.signSolanaTransaction(
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
- OpenApiSolanaMethods,
3
- SolanaAccount as OpenAPISolanaAccount,
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 account.
27
+ * A Solana signature result.
28
28
  */
29
- export type Account = OpenAPISolanaAccount;
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: Account[];
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";