@coinbase/cdp-sdk 1.7.0 → 1.8.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 (158) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +222 -1
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/solana/toSolanaAccount.js +1 -0
  6. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  7. package/_cjs/analytics.js +68 -8
  8. package/_cjs/analytics.js.map +1 -1
  9. package/_cjs/client/cdp.js +9 -3
  10. package/_cjs/client/cdp.js.map +1 -1
  11. package/_cjs/client/evm/evm.js +133 -15
  12. package/_cjs/client/evm/evm.js.map +1 -1
  13. package/_cjs/client/policies/index.js +6 -0
  14. package/_cjs/client/policies/index.js.map +1 -0
  15. package/_cjs/client/policies/policies.js +232 -0
  16. package/_cjs/client/policies/policies.js.map +1 -0
  17. package/_cjs/client/policies/policies.types.js +3 -0
  18. package/_cjs/client/policies/policies.types.js.map +1 -0
  19. package/_cjs/client/solana/solana.js +76 -19
  20. package/_cjs/client/solana/solana.js.map +1 -1
  21. package/_cjs/index.js +4 -1
  22. package/_cjs/index.js.map +1 -1
  23. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  24. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
  25. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  26. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
  27. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  28. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  29. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  30. package/_cjs/openapi-client/generated/index.msw.js +1 -1
  31. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  32. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
  33. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  34. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
  35. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  36. package/_cjs/openapi-client/index.js +6 -1
  37. package/_cjs/openapi-client/index.js.map +1 -1
  38. package/_cjs/policies/schema.js +186 -0
  39. package/_cjs/policies/schema.js.map +1 -0
  40. package/_cjs/policies/types.js +3 -0
  41. package/_cjs/policies/types.js.map +1 -0
  42. package/_cjs/version.js +1 -1
  43. package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
  44. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  45. package/_esm/accounts/solana/toSolanaAccount.js +1 -0
  46. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  47. package/_esm/analytics.js +68 -7
  48. package/_esm/analytics.js.map +1 -1
  49. package/_esm/client/cdp.js +10 -4
  50. package/_esm/client/cdp.js.map +1 -1
  51. package/_esm/client/evm/evm.js +133 -15
  52. package/_esm/client/evm/evm.js.map +1 -1
  53. package/_esm/client/policies/index.js +2 -0
  54. package/_esm/client/policies/index.js.map +1 -0
  55. package/_esm/client/policies/policies.js +228 -0
  56. package/_esm/client/policies/policies.js.map +1 -0
  57. package/_esm/client/policies/policies.types.js +2 -0
  58. package/_esm/client/policies/policies.types.js.map +1 -0
  59. package/_esm/client/solana/solana.js +76 -19
  60. package/_esm/client/solana/solana.js.map +1 -1
  61. package/_esm/index.js +1 -0
  62. package/_esm/index.js.map +1 -1
  63. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  64. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
  65. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  66. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
  67. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  68. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  69. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  70. package/_esm/openapi-client/generated/index.msw.js +1 -1
  71. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  72. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
  73. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  74. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
  75. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  76. package/_esm/openapi-client/index.js +5 -0
  77. package/_esm/openapi-client/index.js.map +1 -1
  78. package/_esm/policies/schema.js +183 -0
  79. package/_esm/policies/schema.js.map +1 -0
  80. package/_esm/policies/types.js +2 -0
  81. package/_esm/policies/types.js.map +1 -0
  82. package/_esm/version.js +1 -1
  83. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  84. package/_types/accounts/evm/types.d.ts +6 -3
  85. package/_types/accounts/evm/types.d.ts.map +1 -1
  86. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  87. package/_types/actions/evm/transfer/types.d.ts +1 -2
  88. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  89. package/_types/analytics.d.ts +14 -5
  90. package/_types/analytics.d.ts.map +1 -1
  91. package/_types/client/cdp.d.ts +3 -0
  92. package/_types/client/cdp.d.ts.map +1 -1
  93. package/_types/client/evm/evm.d.ts +89 -1
  94. package/_types/client/evm/evm.d.ts.map +1 -1
  95. package/_types/client/evm/evm.types.d.ts +33 -3
  96. package/_types/client/evm/evm.types.d.ts.map +1 -1
  97. package/_types/client/policies/index.d.ts +2 -0
  98. package/_types/client/policies/index.d.ts.map +1 -0
  99. package/_types/client/policies/policies.d.ts +216 -0
  100. package/_types/client/policies/policies.d.ts.map +1 -0
  101. package/_types/client/policies/policies.types.d.ts +96 -0
  102. package/_types/client/policies/policies.types.d.ts.map +1 -0
  103. package/_types/client/solana/solana.d.ts +43 -1
  104. package/_types/client/solana/solana.d.ts.map +1 -1
  105. package/_types/client/solana/solana.types.d.ts +14 -2
  106. package/_types/client/solana/solana.types.d.ts.map +1 -1
  107. package/_types/index.d.ts +2 -0
  108. package/_types/index.d.ts.map +1 -1
  109. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +81 -0
  110. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  111. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
  112. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  113. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
  114. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  115. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
  116. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  117. package/_types/openapi-client/generated/index.msw.d.ts +1 -1
  118. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  119. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
  120. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  121. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
  122. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
  123. package/_types/openapi-client/index.d.ts +18 -0
  124. package/_types/openapi-client/index.d.ts.map +1 -1
  125. package/_types/policies/schema.d.ts +922 -0
  126. package/_types/policies/schema.d.ts.map +1 -0
  127. package/_types/policies/types.d.ts +19 -0
  128. package/_types/policies/types.d.ts.map +1 -0
  129. package/_types/types/misc.d.ts +39 -0
  130. package/_types/types/misc.d.ts.map +1 -1
  131. package/_types/version.d.ts +1 -1
  132. package/accounts/evm/toEvmServerAccount.ts +6 -3
  133. package/accounts/evm/types.ts +6 -8
  134. package/accounts/solana/toSolanaAccount.ts +1 -0
  135. package/actions/evm/transfer/types.ts +1 -1
  136. package/analytics.ts +84 -11
  137. package/client/cdp.ts +11 -4
  138. package/client/evm/evm.ts +159 -17
  139. package/client/evm/evm.types.ts +38 -1
  140. package/client/policies/index.ts +1 -0
  141. package/client/policies/policies.ts +246 -0
  142. package/client/policies/policies.types.ts +109 -0
  143. package/client/solana/solana.ts +94 -20
  144. package/client/solana/solana.types.ts +16 -1
  145. package/index.ts +7 -0
  146. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +86 -0
  147. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
  148. package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
  149. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
  150. package/openapi-client/generated/index.msw.ts +1 -1
  151. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
  152. package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
  153. package/openapi-client/index.ts +6 -0
  154. package/package.json +3 -2
  155. package/policies/schema.ts +266 -0
  156. package/policies/types.ts +19 -0
  157. package/types/misc.ts +41 -0
  158. 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.
