@coinbase/cdp-sdk 1.8.0 → 1.9.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 (113) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +182 -105
  3. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  4. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  5. package/_cjs/accounts/solana/toSolanaAccount.js +7 -0
  6. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  7. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
  8. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  9. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  10. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  11. package/_cjs/actions/evm/transfer/transfer.js +2 -39
  12. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  13. package/_cjs/actions/evm/transfer/utils.js +0 -12
  14. package/_cjs/actions/evm/transfer/utils.js.map +1 -1
  15. package/_cjs/actions/solana/constants.js +9 -0
  16. package/_cjs/actions/solana/constants.js.map +1 -0
  17. package/_cjs/actions/solana/transfer.js +117 -0
  18. package/_cjs/actions/solana/transfer.js.map +1 -0
  19. package/_cjs/actions/solana/utils.js +66 -0
  20. package/_cjs/actions/solana/utils.js.map +1 -0
  21. package/_cjs/analytics.js +2 -0
  22. package/_cjs/analytics.js.map +1 -1
  23. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
  24. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  25. package/_cjs/openapi-client/generated/index.msw.js +3 -3
  26. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  27. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
  28. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  29. package/_cjs/policies/schema.js +60 -1
  30. package/_cjs/policies/schema.js.map +1 -1
  31. package/_cjs/version.js +1 -1
  32. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  33. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  34. package/_esm/accounts/solana/toSolanaAccount.js +7 -0
  35. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  36. package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
  37. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  38. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  39. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  40. package/_esm/actions/evm/transfer/transfer.js +2 -39
  41. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  42. package/_esm/actions/evm/transfer/utils.js +0 -11
  43. package/_esm/actions/evm/transfer/utils.js.map +1 -1
  44. package/_esm/actions/solana/constants.js +6 -0
  45. package/_esm/actions/solana/constants.js.map +1 -0
  46. package/_esm/actions/solana/transfer.js +114 -0
  47. package/_esm/actions/solana/transfer.js.map +1 -0
  48. package/_esm/actions/solana/utils.js +61 -0
  49. package/_esm/actions/solana/utils.js.map +1 -0
  50. package/_esm/analytics.js +2 -0
  51. package/_esm/analytics.js.map +1 -1
  52. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
  53. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  54. package/_esm/openapi-client/generated/index.msw.js +3 -3
  55. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  56. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
  57. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  58. package/_esm/policies/schema.js +59 -0
  59. package/_esm/policies/schema.js.map +1 -1
  60. package/_esm/version.js +1 -1
  61. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  62. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  63. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  64. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
  65. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  66. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
  67. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  68. package/_types/actions/evm/transfer/transfer.d.ts +6 -4
  69. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  70. package/_types/actions/evm/transfer/types.d.ts +7 -52
  71. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  72. package/_types/actions/evm/transfer/utils.d.ts +0 -619
  73. package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
  74. package/_types/actions/evm/types.d.ts +140 -68
  75. package/_types/actions/evm/types.d.ts.map +1 -1
  76. package/_types/actions/solana/constants.d.ts +6 -0
  77. package/_types/actions/solana/constants.d.ts.map +1 -0
  78. package/_types/actions/solana/transfer.d.ts +36 -0
  79. package/_types/actions/solana/transfer.d.ts.map +1 -0
  80. package/_types/actions/solana/types.d.ts +27 -0
  81. package/_types/actions/solana/types.d.ts.map +1 -1
  82. package/_types/actions/solana/utils.d.ts +34 -0
  83. package/_types/actions/solana/utils.d.ts.map +1 -0
  84. package/_types/analytics.d.ts.map +1 -1
  85. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +95 -17
  86. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  87. package/_types/openapi-client/generated/index.msw.d.ts +3 -3
  88. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  89. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
  90. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  91. package/_types/policies/schema.d.ts +630 -0
  92. package/_types/policies/schema.d.ts.map +1 -1
  93. package/_types/version.d.ts +1 -1
  94. package/accounts/evm/toEvmServerAccount.ts +7 -6
  95. package/accounts/evm/toEvmSmartAccount.ts +1 -2
  96. package/accounts/solana/toSolanaAccount.ts +7 -0
  97. package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
  98. package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
  99. package/actions/evm/transfer/transfer.ts +10 -51
  100. package/actions/evm/transfer/types.ts +8 -66
  101. package/actions/evm/transfer/utils.ts +0 -13
  102. package/actions/evm/types.ts +143 -78
  103. package/actions/solana/constants.ts +6 -0
  104. package/actions/solana/transfer.ts +219 -0
  105. package/actions/solana/types.ts +28 -0
  106. package/actions/solana/utils.ts +79 -0
  107. package/analytics.ts +2 -0
  108. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +134 -18
  109. package/openapi-client/generated/index.msw.ts +3 -3
  110. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
  111. package/package.json +2 -1
  112. package/policies/schema.ts +83 -0
  113. package/version.ts +1 -1
