@coinbase/cdp-sdk 1.49.1 → 1.50.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.
@@ -89,10 +89,13 @@ export class EndUserClient {
89
89
 
90
90
  const userId = options.userId ?? randomUUID();
91
91
 
92
- const endUser = await CdpOpenApiClient.createEndUser({
93
- ...options,
94
- userId,
95
- });
92
+ const endUser = await CdpOpenApiClient.createEndUser(
93
+ {
94
+ ...options,
95
+ userId,
96
+ },
97
+ options.idempotencyKey,
98
+ );
96
99
 
97
100
  return toEndUserAccount(CdpOpenApiClient, { endUser });
98
101
  }
@@ -192,9 +195,9 @@ export class EndUserClient {
192
195
  action: "add_end_user_evm_account",
193
196
  });
194
197
 
195
- const { userId } = options;
198
+ const { userId, idempotencyKey } = options;
196
199
 
197
- return CdpOpenApiClient.addEndUserEvmAccount(userId, {});
200
+ return CdpOpenApiClient.addEndUserEvmAccount(userId, {}, idempotencyKey);
198
201
  }
199
202
 
200
203
  /**
@@ -229,11 +232,13 @@ export class EndUserClient {
229
232
  action: "add_end_user_evm_smart_account",
230
233
  });
231
234
 
232
- const { userId, enableSpendPermissions } = options;
235
+ const { userId, enableSpendPermissions, idempotencyKey } = options;
233
236
 
234
- return CdpOpenApiClient.addEndUserEvmSmartAccount(userId, {
235
- enableSpendPermissions,
236
- });
237
+ return CdpOpenApiClient.addEndUserEvmSmartAccount(
238
+ userId,
239
+ { enableSpendPermissions },
240
+ idempotencyKey,
241
+ );
237
242
  }
238
243
 
239
244
  /**
@@ -258,9 +263,9 @@ export class EndUserClient {
258
263
  action: "add_end_user_solana_account",
259
264
  });
260
265
 
261
- const { userId } = options;
266
+ const { userId, idempotencyKey } = options;
262
267
 
263
- return CdpOpenApiClient.addEndUserSolanaAccount(userId, {});
268
+ return CdpOpenApiClient.addEndUserSolanaAccount(userId, {}, idempotencyKey);
264
269
  }
265
270
 
266
271
  /**
@@ -311,9 +316,9 @@ export class EndUserClient {
311
316
  action: "revoke_delegation_for_end_user",
312
317
  });
313
318
 
314
- const { userId } = options;
319
+ const { userId, idempotencyKey } = options;
315
320
 
316
- await CdpOpenApiClient.revokeDelegationForEndUser(userId, {});
321
+ await CdpOpenApiClient.revokeDelegationForEndUser(userId, {}, undefined, idempotencyKey);
317
322
  }
318
323
 
319
324
  // ─── Account-Scoped Delegation Methods ───
@@ -402,10 +407,12 @@ export class EndUserClient {
402
407
  async signEvmTransaction(options: SignEvmTransactionOptions): Promise<SignEvmTransactionResult> {
403
408
  Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
404
409
 
405
- return CdpOpenApiClient.signEvmTransactionWithEndUserAccount(options.userId, {
406
- address: options.address,
407
- transaction: options.transaction,
408
- });
410
+ return CdpOpenApiClient.signEvmTransactionWithEndUserAccount(
411
+ options.userId,
412
+ { address: options.address, transaction: options.transaction },
413
+ undefined,
414
+ options.idempotencyKey,
415
+ );
409
416
  }
410
417
 
411
418
  /**
@@ -428,10 +435,12 @@ export class EndUserClient {
428
435
  async signEvmMessage(options: SignEvmMessageOptions): Promise<SignEvmMessageResult> {
429
436
  Analytics.trackAction({ action: "end_user_sign_evm_message" });
430
437
 
431
- return CdpOpenApiClient.signEvmMessageWithEndUserAccount(options.userId, {
432
- address: options.address,
433
- message: options.message,
434
- });
438
+ return CdpOpenApiClient.signEvmMessageWithEndUserAccount(
439
+ options.userId,
440
+ { address: options.address, message: options.message },
441
+ undefined,
442
+ options.idempotencyKey,
443
+ );
435
444
  }
436
445
 
437
446
  /**
@@ -454,10 +463,12 @@ export class EndUserClient {
454
463
  async signEvmTypedData(options: SignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
455
464
  Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
456
465
 
457
- return CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(options.userId, {
458
- address: options.address,
459
- typedData: options.typedData,
460
- });
466
+ return CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(
467
+ options.userId,
468
+ { address: options.address, typedData: options.typedData },
469
+ undefined,
470
+ options.idempotencyKey,
471
+ );
461
472
  }
462
473
 
463
474
  // ─── Delegated EVM Send Methods ───
@@ -483,11 +494,12 @@ export class EndUserClient {
483
494
  async sendEvmTransaction(options: SendEvmTransactionOptions): Promise<SendEvmTransactionResult> {
484
495
  Analytics.trackAction({ action: "end_user_send_evm_transaction" });
485
496
 
486
- return CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(options.userId, {
487
- address: options.address,
488
- transaction: options.transaction,
489
- network: options.network,
490
- });
497
+ return CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(
498
+ options.userId,
499
+ { address: options.address, transaction: options.transaction, network: options.network },
500
+ undefined,
501
+ options.idempotencyKey,
502
+ );
491
503
  }
492
504
 
493
505
  /**
@@ -514,13 +526,20 @@ export class EndUserClient {
514
526
 
515
527
  const asset = options.asset ?? "usdc";
516
528
 
517
- return CdpOpenApiClient.sendEvmAssetWithEndUserAccount(options.userId, options.address, asset, {
518
- to: options.to,
519
- amount: options.amount,
520
- network: options.network,
521
- useCdpPaymaster: options.useCdpPaymaster,
522
- paymasterUrl: options.paymasterUrl,
523
- });
529
+ return CdpOpenApiClient.sendEvmAssetWithEndUserAccount(
530
+ options.userId,
531
+ options.address,
532
+ asset,
533
+ {
534
+ to: options.to,
535
+ amount: options.amount,
536
+ network: options.network,
537
+ useCdpPaymaster: options.useCdpPaymaster,
538
+ paymasterUrl: options.paymasterUrl,
539
+ },
540
+ undefined,
541
+ options.idempotencyKey,
542
+ );
524
543
  }
525
544
 
526
545
  /**
@@ -544,13 +563,19 @@ export class EndUserClient {
544
563
  async sendUserOperation(options: SendUserOperationOptions): Promise<SendUserOperationResult> {
545
564
  Analytics.trackAction({ action: "end_user_send_user_operation" });
546
565
 
547
- return CdpOpenApiClient.sendUserOperationWithEndUserAccount(options.userId, options.address, {
548
- network: options.network,
549
- calls: options.calls,
550
- useCdpPaymaster: options.useCdpPaymaster,
551
- paymasterUrl: options.paymasterUrl,
552
- dataSuffix: options.dataSuffix,
553
- });
566
+ return CdpOpenApiClient.sendUserOperationWithEndUserAccount(
567
+ options.userId,
568
+ options.address,
569
+ {
570
+ network: options.network,
571
+ calls: options.calls,
572
+ useCdpPaymaster: options.useCdpPaymaster,
573
+ paymasterUrl: options.paymasterUrl,
574
+ dataSuffix: options.dataSuffix,
575
+ },
576
+ undefined,
577
+ options.idempotencyKey,
578
+ );
554
579
  }
555
580
 
556
581
  // ─── Delegated EVM EIP-7702 Delegation Method ───
@@ -577,11 +602,16 @@ export class EndUserClient {
577
602
  ): Promise<CreateEvmEip7702DelegationForEndUserResult> {
578
603
  Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
579
604
 
580
- return CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(options.userId, {
581
- address: options.address,
582
- network: options.network,
583
- enableSpendPermissions: options.enableSpendPermissions,
584
- });
605
+ return CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(
606
+ options.userId,
607
+ {
608
+ address: options.address,
609
+ network: options.network,
610
+ enableSpendPermissions: options.enableSpendPermissions,
611
+ },
612
+ undefined,
613
+ options.idempotencyKey,
614
+ );
585
615
  }
586
616
 
587
617
  // ─── Delegated Solana Sign Methods ───
@@ -606,10 +636,12 @@ export class EndUserClient {
606
636
  async signSolanaMessage(options: SignSolanaMessageOptions): Promise<SignSolanaMessageResult> {
607
637
  Analytics.trackAction({ action: "end_user_sign_solana_message" });
608
638
 
609
- return CdpOpenApiClient.signSolanaMessageWithEndUserAccount(options.userId, {
610
- address: options.address,
611
- message: options.message,
612
- });
639
+ return CdpOpenApiClient.signSolanaMessageWithEndUserAccount(
640
+ options.userId,
641
+ { address: options.address, message: options.message },
642
+ undefined,
643
+ options.idempotencyKey,
644
+ );
613
645
  }
614
646
 
615
647
  /**
@@ -634,10 +666,12 @@ export class EndUserClient {
634
666
  ): Promise<SignSolanaTransactionResult> {
635
667
  Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
636
668
 
637
- return CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(options.userId, {
638
- address: options.address,
639
- transaction: options.transaction,
640
- });
669
+ return CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(
670
+ options.userId,
671
+ { address: options.address, transaction: options.transaction },
672
+ undefined,
673
+ options.idempotencyKey,
674
+ );
641
675
  }
642
676
 
643
677
  // ─── Delegated Solana Send Methods ───
@@ -665,11 +699,16 @@ export class EndUserClient {
665
699
  ): Promise<SendSolanaTransactionResult> {
666
700
  Analytics.trackAction({ action: "end_user_send_solana_transaction" });
667
701
 
668
- return CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(options.userId, {
669
- address: options.address,
670
- transaction: options.transaction,
671
- network: options.network,
672
- });
702
+ return CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(
703
+ options.userId,
704
+ {
705
+ address: options.address,
706
+ transaction: options.transaction,
707
+ network: options.network,
708
+ },
709
+ undefined,
710
+ options.idempotencyKey,
711
+ );
673
712
  }
674
713
 
675
714
  /**
@@ -706,6 +745,8 @@ export class EndUserClient {
706
745
  network: options.network,
707
746
  createRecipientAta: options.createRecipientAta,
708
747
  },
748
+ undefined,
749
+ options.idempotencyKey,
709
750
  );
710
751
  }
711
752
 
@@ -809,12 +850,15 @@ export class EndUserClient {
809
850
  privateKeyBytes,
810
851
  );
811
852
 
812
- const endUser = await CdpOpenApiClient.importEndUser({
813
- userId,
814
- authenticationMethods: options.authenticationMethods,
815
- encryptedPrivateKey: encryptedPrivateKey.toString("base64"),
816
- keyType: options.keyType,
817
- });
853
+ const endUser = await CdpOpenApiClient.importEndUser(
854
+ {
855
+ userId,
856
+ authenticationMethods: options.authenticationMethods,
857
+ encryptedPrivateKey: encryptedPrivateKey.toString("base64"),
858
+ keyType: options.keyType,
859
+ },
860
+ options.idempotencyKey,
861
+ );
818
862
 
819
863
  return toEndUserAccount(CdpOpenApiClient, { endUser });
820
864
  }
@@ -59,7 +59,10 @@ export type ListEndUsersOptions = ListEndUsersParams;
59
59
  /**
60
60
  * The options for creating an end user.
61
61
  */
