@coinbase/cdp-sdk 1.6.0 → 1.8.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 +23 -0
- package/README.md +284 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +7 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/types.js.map +1 -0
- package/_cjs/accounts/solana/toSolanaAccount.js +42 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_cjs/accounts/solana/types.js +3 -0
- package/_cjs/accounts/solana/types.js.map +1 -0
- package/_cjs/actions/evm/getUserOperation.js +36 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -0
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +7 -3
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/solana/requestFaucet.js +29 -0
- package/_cjs/actions/solana/requestFaucet.js.map +1 -0
- package/_cjs/actions/solana/signMessage.js +29 -0
- package/_cjs/actions/solana/signMessage.js.map +1 -0
- package/_cjs/actions/solana/signTransaction.js +46 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -0
- package/_cjs/actions/solana/types.js +3 -0
- package/_cjs/actions/solana/types.js.map +1 -0
- package/_cjs/analytics.js +68 -8
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/cdp.js +9 -3
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/evm/evm.js +135 -27
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/index.js +6 -0
- package/_cjs/client/policies/index.js.map +1 -0
- package/_cjs/client/policies/policies.js +232 -0
- package/_cjs/client/policies/policies.js.map +1 -0
- package/_cjs/client/policies/policies.types.js +3 -0
- package/_cjs/client/policies/policies.types.js.map +1 -0
- package/_cjs/client/solana/solana.js +84 -22
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +4 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +3 -2
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +7 -1
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/schema.js +186 -0
- package/_cjs/policies/schema.js.map +1 -0
- package/_cjs/policies/types.js +3 -0
- package/_cjs/{accounts → policies}/types.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +7 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/types.js.map +1 -0
- package/_esm/accounts/solana/toSolanaAccount.js +39 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_esm/accounts/solana/types.js +2 -0
- package/_esm/accounts/solana/types.js.map +1 -0
- package/_esm/actions/evm/getUserOperation.js +33 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -0
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +7 -3
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/solana/requestFaucet.js +26 -0
- package/_esm/actions/solana/requestFaucet.js.map +1 -0
- package/_esm/actions/solana/signMessage.js +26 -0
- package/_esm/actions/solana/signMessage.js.map +1 -0
- package/_esm/actions/solana/signTransaction.js +43 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -0
- package/_esm/actions/solana/types.js +2 -0
- package/_esm/actions/solana/types.js.map +1 -0
- package/_esm/analytics.js +68 -7
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/cdp.js +10 -4
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/evm/evm.js +135 -27
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/index.js +2 -0
- package/_esm/client/policies/index.js.map +1 -0
- package/_esm/client/policies/policies.js +228 -0
- package/_esm/client/policies/policies.js.map +1 -0
- package/_esm/client/policies/policies.types.js +2 -0
- package/_esm/client/policies/policies.types.js.map +1 -0
- package/_esm/client/solana/solana.js +84 -22
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +3 -2
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +6 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/schema.js +183 -0
- package/_esm/policies/schema.js.map +1 -0
- package/_esm/policies/types.js +2 -0
- package/_esm/{accounts → policies}/types.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/{types.d.ts → evm/types.d.ts} +10 -7
- package/_types/accounts/evm/types.d.ts.map +1 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
- package/_types/accounts/solana/types.d.ts +12 -0
- package/_types/accounts/solana/types.d.ts.map +1 -0
- package/_types/actions/evm/getUserOperation.d.ts +22 -0
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
- package/_types/actions/evm/sendUserOperation.d.ts +1 -1
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +3 -3
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +39 -6
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +28 -5
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/requestFaucet.d.ts +23 -0
- package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
- package/_types/actions/solana/signMessage.d.ts +23 -0
- package/_types/actions/solana/signMessage.d.ts.map +1 -0
- package/_types/actions/solana/signTransaction.d.ts +38 -0
- package/_types/actions/solana/signTransaction.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +80 -0
- package/_types/actions/solana/types.d.ts.map +1 -0
- package/_types/analytics.d.ts +14 -5
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +3 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +89 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +36 -6
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/index.d.ts +2 -0
- package/_types/client/policies/index.d.ts.map +1 -0
- package/_types/client/policies/policies.d.ts +216 -0
- package/_types/client/policies/policies.d.ts.map +1 -0
- package/_types/client/policies/policies.types.d.ts +96 -0
- package/_types/client/policies/policies.types.d.ts.map +1 -0
- package/_types/client/solana/solana.d.ts +47 -4
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +21 -12
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +299 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +3 -2
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +19 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +922 -0
- package/_types/policies/schema.d.ts.map +1 -0
- package/_types/policies/types.d.ts +19 -0
- package/_types/policies/types.d.ts.map +1 -0
- package/_types/types/misc.d.ts +39 -0
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +7 -4
- package/accounts/evm/toEvmSmartAccount.ts +11 -1
- package/accounts/{types.ts → evm/types.ts} +10 -12
- package/accounts/solana/toSolanaAccount.ts +60 -0
- package/accounts/solana/types.ts +13 -0
- package/actions/evm/getUserOperation.ts +40 -0
- package/actions/evm/sendUserOperation.ts +1 -1
- package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +10 -7
- package/actions/evm/transfer/transfer.ts +17 -6
- package/actions/evm/transfer/types.ts +54 -11
- package/actions/evm/types.ts +37 -5
- package/actions/solana/requestFaucet.ts +35 -0
- package/actions/solana/signMessage.ts +36 -0
- package/actions/solana/signTransaction.ts +53 -0
- package/actions/solana/types.ts +87 -0
- package/analytics.ts +84 -11
- package/client/cdp.ts +11 -4
- package/client/evm/evm.ts +162 -33
- package/client/evm/evm.types.ts +42 -4
- package/client/policies/index.ts +1 -0
- package/client/policies/policies.ts +246 -0
- package/client/policies/policies.types.ts +109 -0
- package/client/solana/solana.ts +107 -38
- package/client/solana/solana.types.ts +25 -15
- package/index.ts +8 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +360 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
- package/openapi-client/generated/index.msw.ts +3 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
- package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
- package/openapi-client/index.ts +7 -0
- package/package.json +3 -2
- package/policies/schema.ts +266 -0
- package/policies/types.ts +19 -0
- package/types/misc.ts +41 -0
- package/version.ts +1 -1
- package/_types/accounts/types.d.ts.map +0 -1
- /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
- /package/_esm/accounts/{types.js → evm/types.js} +0 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
EthValueCriterion,
|
|
14
|
+
EvmAddressCriterion,
|
|
15
|
+
ListPolicies200,
|
|
16
|
+
Policy,
|
|
17
|
+
SolAddressCriterion,
|
|
18
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
19
|
+
|
|
20
|
+
export const getListPoliciesResponseEthValueCriterionMock = (
|
|
21
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
22
|
+
): EthValueCriterion => ({
|
|
23
|
+
...{
|
|
24
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
25
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
26
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
27
|
+
},
|
|
28
|
+
...overrideResponse,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const getListPoliciesResponseEvmAddressCriterionMock = (
|
|
32
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
33
|
+
): EvmAddressCriterion => ({
|
|
34
|
+
...{
|
|
35
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
36
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
37
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
38
|
+
),
|
|
39
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
40
|
+
},
|
|
41
|
+
...overrideResponse,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const getListPoliciesResponseSolAddressCriterionMock = (
|
|
45
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
46
|
+
): SolAddressCriterion => ({
|
|
47
|
+
...{
|
|
48
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
49
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
50
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
51
|
+
),
|
|
52
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
53
|
+
},
|
|
54
|
+
...overrideResponse,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const getListPoliciesResponseMock = (): ListPolicies200 => ({
|
|
58
|
+
...{
|
|
59
|
+
policies: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
60
|
+
() => ({
|
|
61
|
+
id: faker.helpers.fromRegExp(
|
|
62
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
63
|
+
),
|
|
64
|
+
description: faker.helpers.arrayElement([
|
|
65
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
66
|
+
undefined,
|
|
67
|
+
]),
|
|
68
|
+
scope: faker.helpers.arrayElement(["project", "account"] as const),
|
|
69
|
+
rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
70
|
+
() => ({
|
|
71
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
72
|
+
operation: faker.helpers.arrayElement([
|
|
73
|
+
"signEvmTransaction",
|
|
74
|
+
"signSolTransaction",
|
|
75
|
+
] as const),
|
|
76
|
+
criteria: faker.helpers.arrayElement([
|
|
77
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
78
|
+
() =>
|
|
79
|
+
faker.helpers.arrayElement([
|
|
80
|
+
{ ...getListPoliciesResponseEthValueCriterionMock() },
|
|
81
|
+
{ ...getListPoliciesResponseEvmAddressCriterionMock() },
|
|
82
|
+
]),
|
|
83
|
+
),
|
|
84
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
85
|
+
() =>
|
|
86
|
+
faker.helpers.arrayElement([
|
|
87
|
+
{ ...getListPoliciesResponseSolAddressCriterionMock() },
|
|
88
|
+
]),
|
|
89
|
+
),
|
|
90
|
+
]),
|
|
91
|
+
}),
|
|
92
|
+
),
|
|
93
|
+
createdAt: faker.string.alpha(20),
|
|
94
|
+
updatedAt: faker.string.alpha(20),
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const getCreatePolicyResponseEthValueCriterionMock = (
|
|
102
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
103
|
+
): EthValueCriterion => ({
|
|
104
|
+
...{
|
|
105
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
106
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
107
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
108
|
+
},
|
|
109
|
+
...overrideResponse,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const getCreatePolicyResponseEvmAddressCriterionMock = (
|
|
113
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
114
|
+
): EvmAddressCriterion => ({
|
|
115
|
+
...{
|
|
116
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
117
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
118
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
119
|
+
),
|
|
120
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
121
|
+
},
|
|
122
|
+
...overrideResponse,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const getCreatePolicyResponseSolAddressCriterionMock = (
|
|
126
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
127
|
+
): SolAddressCriterion => ({
|
|
128
|
+
...{
|
|
129
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
130
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
131
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
132
|
+
),
|
|
133
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
134
|
+
},
|
|
135
|
+
...overrideResponse,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
139
|
+
id: faker.helpers.fromRegExp(
|
|
140
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
141
|
+
),
|
|
142
|
+
description: faker.helpers.arrayElement([
|
|
143
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
144
|
+
undefined,
|
|
145
|
+
]),
|
|
146
|
+
scope: faker.helpers.arrayElement(["project", "account"] as const),
|
|
147
|
+
rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
148
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
149
|
+
operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
|
|
150
|
+
criteria: faker.helpers.arrayElement([
|
|
151
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
152
|
+
faker.helpers.arrayElement([
|
|
153
|
+
{ ...getCreatePolicyResponseEthValueCriterionMock() },
|
|
154
|
+
{ ...getCreatePolicyResponseEvmAddressCriterionMock() },
|
|
155
|
+
]),
|
|
156
|
+
),
|
|
157
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
158
|
+
faker.helpers.arrayElement([{ ...getCreatePolicyResponseSolAddressCriterionMock() }]),
|
|
159
|
+
),
|
|
160
|
+
]),
|
|
161
|
+
})),
|
|
162
|
+
createdAt: faker.string.alpha(20),
|
|
163
|
+
updatedAt: faker.string.alpha(20),
|
|
164
|
+
...overrideResponse,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const getGetPolicyByIdResponseEthValueCriterionMock = (
|
|
168
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
169
|
+
): EthValueCriterion => ({
|
|
170
|
+
...{
|
|
171
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
172
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
173
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
174
|
+
},
|
|
175
|
+
...overrideResponse,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const getGetPolicyByIdResponseEvmAddressCriterionMock = (
|
|
179
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
180
|
+
): EvmAddressCriterion => ({
|
|
181
|
+
...{
|
|
182
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
183
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
184
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
185
|
+
),
|
|
186
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
187
|
+
},
|
|
188
|
+
...overrideResponse,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const getGetPolicyByIdResponseSolAddressCriterionMock = (
|
|
192
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
193
|
+
): SolAddressCriterion => ({
|
|
194
|
+
...{
|
|
195
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
196
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
197
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
198
|
+
),
|
|
199
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
200
|
+
},
|
|
201
|
+
...overrideResponse,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
205
|
+
id: faker.helpers.fromRegExp(
|
|
206
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
207
|
+
),
|
|
208
|
+
description: faker.helpers.arrayElement([
|
|
209
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
210
|
+
undefined,
|
|
211
|
+
]),
|
|
212
|
+
scope: faker.helpers.arrayElement(["project", "account"] as const),
|
|
213
|
+
rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
214
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
215
|
+
operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
|
|
216
|
+
criteria: faker.helpers.arrayElement([
|
|
217
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
218
|
+
faker.helpers.arrayElement([
|
|
219
|
+
{ ...getGetPolicyByIdResponseEthValueCriterionMock() },
|
|
220
|
+
{ ...getGetPolicyByIdResponseEvmAddressCriterionMock() },
|
|
221
|
+
]),
|
|
222
|
+
),
|
|
223
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
224
|
+
faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseSolAddressCriterionMock() }]),
|
|
225
|
+
),
|
|
226
|
+
]),
|
|
227
|
+
})),
|
|
228
|
+
createdAt: faker.string.alpha(20),
|
|
229
|
+
updatedAt: faker.string.alpha(20),
|
|
230
|
+
...overrideResponse,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export const getUpdatePolicyResponseEthValueCriterionMock = (
|
|
234
|
+
overrideResponse: Partial<EthValueCriterion> = {},
|
|
235
|
+
): EthValueCriterion => ({
|
|
236
|
+
...{
|
|
237
|
+
type: faker.helpers.arrayElement(["ethValue"] as const),
|
|
238
|
+
ethValue: faker.helpers.fromRegExp("^[0-9]+$"),
|
|
239
|
+
operator: faker.helpers.arrayElement([">", ">=", "<", "<=", "=="] as const),
|
|
240
|
+
},
|
|
241
|
+
...overrideResponse,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
export const getUpdatePolicyResponseEvmAddressCriterionMock = (
|
|
245
|
+
overrideResponse: Partial<EvmAddressCriterion> = {},
|
|
246
|
+
): EvmAddressCriterion => ({
|
|
247
|
+
...{
|
|
248
|
+
type: faker.helpers.arrayElement(["evmAddress"] as const),
|
|
249
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
250
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
251
|
+
),
|
|
252
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
253
|
+
},
|
|
254
|
+
...overrideResponse,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
export const getUpdatePolicyResponseSolAddressCriterionMock = (
|
|
258
|
+
overrideResponse: Partial<SolAddressCriterion> = {},
|
|
259
|
+
): SolAddressCriterion => ({
|
|
260
|
+
...{
|
|
261
|
+
type: faker.helpers.arrayElement(["solAddress"] as const),
|
|
262
|
+
addresses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
263
|
+
() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
264
|
+
),
|
|
265
|
+
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
266
|
+
},
|
|
267
|
+
...overrideResponse,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> = {}): Policy => ({
|
|
271
|
+
id: faker.helpers.fromRegExp(
|
|
272
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
273
|
+
),
|
|
274
|
+
description: faker.helpers.arrayElement([
|
|
275
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9 ,.]{1,50}$"),
|
|
276
|
+
undefined,
|
|
277
|
+
]),
|
|
278
|
+
scope: faker.helpers.arrayElement(["project", "account"] as const),
|
|
279
|
+
rules: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
280
|
+
action: faker.helpers.arrayElement(["reject", "accept"] as const),
|
|
281
|
+
operation: faker.helpers.arrayElement(["signEvmTransaction", "signSolTransaction"] as const),
|
|
282
|
+
criteria: faker.helpers.arrayElement([
|
|
283
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
284
|
+
faker.helpers.arrayElement([
|
|
285
|
+
{ ...getUpdatePolicyResponseEthValueCriterionMock() },
|
|
286
|
+
{ ...getUpdatePolicyResponseEvmAddressCriterionMock() },
|
|
287
|
+
]),
|
|
288
|
+
),
|
|
289
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
290
|
+
faker.helpers.arrayElement([{ ...getUpdatePolicyResponseSolAddressCriterionMock() }]),
|
|
291
|
+
),
|
|
292
|
+
]),
|
|
293
|
+
})),
|
|
294
|
+
createdAt: faker.string.alpha(20),
|
|
295
|
+
updatedAt: faker.string.alpha(20),
|
|
296
|
+
...overrideResponse,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
export const getListPoliciesMockHandler = (
|
|
300
|
+
overrideResponse?:
|
|
301
|
+
| ListPolicies200
|
|
302
|
+
| ((
|
|
303
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
304
|
+
) => Promise<ListPolicies200> | ListPolicies200),
|
|
305
|
+
) => {
|
|
306
|
+
return http.get("*/v2/policy-engine/policies", async info => {
|
|
307
|
+
await delay(0);
|
|
308
|
+
|
|
309
|
+
return new HttpResponse(
|
|
310
|
+
JSON.stringify(
|
|
311
|
+
overrideResponse !== undefined
|
|
312
|
+
? typeof overrideResponse === "function"
|
|
313
|
+
? await overrideResponse(info)
|
|
314
|
+
: overrideResponse
|
|
315
|
+
: getListPoliciesResponseMock(),
|
|
316
|
+
),
|
|
317
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const getCreatePolicyMockHandler = (
|
|
323
|
+
overrideResponse?:
|
|
324
|
+
| Policy
|
|
325
|
+
| ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<Policy> | Policy),
|
|
326
|
+
) => {
|
|
327
|
+
return http.post("*/v2/policy-engine/policies", async info => {
|
|
328
|
+
await delay(0);
|
|
329
|
+
|
|
330
|
+
return new HttpResponse(
|
|
331
|
+
JSON.stringify(
|
|
332
|
+
overrideResponse !== undefined
|
|
333
|
+
? typeof overrideResponse === "function"
|
|
334
|
+
? await overrideResponse(info)
|
|
335
|
+
: overrideResponse
|
|
336
|
+
: getCreatePolicyResponseMock(),
|
|
337
|
+
),
|
|
338
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const getGetPolicyByIdMockHandler = (
|
|
344
|
+
overrideResponse?:
|
|
345
|
+
| Policy
|
|
346
|
+
| ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<Policy> | Policy),
|
|
347
|
+
) => {
|
|
348
|
+
return http.get("*/v2/policy-engine/policies/:policyId", async info => {
|
|
349
|
+
await delay(0);
|
|
350
|
+
|
|
351
|
+
return new HttpResponse(
|
|
352
|
+
JSON.stringify(
|
|
353
|
+
overrideResponse !== undefined
|
|
354
|
+
? typeof overrideResponse === "function"
|
|
355
|
+
? await overrideResponse(info)
|
|
356
|
+
: overrideResponse
|
|
357
|
+
: getGetPolicyByIdResponseMock(),
|
|
358
|
+
),
|
|
359
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export const getDeletePolicyMockHandler = (
|
|
365
|
+
overrideResponse?:
|
|
366
|
+
| void
|
|
367
|
+
| ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
|
|
368
|
+
) => {
|
|
369
|
+
return http.delete("*/v2/policy-engine/policies/:policyId", async info => {
|
|
370
|
+
await delay(0);
|
|
371
|
+
if (typeof overrideResponse === "function") {
|
|
372
|
+
await overrideResponse(info);
|
|
373
|
+
}
|
|
374
|
+
return new HttpResponse(null, { status: 204 });
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export const getUpdatePolicyMockHandler = (
|
|
379
|
+
overrideResponse?:
|
|
380
|
+
| Policy
|
|
381
|
+
| ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<Policy> | Policy),
|
|
382
|
+
) => {
|
|
383
|
+
return http.put("*/v2/policy-engine/policies/:policyId", async info => {
|
|
384
|
+
await delay(0);
|
|
385
|
+
|
|
386
|
+
return new HttpResponse(
|
|
387
|
+
JSON.stringify(
|
|
388
|
+
overrideResponse !== undefined
|
|
389
|
+
? typeof overrideResponse === "function"
|
|
390
|
+
? await overrideResponse(info)
|
|
391
|
+
: overrideResponse
|
|
392
|
+
: getUpdatePolicyResponseMock(),
|
|
393
|
+
),
|
|
394
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
395
|
+
);
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
export const getPolicyEngineMock = () => [
|
|
399
|
+
getListPoliciesMockHandler(),
|
|
400
|
+
getCreatePolicyMockHandler(),
|
|
401
|
+
getGetPolicyByIdMockHandler(),
|
|
402
|
+
getDeletePolicyMockHandler(),
|
|
403
|
+
getUpdatePolicyMockHandler(),
|
|
404
|
+
];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
CreatePolicyBody,
|
|
10
|
+
ListPolicies200,
|
|
11
|
+
ListPoliciesParams,
|
|
12
|
+
Policy,
|
|
13
|
+
UpdatePolicyBody,
|
|
14
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
15
|
+
|
|
16
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
17
|
+
|
|
18
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Lists the policies belonging to the developer's CDP Project. Use the `scope` parameter to filter the policies by scope.
|
|
22
|
+
The response is paginated, and by default, returns 20 policies per page.
|
|
23
|
+
* @summary List policies
|
|
24
|
+
*/
|
|
25
|
+
export const listPolicies = (
|
|
26
|
+
params?: ListPoliciesParams,
|
|
27
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
28
|
+
) => {
|
|
29
|
+
return cdpApiClient<ListPolicies200>(
|
|
30
|
+
{ url: `/v2/policy-engine/policies`, method: "GET", params },
|
|
31
|
+
options,
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Create a policy that can be used to govern the behavior of accounts.
|
|
36
|
+
* @summary Create a policy
|
|
37
|
+
*/
|
|
38
|
+
export const createPolicy = (
|
|
39
|
+
createPolicyBody: CreatePolicyBody,
|
|
40
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
41
|
+
) => {
|
|
42
|
+
return cdpApiClient<Policy>(
|
|
43
|
+
{
|
|
44
|
+
url: `/v2/policy-engine/policies`,
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: { "Content-Type": "application/json" },
|
|
47
|
+
data: createPolicyBody,
|
|
48
|
+
},
|
|
49
|
+
options,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Get a policy by its ID.
|
|
54
|
+
* @summary Get a policy by ID
|
|
55
|
+
*/
|
|
56
|
+
export const getPolicyById = (policyId: string, options?: SecondParameter<typeof cdpApiClient>) => {
|
|
57
|
+
return cdpApiClient<Policy>(
|
|
58
|
+
{ url: `/v2/policy-engine/policies/${policyId}`, method: "GET" },
|
|
59
|
+
options,
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Delete a policy by its ID. This will have the effect of removing the policy from all accounts that are currently using it.
|
|
64
|
+
* @summary Delete a policy
|
|
65
|
+
*/
|
|
66
|
+
export const deletePolicy = (policyId: string, options?: SecondParameter<typeof cdpApiClient>) => {
|
|
67
|
+
return cdpApiClient<void>(
|
|
68
|
+
{ url: `/v2/policy-engine/policies/${policyId}`, method: "DELETE" },
|
|
69
|
+
options,
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Updates a policy by its ID. This will have the effect of applying the updated policy to all accounts that are currently using it.
|
|
74
|
+
* @summary Update a policy
|
|
75
|
+
*/
|
|
76
|
+
export const updatePolicy = (
|
|
77
|
+
policyId: string,
|
|
78
|
+
updatePolicyBody: UpdatePolicyBody,
|
|
79
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
80
|
+
) => {
|
|
81
|
+
return cdpApiClient<Policy>(
|
|
82
|
+
{
|
|
83
|
+
url: `/v2/policy-engine/policies/${policyId}`,
|
|
84
|
+
method: "PUT",
|
|
85
|
+
headers: { "Content-Type": "application/json" },
|
|
86
|
+
data: updatePolicyBody,
|
|
87
|
+
},
|
|
88
|
+
options,
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
export type ListPoliciesResult = NonNullable<Awaited<ReturnType<typeof listPolicies>>>;
|
|
92
|
+
export type CreatePolicyResult = NonNullable<Awaited<ReturnType<typeof createPolicy>>>;
|
|
93
|
+
export type GetPolicyByIdResult = NonNullable<Awaited<ReturnType<typeof getPolicyById>>>;
|
|
94
|
+
export type DeletePolicyResult = NonNullable<Awaited<ReturnType<typeof deletePolicy>>>;
|
|
95
|
+
export type UpdatePolicyResult = NonNullable<Awaited<ReturnType<typeof updatePolicy>>>;
|
|
@@ -25,6 +25,14 @@ export const getListSolanaAccountsResponseMock = (): ListSolanaAccounts200 => ({
|
|
|
25
25
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
26
26
|
undefined,
|
|
27
27
|
]),
|
|
28
|
+
policies: faker.helpers.arrayElement([
|
|
29
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
30
|
+
faker.helpers.fromRegExp(
|
|
31
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
undefined,
|
|
35
|
+
]),
|
|
28
36
|
}),
|
|
29
37
|
),
|
|
30
38
|
},
|
|
@@ -39,6 +47,14 @@ export const getCreateSolanaAccountResponseMock = (
|
|
|
39
47
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
40
48
|
undefined,
|
|
41
49
|
]),
|
|
50
|
+
policies: faker.helpers.arrayElement([
|
|
51
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
52
|
+
faker.helpers.fromRegExp(
|
|
53
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
undefined,
|
|
57
|
+
]),
|
|
42
58
|
...overrideResponse,
|
|
43
59
|
});
|
|
44
60
|
|
|
@@ -50,6 +66,33 @@ export const getGetSolanaAccountResponseMock = (
|
|
|
50
66
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
51
67
|
undefined,
|
|
52
68
|
]),
|
|
69
|
+
policies: faker.helpers.arrayElement([
|
|
70
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
71
|
+
faker.helpers.fromRegExp(
|
|
72
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
undefined,
|
|
76
|
+
]),
|
|
77
|
+
...overrideResponse,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const getUpdateSolanaAccountResponseMock = (
|
|
81
|
+
overrideResponse: Partial<SolanaAccount> = {},
|
|
82
|
+
): SolanaAccount => ({
|
|
83
|
+
address: faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$"),
|
|
84
|
+
name: faker.helpers.arrayElement([
|
|
85
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
86
|
+
undefined,
|
|
87
|
+
]),
|
|
88
|
+
policies: faker.helpers.arrayElement([
|
|
89
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
90
|
+
faker.helpers.fromRegExp(
|
|
91
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
undefined,
|
|
95
|
+
]),
|
|
53
96
|
...overrideResponse,
|
|
54
97
|
});
|
|
55
98
|
|
|
@@ -61,6 +104,14 @@ export const getGetSolanaAccountByNameResponseMock = (
|
|
|
61
104
|
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
62
105
|
undefined,
|
|
63
106
|
]),
|
|
107
|
+
policies: faker.helpers.arrayElement([
|
|
108
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
109
|
+
faker.helpers.fromRegExp(
|
|
110
|
+
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
undefined,
|
|
114
|
+
]),
|
|
64
115
|
...overrideResponse,
|
|
65
116
|
});
|
|
66
117
|
|
|
@@ -141,6 +192,29 @@ export const getGetSolanaAccountMockHandler = (
|
|
|
141
192
|
});
|
|
142
193
|
};
|
|
143
194
|
|
|
195
|
+
export const getUpdateSolanaAccountMockHandler = (
|
|
196
|
+
overrideResponse?:
|
|
197
|
+
| SolanaAccount
|
|
198
|
+
| ((
|
|
199
|
+
info: Parameters<Parameters<typeof http.put>[1]>[0],
|
|
200
|
+
) => Promise<SolanaAccount> | SolanaAccount),
|
|
201
|
+
) => {
|
|
202
|
+
return http.put("*/v2/solana/accounts/:address", async info => {
|
|
203
|
+
await delay(0);
|
|
204
|
+
|
|
205
|
+
return new HttpResponse(
|
|
206
|
+
JSON.stringify(
|
|
207
|
+
overrideResponse !== undefined
|
|
208
|
+
? typeof overrideResponse === "function"
|
|
209
|
+
? await overrideResponse(info)
|
|
210
|
+
: overrideResponse
|
|
211
|
+
: getUpdateSolanaAccountResponseMock(),
|
|
212
|
+
),
|
|
213
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
144
218
|
export const getGetSolanaAccountByNameMockHandler = (
|
|
145
219
|
overrideResponse?:
|
|
146
220
|
| SolanaAccount
|
|
@@ -213,6 +287,7 @@ export const getSolanaAccountsMock = () => [
|
|
|
213
287
|
getListSolanaAccountsMockHandler(),
|
|
214
288
|
getCreateSolanaAccountMockHandler(),
|
|
215
289
|
getGetSolanaAccountMockHandler(),
|
|
290
|
+
getUpdateSolanaAccountMockHandler(),
|
|
216
291
|
getGetSolanaAccountByNameMockHandler(),
|
|
217
292
|
getSignSolanaTransactionMockHandler(),
|
|
218
293
|
getSignSolanaMessageMockHandler(),
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
SignSolanaTransaction200,
|
|
15
15
|
SignSolanaTransactionBody,
|
|
16
16
|
SolanaAccount,
|
|
17
|
+
UpdateSolanaAccountBody,
|
|
17
18
|
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
18
19
|
|
|
19
20
|
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
@@ -67,6 +68,25 @@ export const getSolanaAccount = (
|
|
|
67
68
|
options,
|
|
68
69
|
);
|
|
69
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Updates an existing Solana account. Use this to update the account's name or account-level policy.
|
|
73
|
+
* @summary Update a Solana account
|
|
74
|
+
*/
|
|
75
|
+
export const updateSolanaAccount = (
|
|
76
|
+
address: string,
|
|
77
|
+
updateSolanaAccountBody: UpdateSolanaAccountBody,
|
|
78
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
79
|
+
) => {
|
|
80
|
+
return cdpApiClient<SolanaAccount>(
|
|
81
|
+
{
|
|
82
|
+
url: `/v2/solana/accounts/${address}`,
|
|
83
|
+
method: "PUT",
|
|
84
|
+
headers: { "Content-Type": "application/json" },
|
|
85
|
+
data: updateSolanaAccountBody,
|
|
86
|
+
},
|
|
87
|
+
options,
|
|
88
|
+
);
|
|
89
|
+
};
|
|
70
90
|
/**
|
|
71
91
|
* Gets a Solana account by its name.
|
|
72
92
|
* @summary Get a Solana account by name
|
|
@@ -134,6 +154,9 @@ export type CreateSolanaAccountResult = NonNullable<
|
|
|
134
154
|
Awaited<ReturnType<typeof createSolanaAccount>>
|
|
135
155
|
>;
|
|
136
156
|
export type GetSolanaAccountResult = NonNullable<Awaited<ReturnType<typeof getSolanaAccount>>>;
|
|
157
|
+
export type UpdateSolanaAccountResult = NonNullable<
|
|
158
|
+
Awaited<ReturnType<typeof updateSolanaAccount>>
|
|
159
|
+
>;
|
|
137
160
|
export type GetSolanaAccountByNameResult = NonNullable<
|
|
138
161
|
Awaited<ReturnType<typeof getSolanaAccountByName>>
|
|
139
162
|
>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -4,12 +4,14 @@ export * from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
|
4
4
|
export * from "./generated/evm-token-balances/evm-token-balances.js";
|
|
5
5
|
export * from "./generated/solana-accounts/solana-accounts.js";
|
|
6
6
|
export * from "./generated/faucets/faucets.js";
|
|
7
|
+
export * from "./generated/policy-engine/policy-engine.js";
|
|
7
8
|
|
|
8
9
|
import { configure } from "./cdpApiClient.js";
|
|
9
10
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|
|
10
11
|
import * as evmSmartAccounts from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
11
12
|
import * as evmTokenBalances from "./generated/evm-token-balances/evm-token-balances.js";
|
|
12
13
|
import * as faucets from "./generated/faucets/faucets.js";
|
|
14
|
+
import * as policies from "./generated/policy-engine/policy-engine.js";
|
|
13
15
|
import * as solana from "./generated/solana-accounts/solana-accounts.js";
|
|
14
16
|
|
|
15
17
|
export const CdpOpenApiClient = {
|
|
@@ -18,6 +20,7 @@ export const CdpOpenApiClient = {
|
|
|
18
20
|
...evmTokenBalances,
|
|
19
21
|
...solana,
|
|
20
22
|
...faucets,
|
|
23
|
+
...policies,
|
|
21
24
|
configure,
|
|
22
25
|
};
|
|
23
26
|
|
|
@@ -33,4 +36,8 @@ export const OpenApiSolanaMethods = {
|
|
|
33
36
|
requestSolanaFaucet: faucets.requestSolanaFaucet,
|
|
34
37
|
};
|
|
35
38
|
|
|
39
|
+
export const OpenApiPoliciesMethods = {
|
|
40
|
+
...policies,
|
|
41
|
+
};
|
|
42
|
+
|
|
36
43
|
export type CdpOpenApiClientType = typeof CdpOpenApiClient;
|