@coinbase/cdp-sdk 1.8.0 → 1.10.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 (142) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +190 -105
  3. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  4. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  5. package/_cjs/accounts/solana/toSolanaAccount.js +7 -0
  6. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  7. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
  8. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  9. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  10. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  11. package/_cjs/actions/evm/transfer/transfer.js +2 -39
  12. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  13. package/_cjs/actions/evm/transfer/utils.js +0 -12
  14. package/_cjs/actions/evm/transfer/utils.js.map +1 -1
  15. package/_cjs/actions/solana/constants.js +9 -0
  16. package/_cjs/actions/solana/constants.js.map +1 -0
  17. package/_cjs/actions/solana/transfer.js +117 -0
  18. package/_cjs/actions/solana/transfer.js.map +1 -0
  19. package/_cjs/actions/solana/utils.js +66 -0
  20. package/_cjs/actions/solana/utils.js.map +1 -0
  21. package/_cjs/analytics.js +2 -0
  22. package/_cjs/analytics.js.map +1 -1
  23. package/_cjs/client/evm/constants.js +21 -0
  24. package/_cjs/client/evm/constants.js.map +1 -0
  25. package/_cjs/client/evm/evm.js +75 -0
  26. package/_cjs/client/evm/evm.js.map +1 -1
  27. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
  28. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  29. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +14 -1
  30. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  31. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +26 -1
  32. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  33. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
  34. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  35. package/_cjs/policies/schema.js +60 -1
  36. package/_cjs/policies/schema.js.map +1 -1
  37. package/_cjs/version.js +1 -1
  38. package/_cjs/version.js.map +1 -1
  39. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  40. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  41. package/_esm/accounts/solana/toSolanaAccount.js +7 -0
  42. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  43. package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
  44. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  45. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  46. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  47. package/_esm/actions/evm/transfer/transfer.js +2 -39
  48. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  49. package/_esm/actions/evm/transfer/utils.js +0 -11
  50. package/_esm/actions/evm/transfer/utils.js.map +1 -1
  51. package/_esm/actions/solana/constants.js +6 -0
  52. package/_esm/actions/solana/constants.js.map +1 -0
  53. package/_esm/actions/solana/transfer.js +114 -0
  54. package/_esm/actions/solana/transfer.js.map +1 -0
  55. package/_esm/actions/solana/utils.js +61 -0
  56. package/_esm/actions/solana/utils.js.map +1 -0
  57. package/_esm/analytics.js +2 -0
  58. package/_esm/analytics.js.map +1 -1
  59. package/_esm/client/evm/constants.js +18 -0
  60. package/_esm/client/evm/constants.js.map +1 -0
  61. package/_esm/client/evm/evm.js +75 -0
  62. package/_esm/client/evm/evm.js.map +1 -1
  63. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
  64. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  65. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +12 -0
  66. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  67. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +23 -0
  68. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  69. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
  70. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  71. package/_esm/policies/schema.js +59 -0
  72. package/_esm/policies/schema.js.map +1 -1
  73. package/_esm/version.js +1 -1
  74. package/_esm/version.js.map +1 -1
  75. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  76. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  77. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  78. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
  79. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  80. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
  81. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  82. package/_types/actions/evm/transfer/transfer.d.ts +6 -4
  83. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  84. package/_types/actions/evm/transfer/types.d.ts +7 -52
  85. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  86. package/_types/actions/evm/transfer/utils.d.ts +0 -619
  87. package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
  88. package/_types/actions/evm/types.d.ts +140 -68
  89. package/_types/actions/evm/types.d.ts.map +1 -1
  90. package/_types/actions/solana/constants.d.ts +6 -0
  91. package/_types/actions/solana/constants.d.ts.map +1 -0
  92. package/_types/actions/solana/transfer.d.ts +36 -0
  93. package/_types/actions/solana/transfer.d.ts.map +1 -0
  94. package/_types/actions/solana/types.d.ts +27 -0
  95. package/_types/actions/solana/types.d.ts.map +1 -1
  96. package/_types/actions/solana/utils.d.ts +34 -0
  97. package/_types/actions/solana/utils.d.ts.map +1 -0
  98. package/_types/analytics.d.ts.map +1 -1
  99. package/_types/client/evm/constants.d.ts +5 -0
  100. package/_types/client/evm/constants.d.ts.map +1 -0
  101. package/_types/client/evm/evm.d.ts +44 -1
  102. package/_types/client/evm/evm.d.ts.map +1 -1
  103. package/_types/client/evm/evm.types.d.ts +13 -1
  104. package/_types/client/evm/evm.types.d.ts.map +1 -1
  105. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +106 -17
  106. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  107. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +7 -1
  108. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  109. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +2 -0
  110. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  111. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
  112. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  113. package/_types/openapi-client/index.d.ts +2 -0
  114. package/_types/openapi-client/index.d.ts.map +1 -1
  115. package/_types/policies/schema.d.ts +630 -0
  116. package/_types/policies/schema.d.ts.map +1 -1
  117. package/_types/version.d.ts +1 -1
  118. package/_types/version.d.ts.map +1 -1
  119. package/accounts/evm/toEvmServerAccount.ts +7 -6
  120. package/accounts/evm/toEvmSmartAccount.ts +1 -2
  121. package/accounts/solana/toSolanaAccount.ts +7 -0
  122. package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
  123. package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
  124. package/actions/evm/transfer/transfer.ts +10 -51
  125. package/actions/evm/transfer/types.ts +8 -66
  126. package/actions/evm/transfer/utils.ts +0 -13
  127. package/actions/evm/types.ts +143 -78
  128. package/actions/solana/constants.ts +6 -0
  129. package/actions/solana/transfer.ts +219 -0
  130. package/actions/solana/types.ts +28 -0
  131. package/actions/solana/utils.ts +79 -0
  132. package/analytics.ts +2 -0
  133. package/client/evm/constants.ts +17 -0
  134. package/client/evm/evm.ts +90 -0
  135. package/client/evm/evm.types.ts +14 -0
  136. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +146 -18
  137. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +41 -0
  138. package/openapi-client/generated/evm-accounts/evm-accounts.ts +20 -0
  139. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
  140. package/package.json +2 -1
  141. package/policies/schema.ts +83 -0
  142. 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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