62
- export type CreateEndUserOptions = CreateEndUserBody;
62
+ export type CreateEndUserOptions = CreateEndUserBody & {
63
+ /** Optional idempotency key for safe retries. */
64
+ idempotencyKey?: string;
65
+ };
63
66
 
64
67
  /**
65
68
  * The options for adding an EVM account to an end user.
@@ -69,6 +72,8 @@ export interface AddEndUserEvmAccountOptions {
69
72
  * The unique identifier of the end user.
70
73
  */
71
74
  userId: string;
75
+ /** Optional idempotency key for safe retries. */
76
+ idempotencyKey?: string;
72
77
  }
73
78
 
74
79
  /**
@@ -88,6 +93,8 @@ export interface AddEndUserEvmSmartAccountOptions {
88
93
  * If true, enables spend permissions for the EVM smart account.
89
94
  */
90
95
  enableSpendPermissions: boolean;
96
+ /** Optional idempotency key for safe retries. */
97
+ idempotencyKey?: string;
91
98
  }
92
99
 
93
100
  /**
@@ -103,6 +110,8 @@ export interface AddEndUserSolanaAccountOptions {
103
110
  * The unique identifier of the end user.
104
111
  */
105
112
  userId: string;
113
+ /** Optional idempotency key for safe retries. */
114
+ idempotencyKey?: string;
106
115
  }
