@coinbase/cdp-sdk 1.7.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 (226) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +326 -28
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  6. package/_cjs/accounts/solana/toSolanaAccount.js +8 -0
  7. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  8. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
  9. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  10. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  11. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  12. package/_cjs/actions/evm/transfer/transfer.js +2 -39
  13. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  14. package/_cjs/actions/evm/transfer/utils.js +0 -12
  15. package/_cjs/actions/evm/transfer/utils.js.map +1 -1
  16. package/_cjs/actions/solana/constants.js +9 -0
  17. package/_cjs/actions/solana/constants.js.map +1 -0
  18. package/_cjs/actions/solana/transfer.js +117 -0
  19. package/_cjs/actions/solana/transfer.js.map +1 -0
  20. package/_cjs/actions/solana/utils.js +66 -0
  21. package/_cjs/actions/solana/utils.js.map +1 -0
  22. package/_cjs/analytics.js +70 -8
  23. package/_cjs/analytics.js.map +1 -1
  24. package/_cjs/client/cdp.js +9 -3
  25. package/_cjs/client/cdp.js.map +1 -1
  26. package/_cjs/client/evm/evm.js +133 -15
  27. package/_cjs/client/evm/evm.js.map +1 -1
  28. package/_cjs/client/policies/index.js +6 -0
  29. package/_cjs/client/policies/index.js.map +1 -0
  30. package/_cjs/client/policies/policies.js +232 -0
  31. package/_cjs/client/policies/policies.js.map +1 -0
  32. package/_cjs/client/policies/policies.types.js +3 -0
  33. package/_cjs/client/policies/policies.types.js.map +1 -0
  34. package/_cjs/client/solana/solana.js +76 -19
  35. package/_cjs/client/solana/solana.js.map +1 -1
  36. package/_cjs/index.js +4 -1
  37. package/_cjs/index.js.map +1 -1
  38. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
  39. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  40. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
  41. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  42. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
  43. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  44. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  45. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  46. package/_cjs/openapi-client/generated/index.msw.js +2 -2
  47. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  48. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
  49. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  50. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
  51. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  52. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
  53. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  54. package/_cjs/openapi-client/index.js +6 -1
  55. package/_cjs/openapi-client/index.js.map +1 -1
  56. package/_cjs/policies/schema.js +245 -0
  57. package/_cjs/policies/schema.js.map +1 -0
  58. package/_cjs/policies/types.js +3 -0
  59. package/_cjs/policies/types.js.map +1 -0
  60. package/_cjs/version.js +1 -1
  61. package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
  62. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  63. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  64. package/_esm/accounts/solana/toSolanaAccount.js +8 -0
  65. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  66. package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
  67. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  68. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  69. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  70. package/_esm/actions/evm/transfer/transfer.js +2 -39
  71. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  72. package/_esm/actions/evm/transfer/utils.js +0 -11
  73. package/_esm/actions/evm/transfer/utils.js.map +1 -1
  74. package/_esm/actions/solana/constants.js +6 -0
  75. package/_esm/actions/solana/constants.js.map +1 -0
  76. package/_esm/actions/solana/transfer.js +114 -0
  77. package/_esm/actions/solana/transfer.js.map +1 -0
  78. package/_esm/actions/solana/utils.js +61 -0
  79. package/_esm/actions/solana/utils.js.map +1 -0
  80. package/_esm/analytics.js +70 -7
  81. package/_esm/analytics.js.map +1 -1
  82. package/_esm/client/cdp.js +10 -4
  83. package/_esm/client/cdp.js.map +1 -1
  84. package/_esm/client/evm/evm.js +133 -15
  85. package/_esm/client/evm/evm.js.map +1 -1
  86. package/_esm/client/policies/index.js +2 -0
  87. package/_esm/client/policies/index.js.map +1 -0
  88. package/_esm/client/policies/policies.js +228 -0
  89. package/_esm/client/policies/policies.js.map +1 -0
  90. package/_esm/client/policies/policies.types.js +2 -0
  91. package/_esm/client/policies/policies.types.js.map +1 -0
  92. package/_esm/client/solana/solana.js +76 -19
  93. package/_esm/client/solana/solana.js.map +1 -1
  94. package/_esm/index.js +1 -0
  95. package/_esm/index.js.map +1 -1
  96. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
  97. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  98. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
  99. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  100. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
  101. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  102. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  103. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  104. package/_esm/openapi-client/generated/index.msw.js +2 -2
  105. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  106. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
  107. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  108. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
  109. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  110. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
  111. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  112. package/_esm/openapi-client/index.js +5 -0
  113. package/_esm/openapi-client/index.js.map +1 -1
  114. package/_esm/policies/schema.js +242 -0
  115. package/_esm/policies/schema.js.map +1 -0
  116. package/_esm/policies/types.js +2 -0
  117. package/_esm/policies/types.js.map +1 -0
  118. package/_esm/version.js +1 -1
  119. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  120. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  121. package/_types/accounts/evm/types.d.ts +6 -3
  122. package/_types/accounts/evm/types.d.ts.map +1 -1
  123. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  124. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
  125. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  126. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
  127. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  128. package/_types/actions/evm/transfer/transfer.d.ts +6 -4
  129. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  130. package/_types/actions/evm/transfer/types.d.ts +8 -54
  131. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  132. package/_types/actions/evm/transfer/utils.d.ts +0 -619
  133. package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
  134. package/_types/actions/evm/types.d.ts +140 -68
  135. package/_types/actions/evm/types.d.ts.map +1 -1
  136. package/_types/actions/solana/constants.d.ts +6 -0
  137. package/_types/actions/solana/constants.d.ts.map +1 -0
  138. package/_types/actions/solana/transfer.d.ts +36 -0
  139. package/_types/actions/solana/transfer.d.ts.map +1 -0
  140. package/_types/actions/solana/types.d.ts +27 -0
  141. package/_types/actions/solana/types.d.ts.map +1 -1
  142. package/_types/actions/solana/utils.d.ts +34 -0
  143. package/_types/actions/solana/utils.d.ts.map +1 -0
  144. package/_types/analytics.d.ts +14 -5
  145. package/_types/analytics.d.ts.map +1 -1
  146. package/_types/client/cdp.d.ts +3 -0
  147. package/_types/client/cdp.d.ts.map +1 -1
  148. package/_types/client/evm/evm.d.ts +89 -1
  149. package/_types/client/evm/evm.d.ts.map +1 -1
  150. package/_types/client/evm/evm.types.d.ts +33 -3
  151. package/_types/client/evm/evm.types.d.ts.map +1 -1
  152. package/_types/client/policies/index.d.ts +2 -0
  153. package/_types/client/policies/index.d.ts.map +1 -0
  154. package/_types/client/policies/policies.d.ts +216 -0
  155. package/_types/client/policies/policies.d.ts.map +1 -0
  156. package/_types/client/policies/policies.types.d.ts +96 -0
  157. package/_types/client/policies/policies.types.d.ts.map +1 -0
  158. package/_types/client/solana/solana.d.ts +43 -1
  159. package/_types/client/solana/solana.d.ts.map +1 -1
  160. package/_types/client/solana/solana.types.d.ts +14 -2
  161. package/_types/client/solana/solana.types.d.ts.map +1 -1
  162. package/_types/index.d.ts +2 -0
  163. package/_types/index.d.ts.map +1 -1
  164. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +176 -17
  165. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  166. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
  167. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  168. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
  169. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  170. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
  171. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  172. package/_types/openapi-client/generated/index.msw.d.ts +2 -2
  173. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  174. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
  175. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  176. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
  177. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  178. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
  179. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
  180. package/_types/openapi-client/index.d.ts +18 -0
  181. package/_types/openapi-client/index.d.ts.map +1 -1
  182. package/_types/policies/schema.d.ts +1552 -0
  183. package/_types/policies/schema.d.ts.map +1 -0
  184. package/_types/policies/types.d.ts +19 -0
  185. package/_types/policies/types.d.ts.map +1 -0
  186. package/_types/types/misc.d.ts +39 -0
  187. package/_types/types/misc.d.ts.map +1 -1
  188. package/_types/version.d.ts +1 -1
  189. package/accounts/evm/toEvmServerAccount.ts +11 -7
  190. package/accounts/evm/toEvmSmartAccount.ts +1 -2
  191. package/accounts/evm/types.ts +6 -8
  192. package/accounts/solana/toSolanaAccount.ts +8 -0
  193. package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
  194. package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
  195. package/actions/evm/transfer/transfer.ts +10 -51
  196. package/actions/evm/transfer/types.ts +9 -67
  197. package/actions/evm/transfer/utils.ts +0 -13
  198. package/actions/evm/types.ts +143 -78
  199. package/actions/solana/constants.ts +6 -0
  200. package/actions/solana/transfer.ts +219 -0
  201. package/actions/solana/types.ts +28 -0
  202. package/actions/solana/utils.ts +79 -0
  203. package/analytics.ts +86 -11
  204. package/client/cdp.ts +11 -4
  205. package/client/evm/evm.ts +159 -17
  206. package/client/evm/evm.types.ts +38 -1
  207. package/client/policies/index.ts +1 -0
  208. package/client/policies/policies.ts +246 -0
  209. package/client/policies/policies.types.ts +109 -0
  210. package/client/solana/solana.ts +94 -20
  211. package/client/solana/solana.types.ts +16 -1
  212. package/index.ts +7 -0
  213. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +220 -18
  214. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
  215. package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
  216. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
  217. package/openapi-client/generated/index.msw.ts +2 -2
  218. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
  219. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
  220. package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
  221. package/openapi-client/index.ts +6 -0
  222. package/package.json +4 -2
  223. package/policies/schema.ts +349 -0
  224. package/policies/types.ts +19 -0
  225. package/types/misc.ts +41 -0
  226. package/version.ts +1 -1
