@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 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../types/calls.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,eAAe,SAAS,MAAM,CAAC,MAA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AE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Abi, AbiFunction, AbiParametersToPrimitiveTypes, AbiStateMutability, Address, ExtractAbiFunction, ExtractAbiFunctionNames, ResolvedRegister } from "abitype";
|
|
2
|
-
import type { Hex } from "./misc";
|
|
3
|
-
import type { IsUnion, UnionToTuple } from "./utils";
|
|
2
|
+
import type { Hex } from "./misc.js";
|
|
3
|
+
import type { IsUnion, UnionToTuple } from "./utils.js";
|
|
4
4
|
export type ContractFunctionName<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability> = ExtractAbiFunctionNames<abi extends Abi ? abi : Abi, mutability> extends infer functionName extends string ? [functionName] extends [never] ? string : functionName : string;
|
|
5
5
|
export type ContractFunctionArgs<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability, functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<abi, mutability>> = AbiParametersToPrimitiveTypes<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>["inputs"], "inputs"> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[];
|
|
6
6
|
export type Widen<type> = ([unknown] extends [type] ? unknown : never) | (type extends Function ? type : never) | (type extends ResolvedRegister["BigIntType"] ? bigint : never) | (type extends boolean ? boolean : never) | (type extends ResolvedRegister["IntType"] ? number : never) | (type extends string ? type extends ResolvedRegister["AddressType"] ? ResolvedRegister["AddressType"] : type extends ResolvedRegister["BytesType"]["inputs"] ? ResolvedRegister["BytesType"] : string : never) | (type extends readonly [] ? readonly [] : never) | (type extends Record<string, unknown> ? {
|
|
@@ -28,3 +28,4 @@ export type ContractFunctionParameters<abi extends Abi | readonly unknown[] = Ab
|
|
|
28
28
|
address: Address;
|
|
29
29
|
});
|
|
30
30
|
export {};
|
|
31
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources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,EAAE,UAAU,CAAC,EACxD,OAAO,GAAG,oBAAoB,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,IAK3D;IACF,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,EACR,gBAAgB,GAChB,CAAC,YAAY,SAAS,gBAAgB,GAAG,YAAY,GAAG,KAAK,CAAC,CAAC;IACnE,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;CAC3E,GAAG,CAAC,SAAS,EAAE,SAAS,OAAO,GAAG,EAAE,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,GAC5D,CAAC,UAAU,SAAS,IAAI,GAAG;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../types/misc.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;AACjC,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ContractFunctionArgs, ContractFunctionName, ContractFunctionParameters } from "./contract.js";
|
|
1
2
|
import type { Abi, AbiStateMutability } from "abitype";
|
|
2
|
-
import type { ContractFunctionArgs, ContractFunctionName, ContractFunctionParameters } from "./contract";
|
|
3
3
|
export type GetMulticallContractParameters<contract, mutability extends AbiStateMutability> = contract extends {
|
|
4
4
|
abi: infer abi extends Abi;
|
|
5
5
|
} ? contract extends {
|
|
@@ -7,3 +7,4 @@ export type GetMulticallContractParameters<contract, mutability extends AbiState
|
|
|
7
7
|
} ? contract extends {
|
|
8
8
|
args: infer args extends ContractFunctionArgs<abi, mutability, functionName>;
|
|
9
9
|
} ? ContractFunctionParameters<abi, mutability, functionName, args> : ContractFunctionParameters<abi, mutability, functionName> : Abi extends abi ? ContractFunctionParameters : ContractFunctionParameters<abi, mutability> : ContractFunctionParameters<readonly unknown[]>;
|
|
10
|
+
//# sourceMappingURL=multicall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multicall.d.ts","sourceRoot":"","sources":["../../types/multicall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGvD,MAAM,MAAM,8BAA8B,CACxC,QAAQ,EACR,UAAU,SAAS,kBAAkB,IACnC,QAAQ,SAAS;IAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,CAAA;CAAE,GAE/C,QAAQ,SAAS;IACf,YAAY,EAAE,MAAM,YAAY,SAAS,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;CAChF,GAEC,QAAQ,SAAS;IACf,IAAI,EAAE,MAAM,IAAI,SAAS,oBAAoB,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;CAC9E,GACC,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,GAC/D,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,GAE3D,GAAG,SAAS,GAAG,GACb,0BAA0B,GAE1B,0BAA0B,CAAC,GAAG,EAAE,UAAU,CAAC,GAC/C,0BAA0B,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","s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AAC,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;AAE3F;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../utils/wait.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EACjC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,EAC/B,SAAS,GAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAmC,EAC1D,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { serializeTransaction, TransactionSerializable } from "viem";
|
|
2
|
+
|
|
3
|
+
import { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
|
|
4
|
+
import { EvmServerAccount } from "../types.js";
|
|
5
|
+
|
|
6
|
+
import type { Address, Hash } from "../../types/misc.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for converting a pre-existing EvmAccount to a EvmServerAccount.
|
|
10
|
+
*/
|
|
11
|
+
export type ToEvmServerAccountOptions = {
|
|
12
|
+
/** The EvmAccount that was previously created. */
|
|
13
|
+
account: EvmAccount;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Server-managed EvmAccount instance from an existing EvmAccount.
|
|
18
|
+
* Use this to interact with previously deployed EvmAccounts, rather than creating new ones.
|
|
19
|
+
*
|
|
20
|
+
* @param {CdpOpenApiClientType} apiClient - The API client.
|
|
21
|
+
* @param {ToEvmServerAccountOptions} options - Configuration options.
|
|
22
|
+
* @param {EvmAccount} options.account - The EvmAccount that was previously created.
|
|
23
|
+
* @returns {EvmServerAccount} A configured EvmAccount instance ready for signing.
|
|
24
|
+
*/
|
|
25
|
+
export function toEvmServerAccount(
|
|
26
|
+
apiClient: CdpOpenApiClientType,
|
|
27
|
+
options: ToEvmServerAccountOptions,
|
|
28
|
+
): EvmServerAccount {
|
|
29
|
+
const account: EvmServerAccount = {
|
|
30
|
+
address: options.account.address as Address,
|
|
31
|
+
async signMessage({ message }) {
|
|
32
|
+
const result = await apiClient.signEvmMessage(options.account.address, {
|
|
33
|
+
message: message.toString(),
|
|
34
|
+
});
|
|
35
|
+
return result.signature as `0x${string}`;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
async sign(parameters: { hash: Hash }) {
|
|
39
|
+
const result = await apiClient.signEvmHash(options.account.address, {
|
|
40
|
+
hash: parameters.hash,
|
|
41
|
+
});
|
|
42
|
+
return result.signature as `0x${string}`;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
async signTransaction(transaction: TransactionSerializable) {
|
|
46
|
+
const result = await apiClient.signEvmTransaction(options.account.address, {
|
|
47
|
+
transaction: serializeTransaction(transaction),
|
|
48
|
+
});
|
|
49
|
+
return result.signedTransaction as `0x${string}`;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
async signTypedData() {
|
|
53
|
+
throw new Error("Not implemented");
|
|
54
|
+
},
|
|
55
|
+
name: options.account.name,
|
|
56
|
+
type: "evm-server",
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return account;
|
|
60
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EvmSmartAccount as EvmSmartAccountModel } from "../../openapi-client/index.js";
|
|
2
|
+
import { EvmAccount, EvmSmartAccount } from "../types.js";
|
|
3
|
+
|
|
4
|
+
import type { Address } from "../../types/misc.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for converting a pre-existing EvmSmartAccount and owner to a EvmSmartAccount
|
|
8
|
+
*/
|
|
9
|
+
export type ToEvmSmartAccountOptions = {
|
|
10
|
+
/** The pre-existing EvmSmartAccount. */
|
|
11
|
+
smartAccount: EvmSmartAccountModel;
|
|
12
|
+
/** The owner of the smart account. */
|
|
13
|
+
owner: EvmAccount;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a EvmSmartAccount instance from an existing EvmSmartAccount and owner.
|
|
18
|
+
* Use this to interact with previously deployed EvmSmartAccounts, rather than creating new ones.
|
|
19
|
+
*
|
|
20
|
+
* The owner must be the original owner of the evm smart account.
|
|
21
|
+
*
|
|
22
|
+
* @param {ToEvmSmartAccountOptions} options - Configuration options.
|
|
23
|
+
* @param {EvmSmartAccount} options.smartAccount - The deployed evm smart account.
|
|
24
|
+
* @param {EvmAccount} options.owner - The owner which signs for the smart account.
|
|
25
|
+
* @returns {EvmSmartAccount} A configured EvmSmartAccount instance ready for user operation submission.
|
|
26
|
+
* @throws {Error} If the account is not an original owner of the smart account.
|
|
27
|
+
*/
|
|
28
|
+
export function toEvmSmartAccount(options: ToEvmSmartAccountOptions): EvmSmartAccount {
|
|
29
|
+
const account: EvmSmartAccount = {
|
|
30
|
+
address: options.smartAccount.address as Address,
|
|
31
|
+
owners: [options.owner],
|
|
32
|
+
name: options.smartAccount.name,
|
|
33
|
+
type: "evm-smart",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return account;
|
|
37
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SignableMessage, TransactionSerializable, TypedData, TypedDataDefinition } from "viem";
|
|
2
|
+
|
|
3
|
+
import { Prettify } from "../types/utils.js";
|
|
4
|
+
|
|
5
|
+
import type { Hash, Hex, Address } from "../types/misc.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base type for any Ethereum account with signing capabilities.
|
|
9
|
+
* For example, this could be an EVM ServerAccount, or a viem LocalAccount.
|
|
10
|
+
*/
|
|
11
|
+
export type EvmAccount = {
|
|
12
|
+
/** The address of the signer. */
|
|
13
|
+
address: Address;
|
|
14
|
+
/** Signs a message hash and returns the signature as a hex string. */
|
|
15
|
+
sign: (parameters: { hash: Hash }) => Promise<Hex>;
|
|
16
|
+
/** Signs a message and returns the signature as a hex string. */
|
|
17
|
+
signMessage: (parameters: { message: SignableMessage }) => Promise<Hex>;
|
|
18
|
+
/** Signs a transaction and returns the signed transaction as a hex string. */
|
|
19
|
+
signTransaction: (transaction: TransactionSerializable) => Promise<Hex>;
|
|
20
|
+
/** Signs a typed data and returns the signature as a hex string. */
|
|
21
|
+
signTypedData: <
|
|
22
|
+
const typedData extends TypedData | Record<string, unknown>,
|
|
23
|
+
primaryType extends keyof typedData | "EIP712Domain" = keyof typedData,
|
|
24
|
+
>(
|
|
25
|
+
parameters: TypedDataDefinition<typedData, primaryType>,
|
|
26
|
+
) => Promise<Hex>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Server-managed ethereum account
|
|
31
|
+
*/
|
|
32
|
+
export type EvmServerAccount = Prettify<
|
|
33
|
+
EvmAccount & {
|
|
34
|
+
/** Optional name for the server account. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Indicates this is a server-managed account. */
|
|
37
|
+
type: "evm-server";
|
|
38
|
+
}
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Ethereum smart account which supports account abstraction features like user operations, batch transactions, and paymaster.
|
|
43
|
+
*/
|
|
44
|
+
export type EvmSmartAccount = {
|
|
45
|
+
/** The smart account's address. */
|
|
46
|
+
address: Address;
|
|
47
|
+
/** The name of the smart account. */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** Array of accounts that own and can sign for the smart account (currently only supports one owner but will be extended to support multiple owners in the future). */
|
|
50
|
+
owners: EvmAccount[];
|
|
51
|
+
/** Identifier for the smart account type. */
|
|
52
|
+
type: "evm-smart";
|
|
53
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
EvmUserOperationNetwork,
|
|
5
|
+
EvmUserOperationStatus,
|
|
6
|
+
CdpOpenApiClientType,
|
|
7
|
+
} from "../../openapi-client/index.js";
|
|
8
|
+
|
|
9
|
+
import type { EvmSmartAccount } from "../../accounts/types.js";
|
|
10
|
+
import type { Calls } from "../../types/calls.js";
|
|
11
|
+
import type { Address, Hex } from "../../types/misc.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for sending a user operation.
|
|
15
|
+
*
|
|
16
|
+
* @template T - Array type for the calls parameter.
|
|
17
|
+
*/
|
|
18
|
+
export type SendUserOperationOptions<T extends readonly unknown[]> = {
|
|
19
|
+
/**
|
|
20
|
+
* Array of contract calls to execute in the user operation.
|
|
21
|
+
* Each call can either be:
|
|
22
|
+
* - A direct call with `to`, `value`, and `data`.
|
|
23
|
+
* - A contract call with `to`, `abi`, `functionName`, and `args`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const calls = [
|
|
28
|
+
* {
|
|
29
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
30
|
+
* value: parseEther("0.0000005"),
|
|
31
|
+
* data: "0x",
|
|
32
|
+
* },
|
|
33
|
+
* {
|
|
34
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
35
|
+
* abi: erc20Abi,
|
|
36
|
+
* functionName: "transfer",
|
|
37
|
+
* args: [to, amount],
|
|
38
|
+
* },
|
|
39
|
+
* ]
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
calls: Calls<T>;
|
|
43
|
+
/** Chain ID of the network to execute on. */
|
|
44
|
+
network: EvmUserOperationNetwork;
|
|
45
|
+
/** Optional URL of the paymaster service to use for gas sponsorship. Must be ERC-7677 compliant. */
|
|
46
|
+
paymasterUrl?: string;
|
|
47
|
+
/** The idempotency key. */
|
|
48
|
+
idempotencyKey?: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Return type for the sendUserOperation function.
|
|
53
|
+
*/
|
|
54
|
+
export type SendUserOperationReturnType = {
|
|
55
|
+
/** The address of the smart wallet. */
|
|
56
|
+
smartAccountAddress: Address;
|
|
57
|
+
/** The status of the user operation. */
|
|
58
|
+
status: typeof EvmUserOperationStatus.broadcast;
|
|
59
|
+
/** The hash of the user operation. This is not the transaction hash which is only available after the operation is completed.*/
|
|
60
|
+
userOpHash: Hex;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Sends a user operation to the network.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { sendUserOperation } from "@coinbase/cdp-sdk";
|
|
69
|
+
* import { parseEther } from "viem";
|
|
70
|
+
* import { CdpClient } from "@coinbase/cdp-sdk";
|
|
71
|
+
*
|
|
72
|
+
* const client = new CdpClient({
|
|
73
|
+
* apiKeyId: "your-api-key-id",
|
|
74
|
+
* apiKeySecret: "your-api-key-secret",
|
|
75
|
+
* walletSecret: "your-wallet-secret",
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const ethAccount = await client.createEvmServerAccount()
|
|
79
|
+
* const smartAccount = await client.createEvmSmartAccount({ owner: ethAccount })
|
|
80
|
+
*
|
|
81
|
+
* const result = await sendUserOperation(client, smartAccount, {
|
|
82
|
+
* calls: [
|
|
83
|
+
* {
|
|
84
|
+
* abi: erc20Abi,
|
|
85
|
+
* functionName: "transfer",
|
|
86
|
+
* args: [to, amount],
|
|
87
|
+
* },
|
|
88
|
+
* {
|
|
89
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
90
|
+
* data: "0x",
|
|
91
|
+
* value: parseEther("0.0000005"),
|
|
92
|
+
* },
|
|
93
|
+
* ],
|
|
94
|
+
* network: "base-sepolia",
|
|
95
|
+
* paymasterUrl: "https://api.developer.coinbase.com/rpc/v1/base/someapikey",
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param {CdpOpenApiClientType} client - The client to use to send the user operation.
|
|
100
|
+
* @param {EvmSmartAccount} smartAccount - The smart account to send the user operation from.
|
|
101
|
+
* @param {SendUserOperationOptions<T>} options - The options for the user operation.
|
|
102
|
+
* @returns {Promise<SendUserOperationReturnType>} The result of the user operation.
|
|
103
|
+
*/
|
|
104
|
+
export async function sendUserOperation<T extends readonly unknown[]>(
|
|
105
|
+
client: CdpOpenApiClientType,
|
|
106
|
+
smartAccount: EvmSmartAccount,
|
|
107
|
+
options: SendUserOperationOptions<T>,
|
|
108
|
+
): Promise<SendUserOperationReturnType> {
|
|
109
|
+
const { calls, network, paymasterUrl } = options;
|
|
110
|
+
|
|
111
|
+
if (calls.length === 0) {
|
|
112
|
+
throw new Error("Calls array is empty");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const encodedCalls = calls.map(call => {
|
|
116
|
+
const value = (call.value ?? BigInt(0)).toString();
|
|
117
|
+
|
|
118
|
+
if ("abi" in call && call.abi && "functionName" in call) {
|
|
119
|
+
return {
|
|
120
|
+
to: call.to,
|
|
121
|
+
data: encodeFunctionData({
|
|
122
|
+
abi: call.abi,
|
|
123
|
+
functionName: call.functionName,
|
|
124
|
+
args: call.args,
|
|
125
|
+
}),
|
|
126
|
+
value,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
to: call.to,
|
|
132
|
+
data: call.data ?? "0x",
|
|
133
|
+
value,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const createOpResponse = await client.prepareUserOperation(smartAccount.address, {
|
|
138
|
+
network,
|
|
139
|
+
calls: encodedCalls,
|
|
140
|
+
paymasterUrl,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const owner = smartAccount.owners[0];
|
|
144
|
+
|
|
145
|
+
const signature = await owner.sign({
|
|
146
|
+
hash: createOpResponse.userOpHash as Hex,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const broadcastResponse = await client.sendUserOperation(
|
|
150
|
+
smartAccount.address,
|
|
151
|
+
createOpResponse.userOpHash as Hex,
|
|
152
|
+
{
|
|
153
|
+
signature,
|
|
154
|
+
},
|
|
155
|
+
options.idempotencyKey,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
smartAccountAddress: smartAccount.address,
|
|
160
|
+
status: broadcastResponse.status,
|
|
161
|
+
userOpHash: createOpResponse.userOpHash,
|
|
162
|
+
} as SendUserOperationReturnType;
|
|
163
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EvmUserOperationStatus,
|
|
3
|
+
EvmUserOperation,
|
|
4
|
+
CdpOpenApiClientType,
|
|
5
|
+
} from "../../openapi-client/index.js";
|
|
6
|
+
import { wait, WaitOptions } from "../../utils/wait.js";
|
|
7
|
+
|
|
8
|
+
import type { Address, Hex } from "../../types/misc.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for waiting for a user operation.
|
|
12
|
+
*/
|
|
13
|
+
export type WaitForUserOperationOptions = {
|
|
14
|
+
/** The hash of the user operation. */
|
|
15
|
+
userOpHash: Hex;
|
|
16
|
+
/** The address of the smart account. */
|
|
17
|
+
smartAccountAddress: Address;
|
|
18
|
+
/** Optional options for the wait operation. */
|
|
19
|
+
waitOptions?: WaitOptions;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents a failed user operation.
|
|
24
|
+
*/
|
|
25
|
+
export type FailedOperation = {
|
|
26
|
+
/** The address of the smart account. */
|
|
27
|
+
smartAccountAddress: Address;
|
|
28
|
+
/** The status of the user operation. */
|
|
29
|
+
status: typeof EvmUserOperationStatus.failed;
|
|
30
|
+
/** The hash of the user operation. This is not the transaction hash which is only available after the operation is completed.*/
|
|
31
|
+
userOpHash: Hex;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents a completed user operation.
|
|
36
|
+
*/
|
|
37
|
+
export type CompletedOperation = {
|
|
38
|
+
/** The address of the smart account. */
|
|
39
|
+
smartAccountAddress: Address;
|
|
40
|
+
/** The transaction hash that executed the completed user operation. */
|
|
41
|
+
transactionHash: string;
|
|
42
|
+
/** The status of the user operation. */
|
|
43
|
+
status: typeof EvmUserOperationStatus.complete;
|
|
44
|
+
/** The hash of the user operation. This is not the transaction hash which is only available after the operation is completed.*/
|
|
45
|
+
userOpHash: Hex;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Represents the return type of the waitForUserOperation function.
|
|
50
|
+
*/
|
|
51
|
+
export type WaitForUserOperationReturnType = FailedOperation | CompletedOperation;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Waits for a user operation to complete or fail.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { waitForUserOperation } from "@coinbase/cdp-sdk";
|
|
59
|
+
*
|
|
60
|
+
* const result = await waitForUserOperation(client, {
|
|
61
|
+
* userOpHash: "0x1234567890123456789012345678901234567890",
|
|
62
|
+
* smartAccountAddress: "0x1234567890123456789012345678901234567890",
|
|
63
|
+
* waitOptions: {
|
|
64
|
+
* timeoutSeconds: 30,
|
|
65
|
+
* },
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {CdpOpenApiClientType} client - The client to use to wait for the user operation.
|
|
70
|
+
* @param {WaitForUserOperationOptions} options - The options for the wait operation.
|
|
71
|
+
* @returns {Promise<WaitForUserOperationReturnType>} The result of the user operation.
|
|
72
|
+
*/
|
|
73
|
+
export async function waitForUserOperation(
|
|
74
|
+
client: CdpOpenApiClientType,
|
|
75
|
+
options: WaitForUserOperationOptions,
|
|
76
|
+
): Promise<WaitForUserOperationReturnType> {
|
|
77
|
+
const { userOpHash, smartAccountAddress } = options;
|
|
78
|
+
|
|
79
|
+
const reload = async () => {
|
|
80
|
+
const response = await client.getUserOperation(smartAccountAddress, userOpHash);
|
|
81
|
+
return response;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const transform = (operation: EvmUserOperation): WaitForUserOperationReturnType => {
|
|
85
|
+
if (operation.status === EvmUserOperationStatus.failed) {
|
|
86
|
+
return {
|
|
87
|
+
smartAccountAddress: smartAccountAddress,
|
|
88
|
+
status: EvmUserOperationStatus.failed,
|
|
89
|
+
userOpHash: operation.userOpHash as Hex,
|
|
90
|
+
} satisfies FailedOperation;
|
|
91
|
+
} else if (operation.status === EvmUserOperationStatus.complete) {
|
|
92
|
+
return {
|
|
93
|
+
smartAccountAddress: smartAccountAddress,
|
|
94
|
+
transactionHash: operation.transactionHash!,
|
|
95
|
+
status: EvmUserOperationStatus.complete,
|
|
96
|
+
userOpHash: operation.userOpHash as Hex,
|
|
97
|
+
} satisfies CompletedOperation;
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error("User operation is not terminal");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const waitOptions = options.waitOptions || {
|
|
104
|
+
timeoutSeconds: 30,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return await wait(reload, isTerminal, transform, waitOptions);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isTerminal = (operation: EvmUserOperation): boolean => {
|
|
111
|
+
return (
|
|
112
|
+
operation.status === EvmUserOperationStatus.complete ||
|
|
113
|
+
operation.status === EvmUserOperationStatus.failed
|
|
114
|
+
);
|
|
115
|
+
};
|
package/analytics.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import md5 from "md5";
|
|
2
|
+
|
|
3
|
+
import { CdpClient } from "./client/cdp.js";
|
|
4
|
+
import { EvmClient } from "./client/evm/evm.js";
|
|
5
|
+
import { SolanaClient } from "./client/solana/solana.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The data in an error event
|
|
9
|
+
*/
|
|
10
|
+
type ErrorEventData = {
|
|
11
|
+
/**
|
|
12
|
+
* The API method where the error occurred, e.g. createAccount, getAccount
|
|
13
|
+
*/
|
|
14
|
+
method: string;
|
|
15
|
+
/**
|
|
16
|
+
* The error message
|
|
17
|
+
*/
|
|
18
|
+
message: string;
|
|
19
|
+
/**
|
|
20
|
+
* The error stack trace
|
|
21
|
+
*/
|
|
22
|
+
stack?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The name of the event. This should match the name in AEC
|
|
25
|
+
*/
|
|
26
|
+
name: "error";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type EventData = ErrorEventData;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sends an analytics event to the default endpoint
|
|
33
|
+
*
|
|
34
|
+
* @param event - The event data containing event-specific fields
|
|
35
|
+
* @returns Promise that resolves when the event is sent
|
|
36
|
+
*/
|
|
37
|
+
export async function sendEvent(event: EventData): Promise<void> {
|
|
38
|
+
const timestamp = Date.now();
|
|
39
|
+
|
|
40
|
+
const enhancedEvent = {
|
|
41
|
+
event_type: event.name,
|
|
42
|
+
platform: "server",
|
|
43
|
+
event_properties: {
|
|
44
|
+
platform: "server",
|
|
45
|
+
project_name: "cdp-sdk",
|
|
46
|
+
time_start: timestamp,
|
|
47
|
+
cdp_sdk_language: "typescript",
|
|
48
|
+
...event,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const events = [enhancedEvent];
|
|
53
|
+
const stringifiedEventData = JSON.stringify(events);
|
|
54
|
+
const uploadTime = timestamp.toString();
|
|
55
|
+
|
|
56
|
+
const checksum = md5(stringifiedEventData + uploadTime);
|
|
57
|
+
|
|
58
|
+
const analyticsServiceData = {
|
|
59
|
+
e: stringifiedEventData,
|
|
60
|
+
checksum,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const apiEndpoint = "https://cca-lite.coinbase.com";
|
|
64
|
+
const eventPath = "/amp";
|
|
65
|
+
const eventEndPoint = `${apiEndpoint}${eventPath}`;
|
|
66
|
+
|
|
67
|
+
const response = await fetch(eventEndPoint, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
mode: "no-cors",
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify(analyticsServiceData),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Wraps all methods of a class with error tracking.
|
|
83
|
+
*
|
|
84
|
+
* @param ClassToWrap - The class whose prototype methods should be wrapped.
|
|
85
|
+
*/
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
function wrapClassWithErrorTracking(ClassToWrap: any): void {
|
|
88
|
+
const methodNames = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(
|
|
89
|
+
name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
for (const methodName of methodNames) {
|
|
93
|
+
const originalMethod = ClassToWrap.prototype[methodName];
|
|
94
|
+
ClassToWrap.prototype[methodName] = async function (...args: unknown[]) {
|
|
95
|
+
try {
|
|
96
|
+
return await originalMethod.apply(this, args);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!(error instanceof Error)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const { message, stack } = error;
|
|
103
|
+
|
|
104
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING !== "true") {
|
|
105
|
+
sendEvent({
|
|
106
|
+
method: String(methodName),
|
|
107
|
+
message,
|
|
108
|
+
stack,
|
|
109
|
+
name: "error",
|
|
110
|
+
}).catch(() => {
|
|
111
|
+
// ignore error
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
wrapClassWithErrorTracking(CdpClient);
|
|
122
|
+
wrapClassWithErrorTracking(EvmClient);
|
|
123
|
+
wrapClassWithErrorTracking(SolanaClient);
|