@@ -333,6 +333,125 @@ export type SignEvmTransactionCriteriaItem = EthValueCriterion | EvmAddressCrite
333
333
  */
334
334
  export type SignEvmTransactionCriteria = SignEvmTransactionCriteriaItem[];
335
335
 
336
+ /**
337
+ * Whether matching the rule will cause the request to be rejected or accepted.
338
+ */
339
+ export type SignEvmTransactionRuleAction =
340
+ (typeof SignEvmTransactionRuleAction)[keyof typeof SignEvmTransactionRuleAction];
341
+
342
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
343
+ export const SignEvmTransactionRuleAction = {
344
+ reject: "reject",
345
+ accept: "accept",
346
+ } as const;
347
+
348
+ /**
349
+ * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
350
+ */
351
+ export type SignEvmTransactionRuleOperation =
352
+ (typeof SignEvmTransactionRuleOperation)[keyof typeof SignEvmTransactionRuleOperation];
353
+
354
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
355
+ export const SignEvmTransactionRuleOperation = {
356
+ signEvmTransaction: "signEvmTransaction",
357
+ } as const;
358
+
359
+ export interface SignEvmTransactionRule {
360
+ /** Whether matching the rule will cause the request to be rejected or accepted. */
361
+ action: SignEvmTransactionRuleAction;
362
+ /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
363
+ operation: SignEvmTransactionRuleOperation;
364
+ criteria: SignEvmTransactionCriteria;
365
+ }
366
+
367
+ /**
368
+ * The type of criterion to use. This should be `evmNetwork`.
369
+ */
370
+ export type EvmNetworkCriterionType =
371
+ (typeof EvmNetworkCriterionType)[keyof typeof EvmNetworkCriterionType];
372
+
373
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
374
+ export const EvmNetworkCriterionType = {
375
+ evmNetwork: "evmNetwork",
376
+ } as const;
377
+
378
+ /**
379
+ * The network the transaction is for.
380
+ */
381
+ export type EvmNetworkCriterionNetworksItem =
382
+ (typeof EvmNetworkCriterionNetworksItem)[keyof typeof EvmNetworkCriterionNetworksItem];
383
+
384
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
385
+ export const EvmNetworkCriterionNetworksItem = {
386
+ "base-sepolia": "base-sepolia",
387
+ base: "base",
388
+ } as const;
389
+
390
+ /**
391
+ * The operator to use for the comparison. The transaction's intended `network` will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side.
392
+ */
393
+ export type EvmNetworkCriterionOperator =
394
+ (typeof EvmNetworkCriterionOperator)[keyof typeof EvmNetworkCriterionOperator];
395
+
396
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
397
+ export const EvmNetworkCriterionOperator = {
398
+ in: "in",
399
+ not_in: "not in",
400
+ } as const;
401
+
402
+ /**
403
+ * A schema for specifying a criterion for the intended `network` of an EVM transaction.
404
+ */
405
+ export interface EvmNetworkCriterion {
406
+ /** The type of criterion to use. This should be `evmNetwork`. */
407
+ type: EvmNetworkCriterionType;
408
+ /** A list of EVM network identifiers that the transaction's intended `network` should be compared to. */
409
+ networks: EvmNetworkCriterionNetworksItem[];
410
+ /** The operator to use for the comparison. The transaction's intended `network` will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side. */
411
+ operator: EvmNetworkCriterionOperator;
412
+ }
413
+
414
+ export type SendEvmTransactionCriteriaItem =
415
+ | EthValueCriterion
416
+ | EvmAddressCriterion
417
+ | EvmNetworkCriterion;
418
+
419
+ /**
420
+ * A schema for specifying the rejection criteria for the SignEvmTransaction operation.
421
+ */
422
+ export type SendEvmTransactionCriteria = SendEvmTransactionCriteriaItem[];
423
+
424
+ /**
425
+ * Whether matching the rule will cause the request to be rejected or accepted.
426
+ */
427
+ export type SendEvmTransactionRuleAction =
428
+ (typeof SendEvmTransactionRuleAction)[keyof typeof SendEvmTransactionRuleAction];
429
+
430
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
431
+ export const SendEvmTransactionRuleAction = {
432
+ reject: "reject",
433
+ accept: "accept",
434
+ } as const;
435
+
436
+ /**
437
+ * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
438
+ */
439
+ export type SendEvmTransactionRuleOperation =
440
+ (typeof SendEvmTransactionRuleOperation)[keyof typeof SendEvmTransactionRuleOperation];
441
+
442
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
443
+ export const SendEvmTransactionRuleOperation = {
444
+ sendEvmTransaction: "sendEvmTransaction",
445
+ } as const;
446
+
447
+ export interface SendEvmTransactionRule {
448
+ /** Whether matching the rule will cause the request to be rejected or accepted. */
449
+ action: SendEvmTransactionRuleAction;
450
+ /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
451
+ operation: SendEvmTransactionRuleOperation;
452
+ criteria: SendEvmTransactionCriteria;
453
+ }
454
+
336
455
  /**
337
456
  * The type of criterion to use. This should be `solAddress`.
338
457
  */