@@ -408,6 +458,8 @@ Account names are guaranteed to be unique across all Solana accounts in the deve
408
458
  * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
409
459
  */
410
460
  name?: string;
461
+ /** 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. */
462
+ policies?: string[];
411
463
  }
412
464
 
413
465
  /**
@@ -479,6 +531,21 @@ Account names must be unique across all EVM accounts in the developer's CDP Proj
479
531
  name?: string;
480
532
  };
481
533
 
534
+ export type UpdateEvmAccountBody = {
535
+ /**
536
+ * An optional name for the account.
537
+ Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
538
+ Account names must be unique across all EVM accounts in the developer's CDP Project.
539
+ * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
540
+ */
541
+ name?: string;
542
+ /**
543
+ * The ID of the account-level policy to apply to the account.
544
+ * @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}$
545
+ */
546
+ accountPolicy?: string;
547
+ };
548
+
482
549
  /**
483
550
  * The network to send the transaction to.
484
551
  */
@@ -533,6 +600,11 @@ export type SignEvmMessage200 = {
533
600
  signature: string;
534
601
  };
535
602
 
603
+ export type SignEvmTypedData200 = {
604
+ /** The signature of the typed data, as a 0x-prefixed hex string. */
605
+ signature: string;
606
+ };
607
+
536
608
  export type ListEvmSmartAccountsParams = {
537
609
  /**
538
610
  * The number of accounts to return per page.
@@ -738,6 +810,20 @@ Account names must be unique across all Solana accounts in the developer's CDP P
738
810
  name?: string;
739
811
  };
740
812
 
813
+ export type UpdateSolanaAccountBody = {
814
+ /**
815
+ * An optional name for the account. Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
816
+ Account names must be unique across all Solana accounts in the developer's CDP Project.
817
+ * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
818
+ */
819
+ name?: string;
820
+ /**
821
+ * The ID of the account-level policy to apply to the account.
822
+ * @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}$
823
+ */
824
+ accountPolicy?: string;
825
+ };
826
+
741
827
  export type SignSolanaTransactionBody = {
742
828
  /** The base64 encoded transaction to sign. */
743
829
  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
- export * from "./faucets/faucets.msw.js";
2
1
  export * from "./evm-accounts/evm-accounts.msw.js";
3
2
  export * from "./evm-token-balances/evm-token-balances.msw.js";
4
3
  export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
4
+ export * from "./faucets/faucets.msw.js";
5
5
  export * from "./policy-engine/policy-engine.msw.js";
6
6
  export * from "./solana-accounts/solana-accounts.msw.js";
@@ -25,6 +25,14 @@ export const getListSolanaAccountsResponseMock = (): ListSolanaAccounts200 => ({
25
25
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
26
26
  undefined,
27
27
  ]),
28
+ policies: faker.helpers.arrayElement([
29
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
30
+ faker.helpers.fromRegExp(
31
+ "^[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}$",
32
+ ),
33
+ ),
34
+ undefined,
35
+ ]),
28
36
  }),