@@ -18,6 +18,8 @@ Account names are guaranteed to be unique across all EVM accounts in the develop
18
18
  * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
19
19
  */
20
20
  name?: string;
21
+ /** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
22
+ policies?: string[];
21
23
  }
22
24
 
23
25
  export interface ListResponse {
@@ -64,6 +66,54 @@ export interface Error {
64
66
  errorLink?: string;
65
67
  }
66
68
 
69
+ /**
70
+ * The domain of the EIP-712 typed data.
71
+ */
72
+ export interface EIP712Domain {
73
+ /** The name of the DApp or protocol. */
74
+ name?: string;
75
+ /** The version of the DApp or protocol. */
76
+ version?: string;
77
+ /** The chain ID of the EVM network. */
78
+ chainId?: number;
79
+ /**
80
+ * The 0x-prefixed EVM address of the verifying smart contract.
81
+ * @pattern ^0x[a-fA-F0-9]{40}$
82
+ */
83
+ verifyingContract?: string;
84
+ /**
85
+ * The optional 32-byte 0x-prefixed hex salt for domain separation.
86
+ * @pattern ^0x[a-fA-F0-9]{64}$
87
+ */
88
+ salt?: string;
89
+ }
90
+
91
+ /**
92
+ * A mapping of struct names to an array of type objects (name + type).
93
+ Each key corresponds to a type name (e.g., "`EIP712Domain`", "`PermitTransferFrom`").
94
+
95
+ */
96
+ export interface EIP712Types {
97
+ [key: string]: unknown;
98
+ }
99
+
100
+ /**
101
+ * The message to sign. The structure of this message must match the `primaryType` struct in the `types` object.
102
+ */
103
+ export type EIP712MessageMessage = { [key: string]: unknown };
104
+
105
+ /**
106
+ * The message to sign using EIP-712.
107
+ */
108
+ export interface EIP712Message {
109
+ domain: EIP712Domain;
110
+ types: EIP712Types;
111
+ /** The primary type of the message. This is the name of the struct in the `types` object that is the root of the message. */
112
+ primaryType: string;
113
+ /** The message to sign. The structure of this message must match the `primaryType` struct in the `types` object. */
114
+ message: EIP712MessageMessage;
115
+ }
116
+
67
117
  export interface EvmSmartAccount {
68
118
  /**
69
119
  * The 0x-prefixed, checksum address of the Smart Account.
@@ -283,6 +333,125 @@ export type SignEvmTransactionCriteriaItem = EthValueCriterion | EvmAddressCrite
283
333
  */
284
334
  export type SignEvmTransactionCriteria = SignEvmTransactionCriteriaItem[];
285
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
+
286
455
  /**
287
456
  * The type of criterion to use. This should be `solAddress`.
288
457
  */
@@ -326,10 +495,11 @@ export type SignSolTransactionCriteria = SolAddressCriterion[];
326
495
  /**
327
496
  * Whether matching the rule will cause the request to be rejected or accepted.
328
497
  */
329
- export type RuleAction = (typeof RuleAction)[keyof typeof RuleAction];
498
+ export type SignSolTransactionRuleAction =
499
+ (typeof SignSolTransactionRuleAction)[keyof typeof SignSolTransactionRuleAction];
330
500
 
331
501
  // eslint-disable-next-line @typescript-eslint/no-redeclare
332
- export const RuleAction = {
502
+ export const SignSolTransactionRuleAction = {
333
503
  reject: "reject",
334
504
  accept: "accept",
335
505
  } as const;
@@ -337,30 +507,26 @@ export const RuleAction = {
337
507
  /**
338
508
  * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
339
509
  */
340
- export type RuleOperation = (typeof RuleOperation)[keyof typeof RuleOperation];
510
+ export type SignSolTransactionRuleOperation =
511
+ (typeof SignSolTransactionRuleOperation)[keyof typeof SignSolTransactionRuleOperation];
341
512
 
342
513
  // eslint-disable-next-line @typescript-eslint/no-redeclare
343
- export const RuleOperation = {
344
- signEvmTransaction: "signEvmTransaction",
514
+ export const SignSolTransactionRuleOperation = {
345
515
  signSolTransaction: "signSolTransaction",
346
516
  } as const;
347
517
 
348
- /**
349
- * The set of criteria for the rule. There is a limit of 10 criteria per rule.
350
- */
351
- 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
+ }
352
525
 
353
526
  /**
354
527
  * A rule that limits the behavior of an account.
355
528
  */
356
- export interface Rule {
357
- /** Whether matching the rule will cause the request to be rejected or accepted. */
358
- action: RuleAction;
359
- /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
360
- operation: RuleOperation;
361
- /** The set of criteria for the rule. There is a limit of 10 criteria per rule. */
362
- criteria: RuleCriteria;
363
- }
529
+ export type Rule = SignEvmTransactionRule | SendEvmTransactionRule | SignSolTransactionRule;
364
530
 
365
531
  /**
366
532
  * The scope of the policy. Only one project-level policy can exist at any time.
@@ -380,7 +546,7 @@ export interface Policy {
380
546
  */
381
547
  id: string;
382
548
  /**
383
- * An optional human-readable description of the policy.
549
+ * An optional human-readable description of the policy.
384
550
  Policy descriptions can consist of alphanumeric characters, spaces, commas, and periods, and be 50 characters or less.
385
551
  * @pattern ^[A-Za-z0-9 ,.]{1,50}$
386
552
  */
@@ -408,6 +574,8 @@ Account names are guaranteed to be unique across all Solana accounts in the deve
408
574
  * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
409
575
  */
410
576
  name?: string;
577
+ /** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
578
+ policies?: string[];
411
579
  }
412
580
 
413
581
  /**
@@ -479,6 +647,21 @@ Account names must be unique across all EVM accounts in the developer's CDP Proj
479
647
  name?: string;
480
648
  };
481
649
 
650
+ export type UpdateEvmAccountBody = {
651
+ /**
652
+ * An optional name for the account.
653
+ Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
654
+ Account names must be unique across all EVM accounts in the developer's CDP Project.
655
+ * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
656
+ */
657
+ name?: string;
658
+ /**
659
+ * The ID of the account-level policy to apply to the account.
660
+ * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
661
+ */
662
+ accountPolicy?: string;
663
+ };
664
+
482
665
  /**
483
666
  * The network to send the transaction to.
484
667
  */
@@ -533,6 +716,11 @@ export type SignEvmMessage200 = {
533
716
  signature: string;
534
717
  };
535
718
 
719
+ export type SignEvmTypedData200 = {
720
+ /** The signature of the typed data, as a 0x-prefixed hex string. */
721
+ signature: string;
722
+ };
723
+
536
724
  export type ListEvmSmartAccountsParams = {
537
725
  /**
538
726
  * The number of accounts to return per page.
@@ -738,6 +926,20 @@ Account names must be unique across all Solana accounts in the developer's CDP P
738
926
  name?: string;
739
927
  };
740
928
 
929
+ export type UpdateSolanaAccountBody = {
930
+ /**
931
+ * An optional name for the account. Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
932
+ Account names must be unique across all Solana accounts in the developer's CDP Project.
933
+ * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
934
+ */
935
+ name?: string;
936
+ /**
937
+ * The ID of the account-level policy to apply to the account.
938
+ * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
939
+ */
940
+ accountPolicy?: string;
941
+ };
942
+
741
943
  export type SignSolanaTransactionBody = {
742
944
  /** The base64 encoded transaction to sign. */
743
945
  transaction: string;
@@ -16,6 +16,7 @@ import type {
16
16
  SignEvmHash200,
17
17
  SignEvmMessage200,
18
18
  SignEvmTransaction200,
19
+ SignEvmTypedData200,
19
20
  } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
20
21
 
21
22
  export const getListEvmAccountsResponseMock = (): ListEvmAccounts200 => ({
@@ -27,6 +28,14 @@ export const getListEvmAccountsResponseMock = (): ListEvmAccounts200 => ({
27
28
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
28
29
  undefined,
29
30
  ]),
31
+ policies: faker.helpers.arrayElement([
32
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
33
+ faker.helpers.fromRegExp(
34
+ "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
35
+ ),
36
+ ),
37
+ undefined,
38
+ ]),
30
39
  }),
31
40
  ),
32
41
  },