@@ -376,10 +495,11 @@ export type SignSolTransactionCriteria = SolAddressCriterion[];
376
495
  /**
377
496
  * Whether matching the rule will cause the request to be rejected or accepted.
378
497
  */
379
- export type RuleAction = (typeof RuleAction)[keyof typeof RuleAction];
498
+ export type SignSolTransactionRuleAction =
499
+ (typeof SignSolTransactionRuleAction)[keyof typeof SignSolTransactionRuleAction];
380
500
 
381
501
  // eslint-disable-next-line @typescript-eslint/no-redeclare
382
- export const RuleAction = {
502
+ export const SignSolTransactionRuleAction = {
383
503
  reject: "reject",
384
504
  accept: "accept",
385
505
  } as const;
@@ -387,30 +507,26 @@ export const RuleAction = {
387
507
  /**
388
508
  * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
389
509
  */
390
- export type RuleOperation = (typeof RuleOperation)[keyof typeof RuleOperation];
510
+ export type SignSolTransactionRuleOperation =
511
+ (typeof SignSolTransactionRuleOperation)[keyof typeof SignSolTransactionRuleOperation];
391
512
 
392
513
  // eslint-disable-next-line @typescript-eslint/no-redeclare
393
- export const RuleOperation = {
394
- signEvmTransaction: "signEvmTransaction",
514
+ export const SignSolTransactionRuleOperation = {
395
515
  signSolTransaction: "signSolTransaction",
396
516
  } as const;
397
517
 
398
- /**
399
- * The set of criteria for the rule. There is a limit of 10 criteria per rule.
400
- */
401
- export type RuleCriteria = SignEvmTransactionCriteria | SignSolTransactionCriteria;
518
+ export interface SignSolTransactionRule {
519
+ /** Whether matching the rule will cause the request to be rejected or accepted. */
520
+ action: SignSolTransactionRuleAction;
521
+ /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
522
+ operation: SignSolTransactionRuleOperation;
523
+ criteria: SignSolTransactionCriteria;
524
+ }
402
525
 
403
526
  /**
404
527
  * A rule that limits the behavior of an account.
405
528
  */
406
- export interface Rule {
407
- /** Whether matching the rule will cause the request to be rejected or accepted. */
408
- action: RuleAction;
409
- /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
410
- operation: RuleOperation;
411
- /** The set of criteria for the rule. There is a limit of 10 criteria per rule. */
412
- criteria: RuleCriteria;
413
- }
529
+ export type Rule = SignEvmTransactionRule | SendEvmTransactionRule | SignSolTransactionRule;
414
530
 
415
531
  /**
416
532
  * The scope of the policy. Only one project-level policy can exist at any time.
@@ -430,7 +546,7 @@ export interface Policy {
430
546
  */
431
547
  id: string;
432
548
  /**
433
- * An optional human-readable description of the policy.
549
+ * An optional human-readable description of the policy.
434
550
  Policy descriptions can consist of alphanumeric characters, spaces, commas, and periods, and be 50 characters or less.
435
551
  * @pattern ^[A-Za-z0-9 ,.]{1,50}$
436
552
  */
@@ -1,6 +1,6 @@
1
- export * from "./evm-accounts/evm-accounts.msw.js";
2
- export * from "./evm-token-balances/evm-token-balances.msw.js";
3
- export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
4
1
  export * from "./faucets/faucets.msw.js";
5
2
  export * from "./policy-engine/policy-engine.msw.js";
3
+ export * from "./evm-accounts/evm-accounts.msw.js";
4
+ export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
5
+ export * from "./evm-token-balances/evm-token-balances.msw.js";
6
6
  export * from "./solana-accounts/solana-accounts.msw.js";
@@ -12,6 +12,7 @@ import { HttpResponse, delay, http } from "msw";
12
12
  import type {
13
13
  EthValueCriterion,
14
14
  EvmAddressCriterion,
15
+ EvmNetworkCriterion,
15
16
  ListPolicies200,
16
17
  Policy,
17
18
  SolAddressCriterion,
@@ -41,6 +42,17 @@ export const getListPoliciesResponseEvmAddressCriterionMock = (
41
42
  ...overrideResponse,
42
43
  });
43
44
 
45
+ export const getListPoliciesResponseEvmNetworkCriterionMock = (
46
+ overrideResponse: Partial<EvmNetworkCriterion> = {},
47
+ ): EvmNetworkCriterion => ({
48
+ ...{
49
+ type: faker.helpers.arrayElement(["evmNetwork"] as const),
50
+ networks: faker.helpers.arrayElements(["base-sepolia", "base"] as const),
51
+ operator: faker.helpers.arrayElement(["in", "not in"] as const),
52
+ },
53
+ ...overrideResponse,
54
+ });
55
+
44
56
  export const getListPoliciesResponseSolAddressCriterionMock = (
45
57
  overrideResponse: Partial<SolAddressCriterion> = {},
46
58
  ): SolAddressCriterion => ({
@@ -67,28 +79,48 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
67
79
  ]),
68
80
  scope: faker.helpers.arrayElement(["project", "account"] as const),
69
81
  rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
70
- () => ({
71
- action: faker.helpers.arrayElement(["reject", "accept"] as const),
72
- operation: faker.helpers.arrayElement([
73
- "signEvmTransaction",
74
- "signSolTransaction",
75
- ] as const),
76
- criteria: faker.helpers.arrayElement([
77
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
78
- () =>
82
+ () =>
83
+ faker.helpers.arrayElement([
84
+ {
85
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
86
+ operation: faker.helpers.arrayElement(["signEvmTransaction"] as const),
87
+ criteria: Array.from(
88
+ { length: faker.number.int({ min: 1, max: 10 }) },
89
+ (_, i) => i + 1,
90
+ ).map(() =>
79
91
  faker.helpers.arrayElement([
80
92
  { ...getListPoliciesResponseEthValueCriterionMock() },
81
93
  { ...getListPoliciesResponseEvmAddressCriterionMock() },
82
94
  ]),
83
- ),
84
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
85
- () =>
95
+ ),
96
+ },
97
+ {
98
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
99
+ operation: faker.helpers.arrayElement(["sendEvmTransaction"] as const),
100
+ criteria: Array.from(
101
+ { length: faker.number.int({ min: 1, max: 10 }) },
102
+ (_, i) => i + 1,
103
+ ).map(() =>
104
+ faker.helpers.arrayElement([
105
+ { ...getListPoliciesResponseEthValueCriterionMock() },
106
+ { ...getListPoliciesResponseEvmAddressCriterionMock() },
107
+ { ...getListPoliciesResponseEvmNetworkCriterionMock() },
108
+ ]),
109
+ ),
110
+ },
111
+ {
112
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
113
+ operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
114
+ criteria: Array.from(
115
+ { length: faker.number.int({ min: 1, max: 10 }) },
116
+ (_, i) => i + 1,
117
+ ).map(() =>
86
118
  faker.helpers.arrayElement([
87
119
  { ...getListPoliciesResponseSolAddressCriterionMock() },
88
120
  ]),
89
- ),
121
+ ),
122
+ },
90
123
  ]),
91
- }),
92
124
  ),
93
125
  createdAt: faker.string.alpha(20),
94
126
  updatedAt: faker.string.alpha(20),
@@ -122,6 +154,17 @@ export const getCreatePolicyResponseEvmAddressCriterionMock = (
122
154
  ...overrideResponse,
123
155
  });
124
156
 
157
+ export const getCreatePolicyResponseEvmNetworkCriterionMock = (
158
+ overrideResponse: Partial<EvmNetworkCriterion> = {},
159
+ ): EvmNetworkCriterion => ({
160
+ ...{
161
+ type: faker.helpers.arrayElement(["evmNetwork"] as const),
162
+ networks: faker.helpers.arrayElements(["base-sepolia", "base"] as const),
163
+ operator: faker.helpers.arrayElement(["in", "not in"] as const),
164
+ },
165
+ ...overrideResponse,
166
+ });
167
+
125
168
  export const getCreatePolicyResponseSolAddressCriterionMock = (
126
169
  overrideResponse: Partial<SolAddressCriterion> = {},
127
170
  ): SolAddressCriterion => ({
@@ -144,21 +187,47 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
144
187
  undefined,
145
188
  ]),
146
189
  scope: faker.helpers.arrayElement(["project", "account"] as const),
147
- rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
148
- action: faker.helpers.arrayElement(["reject", "accept"] as const),
149
- operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
150
- criteria: faker.helpers.arrayElement([
151
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
152
- faker.helpers.arrayElement([
153
- { ...getCreatePolicyResponseEthValueCriterionMock() },
154
- { ...getCreatePolicyResponseEvmAddressCriterionMock() },
155
- ]),
156
- ),
157
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
158
- faker.helpers.arrayElement([{ ...getCreatePolicyResponseSolAddressCriterionMock() }]),
159
- ),
190
+ rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
191
+ faker.helpers.arrayElement([
192
+ {
193
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
194
+ operation: faker.helpers.arrayElement(["signEvmTransaction"] as const),
195
+ criteria: Array.from(
196
+ { length: faker.number.int({ min: 1, max: 10 }) },
197
+ (_, i) => i + 1,
198
+ ).map(() =>
199
+ faker.helpers.arrayElement([
200
+ { ...getCreatePolicyResponseEthValueCriterionMock() },
201
+ { ...getCreatePolicyResponseEvmAddressCriterionMock() },
202
+ ]),
203
+ ),
204
+ },
205
+ {
206
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
207
+ operation: faker.helpers.arrayElement(["sendEvmTransaction"] as const),
208
+ criteria: Array.from(
209
+ { length: faker.number.int({ min: 1, max: 10 }) },
210
+ (_, i) => i + 1,
211
+ ).map(() =>
212
+ faker.helpers.arrayElement([
213
+ { ...getCreatePolicyResponseEthValueCriterionMock() },
214
+ { ...getCreatePolicyResponseEvmAddressCriterionMock() },
215
+ { ...getCreatePolicyResponseEvmNetworkCriterionMock() },
216
+ ]),
217
+ ),
218
+ },
219
+ {
220
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
221
+ operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
222
+ criteria: Array.from(
223
+ { length: faker.number.int({ min: 1, max: 10 }) },
224
+ (_, i) => i + 1,
225
+ ).map(() =>
226
+ faker.helpers.arrayElement([{ ...getCreatePolicyResponseSolAddressCriterionMock() }]),
227
+ ),
228
+ },
160
229
  ]),
161
- })),
230
+ ),
162
231
  createdAt: faker.string.alpha(20),