29
37
  ),
30
38
  },
@@ -39,6 +47,14 @@ export const getCreateSolanaAccountResponseMock = (
39
47
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
40
48
  undefined,
41
49
  ]),
50
+ policies: faker.helpers.arrayElement([
51
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
52
+ faker.helpers.fromRegExp(
53
+ "^[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}$",
54
+ ),
55
+ ),
56
+ undefined,
57
+ ]),
42
58
  ...overrideResponse,
43
59
  });
44
60
 
@@ -50,6 +66,33 @@ export const getGetSolanaAccountResponseMock = (
50
66
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
51
67
  undefined,
52
68
  ]),
69
+ policies: faker.helpers.arrayElement([
70
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
71
+ faker.helpers.fromRegExp(
72
+ "^[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}$",
73
+ ),
74
+ ),
75
+ undefined,
76
+ ]),
77
+ ...overrideResponse,
78
+ });
79
+
80
+ export const getUpdateSolanaAccountResponseMock = (
81
+ overrideResponse: Partial<SolanaAccount> = {},
82
+ ): SolanaAccount => ({
83
+ address: faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
84
+ name: faker.helpers.arrayElement([
85
+ faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
86
+ undefined,
87
+ ]),
88
+ policies: faker.helpers.arrayElement([
89
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
90
+ faker.helpers.fromRegExp(
91
+ "^[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}$",
92
+ ),
93
+ ),
94
+ undefined,
95
+ ]),
53
96
  ...overrideResponse,
54
97
  });
55
98
 
@@ -61,6 +104,14 @@ export const getGetSolanaAccountByNameResponseMock = (
61
104
  faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
62
105
  undefined,
63
106
  ]),
107
+ policies: faker.helpers.arrayElement([
108
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
109
+ faker.helpers.fromRegExp(
110
+ "^[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}$",
111
+ ),
112
+ ),
113
+ undefined,
114
+ ]),
64
115
  ...overrideResponse,
65
116
  });
66
117
 
@@ -141,6 +192,29 @@ export const getGetSolanaAccountMockHandler = (
141
192
  });
142
193
  };
143
194
 