107
116
 
108
117
  /**
@@ -139,6 +148,8 @@ export interface ImportEndUserOptions {
139
148
  * Defaults to the known CDP public key.
140
149
  */
141
150
  encryptionPublicKey?: string;
151
+ /** Optional idempotency key for safe retries. */
152
+ idempotencyKey?: string;
142
153
  }
143
154
 
144
155
  /**
@@ -164,6 +175,8 @@ export interface RevokeDelegationForEndUserOptions {
164
175
  * The unique identifier of the end user.
165
176
  */
166
177
  userId: string;
178
+ /** Optional idempotency key for safe retries. */
179
+ idempotencyKey?: string;
167
180
  }
168
181
 
169
182
  // ─── Account-Scoped Delegation Options/Results ───
@@ -225,6 +238,8 @@ export interface SignEvmTransactionOptions {
225
238
  address: string;
226
239
  /** The RLP-serialized EIP-1559 transaction to sign, hex-encoded. */
227
240
  transaction: string;
241
+ /** Optional idempotency key for safe retries. */
242
+ idempotencyKey?: string;
228
243
  }
229
244
 
230
245
  /**
@@ -242,6 +257,8 @@ export interface SignEvmMessageOptions {
242
257
  address: string;
243
258
  /** The EIP-191 message to sign. */