163
232
  updatedAt: faker.string.alpha(20),
164
233
  ...overrideResponse,
@@ -188,6 +257,17 @@ export const getGetPolicyByIdResponseEvmAddressCriterionMock = (
188
257
  ...overrideResponse,
189
258
  });
190
259
 
260
+ export const getGetPolicyByIdResponseEvmNetworkCriterionMock = (
261
+ overrideResponse: Partial<EvmNetworkCriterion> = {},
262
+ ): EvmNetworkCriterion => ({
263
+ ...{
264
+ type: faker.helpers.arrayElement(["evmNetwork"] as const),
265
+ networks: faker.helpers.arrayElements(["base-sepolia", "base"] as const),
266
+ operator: faker.helpers.arrayElement(["in", "not in"] as const),
267
+ },
268
+ ...overrideResponse,
269
+ });
270
+
191
271
  export const getGetPolicyByIdResponseSolAddressCriterionMock = (
192
272
  overrideResponse: Partial<SolAddressCriterion> = {},
193
273
  ): SolAddressCriterion => ({
@@ -210,21 +290,47 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
210
290
  undefined,
211
291
  ]),
212
292
  scope: faker.helpers.arrayElement(["project", "account"] as const),
213
- rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
214
- action: faker.helpers.arrayElement(["reject", "accept"] as const),
215
- operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
216
- criteria: faker.helpers.arrayElement([
217
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
218
- faker.helpers.arrayElement([
219
- { ...getGetPolicyByIdResponseEthValueCriterionMock() },
220
- { ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
221
- ]),
222
- ),
223
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
224
- faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseSolAddressCriterionMock() }]),
225
- ),
293
+ rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
294
+ faker.helpers.arrayElement([
295
+ {
296
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
297
+ operation: faker.helpers.arrayElement(["signEvmTransaction"] as const),
298
+ criteria: Array.from(
299
+ { length: faker.number.int({ min: 1, max: 10 }) },
300
+ (_, i) => i + 1,
301
+ ).map(() =>
302
+ faker.helpers.arrayElement([
303
+ { ...getGetPolicyByIdResponseEthValueCriterionMock() },
304
+ { ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
305
+ ]),
306
+ ),
307
+ },
308
+ {
309
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
310
+ operation: faker.helpers.arrayElement(["sendEvmTransaction"] as const),
311
+ criteria: Array.from(
312
+ { length: faker.number.int({ min: 1, max: 10 }) },
313
+ (_, i) => i + 1,
314
+ ).map(() =>
315
+ faker.helpers.arrayElement([
316
+ { ...getGetPolicyByIdResponseEthValueCriterionMock() },
317
+ { ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
318
+ { ...getGetPolicyByIdResponseEvmNetworkCriterionMock() },
319
+ ]),
320
+ ),
321
+ },
322
+ {
323
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
324
+ operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
325
+ criteria: Array.from(
326
+ { length: faker.number.int({ min: 1, max: 10 }) },
327
+ (_, i) => i + 1,
328
+ ).map(() =>
329
+ faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseSolAddressCriterionMock() }]),
330
+ ),
331
+ },
226
332
  ]),
