@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.
- package/CHANGELOG.md +16 -0
- package/README.md +190 -105
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +7 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +2 -39
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/evm/transfer/utils.js +0 -12
- package/_cjs/actions/evm/transfer/utils.js.map +1 -1
- package/_cjs/actions/solana/constants.js +9 -0
- package/_cjs/actions/solana/constants.js.map +1 -0
- package/_cjs/actions/solana/transfer.js +117 -0
- package/_cjs/actions/solana/transfer.js.map +1 -0
- package/_cjs/actions/solana/utils.js +66 -0
- package/_cjs/actions/solana/utils.js.map +1 -0
- package/_cjs/analytics.js +2 -0
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/evm/constants.js +21 -0
- package/_cjs/client/evm/constants.js.map +1 -0
- package/_cjs/client/evm/evm.js +75 -0
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +14 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +26 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/policies/schema.js +60 -1
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/version.js.map +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +7 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +2 -39
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/evm/transfer/utils.js +0 -11
- package/_esm/actions/evm/transfer/utils.js.map +1 -1
- package/_esm/actions/solana/constants.js +6 -0
- package/_esm/actions/solana/constants.js.map +1 -0
- package/_esm/actions/solana/transfer.js +114 -0
- package/_esm/actions/solana/transfer.js.map +1 -0
- package/_esm/actions/solana/utils.js +61 -0
- package/_esm/actions/solana/utils.js.map +1 -0
- package/_esm/analytics.js +2 -0
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/evm/constants.js +18 -0
- package/_esm/client/evm/constants.js.map +1 -0
- package/_esm/client/evm/evm.js +75 -0
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +12 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +23 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/policies/schema.js +59 -0
- package/_esm/policies/schema.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/version.js.map +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +6 -4
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +7 -52
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/transfer/utils.d.ts +0 -619
- package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +140 -68
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/constants.d.ts +6 -0
- package/_types/actions/solana/constants.d.ts.map +1 -0
- package/_types/actions/solana/transfer.d.ts +36 -0
- package/_types/actions/solana/transfer.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +27 -0
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +34 -0
- package/_types/actions/solana/utils.d.ts.map +1 -0
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/evm/constants.d.ts +5 -0
- package/_types/client/evm/constants.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts +44 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +13 -1
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +106 -17
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +2 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +630 -0
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/version.d.ts.map +1 -1
- package/accounts/evm/toEvmServerAccount.ts +7 -6
- package/accounts/evm/toEvmSmartAccount.ts +1 -2
- package/accounts/solana/toSolanaAccount.ts +7 -0
- package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
- package/actions/evm/transfer/transfer.ts +10 -51
- package/actions/evm/transfer/types.ts +8 -66
- package/actions/evm/transfer/utils.ts +0 -13
- package/actions/evm/types.ts +143 -78
- package/actions/solana/constants.ts +6 -0
- package/actions/solana/transfer.ts +219 -0
- package/actions/solana/types.ts +28 -0
- package/actions/solana/utils.ts +79 -0
- package/analytics.ts +2 -0
- package/client/evm/constants.ts +17 -0
- package/client/evm/evm.ts +90 -0
- package/client/evm/evm.types.ts +14 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +146 -18
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +41 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +20 -0
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
- package/package.json +2 -1
- package/policies/schema.ts +83 -0
- 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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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.
|
|
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",
|
package/policies/schema.ts
CHANGED
|
@@ -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.
|
|
1
|
+
export const version = "1.10.0";
|