@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
@@ -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,
@@ -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.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,12 +18,14 @@
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",
24
25
  "jose": "^6.0.8",
25
26
  "md5": "^2.3.0",
26
- "viem": "^2.21.26"
27
+ "viem": "^2.21.26",
28
+ "zod": "^3.24.4"
27
29
  },
28
30
  "author": "Coinbase Inc.",
29
31
  "repository": "https://github.com/coinbase/cdp-sdk",