@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,303 @@
|
|
|
1
|
+
import { SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
|
|
2
|
+
import { Call, Calls } from "../../types/calls.js";
|
|
3
|
+
import { Address, Hex } from "../../types/misc.js";
|
|
4
|
+
import { WaitOptions } from "../../utils/wait.js";
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
EvmAccount as Account,
|
|
8
|
+
EvmServerAccount as ServerAccount,
|
|
9
|
+
EvmSmartAccount as SmartAccount,
|
|
10
|
+
} from "../../accounts/types.js";
|
|
11
|
+
import type {
|
|
12
|
+
EvmUserOperationNetwork,
|
|
13
|
+
EvmUserOperationStatus,
|
|
14
|
+
OpenApiEvmMethods,
|
|
15
|
+
} from "../../openapi-client/index.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The EvmClient type, where all OpenApiEvmMethods methods are wrapped.
|
|
19
|
+
*/
|
|
20
|
+
export type EvmClientInterface = Omit<
|
|
21
|
+
typeof OpenApiEvmMethods,
|
|
22
|
+
| "createEvmAccount" // mapped to createAccount
|
|
23
|
+
| "createEvmSmartAccount" // mapped to createSmartAccount
|
|
24
|
+
| "getEvmAccount" // mapped to getAccount
|
|
25
|
+
| "getEvmAccountByName" // mapped to getAccount
|
|
26
|
+
| "getEvmSmartAccount" // mapped to getSmartAccount
|
|
27
|
+
| "getUserOperation"
|
|
28
|
+
| "listEVMBalances" // omit
|
|
29
|
+
| "listEvmAccounts" // mapped to listAccounts
|
|
30
|
+
| "listEvmSmartAccounts" // mapped to listSmartAccounts
|
|
31
|
+
| "prepareUserOperation"
|
|
32
|
+
| "requestEvmFaucet" // mapped to requestFaucet
|
|
33
|
+
| "sendUserOperation"
|
|
34
|
+
| "signEvmHash" // mapped to signHash
|
|
35
|
+
| "signEvmMessage" // mapped to signMessage
|
|
36
|
+
| "signEvmTransaction" // mapped to signTransaction
|
|
37
|
+
> & {
|
|
38
|
+
createAccount: (options: CreateServerAccountOptions) => Promise<ServerAccount>;
|
|
39
|
+
createSmartAccount: (options: CreateSmartAccountOptions) => Promise<SmartAccount>;
|
|
40
|
+
getAccount: (options: GetServerAccountOptions) => Promise<ServerAccount>;
|
|
41
|
+
getSmartAccount: (options: GetSmartAccountOptions) => Promise<SmartAccount>;
|
|
42
|
+
getUserOperation: (options: GetUserOperationOptions) => Promise<UserOperation>;
|
|
43
|
+
listAccounts: (options: ListServerAccountsOptions) => Promise<ListServerAccountResult>;
|
|
44
|
+
listSmartAccounts: (options: ListSmartAccountsOptions) => Promise<ListSmartAccountResult>;
|
|
45
|
+
prepareUserOperation: (options: PrepareUserOperationOptions) => Promise<UserOperation>;
|
|
46
|
+
requestFaucet: (options: RequestFaucetOptions) => Promise<RequestFaucetResult>;
|
|
47
|
+
sendUserOperation: (options: SendUserOperationOptions) => Promise<SendUserOperationReturnType>;
|
|
48
|
+
signHash: (options: SignHashOptions) => Promise<SignatureResult>;
|
|
49
|
+
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
50
|
+
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type { ServerAccount, SmartAccount };
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Options for getting a user operation.
|
|
57
|
+
*/
|
|
58
|
+
export interface GetUserOperationOptions {
|
|
59
|
+
/** The smart account. */
|
|
60
|
+
smartAccount: SmartAccount;
|
|
61
|
+
/** The user operation hash. */
|
|
62
|
+
userOpHash: Hex;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Options for preparing a user operation.
|
|
67
|
+
*/
|
|
68
|
+
export interface PrepareUserOperationOptions {
|
|
69
|
+
/** The smart account. */
|
|
70
|
+
smartAccount: SmartAccount;
|
|
71
|
+
/** The network. */
|
|
72
|
+
network: EvmUserOperationNetwork;
|
|
73
|
+
/** The calls. */
|
|
74
|
+
calls: Calls<EvmCall[]>;
|
|
75
|
+
/** The paymaster URL. */
|
|
76
|
+
paymasterUrl?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A call to be executed in a user operation.
|
|
81
|
+
*/
|
|
82
|
+
export interface EvmCall {
|
|
83
|
+
/**
|
|
84
|
+
* The address the call is directed to.
|
|
85
|
+
*/
|
|
86
|
+
to: Address;
|
|
87
|
+
/** The amount of ETH to send with the call, in wei. */
|
|
88
|
+
value: bigint;
|
|
89
|
+
/**
|
|
90
|
+
* The call data to send. This is the hex-encoded data of the function call consisting of the method selector and the function arguments.
|
|
91
|
+
*/
|
|
92
|
+
data: Hex;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A user operation.
|
|
97
|
+
*/
|
|
98
|
+
export interface UserOperation {
|
|
99
|
+
/** The network the user operation is for. */
|
|
100
|
+
network: EvmUserOperationNetwork;
|
|
101
|
+
/**
|
|
102
|
+
* The hash of the user operation. This is not the transaction hash, as a transaction consists of multiple user operations. The user operation hash is the hash of this particular user operation which gets signed by the owner of the Smart Account.
|
|
103
|
+
*/
|
|
104
|
+
userOpHash: Hex;
|
|
105
|
+
/** The list of calls in the user operation. */
|
|
106
|
+
calls: Calls<EvmCall[]>;
|
|
107
|
+
/** The status of the user operation. */
|
|
108
|
+
status: EvmUserOperationStatus;
|
|
109
|
+
/**
|
|
110
|
+
* The hash of the transaction that included this particular user operation. This gets set after the user operation is broadcasted and the transaction is included in a block.
|
|
111
|
+
*/
|
|
112
|
+
transactionHash?: Hex;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Options for creating an EVM server account.
|
|
117
|
+
*/
|
|
118
|
+
export interface CreateServerAccountOptions {
|
|
119
|
+
/** The name of the account. */
|
|
120
|
+
name?: string;
|
|
121
|
+
/** The idempotency key. */
|
|
122
|
+
idempotencyKey?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Options for getting an EVM account.
|
|
127
|
+
*/
|
|
128
|
+
export interface GetServerAccountOptions {
|
|
129
|
+
/** The address of the account. */
|
|
130
|
+
address?: Address;
|
|
131
|
+
/** The name of the account. */
|
|
132
|
+
name?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Options for getting an EVM smart account.
|
|
137
|
+
*/
|
|
138
|
+
export interface GetSmartAccountOptions {
|
|
139
|
+
/** The address of the account. */
|
|
140
|
+
address: Address;
|
|
141
|
+
/** The owner of the account. */
|
|
142
|
+
owner: Account;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Options for listing EVM accounts.
|
|
147
|
+
*/
|
|
148
|
+
export interface ListServerAccountsOptions {
|
|
149
|
+
/** The page size to paginate through the accounts. */
|
|
150
|
+
pageSize?: number;
|
|
151
|
+
/** The page token to paginate through the accounts. */
|
|
152
|
+
pageToken?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A smart account that only contains the owner address.
|
|
157
|
+
*/
|
|
158
|
+
export interface ReadonlySmartAccount extends Omit<SmartAccount, "owners"> {
|
|
159
|
+
/** The owners of the smart account. */
|
|
160
|
+
owners: Address[];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The result of listing EVM smart accounts.
|
|
165
|
+
*/
|
|
166
|
+
export interface ListSmartAccountResult {
|
|
167
|
+
/** The accounts. */
|
|
168
|
+
accounts: ReadonlySmartAccount[];
|
|
169
|
+
/**
|
|
170
|
+
* The next page token to paginate through the accounts.
|
|
171
|
+
* If undefined, there are no more accounts to paginate through.
|
|
172
|
+
*/
|
|
173
|
+
nextPageToken?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The result of listing EVM server accounts.
|
|
178
|
+
*/
|
|
179
|
+
export interface ListServerAccountResult {
|
|
180
|
+
/** The accounts. */
|
|
181
|
+
accounts: ServerAccount[];
|
|
182
|
+
/**
|
|
183
|
+
* The next page token to paginate through the accounts.
|
|
184
|
+
* If undefined, there are no more accounts to paginate through.
|
|
185
|
+
*/
|
|
186
|
+
nextPageToken?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Options for listing EVM smart accounts.
|
|
191
|
+
*/
|
|
192
|
+
export interface ListSmartAccountsOptions {
|
|
193
|
+
/** The name of the account. */
|
|
194
|
+
name?: string;
|
|
195
|
+
/** The page size to paginate through the accounts. */
|
|
196
|
+
pageSize?: number;
|
|
197
|
+
/** The page token to paginate through the accounts. */
|
|
198
|
+
pageToken?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Options for creating an EVM smart account.
|
|
203
|
+
*/
|
|
204
|
+
export interface CreateSmartAccountOptions {
|
|
205
|
+
/** The owner of the account. */
|
|
206
|
+
owner: Account;
|
|
207
|
+
/** The idempotency key. */
|
|
208
|
+
idempotencyKey?: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Options for requesting funds from an EVM faucet.
|
|
213
|
+
*/
|
|
214
|
+
export interface RequestFaucetOptions {
|
|
215
|
+
/** The address of the account. */
|
|
216
|
+
address: string;
|
|
217
|
+
/** The network to request funds from. */
|
|
218
|
+
network: "base-sepolia" | "ethereum-sepolia";
|
|
219
|
+
/** The token to request funds for. */
|
|
220
|
+
token: "eth" | "usdc" | "eurc" | "cbbtc";
|
|
221
|
+
/** The idempotency key. */
|
|
222
|
+
idempotencyKey?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The result of requesting funds from an EVM faucet.
|
|
227
|
+
*/
|
|
228
|
+
export interface RequestFaucetResult {
|
|
229
|
+
/** The transaction hash. */
|
|
230
|
+
transactionHash: Hex;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Options for sending a user operation.
|
|
235
|
+
*/
|
|
236
|
+
export interface SendUserOperationOptions {
|
|
237
|
+
/** The smart account. */
|
|
238
|
+
smartAccount: SmartAccount;
|
|
239
|
+
/** The network. */
|
|
240
|
+
network: EvmUserOperationNetwork;
|
|
241
|
+
/** The calls. */
|
|
242
|
+
calls: Call[];
|
|
243
|
+
/** The paymaster URL. */
|
|
244
|
+
paymasterUrl?: string;
|
|
245
|
+
/** The idempotency key. */
|
|
246
|
+
idempotencyKey?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Options for signing an EVM hash.
|
|
251
|
+
*/
|
|
252
|
+
export interface SignHashOptions {
|
|
253
|
+
/** The address of the account. */
|
|
254
|
+
address: Address;
|
|
255
|
+
/** The hash to sign. */
|
|
256
|
+
hash: Hex;
|
|
257
|
+
/** The idempotency key. */
|
|
258
|
+
idempotencyKey?: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Options for signing an EVM message.
|
|
263
|
+
*/
|
|
264
|
+
export interface SignMessageOptions {
|
|
265
|
+
/** The address of the account. */
|
|
266
|
+
address: Address;
|
|
267
|
+
/** The message to sign. */
|
|
268
|
+
message: string;
|
|
269
|
+
/** The idempotency key. */
|
|
270
|
+
idempotencyKey?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Options for signing an EVM transaction.
|
|
275
|
+
*/
|
|
276
|
+
export interface SignTransactionOptions {
|
|
277
|
+
/** The address of the account. */
|
|
278
|
+
address: Address;
|
|
279
|
+
/** The RLP-encoded transaction to sign, as a 0x-prefixed hex string. */
|
|
280
|
+
transaction: Hex;
|
|
281
|
+
/** The idempotency key. */
|
|
282
|
+
idempotencyKey?: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A signature result.
|
|
287
|
+
*/
|
|
288
|
+
export interface SignatureResult {
|
|
289
|
+
/** The signature. */
|
|
290
|
+
signature: Hex;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Options for waiting for a user operation.
|
|
295
|
+
*/
|
|
296
|
+
export interface WaitForUserOperationOptions {
|
|
297
|
+
/** The smart account address. */
|
|
298
|
+
smartAccountAddress: Address;
|
|
299
|
+
/** The user operation hash. */
|
|
300
|
+
userOpHash: Hex;
|
|
301
|
+
/** The wait options. */
|
|
302
|
+
waitOptions?: WaitOptions;
|
|
303
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SolanaClient } from "./solana.js";
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SolanaClientInterface,
|
|
3
|
+
Account,
|
|
4
|
+
CreateAccountOptions,
|
|
5
|
+
GetAccountOptions,
|
|
6
|
+
ListAccountsOptions,
|
|
7
|
+
RequestFaucetOptions,
|
|
8
|
+
ListAccountsResult,
|
|
9
|
+
SignatureResult,
|
|
10
|
+
SignMessageOptions,
|
|
11
|
+
SignTransactionOptions,
|
|
12
|
+
} from "./solana.types.js";
|
|
13
|
+
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The namespace containing all Solana methods.
|
|
17
|
+
*/
|
|
18
|
+
export class SolanaClient implements SolanaClientInterface {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new Solana account.
|
|
21
|
+
*
|
|
22
|
+
* @param {CreateAccountOptions} options - Parameters for creating the Solana account.
|
|
23
|
+
* @param {string} [options.name] - The name of the account.
|
|
24
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves to the newly created account.
|
|
27
|
+
*
|
|
28
|
+
* @example **Without arguments**
|
|
29
|
+
* ```ts
|
|
30
|
+
* const account = await cdp.solana.createAccount();
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example **With a name**
|
|
34
|
+
* ```ts
|
|
35
|
+
* const account = await cdp.solana.createAccount({ name: "MyAccount" });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example **With an idempotency key**
|
|
39
|
+
* ```ts
|
|
40
|
+
* const idempotencyKey = uuidv4();
|
|
41
|
+
*
|
|
42
|
+
* // First call
|
|
43
|
+
* await cdp.solana.createAccount({ idempotencyKey });
|
|
44
|
+
*
|
|
45
|
+
* // Second call with the same idempotency key will return the same account
|
|
46
|
+
* await cdp.solana.createAccount({ idempotencyKey });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async createAccount(options: CreateAccountOptions = {}): Promise<Account> {
|
|
50
|
+
return CdpOpenApiClient.createSolanaAccount(options, options.idempotencyKey);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets a Solana account by its address.
|
|
55
|
+
*
|
|
56
|
+
* @param {GetAccountOptions} options - Parameters for getting the Solana account.
|
|
57
|
+
* Either `address` or `name` must be provided.
|
|
58
|
+
* If both are provided, lookup will be done by `address` and `name` will be ignored.
|
|
59
|
+
* @param {string} [options.address] - The address of the account.
|
|
60
|
+
* @param {string} [options.name] - The name of the account.
|
|
61
|
+
*
|
|
62
|
+
* @returns A promise that resolves to the account.
|
|
63
|
+
*
|
|
64
|
+
* @example **Get an account by address**
|
|
65
|
+
* ```ts
|
|
66
|
+
* const account = await cdp.solana.getAccount({
|
|
67
|
+
* address: "1234567890123456789012345678901234567890",
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example **Get an account by name**
|
|
72
|
+
* ```ts
|
|
73
|
+
* const account = await cdp.solana.getAccount({
|
|
74
|
+
* name: "MyAccount",
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
async getAccount(options: GetAccountOptions): Promise<Account> {
|
|
79
|
+
if (options.address) {
|
|
80
|
+
return CdpOpenApiClient.getSolanaAccount(options.address);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (options.name) {
|
|
84
|
+
return CdpOpenApiClient.getSolanaAccountByName(options.name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
throw new Error("Either address or name must be provided");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Lists all Solana accounts.
|
|
92
|
+
*
|
|
93
|
+
* @param {ListAccountsOptions} options - Parameters for listing the Solana accounts.
|
|
94
|
+
* @param {number} [options.pageSize] - The number of accounts to return.
|
|
95
|
+
* @param {string} [options.pageToken] - The page token to begin listing from.
|
|
96
|
+
* This is obtained by previous calls to this method.
|
|
97
|
+
*
|
|
98
|
+
* @returns A promise that resolves to an array of Solana account instances.
|
|
99
|
+
*
|
|
100
|
+
* @example **Without arguments**
|
|
101
|
+
* ```ts
|
|
102
|
+
* const accounts = await cdp.solana.listAccounts();
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example **With pagination**
|
|
106
|
+
* ```ts
|
|
107
|
+
* let page = await cdp.solana.listAccounts();
|
|
108
|
+
*
|
|
109
|
+
* while (page.nextPageToken) {
|
|
110
|
+
* page = await cdp.solana.listAccounts({ pageToken: page.nextPageToken });
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* page.accounts.forEach(account => console.log(account));
|
|
114
|
+
* ```
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
async listAccounts(options: ListAccountsOptions = {}): Promise<ListAccountsResult> {
|
|
119
|
+
const solAccounts = await CdpOpenApiClient.listSolanaAccounts({
|
|
120
|
+
pageSize: options.pageSize,
|
|
121
|
+
pageToken: options.pageToken,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
accounts: solAccounts.accounts,
|
|
126
|
+
nextPageToken: solAccounts.nextPageToken,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Requests funds from a Solana faucet.
|
|
132
|
+
*
|
|
133
|
+
* @param {RequestFaucetOptions} options - Parameters for requesting funds from the Solana faucet.
|
|
134
|
+
* @param {string} options.address - The address to request funds for.
|
|
135
|
+
* @param {string} options.token - The token to request funds for.
|
|
136
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
137
|
+
*
|
|
138
|
+
* @returns A promise that resolves to the transaction signature.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const signature = await cdp.solana.requestFaucet({
|
|
143
|
+
* address: "1234567890123456789012345678901234567890",
|
|
144
|
+
* token: "sol",
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
async requestFaucet(options: RequestFaucetOptions): Promise<SignatureResult> {
|
|
149
|
+
const signature = await CdpOpenApiClient.requestSolanaFaucet(
|
|
150
|
+
{ address: options.address, token: options.token },
|
|
151
|
+
options.idempotencyKey,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
signature: signature.transactionSignature,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Signs a message.
|
|
161
|
+
*
|
|
162
|
+
* @param {SignMessageOptions} options - Parameters for signing the message.
|
|
163
|
+
* @param {string} options.address - The address to sign the message for.
|
|
164
|
+
* @param {string} options.message - The message to sign.
|
|
165
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
166
|
+
*
|
|
167
|
+
* @returns A promise that resolves to the signature.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* // Create a Solana account
|
|
172
|
+
* const account = await cdp.solana.createAccount();
|
|
173
|
+
*
|
|
174
|
+
* // When you want to sign a message, you can do so by address
|
|
175
|
+
* const signature = await cdp.solana.signMessage({
|
|
176
|
+
* address: account.address,
|
|
177
|
+
* message: "Hello, world!",
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
async signMessage(options: SignMessageOptions): Promise<SignatureResult> {
|
|
182
|
+
return CdpOpenApiClient.signSolanaMessage(
|
|
183
|
+
options.address,
|
|
184
|
+
{
|
|
185
|
+
message: options.message,
|
|
186
|
+
},
|
|
187
|
+
options.idempotencyKey,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Signs a transaction.
|
|
193
|
+
*
|
|
194
|
+
* @param {SignTransactionOptions} options - Parameters for signing the transaction.
|
|
195
|
+
* @param {string} options.address - The address to sign the transaction for.
|
|
196
|
+
* @param {string} options.transaction - The transaction to sign.
|
|
197
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
198
|
+
*
|
|
199
|
+
* @returns A promise that resolves to the signature.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* // Create a Solana account
|
|
204
|
+
* const account = await cdp.solana.createAccount();
|
|
205
|
+
*
|
|
206
|
+
* // Add your transaction instructions here
|
|
207
|
+
* const transaction = new Transaction()
|
|
208
|
+
*
|
|
209
|
+
* // Make sure to set requireAllSignatures to false, since signing will be done through the API
|
|
210
|
+
* const serializedTransaction = transaction.serialize({
|
|
211
|
+
* requireAllSignatures: false,
|
|
212
|
+
* });
|
|
213
|
+
*
|
|
214
|
+
* // Base64 encode the serialized transaction
|
|
215
|
+
* const transaction = Buffer.from(serializedTransaction).toString("base64");
|
|
216
|
+
*
|
|
217
|
+
* // When you want to sign a transaction, you can do so by address and base64 encoded transaction
|
|
218
|
+
* const signature = await cdp.solana.signTransaction({
|
|
219
|
+
* address: account.address,
|
|
220
|
+
* transaction,
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
async signTransaction(options: SignTransactionOptions): Promise<SignatureResult> {
|
|
225
|
+
const signature = await CdpOpenApiClient.signSolanaTransaction(
|
|
226
|
+
options.address,
|
|
227
|
+
{
|
|
228
|
+
transaction: options.transaction,
|
|
229
|
+
},
|
|
230
|
+
options.idempotencyKey,
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
signature: signature.signedTransaction,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenApiSolanaMethods,
|
|
3
|
+
SolanaAccount as OpenAPISolanaAccount,
|
|
4
|
+
} from "../../openapi-client/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
|
|
7
|
+
*/
|
|
8
|
+
export type SolanaClientInterface = Omit<
|
|
9
|
+
typeof OpenApiSolanaMethods,
|
|
10
|
+
| "createSolanaAccount" // mapped to createAccount
|
|
11
|
+
| "getSolanaAccount" // mapped to getAccount
|
|
12
|
+
| "getSolanaAccountByName" // mapped to getAccount
|
|
13
|
+
| "listSolanaAccounts" // mapped to listAccounts
|
|
14
|
+
| "requestSolanaFaucet" // mapped to requestFaucet
|
|
15
|
+
| "signSolanaMessage" // mapped to signMessage
|
|
16
|
+
| "signSolanaTransaction" // mapped to signTransaction
|
|
17
|
+
> & {
|
|
18
|
+
createAccount: (options: CreateAccountOptions) => Promise<Account>;
|
|
19
|
+
getAccount: (options: GetAccountOptions) => Promise<Account>;
|
|
20
|
+
listAccounts: (options: ListAccountsOptions) => Promise<ListAccountsResult>;
|
|
21
|
+
requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
|
|
22
|
+
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
23
|
+
signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A Solana account.
|
|
27
|
+
*/
|
|
28
|
+
export type Account = OpenAPISolanaAccount;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Options for creating a Solana account.
|
|
32
|
+
*/
|
|
33
|
+
export interface CreateAccountOptions {
|
|
34
|
+
/** The name of the account. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** The idempotency key. */
|
|
37
|
+
idempotencyKey?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for getting a Solana account.
|
|
42
|
+
*/
|
|
43
|
+
export interface GetAccountOptions {
|
|
44
|
+
/** The address of the account. */
|
|
45
|
+
address?: string;
|
|
46
|
+
/** The name of the account. */
|
|
47
|
+
name?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Options for listing Solana accounts.
|
|
52
|
+
*/
|
|
53
|
+
export interface ListAccountsOptions {
|
|
54
|
+
/** The page size. */
|
|
55
|
+
pageSize?: number;
|
|
56
|
+
/** The page token. */
|
|
57
|
+
pageToken?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The result of listing Solana accounts.
|
|
62
|
+
*/
|
|
63
|
+
export interface ListAccountsResult {
|
|
64
|
+
/** The accounts. */
|
|
65
|
+
accounts: Account[];
|
|
66
|
+
/**
|
|
67
|
+
* The token for the next page of accounts, if any.
|
|
68
|
+
*/
|
|
69
|
+
nextPageToken?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Options for requesting funds from a Solana faucet.
|
|
74
|
+
*/
|
|
75
|
+
export interface RequestFaucetOptions {
|
|
76
|
+
/** The address of the account. */
|
|
77
|
+
address: string;
|
|
78
|
+
/** The token to request funds for. */
|
|
79
|
+
token: "sol" | "usdc";
|
|
80
|
+
/** The idempotency key. */
|
|
81
|
+
idempotencyKey?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Options for signing a Solana message.
|
|
86
|
+
*/
|
|
87
|
+
export interface SignMessageOptions {
|
|
88
|
+
/** The address of the account. */
|
|
89
|
+
address: string;
|
|
90
|
+
/** The message to sign. */
|
|
91
|
+
message: string;
|
|
92
|
+
/** The idempotency key. */
|
|
93
|
+
idempotencyKey?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Options for signing a Solana transaction.
|
|
98
|
+
*/
|
|
99
|
+
export interface SignTransactionOptions {
|
|
100
|
+
/** The address of the account. */
|
|
101
|
+
address: string;
|
|
102
|
+
/** The base64 encoded transaction to sign. */
|
|
103
|
+
transaction: string;
|
|
104
|
+
/** The idempotency key. */
|
|
105
|
+
idempotencyKey?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A Solana signature result.
|
|
110
|
+
*/
|
|
111
|
+
export interface SignatureResult {
|
|
112
|
+
/** The signature. */
|
|
113
|
+
signature: string;
|
|
114
|
+
}
|
package/constants.ts
ADDED
package/errors.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TimeoutError is thrown when an operation times out.
|
|
3
|
+
*/
|
|
4
|
+
export class TimeoutError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Initializes a new TimeoutError instance.
|
|
7
|
+
*
|
|
8
|
+
* @param message - The error message.
|
|
9
|
+
*/
|
|
10
|
+
constructor(message: string = "Timeout Error") {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "TimeoutError";
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, TimeoutError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
package/index.ts
ADDED