244
259
  message: string;
260
+ /** Optional idempotency key for safe retries. */
261
+ idempotencyKey?: string;
245
262
  }
246
263
 
247
264
  /**
@@ -259,6 +276,8 @@ export interface SignEvmTypedDataOptions {
259
276
  address: string;
260
277
  /** The EIP-712 typed data to sign. */
261
278
  typedData: EIP712Message;
279
+ /** Optional idempotency key for safe retries. */
280
+ idempotencyKey?: string;
262
281
  }
263
282
 
264
283
  /**
@@ -280,6 +299,8 @@ export interface SendEvmTransactionOptions {
280
299
  transaction: string;
281
300
  /** The network to send the transaction on. */
282
301
  network: SendEvmTransactionWithEndUserAccountBodyNetwork;
302
+ /** Optional idempotency key for safe retries. */
303
+ idempotencyKey?: string;
283
304
  }
284
305
 
285
306
  /**
@@ -307,6 +328,8 @@ export interface SendEvmAssetOptions {
307
328
  useCdpPaymaster?: boolean;
308
329
  /** A custom paymaster URL. */
309
330
  paymasterUrl?: string;
331
+ /** Optional idempotency key for safe retries. */
332
+ idempotencyKey?: string;
310
333
  }
311
334
 
312
335
  /**
@@ -332,6 +355,8 @@ export interface SendUserOperationOptions {
332
355
  paymasterUrl?: string;
333
356
  /** An optional data suffix. */
334
357
  dataSuffix?: string;
358
+ /** Optional idempotency key for safe retries. */
359
+ idempotencyKey?: string;
335
360
  }