227
- })),
333
+ ),
228
334
  createdAt: faker.string.alpha(20),
229
335
  updatedAt: faker.string.alpha(20),
230
336
  ...overrideResponse,
@@ -254,6 +360,17 @@ export const getUpdatePolicyResponseEvmAddressCriterionMock = (
254
360
  ...overrideResponse,
255
361
  });
256
362
 
363
+ export const getUpdatePolicyResponseEvmNetworkCriterionMock = (
364
+ overrideResponse: Partial<EvmNetworkCriterion> = {},
365
+ ): EvmNetworkCriterion => ({
366
+ ...{
367
+ type: faker.helpers.arrayElement(["evmNetwork"] as const),
368
+ networks: faker.helpers.arrayElements(["base-sepolia", "base"] as const),
369
+ operator: faker.helpers.arrayElement(["in", "not in"] as const),
370
+ },
371
+ ...overrideResponse,
372
+ });
373
+
257
374
  export const getUpdatePolicyResponseSolAddressCriterionMock = (
258
375
  overrideResponse: Partial<SolAddressCriterion> = {},
259
376
  ): SolAddressCriterion => ({
@@ -276,21 +393,47 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
276
393
  undefined,
277
394
  ]),
278
395
  scope: faker.helpers.arrayElement(["project", "account"] as const),
