@coinbase/cdp-sdk 1.7.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 +10 -0
- package/README.md +222 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +1 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- 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 +133 -15
- 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 +76 -19
- 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.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 +1 -1
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- 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 +6 -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/policies/types.js.map +1 -0
- 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/solana/toSolanaAccount.js +1 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- 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 +133 -15
- 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 +76 -19
- 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.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 +1 -1
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- 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 +5 -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/policies/types.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +6 -3
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +1 -2
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- 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 +33 -3
- 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 +43 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +14 -2
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +81 -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 +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- 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 +18 -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 +6 -3
- package/accounts/evm/types.ts +6 -8
- package/accounts/solana/toSolanaAccount.ts +1 -0
- package/actions/evm/transfer/types.ts +1 -1
- package/analytics.ts +84 -11
- package/client/cdp.ts +11 -4
- package/client/evm/evm.ts +159 -17
- package/client/evm/evm.types.ts +38 -1
- 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 +94 -20
- package/client/solana/solana.types.ts +16 -1
- package/index.ts +7 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +86 -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 +1 -1
- 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 +6 -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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdatePolicyBodySchema = exports.CreatePolicyBodySchema = exports.PolicyScopeEnum = exports.RuleSchema = exports.SignSolTransactionRuleSchema = exports.SignEvmTransactionRuleSchema = exports.ActionEnum = exports.EvmOperationEnum = exports.SolOperationEnum = exports.SignSolTransactionCriteriaSchema = exports.SignEvmTransactionCriteriaSchema = exports.SolAddressCriterionSchema = exports.EvmAddressCriterionSchema = exports.EthValueCriterionSchema = exports.SolAddressOperatorEnum = exports.EvmAddressOperatorEnum = exports.EthValueOperatorEnum = void 0;
|
|
4
|
+
const zod_1 = require("abitype/zod");
|
|
5
|
+
const zod_2 = require("zod");
|
|
6
|
+
/**
|
|
7
|
+
* Enum for EthValueOperator values
|
|
8
|
+
*/
|
|
9
|
+
exports.EthValueOperatorEnum = zod_2.z.enum([">", ">=", "<", "<=", "=="]);
|
|
10
|
+
/**
|
|
11
|
+
* Enum for EvmAddressOperator values
|
|
12
|
+
*/
|
|
13
|
+
exports.EvmAddressOperatorEnum = zod_2.z.enum(["in", "not in"]);
|
|
14
|
+
/**
|
|
15
|
+
* Enum for SolAddressOperator values
|
|
16
|
+
*/
|
|
17
|
+
exports.SolAddressOperatorEnum = zod_2.z.enum(["in", "not in"]);
|
|
18
|
+
/**
|
|
19
|
+
* Schema for ETH value criterions
|
|
20
|
+
*/
|
|
21
|
+
exports.EthValueCriterionSchema = zod_2.z.object({
|
|
22
|
+
/** The type of criterion, must be "ethValue" for Ethereum value-based rules. */
|
|
23
|
+
type: zod_2.z.literal("ethValue"),
|
|
24
|
+
/**
|
|
25
|
+
* The ETH value amount in wei to compare against, as a string.
|
|
26
|
+
* Must contain only digits.
|
|
27
|
+
*/
|
|
28
|
+
ethValue: zod_2.z.string().regex(/^[0-9]+$/),
|
|
29
|
+
/** The comparison operator to use for evaluating transaction values against the threshold. */
|
|
30
|
+
operator: exports.EthValueOperatorEnum,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Schema for EVM address criterions
|
|
34
|
+
*/
|
|
35
|
+
exports.EvmAddressCriterionSchema = zod_2.z.object({
|
|
36
|
+
/** The type of criterion, must be "evmAddress" for EVM address-based rules. */
|
|
37
|
+
type: zod_2.z.literal("evmAddress"),
|
|
38
|
+
/**
|
|
39
|
+
* Array of EVM addresses to compare against.
|
|
40
|
+
* Each address must be a 0x-prefixed 40-character hexadecimal string.
|
|
41
|
+
* Limited to a maximum of 100 addresses per criterion.
|
|
42
|
+
*/
|
|
43
|
+
addresses: zod_2.z.array(zod_1.Address).max(100),
|
|
44
|
+
/**
|
|
45
|
+
* The operator to use for evaluating transaction addresses.
|
|
46
|
+
* "in" checks if an address is in the provided list.
|
|
47
|
+
* "not in" checks if an address is not in the provided list.
|
|
48
|
+
*/
|
|
49
|
+
operator: exports.EvmAddressOperatorEnum,
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Schema for Solana address criterions
|
|
53
|
+
*/
|
|
54
|
+
exports.SolAddressCriterionSchema = zod_2.z.object({
|
|
55
|
+
/** The type of criterion, must be "solAddress" for Solana address-based rules. */
|
|
56
|
+
type: zod_2.z.literal("solAddress"),
|
|
57
|
+
/**
|
|
58
|
+
* Array of Solana addresses to compare against.
|
|
59
|
+
* Each address must be a valid Base58-encoded Solana address (32-44 characters).
|
|
60
|
+
*/
|
|
61
|
+
addresses: zod_2.z.array(zod_2.z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/)),
|
|
62
|
+
/**
|
|
63
|
+
* The operator to use for evaluating transaction addresses.
|
|
64
|
+
* "in" checks if an address is in the provided list.
|
|
65
|
+
* "not in" checks if an address is not in the provided list.
|
|
66
|
+
*/
|
|
67
|
+
operator: exports.SolAddressOperatorEnum,
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Schema for criteria used in SignEvmTransaction operations
|
|
71
|
+
*/
|
|
72
|
+
exports.SignEvmTransactionCriteriaSchema = zod_2.z
|
|
73
|
+
.array(zod_2.z.discriminatedUnion("type", [exports.EthValueCriterionSchema, exports.EvmAddressCriterionSchema]))
|
|
74
|
+
.max(10)
|
|
75
|
+
.min(1);
|
|
76
|
+
/**
|
|
77
|
+
* Schema for criteria used in SignSolTransaction operations
|
|
78
|
+
*/
|
|
79
|
+
exports.SignSolTransactionCriteriaSchema = zod_2.z
|
|
80
|
+
.array(zod_2.z.discriminatedUnion("type", [exports.SolAddressCriterionSchema]))
|
|
81
|
+
.max(10)
|
|
82
|
+
.min(1);
|
|
83
|
+
/**
|
|
84
|
+
* Enum for Solana Operation types
|
|
85
|
+
*/
|
|
86
|
+
exports.SolOperationEnum = zod_2.z.enum(["signSolTransaction"]);
|
|
87
|
+
/**
|
|
88
|
+
* Enum for Evm Operation types
|
|
89
|
+
*/
|
|
90
|
+
exports.EvmOperationEnum = zod_2.z.enum(["signEvmTransaction"]);
|
|
91
|
+
/**
|
|
92
|
+
* Enum for Action types
|
|
93
|
+
*/
|
|
94
|
+
exports.ActionEnum = zod_2.z.enum(["reject", "accept"]);
|
|
95
|
+
/**
|
|
96
|
+
* Type representing a 'signEvmTransaction' policy rule that can accept or reject specific operations
|
|
97
|
+
* based on a set of criteria.
|
|
98
|
+
*/
|
|
99
|
+
exports.SignEvmTransactionRuleSchema = zod_2.z.object({
|
|
100
|
+
/**
|
|
101
|
+
* Determines whether matching the rule will cause a request to be rejected or accepted.
|
|
102
|
+
* "accept" will allow the transaction, "reject" will block it.
|
|
103
|
+
*/
|
|
104
|
+
action: exports.ActionEnum,
|
|
105
|
+
/**
|
|
106
|
+
* The operation to which this rule applies.
|
|
107
|
+
* Must be "signEvmTransaction".
|
|
108
|
+
*/
|
|
109
|
+
operation: zod_2.z.literal("signEvmTransaction"),
|
|
110
|
+
/**
|
|
111
|
+
* The set of criteria that must be matched for this rule to apply.
|
|
112
|
+
* Must be compatible with the specified operation type.
|
|
113
|
+
*/
|
|
114
|
+
criteria: exports.SignEvmTransactionCriteriaSchema,
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Type representing a 'signSolTransaction' policy rule that can accept or reject specific operations
|
|
118
|
+
* based on a set of criteria.
|
|
119
|
+
*/
|
|
120
|
+
exports.SignSolTransactionRuleSchema = zod_2.z.object({
|
|
121
|
+
/**
|
|
122
|
+
* Determines whether matching the rule will cause a request to be rejected or accepted.
|
|
123
|
+
* "accept" will allow the transaction, "reject" will block it.
|
|
124
|
+
*/
|
|
125
|
+
action: exports.ActionEnum,
|
|
126
|
+
/**
|
|
127
|
+
* The operation to which this rule applies.
|
|
128
|
+
* Must be "signSolTransaction".
|
|
129
|
+
*/
|
|
130
|
+
operation: zod_2.z.literal("signSolTransaction"),
|
|
131
|
+
/**
|
|
132
|
+
* The set of criteria that must be matched for this rule to apply.
|
|
133
|
+
* Must be compatible with the specified operation type.
|
|
134
|
+
*/
|
|
135
|
+
criteria: exports.SignSolTransactionCriteriaSchema,
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* Schema for policy rules
|
|
139
|
+
*/
|
|
140
|
+
exports.RuleSchema = zod_2.z.discriminatedUnion("operation", [
|
|
141
|
+
exports.SignEvmTransactionRuleSchema,
|
|
142
|
+
exports.SignSolTransactionRuleSchema,
|
|
143
|
+
]);
|
|
144
|
+
/**
|
|
145
|
+
* Enum for policy scopes
|
|
146
|
+
*/
|
|
147
|
+
exports.PolicyScopeEnum = zod_2.z.enum(["project", "account"]);
|
|
148
|
+
/**
|
|
149
|
+
* Schema for creating or updating a Policy.
|
|
150
|
+
*/
|
|
151
|
+
exports.CreatePolicyBodySchema = zod_2.z.object({
|
|
152
|
+
/**
|
|
153
|
+
* The scope of the policy.
|
|
154
|
+
* "project" applies to the entire project, "account" applies to specific accounts.
|
|
155
|
+
*/
|
|
156
|
+
scope: exports.PolicyScopeEnum,
|
|
157
|
+
/**
|
|
158
|
+
* An optional human-readable description for the policy.
|
|
159
|
+
* Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
|
|
160
|
+
*/
|
|
161
|
+
description: zod_2.z
|
|
162
|
+
.string()
|
|
163
|
+
.regex(/^[A-Za-z0-9 ,.]{1,50}$/)
|
|
164
|
+
.optional(),
|
|
165
|
+
/**
|
|
166
|
+
* Array of rules that comprise the policy.
|
|
167
|
+
* Limited to a maximum of 10 rules per policy.
|
|
168
|
+
*/
|
|
169
|
+
rules: zod_2.z.array(exports.RuleSchema).max(10).min(1),
|
|
170
|
+
});
|
|
171
|
+
exports.UpdatePolicyBodySchema = zod_2.z.object({
|
|
172
|
+
/**
|
|
173
|
+
* An optional human-readable description for the policy.
|
|
174
|
+
* Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
|
|
175
|
+
*/
|
|
176
|
+
description: zod_2.z
|
|
177
|
+
.string()
|
|
178
|
+
.regex(/^[A-Za-z0-9 ,.]{1,50}$/)
|
|
179
|
+
.optional(),
|
|
180
|
+
/**
|
|
181
|
+
* Array of rules that comprise the policy.
|
|
182
|
+
* Limited to a maximum of 10 rules per policy.
|
|
183
|
+
*/
|
|
184
|
+
rules: zod_2.z.array(exports.RuleSchema).max(10).min(1),
|
|
185
|
+
});
|
|
186
|
+
//# source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,OAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC1C;;;OAGG;IACH,QAAQ,EAAE,wCAAgC;CAC3C,CAAC,CAAC;AAGH;;GAEG;AACU,QAAA,UAAU,GAAG,OAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE;IAC1D,oCAA4B;IAC5B,oCAA4B;CAC7B,CAAC,CAAC;AAQH;;GAEG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAO9D;;GAEG;AACU,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C;;;OAGG;IACH,KAAK,EAAE,uBAAe;IACtB;;;OAGG;IACH,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,KAAK,CAAC,wBAAwB,CAAC;SAC/B,QAAQ,EAAE;IACb;;;OAGG;IACH,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,kBAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1C,CAAC,CAAC;AAOU,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C;;;OAGG;IACH,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,KAAK,CAAC,wBAAwB,CAAC;SAC/B,QAAQ,EAAE;IACb;;;OAGG;IACH,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,kBAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../policies/types.ts"],"names":[],"mappings":""}
|
package/_cjs/version.js
CHANGED
|
@@ -34,8 +34,9 @@ export function toEvmServerAccount(apiClient, options) {
|
|
|
34
34
|
});
|
|
35
35
|
return result.signedTransaction;
|
|
36
36
|
},
|
|
37
|
-
async signTypedData() {
|
|
38
|
-
|
|
37
|
+
async signTypedData(message) {
|
|
38
|
+
const result = await apiClient.signEvmTypedData(options.account.address, message);
|
|
39
|
+
return result.signature;
|
|
39
40
|
},
|
|
40
41
|
async transfer(transferArgs) {
|
|
41
42
|
return transfer(apiClient, account, transferArgs, accountTransferStrategy);
|
|
@@ -60,6 +61,7 @@ export function toEvmServerAccount(apiClient, options) {
|
|
|
60
61
|
},
|
|
61
62
|
name: options.account.name,
|
|
62
63
|
type: "evm-server",
|
|
64
|
+
policies: options.account.policies,
|
|
63
65
|
};
|
|
64
66
|
return account;
|
|
65
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmServerAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAEpF,OAAO,EACL,iBAAiB,GAGlB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,aAAa,GAGd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAgBlE;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA+B,EAC/B,OAAkC;IAElC,MAAM,OAAO,GAAqB;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAkB;QAC3C,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;gBACrE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;aAC5B,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,SAAgB,CAAC;QACjC,CAAC;QAED,KAAK,CAAC,IA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":3,"file":"toSolanaAccount.js","sourceRoot":"","sources":["../../../accounts/solana/toSolanaAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAgB1E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA+B,EAC/B,OAA+B;IAE/B,MAAM,OAAO,GAAkB;QAC7B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;QAC1B,KAAK,CAAC,aAAa,CAAC,OAA8C;YAChE,OAAO,aAAa,CAAC,SAAS,EAAE;gBAC9B,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAA4C;YAC5D,OAAO,WAAW,CAAC,SAAS,EAAE;gBAC5B,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,eAAe,CACnB,OAAgD;YAEhD,OAAO,eAAe,CAAC,SAAS,EAAE;gBAChC,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;KACnC,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/_esm/analytics.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import md5 from "md5";
|
|
2
|
+
import { APIError } from "./openapi-client/errors.js";
|
|
2
3
|
// This is a public client id for the analytics service
|
|
3
4
|
const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
|
|
5
|
+
export const Analytics = {
|
|
6
|
+
identifier: "", // set in cdp.ts
|
|
7
|
+
wrapClassWithErrorTracking,
|
|
8
|
+
wrapObjectMethodsWithErrorTracking,
|
|
9
|
+
sendEvent,
|
|
10
|
+
};
|
|
4
11
|
/**
|
|
5
12
|
* Sends an analytics event to the default endpoint
|
|
6
13
|
*
|
|
7
14
|
* @param event - The event data containing event-specific fields
|
|
8
15
|
* @returns Promise that resolves when the event is sent
|
|
9
16
|
*/
|
|
10
|
-
|
|
17
|
+
async function sendEvent(event) {
|
|
18
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
11
21
|
const timestamp = Date.now();
|
|
12
22
|
const enhancedEvent = {
|
|
13
|
-
user_id:
|
|
23
|
+
user_id: Analytics.identifier,
|
|
14
24
|
event_type: event.name,
|
|
15
25
|
platform: "server",
|
|
16
26
|
timestamp,
|
|
@@ -45,10 +55,12 @@ export async function sendEvent(event) {
|
|
|
45
55
|
* Wraps all methods of a class with error tracking.
|
|
46
56
|
*
|
|
47
57
|
* @param ClassToWrap - The class whose prototype methods should be wrapped.
|
|
48
|
-
* @param apiKeyId - The API key ID to use for the error tracking.
|
|
49
58
|
*/
|
|
50
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
-
|
|
60
|
+
function wrapClassWithErrorTracking(ClassToWrap) {
|
|
61
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
52
64
|
const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function");
|
|
53
65
|
for (const method of methods) {
|
|
54
66
|
const originalMethod = ClassToWrap.prototype[method];
|
|
@@ -57,12 +69,11 @@ export function wrapClassWithErrorTracking(ClassToWrap, apiKeyId) {
|
|
|
57
69
|
return await originalMethod.apply(this, args);
|
|
58
70
|
}
|
|
59
71
|
catch (error) {
|
|
60
|
-
if (!(error
|
|
61
|
-
|
|
72
|
+
if (!shouldTrackError(error)) {
|
|
73
|
+
throw error;
|
|
62
74
|
}
|
|
63
75
|
const { message, stack } = error;
|
|
64
76
|
sendEvent({
|
|
65
|
-
apiKeyId,
|
|
66
77
|
method,
|
|
67
78
|
message,
|
|
68
79
|
stack,
|
|
@@ -75,4 +86,54 @@ export function wrapClassWithErrorTracking(ClassToWrap, apiKeyId) {
|
|
|
75
86
|
};
|
|
76
87
|
}
|
|
77
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Wraps all methods of an object with error tracking.
|
|
91
|
+
*
|
|
92
|
+
* @param object - The object whose methods should be wrapped.
|
|
93
|
+
*/
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
function wrapObjectMethodsWithErrorTracking(object) {
|
|
96
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const methods = Object.getOwnPropertyNames(object).filter(name => name !== "constructor" && typeof object[name] === "function");
|
|
100
|
+
for (const method of methods) {
|
|
101
|
+
const originalMethod = object[method];
|
|
102
|
+
object[method] = async function (...args) {
|
|
103
|
+
try {
|
|
104
|
+
return await originalMethod.apply(this, args);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!shouldTrackError(error)) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
const { message, stack } = error;
|
|
111
|
+
sendEvent({
|
|
112
|
+
method,
|
|
113
|
+
message,
|
|
114
|
+
stack,
|
|
115
|
+
name: "error",
|
|
116
|
+
}).catch(() => {
|
|
117
|
+
// ignore error
|
|
118
|
+
});
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Filters out non-errors and API errors
|
|
126
|
+
*
|
|
127
|
+
* @param error - The error to check.
|
|
128
|
+
* @returns True if the error should be tracked, false otherwise.
|
|
129
|
+
*/
|
|
130
|
+
function shouldTrackError(error) {
|
|
131
|
+
if (!(error instanceof Error)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (error instanceof APIError) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
78
139
|
//# sourceMappingURL=analytics.js.map
|
package/_esm/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AA0BtD,uDAAuD;AACvD,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE1D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,EAAE,EAAE,gBAAgB;IAChC,0BAA0B;IAC1B,kCAAkC;IAClC,SAAS;CACV,CAAC;AAEF;;;;;GAKG;AACH,KAAK,UAAU,SAAS,CAAC,KAAgB;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM,EAAE,CAAC;QACvD,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,aAAa,GAAG;QACpB,OAAO,EAAE,SAAS,CAAC,UAAU;QAC7B,UAAU,EAAE,KAAK,CAAC,IAAI;QACtB,QAAQ,EAAE,QAAQ;QAClB,SAAS;QACT,gBAAgB,EAAE;YAChB,YAAY,EAAE,SAAS;YACvB,gBAAgB,EAAE,YAAY;YAC9B,GAAG,KAAK;SACT;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/B,MAAM,oBAAo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EAAE,GAAG,KAAc,CAAC;gBAE1C,SAAS,CAAC;oBACR,MAAM;oBACN,OAAO;oBACP,KAAK;oBACL,IAAI,EAAE,OAAO;iBACd,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;oBACZ,eAAe;gBACjB,CAAC,CAAC,CAAC;gBAEH,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/_esm/client/cdp.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Analytics } from "../analytics.js";
|
|
2
2
|
import { CdpOpenApiClient } from "../openapi-client/index.js";
|
|
3
3
|
import { version } from "../version.js";
|
|
4
4
|
import { EvmClient } from "./evm/evm.js";
|
|
5
|
+
import { PoliciesClient } from "./policies/policies.js";
|
|
5
6
|
import { SolanaClient } from "./solana/solana.js";
|
|
6
7
|
/**
|
|
7
8
|
* The main client for interacting with the CDP API.
|
|
@@ -11,6 +12,8 @@ export class CdpClient {
|
|
|
11
12
|
evm;
|
|
12
13
|
/** Namespace containing all Solana methods. */
|
|
13
14
|
solana;
|
|
15
|
+
/** Namespace containing all Policies methods. */
|
|
16
|
+
policies;
|
|
14
17
|
/**
|
|
15
18
|
* The CdpClient is the main class for interacting with the CDP API.
|
|
16
19
|
*
|
|
@@ -90,12 +93,15 @@ For more information, see: https://github.com/coinbase/cdp-sdk/blob/main/typescr
|
|
|
90
93
|
sourceVersion: version,
|
|
91
94
|
});
|
|
92
95
|
if (process.env.DISABLE_CDP_ERROR_REPORTING !== "true") {
|
|
93
|
-
|
|
94
|
-
wrapClassWithErrorTracking(
|
|
95
|
-
wrapClassWithErrorTracking(
|
|
96
|
+
Analytics.identifier = apiKeyId;
|
|
97
|
+
Analytics.wrapClassWithErrorTracking(CdpClient);
|
|
98
|
+
Analytics.wrapClassWithErrorTracking(EvmClient);
|
|
99
|
+
Analytics.wrapClassWithErrorTracking(SolanaClient);
|
|
100
|
+
Analytics.wrapClassWithErrorTracking(PoliciesClient);
|
|
96
101
|
}
|
|
97
102
|
this.evm = new EvmClient();
|
|
98
103
|
this.solana = new SolanaClient();
|
|
104
|
+
this.policies = new PoliciesClient();
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
//# sourceMappingURL=cdp.js.map
|
package/_esm/client/cdp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../../client/cdp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../../client/cdp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAelD;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB,4CAA4C;IACrC,GAAG,CAAY;IAEtB,+CAA+C;IACxC,MAAM,CAAe;IAE5B,iDAAiD;IAC1C,QAAQ,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,YAAY,UAA4B,EAAE;QACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAChG,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC5E,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAE3E,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BrB,CAAC,CAAC;QACC,CAAC;QAED,gBAAgB,CAAC,SAAS,CAAC;YACzB,GAAG,OAAO;YACV,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,MAAM,EAAE,KAAK;YACb,aAAa,EAAE,OAAO;SACvB,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM,EAAE,CAAC;YACvD,SAAS,CAAC,UAAU,GAAG,QAAQ,CAAC;YAChC,SAAS,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;YAChD,SAAS,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;YAChD,SAAS,CAAC,0BAA0B,CAAC,YAAY,CAAC,CAAC;YACnD,SAAS,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IACvC,CAAC;CACF"}
|
package/_esm/client/evm/evm.js
CHANGED
|
@@ -6,6 +6,7 @@ import { requestFaucet, } from "../../actions/evm/requestFaucet.js";
|
|
|
6
6
|
import { sendTransaction } from "../../actions/evm/sendTransaction.js";
|
|
7
7
|
import { sendUserOperation, } from "../../actions/evm/sendUserOperation.js";
|
|
8
8
|
import { waitForUserOperation, } from "../../actions/evm/waitForUserOperation.js";
|
|
9
|
+
import { Analytics } from "../../analytics.js";
|
|
9
10
|
import { APIError } from "../../openapi-client/errors.js";
|
|
10
11
|
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
11
12
|
/**
|
|
@@ -47,12 +48,14 @@ export class EvmClient {
|
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
50
|
async createAccount(options = {}) {
|
|
50
|
-
const
|
|
51
|
+
const openApiAccount = await CdpOpenApiClient.createEvmAccount({
|
|
51
52
|
name: options.name,
|
|
52
53
|
}, options.idempotencyKey);
|
|
53
|
-
|
|
54
|
-
account,
|
|
54
|
+
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
55
|
+
account: openApiAccount,
|
|
55
56
|
});
|
|
57
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
58
|
+
return account;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Creates a new CDP EVM smart account.
|
|
@@ -100,13 +103,15 @@ export class EvmClient {
|
|
|
100
103
|
* ```
|
|
101
104
|
*/
|
|
102
105
|
async createSmartAccount(options) {
|
|
103
|
-
const
|
|
106
|
+
const openApiSmartAccount = await CdpOpenApiClient.createEvmSmartAccount({
|
|
104
107
|
owners: [options.owner.address],
|
|
105
108
|
}, options.idempotencyKey);
|
|
106
|
-
|
|
107
|
-
smartAccount,
|
|
109
|
+
const smartAccount = toEvmSmartAccount(CdpOpenApiClient, {
|
|
110
|
+
smartAccount: openApiSmartAccount,
|
|
108
111
|
owner: options.owner,
|
|
109
112
|
});
|
|
113
|
+
Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
114
|
+
return smartAccount;
|
|
110
115
|
}
|
|
111
116
|
/**
|
|
112
117
|
* Gets a CDP EVM account.
|
|
@@ -134,7 +139,7 @@ export class EvmClient {
|
|
|
134
139
|
* ```
|
|
135
140
|
*/
|
|
136
141
|
async getAccount(options) {
|
|
137
|
-
const
|
|
142
|
+
const openApiAccount = await (() => {
|
|
138
143
|
if (options.address) {
|
|
139
144
|
return CdpOpenApiClient.getEvmAccount(options.address);
|
|
140
145
|
}
|
|
@@ -143,9 +148,11 @@ export class EvmClient {
|
|
|
143
148
|
}
|
|
144
149
|
throw new Error("Either address or name must be provided");
|
|
145
150
|
})();
|
|
146
|
-
|
|
147
|
-
account,
|
|
151
|
+
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
152
|
+
account: openApiAccount,
|
|
148
153
|
});
|
|
154
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
155
|
+
return account;
|
|
149
156
|
}
|
|
150
157
|
/**
|
|
151
158
|
* Gets a CDP EVM smart account.
|
|
@@ -167,11 +174,13 @@ export class EvmClient {
|
|
|
167
174
|
* ```
|
|
168
175
|
*/
|
|
169
176
|
async getSmartAccount(options) {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
smartAccount,
|
|
177
|
+
const openApiSmartAccount = await CdpOpenApiClient.getEvmSmartAccount(options.address);
|
|
178
|
+
const smartAccount = toEvmSmartAccount(CdpOpenApiClient, {
|
|
179
|
+
smartAccount: openApiSmartAccount,
|
|
173
180
|
owner: options.owner,
|
|
174
181
|
});
|
|
182
|
+
Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
183
|
+
return smartAccount;
|
|
175
184
|
}
|
|
176
185
|
/**
|
|
177
186
|
* Gets a CDP EVM account, or creates one if it doesn't exist.
|
|
@@ -264,9 +273,13 @@ export class EvmClient {
|
|
|
264
273
|
pageToken: options.pageToken,
|
|
265
274
|
});
|
|
266
275
|
return {
|
|
267
|
-
accounts: ethAccounts.accounts.map(account =>
|
|
268
|
-
|
|
269
|
-
|
|
276
|
+
accounts: ethAccounts.accounts.map(account => {
|
|
277
|
+
const evmAccount = toEvmServerAccount(CdpOpenApiClient, {
|
|
278
|
+
account,
|
|
279
|
+
});
|
|
280
|
+
Analytics.wrapObjectMethodsWithErrorTracking(evmAccount);
|
|
281
|
+
return evmAccount;
|
|
282
|
+
}),
|
|
270
283
|
nextPageToken: ethAccounts.nextPageToken,
|
|
271
284
|
};
|
|
272
285
|
}
|
|
@@ -558,6 +571,62 @@ export class EvmClient {
|
|
|
558
571
|
signature: signature.signature,
|
|
559
572
|
};
|
|
560
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Signs an EIP-712 message.
|
|
576
|
+
*
|
|
577
|
+
* @param {SignTypedDataOptions} options - Parameters for signing the EIP-712 message.
|
|
578
|
+
* @returns A promise that resolves to the signature.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```ts
|
|
582
|
+
* const signature = await cdp.evm.signTypedData({
|
|
583
|
+
* address: account.address,
|
|
584
|
+
* domain: {
|
|
585
|
+
* name: "Permit2",
|
|
586
|
+
* chainId: 1,
|
|
587
|
+
* verifyingContract: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
588
|
+
* },
|
|
589
|
+
* types: {
|
|
590
|
+
* EIP712Domain: [
|
|
591
|
+
* { name: "name", type: "string" },
|
|
592
|
+
* { name: "chainId", type: "uint256" },
|
|
593
|
+
* { name: "verifyingContract", type: "address" },
|
|
594
|
+
* ],
|
|
595
|
+
* PermitTransferFrom: [
|
|
596
|
+
* { name: "permitted", type: "TokenPermissions" },
|
|
597
|
+
* { name: "spender", type: "address" },
|
|
598
|
+
* { name: "nonce", type: "uint256" },
|
|
599
|
+
* { name: "deadline", type: "uint256" },
|
|
600
|
+
* ],
|
|
601
|
+
* TokenPermissions: [
|
|
602
|
+
* { name: "token", type: "address" },
|
|
603
|
+
* { name: "amount", type: "uint256" },
|
|
604
|
+
* ],
|
|
605
|
+
* },
|
|
606
|
+
* primaryType: "PermitTransferFrom",
|
|
607
|
+
* message: {
|
|
608
|
+
* permitted: {
|
|
609
|
+
* token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
610
|
+
* amount: "1000000",
|
|
611
|
+
* },
|
|
612
|
+
* spender: "0xFfFfFfFFfFFfFFfFFfFFFFFffFFFffffFfFFFfFf",
|
|
613
|
+
* nonce: "0",
|
|
614
|
+
* deadline: "1717123200",
|
|
615
|
+
* },
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
async signTypedData(options) {
|
|
620
|
+
const signature = await CdpOpenApiClient.signEvmTypedData(options.address, {
|
|
621
|
+
domain: options.domain,
|
|
622
|
+
types: options.types,
|
|
623
|
+
primaryType: options.primaryType,
|
|
624
|
+
message: options.message,
|
|
625
|
+
}, options.idempotencyKey);
|
|
626
|
+
return {
|
|
627
|
+
signature: signature.signature,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
561
630
|
/**
|
|
562
631
|
* Signs an EVM transaction.
|
|
563
632
|
*
|
|
@@ -596,6 +665,55 @@ export class EvmClient {
|
|
|
596
665
|
signature: signature.signedTransaction,
|
|
597
666
|
};
|
|
598
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* Updates a CDP EVM account.
|
|
670
|
+
*
|
|
671
|
+
* @param {UpdateEvmAccountOptions} [options] - Optional parameters for creating the account.
|
|
672
|
+
* @param {string} options.address - The address of the account to update
|
|
673
|
+
* @param {UpdateEvmAccountBody} options.update - An object containing account fields to update.
|
|
674
|
+
* @param {string} [options.update.name] - The new name for the account.
|
|
675
|
+
* @param {string} [options.update.accountPolicy] - The ID of a Policy to apply to the account.
|
|
676
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
677
|
+
*
|
|
678
|
+
* @returns A promise that resolves to the updated account.
|
|
679
|
+
*
|
|
680
|
+
* @example **With a name**
|
|
681
|
+
* ```ts
|
|
682
|
+
* const account = await cdp.evm.updateAccount({ address: "0x...", update: { name: "New Name" } });
|
|
683
|
+
* ```
|
|
684
|
+
*
|
|
685
|
+
* @example **With an account policy**
|
|
686
|
+
* ```ts
|
|
687
|
+
* const account = await cdp.evm.updateAccount({ address: "0x...", update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" } });
|
|
688
|
+
* ```
|
|
689
|
+
*
|
|
690
|
+
* @example **With an idempotency key**
|
|
691
|
+
* ```ts
|
|
692
|
+
* const idempotencyKey = uuidv4();
|
|
693
|
+
*
|
|
694
|
+
* // First call
|
|
695
|
+
* await cdp.evm.updateAccount({
|
|
696
|
+
* address: "0x...",
|
|
697
|
+
* update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" },
|
|
698
|
+
* idempotencyKey,
|
|
699
|
+
* });
|
|
700
|
+
*
|
|
701
|
+
* // Second call with the same idempotency key will not update
|
|
702
|
+
* await cdp.evm.updateAccount({
|
|
703
|
+
* address: '0x...',
|
|
704
|
+
* update: { name: "" },
|
|
705
|
+
* idempotencyKey,
|
|
706
|
+
* });
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
async updateAccount(options) {
|
|
710
|
+
const openApiAccount = await CdpOpenApiClient.updateEvmAccount(options.address, options.update, options.idempotencyKey);
|
|
711
|
+
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
712
|
+
account: openApiAccount,
|
|
713
|
+
});
|
|
714
|
+
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
715
|
+
return account;
|
|
716
|
+
}
|
|
599
717
|
/**
|
|
600
718
|
* Waits for a user operation to complete or fail.
|
|
601
719
|
*
|