336
361
 
337
362
  /**
@@ -353,6 +378,8 @@ export interface CreateEvmEip7702DelegationOptions {
353
378
  network: EvmEip7702DelegationNetwork;
354
379
  /** Whether to enable spend permissions for the delegation. */
355
380
  enableSpendPermissions?: boolean;
381
+ /** Optional idempotency key for safe retries. */
382
+ idempotencyKey?: string;
356
383
  }
357
384
 
358
385
  /**
@@ -373,6 +400,8 @@ export interface SignSolanaMessageOptions {
373
400
  address: string;
374
401
  /** The base64-encoded message to sign. */
375
402
  message: string;
403
+ /** Optional idempotency key for safe retries. */
404
+ idempotencyKey?: string;
376
405
  }
377
406
 
378
407
  /**
@@ -390,6 +419,8 @@ export interface SignSolanaTransactionOptions {
390
419
  address: string;
391
420
  /** The base64-encoded Solana transaction to sign. */
392
421
  transaction: string;
422
+ /** Optional idempotency key for safe retries. */
423
+ idempotencyKey?: string;
393
424
  }
394
425
 
395
426
  /**
@@ -411,6 +442,8 @@ export interface SendSolanaTransactionOptions {
411
442
  transaction: string;
412
443
  /** The Solana network to send on. */
413
444
  network: SendSolanaTransactionWithEndUserAccountBodyNetwork;
445
+ /** Optional idempotency key for safe retries. */
446
+ idempotencyKey?: string;
414
447
  }
415
448
 
416
449
  /**
@@ -436,6 +469,8 @@ export interface SendSolanaAssetOptions {
436
469
  network: SendSolanaAssetWithEndUserAccountBodyNetwork;
437
470
  /** Whether to create the recipient's associated token account if it doesn't exist. */
438
471
  createRecipientAta?: boolean;
472
+ /** Optional idempotency key for safe retries. */
473
+ idempotencyKey?: string;
439
474
  }
440
475
 
441
476
  /**
@@ -453,6 +488,8 @@ export interface AccountSignEvmTransactionOptions {
453
488
  address?: string;
454
489
  /** The RLP-serialized EIP-1559 transaction to sign, hex-encoded. */
455
490
  transaction: string;
491
+ /** Optional idempotency key for safe retries. */
492
+ idempotencyKey?: string;
456
493
  }
457
494
 
458
495
  /**
@@ -463,6 +500,8 @@ export interface AccountSignEvmMessageOptions {
463
500
  address?: string;
464
501
  /** The EIP-191 message to sign. */
465
502
  message: string;
503
+ /** Optional idempotency key for safe retries. */
504
+ idempotencyKey?: string;
466
505
  }
467
506
 
468
507
  /**
@@ -473,6 +512,8 @@ export interface AccountSignEvmTypedDataOptions {
473
512
  address?: string;
474
513
  /** The EIP-712 typed data to sign. */
475
514
  typedData: EIP712Message;
515
+ /** Optional idempotency key for safe retries. */
516
+ idempotencyKey?: string;
476
517
  }
477
518
 
478
519
  /**
@@ -485,6 +526,8 @@ export interface AccountSendEvmTransactionOptions {
485
526
  transaction: string;
486
527
  /** The network to send the transaction on. */
487
528
  network: SendEvmTransactionWithEndUserAccountBodyNetwork;
529
+ /** Optional idempotency key for safe retries. */
530
+ idempotencyKey?: string;
488
531
  }
489
532
 
490
533
  /**
@@ -505,6 +548,8 @@ export interface AccountSendEvmAssetOptions {
505
548
  useCdpPaymaster?: boolean;
506
549
  /** A custom paymaster URL. */
507
550
  paymasterUrl?: string;
551
+ /** Optional idempotency key for safe retries. */
552
+ idempotencyKey?: string;
508
553
  }
509
554
 