@@ -18,6 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
+ "@solana/spl-token": "^0.4.13",
21
22
  "@solana/web3.js": "^1.98.1",
22
23
  "abitype": "1.0.6",
23
24
  "axios": "^1.8.2",
@@ -21,6 +21,16 @@ export const EvmAddressOperatorEnum = z.enum(["in", "not in"]);
21
21
  */
22
22
  export type EvmAddressOperator = z.infer<typeof EvmAddressOperatorEnum>;
23
23
 
24
+ /**
25
+ * Enum for EvmNetworkOperator values
26
+ */
27
+ export const EvmNetworkOperatorEnum = z.enum(["in", "not in"]);
28
+ /**
29
+ * Type representing the operators that can be used for EVM network comparisons.
30
+ * These operators determine how the transaction's network is evaluated against a list.
31
+ */
32
+ export type EvmNetworkOperator = z.infer<typeof EvmNetworkOperatorEnum>;
33
+
24
34
  /**
25
35
  * Enum for SolAddressOperator values
26
36
  */
@@ -68,6 +78,35 @@ export const EvmAddressCriterionSchema = z.object({
68
78
  });
69
79
  export type EvmAddressCriterion = z.infer<typeof EvmAddressCriterionSchema>;
70
80
 
81
+ /**
82
+ * Enum for EVM Network values
83
+ */
84
+ export const EvmNetworkEnum = z.enum(["base", "base-sepolia"]);
85
+ /**
86
+ * Type representing the valid networks used with CDP transaction API's.
87
+ */
88
+ export type EvmNetwork = z.infer<typeof EvmNetworkEnum>;
89
+
90
+ /**
91
+ * Schema for EVM network criterions
92
+ */
93
+ export const EvmNetworkCriterionSchema = z.object({
94
+ /** The type of criterion, must be "evmAddress" for EVM address-based rules. */
95
+ type: z.literal("evmNetwork"),
96
+ /**
97
+ * Array of EVM network identifiers to compare against.
98
+ * Either "base" or "base-sepolia"
99
+ */
100
+ networks: z.array(EvmNetworkEnum),
101
+ /**
102
+ * The operator to use for evaluating transaction network.
103
+ * "in" checks if a network is in the provided list.
104
+ * "not in" checks if a network is not in the provided list.
105
+ */
106
+ operator: EvmNetworkOperatorEnum,
107
+ });
108
+ export type EvmNetworkCriterion = z.infer<typeof EvmNetworkCriterionSchema>;
109
+
71
110
  /**
72
111
  * Schema for Solana address criterions
73
112
  */
