@coinbase/cdp-sdk 1.44.0 → 1.45.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 (125) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +117 -0
  3. package/_cjs/accounts/evm/toEvmDelegatedAccount.js +27 -0
  4. package/_cjs/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
  5. package/_cjs/accounts/evm/toEvmServerAccount.js +127 -55
  6. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  7. package/_cjs/accounts/evm/toEvmSmartAccount.js +111 -45
  8. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  9. package/_cjs/accounts/solana/toSolanaAccount.js +49 -19
  10. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  11. package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js +37 -0
  12. package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
  13. package/_cjs/analytics.js +10 -229
  14. package/_cjs/analytics.js.map +1 -1
  15. package/_cjs/client/cdp.js +0 -6
  16. package/_cjs/client/cdp.js.map +1 -1
  17. package/_cjs/client/evm/evm.js +482 -227
  18. package/_cjs/client/evm/evm.js.map +1 -1
  19. package/_cjs/client/policies/policies.js +41 -11
  20. package/_cjs/client/policies/policies.js.map +1 -1
  21. package/_cjs/client/solana/solana.js +177 -106
  22. package/_cjs/client/solana/solana.js.map +1 -1
  23. package/_cjs/index.js +3 -1
  24. package/_cjs/index.js.map +1 -1
  25. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +139 -5
  26. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  27. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +30 -1
  28. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  29. package/_cjs/openapi-client/generated/onramp/onramp.js +15 -1
  30. package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -1
  31. package/_cjs/policies/evmSchema.js +127 -1
  32. package/_cjs/policies/evmSchema.js.map +1 -1
  33. package/_cjs/policies/solanaSchema.js +102 -1
  34. package/_cjs/policies/solanaSchema.js.map +1 -1
  35. package/_cjs/policies/types.js +7 -0
  36. package/_cjs/policies/types.js.map +1 -1
  37. package/_cjs/version.js +1 -1
  38. package/_esm/accounts/evm/toEvmDelegatedAccount.js +24 -0
  39. package/_esm/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
  40. package/_esm/accounts/evm/toEvmServerAccount.js +127 -55
  41. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  42. package/_esm/accounts/evm/toEvmSmartAccount.js +111 -45
  43. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  44. package/_esm/accounts/solana/toSolanaAccount.js +49 -19
  45. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  46. package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js +34 -0
  47. package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
  48. package/_esm/analytics.js +9 -228
  49. package/_esm/analytics.js.map +1 -1
  50. package/_esm/client/cdp.js +0 -6
  51. package/_esm/client/cdp.js.map +1 -1
  52. package/_esm/client/evm/evm.js +482 -227
  53. package/_esm/client/evm/evm.js.map +1 -1
  54. package/_esm/client/policies/policies.js +41 -11
  55. package/_esm/client/policies/policies.js.map +1 -1
  56. package/_esm/client/solana/solana.js +177 -106
  57. package/_esm/client/solana/solana.js.map +1 -1
  58. package/_esm/index.js +1 -0
  59. package/_esm/index.js.map +1 -1
  60. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +136 -3
  61. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  62. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +27 -0
  63. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  64. package/_esm/openapi-client/generated/onramp/onramp.js +13 -0
  65. package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -1
  66. package/_esm/policies/evmSchema.js +126 -0
  67. package/_esm/policies/evmSchema.js.map +1 -1
  68. package/_esm/policies/solanaSchema.js +101 -0
  69. package/_esm/policies/solanaSchema.js.map +1 -1
  70. package/_esm/policies/types.js +9 -2
  71. package/_esm/policies/types.js.map +1 -1
  72. package/_esm/version.js +1 -1
  73. package/_types/accounts/evm/toEvmDelegatedAccount.d.ts +13 -0
  74. package/_types/accounts/evm/toEvmDelegatedAccount.d.ts.map +1 -0
  75. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  76. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  77. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  78. package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts +32 -0
  79. package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts.map +1 -0
  80. package/_types/analytics.d.ts +5 -38
  81. package/_types/analytics.d.ts.map +1 -1
  82. package/_types/client/cdp.d.ts.map +1 -1
  83. package/_types/client/evm/evm.d.ts +54 -1
  84. package/_types/client/evm/evm.d.ts.map +1 -1
  85. package/_types/client/evm/evm.types.d.ts +29 -2
  86. package/_types/client/evm/evm.types.d.ts.map +1 -1
  87. package/_types/client/policies/policies.d.ts.map +1 -1
  88. package/_types/client/solana/solana.d.ts.map +1 -1
  89. package/_types/index.d.ts +2 -0
  90. package/_types/index.d.ts.map +1 -1
  91. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +482 -187
  92. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  93. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +21 -1
  94. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  95. package/_types/openapi-client/generated/onramp/onramp.d.ts +8 -1
  96. package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
  97. package/_types/openapi-client/index.d.ts +4 -0
  98. package/_types/openapi-client/index.d.ts.map +1 -1
  99. package/_types/policies/evmSchema.d.ts +2717 -601
  100. package/_types/policies/evmSchema.d.ts.map +1 -1
  101. package/_types/policies/solanaSchema.d.ts +1411 -47
  102. package/_types/policies/solanaSchema.d.ts.map +1 -1
  103. package/_types/policies/types.d.ts +8427 -2942
  104. package/_types/policies/types.d.ts.map +1 -1
  105. package/_types/version.d.ts +1 -1
  106. package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
  107. package/accounts/evm/toEvmServerAccount.ts +115 -67
  108. package/accounts/evm/toEvmSmartAccount.ts +100 -56
  109. package/accounts/solana/toSolanaAccount.ts +44 -24
  110. package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
  111. package/analytics.ts +8 -304
  112. package/client/cdp.ts +0 -7
  113. package/client/evm/evm.ts +517 -282
  114. package/client/evm/evm.types.ts +41 -0
  115. package/client/policies/policies.ts +41 -16
  116. package/client/solana/solana.ts +195 -141
  117. package/index.ts +5 -0
  118. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +624 -190
  119. package/openapi-client/generated/evm-accounts/evm-accounts.ts +49 -0
  120. package/openapi-client/generated/onramp/onramp.ts +24 -0
  121. package/package.json +1 -1
  122. package/policies/evmSchema.ts +164 -0
  123. package/policies/solanaSchema.ts +130 -0
  124. package/policies/types.ts +14 -0
  125. package/version.ts +1 -1