@@ -41,6 +50,14 @@ export const getCreateEvmAccountResponseMock = (
41
50
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
42
51
  undefined,
43
52
  ]),
53
+ policies: faker.helpers.arrayElement([
54
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
55
+ faker.helpers.fromRegExp(
56
+ "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
57
+ ),
58
+ ),
59
+ undefined,
60
+ ]),
44
61
  ...overrideResponse,
45
62
  });
46
63
 
@@ -52,6 +69,33 @@ export const getGetEvmAccountResponseMock = (
52
69
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
53
70
  undefined,
54
71
  ]),
72
+ policies: faker.helpers.arrayElement([
73
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
74
+ faker.helpers.fromRegExp(
75
+ "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
76
+ ),
77
+ ),
78
+ undefined,
79
+ ]),
80
+ ...overrideResponse,
81
+ });
82
+
83
+ export const getUpdateEvmAccountResponseMock = (
84
+ overrideResponse: Partial<EvmAccount> = {},
85
+ ): EvmAccount => ({
86
+ address: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
87
+ name: faker.helpers.arrayElement([
88
+ faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
89
+ undefined,
90
+ ]),
91
+ policies: faker.helpers.arrayElement([
92
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
93
+ faker.helpers.fromRegExp(
94
+ "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
95
+ ),
96
+ ),
97
+ undefined,
98
+ ]),
55
99
  ...overrideResponse,
56
100
  });