@@ -101,6 +140,26 @@ export const SignEvmTransactionCriteriaSchema = z
101
140
  */
102
141
  export type SignEvmTransactionCriteria = z.infer<typeof SignEvmTransactionCriteriaSchema>;
103
142
 
143
+ /**
144
+ * Schema for criteria used in SendEvmTransaction operations
145
+ */
146
+ export const SendEvmTransactionCriteriaSchema = z
147
+ .array(
148
+ z.discriminatedUnion("type", [
149
+ EthValueCriterionSchema,
150
+ EvmAddressCriterionSchema,
151
+ EvmNetworkCriterionSchema,
152
+ ]),
153
+ )
154
+ .max(10)
155
+ .min(1);
156
+
157
+ /**
158
+ * Type representing a set of criteria for the sendEvmTransaction operation.
159
+ * Can contain up to 10 individual criterion objects of ETH value or EVM address types.
160
+ */
161
+ export type SendEvmTransactionCriteria = z.infer<typeof SendEvmTransactionCriteriaSchema>;
162
+
104
163
  /**
105
164
  * Schema for criteria used in SignSolTransaction operations
106
165
  */
@@ -167,6 +226,29 @@ export const SignEvmTransactionRuleSchema = z.object({
167
226
  });
168
227
  export type SignEvmTransactionRule = z.infer<typeof SignEvmTransactionRuleSchema>;
169
228
 
229
+ /**
230
+ * Type representing a 'sendEvmTransaction' policy rule that can accept or reject specific operations
231
+ * based on a set of criteria.
232
+ */
233
+ export const SendEvmTransactionRuleSchema = z.object({
234
+ /**
235
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
236
+ * "accept" will allow the transaction, "reject" will block it.
237
+ */
238
+ action: ActionEnum,
239
+ /**
240
+ * The operation to which this rule applies.
241
+ * Must be "sendEvmTransaction".
242
+ */
243
+ operation: z.literal("sendEvmTransaction"),
244
+ /**
245
+ * The set of criteria that must be matched for this rule to apply.
246
+ * Must be compatible with the specified operation type.
247
+ */
248
+ criteria: SendEvmTransactionCriteriaSchema,
249
+ });
250
+ export type SendEvmTransactionRule = z.infer<typeof SendEvmTransactionRuleSchema>;
251
+
170
252
  /**
171
253
  * Type representing a 'signSolTransaction' policy rule that can accept or reject specific operations
172
254
  * based on a set of criteria.
@@ -195,6 +277,7 @@ export type SignSolTransactionRule = z.infer<typeof SignSolTransactionRuleSchema
195
277
  */
196
278
  export const RuleSchema = z.discriminatedUnion("operation", [
197
279
  SignEvmTransactionRuleSchema,
280
+ SendEvmTransactionRuleSchema,
198
281
  SignSolTransactionRuleSchema,
199
282
  ]);
200
283
 
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.8.0";
1
+ export const version = "1.10.0";