@@ -24,6 +24,9 @@ import type {
24
24
  } from "../../actions/evm/sendUserOperation.js";
25
25
  import type { SmartAccountActions } from "../../actions/evm/types.js";
26
26
  import type {
27
+ CreateEvmEip7702DelegationResult as CreateEvmEip7702DelegationResultApi,
28
+ EvmEip7702DelegationNetwork,
29
+ EvmEip7702DelegationOperation,
27
30
  EvmSwapsNetwork,
28
31
  EvmUserOperationNetwork,
29
32
  EvmUserOperationStatus,
@@ -37,6 +40,9 @@ import type { Calls } from "../../types/calls.js";
37
40
  import type { Address, EIP712Message, Hex } from "../../types/misc.js";
38
41
  import type { WaitOptions } from "../../utils/wait.js";
39
42
 
43
+ /** Result of createEvmEip7702Delegation with delegationOperationId. */
44
+ export type CreateEvmEip7702DelegationResult = CreateEvmEip7702DelegationResultApi;
45
+
40
46
  /**
41
47
  * The EvmClient type, where all OpenApiEvmMethods methods are wrapped.
42
48
  */
@@ -75,6 +81,8 @@ export type EvmClientInterface = Omit<
75
81
  | "exportEvmAccount"
76
82
  | "exportEvmAccountByName"
77
83
  | "updateEvmSmartAccount" // 🚧 Coming soon
84
+ | "createEvmEip7702Delegation" // mapped to options-based createEvmEip7702Delegation
85
+ | "getEvmEip7702DelegationOperationById" // wrapped as getEvmEip7702DelegationOperationById
78
86
  > & {
79
87
  createAccount: (options: CreateServerAccountOptions) => Promise<ServerAccount>;
80
88
  createSmartAccount: (options: CreateSmartAccountOptions) => Promise<SmartAccount>;
@@ -111,6 +119,15 @@ export type EvmClientInterface = Omit<
111
119
  signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
112
120
  signTypedData: (options: SignTypedDataOptions) => Promise<SignatureResult>;
113
121
  signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
122
+ createEvmEip7702Delegation: (
123
+ options: CreateEvmEip7702DelegationOptions,
124
+ ) => Promise<CreateEvmEip7702DelegationResult>;
125
+ getEvmEip7702DelegationOperationById: (
126
+ delegationOperationId: string,
127
+ ) => Promise<EvmEip7702DelegationOperation>;
128
+ waitForEvmEip7702DelegationOperationStatus: (
129
+ options: WaitForEvmEip7702DelegationOperationStatusOptions,
130
+ ) => Promise<EvmEip7702DelegationOperation>;
114
131
  };
115
132
 
116
133
  export type { ServerAccount, SmartAccount };
@@ -483,6 +500,30 @@ export interface UpdateEvmSmartAccountOptions {
483
500
  owner: Account;
484
501
  }
485
502
 
503
+ /**
504
+ * Options for creating an EIP-7702 delegation for an EVM EOA account.
505
+ */
506
+ export interface CreateEvmEip7702DelegationOptions {
507
+ /** The address of the EOA account. */
508
+ address: Address;
509
+ /** The network for the EIP-7702 delegation. */
510
+ network: EvmEip7702DelegationNetwork;
511
+ /** Whether to configure spend permissions for the upgraded, delegated account. When enabled, the account can grant permissions for third parties to spend on its behalf. Defaults to false. */
512
+ enableSpendPermissions?: boolean;
513
+ /** Optional idempotency key. */
514
+ idempotencyKey?: string;
515
+ }
516
+
517
+ /**
518
+ * Options for waiting for an EIP-7702 delegation operation to complete.
519
+ */
520
+ export interface WaitForEvmEip7702DelegationOperationStatusOptions {
521
+ /** The delegation operation ID returned by createEvmEip7702Delegation. */
522
+ delegationOperationId: string;
523
+ /** Optional options for the wait operation. */
524
+ waitOptions?: WaitOptions;
525
+ }
526
+
486
527
  /**
487
528
  * The result of listing EVM smart accounts.
488
529
  */
@@ -68,7 +68,12 @@ export class PoliciesClient implements PoliciesClientInterface {
68
68
  },
69
69
  });
