@coinbase/cdp-sdk 1.44.1 → 1.45.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 +14 -0
- package/README.md +117 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js +27 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +127 -55
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +111 -45
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +49 -19
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js +37 -0
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_cjs/analytics.js +10 -228
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/cdp.js +0 -6
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/evm/evm.js +482 -227
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/policies.js +41 -11
- package/_cjs/client/policies/policies.js.map +1 -1
- package/_cjs/client/solana/solana.js +177 -106
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +3 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +137 -5
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +30 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js +15 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_cjs/policies/evmSchema.js +127 -1
- package/_cjs/policies/evmSchema.js.map +1 -1
- package/_cjs/policies/solanaSchema.js +102 -1
- package/_cjs/policies/solanaSchema.js.map +1 -1
- package/_cjs/policies/types.js +7 -0
- package/_cjs/policies/types.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmDelegatedAccount.js +24 -0
- package/_esm/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_esm/accounts/evm/toEvmServerAccount.js +127 -55
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +111 -45
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +49 -19
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js +34 -0
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_esm/analytics.js +9 -227
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/cdp.js +0 -6
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/evm/evm.js +482 -227
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/policies.js +41 -11
- package/_esm/client/policies/policies.js.map +1 -1
- package/_esm/client/solana/solana.js +177 -106
- 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 +134 -3
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +27 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/onramp/onramp.js +13 -0
- package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_esm/policies/evmSchema.js +126 -0
- package/_esm/policies/evmSchema.js.map +1 -1
- package/_esm/policies/solanaSchema.js +101 -0
- package/_esm/policies/solanaSchema.js.map +1 -1
- package/_esm/policies/types.js +9 -2
- package/_esm/policies/types.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts +13 -0
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts.map +1 -0
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts +32 -0
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts.map +1 -0
- package/_types/analytics.d.ts +5 -38
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +54 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +29 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/policies.d.ts.map +1 -1
- package/_types/client/solana/solana.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 +436 -10
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +21 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +8 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +4 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/evmSchema.d.ts +2717 -601
- package/_types/policies/evmSchema.d.ts.map +1 -1
- package/_types/policies/solanaSchema.d.ts +1411 -47
- package/_types/policies/solanaSchema.d.ts.map +1 -1
- package/_types/policies/types.d.ts +8427 -2942
- package/_types/policies/types.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
- package/accounts/evm/toEvmServerAccount.ts +115 -67
- package/accounts/evm/toEvmSmartAccount.ts +100 -56
- package/accounts/solana/toSolanaAccount.ts +44 -24
- package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
- package/analytics.ts +8 -294
- package/client/cdp.ts +0 -7
- package/client/evm/evm.ts +517 -282
- package/client/evm/evm.types.ts +41 -0
- package/client/policies/policies.ts +41 -16
- package/client/solana/solana.ts +195 -141
- package/index.ts +5 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +580 -11
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +49 -0
- package/openapi-client/generated/onramp/onramp.ts +24 -0
- package/package.json +1 -1
- package/policies/evmSchema.ts +164 -0
- package/policies/solanaSchema.ts +130 -0
- package/policies/types.ts +14 -0
- package/version.ts +1 -1
package/_esm/client/evm/evm.js
CHANGED
|
@@ -14,6 +14,7 @@ import { sendUserOperation, } from "../../actions/evm/sendUserOperation.js";
|
|
|
14
14
|
import { resolveSpendPermission } from "../../actions/evm/spend-permissions/resolveSpendPermission.js";
|
|
15
15
|
import { createSwapQuote } from "../../actions/evm/swap/createSwapQuote.js";
|
|
16
16
|
import { getSwapPrice } from "../../actions/evm/swap/getSwapPrice.js";
|
|
17
|
+
import { waitForEvmEip7702DelegationOperationStatus } from "../../actions/evm/waitForEvmEip7702DelegationStatus.js";
|
|
17
18
|
import { waitForUserOperation, } from "../../actions/evm/waitForUserOperation.js";
|
|
18
19
|
import { Analytics } from "../../analytics.js";
|
|
19
20
|
import { ImportAccountPublicRSAKey } from "../../constants.js";
|
|
@@ -65,7 +66,13 @@ export class EvmClient {
|
|
|
65
66
|
action: "create_account",
|
|
66
67
|
accountType: "evm_server",
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
try {
|
|
70
|
+
return await this._createAccountInternal(options);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
Analytics.trackError(error, "createAccount");
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
/**
|
|
71
78
|
* Imports a CDP EVM account from an external source.
|
|
@@ -114,14 +121,14 @@ export class EvmClient {
|
|
|
114
121
|
action: "import_account",
|
|
115
122
|
accountType: "evm_server",
|
|
116
123
|
});
|
|
117
|
-
const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
|
|
118
|
-
const privateKeyHex = options.privateKey.startsWith("0x")
|
|
119
|
-
? options.privateKey.slice(2)
|
|
120
|
-
: options.privateKey;
|
|
121
|
-
if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
|
|
122
|
-
throw new UserInputValidationError("Private key must be a valid hexadecimal string");
|
|
123
|
-
}
|
|
124
124
|
try {
|
|
125
|
+
const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
|
|
126
|
+
const privateKeyHex = options.privateKey.startsWith("0x")
|
|
127
|
+
? options.privateKey.slice(2)
|
|
128
|
+
: options.privateKey;
|
|
129
|
+
if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
|
|
130
|
+
throw new UserInputValidationError("Private key must be a valid hexadecimal string");
|
|
131
|
+
}
|
|
125
132
|
const privateKeyBytes = Buffer.from(privateKeyHex, "hex");
|
|
126
133
|
const encryptedPrivateKey = publicEncrypt({
|
|
127
134
|
key: encryptionPublicKey,
|
|
@@ -135,10 +142,12 @@ export class EvmClient {
|
|
|
135
142
|
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
136
143
|
account: openApiAccount,
|
|
137
144
|
});
|
|
138
|
-
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
139
145
|
return account;
|
|
140
146
|
}
|
|
141
147
|
catch (error) {
|
|
148
|
+
if (!(error instanceof UserInputValidationError)) {
|
|
149
|
+
Analytics.trackError(error, "importAccount");
|
|
150
|
+
}
|
|
142
151
|
if (error instanceof APIError) {
|
|
143
152
|
throw error;
|
|
144
153
|
}
|
|
@@ -175,21 +184,29 @@ export class EvmClient {
|
|
|
175
184
|
action: "export_account",
|
|
176
185
|
accountType: "evm_server",
|
|
177
186
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
try {
|
|
188
|
+
const { publicKey, privateKey } = await generateExportEncryptionKeyPair();
|
|
189
|
+
const { encryptedPrivateKey } = await (async () => {
|
|
190
|
+
if (options.address) {
|
|
191
|
+
return CdpOpenApiClient.exportEvmAccount(options.address, {
|
|
192
|
+
exportEncryptionKey: publicKey,
|
|
193
|
+
}, options.idempotencyKey);
|
|
194
|
+
}
|
|
195
|
+
if (options.name) {
|
|
196
|
+
return CdpOpenApiClient.exportEvmAccountByName(options.name, {
|
|
197
|
+
exportEncryptionKey: publicKey,
|
|
198
|
+
}, options.idempotencyKey);
|
|
199
|
+
}
|
|
200
|
+
throw new UserInputValidationError("Either address or name must be provided");
|
|
201
|
+
})();
|
|
202
|
+
return decryptWithPrivateKey(privateKey, encryptedPrivateKey);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (!(error instanceof UserInputValidationError)) {
|
|
206
|
+
Analytics.trackError(error, "exportAccount");
|
|
189
207
|
}
|
|
190
|
-
throw
|
|
191
|
-
}
|
|
192
|
-
return decryptWithPrivateKey(privateKey, encryptedPrivateKey);
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
193
210
|
}
|
|
194
211
|
/**
|
|
195
212
|
* Creates a new CDP EVM smart account.
|
|
@@ -241,7 +258,13 @@ export class EvmClient {
|
|
|
241
258
|
action: "create_smart_account",
|
|
242
259
|
accountType: "evm_smart",
|
|
243
260
|
});
|
|
244
|
-
|
|
261
|
+
try {
|
|
262
|
+
return await this._createSmartAccountInternal(options);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
Analytics.trackError(error, "createSmartAccount");
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
245
268
|
}
|
|
246
269
|
/**
|
|
247
270
|
* Creates a spend permission for a smart account.
|
|
@@ -264,29 +287,35 @@ export class EvmClient {
|
|
|
264
287
|
Analytics.trackAction({
|
|
265
288
|
action: "create_spend_permission",
|
|
266
289
|
});
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
+
try {
|
|
291
|
+
const resolvedSpendPermission = resolveSpendPermission(options.spendPermission, options.network);
|
|
292
|
+
const userOperation = await CdpOpenApiClient.createSpendPermission(resolvedSpendPermission.account, {
|
|
293
|
+
spender: resolvedSpendPermission.spender,
|
|
294
|
+
token: resolvedSpendPermission.token,
|
|
295
|
+
allowance: resolvedSpendPermission.allowance.toString(),
|
|
296
|
+
period: resolvedSpendPermission.period.toString(),
|
|
297
|
+
start: resolvedSpendPermission.start.toString(),
|
|
298
|
+
end: resolvedSpendPermission.end.toString(),
|
|
299
|
+
salt: resolvedSpendPermission.salt.toString(),
|
|
300
|
+
extraData: resolvedSpendPermission.extraData,
|
|
301
|
+
network: options.network,
|
|
302
|
+
paymasterUrl: options.paymasterUrl,
|
|
303
|
+
}, options.idempotencyKey);
|
|
304
|
+
return {
|
|
305
|
+
network: userOperation.network,
|
|
306
|
+
userOpHash: userOperation.userOpHash,
|
|
307
|
+
status: userOperation.status,
|
|
308
|
+
calls: userOperation.calls.map(call => ({
|
|
309
|
+
to: call.to,
|
|
310
|
+
value: BigInt(call.value),
|
|
311
|
+
data: call.data,
|
|
312
|
+
})),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
Analytics.trackError(error, "createSpendPermission");
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
290
319
|
}
|
|
291
320
|
/**
|
|
292
321
|
* Revokes a spend permission for a smart account.
|
|
@@ -312,21 +341,27 @@ export class EvmClient {
|
|
|
312
341
|
Analytics.trackAction({
|
|
313
342
|
action: "revoke_spend_permission",
|
|
314
343
|
});
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
344
|
+
try {
|
|
345
|
+
const userOperation = await CdpOpenApiClient.revokeSpendPermission(options.address, {
|
|
346
|
+
network: options.network,
|
|
347
|
+
permissionHash: options.permissionHash,
|
|
348
|
+
paymasterUrl: options.paymasterUrl,
|
|
349
|
+
}, options.idempotencyKey);
|
|
350
|
+
return {
|
|
351
|
+
network: userOperation.network,
|
|
352
|
+
userOpHash: userOperation.userOpHash,
|
|
353
|
+
status: userOperation.status,
|
|
354
|
+
calls: userOperation.calls.map(call => ({
|
|
355
|
+
to: call.to,
|
|
356
|
+
value: BigInt(call.value),
|
|
357
|
+
data: call.data,
|
|
358
|
+
})),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
Analytics.trackError(error, "revokeSpendPermission");
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
330
365
|
}
|
|
331
366
|
/**
|
|
332
367
|
* Gets a CDP EVM account.
|
|
@@ -358,7 +393,13 @@ export class EvmClient {
|
|
|
358
393
|
action: "get_account",
|
|
359
394
|
accountType: "evm_server",
|
|
360
395
|
});
|
|
361
|
-
|
|
396
|
+
try {
|
|
397
|
+
return await this._getAccountInternal(options);
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
Analytics.trackError(error, "getAccount");
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
362
403
|
}
|
|
363
404
|
/**
|
|
364
405
|
* Gets a CDP EVM smart account.
|
|
@@ -386,7 +427,13 @@ export class EvmClient {
|
|
|
386
427
|
Analytics.trackAction({
|
|
387
428
|
action: "get_smart_account",
|
|
388
429
|
});
|
|
389
|
-
|
|
430
|
+
try {
|
|
431
|
+
return await this._getSmartAccountInternal(options);
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
Analytics.trackError(error, "getSmartAccount");
|
|
435
|
+
throw error;
|
|
436
|
+
}
|
|
390
437
|
}
|
|
391
438
|
/**
|
|
392
439
|
* Gets a CDP EVM account, or creates one if it doesn't exist.
|
|
@@ -409,27 +456,33 @@ export class EvmClient {
|
|
|
409
456
|
accountType: "evm_server",
|
|
410
457
|
});
|
|
411
458
|
try {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
catch (error) {
|
|
424
|
-
// If it failed because the account already exists, get the existing account
|
|
425
|
-
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
426
|
-
if (doesAccountAlreadyExist) {
|
|
427
|
-
const account = await this._getAccountInternal(options);
|
|
459
|
+
try {
|
|
460
|
+
const account = await this._getAccountInternal(options);
|
|
461
|
+
return account;
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
// If it failed because the account doesn't exist, create it
|
|
465
|
+
const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
|
|
466
|
+
if (doesAccountNotExist) {
|
|
467
|
+
try {
|
|
468
|
+
const account = await this._createAccountInternal(options);
|
|
428
469
|
return account;
|
|
429
470
|
}
|
|
430
|
-
|
|
471
|
+
catch (error) {
|
|
472
|
+
// If it failed because the account already exists, get the existing account
|
|
473
|
+
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
474
|
+
if (doesAccountAlreadyExist) {
|
|
475
|
+
const account = await this._getAccountInternal(options);
|
|
476
|
+
return account;
|
|
477
|
+
}
|
|
478
|
+
throw error;
|
|
479
|
+
}
|
|
431
480
|
}
|
|
481
|
+
throw error;
|
|
432
482
|
}
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
Analytics.trackError(error, "getOrCreateAccount");
|
|
433
486
|
throw error;
|
|
434
487
|
}
|
|
435
488
|
}
|
|
@@ -458,27 +511,33 @@ export class EvmClient {
|
|
|
458
511
|
accountType: "evm_smart",
|
|
459
512
|
});
|
|
460
513
|
try {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
catch (error) {
|
|
473
|
-
// If it failed because the account already exists, get the existing account
|
|
474
|
-
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
475
|
-
if (doesAccountAlreadyExist) {
|
|
476
|
-
const account = await this._getSmartAccountInternal(options);
|
|
514
|
+
try {
|
|
515
|
+
const account = await this._getSmartAccountInternal(options);
|
|
516
|
+
return account;
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
// If it failed because the account doesn't exist, create it
|
|
520
|
+
const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
|
|
521
|
+
if (doesAccountNotExist) {
|
|
522
|
+
try {
|
|
523
|
+
const account = await this._createSmartAccountInternal(options);
|
|
477
524
|
return account;
|
|
478
525
|
}
|
|
479
|
-
|
|
526
|
+
catch (error) {
|
|
527
|
+
// If it failed because the account already exists, get the existing account
|
|
528
|
+
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
529
|
+
if (doesAccountAlreadyExist) {
|
|
530
|
+
const account = await this._getSmartAccountInternal(options);
|
|
531
|
+
return account;
|
|
532
|
+
}
|
|
533
|
+
throw error;
|
|
534
|
+
}
|
|
480
535
|
}
|
|
536
|
+
throw error;
|
|
481
537
|
}
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
Analytics.trackError(error, "getOrCreateSmartAccount");
|
|
482
541
|
throw error;
|
|
483
542
|
}
|
|
484
543
|
}
|
|
@@ -507,7 +566,13 @@ export class EvmClient {
|
|
|
507
566
|
network: options.network,
|
|
508
567
|
},
|
|
509
568
|
});
|
|
510
|
-
|
|
569
|
+
try {
|
|
570
|
+
return await getSwapPrice(CdpOpenApiClient, options);
|
|
571
|
+
}
|
|
572
|
+
catch (error) {
|
|
573
|
+
Analytics.trackError(error, "getSwapPrice");
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
511
576
|
}
|
|
512
577
|
/**
|
|
513
578
|
* Creates a quote for a swap between two tokens on an EVM network.
|
|
@@ -534,7 +599,13 @@ export class EvmClient {
|
|
|
534
599
|
network: options.network,
|
|
535
600
|
},
|
|
536
601
|
});
|
|
537
|
-
|
|
602
|
+
try {
|
|
603
|
+
return await createSwapQuote(CdpOpenApiClient, options);
|
|
604
|
+
}
|
|
605
|
+
catch (error) {
|
|
606
|
+
Analytics.trackError(error, "createSwapQuote");
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
538
609
|
}
|
|
539
610
|
/**
|
|
540
611
|
* Gets a user operation for a smart account by user operation hash.
|
|
@@ -557,7 +628,13 @@ export class EvmClient {
|
|
|
557
628
|
Analytics.trackAction({
|
|
558
629
|
action: "get_user_operation",
|
|
559
630
|
});
|
|
560
|
-
|
|
631
|
+
try {
|
|
632
|
+
return await getUserOperation(CdpOpenApiClient, options);
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
Analytics.trackError(error, "getUserOperation");
|
|
636
|
+
throw error;
|
|
637
|
+
}
|
|
561
638
|
}
|
|
562
639
|
/**
|
|
563
640
|
* Lists CDP EVM accounts.
|
|
@@ -588,20 +665,25 @@ export class EvmClient {
|
|
|
588
665
|
action: "list_accounts",
|
|
589
666
|
accountType: "evm_server",
|
|
590
667
|
});
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
668
|
+
try {
|
|
669
|
+
const ethAccounts = await CdpOpenApiClient.listEvmAccounts({
|
|
670
|
+
pageSize: options.pageSize,
|
|
671
|
+
pageToken: options.pageToken,
|
|
672
|
+
});
|
|
673
|
+
return {
|
|
674
|
+
accounts: ethAccounts.accounts.map(account => {
|
|
675
|
+
const evmAccount = toEvmServerAccount(CdpOpenApiClient, {
|
|
676
|
+
account,
|
|
677
|
+
});
|
|
678
|
+
return evmAccount;
|
|
679
|
+
}),
|
|
680
|
+
nextPageToken: ethAccounts.nextPageToken,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
catch (error) {
|
|
684
|
+
Analytics.trackError(error, "listAccounts");
|
|
685
|
+
throw error;
|
|
686
|
+
}
|
|
605
687
|
}
|
|
606
688
|
/**
|
|
607
689
|
* Lists CDP EVM token balances.
|
|
@@ -644,7 +726,13 @@ export class EvmClient {
|
|
|
644
726
|
network: options.network,
|
|
645
727
|
},
|
|
646
728
|
});
|
|
647
|
-
|
|
729
|
+
try {
|
|
730
|
+
return await listTokenBalances(CdpOpenApiClient, options);
|
|
731
|
+
}
|
|
732
|
+
catch (error) {
|
|
733
|
+
Analytics.trackError(error, "listTokenBalances");
|
|
734
|
+
throw error;
|
|
735
|
+
}
|
|
648
736
|
}
|
|
649
737
|
/**
|
|
650
738
|
* Lists CDP EVM smart accounts.
|
|
@@ -674,19 +762,25 @@ export class EvmClient {
|
|
|
674
762
|
Analytics.trackAction({
|
|
675
763
|
action: "list_smart_accounts",
|
|
676
764
|
});
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
765
|
+
try {
|
|
766
|
+
const smartAccounts = await CdpOpenApiClient.listEvmSmartAccounts({
|
|
767
|
+
pageSize: options.pageSize,
|
|
768
|
+
pageToken: options.pageToken,
|
|
769
|
+
});
|
|
770
|
+
return {
|
|
771
|
+
accounts: smartAccounts.accounts.map(account => ({
|
|
772
|
+
address: account.address,
|
|
773
|
+
owners: [account.owners[0]],
|
|
774
|
+
type: "evm-smart",
|
|
775
|
+
policies: account.policies,
|
|
776
|
+
})),
|
|
777
|
+
nextPageToken: smartAccounts.nextPageToken,
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
catch (error) {
|
|
781
|
+
Analytics.trackError(error, "listSmartAccounts");
|
|
782
|
+
throw error;
|
|
783
|
+
}
|
|
690
784
|
}
|
|
691
785
|
/**
|
|
692
786
|
* Lists the spend permissions for a smart account.
|
|
@@ -702,7 +796,13 @@ export class EvmClient {
|
|
|
702
796
|
Analytics.trackAction({
|
|
703
797
|
action: "list_spend_permissions",
|
|
704
798
|
});
|
|
705
|
-
|
|
799
|
+
try {
|
|
800
|
+
return await listSpendPermissions(CdpOpenApiClient, options);
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
Analytics.trackError(error, "listSpendPermissions");
|
|
804
|
+
throw error;
|
|
805
|
+
}
|
|
706
806
|
}
|
|
707
807
|
/**
|
|
708
808
|
* Prepares a user operation for a smart account.
|
|
@@ -737,27 +837,33 @@ export class EvmClient {
|
|
|
737
837
|
network: options.network,
|
|
738
838
|
},
|
|
739
839
|
});
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
840
|
+
try {
|
|
841
|
+
const userOp = await CdpOpenApiClient.prepareUserOperation(options.smartAccount.address, {
|
|
842
|
+
network: options.network,
|
|
843
|
+
calls: options.calls.map(call => ({
|
|
844
|
+
to: call.to,
|
|
845
|
+
value: call.value.toString(),
|
|
846
|
+
data: call.data,
|
|
847
|
+
overrideGasLimit: call.overrideGasLimit,
|
|
848
|
+
})),
|
|
849
|
+
paymasterUrl: options.paymasterUrl,
|
|
850
|
+
dataSuffix: options.dataSuffix,
|
|
851
|
+
});
|
|
852
|
+
return {
|
|
853
|
+
network: userOp.network,
|
|
854
|
+
userOpHash: userOp.userOpHash,
|
|
855
|
+
status: userOp.status,
|
|
856
|
+
calls: userOp.calls.map(call => ({
|
|
857
|
+
to: call.to,
|
|
858
|
+
value: BigInt(call.value),
|
|
859
|
+
data: call.data,
|
|
860
|
+
})),
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
catch (error) {
|
|
864
|
+
Analytics.trackError(error, "prepareUserOperation");
|
|
865
|
+
throw error;
|
|
866
|
+
}
|
|
761
867
|
}
|
|
762
868
|
/**
|
|
763
869
|
* Prepares and sends a user operation for a smart account.
|
|
@@ -792,20 +898,26 @@ export class EvmClient {
|
|
|
792
898
|
network: options.network,
|
|
793
899
|
},
|
|
794
900
|
});
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
901
|
+
try {
|
|
902
|
+
const userOp = await CdpOpenApiClient.prepareAndSendUserOperation(options.smartAccount.address, {
|
|
903
|
+
network: options.network,
|
|
904
|
+
calls: options.calls.map(call => ({
|
|
905
|
+
to: call.to,
|
|
906
|
+
value: call.value.toString(),
|
|
907
|
+
data: call.data,
|
|
908
|
+
})),
|
|
909
|
+
paymasterUrl: options.paymasterUrl,
|
|
910
|
+
}, options.idempotencyKey);
|
|
911
|
+
return {
|
|
912
|
+
smartAccountAddress: options.smartAccount.address,
|
|
913
|
+
userOpHash: userOp.userOpHash,
|
|
914
|
+
status: userOp.status,
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
catch (error) {
|
|
918
|
+
Analytics.trackError(error, "prepareAndSendUserOperation");
|
|
919
|
+
throw error;
|
|
920
|
+
}
|
|
809
921
|
}
|
|
810
922
|
/**
|
|
811
923
|
* Requests funds from an EVM faucet.
|
|
@@ -834,7 +946,13 @@ export class EvmClient {
|
|
|
834
946
|
network: options.network,
|
|
835
947
|
},
|
|
836
948
|
});
|
|
837
|
-
|
|
949
|
+
try {
|
|
950
|
+
return await requestFaucet(CdpOpenApiClient, options);
|
|
951
|
+
}
|
|
952
|
+
catch (error) {
|
|
953
|
+
Analytics.trackError(error, "requestFaucet");
|
|
954
|
+
throw error;
|
|
955
|
+
}
|
|
838
956
|
}
|
|
839
957
|
/**
|
|
840
958
|
* Signs an EVM transaction and sends it to the specified network using the Coinbase API.
|
|
@@ -889,7 +1007,13 @@ export class EvmClient {
|
|
|
889
1007
|
network: options.network,
|
|
890
1008
|
},
|
|
891
1009
|
});
|
|
892
|
-
|
|
1010
|
+
try {
|
|
1011
|
+
return await sendTransaction(CdpOpenApiClient, options);
|
|
1012
|
+
}
|
|
1013
|
+
catch (error) {
|
|
1014
|
+
Analytics.trackError(error, "sendTransaction");
|
|
1015
|
+
throw error;
|
|
1016
|
+
}
|
|
893
1017
|
}
|
|
894
1018
|
/**
|
|
895
1019
|
* Sends a user operation.
|
|
@@ -926,14 +1050,20 @@ export class EvmClient {
|
|
|
926
1050
|
network: options.network,
|
|
927
1051
|
},
|
|
928
1052
|
});
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1053
|
+
try {
|
|
1054
|
+
return await sendUserOperation(CdpOpenApiClient, {
|
|
1055
|
+
smartAccount: options.smartAccount,
|
|
1056
|
+
network: options.network,
|
|
1057
|
+
calls: options.calls,
|
|
1058
|
+
paymasterUrl: options.paymasterUrl,
|
|
1059
|
+
idempotencyKey: options.idempotencyKey,
|
|
1060
|
+
dataSuffix: options.dataSuffix,
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
catch (error) {
|
|
1064
|
+
Analytics.trackError(error, "sendUserOperation");
|
|
1065
|
+
throw error;
|
|
1066
|
+
}
|
|
937
1067
|
}
|
|
938
1068
|
/**
|
|
939
1069
|
* Signs an EVM hash.
|
|
@@ -960,12 +1090,18 @@ export class EvmClient {
|
|
|
960
1090
|
Analytics.trackAction({
|
|
961
1091
|
action: "sign_hash",
|
|
962
1092
|
});
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1093
|
+
try {
|
|
1094
|
+
const signature = await CdpOpenApiClient.signEvmHash(options.address, {
|
|
1095
|
+
hash: options.hash,
|
|
1096
|
+
}, options.idempotencyKey);
|
|
1097
|
+
return {
|
|
1098
|
+
signature: signature.signature,
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
catch (error) {
|
|
1102
|
+
Analytics.trackError(error, "signHash");
|
|
1103
|
+
throw error;
|
|
1104
|
+
}
|
|
969
1105
|
}
|
|
970
1106
|
/**
|
|
971
1107
|
* Signs an EIP-191 message.
|
|
@@ -992,12 +1128,18 @@ export class EvmClient {
|
|
|
992
1128
|
Analytics.trackAction({
|
|
993
1129
|
action: "sign_message",
|
|
994
1130
|
});
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1131
|
+
try {
|
|
1132
|
+
const signature = await CdpOpenApiClient.signEvmMessage(options.address, {
|
|
1133
|
+
message: options.message,
|
|
1134
|
+
}, options.idempotencyKey);
|
|
1135
|
+
return {
|
|
1136
|
+
signature: signature.signature,
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
catch (error) {
|
|
1140
|
+
Analytics.trackError(error, "signMessage");
|
|
1141
|
+
throw error;
|
|
1142
|
+
}
|
|
1001
1143
|
}
|
|
1002
1144
|
/**
|
|
1003
1145
|
* Signs an EIP-712 message.
|
|
@@ -1048,21 +1190,27 @@ export class EvmClient {
|
|
|
1048
1190
|
Analytics.trackAction({
|
|
1049
1191
|
action: "sign_typed_data",
|
|
1050
1192
|
});
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1193
|
+
try {
|
|
1194
|
+
const { domain, message, primaryType } = options;
|
|
1195
|
+
const types = {
|
|
1196
|
+
EIP712Domain: getTypesForEIP712Domain({ domain }),
|
|
1197
|
+
...options.types,
|
|
1198
|
+
};
|
|
1199
|
+
const openApiMessage = {
|
|
1200
|
+
domain,
|
|
1201
|
+
types,
|
|
1202
|
+
primaryType,
|
|
1203
|
+
message,
|
|
1204
|
+
};
|
|
1205
|
+
const signature = await CdpOpenApiClient.signEvmTypedData(options.address, openApiMessage, options.idempotencyKey);
|
|
1206
|
+
return {
|
|
1207
|
+
signature: signature.signature,
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
catch (error) {
|
|
1211
|
+
Analytics.trackError(error, "signTypedData");
|
|
1212
|
+
throw error;
|
|
1213
|
+
}
|
|
1066
1214
|
}
|
|
1067
1215
|
/**
|
|
1068
1216
|
* Signs an EVM transaction.
|
|
@@ -1098,12 +1246,18 @@ export class EvmClient {
|
|
|
1098
1246
|
Analytics.trackAction({
|
|
1099
1247
|
action: "sign_transaction",
|
|
1100
1248
|
});
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1249
|
+
try {
|
|
1250
|
+
const signature = await CdpOpenApiClient.signEvmTransaction(options.address, {
|
|
1251
|
+
transaction: options.transaction,
|
|
1252
|
+
}, options.idempotencyKey);
|
|
1253
|
+
return {
|
|
1254
|
+
signature: signature.signedTransaction,
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
catch (error) {
|
|
1258
|
+
Analytics.trackError(error, "signTransaction");
|
|
1259
|
+
throw error;
|
|
1260
|
+
}
|
|
1107
1261
|
}
|
|
1108
1262
|
/**
|
|
1109
1263
|
* Updates a CDP EVM account.
|
|
@@ -1150,12 +1304,17 @@ export class EvmClient {
|
|
|
1150
1304
|
Analytics.trackAction({
|
|
1151
1305
|
action: "update_account",
|
|
1152
1306
|
});
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
account
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1307
|
+
try {
|
|
1308
|
+
const openApiAccount = await CdpOpenApiClient.updateEvmAccount(options.address, options.update, options.idempotencyKey);
|
|
1309
|
+
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
1310
|
+
account: openApiAccount,
|
|
1311
|
+
});
|
|
1312
|
+
return account;
|
|
1313
|
+
}
|
|
1314
|
+
catch (error) {
|
|
1315
|
+
Analytics.trackError(error, "updateAccount");
|
|
1316
|
+
throw error;
|
|
1317
|
+
}
|
|
1159
1318
|
}
|
|
1160
1319
|
/**
|
|
1161
1320
|
* Updates a CDP EVM smart account.
|
|
@@ -1173,13 +1332,107 @@ export class EvmClient {
|
|
|
1173
1332
|
Analytics.trackAction({
|
|
1174
1333
|
action: "update_smart_account",
|
|
1175
1334
|
});
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
smartAccount
|
|
1179
|
-
|
|
1335
|
+
try {
|
|
1336
|
+
const openApiSmartAccount = await CdpOpenApiClient.updateEvmSmartAccount(options.address, options.update, options.idempotencyKey);
|
|
1337
|
+
const smartAccount = toEvmSmartAccount(CdpOpenApiClient, {
|
|
1338
|
+
smartAccount: openApiSmartAccount,
|
|
1339
|
+
owner: options.owner,
|
|
1340
|
+
});
|
|
1341
|
+
return smartAccount;
|
|
1342
|
+
}
|
|
1343
|
+
catch (error) {
|
|
1344
|
+
Analytics.trackError(error, "updateSmartAccount");
|
|
1345
|
+
throw error;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Creates an EIP-7702 delegation for an EVM EOA account, upgrading it with smart account capabilities.
|
|
1350
|
+
* The delegation allows the EVM EOA to be used as a smart account, which enables batched transactions and gas sponsorship via paymaster.
|
|
1351
|
+
*
|
|
1352
|
+
* @param {CreateEvmEip7702DelegationOptions} options - The delegation parameters (address and network required, enableSpendPermissions and idempotencyKey optional).
|
|
1353
|
+
* @returns A promise that resolves to the delegation result including the delegation operation ID.
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* ```ts
|
|
1357
|
+
* const result = await cdp.evm.createEvmEip7702Delegation({
|
|
1358
|
+
* address: account.address,
|
|
1359
|
+
* network: "base-sepolia",
|
|
1360
|
+
* enableSpendPermissions: false,
|
|
1361
|
+
* });
|
|
1362
|
+
* console.log(result.delegationOperationId);
|
|
1363
|
+
* ```
|
|
1364
|
+
*/
|
|
1365
|
+
async createEvmEip7702Delegation(options) {
|
|
1366
|
+
Analytics.trackAction({
|
|
1367
|
+
action: "create_eip7702_delegation",
|
|
1180
1368
|
});
|
|
1181
|
-
|
|
1182
|
-
|
|
1369
|
+
try {
|
|
1370
|
+
const { address, network, enableSpendPermissions, idempotencyKey } = options;
|
|
1371
|
+
const body = {
|
|
1372
|
+
network,
|
|
1373
|
+
...(enableSpendPermissions !== undefined && { enableSpendPermissions }),
|
|
1374
|
+
};
|
|
1375
|
+
return await CdpOpenApiClient.createEvmEip7702Delegation(address, body, idempotencyKey);
|
|
1376
|
+
}
|
|
1377
|
+
catch (error) {
|
|
1378
|
+
Analytics.trackError(error, "createEvmEip7702Delegation");
|
|
1379
|
+
throw error;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Gets the EIP-7702 delegation operation status.
|
|
1384
|
+
*
|
|
1385
|
+
* @param {string} delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
|
|
1386
|
+
* @returns A promise that resolves to the delegation operation status.
|
|
1387
|
+
*
|
|
1388
|
+
* @example
|
|
1389
|
+
* ```ts
|
|
1390
|
+
* const operation = await cdp.evm.getEvmEip7702DelegationOperationById(
|
|
1391
|
+
* "delegation-op-123",
|
|
1392
|
+
* );
|
|
1393
|
+
* console.log(operation.status); // "PENDING" | "SUBMITTED" | "COMPLETED" | "FAILED"
|
|
1394
|
+
* ```
|
|
1395
|
+
*/
|
|
1396
|
+
async getEvmEip7702DelegationOperationById(delegationOperationId) {
|
|
1397
|
+
Analytics.trackAction({
|
|
1398
|
+
action: "get_eip7702_delegation_operation_by_id",
|
|
1399
|
+
});
|
|
1400
|
+
try {
|
|
1401
|
+
return await CdpOpenApiClient.getEvmEip7702DelegationOperationById(delegationOperationId);
|
|
1402
|
+
}
|
|
1403
|
+
catch (error) {
|
|
1404
|
+
Analytics.trackError(error, "getEvmEip7702DelegationOperationById");
|
|
1405
|
+
throw error;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Polls the EIP-7702 delegation operation status until the status is COMPLETED or a timeout occurs.
|
|
1410
|
+
*
|
|
1411
|
+
* @param {WaitForEvmEip7702DelegationOperationStatusOptions} options - Parameters for waiting, including delegationOperationId and optional wait configuration.
|
|
1412
|
+
* @param {string} options.delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
|
|
1413
|
+
* @param {WaitOptions} [options.waitOptions] - Optional parameters for the wait operation.
|
|
1414
|
+
*
|
|
1415
|
+
* @returns A promise that resolves to the delegation operation once it reaches COMPLETED.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* ```ts
|
|
1419
|
+
* const operation = await cdp.evm.waitForEvmEip7702DelegationOperationStatus({
|
|
1420
|
+
* delegationOperationId: "delegation-op-123",
|
|
1421
|
+
* });
|
|
1422
|
+
* console.log(operation.status); // "COMPLETED"
|
|
1423
|
+
* ```
|
|
1424
|
+
*/
|
|
1425
|
+
async waitForEvmEip7702DelegationOperationStatus(options) {
|
|
1426
|
+
Analytics.trackAction({
|
|
1427
|
+
action: "wait_for_eip7702_delegation_operation_status",
|
|
1428
|
+
});
|
|
1429
|
+
try {
|
|
1430
|
+
return await waitForEvmEip7702DelegationOperationStatus(CdpOpenApiClient, options);
|
|
1431
|
+
}
|
|
1432
|
+
catch (error) {
|
|
1433
|
+
Analytics.trackError(error, "waitForEvmEip7702DelegationOperationStatus");
|
|
1434
|
+
throw error;
|
|
1435
|
+
}
|
|
1183
1436
|
}
|
|
1184
1437
|
/**
|
|
1185
1438
|
* Waits for a user operation to complete or fail.
|
|
@@ -1217,9 +1470,15 @@ export class EvmClient {
|
|
|
1217
1470
|
Analytics.trackAction({
|
|
1218
1471
|
action: "wait_for_user_operation",
|
|
1219
1472
|
});
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1473
|
+
try {
|
|
1474
|
+
return await waitForUserOperation(CdpOpenApiClient, {
|
|
1475
|
+
...options,
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
catch (error) {
|
|
1479
|
+
Analytics.trackError(error, "waitForUserOperation");
|
|
1480
|
+
throw error;
|
|
1481
|
+
}
|
|
1223
1482
|
}
|
|
1224
1483
|
/**
|
|
1225
1484
|
* Internal method to create an account without tracking analytics.
|
|
@@ -1236,7 +1495,6 @@ export class EvmClient {
|
|
|
1236
1495
|
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
1237
1496
|
account: openApiAccount,
|
|
1238
1497
|
});
|
|
1239
|
-
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
1240
1498
|
return account;
|
|
1241
1499
|
}
|
|
1242
1500
|
/**
|
|
@@ -1259,7 +1517,6 @@ export class EvmClient {
|
|
|
1259
1517
|
const account = toEvmServerAccount(CdpOpenApiClient, {
|
|
1260
1518
|
account: openApiAccount,
|
|
1261
1519
|
});
|
|
1262
|
-
Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
1263
1520
|
return account;
|
|
1264
1521
|
}
|
|
1265
1522
|
/**
|
|
@@ -1282,7 +1539,6 @@ export class EvmClient {
|
|
|
1282
1539
|
smartAccount: openApiSmartAccount,
|
|
1283
1540
|
owner: options.owner,
|
|
1284
1541
|
});
|
|
1285
|
-
Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
1286
1542
|
return smartAccount;
|
|
1287
1543
|
}
|
|
1288
1544
|
/**
|
|
@@ -1313,7 +1569,6 @@ Provided Owner Address: ${options.owner.address}\n`);
|
|
|
1313
1569
|
smartAccount: openApiSmartAccount,
|
|
1314
1570
|
owner: options.owner,
|
|
1315
1571
|
});
|
|
1316
|
-
Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
1317
1572
|
return smartAccount;
|
|
1318
1573
|
}
|
|
1319
1574
|
}
|