57
101
 
@@ -63,6 +107,14 @@ export const getGetEvmAccountByNameResponseMock = (
63
107
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
64
108
  undefined,
65
109
  ]),
110
+ policies: faker.helpers.arrayElement([
111
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
112
+ faker.helpers.fromRegExp(
113
+ "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
114
+ ),
115
+ ),
116
+ undefined,
117
+ ]),
66
118
  ...overrideResponse,
67
119
  });
68
120
 
@@ -82,6 +134,10 @@ export const getSignEvmMessageResponseMock = (
82
134
  overrideResponse: Partial<SignEvmMessage200> = {},
83
135
  ): SignEvmMessage200 => ({ signature: faker.string.alpha(20), ...overrideResponse });
84
136
 
137
+ export const getSignEvmTypedDataResponseMock = (
138
+ overrideResponse: Partial<SignEvmTypedData200> = {},
139
+ ): SignEvmTypedData200 => ({ signature: faker.string.alpha(20), ...overrideResponse });
140
+
85
141
  export const getListEvmAccountsMockHandler = (
86
142
  overrideResponse?:
87
143
  | ListEvmAccounts200
@@ -147,6 +203,27 @@ export const getGetEvmAccountMockHandler = (
147
203
  });
148
204
  };
149
205
 
206
+ export const getUpdateEvmAccountMockHandler = (
207
+ overrideResponse?:
208
+ | EvmAccount
209
+ | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<EvmAccount> | EvmAccount),
210
+ ) => {
211
+ return http.put("*/v2/evm/accounts/:address", async info => {
212
+ await delay(0);
213
+
214
+ return new HttpResponse(
215
+ JSON.stringify(
216
+ overrideResponse !== undefined
217
+ ? typeof overrideResponse === "function"
218
+ ? await overrideResponse(info)
219
+ : overrideResponse
220
+ : getUpdateEvmAccountResponseMock(),
221
+ ),
222
+ { status: 200, headers: { "Content-Type": "application/json" } },
223
+ );
224
+ });
225
+ };
226
+
150
227
  export const getGetEvmAccountByNameMockHandler = (
151
228
  overrideResponse?:
152
229
  | EvmAccount
@@ -259,13 +336,38 @@ export const getSignEvmMessageMockHandler = (
259
336
  );
260
337
  });
