@coinbase/cdp-sdk 1.46.1 → 1.48.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 +14 -0
  2. package/README.md +332 -0
  3. package/_cjs/actions/solana/sendTransaction.js +3 -0
  4. package/_cjs/actions/solana/sendTransaction.js.map +1 -1
  5. package/_cjs/actions/webhooks/createWebhookSubscription.js +48 -0
  6. package/_cjs/actions/webhooks/createWebhookSubscription.js.map +1 -0
  7. package/_cjs/actions/webhooks/index.js +6 -0
  8. package/_cjs/actions/webhooks/index.js.map +1 -0
  9. package/_cjs/client/cdp.js +5 -4
  10. package/_cjs/client/cdp.js.map +1 -1
  11. package/_cjs/client/end-user/endUser.js +19 -89
  12. package/_cjs/client/end-user/endUser.js.map +1 -1
  13. package/_cjs/client/end-user/toEndUserAccount.js +13 -43
  14. package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
  15. package/_cjs/client/solana/solana.js +2 -0
  16. package/_cjs/client/solana/solana.js.map +1 -1
  17. package/_cjs/client/webhooks/webhooks.js +58 -0
  18. package/_cjs/client/webhooks/webhooks.js.map +1 -0
  19. package/_cjs/index.js.map +1 -1
  20. package/_cjs/openapi-client/cdpApiClient.js +0 -32
  21. package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
  22. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +51 -11
  23. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  24. package/_cjs/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +37 -65
  25. package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
  26. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
  27. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  28. package/_cjs/openapi-client/generated/sql-api/sql-api.js +12 -1
  29. package/_cjs/openapi-client/generated/sql-api/sql-api.js.map +1 -1
  30. package/_cjs/openapi-client/generated/webhooks/webhooks.js +32 -5
  31. package/_cjs/openapi-client/generated/webhooks/webhooks.js.map +1 -1
  32. package/_cjs/openapi-client/index.js +2 -2
  33. package/_cjs/openapi-client/index.js.map +1 -1
  34. package/_cjs/version.js +1 -1
  35. package/_esm/actions/solana/sendTransaction.js +3 -0
  36. package/_esm/actions/solana/sendTransaction.js.map +1 -1
  37. package/_esm/actions/webhooks/createWebhookSubscription.js +45 -0
  38. package/_esm/actions/webhooks/createWebhookSubscription.js.map +1 -0
  39. package/_esm/actions/webhooks/index.js +2 -0
  40. package/_esm/actions/webhooks/index.js.map +1 -0
  41. package/_esm/client/cdp.js +6 -5
  42. package/_esm/client/cdp.js.map +1 -1
  43. package/_esm/client/end-user/endUser.js +17 -87
  44. package/_esm/client/end-user/endUser.js.map +1 -1
  45. package/_esm/client/end-user/toEndUserAccount.js +13 -43
  46. package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
  47. package/_esm/client/solana/solana.js +2 -0
  48. package/_esm/client/solana/solana.js.map +1 -1
  49. package/_esm/client/webhooks/webhooks.js +54 -0
  50. package/_esm/client/webhooks/webhooks.js.map +1 -0
  51. package/_esm/index.js.map +1 -1
  52. package/_esm/openapi-client/cdpApiClient.js +0 -32
  53. package/_esm/openapi-client/cdpApiClient.js.map +1 -1
  54. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +48 -8
  55. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  56. package/_esm/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +36 -61
  57. package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
  58. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
  59. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  60. package/_esm/openapi-client/generated/sql-api/sql-api.js +10 -0
  61. package/_esm/openapi-client/generated/sql-api/sql-api.js.map +1 -1
  62. package/_esm/openapi-client/generated/webhooks/webhooks.js +30 -4
  63. package/_esm/openapi-client/generated/webhooks/webhooks.js.map +1 -1
  64. package/_esm/openapi-client/index.js +2 -2
  65. package/_esm/openapi-client/index.js.map +1 -1
  66. package/_esm/version.js +1 -1
  67. package/_types/actions/solana/sendTransaction.d.ts +2 -0
  68. package/_types/actions/solana/sendTransaction.d.ts.map +1 -1
  69. package/_types/actions/webhooks/createWebhookSubscription.d.ts +68 -0
  70. package/_types/actions/webhooks/createWebhookSubscription.d.ts.map +1 -0
  71. package/_types/actions/webhooks/index.d.ts +2 -0
  72. package/_types/actions/webhooks/index.d.ts.map +1 -0
  73. package/_types/client/cdp.d.ts +5 -6
  74. package/_types/client/cdp.d.ts.map +1 -1
  75. package/_types/client/end-user/endUser.d.ts +2 -52
  76. package/_types/client/end-user/endUser.d.ts.map +1 -1
  77. package/_types/client/end-user/endUser.types.d.ts +1 -63
  78. package/_types/client/end-user/endUser.types.d.ts.map +1 -1
  79. package/_types/client/end-user/toEndUserAccount.d.ts +0 -2
  80. package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
  81. package/_types/client/solana/solana.d.ts +2 -0
  82. package/_types/client/solana/solana.d.ts.map +1 -1
  83. package/_types/client/solana/solana.types.d.ts +2 -0
  84. package/_types/client/solana/solana.types.d.ts.map +1 -1
  85. package/_types/client/webhooks/webhooks.d.ts +41 -0
  86. package/_types/client/webhooks/webhooks.d.ts.map +1 -0
  87. package/_types/index.d.ts +2 -1
  88. package/_types/index.d.ts.map +1 -1
  89. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
  90. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +285 -85
  91. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  92. package/_types/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts → embedded-wallets/embedded-wallets.d.ts} +14 -32
  93. package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts.map +1 -0
  94. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +2 -2
  95. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  96. package/_types/openapi-client/generated/sql-api/sql-api.d.ts +10 -1
  97. package/_types/openapi-client/generated/sql-api/sql-api.d.ts.map +1 -1
  98. package/_types/openapi-client/generated/webhooks/webhooks.d.ts +30 -5
  99. package/_types/openapi-client/generated/webhooks/webhooks.d.ts.map +1 -1
  100. package/_types/openapi-client/index.d.ts +16 -18
  101. package/_types/openapi-client/index.d.ts.map +1 -1
  102. package/_types/version.d.ts +1 -1
  103. package/actions/solana/sendTransaction.ts +3 -0
  104. package/actions/webhooks/createWebhookSubscription.ts +104 -0
  105. package/actions/webhooks/index.ts +6 -0
  106. package/client/cdp.ts +8 -8
  107. package/client/end-user/endUser.ts +55 -187
  108. package/client/end-user/endUser.types.ts +0 -72
  109. package/client/end-user/toEndUserAccount.ts +57 -152
  110. package/client/solana/solana.ts +2 -0
  111. package/client/solana/solana.types.ts +2 -0
  112. package/client/webhooks/webhooks.ts +61 -0
  113. package/index.ts +6 -4
  114. package/openapi-client/cdpApiClient.ts +0 -34
  115. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +331 -93
  116. package/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts → embedded-wallets/embedded-wallets.ts} +45 -99
  117. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -3
  118. package/openapi-client/generated/sql-api/sql-api.ts +19 -0
  119. package/openapi-client/generated/webhooks/webhooks.ts +42 -4
  120. package/openapi-client/index.ts +2 -2
  121. package/package.json +1 -1
  122. package/version.ts +1 -1
  123. package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
  124. package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
  125. package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +0 -1