195
+ export const getUpdateSolanaAccountMockHandler = (
196
+ overrideResponse?:
197
+ | SolanaAccount
198
+ | ((
199
+ info: Parameters<Parameters<typeof http.put>[1]>[0],
200
+ ) => Promise<SolanaAccount> | SolanaAccount),
201
+ ) => {
202
+ return http.put("*/v2/solana/accounts/:address", async info => {
203
+ await delay(0);
204
+
205
+ return new HttpResponse(
206
+ JSON.stringify(
207
+ overrideResponse !== undefined
208
+ ? typeof overrideResponse === "function"
209
+ ? await overrideResponse(info)
210
+ : overrideResponse
211
+ : getUpdateSolanaAccountResponseMock(),
212
+ ),
213
+ { status: 200, headers: { "Content-Type": "application/json" } },
214
+ );
215
+ });
216
+ };
217
+
144
218
  export const getGetSolanaAccountByNameMockHandler = (
145
219
  overrideResponse?:
146
220
  | SolanaAccount
@@ -213,6 +287,7 @@ export const getSolanaAccountsMock = () => [
213
287
  getListSolanaAccountsMockHandler(),
214
288
  getCreateSolanaAccountMockHandler(),
215
289
  getGetSolanaAccountMockHandler(),
290
+ getUpdateSolanaAccountMockHandler(),
216
291
  getGetSolanaAccountByNameMockHandler(),
217
292
  getSignSolanaTransactionMockHandler(),
218
293
  getSignSolanaMessageMockHandler(),
@@ -14,6 +14,7 @@ import type {
14
14
  SignSolanaTransaction200,
15
15
  SignSolanaTransactionBody,
16
16
  SolanaAccount,
17
+ UpdateSolanaAccountBody,
17
18
  } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
18
19
 
19
20
  import { cdpApiClient } from "../../cdpApiClient.js";
@@ -67,6 +68,25 @@ export const getSolanaAccount = (
67
68
  options,
68
69
  );
69
70
  };
71
+ /**
72
+ * Updates an existing Solana account. Use this to update the account's name or account-level policy.
73
+ * @summary Update a Solana account
74
+ */
75
+ export const updateSolanaAccount = (
76
+ address: string,
77
+ updateSolanaAccountBody: UpdateSolanaAccountBody,
78
+ options?: SecondParameter<typeof cdpApiClient>,
79
+ ) => {
80
+ return cdpApiClient<SolanaAccount>(
81
+ {
82
+ url: `/v2/solana/accounts/${address}`,
83
+ method: "PUT",
84
+ headers: { "Content-Type": "application/json" },
85
+ data: updateSolanaAccountBody,
86
+ },
87
+ options,
88
+ );
89
+ };
70
90
  /**
71
91
  * Gets a Solana account by its name.
72
92
  * @summary Get a Solana account by name
@@ -134,6 +154,9 @@ export type CreateSolanaAccountResult = NonNullable<
134
154
  Awaited<ReturnType<typeof createSolanaAccount>>
135
155
  >;
136
156
  export type GetSolanaAccountResult = NonNullable<Awaited<ReturnType<typeof getSolanaAccount>>>;
157
+ export type UpdateSolanaAccountResult = NonNullable<
158
+ Awaited<ReturnType<typeof updateSolanaAccount>>
159
+ >;
137
160
  export type GetSolanaAccountByNameResult = NonNullable<
138
161
  Awaited<ReturnType<typeof getSolanaAccountByName>>
139
162
  >;
@@ -11,6 +11,7 @@ import * as evm from "./generated/evm-accounts/evm-accounts.js";
11
11
  import * as evmSmartAccounts from "./generated/evm-smart-accounts/evm-smart-accounts.js";
12
12
  import * as evmTokenBalances from "./generated/evm-token-balances/evm-token-balances.js";
13
13
  import * as faucets from "./generated/faucets/faucets.js";
14
+ import * as policies from "./generated/policy-engine/policy-engine.js";
14
15
  import * as solana from "./generated/solana-accounts/solana-accounts.js";
15
16
 
16
17
  export const CdpOpenApiClient = {
@@ -19,6 +20,7 @@ export const CdpOpenApiClient = {
19
20
  ...evmTokenBalances,
20
21
  ...solana,
21
22
  ...faucets,
23
+ ...policies,
22
24
  configure,
23
25
  };
24
26
 
@@ -34,4 +36,8 @@ export const OpenApiSolanaMethods = {
34
36
  requestSolanaFaucet: faucets.requestSolanaFaucet,
35
37
  };
36
38
 
39
+ export const OpenApiPoliciesMethods = {
40
+ ...policies,
41
+ };
42
+
37
43
  export type CdpOpenApiClientType = typeof CdpOpenApiClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.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",
@@ -23,7 +23,8 @@
23
23
  "axios": "^1.8.2",
24
24
  "jose": "^6.0.8",
25
25
  "md5": "^2.3.0",
26
- "viem": "^2.21.26"
26
+ "viem": "^2.21.26",
27
+ "zod": "^3.24.4"
27
28
  },
28
29
  "author": "Coinbase Inc.",
29
30
  "repository": "https://github.com/coinbase/cdp-sdk",