510
555
  /**
@@ -523,6 +568,8 @@ export interface AccountSendUserOperationOptions {
523
568
  paymasterUrl?: string;
524
569
  /** An optional data suffix. */
525
570
  dataSuffix?: string;
571
+ /** Optional idempotency key for safe retries. */
572
+ idempotencyKey?: string;
526
573
  }
527
574
 
528
575
  /**
@@ -535,6 +582,8 @@ export interface AccountCreateEvmEip7702DelegationOptions {
535
582
  network: EvmEip7702DelegationNetwork;
536
583
  /** Whether to enable spend permissions for the delegation. */
537
584
  enableSpendPermissions?: boolean;
585
+ /** Optional idempotency key for safe retries. */
586
+ idempotencyKey?: string;
538
587
  }
539
588
 
540
589
  /**
@@ -545,6 +594,8 @@ export interface AccountSignSolanaMessageOptions {
545
594
  address?: string;
546
595
  /** The base64-encoded message to sign. */
547
596
  message: string;
597
+ /** Optional idempotency key for safe retries. */
598
+ idempotencyKey?: string;
548
599
  }
549
600
 
550
601
  /**
@@ -555,6 +606,8 @@ export interface AccountSignSolanaTransactionOptions {
555
606
  address?: string;
556
607
  /** The base64-encoded Solana transaction to sign. */
557
608
  transaction: string;
609
+ /** Optional idempotency key for safe retries. */
610
+ idempotencyKey?: string;
558
611
  }
559
612
 
560
613
  /**
@@ -567,6 +620,8 @@ export interface AccountSendSolanaTransactionOptions {
567
620
  transaction: string;
568
621
  /** The Solana network to send on. */
569
622
  network: SendSolanaTransactionWithEndUserAccountBodyNetwork;
623
+ /** Optional idempotency key for safe retries. */
624
+ idempotencyKey?: string;
570
625
  }
571
626
 
572
627
  /**
@@ -585,6 +640,8 @@ export interface AccountSendSolanaAssetOptions {
585
640
  network: SendSolanaAssetWithEndUserAccountBodyNetwork;
586
641
  /** Whether to create the recipient's associated token account if it doesn't exist. */
587
642
  createRecipientAta?: boolean;
643
+ /** Optional idempotency key for safe retries. */
644
+ idempotencyKey?: string;
588
645
  }
589
646
 
590
647
  /**
@@ -595,6 +652,8 @@ export interface AddEvmSmartAccountOptions {
595
652
  * If true, enables spend permissions for the EVM smart account.
596
653
  */
597
654
  enableSpendPermissions: boolean;
655
+ /** Optional idempotency key for safe retries. */
656
+ idempotencyKey?: string;
598
657
  }
599
658
 
600
659
  /**
@@ -617,7 +676,7 @@ export type EndUserAccountActions = {
617
676
  * console.log(result.evmAccount.address);
618
677
  * ```
619
678
  */
620
- addEvmAccount: () => Promise<AddEndUserEvmAccountResult>;
679
+ addEvmAccount: (idempotencyKey?: string) => Promise<AddEndUserEvmAccountResult>;
621
680
 
622
681
  /**
623
682
  * Adds an EVM smart account to this end user.
@@ -657,7 +716,7 @@ export type EndUserAccountActions = {
657
716
  * console.log(result.solanaAccount.address);
658
717
  * ```
659
718
  */
660
- addSolanaAccount: () => Promise<AddEndUserSolanaAccountResult>;
719
+ addSolanaAccount: (idempotencyKey?: string) => Promise<AddEndUserSolanaAccountResult>;
661
720
 
662
721
  /**
663
722
  * Gets the active delegation for this end user, if one exists.
@@ -687,7 +746,7 @@ export type EndUserAccountActions = {
687
746
  * await endUser.revokeDelegation();
688
747
  * ```
689
748
  */
690
- revokeDelegation: () => Promise<void>;
749
+ revokeDelegation: (idempotencyKey?: string) => Promise<void>;
691
750
 
692
751
  // ─── Account-Scoped Delegation Methods ───
693
752