261
338
  };
339
+
340
+ export const getSignEvmTypedDataMockHandler = (
341
+ overrideResponse?:
342
+ | SignEvmTypedData200
343
+ | ((
344
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
345
+ ) => Promise<SignEvmTypedData200> | SignEvmTypedData200),
346
+ ) => {
347
+ return http.post("*/v2/evm/accounts/:address/sign/typed-data", async info => {
348
+ await delay(0);
349
+
350
+ return new HttpResponse(
351
+ JSON.stringify(
352
+ overrideResponse !== undefined
353
+ ? typeof overrideResponse === "function"
354
+ ? await overrideResponse(info)
355
+ : overrideResponse
356
+ : getSignEvmTypedDataResponseMock(),
357
+ ),
358
+ { status: 200, headers: { "Content-Type": "application/json" } },
359
+ );
360
+ });
361
+ };
262
362
  export const getEvmAccountsMock = () => [
263
363
  getListEvmAccountsMockHandler(),
264
364
  getCreateEvmAccountMockHandler(),
265
365
  getGetEvmAccountMockHandler(),
366
+ getUpdateEvmAccountMockHandler(),
266
367
  getGetEvmAccountByNameMockHandler(),
267
368
  getSendEvmTransactionMockHandler(),
268
369
  getSignEvmTransactionMockHandler(),
269
370
  getSignEvmHashMockHandler(),
270
371
  getSignEvmMessageMockHandler(),
372
+ getSignEvmTypedDataMockHandler(),
271
373
  ];
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import type {
9
9
  CreateEvmAccountBody,
10
+ EIP712Message,
10
11
  EvmAccount,
11
12
  ListEvmAccounts200,
12
13
  ListEvmAccountsParams,
@@ -18,6 +19,8 @@ import type {
18
19
  SignEvmMessageBody,
19
20
  SignEvmTransaction200,
20
21
  SignEvmTransactionBody,
22
+ SignEvmTypedData200,
23
+ UpdateEvmAccountBody,
21
24
  } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
22
25
 
23
26
  import { cdpApiClient } from "../../cdpApiClient.js";
@@ -63,6 +66,25 @@ export const createEvmAccount = (
63
66
  export const getEvmAccount = (address: string, options?: SecondParameter<typeof cdpApiClient>) => {
64
67
  return cdpApiClient<EvmAccount>({ url: `/v2/evm/accounts/${address}`, method: "GET" }, options);
65
68
  };
69
+ /**
70
+ * Updates an existing EVM account. Use this to update the account's name or account-level policy.
71
+ * @summary Update an EVM account
72
+ */
73
+ export const updateEvmAccount = (
74
+ address: string,
75
+ updateEvmAccountBody: UpdateEvmAccountBody,
76
+ options?: SecondParameter<typeof cdpApiClient>,
77
+ ) => {
78
+ return cdpApiClient<EvmAccount>(
79
+ {
80
+ url: `/v2/evm/accounts/${address}`,
81
+ method: "PUT",
82
+ headers: { "Content-Type": "application/json" },
83
+ data: updateEvmAccountBody,
84
+ },
85
+ options,
86
+ );
87
+ };
66
88
  /**
67
89
  * Gets an EVM account by its name.
68
90
  * @summary Get an EVM account by name
@@ -182,9 +204,29 @@ export const signEvmMessage = (
182
204
  options,
183
205
  );
184
206
  };
207
+ /**
208
+ * Signs [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data with the given EVM account.
209
+ * @summary Sign EIP-712 typed data
210
+ */
211
+ export const signEvmTypedData = (
212
+ address: string,
213
+ eIP712Message: EIP712Message,
214
+ options?: SecondParameter<typeof cdpApiClient>,
215
+ ) => {
216
+ return cdpApiClient<SignEvmTypedData200>(
217
+ {
218
+ url: `/v2/evm/accounts/${address}/sign/typed-data`,
219
+ method: "POST",
220
+ headers: { "Content-Type": "application/json" },
221
+ data: eIP712Message,
222
+ },
223
+ options,
224
+ );
225
+ };
185
226
  export type ListEvmAccountsResult = NonNullable<Awaited<ReturnType<typeof listEvmAccounts>>>;
186
227
  export type CreateEvmAccountResult = NonNullable<Awaited<ReturnType<typeof createEvmAccount>>>;
187
228
  export type GetEvmAccountResult = NonNullable<Awaited<ReturnType<typeof getEvmAccount>>>;
229
+ export type UpdateEvmAccountResult = NonNullable<Awaited<ReturnType<typeof updateEvmAccount>>>;
188
230
  export type GetEvmAccountByNameResult = NonNullable<
189
231
  Awaited<ReturnType<typeof getEvmAccountByName>>
190
232
  >;
@@ -192,3 +234,4 @@ export type SendEvmTransactionResult = NonNullable<Awaited<ReturnType<typeof sen
192
234
  export type SignEvmTransactionResult = NonNullable<Awaited<ReturnType<typeof signEvmTransaction>>>;
193
235
  export type SignEvmHashResult = NonNullable<Awaited<ReturnType<typeof signEvmHash>>>;
194
236
  export type SignEvmMessageResult = NonNullable<Awaited<ReturnType<typeof signEvmMessage>>>;
237
+ export type SignEvmTypedDataResult = NonNullable<Awaited<ReturnType<typeof signEvmTypedData>>>;
@@ -99,7 +99,9 @@ export const getUserOperation = (
99
99
  };
100
100
  /**
101
101
  * Sends a user operation with a signature.
102
- The signature that is sent should be 65 bytes, consisting of the `r`, `s`, and `v` values of the ECDSA signature. Note that the `v` value should conform to the `personal_sign` standard, which means it should be 27 or 28.
102
+ The payload to sign must be the `userOpHash` field of the user operation. This hash should be signed directly (not using `personal_sign` or EIP-191 message hashing).
103
+ The signature must be 65 bytes in length, consisting of: - 32 bytes for the `r` value - 32 bytes for the `s` value - 1 byte for the `v` value (must be 27 or 28)
104
+ If using the CDP Paymaster, the user operation must be signed and sent within 2 minutes of being prepared.
103
105
  * @summary Send a user operation
104
106
  */
105
107
  export const sendUserOperation = (
@@ -1,6 +1,6 @@
1
1
  export * from "./faucets/faucets.msw.js";
2
+ export * from "./policy-engine/policy-engine.msw.js";
2
3
  export * from "./evm-accounts/evm-accounts.msw.js";
3
- export * from "./evm-token-balances/evm-token-balances.msw.js";
4
4
  export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
5
- export * from "./policy-engine/policy-engine.msw.js";
5
+ export * from "./evm-token-balances/evm-token-balances.msw.js";
6
6
  export * from "./solana-accounts/solana-accounts.msw.js";