279
- rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
280
- action: faker.helpers.arrayElement(["reject", "accept"] as const),
281
- operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
282
- criteria: faker.helpers.arrayElement([
283
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
284
- faker.helpers.arrayElement([
285
- { ...getUpdatePolicyResponseEthValueCriterionMock() },
286
- { ...getUpdatePolicyResponseEvmAddressCriterionMock() },
287
- ]),
288
- ),
289
- Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
290
- faker.helpers.arrayElement([{ ...getUpdatePolicyResponseSolAddressCriterionMock() }]),
291
- ),
396
+ rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
397
+ faker.helpers.arrayElement([
398
+ {
399
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
400
+ operation: faker.helpers.arrayElement(["signEvmTransaction"] as const),
401
+ criteria: Array.from(
402
+ { length: faker.number.int({ min: 1, max: 10 }) },
403
+ (_, i) => i + 1,
404
+ ).map(() =>
405
+ faker.helpers.arrayElement([
406
+ { ...getUpdatePolicyResponseEthValueCriterionMock() },
407
+ { ...getUpdatePolicyResponseEvmAddressCriterionMock() },
408
+ ]),
409
+ ),
410
+ },
411
+ {
412
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
413
+ operation: faker.helpers.arrayElement(["sendEvmTransaction"] as const),
414
+ criteria: Array.from(
415
+ { length: faker.number.int({ min: 1, max: 10 }) },
416
+ (_, i) => i + 1,
417
+ ).map(() =>
418
+ faker.helpers.arrayElement([
419
+ { ...getUpdatePolicyResponseEthValueCriterionMock() },
420
+ { ...getUpdatePolicyResponseEvmAddressCriterionMock() },
421
+ { ...getUpdatePolicyResponseEvmNetworkCriterionMock() },
422
+ ]),
423
+ ),
424
+ },
425
+ {
426
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
427
+ operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
428
+ criteria: Array.from(
429
+ { length: faker.number.int({ min: 1, max: 10 }) },
430
+ (_, i) => i + 1,
431
+ ).map(() =>
432
+ faker.helpers.arrayElement([{ ...getUpdatePolicyResponseSolAddressCriterionMock() }]),
433
+ ),
434
+ },
292
435
  ]),
