@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,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
CreateEvmAccountBody,
|
|
10
|
+
EvmAccount,
|
|
11
|
+
ListEvmAccounts200,
|
|
12
|
+
ListEvmAccountsParams,
|
|
13
|
+
SignEvmHash200,
|
|
14
|
+
SignEvmHashBody,
|
|
15
|
+
SignEvmMessage200,
|
|
16
|
+
SignEvmMessageBody,
|
|
17
|
+
SignEvmTransaction200,
|
|
18
|
+
SignEvmTransactionBody,
|
|
19
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
20
|
+
|
|
21
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
22
|
+
|
|
23
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Lists the EVM accounts belonging to the developer's CDP Project.
|
|
27
|
+
The response is paginated, and by default, returns 20 accounts per page.
|
|
28
|
+
* @summary List EVM accounts
|
|
29
|
+
*/
|
|
30
|
+
export const listEvmAccounts = (
|
|
31
|
+
params?: ListEvmAccountsParams,
|
|
32
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
33
|
+
) => {
|
|
34
|
+
return cdpApiClient<ListEvmAccounts200>(
|
|
35
|
+
{ url: `/v2/evm/accounts`, method: "GET", params },
|
|
36
|
+
options,
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new EVM account.
|
|
41
|
+
* @summary Create an EVM account
|
|
42
|
+
*/
|
|
43
|
+
export const createEvmAccount = (
|
|
44
|
+
createEvmAccountBody?: CreateEvmAccountBody,
|
|
45
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
46
|
+
) => {
|
|
47
|
+
return cdpApiClient<EvmAccount>(
|
|
48
|
+
{
|
|
49
|
+
url: `/v2/evm/accounts`,
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers: { "Content-Type": "application/json" },
|
|
52
|
+
data: createEvmAccountBody,
|
|
53
|
+
},
|
|
54
|
+
options,
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Gets an EVM account by its address.
|
|
59
|
+
* @summary Get an EVM account by address
|
|
60
|
+
*/
|
|
61
|
+
export const getEvmAccount = (address: string, options?: SecondParameter<typeof cdpApiClient>) => {
|
|
62
|
+
return cdpApiClient<EvmAccount>({ url: `/v2/evm/accounts/${address}`, method: "GET" }, options);
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Gets an EVM account by its name.
|
|
66
|
+
* @summary Get an EVM account by name
|
|
67
|
+
*/
|
|
68
|
+
export const getEvmAccountByName = (
|
|
69
|
+
name: string,
|
|
70
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
71
|
+
) => {
|
|
72
|
+
return cdpApiClient<EvmAccount>(
|
|
73
|
+
{ url: `/v2/evm/accounts/by-name/${name}`, method: "GET" },
|
|
74
|
+
options,
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Signs a transaction with the given EVM account.
|
|
79
|
+
The transaction should be serialized as a hex string using [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/).
|
|
80
|
+
|
|
81
|
+
The transaction must be an [EIP-1559 dynamic fee transaction](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md). The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.
|
|
82
|
+
* @summary Sign a transaction
|
|
83
|
+
*/
|
|
84
|
+
export const signEvmTransaction = (
|
|
85
|
+
address: string,
|
|
86
|
+
signEvmTransactionBody: SignEvmTransactionBody,
|
|
87
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
88
|
+
) => {
|
|
89
|
+
return cdpApiClient<SignEvmTransaction200>(
|
|
90
|
+
{
|
|
91
|
+
url: `/v2/evm/accounts/${address}/sign/transaction`,
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "Content-Type": "application/json" },
|
|
94
|
+
data: signEvmTransactionBody,
|
|
95
|
+
},
|
|
96
|
+
options,
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Signs an arbitrary 32 byte hash with the given EVM account.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
**WARNING: This API will likely be deprecated in the future.** It is recommended not to depend on it. Never sign a hash that you didn't generate, as it can be an arbitrary transaction. For example, it might send all of your funds to an attacker.
|
|
104
|
+
* @summary Sign a hash
|
|
105
|
+
*/
|
|
106
|
+
export const signEvmHash = (
|
|
107
|
+
address: string,
|
|
108
|
+
signEvmHashBody: SignEvmHashBody,
|
|
109
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
110
|
+
) => {
|
|
111
|
+
return cdpApiClient<SignEvmHash200>(
|
|
112
|
+
{
|
|
113
|
+
url: `/v2/evm/accounts/${address}/sign`,
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: { "Content-Type": "application/json" },
|
|
116
|
+
data: signEvmHashBody,
|
|
117
|
+
},
|
|
118
|
+
options,
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Signs an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) message with the given EVM account.
|
|
123
|
+
|
|
124
|
+
Per the specification, the message in the request body is prepended with `0x19 <0x45 (E)> <thereum Signed Message:\n" + len(message)>` before being signed.
|
|
125
|
+
* @summary Sign an EIP-191 message
|
|
126
|
+
*/
|
|
127
|
+
export const signEvmMessage = (
|
|
128
|
+
address: string,
|
|
129
|
+
signEvmMessageBody: SignEvmMessageBody,
|
|
130
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
131
|
+
) => {
|
|
132
|
+
return cdpApiClient<SignEvmMessage200>(
|
|
133
|
+
{
|
|
134
|
+
url: `/v2/evm/accounts/${address}/sign/message`,
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers: { "Content-Type": "application/json" },
|
|
137
|
+
data: signEvmMessageBody,
|
|
138
|
+
},
|
|
139
|
+
options,
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
export type ListEvmAccountsResult = NonNullable<Awaited<ReturnType<typeof listEvmAccounts>>>;
|
|
143
|
+
export type CreateEvmAccountResult = NonNullable<Awaited<ReturnType<typeof createEvmAccount>>>;
|
|
144
|
+
export type GetEvmAccountResult = NonNullable<Awaited<ReturnType<typeof getEvmAccount>>>;
|
|
145
|
+
export type GetEvmAccountByNameResult = NonNullable<
|
|
146
|
+
Awaited<ReturnType<typeof getEvmAccountByName>>
|
|
147
|
+
>;
|
|
148
|
+
export type SignEvmTransactionResult = NonNullable<Awaited<ReturnType<typeof signEvmTransaction>>>;
|
|
149
|
+
export type SignEvmHashResult = NonNullable<Awaited<ReturnType<typeof signEvmHash>>>;
|
|
150
|
+
export type SignEvmMessageResult = NonNullable<Awaited<ReturnType<typeof signEvmMessage>>>;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
EvmSmartAccount,
|
|
14
|
+
EvmUserOperation,
|
|
15
|
+
ListEvmSmartAccounts200,
|
|
16
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
17
|
+
|
|
18
|
+
export const getListEvmSmartAccountsResponseMock = (): ListEvmSmartAccounts200 => ({
|
|
19
|
+
...{
|
|
20
|
+
accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
21
|
+
() => ({
|
|
22
|
+
address: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
23
|
+
owners: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
24
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
25
|
+
),
|
|
26
|
+
name: faker.helpers.arrayElement([
|
|
27
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
28
|
+
undefined,
|
|
29
|
+
]),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const getCreateEvmSmartAccountResponseMock = (
|
|
37
|
+
overrideResponse: Partial<EvmSmartAccount> = {},
|
|
38
|
+
): EvmSmartAccount => ({
|
|
39
|
+
address: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
40
|
+
owners: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
41
|
+
faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
42
|
+
),
|
|
43
|
+
name: faker.helpers.arrayElement([
|
|
44
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
45
|
+
undefined,
|
|
46
|
+
]),
|
|
47
|
+
...overrideResponse,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const getGetEvmSmartAccountResponseMock = (
|
|
51
|
+
overrideResponse: Partial<EvmSmartAccount> = {},
|
|
52
|
+
): EvmSmartAccount => ({
|
|
53
|
+
address: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
54
|
+
owners: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
|
|
55
|
+
faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
56
|
+
),
|
|
57
|
+
name: faker.helpers.arrayElement([
|
|
58
|
+
faker.helpers.fromRegExp("^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$"),
|
|
59
|
+
undefined,
|
|
60
|
+
]),
|
|
61
|
+
...overrideResponse,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const getPrepareUserOperationResponseMock = (
|
|
65
|
+
overrideResponse: Partial<EvmUserOperation> = {},
|
|
66
|
+
): EvmUserOperation => ({
|
|
67
|
+
network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
|
|
68
|
+
userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
|
|
69
|
+
calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
70
|
+
to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
71
|
+
value: faker.string.alpha(20),
|
|
72
|
+
data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"),
|
|
73
|
+
})),
|
|
74
|
+
status: faker.helpers.arrayElement([
|
|
75
|
+
"pending",
|
|
76
|
+
"signed",
|
|
77
|
+
"broadcast",
|
|
78
|
+
"complete",
|
|
79
|
+
"failed",
|
|
80
|
+
] as const),
|
|
81
|
+
transactionHash: faker.helpers.arrayElement([
|
|
82
|
+
faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
|
|
83
|
+
undefined,
|
|
84
|
+
]),
|
|
85
|
+
...overrideResponse,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const getGetUserOperationResponseMock = (
|
|
89
|
+
overrideResponse: Partial<EvmUserOperation> = {},
|
|
90
|
+
): EvmUserOperation => ({
|
|
91
|
+
network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
|
|
92
|
+
userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
|
|
93
|
+
calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
94
|
+
to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
95
|
+
value: faker.string.alpha(20),
|
|
96
|
+
data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"),
|
|
97
|
+
})),
|
|
98
|
+
status: faker.helpers.arrayElement([
|
|
99
|
+
"pending",
|
|
100
|
+
"signed",
|
|
101
|
+
"broadcast",
|
|
102
|
+
"complete",
|
|
103
|
+
"failed",
|
|
104
|
+
] as const),
|
|
105
|
+
transactionHash: faker.helpers.arrayElement([
|
|
106
|
+
faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
|
|
107
|
+
undefined,
|
|
108
|
+
]),
|
|
109
|
+
...overrideResponse,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const getSendUserOperationResponseMock = (
|
|
113
|
+
overrideResponse: Partial<EvmUserOperation> = {},
|
|
114
|
+
): EvmUserOperation => ({
|
|
115
|
+
network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
|
|
116
|
+
userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
|
|
117
|
+
calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
118
|
+
to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
119
|
+
value: faker.string.alpha(20),
|
|
120
|
+
data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"),
|
|
121
|
+
})),
|
|
122
|
+
status: faker.helpers.arrayElement([
|
|
123
|
+
"pending",
|
|
124
|
+
"signed",
|
|
125
|
+
"broadcast",
|
|
126
|
+
"complete",
|
|
127
|
+
"failed",
|
|
128
|
+
] as const),
|
|
129
|
+
transactionHash: faker.helpers.arrayElement([
|
|
130
|
+
faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
|
|
131
|
+
undefined,
|
|
132
|
+
]),
|
|
133
|
+
...overrideResponse,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export const getListEvmSmartAccountsMockHandler = (
|
|
137
|
+
overrideResponse?:
|
|
138
|
+
| ListEvmSmartAccounts200
|
|
139
|
+
| ((
|
|
140
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
141
|
+
) => Promise<ListEvmSmartAccounts200> | ListEvmSmartAccounts200),
|
|
142
|
+
) => {
|
|
143
|
+
return http.get("*/v2/evm/smart-accounts", async info => {
|
|
144
|
+
await delay(0);
|
|
145
|
+
|
|
146
|
+
return new HttpResponse(
|
|
147
|
+
JSON.stringify(
|
|
148
|
+
overrideResponse !== undefined
|
|
149
|
+
? typeof overrideResponse === "function"
|
|
150
|
+
? await overrideResponse(info)
|
|
151
|
+
: overrideResponse
|
|
152
|
+
: getListEvmSmartAccountsResponseMock(),
|
|
153
|
+
),
|
|
154
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const getCreateEvmSmartAccountMockHandler = (
|
|
160
|
+
overrideResponse?:
|
|
161
|
+
| EvmSmartAccount
|
|
162
|
+
| ((
|
|
163
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
164
|
+
) => Promise<EvmSmartAccount> | EvmSmartAccount),
|
|
165
|
+
) => {
|
|
166
|
+
return http.post("*/v2/evm/smart-accounts", async info => {
|
|
167
|
+
await delay(0);
|
|
168
|
+
|
|
169
|
+
return new HttpResponse(
|
|
170
|
+
JSON.stringify(
|
|
171
|
+
overrideResponse !== undefined
|
|
172
|
+
? typeof overrideResponse === "function"
|
|
173
|
+
? await overrideResponse(info)
|
|
174
|
+
: overrideResponse
|
|
175
|
+
: getCreateEvmSmartAccountResponseMock(),
|
|
176
|
+
),
|
|
177
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const getGetEvmSmartAccountMockHandler = (
|
|
183
|
+
overrideResponse?:
|
|
184
|
+
| EvmSmartAccount
|
|
185
|
+
| ((
|
|
186
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
187
|
+
) => Promise<EvmSmartAccount> | EvmSmartAccount),
|
|
188
|
+
) => {
|
|
189
|
+
return http.get("*/v2/evm/smart-accounts/:address", async info => {
|
|
190
|
+
await delay(0);
|
|
191
|
+
|
|
192
|
+
return new HttpResponse(
|
|
193
|
+
JSON.stringify(
|
|
194
|
+
overrideResponse !== undefined
|
|
195
|
+
? typeof overrideResponse === "function"
|
|
196
|
+
? await overrideResponse(info)
|
|
197
|
+
: overrideResponse
|
|
198
|
+
: getGetEvmSmartAccountResponseMock(),
|
|
199
|
+
),
|
|
200
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const getPrepareUserOperationMockHandler = (
|
|
206
|
+
overrideResponse?:
|
|
207
|
+
| EvmUserOperation
|
|
208
|
+
| ((
|
|
209
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
210
|
+
) => Promise<EvmUserOperation> | EvmUserOperation),
|
|
211
|
+
) => {
|
|
212
|
+
return http.post("*/v2/evm/smart-accounts/:address/user-operations", async info => {
|
|
213
|
+
await delay(0);
|
|
214
|
+
|
|
215
|
+
return new HttpResponse(
|
|
216
|
+
JSON.stringify(
|
|
217
|
+
overrideResponse !== undefined
|
|
218
|
+
? typeof overrideResponse === "function"
|
|
219
|
+
? await overrideResponse(info)
|
|
220
|
+
: overrideResponse
|
|
221
|
+
: getPrepareUserOperationResponseMock(),
|
|
222
|
+
),
|
|
223
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export const getGetUserOperationMockHandler = (
|
|
229
|
+
overrideResponse?:
|
|
230
|
+
| EvmUserOperation
|
|
231
|
+
| ((
|
|
232
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
233
|
+
) => Promise<EvmUserOperation> | EvmUserOperation),
|
|
234
|
+
) => {
|
|
235
|
+
return http.get("*/v2/evm/smart-accounts/:address/user-operations/:userOpHash", async info => {
|
|
236
|
+
await delay(0);
|
|
237
|
+
|
|
238
|
+
return new HttpResponse(
|
|
239
|
+
JSON.stringify(
|
|
240
|
+
overrideResponse !== undefined
|
|
241
|
+
? typeof overrideResponse === "function"
|
|
242
|
+
? await overrideResponse(info)
|
|
243
|
+
: overrideResponse
|
|
244
|
+
: getGetUserOperationResponseMock(),
|
|
245
|
+
),
|
|
246
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const getSendUserOperationMockHandler = (
|
|
252
|
+
overrideResponse?:
|
|
253
|
+
| EvmUserOperation
|
|
254
|
+
| ((
|
|
255
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
256
|
+
) => Promise<EvmUserOperation> | EvmUserOperation),
|
|
257
|
+
) => {
|
|
258
|
+
return http.post(
|
|
259
|
+
"*/v2/evm/smart-accounts/:address/user-operations/:userOpHash/send",
|
|
260
|
+
async info => {
|
|
261
|
+
await delay(0);
|
|
262
|
+
|
|
263
|
+
return new HttpResponse(
|
|
264
|
+
JSON.stringify(
|
|
265
|
+
overrideResponse !== undefined
|
|
266
|
+
? typeof overrideResponse === "function"
|
|
267
|
+
? await overrideResponse(info)
|
|
268
|
+
: overrideResponse
|
|
269
|
+
: getSendUserOperationResponseMock(),
|
|
270
|
+
),
|
|
271
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
export const getEvmSmartAccountsMock = () => [
|
|
277
|
+
getListEvmSmartAccountsMockHandler(),
|
|
278
|
+
getCreateEvmSmartAccountMockHandler(),
|
|
279
|
+
getGetEvmSmartAccountMockHandler(),
|
|
280
|
+
getPrepareUserOperationMockHandler(),
|
|
281
|
+
getGetUserOperationMockHandler(),
|
|
282
|
+
getSendUserOperationMockHandler(),
|
|
283
|
+
];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
CreateEvmSmartAccountBody,
|
|
10
|
+
EvmSmartAccount,
|
|
11
|
+
EvmUserOperation,
|
|
12
|
+
ListEvmSmartAccounts200,
|
|
13
|
+
ListEvmSmartAccountsParams,
|
|
14
|
+
PrepareUserOperationBody,
|
|
15
|
+
SendUserOperationBody,
|
|
16
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
17
|
+
|
|
18
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
19
|
+
|
|
20
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Lists the Smart Accounts belonging to the developer's CDP Project.
|
|
24
|
+
The response is paginated, and by default, returns 20 accounts per page.
|
|
25
|
+
* @summary List Smart Accounts
|
|
26
|
+
*/
|
|
27
|
+
export const listEvmSmartAccounts = (
|
|
28
|
+
params?: ListEvmSmartAccountsParams,
|
|
29
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
30
|
+
) => {
|
|
31
|
+
return cdpApiClient<ListEvmSmartAccounts200>(
|
|
32
|
+
{ url: `/v2/evm/smart-accounts`, method: "GET", params },
|
|
33
|
+
options,
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new Smart Account.
|
|
38
|
+
* @summary Create a Smart Account
|
|
39
|
+
*/
|
|
40
|
+
export const createEvmSmartAccount = (
|
|
41
|
+
createEvmSmartAccountBody: CreateEvmSmartAccountBody,
|
|
42
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
43
|
+
) => {
|
|
44
|
+
return cdpApiClient<EvmSmartAccount>(
|
|
45
|
+
{
|
|
46
|
+
url: `/v2/evm/smart-accounts`,
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: { "Content-Type": "application/json" },
|
|
49
|
+
data: createEvmSmartAccountBody,
|
|
50
|
+
},
|
|
51
|
+
options,
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Gets a Smart Account by its address.
|
|
56
|
+
* @summary Get a Smart Account by address
|
|
57
|
+
*/
|
|
58
|
+
export const getEvmSmartAccount = (
|
|
59
|
+
address: string,
|
|
60
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
61
|
+
) => {
|
|
62
|
+
return cdpApiClient<EvmSmartAccount>(
|
|
63
|
+
{ url: `/v2/evm/smart-accounts/${address}`, method: "GET" },
|
|
64
|
+
options,
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Prepares a new user operation on a Smart Account for a specific network.
|
|
69
|
+
* @summary Prepare a user operation
|
|
70
|
+
*/
|
|
71
|
+
export const prepareUserOperation = (
|
|
72
|
+
address: string,
|
|
73
|
+
prepareUserOperationBody: PrepareUserOperationBody,
|
|
74
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
75
|
+
) => {
|
|
76
|
+
return cdpApiClient<EvmUserOperation>(
|
|
77
|
+
{
|
|
78
|
+
url: `/v2/evm/smart-accounts/${address}/user-operations`,
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: { "Content-Type": "application/json" },
|
|
81
|
+
data: prepareUserOperationBody,
|
|
82
|
+
},
|
|
83
|
+
options,
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Gets a user operation by its hash.
|
|
88
|
+
* @summary Get a user operation
|
|
89
|
+
*/
|
|
90
|
+
export const getUserOperation = (
|
|
91
|
+
address: string,
|
|
92
|
+
userOpHash: string,
|
|
93
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
94
|
+
) => {
|
|
95
|
+
return cdpApiClient<EvmUserOperation>(
|
|
96
|
+
{ url: `/v2/evm/smart-accounts/${address}/user-operations/${userOpHash}`, method: "GET" },
|
|
97
|
+
options,
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Sends a user operation with a signature.
|
|
102
|
+
* @summary Send a user operation
|
|
103
|
+
*/
|
|
104
|
+
export const sendUserOperation = (
|
|
105
|
+
address: string,
|
|
106
|
+
userOpHash: string,
|
|
107
|
+
sendUserOperationBody: SendUserOperationBody,
|
|
108
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
109
|
+
) => {
|
|
110
|
+
return cdpApiClient<EvmUserOperation>(
|
|
111
|
+
{
|
|
112
|
+
url: `/v2/evm/smart-accounts/${address}/user-operations/${userOpHash}/send`,
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "Content-Type": "application/json" },
|
|
115
|
+
data: sendUserOperationBody,
|
|
116
|
+
},
|
|
117
|
+
options,
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
export type ListEvmSmartAccountsResult = NonNullable<
|
|
121
|
+
Awaited<ReturnType<typeof listEvmSmartAccounts>>
|
|
122
|
+
>;
|
|
123
|
+
export type CreateEvmSmartAccountResult = NonNullable<
|
|
124
|
+
Awaited<ReturnType<typeof createEvmSmartAccount>>
|
|
125
|
+
>;
|
|
126
|
+
export type GetEvmSmartAccountResult = NonNullable<Awaited<ReturnType<typeof getEvmSmartAccount>>>;
|
|
127
|
+
export type PrepareUserOperationResult = NonNullable<
|
|
128
|
+
Awaited<ReturnType<typeof prepareUserOperation>>
|
|
129
|
+
>;
|
|
130
|
+
export type GetUserOperationResult = NonNullable<Awaited<ReturnType<typeof getUserOperation>>>;
|
|
131
|
+
export type SendUserOperationResult = NonNullable<Awaited<ReturnType<typeof sendUserOperation>>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
RequestEvmFaucet200,
|
|
14
|
+
RequestSolanaFaucet200,
|
|
15
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
16
|
+
|
|
17
|
+
export const getRequestEvmFaucetResponseMock = (
|
|
18
|
+
overrideResponse: Partial<RequestEvmFaucet200> = {},
|
|
19
|
+
): RequestEvmFaucet200 => ({ transactionHash: faker.string.alpha(20), ...overrideResponse });
|
|
20
|
+
|
|
21
|
+
export const getRequestSolanaFaucetResponseMock = (
|
|
22
|
+
overrideResponse: Partial<RequestSolanaFaucet200> = {},
|
|
23
|
+
): RequestSolanaFaucet200 => ({
|
|
24
|
+
transactionSignature: faker.string.alpha(20),
|
|
25
|
+
...overrideResponse,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const getRequestEvmFaucetMockHandler = (
|
|
29
|
+
overrideResponse?:
|
|
30
|
+
| RequestEvmFaucet200
|
|
31
|
+
| ((
|
|
32
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
33
|
+
) => Promise<RequestEvmFaucet200> | RequestEvmFaucet200),
|
|
34
|
+
) => {
|
|
35
|
+
return http.post("*/v2/evm/faucet", async info => {
|
|
36
|
+
await delay(0);
|
|
37
|
+
|
|
38
|
+
return new HttpResponse(
|
|
39
|
+
JSON.stringify(
|
|
40
|
+
overrideResponse !== undefined
|
|
41
|
+
? typeof overrideResponse === "function"
|
|
42
|
+
? await overrideResponse(info)
|
|
43
|
+
: overrideResponse
|
|
44
|
+
: getRequestEvmFaucetResponseMock(),
|
|
45
|
+
),
|
|
46
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getRequestSolanaFaucetMockHandler = (
|
|
52
|
+
overrideResponse?:
|
|
53
|
+
| RequestSolanaFaucet200
|
|
54
|
+
| ((
|
|
55
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
56
|
+
) => Promise<RequestSolanaFaucet200> | RequestSolanaFaucet200),
|
|
57
|
+
) => {
|
|
58
|
+
return http.post("*/v2/solana/faucet", async info => {
|
|
59
|
+
await delay(0);
|
|
60
|
+
|
|
61
|
+
return new HttpResponse(
|
|
62
|
+
JSON.stringify(
|
|
63
|
+
overrideResponse !== undefined
|
|
64
|
+
? typeof overrideResponse === "function"
|
|
65
|
+
? await overrideResponse(info)
|
|
66
|
+
: overrideResponse
|
|
67
|
+
: getRequestSolanaFaucetResponseMock(),
|
|
68
|
+
),
|
|
69
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
export const getFaucetsMock = () => [
|
|
74
|
+
getRequestEvmFaucetMockHandler(),
|
|
75
|
+
getRequestSolanaFaucetMockHandler(),
|
|
76
|
+
];
|