@coinbase/cdp-sdk 1.22.0 → 1.24.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 +22 -0
- package/README.md +2 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js +1 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/actions/evm/getUserOperation.js +2 -1
- package/_cjs/actions/evm/getUserOperation.js.map +1 -1
- package/_cjs/client/evm/evm.js +23 -1
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +55 -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 +51 -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 +5 -5
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +322 -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 +210 -1
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +1 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/actions/evm/getUserOperation.js +2 -1
- package/_esm/actions/evm/getUserOperation.js.map +1 -1
- package/_esm/client/evm/evm.js +23 -1
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +53 -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 +48 -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 +300 -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 +209 -0
- package/_esm/policies/schema.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +2 -0
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/actions/evm/getUserOperation.d.ts.map +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 +15 -2
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +19 -5
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +222 -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 +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.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 +7373 -1437
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmSmartAccount.ts +1 -0
- package/accounts/evm/types.ts +2 -0
- package/actions/evm/getUserOperation.ts +4 -1
- package/actions/evm/types.ts +2 -2
- package/client/evm/evm.ts +32 -1
- package/client/evm/evm.types.ts +21 -4
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +301 -3
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +86 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
- package/openapi-client/generated/index.msw.ts +5 -5
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +465 -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 +257 -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),
|
|
@@ -257,6 +348,35 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
|
257
348
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
258
349
|
operation: faker.helpers.arrayElement(["signEvmHash"] as const),
|
|
259
350
|
},
|
|
351
|
+
{
|
|
352
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
353
|
+
operation: faker.helpers.arrayElement(["prepareUserOperation"] as const),
|
|
354
|
+
criteria: Array.from(
|
|
355
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
356
|
+
(_, i) => i + 1,
|
|
357
|
+
).map(() =>
|
|
358
|
+
faker.helpers.arrayElement([
|
|
359
|
+
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
360
|
+
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
361
|
+
{ ...getListPoliciesResponseEvmNetworkCriterionMock() },
|
|
362
|
+
{ ...getListPoliciesResponseEvmDataCriterionMock() },
|
|
363
|
+
]),
|
|
364
|
+
),
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
368
|
+
operation: faker.helpers.arrayElement(["sendUserOperation"] as const),
|
|
369
|
+
criteria: Array.from(
|
|
370
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
371
|
+
(_, i) => i + 1,
|
|
372
|
+
).map(() =>
|
|
373
|
+
faker.helpers.arrayElement([
|
|
374
|
+
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
375
|
+
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
376
|
+
{ ...getListPoliciesResponseEvmDataCriterionMock() },
|
|
377
|
+
]),
|
|
378
|
+
),
|
|
379
|
+
},
|
|
260
380
|
]),
|
|
261
381
|
),
|
|
262
382
|
createdAt: faker.string.alpha(20),
|
|
@@ -414,6 +534,79 @@ export const getCreatePolicyResponseEvmMessageCriterionMock = (
|
|
|
414
534
|
...overrideResponse,
|
|
415
535
|
});
|
|
416
536
|
|
|
537
|
+
export const getCreatePolicyResponseEvmTypedAddressConditionMock = (
|
|
538
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
539
|
+
): EvmTypedAddressCondition => ({
|
|
540
|
+
...{
|
|
541
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
542
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
543
|
+
),
|
|
544
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
545
|
+
path: faker.string.alpha(20),
|
|
546
|
+
},
|
|
547
|
+
...overrideResponse,
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
export const getCreatePolicyResponseEvmTypedNumericalConditionMock = (
|
|
551
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
552
|
+
): EvmTypedNumericalCondition => ({
|
|
553
|
+
...{
|
|
554
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
555
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
556
|
+
path: faker.string.alpha(20),
|
|
557
|
+
},
|
|
558
|
+
...overrideResponse,
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
export const getCreatePolicyResponseEvmTypedStringConditionMock = (
|
|
562
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
563
|
+
): EvmTypedStringCondition => ({
|
|
564
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
565
|
+
...overrideResponse,
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
export const getCreatePolicyResponseSignEvmTypedDataFieldCriterionMock = (
|
|
569
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
570
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
571
|
+
...{
|
|
572
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
573
|
+
types: {
|
|
574
|
+
types: {
|
|
575
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
576
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
577
|
+
(_, i) => i + 1,
|
|
578
|
+
).map(() => ({
|
|
579
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
580
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
581
|
+
})),
|
|
582
|
+
},
|
|
583
|
+
primaryType: faker.string.alpha(20),
|
|
584
|
+
},
|
|
585
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
586
|
+
() =>
|
|
587
|
+
faker.helpers.arrayElement([
|
|
588
|
+
{ ...getCreatePolicyResponseEvmTypedAddressConditionMock() },
|
|
589
|
+
{ ...getCreatePolicyResponseEvmTypedNumericalConditionMock() },
|
|
590
|
+
{ ...getCreatePolicyResponseEvmTypedStringConditionMock() },
|
|
591
|
+
]),
|
|
592
|
+
),
|
|
593
|
+
},
|
|
594
|
+
...overrideResponse,
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
export const getCreatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
598
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
599
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
600
|
+
...{
|
|
601
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
602
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
603
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
604
|
+
),
|
|
605
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
606
|
+
},
|
|
607
|
+
...overrideResponse,
|
|
608
|
+
});
|
|
609
|
+
|
|
417
610
|
export const getCreatePolicyResponseSolAddressCriterionMock = (
|
|
418
611
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
419
612
|
): SolAddressCriterion => ({
|
|
@@ -477,6 +670,19 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
477
670
|
faker.helpers.arrayElement([{ ...getCreatePolicyResponseEvmMessageCriterionMock() }]),
|
|
478
671
|
),
|
|
479
672
|
},
|
|
673
|
+
{
|
|
674
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
675
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
676
|
+
criteria: Array.from(
|
|
677
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
678
|
+
(_, i) => i + 1,
|
|
679
|
+
).map(() =>
|
|
680
|
+
faker.helpers.arrayElement([
|
|
681
|
+
{ ...getCreatePolicyResponseSignEvmTypedDataFieldCriterionMock() },
|
|
682
|
+
{ ...getCreatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
683
|
+
]),
|
|
684
|
+
),
|
|
685
|
+
},
|
|
480
686
|
{
|
|
481
687
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
482
688
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -491,6 +697,35 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
491
697
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
492
698
|
operation: faker.helpers.arrayElement(["signEvmHash"] as const),
|
|
493
699
|
},
|
|
700
|
+
{
|
|
701
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
702
|
+
operation: faker.helpers.arrayElement(["prepareUserOperation"] as const),
|
|
703
|
+
criteria: Array.from(
|
|
704
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
705
|
+
(_, i) => i + 1,
|
|
706
|
+
).map(() =>
|
|
707
|
+
faker.helpers.arrayElement([
|
|
708
|
+
{ ...getCreatePolicyResponseEthValueCriterionMock() },
|
|
709
|
+
{ ...getCreatePolicyResponseEvmAddressCriterionMock() },
|
|
710
|
+
{ ...getCreatePolicyResponseEvmNetworkCriterionMock() },
|
|
711
|
+
{ ...getCreatePolicyResponseEvmDataCriterionMock() },
|
|
712
|
+
]),
|
|
713
|
+
),
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
717
|
+
operation: faker.helpers.arrayElement(["sendUserOperation"] as const),
|
|
718
|
+
criteria: Array.from(
|
|
719
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
720
|
+
(_, i) => i + 1,
|
|
721
|
+
).map(() =>
|
|
722
|
+
faker.helpers.arrayElement([
|
|
723
|
+
{ ...getCreatePolicyResponseEthValueCriterionMock() },
|
|
724
|
+
{ ...getCreatePolicyResponseEvmAddressCriterionMock() },
|
|
725
|
+
{ ...getCreatePolicyResponseEvmDataCriterionMock() },
|
|
726
|
+
]),
|
|
727
|
+
),
|
|
728
|
+
},
|
|
494
729
|
]),
|
|
495
730
|
),
|
|
496
731
|
createdAt: faker.string.alpha(20),
|
|
@@ -645,6 +880,79 @@ export const getGetPolicyByIdResponseEvmMessageCriterionMock = (
|
|
|
645
880
|
...overrideResponse,
|
|
646
881
|
});
|
|
647
882
|
|
|
883
|
+
export const getGetPolicyByIdResponseEvmTypedAddressConditionMock = (
|
|
884
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
885
|
+
): EvmTypedAddressCondition => ({
|
|
886
|
+
...{
|
|
887
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
888
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
889
|
+
),
|
|
890
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
891
|
+
path: faker.string.alpha(20),
|
|
892
|
+
},
|
|
893
|
+
...overrideResponse,
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
export const getGetPolicyByIdResponseEvmTypedNumericalConditionMock = (
|
|
897
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
898
|
+
): EvmTypedNumericalCondition => ({
|
|
899
|
+
...{
|
|
900
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
901
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
902
|
+
path: faker.string.alpha(20),
|
|
903
|
+
},
|
|
904
|
+
...overrideResponse,
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
export const getGetPolicyByIdResponseEvmTypedStringConditionMock = (
|
|
908
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
909
|
+
): EvmTypedStringCondition => ({
|
|
910
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
911
|
+
...overrideResponse,
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
export const getGetPolicyByIdResponseSignEvmTypedDataFieldCriterionMock = (
|
|
915
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
916
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
917
|
+
...{
|
|
918
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
919
|
+
types: {
|
|
920
|
+
types: {
|
|
921
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
922
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
923
|
+
(_, i) => i + 1,
|
|
924
|
+
).map(() => ({
|
|
925
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
926
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
927
|
+
})),
|
|
928
|
+
},
|
|
929
|
+
primaryType: faker.string.alpha(20),
|
|
930
|
+
},
|
|
931
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
932
|
+
() =>
|
|
933
|
+
faker.helpers.arrayElement([
|
|
934
|
+
{ ...getGetPolicyByIdResponseEvmTypedAddressConditionMock() },
|
|
935
|
+
{ ...getGetPolicyByIdResponseEvmTypedNumericalConditionMock() },
|
|
936
|
+
{ ...getGetPolicyByIdResponseEvmTypedStringConditionMock() },
|
|
937
|
+
]),
|
|
938
|
+
),
|
|
939
|
+
},
|
|
940
|
+
...overrideResponse,
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
export const getGetPolicyByIdResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
944
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
945
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
946
|
+
...{
|
|
947
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
948
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
949
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
950
|
+
),
|
|
951
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
952
|
+
},
|
|
953
|
+
...overrideResponse,
|
|
954
|
+
});
|
|
955
|
+
|
|
648
956
|
export const getGetPolicyByIdResponseSolAddressCriterionMock = (
|
|
649
957
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
650
958
|
): SolAddressCriterion => ({
|
|
@@ -708,6 +1016,19 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
708
1016
|
faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseEvmMessageCriterionMock() }]),
|
|
709
1017
|
),
|
|
710
1018
|
},
|
|
1019
|
+
{
|
|
1020
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1021
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
1022
|
+
criteria: Array.from(
|
|
1023
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1024
|
+
(_, i) => i + 1,
|
|
1025
|
+
).map(() =>
|
|
1026
|
+
faker.helpers.arrayElement([
|
|
1027
|
+
{ ...getGetPolicyByIdResponseSignEvmTypedDataFieldCriterionMock() },
|
|
1028
|
+
{ ...getGetPolicyByIdResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
1029
|
+
]),
|
|
1030
|
+
),
|
|
1031
|
+
},
|
|
711
1032
|
{
|
|
712
1033
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
713
1034
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -722,6 +1043,35 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
722
1043
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
723
1044
|
operation: faker.helpers.arrayElement(["signEvmHash"] as const),
|
|
724
1045
|
},
|
|
1046
|
+
{
|
|
1047
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1048
|
+
operation: faker.helpers.arrayElement(["prepareUserOperation"] as const),
|
|
1049
|
+
criteria: Array.from(
|
|
1050
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1051
|
+
(_, i) => i + 1,
|
|
1052
|
+
).map(() =>
|
|
1053
|
+
faker.helpers.arrayElement([
|
|
1054
|
+
{ ...getGetPolicyByIdResponseEthValueCriterionMock() },
|
|
1055
|
+
{ ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
|
|
1056
|
+
{ ...getGetPolicyByIdResponseEvmNetworkCriterionMock() },
|
|
1057
|
+
{ ...getGetPolicyByIdResponseEvmDataCriterionMock() },
|
|
1058
|
+
]),
|
|
1059
|
+
),
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1063
|
+
operation: faker.helpers.arrayElement(["sendUserOperation"] as const),
|
|
1064
|
+
criteria: Array.from(
|
|
1065
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1066
|
+
(_, i) => i + 1,
|
|
1067
|
+
).map(() =>
|
|
1068
|
+
faker.helpers.arrayElement([
|
|
1069
|
+
{ ...getGetPolicyByIdResponseEthValueCriterionMock() },
|
|
1070
|
+
{ ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
|
|
1071
|
+
{ ...getGetPolicyByIdResponseEvmDataCriterionMock() },
|
|
1072
|
+
]),
|
|
1073
|
+
),
|
|
1074
|
+
},
|
|
725
1075
|
]),
|
|
726
1076
|
),
|
|
727
1077
|
createdAt: faker.string.alpha(20),
|
|
@@ -876,6 +1226,79 @@ export const getUpdatePolicyResponseEvmMessageCriterionMock = (
|
|
|
876
1226
|
...overrideResponse,
|
|
877
1227
|
});
|
|
878
1228
|
|
|
1229
|
+
export const getUpdatePolicyResponseEvmTypedAddressConditionMock = (
|
|
1230
|
+
overrideResponse: Partial<EvmTypedAddressCondition> = {},
|
|
1231
|
+
): EvmTypedAddressCondition => ({
|
|
1232
|
+
...{
|
|
1233
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1234
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
1235
|
+
),
|
|
1236
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1237
|
+
path: faker.string.alpha(20),
|
|
1238
|
+
},
|
|
1239
|
+
...overrideResponse,
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
export const getUpdatePolicyResponseEvmTypedNumericalConditionMock = (
|
|
1243
|
+
overrideResponse: Partial<EvmTypedNumericalCondition> = {},
|
|
1244
|
+
): EvmTypedNumericalCondition => ({
|
|
1245
|
+
...{
|
|
1246
|
+
value: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
1247
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
1248
|
+
path: faker.string.alpha(20),
|
|
1249
|
+
},
|
|
1250
|
+
...overrideResponse,
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
export const getUpdatePolicyResponseEvmTypedStringConditionMock = (
|
|
1254
|
+
overrideResponse: Partial<EvmTypedStringCondition> = {},
|
|
1255
|
+
): EvmTypedStringCondition => ({
|
|
1256
|
+
...{ match: faker.string.alpha(20), path: faker.string.alpha(20) },
|
|
1257
|
+
...overrideResponse,
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
export const getUpdatePolicyResponseSignEvmTypedDataFieldCriterionMock = (
|
|
1261
|
+
overrideResponse: Partial<SignEvmTypedDataFieldCriterion> = {},
|
|
1262
|
+
): SignEvmTypedDataFieldCriterion => ({
|
|
1263
|
+
...{
|
|
1264
|
+
type: faker.helpers.arrayElement(["evmTypedDataField"] as const),
|
|
1265
|
+
types: {
|
|
1266
|
+
types: {
|
|
1267
|
+
[faker.string.alphanumeric(5)]: Array.from(
|
|
1268
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1269
|
+
(_, i) => i + 1,
|
|
1270
|
+
).map(() => ({
|
|
1271
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
1272
|
+
type: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
1273
|
+
})),
|
|
1274
|
+
},
|
|
1275
|
+
primaryType: faker.string.alpha(20),
|
|
1276
|
+
},
|
|
1277
|
+
conditions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1278
|
+
() =>
|
|
1279
|
+
faker.helpers.arrayElement([
|
|
1280
|
+
{ ...getUpdatePolicyResponseEvmTypedAddressConditionMock() },
|
|
1281
|
+
{ ...getUpdatePolicyResponseEvmTypedNumericalConditionMock() },
|
|
1282
|
+
{ ...getUpdatePolicyResponseEvmTypedStringConditionMock() },
|
|
1283
|
+
]),
|
|
1284
|
+
),
|
|
1285
|
+
},
|
|
1286
|
+
...overrideResponse,
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
export const getUpdatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock = (
|
|
1290
|
+
overrideResponse: Partial<SignEvmTypedDataVerifyingContractCriterion> = {},
|
|
1291
|
+
): SignEvmTypedDataVerifyingContractCriterion => ({
|
|
1292
|
+
...{
|
|
1293
|
+
type: faker.helpers.arrayElement(["evmTypedDataVerifyingContract"] as const),
|
|
1294
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
1295
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
1296
|
+
),
|
|
1297
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1298
|
+
},
|
|
1299
|
+
...overrideResponse,
|
|
1300
|
+
});
|
|
1301
|
+
|
|
879
1302
|
export const getUpdatePolicyResponseSolAddressCriterionMock = (
|
|
880
1303
|
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
881
1304
|
): SolAddressCriterion => ({
|
|
@@ -939,6 +1362,19 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
939
1362
|
faker.helpers.arrayElement([{ ...getUpdatePolicyResponseEvmMessageCriterionMock() }]),
|
|
940
1363
|
),
|
|
941
1364
|
},
|
|
1365
|
+
{
|
|
1366
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1367
|
+
operation: faker.helpers.arrayElement(["signEvmTypedData"] as const),
|
|
1368
|
+
criteria: Array.from(
|
|
1369
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1370
|
+
(_, i) => i + 1,
|
|
1371
|
+
).map(() =>
|
|
1372
|
+
faker.helpers.arrayElement([
|
|
1373
|
+
{ ...getUpdatePolicyResponseSignEvmTypedDataFieldCriterionMock() },
|
|
1374
|
+
{ ...getUpdatePolicyResponseSignEvmTypedDataVerifyingContractCriterionMock() },
|
|
1375
|
+
]),
|
|
1376
|
+
),
|
|
1377
|
+
},
|
|
942
1378
|
{
|
|
943
1379
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
944
1380
|
operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
|
|
@@ -953,6 +1389,35 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
|
|
|
953
1389
|
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
954
1390
|
operation: faker.helpers.arrayElement(["signEvmHash"] as const),
|
|
955
1391
|
},
|
|
1392
|
+
{
|
|
1393
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1394
|
+
operation: faker.helpers.arrayElement(["prepareUserOperation"] as const),
|
|
1395
|
+
criteria: Array.from(
|
|
1396
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1397
|
+
(_, i) => i + 1,
|
|
1398
|
+
).map(() =>
|
|
1399
|
+
faker.helpers.arrayElement([
|
|
1400
|
+
{ ...getUpdatePolicyResponseEthValueCriterionMock() },
|
|
1401
|
+
{ ...getUpdatePolicyResponseEvmAddressCriterionMock() },
|
|
1402
|
+
{ ...getUpdatePolicyResponseEvmNetworkCriterionMock() },
|
|
1403
|
+
{ ...getUpdatePolicyResponseEvmDataCriterionMock() },
|
|
1404
|
+
]),
|
|
1405
|
+
),
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
1409
|
+
operation: faker.helpers.arrayElement(["sendUserOperation"] as const),
|
|
1410
|
+
criteria: Array.from(
|
|
1411
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
1412
|
+
(_, i) => i + 1,
|
|
1413
|
+
).map(() =>
|
|
1414
|
+
faker.helpers.arrayElement([
|
|
1415
|
+
{ ...getUpdatePolicyResponseEthValueCriterionMock() },
|
|
1416
|
+
{ ...getUpdatePolicyResponseEvmAddressCriterionMock() },
|
|
1417
|
+
{ ...getUpdatePolicyResponseEvmDataCriterionMock() },
|
|
1418
|
+
]),
|
|
1419
|
+
),
|
|
1420
|
+
},
|
|
956
1421
|
]),
|
|
957
1422
|
),
|
|
958
1423
|
createdAt: faker.string.alpha(20),
|
|
@@ -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
|
>;
|