293
- })),
436
+ ),
294
437
  createdAt: faker.string.alpha(20),
295
438
  updatedAt: faker.string.alpha(20),
296
439
  ...overrideResponse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
@@ -18,6 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
+ "@solana/spl-token": "^0.4.13",
21
22
  "@solana/web3.js": "^1.98.1",
22
23
  "abitype": "1.0.6",
23
24
  "axios": "^1.8.2",
@@ -21,6 +21,16 @@ export const EvmAddressOperatorEnum = z.enum(["in", "not in"]);
21
21
  */
22
22
  export type EvmAddressOperator = z.infer<typeof EvmAddressOperatorEnum>;
23
23
 
24
+ /**
25
+ * Enum for EvmNetworkOperator values
26
+ */
27
+ export const EvmNetworkOperatorEnum = z.enum(["in", "not in"]);
28
+ /**
29
+ * Type representing the operators that can be used for EVM network comparisons.
30
+ * These operators determine how the transaction's network is evaluated against a list.
31
+ */
32
+ export type EvmNetworkOperator = z.infer<typeof EvmNetworkOperatorEnum>;
33
+
24
34
  /**
25
35
  * Enum for SolAddressOperator values
26
36
  */
@@ -68,6 +78,35 @@ export const EvmAddressCriterionSchema = z.object({
68
78
  });
69
79
  export type EvmAddressCriterion = z.infer<typeof EvmAddressCriterionSchema>;
70
80
 
