@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.
- package/CHANGELOG.md +20 -0
- package/README.md +326 -28
- package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +8 -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 +70 -8
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/cdp.js +9 -3
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/evm/evm.js +133 -15
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/index.js +6 -0
- package/_cjs/client/policies/index.js.map +1 -0
- package/_cjs/client/policies/policies.js +232 -0
- package/_cjs/client/policies/policies.js.map +1 -0
- package/_cjs/client/policies/policies.types.js +3 -0
- package/_cjs/client/policies/policies.types.js.map +1 -0
- package/_cjs/client/solana/solana.js +76 -19
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +4 -1
- package/_cjs/index.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 +27 -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 +56 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +2 -2
- package/_cjs/openapi-client/generated/index.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/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +6 -1
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/schema.js +245 -0
- package/_cjs/policies/schema.js.map +1 -0
- package/_cjs/policies/types.js +3 -0
- package/_cjs/policies/types.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +8 -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 +70 -7
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/cdp.js +10 -4
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/evm/evm.js +133 -15
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/index.js +2 -0
- package/_esm/client/policies/index.js.map +1 -0
- package/_esm/client/policies/policies.js +228 -0
- package/_esm/client/policies/policies.js.map +1 -0
- package/_esm/client/policies/policies.types.js +2 -0
- package/_esm/client/policies/policies.types.js.map +1 -0
- package/_esm/client/solana/solana.js +76 -19
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.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 +24 -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 +51 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +2 -2
- package/_esm/openapi-client/generated/index.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/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +5 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/schema.js +242 -0
- package/_esm/policies/schema.js.map +1 -0
- package/_esm/policies/types.js +2 -0
- package/_esm/policies/types.js.map +1 -0
- package/_esm/version.js +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/evm/types.d.ts +6 -3
- package/_types/accounts/evm/types.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 +8 -54
- 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 +14 -5
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +3 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +89 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +33 -3
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/index.d.ts +2 -0
- package/_types/client/policies/index.d.ts.map +1 -0
- package/_types/client/policies/policies.d.ts +216 -0
- package/_types/client/policies/policies.d.ts.map +1 -0
- package/_types/client/policies/policies.types.d.ts +96 -0
- package/_types/client/policies/policies.types.d.ts.map +1 -0
- package/_types/client/solana/solana.d.ts +43 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +14 -2
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +176 -17
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -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 +5 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +2 -2
- package/_types/openapi-client/generated/index.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/generated/solana-accounts/solana-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +18 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +1552 -0
- package/_types/policies/schema.d.ts.map +1 -0
- package/_types/policies/types.d.ts +19 -0
- package/_types/policies/types.d.ts.map +1 -0
- package/_types/types/misc.d.ts +39 -0
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +11 -7
- package/accounts/evm/toEvmSmartAccount.ts +1 -2
- package/accounts/evm/types.ts +6 -8
- package/accounts/solana/toSolanaAccount.ts +8 -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 +9 -67
- 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 +86 -11
- package/client/cdp.ts +11 -4
- package/client/evm/evm.ts +159 -17
- package/client/evm/evm.types.ts +38 -1
- package/client/policies/index.ts +1 -0
- package/client/policies/policies.ts +246 -0
- package/client/policies/policies.types.ts +109 -0
- package/client/solana/solana.ts +94 -20
- package/client/solana/solana.types.ts +16 -1
- package/index.ts +7 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +220 -18
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
- package/openapi-client/generated/index.msw.ts +2 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
- package/openapi-client/index.ts +6 -0
- package/package.json +4 -2
- package/policies/schema.ts +349 -0
- package/policies/types.ts +19 -0
- package/types/misc.ts +41 -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,
|
|
@@ -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
|
>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -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.
|
|
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",
|