@coinbase/cdp-sdk 1.1.2 → 1.2.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 +79 -0
- package/LICENSE +21 -0
- package/{dist → _cjs}/accounts/evm/toEvmServerAccount.js +1 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -0
- package/{dist → _cjs}/accounts/evm/toEvmSmartAccount.js +1 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -0
- package/{dist → _cjs}/accounts/types.js +1 -0
- package/_cjs/accounts/types.js.map +1 -0
- package/{dist → _cjs}/actions/evm/sendUserOperation.js +1 -0
- package/_cjs/actions/evm/sendUserOperation.js.map +1 -0
- package/{dist → _cjs}/actions/evm/waitForUserOperation.js +10 -9
- package/_cjs/actions/evm/waitForUserOperation.js.map +1 -0
- package/{dist → _cjs}/analytics.js +7 -6
- package/_cjs/analytics.js.map +1 -0
- package/{dist → _cjs}/auth/errors.js +1 -0
- package/_cjs/auth/errors.js.map +1 -0
- package/{dist → _cjs}/auth/hooks/axios/index.js +2 -1
- package/_cjs/auth/hooks/axios/index.js.map +1 -0
- package/{dist → _cjs}/auth/hooks/axios/withAuth.js +3 -2
- package/_cjs/auth/hooks/axios/withAuth.js.map +1 -0
- package/{dist → _cjs}/auth/index.js +4 -3
- package/_cjs/auth/index.js.map +1 -0
- package/{dist → _cjs}/auth/utils/http.js +6 -5
- package/_cjs/auth/utils/http.js.map +1 -0
- package/{dist → _cjs}/auth/utils/index.js +3 -2
- package/_cjs/auth/utils/index.js.map +1 -0
- package/{dist → _cjs}/auth/utils/jwt.js +4 -3
- package/_cjs/auth/utils/jwt.js.map +1 -0
- package/{dist → _cjs}/client/cdp.js +13 -8
- package/_cjs/client/cdp.js.map +1 -0
- package/{dist → _cjs}/client/evm/evm.js +26 -25
- package/_cjs/client/evm/evm.js.map +1 -0
- package/{dist → _cjs}/client/evm/evm.types.js +1 -0
- package/_cjs/client/evm/evm.types.js.map +1 -0
- package/{dist → _cjs}/client/solana/index.js +3 -2
- package/_cjs/client/solana/index.js.map +1 -0
- package/{dist → _cjs}/client/solana/solana.js +9 -8
- package/_cjs/client/solana/solana.js.map +1 -0
- package/{dist → _cjs}/client/solana/solana.types.js +1 -0
- package/_cjs/client/solana/solana.types.js.map +1 -0
- package/{dist → _cjs}/constants.js +1 -0
- package/_cjs/constants.js.map +1 -0
- package/{dist → _cjs}/errors.js +1 -0
- package/_cjs/errors.js.map +1 -0
- package/{dist → _cjs}/index.js +4 -3
- package/_cjs/index.js.map +1 -0
- package/{dist → _cjs}/openapi-client/cdpApiClient.js +18 -14
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -0
- package/{dist → _cjs}/openapi-client/errors.js +6 -0
- package/_cjs/openapi-client/errors.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +31 -30
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/evm-accounts/evm-accounts.js +46 -41
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/evm-accounts/evm-accounts.msw.js +73 -40
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +69 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +188 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/faucets/faucets.js +18 -13
- package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/faucets/faucets.msw.js +16 -12
- package/_cjs/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/index.msw.js +5 -4
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.js +38 -35
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
- package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.msw.js +68 -35
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
- package/{dist → _cjs}/openapi-client/index.js +12 -11
- package/_cjs/openapi-client/index.js.map +1 -0
- package/_cjs/package.json +1 -0
- package/{dist → _cjs}/types/calls.js +1 -0
- package/_cjs/types/calls.js.map +1 -0
- package/{dist → _cjs}/types/contract.js +1 -0
- package/_cjs/types/contract.js.map +1 -0
- package/{dist → _cjs}/types/misc.js +1 -0
- package/_cjs/types/misc.js.map +1 -0
- package/{dist → _cjs}/types/multicall.js +1 -0
- package/_cjs/types/multicall.js.map +1 -0
- package/{dist → _cjs}/types/utils.js +1 -0
- package/_cjs/types/utils.js.map +1 -0
- package/{dist → _cjs}/utils/wait.js +3 -2
- package/_cjs/utils/wait.js.map +1 -0
- package/_cjs/version.js +5 -0
- package/_cjs/version.js.map +1 -0
- package/_esm/accounts/evm/toEvmServerAccount.js +40 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js +22 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -0
- package/_esm/accounts/types.js +2 -0
- package/_esm/accounts/types.js.map +1 -0
- package/_esm/actions/evm/sendUserOperation.js +85 -0
- package/_esm/actions/evm/sendUserOperation.js.map +1 -0
- package/_esm/actions/evm/waitForUserOperation.js +58 -0
- package/_esm/actions/evm/waitForUserOperation.js.map +1 -0
- package/_esm/analytics.js +84 -0
- package/_esm/analytics.js.map +1 -0
- package/_esm/auth/errors.js +57 -0
- package/_esm/auth/errors.js.map +1 -0
- package/_esm/auth/hooks/axios/index.js +2 -0
- package/_esm/auth/hooks/axios/index.js.map +1 -0
- package/_esm/auth/hooks/axios/withAuth.js +71 -0
- package/_esm/auth/hooks/axios/withAuth.js.map +1 -0
- package/_esm/auth/index.js +5 -0
- package/_esm/auth/index.js.map +1 -0
- package/_esm/auth/utils/http.js +70 -0
- package/_esm/auth/utils/http.js.map +1 -0
- package/_esm/auth/utils/index.js +3 -0
- package/_esm/auth/utils/index.js.map +1 -0
- package/_esm/auth/utils/jwt.js +199 -0
- package/_esm/auth/utils/jwt.js.map +1 -0
- package/_esm/client/cdp.js +95 -0
- package/_esm/client/cdp.js.map +1 -0
- package/_esm/client/evm/evm.js +518 -0
- package/_esm/client/evm/evm.js.map +1 -0
- package/_esm/client/evm/evm.types.js +2 -0
- package/_esm/client/evm/evm.types.js.map +1 -0
- package/_esm/client/solana/index.js +2 -0
- package/_esm/client/solana/index.js.map +1 -0
- package/_esm/client/solana/solana.js +204 -0
- package/_esm/client/solana/solana.js.map +1 -0
- package/_esm/client/solana/solana.types.js +2 -0
- package/_esm/client/solana/solana.types.js.map +1 -0
- package/_esm/constants.js +5 -0
- package/_esm/constants.js.map +1 -0
- package/_esm/errors.js +18 -0
- package/_esm/errors.js.map +1 -0
- package/_esm/index.js +3 -0
- package/_esm/index.js.map +1 -0
- package/_esm/openapi-client/cdpApiClient.js +112 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -0
- package/_esm/openapi-client/errors.js +71 -0
- package/_esm/openapi-client/errors.js.map +1 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +52 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +80 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +128 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +60 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +172 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
- package/_esm/openapi-client/generated/faucets/faucets.js +51 -0
- package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -0
- package/_esm/openapi-client/generated/faucets/faucets.msw.js +39 -0
- package/_esm/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
- package/_esm/openapi-client/generated/index.msw.js +5 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +73 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +116 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +27 -0
- package/_esm/openapi-client/index.js.map +1 -0
- package/_esm/package.json +1 -0
- package/_esm/types/calls.js +4 -0
- package/_esm/types/calls.js.map +1 -0
- package/_esm/types/contract.js +4 -0
- package/_esm/types/contract.js.map +1 -0
- package/_esm/types/misc.js +3 -0
- package/_esm/types/misc.js.map +1 -0
- package/_esm/types/multicall.js +2 -0
- package/_esm/types/multicall.js.map +1 -0
- package/_esm/types/utils.js +4 -0
- package/_esm/types/utils.js.map +1 -0
- package/_esm/utils/wait.js +32 -0
- package/_esm/utils/wait.js.map +1 -0
- package/_esm/version.js +2 -0
- package/_esm/version.js.map +1 -0
- package/{dist → _types}/accounts/evm/toEvmServerAccount.d.ts +3 -2
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -0
- package/{dist → _types}/accounts/evm/toEvmSmartAccount.d.ts +3 -2
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -0
- package/{dist → _types}/accounts/types.d.ts +3 -2
- package/_types/accounts/types.d.ts.map +1 -0
- package/{dist → _types}/actions/evm/sendUserOperation.d.ts +5 -5
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -0
- package/{dist → _types}/actions/evm/waitForUserOperation.d.ts +4 -3
- package/_types/actions/evm/waitForUserOperation.d.ts.map +1 -0
- package/{dist → _types}/analytics.d.ts +1 -0
- package/_types/analytics.d.ts.map +1 -0
- package/{dist → _types}/auth/errors.d.ts +1 -0
- package/_types/auth/errors.d.ts.map +1 -0
- package/_types/auth/hooks/axios/index.d.ts +2 -0
- package/_types/auth/hooks/axios/index.d.ts.map +1 -0
- package/{dist → _types}/auth/hooks/axios/withAuth.d.ts +1 -0
- package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -0
- package/_types/auth/index.d.ts +5 -0
- package/_types/auth/index.d.ts.map +1 -0
- package/{dist → _types}/auth/utils/http.d.ts +1 -0
- package/_types/auth/utils/http.d.ts.map +1 -0
- package/_types/auth/utils/index.d.ts +3 -0
- package/_types/auth/utils/index.d.ts.map +1 -0
- package/{dist → _types}/auth/utils/jwt.d.ts +1 -0
- package/_types/auth/utils/jwt.d.ts.map +1 -0
- package/{dist → _types}/client/cdp.d.ts +3 -2
- package/_types/client/cdp.d.ts.map +1 -0
- package/{dist → _types}/client/evm/evm.d.ts +4 -3
- package/_types/client/evm/evm.d.ts.map +1 -0
- package/{dist → _types}/client/evm/evm.types.d.ts +7 -6
- package/_types/client/evm/evm.types.d.ts.map +1 -0
- package/_types/client/solana/index.d.ts +2 -0
- package/_types/client/solana/index.d.ts.map +1 -0
- package/{dist → _types}/client/solana/solana.d.ts +2 -1
- package/_types/client/solana/solana.d.ts.map +1 -0
- package/{dist → _types}/client/solana/solana.types.d.ts +2 -1
- package/_types/client/solana/solana.types.d.ts.map +1 -0
- package/{dist → _types}/constants.d.ts +1 -0
- package/_types/constants.d.ts.map +1 -0
- package/{dist → _types}/errors.d.ts +1 -0
- package/_types/errors.d.ts.map +1 -0
- package/_types/index.d.ts +4 -0
- package/_types/index.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/cdpApiClient.d.ts +1 -0
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/errors.d.ts +2 -1
- package/_types/openapi-client/errors.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +13 -12
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/evm-accounts/evm-accounts.d.ts +24 -23
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +3 -2
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +21 -20
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +3 -2
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/faucets/faucets.d.ts +9 -8
- package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/faucets/faucets.msw.d.ts +3 -2
- package/_types/openapi-client/generated/faucets/faucets.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts +5 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.d.ts +21 -20
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -0
- package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +3 -2
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +56 -0
- package/_types/openapi-client/index.d.ts.map +1 -0
- package/{dist → _types}/types/calls.d.ts +4 -3
- package/_types/types/calls.d.ts.map +1 -0
- package/{dist → _types}/types/contract.d.ts +3 -2
- package/_types/types/contract.d.ts.map +1 -0
- package/{dist → _types}/types/misc.d.ts +1 -0
- package/_types/types/misc.d.ts.map +1 -0
- package/{dist → _types}/types/multicall.d.ts +2 -1
- package/_types/types/multicall.d.ts.map +1 -0
- package/{dist → _types}/types/utils.d.ts +1 -0
- package/_types/types/utils.d.ts.map +1 -0
- package/{dist → _types}/utils/wait.d.ts +1 -0
- package/_types/utils/wait.d.ts.map +1 -0
- package/_types/version.d.ts +2 -0
- package/_types/version.d.ts.map +1 -0
- package/accounts/evm/toEvmServerAccount.ts +60 -0
- package/accounts/evm/toEvmSmartAccount.ts +37 -0
- package/accounts/types.ts +53 -0
- package/actions/evm/sendUserOperation.ts +163 -0
- package/actions/evm/waitForUserOperation.ts +115 -0
- package/analytics.ts +123 -0
- package/auth/README.md +145 -0
- package/auth/errors.ts +59 -0
- package/auth/hooks/axios/index.ts +1 -0
- package/auth/hooks/axios/withAuth.ts +120 -0
- package/auth/index.ts +5 -0
- package/auth/utils/http.ts +146 -0
- package/auth/utils/index.ts +2 -0
- package/auth/utils/jwt.ts +324 -0
- package/client/cdp.ts +113 -0
- package/client/evm/evm.ts +606 -0
- package/client/evm/evm.types.ts +303 -0
- package/client/solana/index.ts +1 -0
- package/client/solana/solana.ts +237 -0
- package/client/solana/solana.types.ts +114 -0
- package/constants.ts +4 -0
- package/errors.ts +17 -0
- package/index.ts +4 -0
- package/openapi-client/cdpApiClient.ts +214 -0
- package/openapi-client/errors.ts +96 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +411 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +242 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +150 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +283 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +131 -0
- package/openapi-client/generated/faucets/faucets.msw.ts +76 -0
- package/openapi-client/generated/faucets/faucets.ts +83 -0
- package/openapi-client/generated/index.msw.ts +4 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +219 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +143 -0
- package/openapi-client/index.ts +32 -0
- package/package.json +31 -66
- package/types/calls.ts +40 -0
- package/types/contract.ts +126 -0
- package/types/misc.ts +5 -0
- package/types/multicall.ts +29 -0
- package/types/utils.ts +288 -0
- package/utils/wait.ts +52 -0
- package/version.ts +1 -0
- package/dist/auth/hooks/axios/index.d.ts +0 -1
- package/dist/auth/index.d.ts +0 -4
- package/dist/auth/utils/index.d.ts +0 -2
- package/dist/client/evm/index.d.ts +0 -1
- package/dist/client/evm/index.js +0 -5
- package/dist/client/solana/index.d.ts +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +0 -66
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +0 -99
- package/dist/openapi-client/generated/index.msw.d.ts +0 -4
- package/dist/openapi-client/index.d.ts +0 -55
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CreateServerAccountOptions,
|
|
5
|
+
GetServerAccountOptions,
|
|
6
|
+
ListServerAccountsOptions,
|
|
7
|
+
CreateSmartAccountOptions,
|
|
8
|
+
RequestFaucetOptions,
|
|
9
|
+
SendUserOperationOptions,
|
|
10
|
+
WaitForUserOperationOptions,
|
|
11
|
+
RequestFaucetResult,
|
|
12
|
+
SignHashOptions,
|
|
13
|
+
SignatureResult,
|
|
14
|
+
SignMessageOptions,
|
|
15
|
+
SignTransactionOptions,
|
|
16
|
+
GetSmartAccountOptions,
|
|
17
|
+
SmartAccount,
|
|
18
|
+
ServerAccount,
|
|
19
|
+
EvmClientInterface,
|
|
20
|
+
ListServerAccountResult,
|
|
21
|
+
PrepareUserOperationOptions,
|
|
22
|
+
UserOperation,
|
|
23
|
+
GetUserOperationOptions,
|
|
24
|
+
ListSmartAccountResult,
|
|
25
|
+
ListSmartAccountsOptions,
|
|
26
|
+
} from "./evm.types.js";
|
|
27
|
+
import { toEvmServerAccount } from "../../accounts/evm/toEvmServerAccount.js";
|
|
28
|
+
import { toEvmSmartAccount } from "../../accounts/evm/toEvmSmartAccount.js";
|
|
29
|
+
import {
|
|
30
|
+
sendUserOperation,
|
|
31
|
+
SendUserOperationReturnType,
|
|
32
|
+
} from "../../actions/evm/sendUserOperation.js";
|
|
33
|
+
import {
|
|
34
|
+
waitForUserOperation,
|
|
35
|
+
WaitForUserOperationReturnType,
|
|
36
|
+
} from "../../actions/evm/waitForUserOperation.js";
|
|
37
|
+
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
38
|
+
import { Hex } from "../../types/misc.js";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The namespace containing all EVM methods.
|
|
42
|
+
*/
|
|
43
|
+
export class EvmClient implements EvmClientInterface {
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new CDP EVM account.
|
|
46
|
+
*
|
|
47
|
+
* @param {CreateServerAccountOptions} [options] - Optional parameters for creating the account.
|
|
48
|
+
* @param {string} [options.name] - A name for the account to create.
|
|
49
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
50
|
+
*
|
|
51
|
+
* @returns A promise that resolves to the newly created account.
|
|
52
|
+
*
|
|
53
|
+
* @example **Without arguments**
|
|
54
|
+
* ```ts
|
|
55
|
+
* const account = await cdp.evm.createAccount();
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example **With a name**
|
|
59
|
+
* ```ts
|
|
60
|
+
* const account = await cdp.evm.createAccount({ name: "MyAccount" });
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example **With an idempotency key**
|
|
64
|
+
* ```ts
|
|
65
|
+
* const idempotencyKey = uuidv4();
|
|
66
|
+
*
|
|
67
|
+
* // First call
|
|
68
|
+
* await cdp.evm.createAccount({
|
|
69
|
+
* idempotencyKey,
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Second call with the same idempotency key will return the same account
|
|
73
|
+
* await cdp.evm.createAccount({
|
|
74
|
+
* idempotencyKey,
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
async createAccount(options: CreateServerAccountOptions = {}): Promise<ServerAccount> {
|
|
79
|
+
const account = await CdpOpenApiClient.createEvmAccount(
|
|
80
|
+
{
|
|
81
|
+
name: options.name,
|
|
82
|
+
},
|
|
83
|
+
options.idempotencyKey,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return toEvmServerAccount(CdpOpenApiClient, {
|
|
87
|
+
account,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates a new CDP EVM smart account.
|
|
93
|
+
*
|
|
94
|
+
* @param {CreateSmartAccountOptions} options - Parameters for creating the smart account.
|
|
95
|
+
* @param {Account} options.owner - The owner of the smart account.
|
|
96
|
+
* The owner can be any Ethereum account with signing capabilities,
|
|
97
|
+
* such as a CDP EVM account or a Viem LocalAccount.
|
|
98
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
99
|
+
*
|
|
100
|
+
* @returns A promise that resolves to the newly created smart account.
|
|
101
|
+
*
|
|
102
|
+
* @example **With a CDP EVM Account as the owner**
|
|
103
|
+
* ```ts
|
|
104
|
+
* const account = await cdp.evm.createAccount();
|
|
105
|
+
* const smartAccount = await cdp.evm.createSmartAccount({
|
|
106
|
+
* owner: account,
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example **With a Viem LocalAccount as the owner**
|
|
111
|
+
* ```ts
|
|
112
|
+
* // See https://viem.sh/docs/accounts/local/privateKeyToAccount
|
|
113
|
+
* const privateKey = generatePrivateKey();
|
|
114
|
+
* const account = privateKeyToAccount(privateKey);
|
|
115
|
+
* const smartAccount = await client.evm.createSmartAccount({
|
|
116
|
+
* owner: account,
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example **With an idempotency key**
|
|
121
|
+
* ```ts
|
|
122
|
+
* const idempotencyKey = uuidv4();
|
|
123
|
+
*
|
|
124
|
+
* // First call
|
|
125
|
+
* await cdp.evm.createSmartAccount({
|
|
126
|
+
* owner: account,
|
|
127
|
+
* idempotencyKey,
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* // Second call with the same idempotency key will return the same smart account
|
|
131
|
+
* await cdp.evm.createSmartAccount({
|
|
132
|
+
* owner: account,
|
|
133
|
+
* idempotencyKey,
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
async createSmartAccount(options: CreateSmartAccountOptions): Promise<SmartAccount> {
|
|
137
|
+
const smartAccount = await CdpOpenApiClient.createEvmSmartAccount(
|
|
138
|
+
{
|
|
139
|
+
owners: [options.owner.address],
|
|
140
|
+
},
|
|
141
|
+
options.idempotencyKey,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return toEvmSmartAccount({
|
|
145
|
+
smartAccount,
|
|
146
|
+
owner: options.owner,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets a CDP EVM account.
|
|
152
|
+
*
|
|
153
|
+
* @param {GetServerAccountOptions} options - Parameters for getting the account.
|
|
154
|
+
* Either `address` or `name` must be provided.
|
|
155
|
+
* If both are provided, lookup will be done by `address` and `name` will be ignored.
|
|
156
|
+
* @param {string} [options.address] - The address of the account to get.
|
|
157
|
+
* @param {string} [options.name] - The name of the account to get.
|
|
158
|
+
*
|
|
159
|
+
* @returns A promise that resolves to the account.
|
|
160
|
+
*
|
|
161
|
+
* @example **Get an account by address**
|
|
162
|
+
* ```ts
|
|
163
|
+
* const account = await cdp.evm.getAccount({
|
|
164
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example **Get an account by name**
|
|
169
|
+
* ```ts
|
|
170
|
+
* const account = await cdp.evm.getAccount({
|
|
171
|
+
* name: "MyAccount",
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
async getAccount(options: GetServerAccountOptions): Promise<ServerAccount> {
|
|
176
|
+
const account = await (() => {
|
|
177
|
+
if (options.address) {
|
|
178
|
+
return CdpOpenApiClient.getEvmAccount(options.address);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (options.name) {
|
|
182
|
+
return CdpOpenApiClient.getEvmAccountByName(options.name);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
throw new Error("Either address or name must be provided");
|
|
186
|
+
})();
|
|
187
|
+
|
|
188
|
+
return toEvmServerAccount(CdpOpenApiClient, {
|
|
189
|
+
account,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Gets a CDP EVM smart account.
|
|
195
|
+
*
|
|
196
|
+
* @param {GetSmartAccountOptions} options - Parameters for getting the smart account.
|
|
197
|
+
* @param {string} options.address - The address of the smart account to get.
|
|
198
|
+
* @param {Account} options.owner - The owner of the smart account.
|
|
199
|
+
* You must pass the signing-capable owner of the smart account so that the returned smart account
|
|
200
|
+
* can be functional.
|
|
201
|
+
*
|
|
202
|
+
* @returns A promise that resolves to the smart account.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* const smartAccount = await cdp.evm.getSmartAccount({
|
|
207
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
208
|
+
* owner: account,
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
async getSmartAccount(options: GetSmartAccountOptions): Promise<SmartAccount> {
|
|
213
|
+
const smartAccount = await CdpOpenApiClient.getEvmSmartAccount(options.address);
|
|
214
|
+
|
|
215
|
+
return toEvmSmartAccount({
|
|
216
|
+
smartAccount,
|
|
217
|
+
owner: options.owner,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Gets a user operation for a smart account by user operation hash.
|
|
223
|
+
*
|
|
224
|
+
* @param {GetUserOperationOptions} options - Parameters for getting the user operation.
|
|
225
|
+
* @param {SmartAccount} options.smartAccount - The smart account signing the user operation.
|
|
226
|
+
* @param {string} options.userOpHash - The user operation hash.
|
|
227
|
+
*
|
|
228
|
+
* @returns A promise that resolves to the user operation.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const userOp = await cdp.evm.getUserOperation({
|
|
233
|
+
* smartAccount,
|
|
234
|
+
* userOpHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
async getUserOperation(options: GetUserOperationOptions): Promise<UserOperation> {
|
|
239
|
+
const userOp = await CdpOpenApiClient.getUserOperation(
|
|
240
|
+
options.smartAccount.address,
|
|
241
|
+
options.userOpHash,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
calls: userOp.calls.map(call => ({
|
|
246
|
+
to: call.to as Address,
|
|
247
|
+
value: BigInt(call.value),
|
|
248
|
+
data: call.data as Hex,
|
|
249
|
+
})),
|
|
250
|
+
network: userOp.network,
|
|
251
|
+
status: userOp.status,
|
|
252
|
+
transactionHash: userOp.transactionHash as Hex | undefined,
|
|
253
|
+
userOpHash: userOp.userOpHash as Hex,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Lists CDP EVM accounts.
|
|
259
|
+
*
|
|
260
|
+
* @param {ListServerAccountsOptions} [options] - Optional parameters for listing the accounts.
|
|
261
|
+
* @param {number} [options.pageSize] - The number of accounts to return.
|
|
262
|
+
* @param {string} [options.pageToken] - The page token to begin listing from.
|
|
263
|
+
* This is obtained by previous calls to this method.
|
|
264
|
+
*
|
|
265
|
+
* @returns A promise that resolves to an array of accounts, and a token to paginate through the accounts.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* const accounts = await cdp.evm.listAccounts();
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @example **With pagination**
|
|
273
|
+
* ```ts
|
|
274
|
+
* let page = await cdp.evm.listAccounts();
|
|
275
|
+
*
|
|
276
|
+
* while (page.nextPageToken) {
|
|
277
|
+
* page = await cdp.evm.listAccounts({ pageToken: page.nextPageToken });
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
async listAccounts(options: ListServerAccountsOptions = {}): Promise<ListServerAccountResult> {
|
|
282
|
+
const ethAccounts = await CdpOpenApiClient.listEvmAccounts({
|
|
283
|
+
pageSize: options.pageSize,
|
|
284
|
+
pageToken: options.pageToken,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
accounts: ethAccounts.accounts.map(account =>
|
|
289
|
+
toEvmServerAccount(CdpOpenApiClient, {
|
|
290
|
+
account: account,
|
|
291
|
+
}),
|
|
292
|
+
),
|
|
293
|
+
nextPageToken: ethAccounts.nextPageToken,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Lists CDP EVM smart accounts.
|
|
299
|
+
*
|
|
300
|
+
* @param {ListSmartAccountsOptions} options - Parameters for listing the smart accounts.
|
|
301
|
+
* @param {number} [options.pageSize] - The number of smart accounts to return.
|
|
302
|
+
* @param {string} [options.pageToken] - The page token to begin listing from.
|
|
303
|
+
* This is obtained by previous calls to this method.
|
|
304
|
+
*
|
|
305
|
+
* @returns A promise that resolves to an array of smart accounts, and a token to paginate through the smart accounts.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* const smartAccounts = await cdp.evm.listSmartAccounts();
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @example **With pagination**
|
|
313
|
+
* ```ts
|
|
314
|
+
* let page = await cdp.evm.listSmartAccounts();
|
|
315
|
+
*
|
|
316
|
+
* while (page.nextPageToken) {
|
|
317
|
+
* page = await cdp.evm.listSmartAccounts({ pageToken: page.nextPageToken });
|
|
318
|
+
* }
|
|
319
|
+
*/
|
|
320
|
+
async listSmartAccounts(options: ListSmartAccountsOptions = {}): Promise<ListSmartAccountResult> {
|
|
321
|
+
const smartAccounts = await CdpOpenApiClient.listEvmSmartAccounts({
|
|
322
|
+
pageSize: options.pageSize,
|
|
323
|
+
pageToken: options.pageToken,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
accounts: smartAccounts.accounts.map(account => ({
|
|
328
|
+
address: account.address as Address,
|
|
329
|
+
owners: [account.owners[0] as Address],
|
|
330
|
+
type: "evm-smart",
|
|
331
|
+
})),
|
|
332
|
+
nextPageToken: smartAccounts.nextPageToken,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Prepares a user operation for a smart account.
|
|
338
|
+
*
|
|
339
|
+
* @param {PrepareUserOperationOptions} options - Parameters for preparing the user operation.
|
|
340
|
+
* @param {SmartAccount} options.smartAccount - The smart account signing the user operation.
|
|
341
|
+
* @param {string} options.network - The network to prepare the user operation for.
|
|
342
|
+
* @param {EvmCall[]} options.calls - The calls to include in the user operation.
|
|
343
|
+
* @param {string} [options.paymasterUrl] - The optional paymaster URL to use for the user operation.
|
|
344
|
+
*
|
|
345
|
+
* @returns A promise that resolves to the user operation hash.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```ts
|
|
349
|
+
* const userOp = await cdp.evm.prepareUserOperation({
|
|
350
|
+
* smartAccount,
|
|
351
|
+
* network: "base-sepolia",
|
|
352
|
+
* calls: [
|
|
353
|
+
* {
|
|
354
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
355
|
+
* value: parseEther("0.000001"),
|
|
356
|
+
* data: "0x",
|
|
357
|
+
* },
|
|
358
|
+
* ],
|
|
359
|
+
* });
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
async prepareUserOperation(options: PrepareUserOperationOptions): Promise<UserOperation> {
|
|
363
|
+
const userOp = await CdpOpenApiClient.prepareUserOperation(options.smartAccount.address, {
|
|
364
|
+
network: options.network,
|
|
365
|
+
calls: options.calls.map(call => ({
|
|
366
|
+
to: call.to as Address,
|
|
367
|
+
value: call.value.toString(),
|
|
368
|
+
data: call.data as Hex,
|
|
369
|
+
})),
|
|
370
|
+
paymasterUrl: options.paymasterUrl,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
network: userOp.network,
|
|
375
|
+
userOpHash: userOp.userOpHash as Hex,
|
|
376
|
+
status: userOp.status,
|
|
377
|
+
calls: userOp.calls.map(call => ({
|
|
378
|
+
to: call.to as Address,
|
|
379
|
+
value: BigInt(call.value),
|
|
380
|
+
data: call.data as Hex,
|
|
381
|
+
})),
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Requests funds from an EVM faucet.
|
|
387
|
+
*
|
|
388
|
+
* @param {RequestFaucetOptions} options - Parameters for requesting funds from the EVM faucet.
|
|
389
|
+
* @param {string} options.address - The address to request funds for.
|
|
390
|
+
* @param {string} options.network - The network to request funds from.
|
|
391
|
+
* @param {string} options.token - The token to request funds for.
|
|
392
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
393
|
+
*
|
|
394
|
+
* @returns A promise that resolves to the transaction hash.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* const result = await cdp.evm.requestFaucet({
|
|
399
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
400
|
+
* network: "base-sepolia",
|
|
401
|
+
* token: "eth",
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
async requestFaucet(options: RequestFaucetOptions): Promise<RequestFaucetResult> {
|
|
406
|
+
const { transactionHash } = await CdpOpenApiClient.requestEvmFaucet(
|
|
407
|
+
{ address: options.address, network: options.network, token: options.token },
|
|
408
|
+
options.idempotencyKey,
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
return {
|
|
412
|
+
transactionHash: transactionHash as Hex,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Sends a user operation.
|
|
418
|
+
*
|
|
419
|
+
* @param {SendUserOperationOptions} options - Parameters for sending the user operation.
|
|
420
|
+
* @param {SmartAccount} options.smartAccount - The smart account sending the user operation.
|
|
421
|
+
* @param {string} options.network - The network to send the user operation on.
|
|
422
|
+
* @param {EvmCall[]} options.calls - The calls to include in the user operation.
|
|
423
|
+
* @param {string} [options.paymasterUrl] - The optional paymaster URL to use for the user operation.
|
|
424
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
425
|
+
*
|
|
426
|
+
* @returns A promise that resolves to an object containing the smart account address,
|
|
427
|
+
* the user operation hash, and the status of the user operation.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const userOp = await cdp.evm.sendUserOperation({
|
|
432
|
+
* smartAccount,
|
|
433
|
+
* network: "base-sepolia",
|
|
434
|
+
* calls: [
|
|
435
|
+
* {
|
|
436
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
437
|
+
* value: parseEther("0.000001"),
|
|
438
|
+
* data: "0x",
|
|
439
|
+
* },
|
|
440
|
+
* ],
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
async sendUserOperation(options: SendUserOperationOptions): Promise<SendUserOperationReturnType> {
|
|
445
|
+
return sendUserOperation(CdpOpenApiClient, options.smartAccount, {
|
|
446
|
+
network: options.network,
|
|
447
|
+
calls: options.calls,
|
|
448
|
+
paymasterUrl: options.paymasterUrl,
|
|
449
|
+
idempotencyKey: options.idempotencyKey,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Signs an EVM hash.
|
|
455
|
+
*
|
|
456
|
+
* @param {SignHashOptions} options - Parameters for signing the hash.
|
|
457
|
+
* @param {string} options.address - The address to sign the hash for.
|
|
458
|
+
* @param {string} options.hash - The hash to sign.
|
|
459
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
460
|
+
*
|
|
461
|
+
* @returns A promise that resolves to the signature.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* // Create a new EVM server account to sign with
|
|
466
|
+
* const ethAccount = await cdp.createEvmServerAccount({});
|
|
467
|
+
*
|
|
468
|
+
* const signature = await cdp.evm.signHash({
|
|
469
|
+
* address: ethAccount.address,
|
|
470
|
+
* hash: "0x1234567890123456789012345678901234567890123456789012345678901234",
|
|
471
|
+
* });
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
async signHash(options: SignHashOptions): Promise<SignatureResult> {
|
|
475
|
+
const signature = await CdpOpenApiClient.signEvmHash(
|
|
476
|
+
options.address,
|
|
477
|
+
{
|
|
478
|
+
hash: options.hash,
|
|
479
|
+
},
|
|
480
|
+
options.idempotencyKey,
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
return {
|
|
484
|
+
signature: signature.signature as Hex,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Signs an EVM message.
|
|
490
|
+
*
|
|
491
|
+
* @param {SignMessageOptions} options - Parameters for signing the message.
|
|
492
|
+
* @param {string} options.address - The address to sign the message for.
|
|
493
|
+
* @param {string} options.message - The message to sign.
|
|
494
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
495
|
+
*
|
|
496
|
+
* @returns A promise that resolves to the signature.
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* // Create a new EVM server account to sign with
|
|
501
|
+
* const ethAccount = await cdp.createEvmServerAccount({});
|
|
502
|
+
*
|
|
503
|
+
* const signature = await cdp.evm.signMessage({
|
|
504
|
+
* address: ethAccount.address,
|
|
505
|
+
* message: "Hello, world!",
|
|
506
|
+
* });
|
|
507
|
+
* ```
|
|
508
|
+
*/
|
|
509
|
+
async signMessage(options: SignMessageOptions): Promise<SignatureResult> {
|
|
510
|
+
const signature = await CdpOpenApiClient.signEvmMessage(
|
|
511
|
+
options.address,
|
|
512
|
+
{
|
|
513
|
+
message: options.message,
|
|
514
|
+
},
|
|
515
|
+
options.idempotencyKey,
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
return {
|
|
519
|
+
signature: signature.signature as Hex,
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Signs an EVM transaction.
|
|
525
|
+
*
|
|
526
|
+
* @param {SignTransactionOptions} options - Configuration options for signing the transaction.
|
|
527
|
+
* @returns A promise that resolves to the signature.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```ts
|
|
531
|
+
* import { parseEther, serializeTransaction } from "viem";
|
|
532
|
+
* import { baseSepolia } from "viem/chains";
|
|
533
|
+
*
|
|
534
|
+
* // Create a new EVM server account to sign with
|
|
535
|
+
* const ethAccount = await cdp.createEvmServerAccount({});
|
|
536
|
+
*
|
|
537
|
+
* const serializedTx = serializeTransaction(
|
|
538
|
+
* {
|
|
539
|
+
* chainId: baseSepolia.id,
|
|
540
|
+
* data: "0x",
|
|
541
|
+
* to: "0x4252e0c9A3da5A2700e7d91cb50aEf522D0C6Fe8",
|
|
542
|
+
* type: "eip1559",
|
|
543
|
+
* value: parseEther("0.000001"),
|
|
544
|
+
* },
|
|
545
|
+
* );
|
|
546
|
+
*
|
|
547
|
+
* const signature = await cdp.evm.signTransaction({
|
|
548
|
+
* address: ethAccount.address,
|
|
549
|
+
* transaction: serializedTx,
|
|
550
|
+
* });
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
async signTransaction(options: SignTransactionOptions): Promise<SignatureResult> {
|
|
554
|
+
const signature = await CdpOpenApiClient.signEvmTransaction(
|
|
555
|
+
options.address,
|
|
556
|
+
{
|
|
557
|
+
transaction: options.transaction,
|
|
558
|
+
},
|
|
559
|
+
options.idempotencyKey,
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
return {
|
|
563
|
+
signature: signature.signedTransaction as Hex,
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Waits for a user operation to complete or fail.
|
|
569
|
+
*
|
|
570
|
+
* @param {WaitForUserOperationOptions} options - Parameters for waiting for the user operation.
|
|
571
|
+
* @param {string} options.smartAccountAddress - The address of the smart account.
|
|
572
|
+
* @param {string} options.userOpHash - The user operation hash.
|
|
573
|
+
* @param {WaitOptions} [options.waitOptions] - Optional parameters for the wait operation.
|
|
574
|
+
*
|
|
575
|
+
* @returns A promise that resolves to the transaction receipt.
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```ts
|
|
579
|
+
* // Send a user operation and get the user operation hash
|
|
580
|
+
* const { userOpHash } = await cdp.evm.sendUserOperation({
|
|
581
|
+
* smartAccount,
|
|
582
|
+
* network: "base-sepolia",
|
|
583
|
+
* calls: [
|
|
584
|
+
* {
|
|
585
|
+
* to: "0x0000000000000000000000000000000000000000",
|
|
586
|
+
* value: parseEther("0.000001"),
|
|
587
|
+
* data: "0x",
|
|
588
|
+
* },
|
|
589
|
+
* ],
|
|
590
|
+
* });
|
|
591
|
+
*
|
|
592
|
+
* // Wait for the user operation to complete or fail
|
|
593
|
+
* const result = await cdp.evm.waitForUserOperation({
|
|
594
|
+
* smartAccountAddress: smartAccount.address,
|
|
595
|
+
* userOpHash: userOp.userOpHash,
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
async waitForUserOperation(
|
|
600
|
+
options: WaitForUserOperationOptions,
|
|
601
|
+
): Promise<WaitForUserOperationReturnType> {
|
|
602
|
+
return waitForUserOperation(CdpOpenApiClient, {
|
|
603
|
+
...options,
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}
|