81
+ /**
82
+ * Enum for EVM Network values
83
+ */
84
+ export const EvmNetworkEnum = z.enum(["base", "base-sepolia"]);
85
+ /**
86
+ * Type representing the valid networks used with CDP transaction API's.
87
+ */
88
+ export type EvmNetwork = z.infer<typeof EvmNetworkEnum>;
89
+
90
+ /**
91
+ * Schema for EVM network criterions
92
+ */
93
+ export const EvmNetworkCriterionSchema = z.object({
94
+ /** The type of criterion, must be "evmAddress" for EVM address-based rules. */
95
+ type: z.literal("evmNetwork"),
96
+ /**
97
+ * Array of EVM network identifiers to compare against.
98
+ * Either "base" or "base-sepolia"
99
+ */
100
+ networks: z.array(EvmNetworkEnum),
101
+ /**
102
+ * The operator to use for evaluating transaction network.
103
+ * "in" checks if a network is in the provided list.
104
+ * "not in" checks if a network is not in the provided list.
105
+ */
106
+ operator: EvmNetworkOperatorEnum,
107
+ });
108
+ export type EvmNetworkCriterion = z.infer<typeof EvmNetworkCriterionSchema>;
109
+
71
110
  /**
72
111
  * Schema for Solana address criterions
73
112
  */
@@ -101,6 +140,26 @@ export const SignEvmTransactionCriteriaSchema = z
101
140
  */
102
141
  export type SignEvmTransactionCriteria = z.infer<typeof SignEvmTransactionCriteriaSchema>;
103
142
 
143
+ /**
144
+ * Schema for criteria used in SendEvmTransaction operations
145
+ */
146
+ export const SendEvmTransactionCriteriaSchema = z
147
+ .array(
148
+ z.discriminatedUnion("type", [
149
+ EthValueCriterionSchema,
150
+ EvmAddressCriterionSchema,
151
+ EvmNetworkCriterionSchema,
152
+ ]),
153
+ )
154
+ .max(10)
155
+ .min(1);
156
+
157
+ /**
158
+ * Type representing a set of criteria for the sendEvmTransaction operation.
159
+ * Can contain up to 10 individual criterion objects of ETH value or EVM address types.
160
+ */
161
+ export type SendEvmTransactionCriteria = z.infer<typeof SendEvmTransactionCriteriaSchema>;
162
+
104
163
  /**
105
164
  * Schema for criteria used in SignSolTransaction operations
106
165
  */
@@ -167,6 +226,29 @@ export const SignEvmTransactionRuleSchema = z.object({
167
226
  });
168
227
  export type SignEvmTransactionRule = z.infer<typeof SignEvmTransactionRuleSchema>;
169
228
 
229
+ /**
230
+ * Type representing a 'sendEvmTransaction' policy rule that can accept or reject specific operations
231
+ * based on a set of criteria.
232
+ */
233
+ export const SendEvmTransactionRuleSchema = z.object({
234
+ /**
235
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
236
+ * "accept" will allow the transaction, "reject" will block it.
237
+ */
238
+ action: ActionEnum,
239
+ /**
240
+ * The operation to which this rule applies.
241
+ * Must be "sendEvmTransaction".
242
+ */
243
+ operation: z.literal("sendEvmTransaction"),
244
+ /**
245
+ * The set of criteria that must be matched for this rule to apply.
246
+ * Must be compatible with the specified operation type.
247
+ */
248
+ criteria: SendEvmTransactionCriteriaSchema,
249
+ });
250
+ export type SendEvmTransactionRule = z.infer<typeof SendEvmTransactionRuleSchema>;
251
+
170
252
  /**
171
253
  * Type representing a 'signSolTransaction' policy rule that can accept or reject specific operations
172
254
  * based on a set of criteria.
@@ -195,6 +277,7 @@ export type SignSolTransactionRule = z.infer<typeof SignSolTransactionRuleSchema
195
277
  */
196
278
  export const RuleSchema = z.discriminatedUnion("operation", [
197
279
  SignEvmTransactionRuleSchema,
280
+ SendEvmTransactionRuleSchema,
198
281
  SignSolTransactionRuleSchema,
199
282
  ]);
200
283
 
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.8.0";
1
+ export const version = "1.9.0";