70
70
 
71
- return CdpOpenApiClient.listPolicies(options) as Promise<ListPoliciesResult>;
71
+ try {
72
+ return CdpOpenApiClient.listPolicies(options) as Promise<ListPoliciesResult>;
73
+ } catch (error) {
74
+ Analytics.trackError(error, "listPolicies");
75
+ throw error;
76
+ }
72
77
  }
73
78
 
74
79
  /**
@@ -186,13 +191,18 @@ export class PoliciesClient implements PoliciesClientInterface {
186
191
  },
187
192
  });
188
193
 
189
- CreatePolicyBodySchema.parse(options.policy);
190
- return CdpOpenApiClient.createPolicy(
191
- // There are arbitrary differences between the abitype Abi and the openapi Abi
192
- options.policy as CreatePolicyBody,
194
+ try {
195
+ CreatePolicyBodySchema.parse(options.policy);
196
+ return CdpOpenApiClient.createPolicy(
197
+ // There are arbitrary differences between the abitype Abi and the openapi Abi
198
+ options.policy as CreatePolicyBody,
193
199
 
194
- options.idempotencyKey,
195
- ) as Promise<Policy>;
200
+ options.idempotencyKey,
201
+ ) as Promise<Policy>;
202
+ } catch (error) {
203
+ Analytics.trackError(error, "createPolicy");
204
+ throw error;
205
+ }
196
206
  }
197
207
 
198
208
  /**
@@ -218,7 +228,12 @@ export class PoliciesClient implements PoliciesClientInterface {
218
228
  action: "get_policy_by_id",
219
229
  });
220
230
 
221
- return CdpOpenApiClient.getPolicyById(options.id) as Promise<Policy>;
231
+ try {
232
+ return CdpOpenApiClient.getPolicyById(options.id) as Promise<Policy>;
233
+ } catch (error) {
234
+ Analytics.trackError(error, "getPolicyById");
235
+ throw error;
236
+ }
222
237
  }
223
238
 
224
239
  /**
@@ -254,7 +269,12 @@ export class PoliciesClient implements PoliciesClientInterface {
254
269
  action: "delete_policy",
255
270
  });
256
271
 
257
- return CdpOpenApiClient.deletePolicy(options.id, options.idempotencyKey);
272
+ try {
273
+ return CdpOpenApiClient.deletePolicy(options.id, options.idempotencyKey);
274
+ } catch (error) {
275
+ Analytics.trackError(error, "deletePolicy");
276
+ throw error;
277
+ }
258
278
  }
259
279
 
260
280
  /**
@@ -342,12 +362,17 @@ export class PoliciesClient implements PoliciesClientInterface {
342
362
  action: "update_policy",
343
363
  });
344
364
 
345
- UpdatePolicyBodySchema.parse(options.policy);
346
- return CdpOpenApiClient.updatePolicy(
347
- options.id,
348
- // There are arbitrary differences between the abitype Abi and the openapi Abi
349
- options.policy as UpdatePolicyBody,
350
- options.idempotencyKey,
351
- ) as Promise<Policy>;
365
+ try {
366
+ UpdatePolicyBodySchema.parse(options.policy);
367
+ return CdpOpenApiClient.updatePolicy(
368
+ options.id,
369
+ // There are arbitrary differences between the abitype Abi and the openapi Abi
370
+ options.policy as UpdatePolicyBody,
371
+ options.idempotencyKey,
372
+ ) as Promise<Policy>;
373
+ } catch (error) {
374
+ Analytics.trackError(error, "updatePolicy");
375
+ throw error;
376
+ }
352
377
  }
353
378
  }
@@ -87,7 +87,12 @@ export class SolanaClient implements SolanaClientInterface {
87
87
  accountType: "solana",
88
88
  });
89
89
 
90
- return this._createAccountInternal(options);
90
+ try {
91
+ return this._createAccountInternal(options);
92
+ } catch (error) {
93
+ Analytics.trackError(error, "createAccount");
94
+ throw error;
95
+ }
91
96
  }
92
97
 
93
98
  /**
@@ -120,34 +125,41 @@ export class SolanaClient implements SolanaClientInterface {
120
125
  accountType: "solana",
121
126
  });
122
127
 
123
- const { publicKey, privateKey } = await generateExportEncryptionKeyPair();
124
-
125
- const { encryptedPrivateKey } = await (async () => {
126
- if (options.address) {
127
- return CdpOpenApiClient.exportSolanaAccount(
128
- options.address,
129
- {
130
- exportEncryptionKey: publicKey,
131
- },
132
- options.idempotencyKey,
133
- );
134
- }
128
+ try {
129
+ const { publicKey, privateKey } = await generateExportEncryptionKeyPair();
130
+
131
+ const { encryptedPrivateKey } = await (async () => {
132
+ if (options.address) {
133
+ return CdpOpenApiClient.exportSolanaAccount(
134
+ options.address,
135
+ {
136
+ exportEncryptionKey: publicKey,
137
+ },
138
+ options.idempotencyKey,
139
+ );
140
+ }
135
141
 
136
- if (options.name) {
137
- return CdpOpenApiClient.exportSolanaAccountByName(
138
- options.name,
139
- {
140
- exportEncryptionKey: publicKey,
141
- },
142
- options.idempotencyKey,
143
- );
144
- }
142
+ if (options.name) {
143
+ return CdpOpenApiClient.exportSolanaAccountByName(
144
+ options.name,
145
+ {
146
+ exportEncryptionKey: publicKey,
147
+ },
148
+ options.idempotencyKey,
149
+ );
150
+ }
145
151
 
146
- throw new UserInputValidationError("Either address or name must be provided");
147
- })();
152
+ throw new UserInputValidationError("Either address or name must be provided");
153
+ })();
148
154
 
149
- const decryptedPrivateKey = decryptWithPrivateKey(privateKey, encryptedPrivateKey);
150
- return formatSolanaPrivateKey(decryptedPrivateKey);
155
+ const decryptedPrivateKey = decryptWithPrivateKey(privateKey, encryptedPrivateKey);
156
+ return formatSolanaPrivateKey(decryptedPrivateKey);
157
+ } catch (error) {
158
+ if (!(error instanceof UserInputValidationError)) {
159
+ Analytics.trackError(error, "exportAccount");
160
+ }
161
+ throw error;
162
+ }
151
163
  }
152
164
 
153
165
  /**
@@ -194,48 +206,53 @@ export class SolanaClient implements SolanaClientInterface {
194
206
  accountType: "solana",
195
207
  });
196
208
 
197
- let privateKeyBytes: Uint8Array = new Uint8Array();
198
-
199
- if (typeof options.privateKey === "string") {
200
- privateKeyBytes = bs58.decode(options.privateKey);
201
- } else {
202
- privateKeyBytes = options.privateKey;
203
- }
204
-
205
- if (privateKeyBytes.length !== 32 && privateKeyBytes.length !== 64) {
206
- throw new UserInputValidationError("Invalid private key length");
207
- }
208
-
209
- if (privateKeyBytes.length === 64) {
210
- privateKeyBytes = privateKeyBytes.subarray(0, 32);
211
- }
212
-
213
- const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
209
+ try {
210
+ let privateKeyBytes: Uint8Array = new Uint8Array();
214
211
 
215
- const encryptedPrivateKey = publicEncrypt(
216
- {
217
- key: encryptionPublicKey,
218
- padding: constants.RSA_PKCS1_OAEP_PADDING,
219
- oaepHash: "sha256",
220
- },
221
- privateKeyBytes,
222
- );
212
+ if (typeof options.privateKey === "string") {
213
+ privateKeyBytes = bs58.decode(options.privateKey);
214
+ } else {
215
+ privateKeyBytes = options.privateKey;
216
+ }
223
217
 
224
- const openApiAccount = await CdpOpenApiClient.importSolanaAccount(
225
- {
226
- encryptedPrivateKey: encryptedPrivateKey.toString("base64"),
227
- name: options.name,
228
- },
229
- options.idempotencyKey,
230
- );
218
+ if (privateKeyBytes.length !== 32 && privateKeyBytes.length !== 64) {
219
+ throw new UserInputValidationError("Invalid private key length");
220
+ }
231
221
 
232
- const account = toSolanaAccount(CdpOpenApiClient, {
233
- account: openApiAccount,
234
- });
222
+ if (privateKeyBytes.length === 64) {
223
+ privateKeyBytes = privateKeyBytes.subarray(0, 32);
224
+ }
235
225
 
236
- Analytics.wrapObjectMethodsWithErrorTracking(account);
226
+ const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
227
+
228
+ const encryptedPrivateKey = publicEncrypt(
229
+ {
230
+ key: encryptionPublicKey,
231
+ padding: constants.RSA_PKCS1_OAEP_PADDING,
232
+ oaepHash: "sha256",
233
+ },
234
+ privateKeyBytes,
235
+ );
236
+
237
+ const openApiAccount = await CdpOpenApiClient.importSolanaAccount(
238
+ {
239
+ encryptedPrivateKey: encryptedPrivateKey.toString("base64"),
240
+ name: options.name,
241
+ },
242
+ options.idempotencyKey,
243
+ );
244
+
245
+ const account = toSolanaAccount(CdpOpenApiClient, {
246
+ account: openApiAccount,
247
+ });
237
248
 
238
- return account;
249
+ return account;
250
+ } catch (error) {
251
+ if (!(error instanceof UserInputValidationError)) {
252
+ Analytics.trackError(error, "importAccount");
253
+ }
254
+ throw error;
255
+ }
239
256
  }
240
257
 
241
258
  /**
@@ -269,7 +286,12 @@ export class SolanaClient implements SolanaClientInterface {
269
286
  accountType: "solana",
270
287
  });
271
288
 
272
- return this._getAccountInternal(options);
289
+ try {
290
+ return this._getAccountInternal(options);
291
+ } catch (error) {
292
+ Analytics.trackError(error, "getAccount");
293
+ throw error;
294
+ }
273
295
  }
274
296
 
275
297
  /**
@@ -294,26 +316,31 @@ export class SolanaClient implements SolanaClientInterface {
294
316
  });
295
317
 
296
318
  try {
297
- const account = await this._getAccountInternal(options);
298
- return account;
299
- } catch (error) {
300
- // If it failed because the account doesn't exist, create it
301
- const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
302
- if (doesAccountNotExist) {
303
- try {
304
- const account = await this._createAccountInternal(options);
305
- return account;
306
- } catch (error) {
307
- // If it failed because the account already exists, get the existing account
308
- const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
309
- if (doesAccountAlreadyExist) {
310
- const account = await this._getAccountInternal(options);
319
+ try {
320
+ const account = await this._getAccountInternal(options);
321
+ return account;
322
+ } catch (error) {
323
+ // If it failed because the account doesn't exist, create it
324
+ const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
325
+ if (doesAccountNotExist) {
326
+ try {
327
+ const account = await this._createAccountInternal(options);
311
328
  return account;
329
+ } catch (error) {
330
+ // If it failed because the account already exists, get the existing account
331
+ const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
332
+ if (doesAccountAlreadyExist) {
333
+ const account = await this._getAccountInternal(options);
334
+ return account;
335
+ }
336
+ throw error;
312
337
  }
313
- throw error;
314
338
  }
315
- }
316
339
 
340
+ throw error;
341
+ }
342
+ } catch (error) {
343
+ Analytics.trackError(error, "getOrCreateAccount");
317
344
  throw error;
318
345
  }
319
346
  }
@@ -352,23 +379,26 @@ export class SolanaClient implements SolanaClientInterface {
352
379
  accountType: "solana",
353
380
  });
354
381
 
355
- const solAccounts = await CdpOpenApiClient.listSolanaAccounts({
356
- pageSize: options.pageSize,
357
- pageToken: options.pageToken,
358
- });
359
-
360
- return {
361
- accounts: solAccounts.accounts.map(account => {
362
- const solanaAccount = toSolanaAccount(CdpOpenApiClient, {
363
- account,
364
- });
365
-
366
- Analytics.wrapObjectMethodsWithErrorTracking(solanaAccount);
367
-
368
- return solanaAccount;
369
- }),
370
- nextPageToken: solAccounts.nextPageToken,
371
- };
382
+ try {
383
+ const solAccounts = await CdpOpenApiClient.listSolanaAccounts({
384
+ pageSize: options.pageSize,
385
+ pageToken: options.pageToken,
386
+ });
387
+
388
+ return {
389
+ accounts: solAccounts.accounts.map(account => {
390
+ const solanaAccount = toSolanaAccount(CdpOpenApiClient, {
391
+ account,
392
+ });
393
+
394
+ return solanaAccount;
395
+ }),
396
+ nextPageToken: solAccounts.nextPageToken,
397
+ };
398
+ } catch (error) {
399
+ Analytics.trackError(error, "listAccounts");
400
+ throw error;
401
+ }
372
402
  }
373
403
 
374
404
  /**
@@ -395,7 +425,12 @@ export class SolanaClient implements SolanaClientInterface {
395
425
  accountType: "solana",
396
426
  });
397
427
 
398
- return requestFaucet(CdpOpenApiClient, options);
428
+ try {
429
+ return requestFaucet(CdpOpenApiClient, options);
430
+ } catch (error) {
431
+ Analytics.trackError(error, "requestFaucet");
432
+ throw error;
433
+ }
399
434
  }
400
435
 
401
436
  /**
@@ -426,7 +461,12 @@ export class SolanaClient implements SolanaClientInterface {
426
461
  accountType: "solana",
427
462
  });
428
463
 
429
- return signMessage(CdpOpenApiClient, options);
464
+ try {
465
+ return signMessage(CdpOpenApiClient, options);
466
+ } catch (error) {
467
+ Analytics.trackError(error, "signMessage");
468
+ throw error;
469
+ }
430
470
  }
431
471
 
432
472
  /**
@@ -468,7 +508,12 @@ export class SolanaClient implements SolanaClientInterface {
468
508
  accountType: "solana",
469
509
  });
470
510
 
471
- return signTransaction(CdpOpenApiClient, options);
511
+ try {
512
+ return signTransaction(CdpOpenApiClient, options);
513
+ } catch (error) {
514
+ Analytics.trackError(error, "signTransaction");
515
+ throw error;
516
+ }
472
517
  }
473
518
 
474
519
  /**
@@ -518,19 +563,22 @@ export class SolanaClient implements SolanaClientInterface {
518
563
  accountType: "solana",
519
564
  });
520
565
 
521
- const openApiAccount = await CdpOpenApiClient.updateSolanaAccount(
522
- options.address,
523
- options.update,
524
- options.idempotencyKey,
525
- );
526
-
527
- const account = toSolanaAccount(CdpOpenApiClient, {
528
- account: openApiAccount,
529
- });
566
+ try {
567
+ const openApiAccount = await CdpOpenApiClient.updateSolanaAccount(
568
+ options.address,
569
+ options.update,
570
+ options.idempotencyKey,
571
+ );
530
572
 
531
- Analytics.wrapObjectMethodsWithErrorTracking(account);
573
+ const account = toSolanaAccount(CdpOpenApiClient, {
574
+ account: openApiAccount,
575
+ });
532
576
 
533
- return account;
577
+ return account;
578
+ } catch (error) {
579
+ Analytics.trackError(error, "updateAccount");
580
+ throw error;
581
+ }
534
582
  }
535
583
 
536
584
  /**
@@ -560,7 +608,12 @@ export class SolanaClient implements SolanaClientInterface {
560
608
  },
561
609
  });
562
610
 
563
- return sendTransaction(CdpOpenApiClient, options);
611
+ try {
612
+ return sendTransaction(CdpOpenApiClient, options);
613
+ } catch (error) {
614
+ Analytics.trackError(error, "sendTransaction");
615
+ throw error;
616
+ }
564
617
  }
565
618
 
566
619
  /**
@@ -589,31 +642,36 @@ export class SolanaClient implements SolanaClientInterface {
589
642
  },
590
643
  });
591
644
 
592
- const tokenBalances = await CdpOpenApiClient.listSolanaTokenBalances(
593
- options.network || "solana",
594
- options.address,
595
- {
596
- pageSize: options.pageSize,
597
- pageToken: options.pageToken,
598
- },
599
- );
600
-
601
- return {
602
- balances: tokenBalances.balances.map(balance => {
603
- return {
604
- amount: {
605
- amount: BigInt(balance.amount.amount),
606
- decimals: balance.amount.decimals,
607
- },
608
- token: {
609
- mintAddress: balance.token.mintAddress,
610
- name: balance.token.name,
611
- symbol: balance.token.symbol,
612
- },
613
- };
614
- }),
615
- nextPageToken: tokenBalances.nextPageToken,
616
- };
645
+ try {
646
+ const tokenBalances = await CdpOpenApiClient.listSolanaTokenBalances(
647
+ options.network || "solana",
648
+ options.address,
649
+ {
650
+ pageSize: options.pageSize,
651
+ pageToken: options.pageToken,
652
+ },
653
+ );
654
+
655
+ return {
656
+ balances: tokenBalances.balances.map(balance => {
657
+ return {
658
+ amount: {
659
+ amount: BigInt(balance.amount.amount),
660
+ decimals: balance.amount.decimals,
661
+ },
662
+ token: {
663
+ mintAddress: balance.token.mintAddress,
664
+ name: balance.token.name,
665
+ symbol: balance.token.symbol,
666
+ },
667
+ };
668
+ }),
669
+ nextPageToken: tokenBalances.nextPageToken,
670
+ };
671
+ } catch (error) {
672
+ Analytics.trackError(error, "listTokenBalances");
673
+ throw error;
674
+ }
617
675
  }
618
676
 
619
677
  /**
@@ -636,8 +694,6 @@ export class SolanaClient implements SolanaClientInterface {
636
694
  account: openApiAccount,
637
695
  });
638
696
 
639
- Analytics.wrapObjectMethodsWithErrorTracking(account);
640
-
641
697
  return account;
642
698
  }
643
699
 
@@ -665,8 +721,6 @@ export class SolanaClient implements SolanaClientInterface {
665
721
  account: openApiAccount,
666
722
  });
667
723
 
668
- Analytics.wrapObjectMethodsWithErrorTracking(account);
669
-
670
724
  return account;
671
725
  }
672
726
  }
package/index.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export { CdpClient } from "./client/cdp.js";
2
+ export { toEvmDelegatedAccount } from "./accounts/evm/toEvmDelegatedAccount.js";
2
3
  export type { EvmServerAccount, EvmSmartAccount } from "./accounts/evm/types.js";
4
+ export type {
5
+ CreateEvmEip7702DelegationResult,
6
+ WaitForEvmEip7702DelegationOperationStatusOptions,
7
+ } from "./client/evm/evm.types.js";
3
8
  export type { Policy } from "./policies/types.js";
4
9
  export {
5
10
  CreatePolicyBodySchema,