@@ -6,7 +6,6 @@ import type {
6
6
  AddEndUserEvmSmartAccountResult,
7
7
  AddEndUserSolanaAccountResult,
8
8
  AddEvmSmartAccountOptions,
9
- SignEvmHashResult,
10
9
  SignEvmTransactionResult,
11
10
  SignEvmMessageResult,
12
11
  SignEvmTypedDataResult,
@@ -14,12 +13,10 @@ import type {
14
13
  SendEvmAssetResult,
15
14
  SendUserOperationResult,
16
15
  CreateEvmEip7702DelegationForEndUserResult,
17
- SignSolanaHashResult,
18
16
  SignSolanaMessageResult,
19
17
  SignSolanaTransactionResult,
20
18
  SendSolanaTransactionResult,
21
19
  SendSolanaAssetResult,
22
- AccountSignEvmHashOptions,
23
20
  AccountSignEvmTransactionOptions,
24
21
  AccountSignEvmMessageOptions,
25
22
  AccountSignEvmTypedDataOptions,
@@ -27,7 +24,6 @@ import type {
27
24
  AccountSendEvmAssetOptions,
28
25
  AccountSendUserOperationOptions,
29
26
  AccountCreateEvmEip7702DelegationOptions,
30
- AccountSignSolanaHashOptions,
31
27
  AccountSignSolanaMessageOptions,
32
28
  AccountSignSolanaTransactionOptions,
33
29
  AccountSendSolanaTransactionOptions,
@@ -44,28 +40,8 @@ import type {
44
40
  export type ToEndUserAccountOptions = {
45
41
  /** The end user from the API response. */
46
42
  endUser: OpenAPIEndUser;
47
- /** The CDP project ID. Required for delegation operations (signing, sending). */
48
- projectId?: string;
49
43
  };
50
44
 
51
- /**
52
- * Returns the project ID or throws if not configured.
53
- * Used by delegation operations that require a project ID.
54
- *
55
- * @param projectId - The project ID to validate.
56
- * @returns The validated project ID.
57
- */
58
- function requireProjectId(projectId: string | undefined): string {
59
- if (!projectId) {
60
- throw new Error(
61
- "Missing required project ID for delegation operation. " +
62
- "Set the CDP_PROJECT_ID environment variable or pass projectId to the CdpClient constructor.",
63
- );
64
- }
65
-
66
- return projectId;
67
- }
68
-
69
45
  /**
70
46
  * Resolves the first EVM EOA address for this end user, or throws if none exist and no override was provided.
71
47
  *
@@ -131,7 +107,7 @@ export function toEndUserAccount(
131
107
  apiClient: CdpOpenApiClientType,
132
108
  options: ToEndUserAccountOptions,
133
109
  ): EndUserAccount {
134
- const { endUser, projectId } = options;
110
+ const { endUser } = options;
135
111
 
136
112
  const endUserAccount: EndUserAccount = {
137
113
  // Pass through all properties from the OpenAPI EndUser
@@ -169,59 +145,38 @@ export function toEndUserAccount(
169
145
 
170
146
  async revokeDelegation(): Promise<void> {
171
147
  Analytics.trackAction({ action: "end_user_revoke_delegation" });
172
- await apiClient.revokeDelegationForEndUser(requireProjectId(projectId), endUser.userId, {});
148
+ await apiClient.revokeDelegationForEndUser(endUser.userId, {});
173
149
  },
174
150
 
175
151
  // ─── Delegated EVM Sign Methods ───
176
152
 
177
- async signEvmHash(opts: AccountSignEvmHashOptions): Promise<SignEvmHashResult> {
178
- Analytics.trackAction({ action: "end_user_sign_evm_hash" });
179
- const address = resolveEvmAddress(endUser, opts.address);
180
- return apiClient.signEvmHashWithEndUserAccount(requireProjectId(projectId), endUser.userId, {
181
- hash: opts.hash,
182
- address,
183
- });
184
- },
185
-
186
153
  async signEvmTransaction(
187
154
  opts: AccountSignEvmTransactionOptions,
188
155
  ): Promise<SignEvmTransactionResult> {
189
156
  Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
190
157
  const address = resolveEvmAddress(endUser, opts.address);
191
- return apiClient.signEvmTransactionWithEndUserAccount(
192
- requireProjectId(projectId),
193
- endUser.userId,
194
- {
195
- address,
196
- transaction: opts.transaction,
197
- },
198
- );
158
+ return apiClient.signEvmTransactionWithEndUserAccount(endUser.userId, {
159
+ address,
160
+ transaction: opts.transaction,
161
+ });
199
162
  },
200
163
 
201
164
  async signEvmMessage(opts: AccountSignEvmMessageOptions): Promise<SignEvmMessageResult> {
202
165
  Analytics.trackAction({ action: "end_user_sign_evm_message" });
203
166
  const address = resolveEvmAddress(endUser, opts.address);
204
- return apiClient.signEvmMessageWithEndUserAccount(
205
- requireProjectId(projectId),
206
- endUser.userId,
207
- {
208
- address,
209
- message: opts.message,
210
- },
211
- );
167
+ return apiClient.signEvmMessageWithEndUserAccount(endUser.userId, {
168
+ address,
169
+ message: opts.message,
170
+ });
212
171
  },
213
172
 
214
173
  async signEvmTypedData(opts: AccountSignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
215
174
  Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
216
175
  const address = resolveEvmAddress(endUser, opts.address);
217
- return apiClient.signEvmTypedDataWithEndUserAccount(
218
- requireProjectId(projectId),
219
- endUser.userId,
220
- {
221
- address,
222
- typedData: opts.typedData,
223
- },
224
- );
176
+ return apiClient.signEvmTypedDataWithEndUserAccount(endUser.userId, {
177
+ address,
178
+ typedData: opts.typedData,
179
+ });
225
180
  },
226
181
 
227
182
  // ─── Delegated EVM Send Methods ───
@@ -231,34 +186,24 @@ export function toEndUserAccount(
231
186
  ): Promise<SendEvmTransactionResult> {
232
187
  Analytics.trackAction({ action: "end_user_send_evm_transaction" });
233
188
  const address = resolveEvmAddress(endUser, opts.address);
234
- return apiClient.sendEvmTransactionWithEndUserAccount(
235
- requireProjectId(projectId),
236
- endUser.userId,
237
- {
238
- address,
239
- transaction: opts.transaction,
240
- network: opts.network,
241
- },
242
- );
189
+ return apiClient.sendEvmTransactionWithEndUserAccount(endUser.userId, {
190
+ address,
191
+ transaction: opts.transaction,
192
+ network: opts.network,
193
+ });
243
194
  },
244
195
 
245
196
  async sendEvmAsset(opts: AccountSendEvmAssetOptions): Promise<SendEvmAssetResult> {
246
197
  Analytics.trackAction({ action: "end_user_send_evm_asset" });
247
198
  const address = resolveEvmAddress(endUser, opts.address);
248
199
  const asset = opts.asset ?? "usdc";
249
- return apiClient.sendEvmAssetWithEndUserAccount(
250
- requireProjectId(projectId),
251
- endUser.userId,
252
- address,
253
- asset,
254
- {
255
- to: opts.to,
256
- amount: opts.amount,
257
- network: opts.network,
258
- useCdpPaymaster: opts.useCdpPaymaster,
259
- paymasterUrl: opts.paymasterUrl,
260
- },
261
- );
200
+ return apiClient.sendEvmAssetWithEndUserAccount(endUser.userId, address, asset, {
201
+ to: opts.to,
202
+ amount: opts.amount,
203
+ network: opts.network,
204
+ useCdpPaymaster: opts.useCdpPaymaster,
205
+ paymasterUrl: opts.paymasterUrl,
206
+ });
262
207
  },
263
208
 
264
209
  async sendUserOperation(
@@ -266,18 +211,13 @@ export function toEndUserAccount(
266
211
  ): Promise<SendUserOperationResult> {
267
212
  Analytics.trackAction({ action: "end_user_send_user_operation" });
268
213
  const address = resolveEvmSmartAccountAddress(endUser, opts.address);
269
- return apiClient.sendUserOperationWithEndUserAccount(
270
- requireProjectId(projectId),
271
- endUser.userId,
272
- address,
273
- {
274
- network: opts.network,
275
- calls: opts.calls,
276
- useCdpPaymaster: opts.useCdpPaymaster,
277
- paymasterUrl: opts.paymasterUrl,
278
- dataSuffix: opts.dataSuffix,
279
- },
280
- );
214
+ return apiClient.sendUserOperationWithEndUserAccount(endUser.userId, address, {
215
+ network: opts.network,
216
+ calls: opts.calls,
217
+ useCdpPaymaster: opts.useCdpPaymaster,
218
+ paymasterUrl: opts.paymasterUrl,
219
+ dataSuffix: opts.dataSuffix,
220
+ });
281
221
  },
282
222
 
283
223
  // ─── Delegated EVM EIP-7702 Delegation Method ───
@@ -287,45 +227,24 @@ export function toEndUserAccount(
287
227
  ): Promise<CreateEvmEip7702DelegationForEndUserResult> {
288
228
  Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
289
229
  const address = resolveEvmAddress(endUser, opts.address);
290
- return apiClient.createEvmEip7702DelegationWithEndUserAccount(
291
- requireProjectId(projectId),
292
- endUser.userId,
293
- {
294
- address,
295
- network: opts.network,
296
- enableSpendPermissions: opts.enableSpendPermissions,
297
- },
298
- );
230
+ return apiClient.createEvmEip7702DelegationWithEndUserAccount(endUser.userId, {
231
+ address,
232
+ network: opts.network,
233
+ enableSpendPermissions: opts.enableSpendPermissions,
234
+ });
299
235
  },
300
236
 
301
237
  // ─── Delegated Solana Sign Methods ───
302
238
 
303
- async signSolanaHash(opts: AccountSignSolanaHashOptions): Promise<SignSolanaHashResult> {
304
- Analytics.trackAction({ action: "end_user_sign_solana_hash" });
305
- const address = resolveSolanaAddress(endUser, opts.address);
306
- return apiClient.signSolanaHashWithEndUserAccount(
307
- requireProjectId(projectId),
308
- endUser.userId,
309
- {
310
- hash: opts.hash,
311
- address,
312
- },
313
- );
314
- },
315
-
316
239
  async signSolanaMessage(
317
240
  opts: AccountSignSolanaMessageOptions,
318
241
  ): Promise<SignSolanaMessageResult> {
319
242
  Analytics.trackAction({ action: "end_user_sign_solana_message" });
320
243
  const address = resolveSolanaAddress(endUser, opts.address);
321
- return apiClient.signSolanaMessageWithEndUserAccount(
322
- requireProjectId(projectId),
323
- endUser.userId,
324
- {
325
- address,
326
- message: opts.message,
327
- },
328
- );
244
+ return apiClient.signSolanaMessageWithEndUserAccount(endUser.userId, {
245
+ address,
246
+ message: opts.message,
247
+ });
329
248
  },
330
249
 
331
250
  async signSolanaTransaction(
@@ -333,14 +252,10 @@ export function toEndUserAccount(
333
252
  ): Promise<SignSolanaTransactionResult> {
334
253
  Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
335
254
  const address = resolveSolanaAddress(endUser, opts.address);
336
- return apiClient.signSolanaTransactionWithEndUserAccount(
337
- requireProjectId(projectId),
338
- endUser.userId,
339
- {
340
- address,
341
- transaction: opts.transaction,
342
- },
343
- );
255
+ return apiClient.signSolanaTransactionWithEndUserAccount(endUser.userId, {
256
+ address,
257
+ transaction: opts.transaction,
258
+ });
344
259
  },
345
260
 
346
261
  // ─── Delegated Solana Send Methods ───
@@ -350,33 +265,23 @@ export function toEndUserAccount(
350
265
  ): Promise<SendSolanaTransactionResult> {
351
266
  Analytics.trackAction({ action: "end_user_send_solana_transaction" });
352
267
  const address = resolveSolanaAddress(endUser, opts.address);
353
- return apiClient.sendSolanaTransactionWithEndUserAccount(
354
- requireProjectId(projectId),
355
- endUser.userId,
356
- {
357
- address,
358
- transaction: opts.transaction,
359
- network: opts.network,
360
- },
361
- );
268
+ return apiClient.sendSolanaTransactionWithEndUserAccount(endUser.userId, {
269
+ address,
270
+ transaction: opts.transaction,
271
+ network: opts.network,
272
+ });
362
273
  },
363
274
 
364
275
  async sendSolanaAsset(opts: AccountSendSolanaAssetOptions): Promise<SendSolanaAssetResult> {
365
276
  Analytics.trackAction({ action: "end_user_send_solana_asset" });
366
277
  const address = resolveSolanaAddress(endUser, opts.address);
367
278
  const asset = opts.asset ?? "usdc";
368
- return apiClient.sendSolanaAssetWithEndUserAccount(
369
- requireProjectId(projectId),
370
- endUser.userId,
371
- address,
372
- asset,
373
- {
374
- to: opts.to,
375
- amount: opts.amount,
376
- network: opts.network,
377
- createRecipientAta: opts.createRecipientAta,
378
- },
379
- );
279
+ return apiClient.sendSolanaAssetWithEndUserAccount(endUser.userId, address, asset, {
280
+ to: opts.to,
281
+ amount: opts.amount,
282
+ network: opts.network,
283
+ createRecipientAta: opts.createRecipientAta,
284
+ });
380
285
  },
381
286
  };
382
287
 
@@ -613,6 +613,7 @@ export class SolanaClient implements SolanaClientInterface {
613
613
  * @param {SendTransactionOptions} options - Parameters for sending the Solana transaction.
614
614
  * @param {string} options.network - The network to send the transaction to.
615
615
  * @param {string} options.transaction - The base64 encoded transaction to send.
616
+ * @param {boolean} [options.useCdpSponsor] - Whether CDP should sponsor the transaction fees.
616
617
  * @param {string} [options.idempotencyKey] - An idempotency key.
617
618
  *
618
619
  * @returns A promise that resolves to the transaction result.
@@ -622,6 +623,7 @@ export class SolanaClient implements SolanaClientInterface {
622
623
  * const signature = await cdp.solana.sendTransaction({
623
624
  * network: "solana-devnet",
624
625
  * transaction: "...",
626
+ * useCdpSponsor: true,
625
627
  * });
626
628
  * ```
627
629
  */
@@ -201,6 +201,8 @@ export interface SendTransactionOptions {
201
201
  network: SendSolanaTransactionBodyNetwork;
202
202
  /** The base64 encoded transaction to send. */
203
203
  transaction: string;
204
+ /** Whether CDP should sponsor the transaction fees. */
205
+ useCdpSponsor?: boolean;
204
206
  /** The idempotency key. */
205
207
  idempotencyKey?: string;
206
208
  }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @module Client
3
+ */
4
+
5
+ import {
6
+ createWebhookSubscription,
7
+ CreateWebhookSubscriptionOptions,
8
+ CreateWebhookSubscriptionResult,
9
+ } from "../../actions/webhooks/createWebhookSubscription.js";
10
+ import { Analytics } from "../../analytics.js";
11
+ import { CdpOpenApiClient } from "../../openapi-client/index.js";
12
+
13
+ /**
14
+ * The namespace containing all webhook methods.
15
+ */
16
+ export class WebhooksClient {
17
+ /**
18
+ * Creates a webhook subscription for wallet transaction events.
19
+ *
20
+ * @param {CreateWebhookSubscriptionOptions} options - Parameters for creating the webhook subscription.
21
+ * @param {string} [options.description] - A description of the webhook subscription.
22
+ * @param {WebhookEventType[]} options.eventTypes - The event types to subscribe to.
23
+ * @param {string} options.targetUrl - The URL to deliver webhook events to.
24
+ * @param {Record<string, string>} [options.targetHeaders] - Additional headers to include in webhook requests.
25
+ * @param {boolean} [options.isEnabled] - Whether the subscription is enabled. Defaults to `true`.
26
+ * @param {Record<string, string>} [options.metadata] - Additional metadata for the subscription.
27
+ *
28
+ * @returns A promise that resolves to the created webhook subscription.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const subscription = await cdp.webhooks.createSubscription({
33
+ * description: "Monitor wallet transactions",
34
+ * eventTypes: [
35
+ * "wallet.transaction.pending",
36
+ * "wallet.transaction.confirmed",
37
+ * "wallet.transaction.failed",
38
+ * ],
39
+ * targetUrl: "https://example.com/webhook",
40
+ * isEnabled: true,
41
+ * });
42
+ *
43
+ * console.log("Subscription ID:", subscription.subscriptionId);
44
+ * console.log("Secret:", subscription.secret);
45
+ * ```
46
+ */
47
+ async createSubscription(
48
+ options: CreateWebhookSubscriptionOptions,
49
+ ): Promise<CreateWebhookSubscriptionResult> {
50
+ Analytics.trackAction({
51
+ action: "create_webhook_subscription",
52
+ });
53
+
54
+ try {
55
+ return await createWebhookSubscription(CdpOpenApiClient, options);
56
+ } catch (error) {
57
+ Analytics.trackError(error, "createWebhookSubscription");
58
+ throw error;
59
+ }
60
+ }
61
+ }
package/index.ts CHANGED
@@ -19,8 +19,6 @@ export type {
19
19
  ListEndUsersOptions,
20
20
  EndUserAccount,
21
21
  RevokeDelegationForEndUserOptions,
22
- SignEvmHashOptions,
23
- SignEvmHashResult,
24
22
  SignEvmTransactionOptions,
25
23
  SignEvmTransactionResult,
26
24
  SignEvmMessageOptions,
@@ -35,8 +33,6 @@ export type {
35
33
  SendUserOperationResult,
36
34
  CreateEvmEip7702DelegationOptions as CreateEvmEip7702DelegationForEndUserOptions,
37
35
  CreateEvmEip7702DelegationForEndUserResult,
38
- SignSolanaHashOptions,
39
- SignSolanaHashResult,
40
36
  SignSolanaMessageOptions,
41
37
  SignSolanaMessageResult,
42
38
  SignSolanaTransactionOptions,
@@ -51,4 +47,10 @@ export {
51
47
  SPEND_PERMISSION_MANAGER_ADDRESS as spendPermissionManagerAddress,
52
48
  } from "./spend-permissions/constants.js";
53
49
 
50
+ export type {
51
+ CreateWebhookSubscriptionOptions,
52
+ CreateWebhookSubscriptionResult,
53
+ WebhookEventType,
54
+ } from "./actions/webhooks/index.js";
55
+
54
56
  export { parseEther, parseUnits } from "viem";
@@ -85,26 +85,6 @@ export const configure = (options: CdpOptions) => {
85
85
  expiresIn: options.expiresIn,
86
86
  debug: options.debugging,
87
87
  });
88
-
89
- /*
90
- * Delegated routing interceptor.
91
- * Embedded Wallet API's are exposed to the developer for delegated signing
92
- * via the /delegated path, which properly forwards the Authorization and
93
- * X-Wallet-Auth headers from the edge.
94
- *
95
- * Registered after withAuth so it runs BEFORE the auth interceptor (LIFO order).
96
- * This rewrites the URL first, then the auth interceptor computes JWT headers
97
- * (Authorization and X-Wallet-Auth) against the rewritten URL path, ensuring
98
- * the `uris` claim matches the actual request URL.
99
- * The API gateway validates the JWT, strips the /delegated prefix, and forwards
100
- * to the backend.
101
- */
102
- axiosInstance.interceptors.request.use(config => {
103
- if (config.url && isDelegatedEndUserPath(config.url)) {
104
- config.url = `/delegated${config.url}`;
105
- }
106
- return config;
107
- });
108
88
  };
109
89
 
110
90
  /**
@@ -327,20 +307,6 @@ export const cdpApiClient = async <T>(
327
307
  }
328
308
  };
329
309
 
330
- /**
331
- * Checks if the given request URL is a delegated end-user operation that should
332
- * be routed through the /platform/delegated gateway prefix.
333
- *
334
- * These endpoints require both Authorization and X-Wallet-Auth headers to be
335
- * forwarded by the API gateway, which the /delegated prefix enables.
336
- *
337
- * @param url - The request URL (relative, without base path).
338
- * @returns True if the path should be routed through /platform/delegated.
339
- */
340
- const isDelegatedEndUserPath = (url: string): boolean => {
341
- return /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/end-users\//.test(url);
342
- };
343
-
344
310
  /**
345
311
  * Validates the call to the cdpApiClient.
346
312
  *