@coinbase/cdp-sdk 1.22.0 → 1.23.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 +10 -0
- package/_cjs/client/evm/evm.js +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +37 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +14 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +31 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +4 -4
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +246 -1
- 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 -10
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +34 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_cjs/policies/schema.js +143 -1
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/client/evm/evm.js +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +12 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +28 -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 +4 -4
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +224 -0
- 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 -8
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +31 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_esm/policies/schema.js +142 -0
- package/_esm/policies/schema.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/actions/evm/types.d.ts +2 -2
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +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/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +166 -3
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +2 -0
- 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 +4 -4
- 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.d.ts +7 -6
- 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 +4 -10
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +1606 -44
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/actions/evm/types.ts +2 -2
- package/client/evm/evm.ts +1 -1
- package/client/evm/evm.types.ts +1 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +213 -2
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +46 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
- package/openapi-client/generated/index.msw.ts +4 -4
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +349 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +51 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +22 -20
- package/package.json +1 -1
- package/policies/schema.ts +170 -0
- package/version.ts +1 -1
|
@@ -20,8 +20,13 @@ import type {
|
|
|
20
20
|
EvmDataParameterConditionList,
|
|
21
21
|
EvmMessageCriterion,
|
|
22
22
|
EvmNetworkCriterion,
|
|
23
|
+
EvmTypedAddressCondition,
|
|
24
|
+
EvmTypedNumericalCondition,
|
|
25
|
+
EvmTypedStringCondition,
|
|
23
26
|
ListPolicies200,
|
|
24
27
|
Policy,
|
|
28
|
+
SignEvmTypedDataFieldCriterion,
|
|
29
|
+
SignEvmTypedDataVerifyingContractCriterion,
|
|
25
30
|
SolAddressCriterion,
|
|
26
31
|
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
27
32
|
|
|
@@ -172,6 +177,79 @@ export const getListPoliciesResponseEvmMessageCriterionMock = (
|
|
|
172
177
|
...overrideResponse,
|
|
173
178
|
});
|
|
174
179
|
|
|
180
|
+
export const getListPoliciesResponseEvmTypedAddressConditionMock = (
|
|
181
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
182
|
+
): EvmTypedAddressCondition => ({
|
|
183
|
+
...{
|
|
184
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
185
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
186
|
+
),
|
|
187
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
188
|
+
path: faker.string.alpha(20),
|
|
189
|
+
},
|
|
190
|
+
...overrideResponse,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
export const getListPoliciesResponseEvmTypedNumericalConditionMock = (
|
|
194
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
195
|
+
): EvmTypedNumericalCondition => ({
|
|
196
|
+
...{
|
|
197
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
198
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
199
|
+
path: faker.string.alpha(20),
|
|
200
|
+
},
|
|
201
|
+
...overrideResponse,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export const getListPoliciesResponseEvmTypedStringConditionMock = (
|
|
205
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
206
|
+
): EvmTypedStringCondition => ({
|
|
207
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
208
|
+
...overrideResponse,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
export const getListPoliciesResponseSignEvmTypedDataFieldCriterionMock = (
|
|
212
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
213
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
214
|
+
...{
|
|
215
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
216
|
+
types: {
|
|
217
|
+
types: {
|
|
218
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
219
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
220
|
+
(_, i) => i + 1,
|
|
221
|
+
).map(() => ({
|
|
222
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
223
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
224
|
+
})),
|
|
225
|
+
},
|
|
226
|
+
primaryType: faker.string.alpha(20),
|
|
227
|
+
},
|
|
228
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
229
|
+
() =>
|
|
230
|
+
faker.helpers.arrayElement([
|
|
231
|
+
{ ...getListPoliciesResponseEvmTypedAddressConditionMock() },
|
|
232
|
+
{ ...getListPoliciesResponseEvmTypedNumericalConditionMock() },
|
|
233
|
+
{ ...getListPoliciesResponseEvmTypedStringConditionMock() },
|
|
234
|
+
]),
|
|
235
|
+
),
|
|
236
|
+
},
|
|
237
|
+
...overrideResponse,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
export const getListPoliciesResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
241
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
242
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
243
|
+
...{
|
|
244
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
245
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
246
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
247
|
+
),
|
|
248
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
249
|
+
},
|
|
250
|
+
...overrideResponse,
|
|
251
|
+
});
|
|
252
|
+
|
|
175
253
|
export const getListPoliciesResponseSolAddressCriterionMock = (
|
|
176
254
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
177
255
|
): SolAddressCriterion => ({
|
|
@@ -241,6 +319,19 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
|
241
319
|
]),
|
|
242
320
|
),
|
|
243
321
|
},
|
|
322
|
+
{
|
|
323
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
324
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] 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([
|
|
330
|
+
{ ...getListPoliciesResponseSignEvmTypedDataFieldCriterionMock() },
|
|
331
|
+
{ ...getListPoliciesResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
332
|
+
]),
|
|
333
|
+
),
|
|
334
|
+
},
|
|
244
335
|
{
|
|
245
336
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
246
337
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -414,6 +505,79 @@ export const getCreatePolicyResponseEvmMessageCriterionMock = (
|
|
|
414
505
|
...overrideResponse,
|
|
415
506
|
});
|
|
416
507
|
|
|
508
|
+
export const getCreatePolicyResponseEvmTypedAddressConditionMock = (
|
|
509
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
510
|
+
): EvmTypedAddressCondition => ({
|
|
511
|
+
...{
|
|
512
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
513
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
514
|
+
),
|
|
515
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
516
|
+
path: faker.string.alpha(20),
|
|
517
|
+
},
|
|
518
|
+
...overrideResponse,
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
export const getCreatePolicyResponseEvmTypedNumericalConditionMock = (
|
|
522
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
523
|
+
): EvmTypedNumericalCondition => ({
|
|
524
|
+
...{
|
|
525
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
526
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
527
|
+
path: faker.string.alpha(20),
|
|
528
|
+
},
|
|
529
|
+
...overrideResponse,
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
export const getCreatePolicyResponseEvmTypedStringConditionMock = (
|
|
533
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
534
|
+
): EvmTypedStringCondition => ({
|
|
535
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
536
|
+
...overrideResponse,
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
export const getCreatePolicyResponseSignEvmTypedDataFieldCriterionMock = (
|
|
540
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
541
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
542
|
+
...{
|
|
543
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
544
|
+
types: {
|
|
545
|
+
types: {
|
|
546
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
547
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
548
|
+
(_, i) => i + 1,
|
|
549
|
+
).map(() => ({
|
|
550
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
551
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
552
|
+
})),
|
|
553
|
+
},
|
|
554
|
+
primaryType: faker.string.alpha(20),
|
|
555
|
+
},
|
|
556
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
557
|
+
() =>
|
|
558
|
+
faker.helpers.arrayElement([
|
|
559
|
+
{ ...getCreatePolicyResponseEvmTypedAddressConditionMock() },
|
|
560
|
+
{ ...getCreatePolicyResponseEvmTypedNumericalConditionMock() },
|
|
561
|
+
{ ...getCreatePolicyResponseEvmTypedStringConditionMock() },
|
|
562
|
+
]),
|
|
563
|
+
),
|
|
564
|
+
},
|
|
565
|
+
...overrideResponse,
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
export const getCreatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
569
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
570
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
571
|
+
...{
|
|
572
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
573
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
574
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
575
|
+
),
|
|
576
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
577
|
+
},
|
|
578
|
+
...overrideResponse,
|
|
579
|
+
});
|
|
580
|
+
|
|
417
581
|
export const getCreatePolicyResponseSolAddressCriterionMock = (
|
|
418
582
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
419
583
|
): SolAddressCriterion => ({
|
|
@@ -477,6 +641,19 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
477
641
|
faker.helpers.arrayElement([{ ...getCreatePolicyResponseEvmMessageCriterionMock() }]),
|
|
478
642
|
),
|
|
479
643
|
},
|
|
644
|
+
{
|
|
645
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
646
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
647
|
+
criteria: Array.from(
|
|
648
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
649
|
+
(_, i) => i + 1,
|
|
650
|
+
).map(() =>
|
|
651
|
+
faker.helpers.arrayElement([
|
|
652
|
+
{ ...getCreatePolicyResponseSignEvmTypedDataFieldCriterionMock() },
|
|
653
|
+
{ ...getCreatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
654
|
+
]),
|
|
655
|
+
),
|
|
656
|
+
},
|
|
480
657
|
{
|
|
481
658
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
482
659
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -645,6 +822,79 @@ export const getGetPolicyByIdResponseEvmMessageCriterionMock = (
|
|
|
645
822
|
...overrideResponse,
|
|
646
823
|
});
|
|
647
824
|
|
|
825
|
+
export const getGetPolicyByIdResponseEvmTypedAddressConditionMock = (
|
|
826
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
827
|
+
): EvmTypedAddressCondition => ({
|
|
828
|
+
...{
|
|
829
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
830
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
831
|
+
),
|
|
832
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
833
|
+
path: faker.string.alpha(20),
|
|
834
|
+
},
|
|
835
|
+
...overrideResponse,
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
export const getGetPolicyByIdResponseEvmTypedNumericalConditionMock = (
|
|
839
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
840
|
+
): EvmTypedNumericalCondition => ({
|
|
841
|
+
...{
|
|
842
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
843
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
844
|
+
path: faker.string.alpha(20),
|
|
845
|
+
},
|
|
846
|
+
...overrideResponse,
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
export const getGetPolicyByIdResponseEvmTypedStringConditionMock = (
|
|
850
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
851
|
+
): EvmTypedStringCondition => ({
|
|
852
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
853
|
+
...overrideResponse,
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
export const getGetPolicyByIdResponseSignEvmTypedDataFieldCriterionMock = (
|
|
857
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
858
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
859
|
+
...{
|
|
860
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
861
|
+
types: {
|
|
862
|
+
types: {
|
|
863
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
864
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
865
|
+
(_, i) => i + 1,
|
|
866
|
+
).map(() => ({
|
|
867
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
868
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
869
|
+
})),
|
|
870
|
+
},
|
|
871
|
+
primaryType: faker.string.alpha(20),
|
|
872
|
+
},
|
|
873
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
874
|
+
() =>
|
|
875
|
+
faker.helpers.arrayElement([
|
|
876
|
+
{ ...getGetPolicyByIdResponseEvmTypedAddressConditionMock() },
|
|
877
|
+
{ ...getGetPolicyByIdResponseEvmTypedNumericalConditionMock() },
|
|
878
|
+
{ ...getGetPolicyByIdResponseEvmTypedStringConditionMock() },
|
|
879
|
+
]),
|
|
880
|
+
),
|
|
881
|
+
},
|
|
882
|
+
...overrideResponse,
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
export const getGetPolicyByIdResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
886
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
887
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
888
|
+
...{
|
|
889
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
890
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
891
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
892
|
+
),
|
|
893
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
894
|
+
},
|
|
895
|
+
...overrideResponse,
|
|
896
|
+
});
|
|
897
|
+
|
|
648
898
|
export const getGetPolicyByIdResponseSolAddressCriterionMock = (
|
|
649
899
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
650
900
|
): SolAddressCriterion => ({
|
|
@@ -708,6 +958,19 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
708
958
|
faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseEvmMessageCriterionMock() }]),
|
|
709
959
|
),
|
|
710
960
|
},
|
|
961
|
+
{
|
|
962
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
963
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
964
|
+
criteria: Array.from(
|
|
965
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
966
|
+
(_, i) => i + 1,
|
|
967
|
+
).map(() =>
|
|
968
|
+
faker.helpers.arrayElement([
|
|
969
|
+
{ ...getGetPolicyByIdResponseSignEvmTypedDataFieldCriterionMock() },
|
|
970
|
+
{ ...getGetPolicyByIdResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
971
|
+
]),
|
|
972
|
+
),
|
|
973
|
+
},
|
|
711
974
|
{
|
|
712
975
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
713
976
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -876,6 +1139,79 @@ export const getUpdatePolicyResponseEvmMessageCriterionMock = (
|
|
|
876
1139
|
...overrideResponse,
|
|
877
1140
|
});
|
|
878
1141
|
|
|
1142
|
+
export const getUpdatePolicyResponseEvmTypedAddressConditionMock = (
|
|
1143
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
1144
|
+
): EvmTypedAddressCondition => ({
|
|
1145
|
+
...{
|
|
1146
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1147
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
1148
|
+
),
|
|
1149
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1150
|
+
path: faker.string.alpha(20),
|
|
1151
|
+
},
|
|
1152
|
+
...overrideResponse,
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
export const getUpdatePolicyResponseEvmTypedNumericalConditionMock = (
|
|
1156
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
1157
|
+
): EvmTypedNumericalCondition => ({
|
|
1158
|
+
...{
|
|
1159
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
1160
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
1161
|
+
path: faker.string.alpha(20),
|
|
1162
|
+
},
|
|
1163
|
+
...overrideResponse,
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
export const getUpdatePolicyResponseEvmTypedStringConditionMock = (
|
|
1167
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
1168
|
+
): EvmTypedStringCondition => ({
|
|
1169
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
1170
|
+
...overrideResponse,
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
export const getUpdatePolicyResponseSignEvmTypedDataFieldCriterionMock = (
|
|
1174
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
1175
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
1176
|
+
...{
|
|
1177
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
1178
|
+
types: {
|
|
1179
|
+
types: {
|
|
1180
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
1181
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1182
|
+
(_, i) => i + 1,
|
|
1183
|
+
).map(() => ({
|
|
1184
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
1185
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
1186
|
+
})),
|
|
1187
|
+
},
|
|
1188
|
+
primaryType: faker.string.alpha(20),
|
|
1189
|
+
},
|
|
1190
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1191
|
+
() =>
|
|
1192
|
+
faker.helpers.arrayElement([
|
|
1193
|
+
{ ...getUpdatePolicyResponseEvmTypedAddressConditionMock() },
|
|
1194
|
+
{ ...getUpdatePolicyResponseEvmTypedNumericalConditionMock() },
|
|
1195
|
+
{ ...getUpdatePolicyResponseEvmTypedStringConditionMock() },
|
|
1196
|
+
]),
|
|
1197
|
+
),
|
|
1198
|
+
},
|
|
1199
|
+
...overrideResponse,
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
export const getUpdatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
1203
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
1204
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
1205
|
+
...{
|
|
1206
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
1207
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1208
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
1209
|
+
),
|
|
1210
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1211
|
+
},
|
|
1212
|
+
...overrideResponse,
|
|
1213
|
+
});
|
|
1214
|
+
|
|
879
1215
|
export const getUpdatePolicyResponseSolAddressCriterionMock = (
|
|
880
1216
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
881
1217
|
): SolAddressCriterion => ({
|
|
@@ -939,6 +1275,19 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
939
1275
|
faker.helpers.arrayElement([{ ...getUpdatePolicyResponseEvmMessageCriterionMock() }]),
|
|
940
1276
|
),
|
|
941
1277
|
},
|
|
1278
|
+
{
|
|
1279
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1280
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
1281
|
+
criteria: Array.from(
|
|
1282
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1283
|
+
(_, i) => i + 1,
|
|
1284
|
+
).map(() =>
|
|
1285
|
+
faker.helpers.arrayElement([
|
|
1286
|
+
{ ...getUpdatePolicyResponseSignEvmTypedDataFieldCriterionMock() },
|
|
1287
|
+
{ ...getUpdatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
1288
|
+
]),
|
|
1289
|
+
),
|
|
1290
|
+
},
|
|
942
1291
|
{
|
|
943
1292
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
944
1293
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -157,6 +157,33 @@ export const getGetSolanaAccountByNameResponseMock = (
|
|
|
157
157
|
...overrideResponse,
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
+
export const getImportSolanaAccountResponseMock = (
|
|
161
|
+
overrideResponse: Partial<SolanaAccount> = {},
|
|
162
|
+
): SolanaAccount => ({
|
|
163
|
+
address: faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
164
|
+
name: faker.helpers.arrayElement([
|
|
165
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
166
|
+
undefined,
|
|
167
|
+
]),
|
|
168
|
+
policies: faker.helpers.arrayElement([
|
|
169
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
170
|
+
faker.helpers.fromRegExp(
|
|
171
|
+
"^[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}$",
|
|
172
|
+
),
|
|
173
|
+
),
|
|
174
|
+
undefined,
|
|
175
|
+
]),
|
|
176
|
+
createdAt: faker.helpers.arrayElement([
|
|
177
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
178
|
+
undefined,
|
|
179
|
+
]),
|
|
180
|
+
updatedAt: faker.helpers.arrayElement([
|
|
181
|
+
`${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
182
|
+
undefined,
|
|
183
|
+
]),
|
|
184
|
+
...overrideResponse,
|
|
185
|
+
});
|
|
186
|
+
|
|
160
187
|
export const getExportSolanaAccountResponseMock = (
|
|
161
188
|
overrideResponse: Partial<ExportSolanaAccount200> = {},
|
|
162
189
|
): ExportSolanaAccount200 => ({ encryptedPrivateKey: faker.string.alpha(20), ...overrideResponse });
|
|
@@ -291,6 +318,29 @@ export const getGetSolanaAccountByNameMockHandler = (
|
|
|
291
318
|
});
|
|
292
319
|
};
|
|
293
320
|
|
|
321
|
+
export const getImportSolanaAccountMockHandler = (
|
|
322
|
+
overrideResponse?:
|
|
323
|
+
| SolanaAccount
|
|
324
|
+
| ((
|
|
325
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
326
|
+
) => Promise<SolanaAccount> | SolanaAccount),
|
|
327
|
+
) => {
|
|
328
|
+
return http.post("*/v2/solana/accounts/import", async info => {
|
|
329
|
+
await delay(0);
|
|
330
|
+
|
|
331
|
+
return new HttpResponse(
|
|
332
|
+
JSON.stringify(
|
|
333
|
+
overrideResponse !== undefined
|
|
334
|
+
? typeof overrideResponse === "function"
|
|
335
|
+
? await overrideResponse(info)
|
|
336
|
+
: overrideResponse
|
|
337
|
+
: getImportSolanaAccountResponseMock(),
|
|
338
|
+
),
|
|
339
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
|
|
294
344
|
export const getExportSolanaAccountMockHandler = (
|
|
295
345
|
overrideResponse?:
|
|
296
346
|
| ExportSolanaAccount200
|
|
@@ -388,6 +438,7 @@ export const getSolanaAccountsMock = () => [
|
|
|
388
438
|
getGetSolanaAccountMockHandler(),
|
|
389
439
|
getUpdateSolanaAccountMockHandler(),
|
|
390
440
|
getGetSolanaAccountByNameMockHandler(),
|
|
441
|
+
getImportSolanaAccountMockHandler(),
|
|
391
442
|
getExportSolanaAccountMockHandler(),
|
|
392
443
|
getExportSolanaAccountByNameMockHandler(),
|
|
393
444
|
getSignSolanaTransactionMockHandler(),
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
ExportSolanaAccountBody,
|
|
12
12
|
ExportSolanaAccountByName200,
|
|
13
13
|
ExportSolanaAccountByNameBody,
|
|
14
|
+
ImportSolanaAccountBody,
|
|
14
15
|
ListSolanaAccounts200,
|
|
15
16
|
ListSolanaAccountsParams,
|
|
16
17
|
SignSolanaMessage200,
|
|
@@ -104,6 +105,24 @@ export const getSolanaAccountByName = (
|
|
|
104
105
|
options,
|
|
105
106
|
);
|
|
106
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Import an existing Solana account into the developer's CDP Project. This API should be called from the [CDP SDK](https://github.com/coinbase/cdp-sdk) to ensure that the associated private key is properly encrypted.
|
|
110
|
+
* @summary Import a Solana account
|
|
111
|
+
*/
|
|
112
|
+
export const importSolanaAccount = (
|
|
113
|
+
importSolanaAccountBody: ImportSolanaAccountBody,
|
|
114
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
115
|
+
) => {
|
|
116
|
+
return cdpApiClient<SolanaAccount>(
|
|
117
|
+
{
|
|
118
|
+
url: `/v2/solana/accounts/import`,
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { "Content-Type": "application/json" },
|
|
121
|
+
data: importSolanaAccountBody,
|
|
122
|
+
},
|
|
123
|
+
options,
|
|
124
|
+
);
|
|
125
|
+
};
|
|
107
126
|
/**
|
|
108
127
|
* Export an existing Solana account's private key. It is important to store the private key in a secure place after it's exported.
|
|
109
128
|
* @summary Export an Solana account
|
|
@@ -191,26 +210,6 @@ export const signSolanaMessage = (
|
|
|
191
210
|
options,
|
|
192
211
|
);
|
|
193
212
|
};
|
|
194
|
-
|
|
195
|
-
export const importSolanaAccount = (
|
|
196
|
-
importSolanaAccountBody: {
|
|
197
|
-
name?: string;
|
|
198
|
-
encryptedPrivateKey: string;
|
|
199
|
-
idempotencyKey?: string;
|
|
200
|
-
},
|
|
201
|
-
options?: SecondParameter<typeof cdpApiClient>,
|
|
202
|
-
) => {
|
|
203
|
-
return cdpApiClient<SolanaAccount>(
|
|
204
|
-
{
|
|
205
|
-
url: `/v2/solana/accounts/import`,
|
|
206
|
-
method: "POST",
|
|
207
|
-
headers: { "Content-Type": "application/json" },
|
|
208
|
-
data: importSolanaAccountBody,
|
|
209
|
-
},
|
|
210
|
-
options,
|
|
211
|
-
);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
213
|
export type ListSolanaAccountsResult = NonNullable<Awaited<ReturnType<typeof listSolanaAccounts>>>;
|
|
215
214
|
export type CreateSolanaAccountResult = NonNullable<
|
|
216
215
|
Awaited<ReturnType<typeof createSolanaAccount>>
|
|
@@ -222,6 +221,9 @@ export type UpdateSolanaAccountResult = NonNullable<
|
|
|
222
221
|
export type GetSolanaAccountByNameResult = NonNullable<
|
|
223
222
|
Awaited<ReturnType<typeof getSolanaAccountByName>>
|
|
224
223
|
>;
|
|
224
|
+
export type ImportSolanaAccountResult = NonNullable<
|
|
225
|
+
Awaited<ReturnType<typeof importSolanaAccount>>
|
|
226
|
+
>;
|
|
225
227
|
export type ExportSolanaAccountResult = NonNullable<
|
|
226
228
|
Awaited<ReturnType<typeof exportSolanaAccount>>
|
|
227
229
|
>;
|