@coinbase/cdp-sdk 1.6.0 → 1.7.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 +13 -0
- package/README.md +62 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js +7 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +41 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_cjs/accounts/solana/types.js +3 -0
- package/_cjs/accounts/solana/types.js.map +1 -0
- package/_cjs/actions/evm/getUserOperation.js +36 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -0
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +7 -3
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/solana/requestFaucet.js +29 -0
- package/_cjs/actions/solana/requestFaucet.js.map +1 -0
- package/_cjs/actions/solana/signMessage.js +29 -0
- package/_cjs/actions/solana/signMessage.js.map +1 -0
- package/_cjs/actions/solana/signTransaction.js +46 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -0
- package/_cjs/actions/solana/types.js +3 -0
- package/_cjs/actions/solana/types.js.map +1 -0
- package/_cjs/client/evm/evm.js +2 -12
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js +22 -17
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +3 -2
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +1 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +7 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +38 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_esm/accounts/solana/types.js +2 -0
- package/_esm/accounts/solana/types.js.map +1 -0
- package/_esm/actions/evm/getUserOperation.js +33 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -0
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +7 -3
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/solana/requestFaucet.js +26 -0
- package/_esm/actions/solana/requestFaucet.js.map +1 -0
- package/_esm/actions/solana/signMessage.js +26 -0
- package/_esm/actions/solana/signMessage.js.map +1 -0
- package/_esm/actions/solana/signTransaction.js +43 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -0
- package/_esm/actions/solana/types.js +2 -0
- package/_esm/actions/solana/types.js.map +1 -0
- package/_esm/client/evm/evm.js +2 -12
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +22 -17
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +3 -2
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +1 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/{types.d.ts → evm/types.d.ts} +5 -5
- package/_types/accounts/evm/types.d.ts.map +1 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
- package/_types/accounts/solana/types.d.ts +12 -0
- package/_types/accounts/solana/types.d.ts.map +1 -0
- package/_types/actions/evm/getUserOperation.d.ts +22 -0
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
- package/_types/actions/evm/sendUserOperation.d.ts +1 -1
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +3 -3
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +41 -7
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +28 -5
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/requestFaucet.d.ts +23 -0
- package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
- package/_types/actions/solana/signMessage.d.ts +23 -0
- package/_types/actions/solana/signMessage.d.ts.map +1 -0
- package/_types/actions/solana/signTransaction.d.ts +38 -0
- package/_types/actions/solana/signTransaction.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +80 -0
- package/_types/actions/solana/types.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +3 -3
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +5 -4
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +8 -11
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +218 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +3 -2
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +1 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +1 -1
- package/accounts/evm/toEvmSmartAccount.ts +11 -1
- package/accounts/{types.ts → evm/types.ts} +5 -5
- package/accounts/solana/toSolanaAccount.ts +59 -0
- package/accounts/solana/types.ts +13 -0
- package/actions/evm/getUserOperation.ts +40 -0
- package/actions/evm/sendUserOperation.ts +1 -1
- package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +10 -7
- package/actions/evm/transfer/transfer.ts +17 -6
- package/actions/evm/transfer/types.ts +55 -12
- package/actions/evm/types.ts +37 -5
- package/actions/solana/requestFaucet.ts +35 -0
- package/actions/solana/signMessage.ts +36 -0
- package/actions/solana/signTransaction.ts +53 -0
- package/actions/solana/types.ts +87 -0
- package/client/evm/evm.ts +3 -16
- package/client/evm/evm.types.ts +4 -3
- package/client/solana/solana.ts +32 -37
- package/client/solana/solana.types.ts +10 -15
- package/index.ts +1 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +274 -0
- package/openapi-client/generated/index.msw.ts +3 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
- package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
- package/openapi-client/index.ts +1 -0
- package/package.json +1 -1
- package/version.ts +1 -1
- package/_types/accounts/types.d.ts.map +0 -1
- /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
- /package/_esm/accounts/{types.js → evm/types.js} +0 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
EthValueCriterion,
|
|
14
|
+
EvmAddressCriterion,
|
|
15
|
+
ListPolicies200,
|
|
16
|
+
Policy,
|
|
17
|
+
SolAddressCriterion,
|
|
18
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
19
|
+
|
|
20
|
+
export const getListPoliciesResponseEthValueCriterionMock = (
|
|
21
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
22
|
+
): EthValueCriterion => ({
|
|
23
|
+
...{
|
|
24
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
25
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
26
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
27
|
+
},
|
|
28
|
+
...overrideResponse,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const getListPoliciesResponseEvmAddressCriterionMock = (
|
|
32
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
33
|
+
): EvmAddressCriterion => ({
|
|
34
|
+
...{
|
|
35
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
36
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
37
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
38
|
+
),
|
|
39
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
40
|
+
},
|
|
41
|
+
...overrideResponse,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const getListPoliciesResponseSolAddressCriterionMock = (
|
|
45
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
46
|
+
): SolAddressCriterion => ({
|
|
47
|
+
...{
|
|
48
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
49
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
50
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
51
|
+
),
|
|
52
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
53
|
+
},
|
|
54
|
+
...overrideResponse,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
58
|
+
...{
|
|
59
|
+
policies: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
60
|
+
() => ({
|
|
61
|
+
id: faker.helpers.fromRegExp(
|
|
62
|
+
"^[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}$",
|
|
63
|
+
),
|
|
64
|
+
description: faker.helpers.arrayElement([
|
|
65
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
66
|
+
undefined,
|
|
67
|
+
]),
|
|
68
|
+
scope: faker.helpers.arrayElement(["project", "account"] as const),
|
|
69
|
+
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
|
+
() =>
|
|
79
|
+
faker.helpers.arrayElement([
|
|
80
|
+
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
81
|
+
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
82
|
+
]),
|
|
83
|
+
),
|
|
84
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
85
|
+
() =>
|
|
86
|
+
faker.helpers.arrayElement([
|
|
87
|
+
{ ...getListPoliciesResponseSolAddressCriterionMock() },
|
|
88
|
+
]),
|
|
89
|
+
),
|
|
90
|
+
]),
|
|
91
|
+
}),
|
|
92
|
+
),
|
|
93
|
+
createdAt: faker.string.alpha(20),
|
|
94
|
+
updatedAt: faker.string.alpha(20),
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const getCreatePolicyResponseEthValueCriterionMock = (
|
|
102
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
103
|
+
): EthValueCriterion => ({
|
|
104
|
+
...{
|
|
105
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
106
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
107
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
108
|
+
},
|
|
109
|
+
...overrideResponse,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const getCreatePolicyResponseEvmAddressCriterionMock = (
|
|
113
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
114
|
+
): EvmAddressCriterion => ({
|
|
115
|
+
...{
|
|
116
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
117
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
118
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
119
|
+
),
|
|
120
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
121
|
+
},
|
|
122
|
+
...overrideResponse,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const getCreatePolicyResponseSolAddressCriterionMock = (
|
|
126
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
127
|
+
): SolAddressCriterion => ({
|
|
128
|
+
...{
|
|
129
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
130
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
131
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
132
|
+
),
|
|
133
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
134
|
+
},
|
|
135
|
+
...overrideResponse,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
139
|
+
id: faker.helpers.fromRegExp(
|
|
140
|
+
"^[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}$",
|
|
141
|
+
),
|
|
142
|
+
description: faker.helpers.arrayElement([
|
|
143
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
144
|
+
undefined,
|
|
145
|
+
]),
|
|
146
|
+
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
|
+
),
|
|
160
|
+
]),
|
|
161
|
+
})),
|
|
162
|
+
createdAt: faker.string.alpha(20),
|
|
163
|
+
updatedAt: faker.string.alpha(20),
|
|
164
|
+
...overrideResponse,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const getGetPolicyByIdResponseEthValueCriterionMock = (
|
|
168
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
169
|
+
): EthValueCriterion => ({
|
|
170
|
+
...{
|
|
171
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
172
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
173
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
174
|
+
},
|
|
175
|
+
...overrideResponse,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const getGetPolicyByIdResponseEvmAddressCriterionMock = (
|
|
179
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
180
|
+
): EvmAddressCriterion => ({
|
|
181
|
+
...{
|
|
182
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
183
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
184
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
185
|
+
),
|
|
186
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
187
|
+
},
|
|
188
|
+
...overrideResponse,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const getGetPolicyByIdResponseSolAddressCriterionMock = (
|
|
192
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
193
|
+
): SolAddressCriterion => ({
|
|
194
|
+
...{
|
|
195
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
196
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
197
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
198
|
+
),
|
|
199
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
200
|
+
},
|
|
201
|
+
...overrideResponse,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
205
|
+
id: faker.helpers.fromRegExp(
|
|
206
|
+
"^[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}$",
|
|
207
|
+
),
|
|
208
|
+
description: faker.helpers.arrayElement([
|
|
209
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
210
|
+
undefined,
|
|
211
|
+
]),
|
|
212
|
+
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
|
+
),
|
|
226
|
+
]),
|
|
227
|
+
})),
|
|
228
|
+
createdAt: faker.string.alpha(20),
|
|
229
|
+
updatedAt: faker.string.alpha(20),
|
|
230
|
+
...overrideResponse,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export const getUpdatePolicyResponseEthValueCriterionMock = (
|
|
234
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
235
|
+
): EthValueCriterion => ({
|
|
236
|
+
...{
|
|
237
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
238
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
239
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
240
|
+
},
|
|
241
|
+
...overrideResponse,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
export const getUpdatePolicyResponseEvmAddressCriterionMock = (
|
|
245
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
246
|
+
): EvmAddressCriterion => ({
|
|
247
|
+
...{
|
|
248
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
249
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
250
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
251
|
+
),
|
|
252
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
253
|
+
},
|
|
254
|
+
...overrideResponse,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
export const getUpdatePolicyResponseSolAddressCriterionMock = (
|
|
258
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
259
|
+
): SolAddressCriterion => ({
|
|
260
|
+
...{
|
|
261
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
262
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
263
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
264
|
+
),
|
|
265
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
266
|
+
},
|
|
267
|
+
...overrideResponse,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
271
|
+
id: faker.helpers.fromRegExp(
|
|
272
|
+
"^[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}$",
|
|
273
|
+
),
|
|
274
|
+
description: faker.helpers.arrayElement([
|
|
275
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
276
|
+
undefined,
|
|
277
|
+
]),
|
|
278
|
+
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
|
+
),
|
|
292
|
+
]),
|
|
293
|
+
})),
|
|
294
|
+
createdAt: faker.string.alpha(20),
|
|
295
|
+
updatedAt: faker.string.alpha(20),
|
|
296
|
+
...overrideResponse,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
export const getListPoliciesMockHandler = (
|
|
300
|
+
overrideResponse?:
|
|
301
|
+
| ListPolicies200
|
|
302
|
+
| ((
|
|
303
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
304
|
+
) => Promise<ListPolicies200> | ListPolicies200),
|
|
305
|
+
) => {
|
|
306
|
+
return http.get("*/v2/policy-engine/policies", async info => {
|
|
307
|
+
await delay(0);
|
|
308
|
+
|
|
309
|
+
return new HttpResponse(
|
|
310
|
+
JSON.stringify(
|
|
311
|
+
overrideResponse !== undefined
|
|
312
|
+
? typeof overrideResponse === "function"
|
|
313
|
+
? await overrideResponse(info)
|
|
314
|
+
: overrideResponse
|
|
315
|
+
: getListPoliciesResponseMock(),
|
|
316
|
+
),
|
|
317
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const getCreatePolicyMockHandler = (
|
|
323
|
+
overrideResponse?:
|
|
324
|
+
| Policy
|
|
325
|
+
| ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<Policy> | Policy),
|
|
326
|
+
) => {
|
|
327
|
+
return http.post("*/v2/policy-engine/policies", async info => {
|
|
328
|
+
await delay(0);
|
|
329
|
+
|
|
330
|
+
return new HttpResponse(
|
|
331
|
+
JSON.stringify(
|
|
332
|
+
overrideResponse !== undefined
|
|
333
|
+
? typeof overrideResponse === "function"
|
|
334
|
+
? await overrideResponse(info)
|
|
335
|
+
: overrideResponse
|
|
336
|
+
: getCreatePolicyResponseMock(),
|
|
337
|
+
),
|
|
338
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const getGetPolicyByIdMockHandler = (
|
|
344
|
+
overrideResponse?:
|
|
345
|
+
| Policy
|
|
346
|
+
| ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<Policy> | Policy),
|
|
347
|
+
) => {
|
|
348
|
+
return http.get("*/v2/policy-engine/policies/:policyId", async info => {
|
|
349
|
+
await delay(0);
|
|
350
|
+
|
|
351
|
+
return new HttpResponse(
|
|
352
|
+
JSON.stringify(
|
|
353
|
+
overrideResponse !== undefined
|
|
354
|
+
? typeof overrideResponse === "function"
|
|
355
|
+
? await overrideResponse(info)
|
|
356
|
+
: overrideResponse
|
|
357
|
+
: getGetPolicyByIdResponseMock(),
|
|
358
|
+
),
|
|
359
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export const getDeletePolicyMockHandler = (
|
|
365
|
+
overrideResponse?:
|
|
366
|
+
| void
|
|
367
|
+
| ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
|
|
368
|
+
) => {
|
|
369
|
+
return http.delete("*/v2/policy-engine/policies/:policyId", async info => {
|
|
370
|
+
await delay(0);
|
|
371
|
+
if (typeof overrideResponse === "function") {
|
|
372
|
+
await overrideResponse(info);
|
|
373
|
+
}
|
|
374
|
+
return new HttpResponse(null, { status: 204 });
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export const getUpdatePolicyMockHandler = (
|
|
379
|
+
overrideResponse?:
|
|
380
|
+
| Policy
|
|
381
|
+
| ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<Policy> | Policy),
|
|
382
|
+
) => {
|
|
383
|
+
return http.put("*/v2/policy-engine/policies/:policyId", async info => {
|
|
384
|
+
await delay(0);
|
|
385
|
+
|
|
386
|
+
return new HttpResponse(
|
|
387
|
+
JSON.stringify(
|
|
388
|
+
overrideResponse !== undefined
|
|
389
|
+
? typeof overrideResponse === "function"
|
|
390
|
+
? await overrideResponse(info)
|
|
391
|
+
: overrideResponse
|
|
392
|
+
: getUpdatePolicyResponseMock(),
|
|
393
|
+
),
|
|
394
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
395
|
+
);
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
export const getPolicyEngineMock = () => [
|
|
399
|
+
getListPoliciesMockHandler(),
|
|
400
|
+
getCreatePolicyMockHandler(),
|
|
401
|
+
getGetPolicyByIdMockHandler(),
|
|
402
|
+
getDeletePolicyMockHandler(),
|
|
403
|
+
getUpdatePolicyMockHandler(),
|
|
404
|
+
];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
CreatePolicyBody,
|
|
10
|
+
ListPolicies200,
|
|
11
|
+
ListPoliciesParams,
|
|
12
|
+
Policy,
|
|
13
|
+
UpdatePolicyBody,
|
|
14
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
15
|
+
|
|
16
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
17
|
+
|
|
18
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Lists the policies belonging to the developer's CDP Project. Use the `scope` parameter to filter the policies by scope.
|
|
22
|
+
The response is paginated, and by default, returns 20 policies per page.
|
|
23
|
+
* @summary List policies
|
|
24
|
+
*/
|
|
25
|
+
export const listPolicies = (
|
|
26
|
+
params?: ListPoliciesParams,
|
|
27
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
28
|
+
) => {
|
|
29
|
+
return cdpApiClient<ListPolicies200>(
|
|
30
|
+
{ url: `/v2/policy-engine/policies`, method: "GET", params },
|
|
31
|
+
options,
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Create a policy that can be used to govern the behavior of accounts.
|
|
36
|
+
* @summary Create a policy
|
|
37
|
+
*/
|
|
38
|
+
export const createPolicy = (
|
|
39
|
+
createPolicyBody: CreatePolicyBody,
|
|
40
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
41
|
+
) => {
|
|
42
|
+
return cdpApiClient<Policy>(
|
|
43
|
+
{
|
|
44
|
+
url: `/v2/policy-engine/policies`,
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: { "Content-Type": "application/json" },
|
|
47
|
+
data: createPolicyBody,
|
|
48
|
+
},
|
|
49
|
+
options,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Get a policy by its ID.
|
|
54
|
+
* @summary Get a policy by ID
|
|
55
|
+
*/
|
|
56
|
+
export const getPolicyById = (policyId: string, options?: SecondParameter<typeof cdpApiClient>) => {
|
|
57
|
+
return cdpApiClient<Policy>(
|
|
58
|
+
{ url: `/v2/policy-engine/policies/${policyId}`, method: "GET" },
|
|
59
|
+
options,
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Delete a policy by its ID. This will have the effect of removing the policy from all accounts that are currently using it.
|
|
64
|
+
* @summary Delete a policy
|
|
65
|
+
*/
|
|
66
|
+
export const deletePolicy = (policyId: string, options?: SecondParameter<typeof cdpApiClient>) => {
|
|
67
|
+
return cdpApiClient<void>(
|
|
68
|
+
{ url: `/v2/policy-engine/policies/${policyId}`, method: "DELETE" },
|
|
69
|
+
options,
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Updates a policy by its ID. This will have the effect of applying the updated policy to all accounts that are currently using it.
|
|
74
|
+
* @summary Update a policy
|
|
75
|
+
*/
|
|
76
|
+
export const updatePolicy = (
|
|
77
|
+
policyId: string,
|
|
78
|
+
updatePolicyBody: UpdatePolicyBody,
|
|
79
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
80
|
+
) => {
|
|
81
|
+
return cdpApiClient<Policy>(
|
|
82
|
+
{
|
|
83
|
+
url: `/v2/policy-engine/policies/${policyId}`,
|
|
84
|
+
method: "PUT",
|
|
85
|
+
headers: { "Content-Type": "application/json" },
|
|
86
|
+
data: updatePolicyBody,
|
|
87
|
+
},
|
|
88
|
+
options,
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
export type ListPoliciesResult = NonNullable<Awaited<ReturnType<typeof listPolicies>>>;
|
|
92
|
+
export type CreatePolicyResult = NonNullable<Awaited<ReturnType<typeof createPolicy>>>;
|
|
93
|
+
export type GetPolicyByIdResult = NonNullable<Awaited<ReturnType<typeof getPolicyById>>>;
|
|
94
|
+
export type DeletePolicyResult = NonNullable<Awaited<ReturnType<typeof deletePolicy>>>;
|
|
95
|
+
export type UpdatePolicyResult = NonNullable<Awaited<ReturnType<typeof updatePolicy>>>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
|
4
4
|
export * from "./generated/evm-token-balances/evm-token-balances.js";
|
|
5
5
|
export * from "./generated/solana-accounts/solana-accounts.js";
|
|
6
6
|
export * from "./generated/faucets/faucets.js";
|
|
7
|
+
export * from "./generated/policy-engine/policy-engine.js";
|
|
7
8
|
|
|
8
9
|
import { configure } from "./cdpApiClient.js";
|
|
9
10
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|
package/package.json
CHANGED
package/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.7.0";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,sEAAsE;IACtE,IAAI,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnD,iEAAiE;IACjE,WAAW,EAAE,CAAC,UAAU,EAAE;QAAE,OAAO,EAAE,eAAe,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE,8EAA8E;IAC9E,eAAe,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE,oEAAoE;IACpE,aAAa,EAAE,CACb,KAAK,CAAC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,EAEtE,UAAU,EAAE,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,KACpD,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,UAAU,GACR,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,sBAAsB,CAAC,GAAG;IAC5D,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,IAAI,EAAE,YAAY,CAAC;CACpB,CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC;IACE,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uKAAuK;IACvK,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,6CAA6C;IAC7C,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CACrC,CAAC"}
|
|
File without changes
|
|
File without changes
|