@coinbase/cdp-sdk 1.16.0 → 1.17.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 +6 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +7 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +8 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +28 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +26 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -0
- package/_cjs/client/policies/policies.js +6 -2
- package/_cjs/client/policies/policies.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +45 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +48 -0
- 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.msw.js +35 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +5 -5
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +342 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +40 -0
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_cjs/policies/schema.js +83 -2
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +7 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +8 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +25 -0
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +23 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -0
- package/_esm/client/policies/policies.js +7 -3
- package/_esm/client/policies/policies.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +44 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +48 -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.msw.js +35 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +5 -5
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +321 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +40 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_esm/policies/schema.js +83 -2
- package/_esm/policies/schema.js.map +1 -1
- 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/toNetworkScopedEvmServerAccount.d.ts +23 -0
- package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -0
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts +27 -0
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -0
- package/_types/accounts/evm/types.d.ts +22 -5
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +1 -1
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/policies.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +182 -2
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -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.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +5 -5
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +21 -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.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +3780 -7
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +7 -0
- package/accounts/evm/toEvmSmartAccount.ts +8 -0
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +42 -0
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +41 -0
- package/accounts/evm/types.ts +32 -11
- package/client/evm/evm.types.ts +1 -1
- package/client/policies/policies.ts +12 -3
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +221 -2
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +48 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +35 -0
- package/openapi-client/generated/faucets/faucets.ts +4 -4
- package/openapi-client/generated/index.msw.ts +5 -5
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +434 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +40 -0
- package/package.json +1 -1
- package/policies/schema.ts +94 -6
- package/version.ts +1 -1
|
@@ -27,6 +27,14 @@ export const getListEvmSmartAccountsResponseMock = (): ListEvmSmartAccounts200 =
|
|
|
27
27
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
28
28
|
undefined,
|
|
29
29
|
]),
|
|
30
|
+
createdAt: faker.helpers.arrayElement([
|
|
31
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
32
|
+
undefined,
|
|
33
|
+
]),
|
|
34
|
+
updatedAt: faker.helpers.arrayElement([
|
|
35
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
36
|
+
undefined,
|
|
37
|
+
]),
|
|
30
38
|
}),
|
|
31
39
|
),
|
|
32
40
|
},
|
|
@@ -44,6 +52,14 @@ export const getCreateEvmSmartAccountResponseMock = (
|
|
|
44
52
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
45
53
|
undefined,
|
|
46
54
|
]),
|
|
55
|
+
createdAt: faker.helpers.arrayElement([
|
|
56
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
57
|
+
undefined,
|
|
58
|
+
]),
|
|
59
|
+
updatedAt: faker.helpers.arrayElement([
|
|
60
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
61
|
+
undefined,
|
|
62
|
+
]),
|
|
47
63
|
...overrideResponse,
|
|
48
64
|
});
|
|
49
65
|
|
|
@@ -58,6 +74,14 @@ export const getGetEvmSmartAccountByNameResponseMock = (
|
|
|
58
74
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
59
75
|
undefined,
|
|
60
76
|
]),
|
|
77
|
+
createdAt: faker.helpers.arrayElement([
|
|
78
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
79
|
+
undefined,
|
|
80
|
+
]),
|
|
81
|
+
updatedAt: faker.helpers.arrayElement([
|
|
82
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
83
|
+
undefined,
|
|
84
|
+
]),
|
|
61
85
|
...overrideResponse,
|
|
62
86
|
});
|
|
63
87
|
|
|
@@ -72,6 +96,14 @@ export const getGetEvmSmartAccountResponseMock = (
|
|
|
72
96
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
73
97
|
undefined,
|
|
74
98
|
]),
|
|
99
|
+
createdAt: faker.helpers.arrayElement([
|
|
100
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
101
|
+
undefined,
|
|
102
|
+
]),
|
|
103
|
+
updatedAt: faker.helpers.arrayElement([
|
|
104
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
105
|
+
undefined,
|
|
106
|
+
]),
|
|
75
107
|
...overrideResponse,
|
|
76
108
|
});
|
|
77
109
|
|
|
@@ -90,6 +122,7 @@ export const getPrepareUserOperationResponseMock = (
|
|
|
90
122
|
"signed",
|
|
91
123
|
"broadcast",
|
|
92
124
|
"complete",
|
|
125
|
+
"dropped",
|
|
93
126
|
"failed",
|
|
94
127
|
] as const),
|
|
95
128
|
transactionHash: faker.helpers.arrayElement([
|
|
@@ -114,6 +147,7 @@ export const getGetUserOperationResponseMock = (
|
|
|
114
147
|
"signed",
|
|
115
148
|
"broadcast",
|
|
116
149
|
"complete",
|
|
150
|
+
"dropped",
|
|
117
151
|
"failed",
|
|
118
152
|
] as const),
|
|
119
153
|
transactionHash: faker.helpers.arrayElement([
|
|
@@ -138,6 +172,7 @@ export const getSendUserOperationResponseMock = (
|
|
|
138
172
|
"signed",
|
|
139
173
|
"broadcast",
|
|
140
174
|
"complete",
|
|
175
|
+
"dropped",
|
|
141
176
|
"failed",
|
|
142
177
|
] as const),
|
|
143
178
|
transactionHash: faker.helpers.arrayElement([
|
|
@@ -21,8 +21,8 @@ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
21
21
|
|
|
22
22
|
Faucets are available for ETH, USDC, EURC, and cbBTC on Base Sepolia and Ethereum Sepolia, and for ETH only on Ethereum Hoodi.
|
|
23
23
|
|
|
24
|
-
To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested.
|
|
25
|
-
These limits are applied at both the CDP User level and the blockchain address level.
|
|
24
|
+
To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested.
|
|
25
|
+
These limits are applied at both the CDP User level and the blockchain address level.
|
|
26
26
|
A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address.
|
|
27
27
|
|
|
28
28
|
| Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits|
|
|
@@ -53,8 +53,8 @@ export const requestEvmFaucet = (
|
|
|
53
53
|
|
|
54
54
|
Faucets are available for SOL.
|
|
55
55
|
|
|
56
|
-
To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested.
|
|
57
|
-
These limits are applied at both the CDP User level and the blockchain address level.
|
|
56
|
+
To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested.
|
|
57
|
+
These limits are applied at both the CDP User level and the blockchain address level.
|
|
58
58
|
A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address.
|
|
59
59
|
|
|
60
60
|
| Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./evm-accounts/evm-accounts.msw.js";
|
|
2
|
-
export * from "./evm-swaps/evm-swaps.msw.js";
|
|
3
|
-
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
4
|
-
export * from "./policy-engine/policy-engine.msw.js";
|
|
5
1
|
export * from "./evm-token-balances/evm-token-balances.msw.js";
|
|
2
|
+
export * from "./evm-accounts/evm-accounts.msw.js";
|
|
3
|
+
export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
|
|
6
4
|
export * from "./faucets/faucets.msw.js";
|
|
5
|
+
export * from "./evm-swaps/evm-swaps.msw.js";
|
|
7
6
|
export * from "./payments-alpha/payments-alpha.msw.js";
|
|
8
|
-
export * from "./
|
|
7
|
+
export * from "./policy-engine/policy-engine.msw.js";
|
|
8
|
+
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
@@ -9,9 +9,15 @@ import { faker } from "@faker-js/faker";
|
|
|
9
9
|
|
|
10
10
|
import { HttpResponse, delay, http } from "msw";
|
|
11
11
|
|
|
12
|
+
import { AbiStateMutability, KnownAbiType } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
12
13
|
import type {
|
|
14
|
+
AbiFunction,
|
|
15
|
+
AbiInput,
|
|
13
16
|
EthValueCriterion,
|
|
14
17
|
EvmAddressCriterion,
|
|
18
|
+
EvmDataCriterion,
|
|
19
|
+
EvmDataParameterCondition,
|
|
20
|
+
EvmDataParameterConditionList,
|
|
15
21
|
EvmMessageCriterion,
|
|
16
22
|
EvmNetworkCriterion,
|
|
17
23
|
ListPolicies200,
|
|
@@ -43,6 +49,111 @@ export const getListPoliciesResponseEvmAddressCriterionMock = (
|
|
|
43
49
|
...overrideResponse,
|
|
44
50
|
});
|
|
45
51
|
|
|
52
|
+
export const getListPoliciesResponseAbiFunctionMock = (
|
|
53
|
+
overrideResponse: Partial<AbiFunction> = {},
|
|
54
|
+
): AbiFunction => ({
|
|
55
|
+
...{
|
|
56
|
+
type: faker.helpers.arrayElement(["function"] as const),
|
|
57
|
+
name: faker.string.alpha(20),
|
|
58
|
+
inputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
59
|
+
() => ({
|
|
60
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
61
|
+
type: faker.string.alpha(20),
|
|
62
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
63
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
64
|
+
}),
|
|
65
|
+
),
|
|
66
|
+
outputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
67
|
+
() => ({
|
|
68
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
69
|
+
type: faker.string.alpha(20),
|
|
70
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
71
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
constant: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
75
|
+
payable: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
76
|
+
stateMutability: faker.helpers.arrayElement(Object.values(AbiStateMutability)),
|
|
77
|
+
gas: faker.helpers.arrayElement([
|
|
78
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
79
|
+
undefined,
|
|
80
|
+
]),
|
|
81
|
+
},
|
|
82
|
+
...overrideResponse,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const getListPoliciesResponseAbiInputMock = (
|
|
86
|
+
overrideResponse: Partial<AbiInput> = {},
|
|
87
|
+
): AbiInput => ({
|
|
88
|
+
...{
|
|
89
|
+
type: faker.helpers.arrayElement([
|
|
90
|
+
"constructor",
|
|
91
|
+
"error",
|
|
92
|
+
"event",
|
|
93
|
+
"fallback",
|
|
94
|
+
"receive",
|
|
95
|
+
] as const),
|
|
96
|
+
additionalProperties: faker.helpers.arrayElement([{}, undefined]),
|
|
97
|
+
},
|
|
98
|
+
...overrideResponse,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const getListPoliciesResponseEvmDataParameterConditionMock = (
|
|
102
|
+
overrideResponse: Partial<EvmDataParameterCondition> = {},
|
|
103
|
+
): EvmDataParameterCondition => ({
|
|
104
|
+
...{
|
|
105
|
+
name: faker.string.alpha(20),
|
|
106
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
107
|
+
value: faker.string.alpha(20),
|
|
108
|
+
},
|
|
109
|
+
...overrideResponse,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const getListPoliciesResponseEvmDataParameterConditionListMock = (
|
|
113
|
+
overrideResponse: Partial<EvmDataParameterConditionList> = {},
|
|
114
|
+
): EvmDataParameterConditionList => ({
|
|
115
|
+
...{
|
|
116
|
+
name: faker.string.alpha(20),
|
|
117
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
118
|
+
values: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
119
|
+
faker.string.alpha(20),
|
|
120
|
+
),
|
|
121
|
+
},
|
|
122
|
+
...overrideResponse,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const getListPoliciesResponseEvmDataCriterionMock = (
|
|
126
|
+
overrideResponse: Partial<EvmDataCriterion> = {},
|
|
127
|
+
): EvmDataCriterion => ({
|
|
128
|
+
...{
|
|
129
|
+
type: faker.helpers.arrayElement(["evmData"] as const),
|
|
130
|
+
abi: faker.helpers.arrayElement([
|
|
131
|
+
faker.helpers.arrayElement(Object.values(KnownAbiType)),
|
|
132
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
133
|
+
faker.helpers.arrayElement([
|
|
134
|
+
{ ...getListPoliciesResponseAbiFunctionMock() },
|
|
135
|
+
{ ...getListPoliciesResponseAbiInputMock() },
|
|
136
|
+
]),
|
|
137
|
+
),
|
|
138
|
+
]),
|
|
139
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
140
|
+
() => ({
|
|
141
|
+
function: faker.string.alpha(20),
|
|
142
|
+
params: faker.helpers.arrayElement([
|
|
143
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
144
|
+
faker.helpers.arrayElement([
|
|
145
|
+
{ ...getListPoliciesResponseEvmDataParameterConditionMock() },
|
|
146
|
+
{ ...getListPoliciesResponseEvmDataParameterConditionListMock() },
|
|
147
|
+
]),
|
|
148
|
+
),
|
|
149
|
+
undefined,
|
|
150
|
+
]),
|
|
151
|
+
}),
|
|
152
|
+
),
|
|
153
|
+
},
|
|
154
|
+
...overrideResponse,
|
|
155
|
+
});
|
|
156
|
+
|
|
46
157
|
export const getListPoliciesResponseEvmNetworkCriterionMock = (
|
|
47
158
|
overrideResponse: Partial<EvmNetworkCriterion> = {},
|
|
48
159
|
): EvmNetworkCriterion => ({
|
|
@@ -99,6 +210,7 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
|
99
210
|
faker.helpers.arrayElement([
|
|
100
211
|
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
101
212
|
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
213
|
+
{ ...getListPoliciesResponseEvmDataCriterionMock() },
|
|
102
214
|
]),
|
|
103
215
|
),
|
|
104
216
|
},
|
|
@@ -113,6 +225,7 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
|
113
225
|
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
114
226
|
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
115
227
|
{ ...getListPoliciesResponseEvmNetworkCriterionMock() },
|
|
228
|
+
{ ...getListPoliciesResponseEvmDataCriterionMock() },
|
|
116
229
|
]),
|
|
117
230
|
),
|
|
118
231
|
},
|
|
@@ -178,6 +291,111 @@ export const getCreatePolicyResponseEvmAddressCriterionMock = (
|
|
|
178
291
|
...overrideResponse,
|
|
179
292
|
});
|
|
180
293
|
|
|
294
|
+
export const getCreatePolicyResponseAbiFunctionMock = (
|
|
295
|
+
overrideResponse: Partial<AbiFunction> = {},
|
|
296
|
+
): AbiFunction => ({
|
|
297
|
+
...{
|
|
298
|
+
type: faker.helpers.arrayElement(["function"] as const),
|
|
299
|
+
name: faker.string.alpha(20),
|
|
300
|
+
inputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
301
|
+
() => ({
|
|
302
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
303
|
+
type: faker.string.alpha(20),
|
|
304
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
305
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
306
|
+
}),
|
|
307
|
+
),
|
|
308
|
+
outputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
309
|
+
() => ({
|
|
310
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
311
|
+
type: faker.string.alpha(20),
|
|
312
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
313
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
314
|
+
}),
|
|
315
|
+
),
|
|
316
|
+
constant: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
317
|
+
payable: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
318
|
+
stateMutability: faker.helpers.arrayElement(Object.values(AbiStateMutability)),
|
|
319
|
+
gas: faker.helpers.arrayElement([
|
|
320
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
321
|
+
undefined,
|
|
322
|
+
]),
|
|
323
|
+
},
|
|
324
|
+
...overrideResponse,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export const getCreatePolicyResponseAbiInputMock = (
|
|
328
|
+
overrideResponse: Partial<AbiInput> = {},
|
|
329
|
+
): AbiInput => ({
|
|
330
|
+
...{
|
|
331
|
+
type: faker.helpers.arrayElement([
|
|
332
|
+
"constructor",
|
|
333
|
+
"error",
|
|
334
|
+
"event",
|
|
335
|
+
"fallback",
|
|
336
|
+
"receive",
|
|
337
|
+
] as const),
|
|
338
|
+
additionalProperties: faker.helpers.arrayElement([{}, undefined]),
|
|
339
|
+
},
|
|
340
|
+
...overrideResponse,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
export const getCreatePolicyResponseEvmDataParameterConditionMock = (
|
|
344
|
+
overrideResponse: Partial<EvmDataParameterCondition> = {},
|
|
345
|
+
): EvmDataParameterCondition => ({
|
|
346
|
+
...{
|
|
347
|
+
name: faker.string.alpha(20),
|
|
348
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
349
|
+
value: faker.string.alpha(20),
|
|
350
|
+
},
|
|
351
|
+
...overrideResponse,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
export const getCreatePolicyResponseEvmDataParameterConditionListMock = (
|
|
355
|
+
overrideResponse: Partial<EvmDataParameterConditionList> = {},
|
|
356
|
+
): EvmDataParameterConditionList => ({
|
|
357
|
+
...{
|
|
358
|
+
name: faker.string.alpha(20),
|
|
359
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
360
|
+
values: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
361
|
+
faker.string.alpha(20),
|
|
362
|
+
),
|
|
363
|
+
},
|
|
364
|
+
...overrideResponse,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
export const getCreatePolicyResponseEvmDataCriterionMock = (
|
|
368
|
+
overrideResponse: Partial<EvmDataCriterion> = {},
|
|
369
|
+
): EvmDataCriterion => ({
|
|
370
|
+
...{
|
|
371
|
+
type: faker.helpers.arrayElement(["evmData"] as const),
|
|
372
|
+
abi: faker.helpers.arrayElement([
|
|
373
|
+
faker.helpers.arrayElement(Object.values(KnownAbiType)),
|
|
374
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
375
|
+
faker.helpers.arrayElement([
|
|
376
|
+
{ ...getCreatePolicyResponseAbiFunctionMock() },
|
|
377
|
+
{ ...getCreatePolicyResponseAbiInputMock() },
|
|
378
|
+
]),
|
|
379
|
+
),
|
|
380
|
+
]),
|
|
381
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
382
|
+
() => ({
|
|
383
|
+
function: faker.string.alpha(20),
|
|
384
|
+
params: faker.helpers.arrayElement([
|
|
385
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
386
|
+
faker.helpers.arrayElement([
|
|
387
|
+
{ ...getCreatePolicyResponseEvmDataParameterConditionMock() },
|
|
388
|
+
{ ...getCreatePolicyResponseEvmDataParameterConditionListMock() },
|
|
389
|
+
]),
|
|
390
|
+
),
|
|
391
|
+
undefined,
|
|
392
|
+
]),
|
|
393
|
+
}),
|
|
394
|
+
),
|
|
395
|
+
},
|
|
396
|
+
...overrideResponse,
|
|
397
|
+
});
|
|
398
|
+
|
|
181
399
|
export const getCreatePolicyResponseEvmNetworkCriterionMock = (
|
|
182
400
|
overrideResponse: Partial<EvmNetworkCriterion> = {},
|
|
183
401
|
): EvmNetworkCriterion => ({
|
|
@@ -230,6 +448,7 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
230
448
|
faker.helpers.arrayElement([
|
|
231
449
|
{ ...getCreatePolicyResponseEthValueCriterionMock() },
|
|
232
450
|
{ ...getCreatePolicyResponseEvmAddressCriterionMock() },
|
|
451
|
+
{ ...getCreatePolicyResponseEvmDataCriterionMock() },
|
|
233
452
|
]),
|
|
234
453
|
),
|
|
235
454
|
},
|
|
@@ -244,6 +463,7 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
244
463
|
{ ...getCreatePolicyResponseEthValueCriterionMock() },
|
|
245
464
|
{ ...getCreatePolicyResponseEvmAddressCriterionMock() },
|
|
246
465
|
{ ...getCreatePolicyResponseEvmNetworkCriterionMock() },
|
|
466
|
+
{ ...getCreatePolicyResponseEvmDataCriterionMock() },
|
|
247
467
|
]),
|
|
248
468
|
),
|
|
249
469
|
},
|
|
@@ -302,6 +522,111 @@ export const getGetPolicyByIdResponseEvmAddressCriterionMock = (
|
|
|
302
522
|
...overrideResponse,
|
|
303
523
|
});
|
|
304
524
|
|
|
525
|
+
export const getGetPolicyByIdResponseAbiFunctionMock = (
|
|
526
|
+
overrideResponse: Partial<AbiFunction> = {},
|
|
527
|
+
): AbiFunction => ({
|
|
528
|
+
...{
|
|
529
|
+
type: faker.helpers.arrayElement(["function"] as const),
|
|
530
|
+
name: faker.string.alpha(20),
|
|
531
|
+
inputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
532
|
+
() => ({
|
|
533
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
534
|
+
type: faker.string.alpha(20),
|
|
535
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
536
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
537
|
+
}),
|
|
538
|
+
),
|
|
539
|
+
outputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
540
|
+
() => ({
|
|
541
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
542
|
+
type: faker.string.alpha(20),
|
|
543
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
544
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
545
|
+
}),
|
|
546
|
+
),
|
|
547
|
+
constant: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
548
|
+
payable: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
549
|
+
stateMutability: faker.helpers.arrayElement(Object.values(AbiStateMutability)),
|
|
550
|
+
gas: faker.helpers.arrayElement([
|
|
551
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
552
|
+
undefined,
|
|
553
|
+
]),
|
|
554
|
+
},
|
|
555
|
+
...overrideResponse,
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
export const getGetPolicyByIdResponseAbiInputMock = (
|
|
559
|
+
overrideResponse: Partial<AbiInput> = {},
|
|
560
|
+
): AbiInput => ({
|
|
561
|
+
...{
|
|
562
|
+
type: faker.helpers.arrayElement([
|
|
563
|
+
"constructor",
|
|
564
|
+
"error",
|
|
565
|
+
"event",
|
|
566
|
+
"fallback",
|
|
567
|
+
"receive",
|
|
568
|
+
] as const),
|
|
569
|
+
additionalProperties: faker.helpers.arrayElement([{}, undefined]),
|
|
570
|
+
},
|
|
571
|
+
...overrideResponse,
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
export const getGetPolicyByIdResponseEvmDataParameterConditionMock = (
|
|
575
|
+
overrideResponse: Partial<EvmDataParameterCondition> = {},
|
|
576
|
+
): EvmDataParameterCondition => ({
|
|
577
|
+
...{
|
|
578
|
+
name: faker.string.alpha(20),
|
|
579
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
580
|
+
value: faker.string.alpha(20),
|
|
581
|
+
},
|
|
582
|
+
...overrideResponse,
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
export const getGetPolicyByIdResponseEvmDataParameterConditionListMock = (
|
|
586
|
+
overrideResponse: Partial<EvmDataParameterConditionList> = {},
|
|
587
|
+
): EvmDataParameterConditionList => ({
|
|
588
|
+
...{
|
|
589
|
+
name: faker.string.alpha(20),
|
|
590
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
591
|
+
values: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
592
|
+
faker.string.alpha(20),
|
|
593
|
+
),
|
|
594
|
+
},
|
|
595
|
+
...overrideResponse,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
export const getGetPolicyByIdResponseEvmDataCriterionMock = (
|
|
599
|
+
overrideResponse: Partial<EvmDataCriterion> = {},
|
|
600
|
+
): EvmDataCriterion => ({
|
|
601
|
+
...{
|
|
602
|
+
type: faker.helpers.arrayElement(["evmData"] as const),
|
|
603
|
+
abi: faker.helpers.arrayElement([
|
|
604
|
+
faker.helpers.arrayElement(Object.values(KnownAbiType)),
|
|
605
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
606
|
+
faker.helpers.arrayElement([
|
|
607
|
+
{ ...getGetPolicyByIdResponseAbiFunctionMock() },
|
|
608
|
+
{ ...getGetPolicyByIdResponseAbiInputMock() },
|
|
609
|
+
]),
|
|
610
|
+
),
|
|
611
|
+
]),
|
|
612
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
613
|
+
() => ({
|
|
614
|
+
function: faker.string.alpha(20),
|
|
615
|
+
params: faker.helpers.arrayElement([
|
|
616
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
617
|
+
faker.helpers.arrayElement([
|
|
618
|
+
{ ...getGetPolicyByIdResponseEvmDataParameterConditionMock() },
|
|
619
|
+
{ ...getGetPolicyByIdResponseEvmDataParameterConditionListMock() },
|
|
620
|
+
]),
|
|
621
|
+
),
|
|
622
|
+
undefined,
|
|
623
|
+
]),
|
|
624
|
+
}),
|
|
625
|
+
),
|
|
626
|
+
},
|
|
627
|
+
...overrideResponse,
|
|
628
|
+
});
|
|
629
|
+
|
|
305
630
|
export const getGetPolicyByIdResponseEvmNetworkCriterionMock = (
|
|
306
631
|
overrideResponse: Partial<EvmNetworkCriterion> = {},
|
|
307
632
|
): EvmNetworkCriterion => ({
|
|
@@ -354,6 +679,7 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
354
679
|
faker.helpers.arrayElement([
|
|
355
680
|
{ ...getGetPolicyByIdResponseEthValueCriterionMock() },
|
|
356
681
|
{ ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
|
|
682
|
+
{ ...getGetPolicyByIdResponseEvmDataCriterionMock() },
|
|
357
683
|
]),
|
|
358
684
|
),
|
|
359
685
|
},
|
|
@@ -368,6 +694,7 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
368
694
|
{ ...getGetPolicyByIdResponseEthValueCriterionMock() },
|
|
369
695
|
{ ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
|
|
370
696
|
{ ...getGetPolicyByIdResponseEvmNetworkCriterionMock() },
|
|
697
|
+
{ ...getGetPolicyByIdResponseEvmDataCriterionMock() },
|
|
371
698
|
]),
|
|
372
699
|
),
|
|
373
700
|
},
|
|
@@ -426,6 +753,111 @@ export const getUpdatePolicyResponseEvmAddressCriterionMock = (
|
|
|
426
753
|
...overrideResponse,
|
|
427
754
|
});
|
|
428
755
|
|
|
756
|
+
export const getUpdatePolicyResponseAbiFunctionMock = (
|
|
757
|
+
overrideResponse: Partial<AbiFunction> = {},
|
|
758
|
+
): AbiFunction => ({
|
|
759
|
+
...{
|
|
760
|
+
type: faker.helpers.arrayElement(["function"] as const),
|
|
761
|
+
name: faker.string.alpha(20),
|
|
762
|
+
inputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
763
|
+
() => ({
|
|
764
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
765
|
+
type: faker.string.alpha(20),
|
|
766
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
767
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
768
|
+
}),
|
|
769
|
+
),
|
|
770
|
+
outputs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
771
|
+
() => ({
|
|
772
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
773
|
+
type: faker.string.alpha(20),
|
|
774
|
+
internalType: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
775
|
+
components: faker.helpers.arrayElement([[], undefined]),
|
|
776
|
+
}),
|
|
777
|
+
),
|
|
778
|
+
constant: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
779
|
+
payable: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
|
|
780
|
+
stateMutability: faker.helpers.arrayElement(Object.values(AbiStateMutability)),
|
|
781
|
+
gas: faker.helpers.arrayElement([
|
|
782
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
783
|
+
undefined,
|
|
784
|
+
]),
|
|
785
|
+
},
|
|
786
|
+
...overrideResponse,
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
export const getUpdatePolicyResponseAbiInputMock = (
|
|
790
|
+
overrideResponse: Partial<AbiInput> = {},
|
|
791
|
+
): AbiInput => ({
|
|
792
|
+
...{
|
|
793
|
+
type: faker.helpers.arrayElement([
|
|
794
|
+
"constructor",
|
|
795
|
+
"error",
|
|
796
|
+
"event",
|
|
797
|
+
"fallback",
|
|
798
|
+
"receive",
|
|
799
|
+
] as const),
|
|
800
|
+
additionalProperties: faker.helpers.arrayElement([{}, undefined]),
|
|
801
|
+
},
|
|
802
|
+
...overrideResponse,
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
export const getUpdatePolicyResponseEvmDataParameterConditionMock = (
|
|
806
|
+
overrideResponse: Partial<EvmDataParameterCondition> = {},
|
|
807
|
+
): EvmDataParameterCondition => ({
|
|
808
|
+
...{
|
|
809
|
+
name: faker.string.alpha(20),
|
|
810
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
811
|
+
value: faker.string.alpha(20),
|
|
812
|
+
},
|
|
813
|
+
...overrideResponse,
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
export const getUpdatePolicyResponseEvmDataParameterConditionListMock = (
|
|
817
|
+
overrideResponse: Partial<EvmDataParameterConditionList> = {},
|
|
818
|
+
): EvmDataParameterConditionList => ({
|
|
819
|
+
...{
|
|
820
|
+
name: faker.string.alpha(20),
|
|
821
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
822
|
+
values: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
823
|
+
faker.string.alpha(20),
|
|
824
|
+
),
|
|
825
|
+
},
|
|
826
|
+
...overrideResponse,
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
export const getUpdatePolicyResponseEvmDataCriterionMock = (
|
|
830
|
+
overrideResponse: Partial<EvmDataCriterion> = {},
|
|
831
|
+
): EvmDataCriterion => ({
|
|
832
|
+
...{
|
|
833
|
+
type: faker.helpers.arrayElement(["evmData"] as const),
|
|
834
|
+
abi: faker.helpers.arrayElement([
|
|
835
|
+
faker.helpers.arrayElement(Object.values(KnownAbiType)),
|
|
836
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
837
|
+
faker.helpers.arrayElement([
|
|
838
|
+
{ ...getUpdatePolicyResponseAbiFunctionMock() },
|
|
839
|
+
{ ...getUpdatePolicyResponseAbiInputMock() },
|
|
840
|
+
]),
|
|
841
|
+
),
|
|
842
|
+
]),
|
|
843
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
844
|
+
() => ({
|
|
845
|
+
function: faker.string.alpha(20),
|
|
846
|
+
params: faker.helpers.arrayElement([
|
|
847
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
848
|
+
faker.helpers.arrayElement([
|
|
849
|
+
{ ...getUpdatePolicyResponseEvmDataParameterConditionMock() },
|
|
850
|
+
{ ...getUpdatePolicyResponseEvmDataParameterConditionListMock() },
|
|
851
|
+
]),
|
|
852
|
+
),
|
|
853
|
+
undefined,
|
|
854
|
+
]),
|
|
855
|
+
}),
|
|
856
|
+
),
|
|
857
|
+
},
|
|
858
|
+
...overrideResponse,
|
|
859
|
+
});
|
|
860
|
+
|
|
429
861
|
export const getUpdatePolicyResponseEvmNetworkCriterionMock = (
|
|
430
862
|
overrideResponse: Partial<EvmNetworkCriterion> = {},
|
|
431
863
|
): EvmNetworkCriterion => ({
|
|
@@ -478,6 +910,7 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
478
910
|
faker.helpers.arrayElement([
|
|
479
911
|
{ ...getUpdatePolicyResponseEthValueCriterionMock() },
|
|
480
912
|
{ ...getUpdatePolicyResponseEvmAddressCriterionMock() },
|
|
913
|
+
{ ...getUpdatePolicyResponseEvmDataCriterionMock() },
|
|
481
914
|
]),
|
|
482
915
|
),
|
|
483
916
|
},
|
|
@@ -492,6 +925,7 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
492
925
|
{ ...getUpdatePolicyResponseEthValueCriterionMock() },
|
|
493
926
|
{ ...getUpdatePolicyResponseEvmAddressCriterionMock() },
|
|
494
927
|
{ ...getUpdatePolicyResponseEvmNetworkCriterionMock() },
|
|
928
|
+
{ ...getUpdatePolicyResponseEvmDataCriterionMock() },
|
|
495
929
|
]),
|
|
496
930
|
),
|
|
497
931
|
},
|