@coinbase/cdp-sdk 1.44.1 → 1.46.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 +28 -2
- package/README.md +164 -43
- package/_cjs/accounts/evm/eip6492.js +49 -0
- package/_cjs/accounts/evm/eip6492.js.map +1 -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 +115 -45
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.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/actions/solana/transfer.js.map +1 -1
- package/_cjs/actions/solana/utils.js +9 -9
- package/_cjs/actions/solana/utils.js.map +1 -1
- package/_cjs/analytics.js +10 -228
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/auth/utils/http.js +1 -0
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/client/cdp.js +4 -7
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +385 -4
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/end-user/toEndUserAccount.js +201 -23
- package/_cjs/client/end-user/toEndUserAccount.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 +215 -118
- 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/cdpApiClient.js +32 -0
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +178 -9
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +261 -0
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.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/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/faucets/faucets.js +6 -5
- package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.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/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/sql-api/sql-api.js +75 -0
- package/_cjs/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_cjs/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -1
- package/_cjs/openapi-client/index.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/utils/export.js +6 -5
- package/_cjs/utils/export.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/eip6492.js +46 -0
- package/_esm/accounts/evm/eip6492.js.map +1 -0
- 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 +115 -45
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.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/actions/solana/transfer.js.map +1 -1
- package/_esm/actions/solana/utils.js +9 -9
- package/_esm/actions/solana/utils.js.map +1 -1
- package/_esm/analytics.js +9 -227
- package/_esm/analytics.js.map +1 -1
- package/_esm/auth/utils/http.js +1 -0
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/client/cdp.js +4 -7
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +385 -4
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/end-user/toEndUserAccount.js +201 -23
- package/_esm/client/end-user/toEndUserAccount.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 +215 -118
- 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/cdpApiClient.js +32 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +175 -7
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +243 -0
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.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/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/faucets/faucets.js +6 -5
- package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_esm/openapi-client/generated/onchain-data/onchain-data.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/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/sql-api/sql-api.js +70 -0
- package/_esm/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_esm/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -1
- package/_esm/openapi-client/index.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/utils/export.js +6 -5
- package/_esm/utils/export.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/eip6492.d.ts +17 -0
- package/_types/accounts/evm/eip6492.d.ts.map +1 -0
- 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/evm/toNetworkScopedEvmSmartAccount.d.ts +4 -4
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -2
- package/_types/accounts/evm/types.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/actions/solana/transfer.d.ts +3 -4
- package/_types/actions/solana/transfer.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +79 -29
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +10 -9
- package/_types/actions/solana/utils.d.ts.map +1 -1
- package/_types/analytics.d.ts +5 -38
- package/_types/analytics.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +4 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +272 -1
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +491 -1
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/end-user/toEndUserAccount.d.ts +4 -1
- package/_types/client/end-user/toEndUserAccount.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 +38 -12
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +884 -90
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +163 -0
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +1 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +9 -9
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +35 -15
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +14 -14
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts +3 -3
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/faucets/faucets.d.ts +9 -8
- package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -1
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +3 -3
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +12 -5
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +6 -6
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +12 -12
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts +73 -0
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts.map +1 -0
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts.map +1 -1
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +4 -4
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +23 -3
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/evmSchema.d.ts +3128 -1064
- 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/types/contract.d.ts.map +1 -1
- package/_types/utils/export.d.ts +1 -1
- package/_types/utils/export.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/eip6492.ts +60 -0
- package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
- package/accounts/evm/toEvmServerAccount.ts +115 -67
- package/accounts/evm/toEvmSmartAccount.ts +114 -57
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +44 -5
- package/accounts/evm/types.ts +8 -3
- package/accounts/solana/toSolanaAccount.ts +44 -24
- package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
- package/actions/solana/transfer.ts +3 -3
- package/actions/solana/types.ts +79 -29
- package/actions/solana/utils.ts +13 -11
- package/analytics.ts +8 -294
- package/auth/utils/http.ts +1 -0
- package/client/cdp.ts +6 -8
- package/client/end-user/endUser.ts +513 -4
- package/client/end-user/endUser.types.ts +598 -0
- package/client/end-user/toEndUserAccount.ts +330 -26
- package/client/evm/evm.ts +517 -282
- package/client/evm/evm.types.ts +45 -2
- package/client/policies/policies.ts +41 -16
- package/client/solana/solana.ts +233 -153
- package/index.ts +36 -1
- package/openapi-client/cdpApiClient.ts +34 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +1155 -172
- package/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts +455 -0
- package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +12 -9
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +66 -14
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +16 -16
- package/openapi-client/generated/evm-swaps/evm-swaps.ts +3 -3
- package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +2 -2
- package/openapi-client/generated/faucets/faucets.ts +9 -8
- package/openapi-client/generated/onchain-data/onchain-data.ts +3 -3
- package/openapi-client/generated/onramp/onramp.ts +28 -4
- package/openapi-client/generated/policy-engine/policy-engine.ts +12 -6
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +12 -12
- package/openapi-client/generated/solana-token-balances/solana-token-balances.ts +2 -2
- package/openapi-client/generated/sql-api/sql-api.ts +92 -0
- package/openapi-client/generated/webhooks/webhooks.ts +6 -6
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +6 -4
- package/openapi-client/index.ts +4 -1
- package/package.json +7 -8
- package/policies/evmSchema.ts +164 -0
- package/policies/solanaSchema.ts +130 -0
- package/policies/types.ts +14 -0
- package/types/contract.ts +2 -4
- package/utils/export.ts +6 -5
- package/version.ts +1 -1
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -55
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -50
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts +0 -53
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts.map +0 -1
- package/openapi-client/generated/sql-api-alpha/sql-api-alpha.ts +0 -72
package/_cjs/client/evm/evm.js
CHANGED
|
@@ -17,6 +17,7 @@ const sendUserOperation_js_1 = require("../../actions/evm/sendUserOperation.js")
|
|
|
17
17
|
const resolveSpendPermission_js_1 = require("../../actions/evm/spend-permissions/resolveSpendPermission.js");
|
|
18
18
|
const createSwapQuote_js_1 = require("../../actions/evm/swap/createSwapQuote.js");
|
|
19
19
|
const getSwapPrice_js_1 = require("../../actions/evm/swap/getSwapPrice.js");
|
|
20
|
+
const waitForEvmEip7702DelegationStatus_js_1 = require("../../actions/evm/waitForEvmEip7702DelegationStatus.js");
|
|
20
21
|
const waitForUserOperation_js_1 = require("../../actions/evm/waitForUserOperation.js");
|
|
21
22
|
const analytics_js_1 = require("../../analytics.js");
|
|
22
23
|
const constants_js_1 = require("../../constants.js");
|
|
@@ -68,7 +69,13 @@ class EvmClient {
|
|
|
68
69
|
action: "create_account",
|
|
69
70
|
accountType: "evm_server",
|
|
70
71
|
});
|
|
71
|
-
|
|
72
|
+
try {
|
|
73
|
+
return await this._createAccountInternal(options);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
analytics_js_1.Analytics.trackError(error, "createAccount");
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
72
79
|
}
|
|
73
80
|
/**
|
|
74
81
|
* Imports a CDP EVM account from an external source.
|
|
@@ -117,14 +124,14 @@ class EvmClient {
|
|
|
117
124
|
action: "import_account",
|
|
118
125
|
accountType: "evm_server",
|
|
119
126
|
});
|
|
120
|
-
const encryptionPublicKey = options.encryptionPublicKey || constants_js_1.ImportAccountPublicRSAKey;
|
|
121
|
-
const privateKeyHex = options.privateKey.startsWith("0x")
|
|
122
|
-
? options.privateKey.slice(2)
|
|
123
|
-
: options.privateKey;
|
|
124
|
-
if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
|
|
125
|
-
throw new errors_js_1.UserInputValidationError("Private key must be a valid hexadecimal string");
|
|
126
|
-
}
|
|
127
127
|
try {
|
|
128
|
+
const encryptionPublicKey = options.encryptionPublicKey || constants_js_1.ImportAccountPublicRSAKey;
|
|
129
|
+
const privateKeyHex = options.privateKey.startsWith("0x")
|
|
130
|
+
? options.privateKey.slice(2)
|
|
131
|
+
: options.privateKey;
|
|
132
|
+
if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
|
|
133
|
+
throw new errors_js_1.UserInputValidationError("Private key must be a valid hexadecimal string");
|
|
134
|
+
}
|
|
128
135
|
const privateKeyBytes = Buffer.from(privateKeyHex, "hex");
|
|
129
136
|
const encryptedPrivateKey = (0, crypto_1.publicEncrypt)({
|
|
130
137
|
key: encryptionPublicKey,
|
|
@@ -138,10 +145,12 @@ class EvmClient {
|
|
|
138
145
|
const account = (0, toEvmServerAccount_js_1.toEvmServerAccount)(index_js_1.CdpOpenApiClient, {
|
|
139
146
|
account: openApiAccount,
|
|
140
147
|
});
|
|
141
|
-
analytics_js_1.Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
142
148
|
return account;
|
|
143
149
|
}
|
|
144
150
|
catch (error) {
|
|
151
|
+
if (!(error instanceof errors_js_1.UserInputValidationError)) {
|
|
152
|
+
analytics_js_1.Analytics.trackError(error, "importAccount");
|
|
153
|
+
}
|
|
145
154
|
if (error instanceof errors_js_2.APIError) {
|
|
146
155
|
throw error;
|
|
147
156
|
}
|
|
@@ -178,21 +187,29 @@ class EvmClient {
|
|
|
178
187
|
action: "export_account",
|
|
179
188
|
accountType: "evm_server",
|
|
180
189
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
try {
|
|
191
|
+
const { publicKey, privateKey } = await (0, export_js_1.generateExportEncryptionKeyPair)();
|
|
192
|
+
const { encryptedPrivateKey } = await (async () => {
|
|
193
|
+
if (options.address) {
|
|
194
|
+
return index_js_1.CdpOpenApiClient.exportEvmAccount(options.address, {
|
|
195
|
+
exportEncryptionKey: publicKey,
|
|
196
|
+
}, options.idempotencyKey);
|
|
197
|
+
}
|
|
198
|
+
if (options.name) {
|
|
199
|
+
return index_js_1.CdpOpenApiClient.exportEvmAccountByName(options.name, {
|
|
200
|
+
exportEncryptionKey: publicKey,
|
|
201
|
+
}, options.idempotencyKey);
|
|
202
|
+
}
|
|
203
|
+
throw new errors_js_1.UserInputValidationError("Either address or name must be provided");
|
|
204
|
+
})();
|
|
205
|
+
return (0, export_js_1.decryptWithPrivateKey)(privateKey, encryptedPrivateKey);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (!(error instanceof errors_js_1.UserInputValidationError)) {
|
|
209
|
+
analytics_js_1.Analytics.trackError(error, "exportAccount");
|
|
192
210
|
}
|
|
193
|
-
throw
|
|
194
|
-
}
|
|
195
|
-
return (0, export_js_1.decryptWithPrivateKey)(privateKey, encryptedPrivateKey);
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
196
213
|
}
|
|
197
214
|
/**
|
|
198
215
|
* Creates a new CDP EVM smart account.
|
|
@@ -244,7 +261,13 @@ class EvmClient {
|
|
|
244
261
|
action: "create_smart_account",
|
|
245
262
|
accountType: "evm_smart",
|
|
246
263
|
});
|
|
247
|
-
|
|
264
|
+
try {
|
|
265
|
+
return await this._createSmartAccountInternal(options);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
analytics_js_1.Analytics.trackError(error, "createSmartAccount");
|
|
269
|
+
throw error;
|
|
270
|
+
}
|
|
248
271
|
}
|
|
249
272
|
/**
|
|
250
273
|
* Creates a spend permission for a smart account.
|
|
@@ -267,29 +290,35 @@ class EvmClient {
|
|
|
267
290
|
analytics_js_1.Analytics.trackAction({
|
|
268
291
|
action: "create_spend_permission",
|
|
269
292
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
try {
|
|
294
|
+
const resolvedSpendPermission = (0, resolveSpendPermission_js_1.resolveSpendPermission)(options.spendPermission, options.network);
|
|
295
|
+
const userOperation = await index_js_1.CdpOpenApiClient.createSpendPermission(resolvedSpendPermission.account, {
|
|
296
|
+
spender: resolvedSpendPermission.spender,
|
|
297
|
+
token: resolvedSpendPermission.token,
|
|
298
|
+
allowance: resolvedSpendPermission.allowance.toString(),
|
|
299
|
+
period: resolvedSpendPermission.period.toString(),
|
|
300
|
+
start: resolvedSpendPermission.start.toString(),
|
|
301
|
+
end: resolvedSpendPermission.end.toString(),
|
|
302
|
+
salt: resolvedSpendPermission.salt.toString(),
|
|
303
|
+
extraData: resolvedSpendPermission.extraData,
|
|
304
|
+
network: options.network,
|
|
305
|
+
paymasterUrl: options.paymasterUrl,
|
|
306
|
+
}, options.idempotencyKey);
|
|
307
|
+
return {
|
|
308
|
+
network: userOperation.network,
|
|
309
|
+
userOpHash: userOperation.userOpHash,
|
|
310
|
+
status: userOperation.status,
|
|
311
|
+
calls: userOperation.calls.map(call => ({
|
|
312
|
+
to: call.to,
|
|
313
|
+
value: BigInt(call.value),
|
|
314
|
+
data: call.data,
|
|
315
|
+
})),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
analytics_js_1.Analytics.trackError(error, "createSpendPermission");
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
293
322
|
}
|
|
294
323
|
/**
|
|
295
324
|
* Revokes a spend permission for a smart account.
|
|
@@ -315,21 +344,27 @@ class EvmClient {
|
|
|
315
344
|
analytics_js_1.Analytics.trackAction({
|
|
316
345
|
action: "revoke_spend_permission",
|
|
317
346
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
347
|
+
try {
|
|
348
|
+
const userOperation = await index_js_1.CdpOpenApiClient.revokeSpendPermission(options.address, {
|
|
349
|
+
network: options.network,
|
|
350
|
+
permissionHash: options.permissionHash,
|
|
351
|
+
paymasterUrl: options.paymasterUrl,
|
|
352
|
+
}, options.idempotencyKey);
|
|
353
|
+
return {
|
|
354
|
+
network: userOperation.network,
|
|
355
|
+
userOpHash: userOperation.userOpHash,
|
|
356
|
+
status: userOperation.status,
|
|
357
|
+
calls: userOperation.calls.map(call => ({
|
|
358
|
+
to: call.to,
|
|
359
|
+
value: BigInt(call.value),
|
|
360
|
+
data: call.data,
|
|
361
|
+
})),
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
analytics_js_1.Analytics.trackError(error, "revokeSpendPermission");
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
333
368
|
}
|
|
334
369
|
/**
|
|
335
370
|
* Gets a CDP EVM account.
|
|
@@ -361,7 +396,13 @@ class EvmClient {
|
|
|
361
396
|
action: "get_account",
|
|
362
397
|
accountType: "evm_server",
|
|
363
398
|
});
|
|
364
|
-
|
|
399
|
+
try {
|
|
400
|
+
return await this._getAccountInternal(options);
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
analytics_js_1.Analytics.trackError(error, "getAccount");
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
365
406
|
}
|
|
366
407
|
/**
|
|
367
408
|
* Gets a CDP EVM smart account.
|
|
@@ -389,7 +430,13 @@ class EvmClient {
|
|
|
389
430
|
analytics_js_1.Analytics.trackAction({
|
|
390
431
|
action: "get_smart_account",
|
|
391
432
|
});
|
|
392
|
-
|
|
433
|
+
try {
|
|
434
|
+
return await this._getSmartAccountInternal(options);
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
analytics_js_1.Analytics.trackError(error, "getSmartAccount");
|
|
438
|
+
throw error;
|
|
439
|
+
}
|
|
393
440
|
}
|
|
394
441
|
/**
|
|
395
442
|
* Gets a CDP EVM account, or creates one if it doesn't exist.
|
|
@@ -412,27 +459,33 @@ class EvmClient {
|
|
|
412
459
|
accountType: "evm_server",
|
|
413
460
|
});
|
|
414
461
|
try {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
// If it failed because the account already exists, get the existing account
|
|
428
|
-
const doesAccountAlreadyExist = error instanceof errors_js_2.APIError && error.statusCode === 409;
|
|
429
|
-
if (doesAccountAlreadyExist) {
|
|
430
|
-
const account = await this._getAccountInternal(options);
|
|
462
|
+
try {
|
|
463
|
+
const account = await this._getAccountInternal(options);
|
|
464
|
+
return account;
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
// If it failed because the account doesn't exist, create it
|
|
468
|
+
const doesAccountNotExist = error instanceof errors_js_2.APIError && error.statusCode === 404;
|
|
469
|
+
if (doesAccountNotExist) {
|
|
470
|
+
try {
|
|
471
|
+
const account = await this._createAccountInternal(options);
|
|
431
472
|
return account;
|
|
432
473
|
}
|
|
433
|
-
|
|
474
|
+
catch (error) {
|
|
475
|
+
// If it failed because the account already exists, get the existing account
|
|
476
|
+
const doesAccountAlreadyExist = error instanceof errors_js_2.APIError && error.statusCode === 409;
|
|
477
|
+
if (doesAccountAlreadyExist) {
|
|
478
|
+
const account = await this._getAccountInternal(options);
|
|
479
|
+
return account;
|
|
480
|
+
}
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
434
483
|
}
|
|
484
|
+
throw error;
|
|
435
485
|
}
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
analytics_js_1.Analytics.trackError(error, "getOrCreateAccount");
|
|
436
489
|
throw error;
|
|
437
490
|
}
|
|
438
491
|
}
|
|
@@ -461,27 +514,33 @@ class EvmClient {
|
|
|
461
514
|
accountType: "evm_smart",
|
|
462
515
|
});
|
|
463
516
|
try {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
catch (error) {
|
|
476
|
-
// If it failed because the account already exists, get the existing account
|
|
477
|
-
const doesAccountAlreadyExist = error instanceof errors_js_2.APIError && error.statusCode === 409;
|
|
478
|
-
if (doesAccountAlreadyExist) {
|
|
479
|
-
const account = await this._getSmartAccountInternal(options);
|
|
517
|
+
try {
|
|
518
|
+
const account = await this._getSmartAccountInternal(options);
|
|
519
|
+
return account;
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
// If it failed because the account doesn't exist, create it
|
|
523
|
+
const doesAccountNotExist = error instanceof errors_js_2.APIError && error.statusCode === 404;
|
|
524
|
+
if (doesAccountNotExist) {
|
|
525
|
+
try {
|
|
526
|
+
const account = await this._createSmartAccountInternal(options);
|
|
480
527
|
return account;
|
|
481
528
|
}
|
|
482
|
-
|
|
529
|
+
catch (error) {
|
|
530
|
+
// If it failed because the account already exists, get the existing account
|
|
531
|
+
const doesAccountAlreadyExist = error instanceof errors_js_2.APIError && error.statusCode === 409;
|
|
532
|
+
if (doesAccountAlreadyExist) {
|
|
533
|
+
const account = await this._getSmartAccountInternal(options);
|
|
534
|
+
return account;
|
|
535
|
+
}
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
483
538
|
}
|
|
539
|
+
throw error;
|
|
484
540
|
}
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
analytics_js_1.Analytics.trackError(error, "getOrCreateSmartAccount");
|
|
485
544
|
throw error;
|
|
486
545
|
}
|
|
487
546
|
}
|
|
@@ -510,7 +569,13 @@ class EvmClient {
|
|
|
510
569
|
network: options.network,
|
|
511
570
|
},
|
|
512
571
|
});
|
|
513
|
-
|
|
572
|
+
try {
|
|
573
|
+
return await (0, getSwapPrice_js_1.getSwapPrice)(index_js_1.CdpOpenApiClient, options);
|
|
574
|
+
}
|
|
575
|
+
catch (error) {
|
|
576
|
+
analytics_js_1.Analytics.trackError(error, "getSwapPrice");
|
|
577
|
+
throw error;
|
|
578
|
+
}
|
|
514
579
|
}
|
|
515
580
|
/**
|
|
516
581
|
* Creates a quote for a swap between two tokens on an EVM network.
|
|
@@ -537,7 +602,13 @@ class EvmClient {
|
|
|
537
602
|
network: options.network,
|
|
538
603
|
},
|
|
539
604
|
});
|
|
540
|
-
|
|
605
|
+
try {
|
|
606
|
+
return await (0, createSwapQuote_js_1.createSwapQuote)(index_js_1.CdpOpenApiClient, options);
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
analytics_js_1.Analytics.trackError(error, "createSwapQuote");
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
541
612
|
}
|
|
542
613
|
/**
|
|
543
614
|
* Gets a user operation for a smart account by user operation hash.
|
|
@@ -560,7 +631,13 @@ class EvmClient {
|
|
|
560
631
|
analytics_js_1.Analytics.trackAction({
|
|
561
632
|
action: "get_user_operation",
|
|
562
633
|
});
|
|
563
|
-
|
|
634
|
+
try {
|
|
635
|
+
return await (0, getUserOperation_js_1.getUserOperation)(index_js_1.CdpOpenApiClient, options);
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
analytics_js_1.Analytics.trackError(error, "getUserOperation");
|
|
639
|
+
throw error;
|
|
640
|
+
}
|
|
564
641
|
}
|
|
565
642
|
/**
|
|
566
643
|
* Lists CDP EVM accounts.
|
|
@@ -591,20 +668,25 @@ class EvmClient {
|
|
|
591
668
|
action: "list_accounts",
|
|
592
669
|
accountType: "evm_server",
|
|
593
670
|
});
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
671
|
+
try {
|
|
672
|
+
const ethAccounts = await index_js_1.CdpOpenApiClient.listEvmAccounts({
|
|
673
|
+
pageSize: options.pageSize,
|
|
674
|
+
pageToken: options.pageToken,
|
|
675
|
+
});
|
|
676
|
+
return {
|
|
677
|
+
accounts: ethAccounts.accounts.map(account => {
|
|
678
|
+
const evmAccount = (0, toEvmServerAccount_js_1.toEvmServerAccount)(index_js_1.CdpOpenApiClient, {
|
|
679
|
+
account,
|
|
680
|
+
});
|
|
681
|
+
return evmAccount;
|
|
682
|
+
}),
|
|
683
|
+
nextPageToken: ethAccounts.nextPageToken,
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
catch (error) {
|
|
687
|
+
analytics_js_1.Analytics.trackError(error, "listAccounts");
|
|
688
|
+
throw error;
|
|
689
|
+
}
|
|
608
690
|
}
|
|
609
691
|
/**
|
|
610
692
|
* Lists CDP EVM token balances.
|
|
@@ -647,7 +729,13 @@ class EvmClient {
|
|
|
647
729
|
network: options.network,
|
|
648
730
|
},
|
|
649
731
|
});
|
|
650
|
-
|
|
732
|
+
try {
|
|
733
|
+
return await (0, listTokenBalances_js_1.listTokenBalances)(index_js_1.CdpOpenApiClient, options);
|
|
734
|
+
}
|
|
735
|
+
catch (error) {
|
|
736
|
+
analytics_js_1.Analytics.trackError(error, "listTokenBalances");
|
|
737
|
+
throw error;
|
|
738
|
+
}
|
|
651
739
|
}
|
|
652
740
|
/**
|
|
653
741
|
* Lists CDP EVM smart accounts.
|
|
@@ -677,19 +765,25 @@ class EvmClient {
|
|
|
677
765
|
analytics_js_1.Analytics.trackAction({
|
|
678
766
|
action: "list_smart_accounts",
|
|
679
767
|
});
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
768
|
+
try {
|
|
769
|
+
const smartAccounts = await index_js_1.CdpOpenApiClient.listEvmSmartAccounts({
|
|
770
|
+
pageSize: options.pageSize,
|
|
771
|
+
pageToken: options.pageToken,
|
|
772
|
+
});
|
|
773
|
+
return {
|
|
774
|
+
accounts: smartAccounts.accounts.map(account => ({
|
|
775
|
+
address: account.address,
|
|
776
|
+
owners: [account.owners[0]],
|
|
777
|
+
type: "evm-smart",
|
|
778
|
+
policies: account.policies,
|
|
779
|
+
})),
|
|
780
|
+
nextPageToken: smartAccounts.nextPageToken,
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
catch (error) {
|
|
784
|
+
analytics_js_1.Analytics.trackError(error, "listSmartAccounts");
|
|
785
|
+
throw error;
|
|
786
|
+
}
|
|
693
787
|
}
|
|
694
788
|
/**
|
|
695
789
|
* Lists the spend permissions for a smart account.
|
|
@@ -705,7 +799,13 @@ class EvmClient {
|
|
|
705
799
|
analytics_js_1.Analytics.trackAction({
|
|
706
800
|
action: "list_spend_permissions",
|
|
707
801
|
});
|
|
708
|
-
|
|
802
|
+
try {
|
|
803
|
+
return await (0, listSpendPermissions_js_1.listSpendPermissions)(index_js_1.CdpOpenApiClient, options);
|
|
804
|
+
}
|
|
805
|
+
catch (error) {
|
|
806
|
+
analytics_js_1.Analytics.trackError(error, "listSpendPermissions");
|
|
807
|
+
throw error;
|
|
808
|
+
}
|
|
709
809
|
}
|
|
710
810
|
/**
|
|
711
811
|
* Prepares a user operation for a smart account.
|
|
@@ -740,27 +840,33 @@ class EvmClient {
|
|
|
740
840
|
network: options.network,
|
|
741
841
|
},
|
|
742
842
|
});
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
843
|
+
try {
|
|
844
|
+
const userOp = await index_js_1.CdpOpenApiClient.prepareUserOperation(options.smartAccount.address, {
|
|
845
|
+
network: options.network,
|
|
846
|
+
calls: options.calls.map(call => ({
|
|
847
|
+
to: call.to,
|
|
848
|
+
value: call.value.toString(),
|
|
849
|
+
data: call.data,
|
|
850
|
+
overrideGasLimit: call.overrideGasLimit,
|
|
851
|
+
})),
|
|
852
|
+
paymasterUrl: options.paymasterUrl,
|
|
853
|
+
dataSuffix: options.dataSuffix,
|
|
854
|
+
});
|
|
855
|
+
return {
|
|
856
|
+
network: userOp.network,
|
|
857
|
+
userOpHash: userOp.userOpHash,
|
|
858
|
+
status: userOp.status,
|
|
859
|
+
calls: userOp.calls.map(call => ({
|
|
860
|
+
to: call.to,
|
|
861
|
+
value: BigInt(call.value),
|
|
862
|
+
data: call.data,
|
|
863
|
+
})),
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
catch (error) {
|
|
867
|
+
analytics_js_1.Analytics.trackError(error, "prepareUserOperation");
|
|
868
|
+
throw error;
|
|
869
|
+
}
|
|
764
870
|
}
|
|
765
871
|
/**
|
|
766
872
|
* Prepares and sends a user operation for a smart account.
|
|
@@ -795,20 +901,26 @@ class EvmClient {
|
|
|
795
901
|
network: options.network,
|
|
796
902
|
},
|
|
797
903
|
});
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
904
|
+
try {
|
|
905
|
+
const userOp = await index_js_1.CdpOpenApiClient.prepareAndSendUserOperation(options.smartAccount.address, {
|
|
906
|
+
network: options.network,
|
|
907
|
+
calls: options.calls.map(call => ({
|
|
908
|
+
to: call.to,
|
|
909
|
+
value: call.value.toString(),
|
|
910
|
+
data: call.data,
|
|
911
|
+
})),
|
|
912
|
+
paymasterUrl: options.paymasterUrl,
|
|
913
|
+
}, options.idempotencyKey);
|
|
914
|
+
return {
|
|
915
|
+
smartAccountAddress: options.smartAccount.address,
|
|
916
|
+
userOpHash: userOp.userOpHash,
|
|
917
|
+
status: userOp.status,
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
catch (error) {
|
|
921
|
+
analytics_js_1.Analytics.trackError(error, "prepareAndSendUserOperation");
|
|
922
|
+
throw error;
|
|
923
|
+
}
|
|
812
924
|
}
|
|
813
925
|
/**
|
|
814
926
|
* Requests funds from an EVM faucet.
|
|
@@ -837,7 +949,13 @@ class EvmClient {
|
|
|
837
949
|
network: options.network,
|
|
838
950
|
},
|
|
839
951
|
});
|
|
840
|
-
|
|
952
|
+
try {
|
|
953
|
+
return await (0, requestFaucet_js_1.requestFaucet)(index_js_1.CdpOpenApiClient, options);
|
|
954
|
+
}
|
|
955
|
+
catch (error) {
|
|
956
|
+
analytics_js_1.Analytics.trackError(error, "requestFaucet");
|
|
957
|
+
throw error;
|
|
958
|
+
}
|
|
841
959
|
}
|
|
842
960
|
/**
|
|
843
961
|
* Signs an EVM transaction and sends it to the specified network using the Coinbase API.
|
|
@@ -892,7 +1010,13 @@ class EvmClient {
|
|
|
892
1010
|
network: options.network,
|
|
893
1011
|
},
|
|
894
1012
|
});
|
|
895
|
-
|
|
1013
|
+
try {
|
|
1014
|
+
return await (0, sendTransaction_js_1.sendTransaction)(index_js_1.CdpOpenApiClient, options);
|
|
1015
|
+
}
|
|
1016
|
+
catch (error) {
|
|
1017
|
+
analytics_js_1.Analytics.trackError(error, "sendTransaction");
|
|
1018
|
+
throw error;
|
|
1019
|
+
}
|
|
896
1020
|
}
|
|
897
1021
|
/**
|
|
898
1022
|
* Sends a user operation.
|
|
@@ -929,14 +1053,20 @@ class EvmClient {
|
|
|
929
1053
|
network: options.network,
|
|
930
1054
|
},
|
|
931
1055
|
});
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1056
|
+
try {
|
|
1057
|
+
return await (0, sendUserOperation_js_1.sendUserOperation)(index_js_1.CdpOpenApiClient, {
|
|
1058
|
+
smartAccount: options.smartAccount,
|
|
1059
|
+
network: options.network,
|
|
1060
|
+
calls: options.calls,
|
|
1061
|
+
paymasterUrl: options.paymasterUrl,
|
|
1062
|
+
idempotencyKey: options.idempotencyKey,
|
|
1063
|
+
dataSuffix: options.dataSuffix,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
catch (error) {
|
|
1067
|
+
analytics_js_1.Analytics.trackError(error, "sendUserOperation");
|
|
1068
|
+
throw error;
|
|
1069
|
+
}
|
|
940
1070
|
}
|
|
941
1071
|
/**
|
|
942
1072
|
* Signs an EVM hash.
|
|
@@ -963,12 +1093,18 @@ class EvmClient {
|
|
|
963
1093
|
analytics_js_1.Analytics.trackAction({
|
|
964
1094
|
action: "sign_hash",
|
|
965
1095
|
});
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1096
|
+
try {
|
|
1097
|
+
const signature = await index_js_1.CdpOpenApiClient.signEvmHash(options.address, {
|
|
1098
|
+
hash: options.hash,
|
|
1099
|
+
}, options.idempotencyKey);
|
|
1100
|
+
return {
|
|
1101
|
+
signature: signature.signature,
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
analytics_js_1.Analytics.trackError(error, "signHash");
|
|
1106
|
+
throw error;
|
|
1107
|
+
}
|
|
972
1108
|
}
|
|
973
1109
|
/**
|
|
974
1110
|
* Signs an EIP-191 message.
|
|
@@ -995,12 +1131,18 @@ class EvmClient {
|
|
|
995
1131
|
analytics_js_1.Analytics.trackAction({
|
|
996
1132
|
action: "sign_message",
|
|
997
1133
|
});
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1134
|
+
try {
|
|
1135
|
+
const signature = await index_js_1.CdpOpenApiClient.signEvmMessage(options.address, {
|
|
1136
|
+
message: options.message,
|
|
1137
|
+
}, options.idempotencyKey);
|
|
1138
|
+
return {
|
|
1139
|
+
signature: signature.signature,
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
catch (error) {
|
|
1143
|
+
analytics_js_1.Analytics.trackError(error, "signMessage");
|
|
1144
|
+
throw error;
|
|
1145
|
+
}
|
|
1004
1146
|
}
|
|
1005
1147
|
/**
|
|
1006
1148
|
* Signs an EIP-712 message.
|
|
@@ -1051,21 +1193,27 @@ class EvmClient {
|
|
|
1051
1193
|
analytics_js_1.Analytics.trackAction({
|
|
1052
1194
|
action: "sign_typed_data",
|
|
1053
1195
|
});
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1196
|
+
try {
|
|
1197
|
+
const { domain, message, primaryType } = options;
|
|
1198
|
+
const types = {
|
|
1199
|
+
EIP712Domain: (0, viem_1.getTypesForEIP712Domain)({ domain }),
|
|
1200
|
+
...options.types,
|
|
1201
|
+
};
|
|
1202
|
+
const openApiMessage = {
|
|
1203
|
+
domain,
|
|
1204
|
+
types,
|
|
1205
|
+
primaryType,
|
|
1206
|
+
message,
|
|
1207
|
+
};
|
|
1208
|
+
const signature = await index_js_1.CdpOpenApiClient.signEvmTypedData(options.address, openApiMessage, options.idempotencyKey);
|
|
1209
|
+
return {
|
|
1210
|
+
signature: signature.signature,
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
catch (error) {
|
|
1214
|
+
analytics_js_1.Analytics.trackError(error, "signTypedData");
|
|
1215
|
+
throw error;
|
|
1216
|
+
}
|
|
1069
1217
|
}
|
|
1070
1218
|
/**
|
|
1071
1219
|
* Signs an EVM transaction.
|
|
@@ -1101,12 +1249,18 @@ class EvmClient {
|
|
|
1101
1249
|
analytics_js_1.Analytics.trackAction({
|
|
1102
1250
|
action: "sign_transaction",
|
|
1103
1251
|
});
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1252
|
+
try {
|
|
1253
|
+
const signature = await index_js_1.CdpOpenApiClient.signEvmTransaction(options.address, {
|
|
1254
|
+
transaction: options.transaction,
|
|
1255
|
+
}, options.idempotencyKey);
|
|
1256
|
+
return {
|
|
1257
|
+
signature: signature.signedTransaction,
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
catch (error) {
|
|
1261
|
+
analytics_js_1.Analytics.trackError(error, "signTransaction");
|
|
1262
|
+
throw error;
|
|
1263
|
+
}
|
|
1110
1264
|
}
|
|
1111
1265
|
/**
|
|
1112
1266
|
* Updates a CDP EVM account.
|
|
@@ -1153,12 +1307,17 @@ class EvmClient {
|
|
|
1153
1307
|
analytics_js_1.Analytics.trackAction({
|
|
1154
1308
|
action: "update_account",
|
|
1155
1309
|
});
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
account
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1310
|
+
try {
|
|
1311
|
+
const openApiAccount = await index_js_1.CdpOpenApiClient.updateEvmAccount(options.address, options.update, options.idempotencyKey);
|
|
1312
|
+
const account = (0, toEvmServerAccount_js_1.toEvmServerAccount)(index_js_1.CdpOpenApiClient, {
|
|
1313
|
+
account: openApiAccount,
|
|
1314
|
+
});
|
|
1315
|
+
return account;
|
|
1316
|
+
}
|
|
1317
|
+
catch (error) {
|
|
1318
|
+
analytics_js_1.Analytics.trackError(error, "updateAccount");
|
|
1319
|
+
throw error;
|
|
1320
|
+
}
|
|
1162
1321
|
}
|
|
1163
1322
|
/**
|
|
1164
1323
|
* Updates a CDP EVM smart account.
|
|
@@ -1176,13 +1335,107 @@ class EvmClient {
|
|
|
1176
1335
|
analytics_js_1.Analytics.trackAction({
|
|
1177
1336
|
action: "update_smart_account",
|
|
1178
1337
|
});
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
smartAccount
|
|
1182
|
-
|
|
1338
|
+
try {
|
|
1339
|
+
const openApiSmartAccount = await index_js_1.CdpOpenApiClient.updateEvmSmartAccount(options.address, options.update, options.idempotencyKey);
|
|
1340
|
+
const smartAccount = (0, toEvmSmartAccount_js_1.toEvmSmartAccount)(index_js_1.CdpOpenApiClient, {
|
|
1341
|
+
smartAccount: openApiSmartAccount,
|
|
1342
|
+
owner: options.owner,
|
|
1343
|
+
});
|
|
1344
|
+
return smartAccount;
|
|
1345
|
+
}
|
|
1346
|
+
catch (error) {
|
|
1347
|
+
analytics_js_1.Analytics.trackError(error, "updateSmartAccount");
|
|
1348
|
+
throw error;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Creates an EIP-7702 delegation for an EVM EOA account, upgrading it with smart account capabilities.
|
|
1353
|
+
* The delegation allows the EVM EOA to be used as a smart account, which enables batched transactions and gas sponsorship via paymaster.
|
|
1354
|
+
*
|
|
1355
|
+
* @param {CreateEvmEip7702DelegationOptions} options - The delegation parameters (address and network required, enableSpendPermissions and idempotencyKey optional).
|
|
1356
|
+
* @returns A promise that resolves to the delegation result including the delegation operation ID.
|
|
1357
|
+
*
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* const result = await cdp.evm.createEvmEip7702Delegation({
|
|
1361
|
+
* address: account.address,
|
|
1362
|
+
* network: "base-sepolia",
|
|
1363
|
+
* enableSpendPermissions: false,
|
|
1364
|
+
* });
|
|
1365
|
+
* console.log(result.delegationOperationId);
|
|
1366
|
+
* ```
|
|
1367
|
+
*/
|
|
1368
|
+
async createEvmEip7702Delegation(options) {
|
|
1369
|
+
analytics_js_1.Analytics.trackAction({
|
|
1370
|
+
action: "create_eip7702_delegation",
|
|
1183
1371
|
});
|
|
1184
|
-
|
|
1185
|
-
|
|
1372
|
+
try {
|
|
1373
|
+
const { address, network, enableSpendPermissions, idempotencyKey } = options;
|
|
1374
|
+
const body = {
|
|
1375
|
+
network,
|
|
1376
|
+
...(enableSpendPermissions !== undefined && { enableSpendPermissions }),
|
|
1377
|
+
};
|
|
1378
|
+
return await index_js_1.CdpOpenApiClient.createEvmEip7702Delegation(address, body, idempotencyKey);
|
|
1379
|
+
}
|
|
1380
|
+
catch (error) {
|
|
1381
|
+
analytics_js_1.Analytics.trackError(error, "createEvmEip7702Delegation");
|
|
1382
|
+
throw error;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Gets the EIP-7702 delegation operation status.
|
|
1387
|
+
*
|
|
1388
|
+
* @param {string} delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
|
|
1389
|
+
* @returns A promise that resolves to the delegation operation status.
|
|
1390
|
+
*
|
|
1391
|
+
* @example
|
|
1392
|
+
* ```ts
|
|
1393
|
+
* const operation = await cdp.evm.getEvmEip7702DelegationOperationById(
|
|
1394
|
+
* "delegation-op-123",
|
|
1395
|
+
* );
|
|
1396
|
+
* console.log(operation.status); // "PENDING" | "SUBMITTED" | "COMPLETED" | "FAILED"
|
|
1397
|
+
* ```
|
|
1398
|
+
*/
|
|
1399
|
+
async getEvmEip7702DelegationOperationById(delegationOperationId) {
|
|
1400
|
+
analytics_js_1.Analytics.trackAction({
|
|
1401
|
+
action: "get_eip7702_delegation_operation_by_id",
|
|
1402
|
+
});
|
|
1403
|
+
try {
|
|
1404
|
+
return await index_js_1.CdpOpenApiClient.getEvmEip7702DelegationOperationById(delegationOperationId);
|
|
1405
|
+
}
|
|
1406
|
+
catch (error) {
|
|
1407
|
+
analytics_js_1.Analytics.trackError(error, "getEvmEip7702DelegationOperationById");
|
|
1408
|
+
throw error;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Polls the EIP-7702 delegation operation status until the status is COMPLETED or a timeout occurs.
|
|
1413
|
+
*
|
|
1414
|
+
* @param {WaitForEvmEip7702DelegationOperationStatusOptions} options - Parameters for waiting, including delegationOperationId and optional wait configuration.
|
|
1415
|
+
* @param {string} options.delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
|
|
1416
|
+
* @param {WaitOptions} [options.waitOptions] - Optional parameters for the wait operation.
|
|
1417
|
+
*
|
|
1418
|
+
* @returns A promise that resolves to the delegation operation once it reaches COMPLETED.
|
|
1419
|
+
*
|
|
1420
|
+
* @example
|
|
1421
|
+
* ```ts
|
|
1422
|
+
* const operation = await cdp.evm.waitForEvmEip7702DelegationOperationStatus({
|
|
1423
|
+
* delegationOperationId: "delegation-op-123",
|
|
1424
|
+
* });
|
|
1425
|
+
* console.log(operation.status); // "COMPLETED"
|
|
1426
|
+
* ```
|
|
1427
|
+
*/
|
|
1428
|
+
async waitForEvmEip7702DelegationOperationStatus(options) {
|
|
1429
|
+
analytics_js_1.Analytics.trackAction({
|
|
1430
|
+
action: "wait_for_eip7702_delegation_operation_status",
|
|
1431
|
+
});
|
|
1432
|
+
try {
|
|
1433
|
+
return await (0, waitForEvmEip7702DelegationStatus_js_1.waitForEvmEip7702DelegationOperationStatus)(index_js_1.CdpOpenApiClient, options);
|
|
1434
|
+
}
|
|
1435
|
+
catch (error) {
|
|
1436
|
+
analytics_js_1.Analytics.trackError(error, "waitForEvmEip7702DelegationOperationStatus");
|
|
1437
|
+
throw error;
|
|
1438
|
+
}
|
|
1186
1439
|
}
|
|
1187
1440
|
/**
|
|
1188
1441
|
* Waits for a user operation to complete or fail.
|
|
@@ -1220,9 +1473,15 @@ class EvmClient {
|
|
|
1220
1473
|
analytics_js_1.Analytics.trackAction({
|
|
1221
1474
|
action: "wait_for_user_operation",
|
|
1222
1475
|
});
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1476
|
+
try {
|
|
1477
|
+
return await (0, waitForUserOperation_js_1.waitForUserOperation)(index_js_1.CdpOpenApiClient, {
|
|
1478
|
+
...options,
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
catch (error) {
|
|
1482
|
+
analytics_js_1.Analytics.trackError(error, "waitForUserOperation");
|
|
1483
|
+
throw error;
|
|
1484
|
+
}
|
|
1226
1485
|
}
|
|
1227
1486
|
/**
|
|
1228
1487
|
* Internal method to create an account without tracking analytics.
|
|
@@ -1239,7 +1498,6 @@ class EvmClient {
|
|
|
1239
1498
|
const account = (0, toEvmServerAccount_js_1.toEvmServerAccount)(index_js_1.CdpOpenApiClient, {
|
|
1240
1499
|
account: openApiAccount,
|
|
1241
1500
|
});
|
|
1242
|
-
analytics_js_1.Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
1243
1501
|
return account;
|
|
1244
1502
|
}
|
|
1245
1503
|
/**
|
|
@@ -1262,7 +1520,6 @@ class EvmClient {
|
|
|
1262
1520
|
const account = (0, toEvmServerAccount_js_1.toEvmServerAccount)(index_js_1.CdpOpenApiClient, {
|
|
1263
1521
|
account: openApiAccount,
|
|
1264
1522
|
});
|
|
1265
|
-
analytics_js_1.Analytics.wrapObjectMethodsWithErrorTracking(account);
|
|
1266
1523
|
return account;
|
|
1267
1524
|
}
|
|
1268
1525
|
/**
|
|
@@ -1285,7 +1542,6 @@ class EvmClient {
|
|
|
1285
1542
|
smartAccount: openApiSmartAccount,
|
|
1286
1543
|
owner: options.owner,
|
|
1287
1544
|
});
|
|
1288
|
-
analytics_js_1.Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
1289
1545
|
return smartAccount;
|
|
1290
1546
|
}
|
|
1291
1547
|
/**
|
|
@@ -1316,7 +1572,6 @@ Provided Owner Address: ${options.owner.address}\n`);
|
|
|
1316
1572
|
smartAccount: openApiSmartAccount,
|
|
1317
1573
|
owner: options.owner,
|
|
1318
1574
|
});
|
|
1319
|
-
analytics_js_1.Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
|
|
1320
1575
|
return smartAccount;
|
|
1321
1576
|
}
|
|
1322
1577
|
}
|