@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,109 @@
|
|
|
1
|
+
import { OpenApiPoliciesMethods } from "../../openapi-client/index.js";
|
|
2
|
+
import { CreatePolicyBody, PolicyScope, UpdatePolicyBody } from "../../policies/schema.js";
|
|
3
|
+
import { Policy } from "../../policies/types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The PoliciesClient type, where all OpenApiPoliciesMethods methods are wrapped.
|
|
7
|
+
*/
|
|
8
|
+
export type PoliciesClientInterface = Omit<
|
|
9
|
+
typeof OpenApiPoliciesMethods,
|
|
10
|
+
| "createPolicy" // mapped to createPolicy
|
|
11
|
+
| "listPolicies" // mapped to listPolicies
|
|
12
|
+
| "getPolicyById" // mapped to getPolicyById
|
|
13
|
+
| "deletePolicy" // mapped to deletePolicy
|
|
14
|
+
| "updatePolicy" // mapped to updatePolicy
|
|
15
|
+
> & {
|
|
16
|
+
listPolicies: (options: ListPoliciesOptions) => Promise<ListPoliciesResult>;
|
|
17
|
+
createPolicy: (options: CreatePolicyOptions) => Promise<Policy>;
|
|
18
|
+
getPolicyById: (options: GetPolicyByIdOptions) => Promise<Policy>;
|
|
19
|
+
deletePolicy: (options: DeletePolicyOptions) => Promise<void>;
|
|
20
|
+
updatePolicy: (options: UpdatePolicyOptions) => Promise<Policy>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export interface ListPoliciesOptions {
|
|
24
|
+
/** The page size to paginate through the accounts. */
|
|
25
|
+
pageSize?: number;
|
|
26
|
+
/** The page token to paginate through the accounts. */
|
|
27
|
+
pageToken?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The scope of the policies to return. If `project`, the response will include exactly one policy, which is the project-level policy. If `account`, the response will include all account-level policies for the developer's CDP Project.
|
|
30
|
+
*/
|
|
31
|
+
scope?: PolicyScope;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The result of listing policies.
|
|
36
|
+
*/
|
|
37
|
+
export interface ListPoliciesResult {
|
|
38
|
+
/** The list of policies matching the query parameters. */
|
|
39
|
+
policies: Policy[];
|
|
40
|
+
/**
|
|
41
|
+
* The next page token to paginate through the policies.
|
|
42
|
+
* If undefined, there are no more policies to paginate through.
|
|
43
|
+
*/
|
|
44
|
+
nextPageToken?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Options for creating a Policy.
|
|
49
|
+
*/
|
|
50
|
+
export interface CreatePolicyOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The idempotency key to ensure the request is processed exactly once.
|
|
53
|
+
* Used to safely retry requests without accidentally performing the same operation twice.
|
|
54
|
+
*/
|
|
55
|
+
idempotencyKey?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The policy definition to create.
|
|
58
|
+
* Contains the scope, description, and rules for the policy.
|
|
59
|
+
*/
|
|
60
|
+
policy: CreatePolicyBody;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Options for retrieving a Policy by ID.
|
|
65
|
+
*/
|
|
66
|
+
export interface GetPolicyByIdOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The unique identifier of the policy to retrieve.
|
|
69
|
+
* This is a UUID that's generated when the policy is created.
|
|
70
|
+
*/
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Options for deleting a Policy.
|
|
76
|
+
*/
|
|
77
|
+
export interface DeletePolicyOptions {
|
|
78
|
+
/**
|
|
79
|
+
* The unique identifier of the policy to delete.
|
|
80
|
+
* This is a UUID that's generated when the policy is created.
|
|
81
|
+
*/
|
|
82
|
+
id: string;
|
|
83
|
+
/**
|
|
84
|
+
* The idempotency key to ensure the request is processed exactly once.
|
|
85
|
+
* Used to safely retry requests without accidentally performing the same operation twice.
|
|
86
|
+
*/
|
|
87
|
+
idempotencyKey?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Options for updating a Policy.
|
|
92
|
+
*/
|
|
93
|
+
export interface UpdatePolicyOptions {
|
|
94
|
+
/**
|
|
95
|
+
* The unique identifier of the policy to update.
|
|
96
|
+
* This is a UUID that's generated when the policy is created.
|
|
97
|
+
*/
|
|
98
|
+
id: string;
|
|
99
|
+
/**
|
|
100
|
+
* The updated policy definition.
|
|
101
|
+
* Contains the description and rules for the policy.
|
|
102
|
+
*/
|
|
103
|
+
policy: UpdatePolicyBody;
|
|
104
|
+
/**
|
|
105
|
+
* The idempotency key to ensure the request is processed exactly once.
|
|
106
|
+
* Used to safely retry requests without accidentally performing the same operation twice.
|
|
107
|
+
*/
|
|
108
|
+
idempotencyKey?: string;
|
|
109
|
+
}
|
package/client/solana/solana.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SolanaClientInterface,
|
|
3
|
-
Account,
|
|
4
2
|
CreateAccountOptions,
|
|
5
3
|
GetAccountOptions,
|
|
4
|
+
GetOrCreateAccountOptions,
|
|
6
5
|
ListAccountsOptions,
|
|
7
|
-
RequestFaucetOptions,
|
|
8
6
|
ListAccountsResult,
|
|
7
|
+
RequestFaucetOptions,
|
|
9
8
|
SignatureResult,
|
|
10
9
|
SignMessageOptions,
|
|
11
10
|
SignTransactionOptions,
|
|
12
|
-
|
|
11
|
+
SolanaClientInterface,
|
|
12
|
+
UpdateSolanaAccountOptions,
|
|
13
13
|
} from "./solana.types.js";
|
|
14
|
+
import { toSolanaAccount } from "../../accounts/solana/toSolanaAccount.js";
|
|
15
|
+
import { SolanaAccount } from "../../accounts/solana/types.js";
|
|
16
|
+
import { requestFaucet } from "../../actions/solana/requestFaucet.js";
|
|
17
|
+
import { signMessage } from "../../actions/solana/signMessage.js";
|
|
18
|
+
import { signTransaction } from "../../actions/solana/signTransaction.js";
|
|
19
|
+
import { Analytics } from "../../analytics.js";
|
|
14
20
|
import { APIError } from "../../openapi-client/errors.js";
|
|
15
21
|
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
16
22
|
|
|
@@ -48,8 +54,19 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
48
54
|
* await cdp.solana.createAccount({ idempotencyKey });
|
|
49
55
|
* ```
|
|
50
56
|
*/
|
|
51
|
-
async createAccount(options: CreateAccountOptions = {}): Promise<
|
|
52
|
-
|
|
57
|
+
async createAccount(options: CreateAccountOptions = {}): Promise<SolanaAccount> {
|
|
58
|
+
const openApiAccount = await CdpOpenApiClient.createSolanaAccount(
|
|
59
|
+
options,
|
|
60
|
+
options.idempotencyKey,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const account = toSolanaAccount(CdpOpenApiClient, {
|
|
64
|
+
account: openApiAccount,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
68
|
+
|
|
69
|
+
return account;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
/**
|
|
@@ -77,16 +94,26 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
77
94
|
* });
|
|
78
95
|
* ```
|
|
79
96
|
*/
|
|
80
|
-
async getAccount(options: GetAccountOptions): Promise<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
async getAccount(options: GetAccountOptions): Promise<SolanaAccount> {
|
|
98
|
+
const openApiAccount = await (() => {
|
|
99
|
+
if (options.address) {
|
|
100
|
+
return CdpOpenApiClient.getSolanaAccount(options.address);
|
|
101
|
+
}
|
|
84
102
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
if (options.name) {
|
|
104
|
+
return CdpOpenApiClient.getSolanaAccountByName(options.name);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
throw new Error("Either address or name must be provided");
|
|
108
|
+
})();
|
|
109
|
+
|
|
110
|
+
const account = toSolanaAccount(CdpOpenApiClient, {
|
|
111
|
+
account: openApiAccount,
|
|
112
|
+
});
|
|
88
113
|
|
|
89
|
-
|
|
114
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
115
|
+
|
|
116
|
+
return account;
|
|
90
117
|
}
|
|
91
118
|
|
|
92
119
|
/**
|
|
@@ -104,7 +131,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
104
131
|
* });
|
|
105
132
|
* ```
|
|
106
133
|
*/
|
|
107
|
-
async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<
|
|
134
|
+
async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<SolanaAccount> {
|
|
108
135
|
try {
|
|
109
136
|
const account = await this.getAccount(options);
|
|
110
137
|
return account;
|
|
@@ -165,7 +192,15 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
165
192
|
});
|
|
166
193
|
|
|
167
194
|
return {
|
|
168
|
-
accounts: solAccounts.accounts
|
|
195
|
+
accounts: solAccounts.accounts.map(account => {
|
|
196
|
+
const solanaAccount = toSolanaAccount(CdpOpenApiClient, {
|
|
197
|
+
account,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
Analytics.wrapObjectMethodsWithErrorTracking(solanaAccount);
|
|
201
|
+
|
|
202
|
+
return solanaAccount;
|
|
203
|
+
}),
|
|
169
204
|
nextPageToken: solAccounts.nextPageToken,
|
|
170
205
|
};
|
|
171
206
|
}
|
|
@@ -189,14 +224,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
189
224
|
* ```
|
|
190
225
|
*/
|
|
191
226
|
async requestFaucet(options: RequestFaucetOptions): Promise<SignatureResult> {
|
|
192
|
-
|
|
193
|
-
{ address: options.address, token: options.token },
|
|
194
|
-
options.idempotencyKey,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
signature: signature.transactionSignature,
|
|
199
|
-
};
|
|
227
|
+
return requestFaucet(CdpOpenApiClient, options);
|
|
200
228
|
}
|
|
201
229
|
|
|
202
230
|
/**
|
|
@@ -222,13 +250,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
222
250
|
* ```
|
|
223
251
|
*/
|
|
224
252
|
async signMessage(options: SignMessageOptions): Promise<SignatureResult> {
|
|
225
|
-
return CdpOpenApiClient
|
|
226
|
-
options.address,
|
|
227
|
-
{
|
|
228
|
-
message: options.message,
|
|
229
|
-
},
|
|
230
|
-
options.idempotencyKey,
|
|
231
|
-
);
|
|
253
|
+
return signMessage(CdpOpenApiClient, options);
|
|
232
254
|
}
|
|
233
255
|
|
|
234
256
|
/**
|
|
@@ -265,16 +287,63 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
265
287
|
* ```
|
|
266
288
|
*/
|
|
267
289
|
async signTransaction(options: SignTransactionOptions): Promise<SignatureResult> {
|
|
268
|
-
|
|
290
|
+
return signTransaction(CdpOpenApiClient, options);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Updates a CDP Solana account.
|
|
295
|
+
*
|
|
296
|
+
* @param {UpdateSolanaAccountOptions} [options] - Optional parameters for creating the account.
|
|
297
|
+
* @param {string} options.address - The address of the account to update
|
|
298
|
+
* @param {UpdateSolanaAccountBody} options.update - An object containing account fields to update.
|
|
299
|
+
* @param {string} [options.update.name] - The new name for the account.
|
|
300
|
+
* @param {string} [options.update.accountPolicy] - The ID of a Policy to apply to the account.
|
|
301
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
302
|
+
*
|
|
303
|
+
* @returns A promise that resolves to the updated account.
|
|
304
|
+
*
|
|
305
|
+
* @example **With a name**
|
|
306
|
+
* ```ts
|
|
307
|
+
* const account = await cdp.sol.updateAccount({ address: "...", update: { name: "New Name" } });
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @example **With an account policy**
|
|
311
|
+
* ```ts
|
|
312
|
+
* const account = await cdp.sol.updateAccount({ address: "...", update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" } });
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @example **With an idempotency key**
|
|
316
|
+
* ```ts
|
|
317
|
+
* const idempotencyKey = uuidv4();
|
|
318
|
+
*
|
|
319
|
+
* // First call
|
|
320
|
+
* await cdp.sol.updateAccount({
|
|
321
|
+
* address: "0x...",
|
|
322
|
+
* update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" },
|
|
323
|
+
* idempotencyKey,
|
|
324
|
+
* });
|
|
325
|
+
*
|
|
326
|
+
* // Second call with the same idempotency key will not update
|
|
327
|
+
* await cdp.sol.updateAccount({
|
|
328
|
+
* address: '0x...',
|
|
329
|
+
* update: { name: "" },
|
|
330
|
+
* idempotencyKey,
|
|
331
|
+
* });
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
async updateAccount(options: UpdateSolanaAccountOptions): Promise<SolanaAccount> {
|
|
335
|
+
const openApiAccount = await CdpOpenApiClient.updateSolanaAccount(
|
|
269
336
|
options.address,
|
|
270
|
-
|
|
271
|
-
transaction: options.transaction,
|
|
272
|
-
},
|
|
337
|
+
options.update,
|
|
273
338
|
options.idempotencyKey,
|
|
274
339
|
);
|
|
275
340
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
};
|
|
341
|
+
const account = toSolanaAccount(CdpOpenApiClient, {
|
|
342
|
+
account: openApiAccount,
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
346
|
+
|
|
347
|
+
return account;
|
|
279
348
|
}
|
|
280
349
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../../openapi-client/index.js";
|
|
1
|
+
import { Account, SolanaAccount } from "../../accounts/solana/types.js";
|
|
2
|
+
import { OpenApiSolanaMethods, UpdateSolanaAccountBody } from "../../openapi-client/index.js";
|
|
3
|
+
|
|
5
4
|
/**
|
|
6
5
|
* The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
|
|
7
6
|
*/
|
|
@@ -10,23 +9,30 @@ export type SolanaClientInterface = Omit<
|
|
|
10
9
|
| "createSolanaAccount" // mapped to createAccount
|
|
11
10
|
| "getSolanaAccount" // mapped to getAccount
|
|
12
11
|
| "getSolanaAccountByName" // mapped to getAccount
|
|
12
|
+
| "updateSolanaAccount" // mapped to updateAccount
|
|
13
13
|
| "listSolanaAccounts" // mapped to listAccounts
|
|
14
14
|
| "requestSolanaFaucet" // mapped to requestFaucet
|
|
15
15
|
| "signSolanaMessage" // mapped to signMessage
|
|
16
16
|
| "signSolanaTransaction" // mapped to signTransaction
|
|
17
|
+
| "updateSolanaAccount" // mapped to updateAccount
|
|
17
18
|
> & {
|
|
18
19
|
createAccount: (options: CreateAccountOptions) => Promise<Account>;
|
|
19
20
|
getAccount: (options: GetAccountOptions) => Promise<Account>;
|
|
20
21
|
getOrCreateAccount: (options: GetOrCreateAccountOptions) => Promise<Account>;
|
|
22
|
+
updateAccount: (options: UpdateSolanaAccountOptions) => Promise<Account>;
|
|
21
23
|
listAccounts: (options: ListAccountsOptions) => Promise<ListAccountsResult>;
|
|
22
24
|
requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
|
|
23
25
|
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
24
26
|
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
25
27
|
};
|
|
28
|
+
|
|
26
29
|
/**
|
|
27
|
-
* A Solana
|
|
30
|
+
* A Solana signature result.
|
|
28
31
|
*/
|
|
29
|
-
export
|
|
32
|
+
export interface SignatureResult {
|
|
33
|
+
/** The signature. */
|
|
34
|
+
signature: string;
|
|
35
|
+
}
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Options for creating a Solana account.
|
|
@@ -56,6 +62,18 @@ export interface GetOrCreateAccountOptions {
|
|
|
56
62
|
name: string;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Options for creating a SOL server account.
|
|
67
|
+
*/
|
|
68
|
+
export interface UpdateSolanaAccountOptions {
|
|
69
|
+
/** The address of the account. */
|
|
70
|
+
address: string;
|
|
71
|
+
/** The updates to apply to the account */
|
|
72
|
+
update: UpdateSolanaAccountBody;
|
|
73
|
+
/** The idempotency key. */
|
|
74
|
+
idempotencyKey?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
/**
|
|
60
78
|
* Options for listing Solana accounts.
|
|
61
79
|
*/
|
|
@@ -71,7 +89,7 @@ export interface ListAccountsOptions {
|
|
|
71
89
|
*/
|
|
72
90
|
export interface ListAccountsResult {
|
|
73
91
|
/** The accounts. */
|
|
74
|
-
accounts:
|
|
92
|
+
accounts: SolanaAccount[];
|
|
75
93
|
/**
|
|
76
94
|
* The token for the next page of accounts, if any.
|
|
77
95
|
*/
|
|
@@ -113,11 +131,3 @@ export interface SignTransactionOptions {
|
|
|
113
131
|
/** The idempotency key. */
|
|
114
132
|
idempotencyKey?: string;
|
|
115
133
|
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A Solana signature result.
|
|
119
|
-
*/
|
|
120
|
-
export interface SignatureResult {
|
|
121
|
-
/** The signature. */
|
|
122
|
-
signature: string;
|
|
123
|
-
}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export { CdpClient } from "./client/cdp.js";
|
|
2
|
-
export type { EvmServerAccount, EvmSmartAccount } from "./accounts/types.js";
|
|
2
|
+
export type { EvmServerAccount, EvmSmartAccount } from "./accounts/evm/types.js";
|
|
3
|
+
export type { Policy } from "./policies/types.js";
|
|
4
|
+
export {
|
|
5
|
+
CreatePolicyBodySchema,
|
|
6
|
+
UpdatePolicyBodySchema,
|
|
7
|
+
type CreatePolicyBody,
|
|
8
|
+
type UpdatePolicyBody,
|
|
9
|
+
} from "./policies/schema.js";
|