@coinbase/cdp-sdk 1.7.0 → 1.9.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 +20 -0
- package/README.md +326 -28
- package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +8 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +2 -39
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/evm/transfer/utils.js +0 -12
- package/_cjs/actions/evm/transfer/utils.js.map +1 -1
- package/_cjs/actions/solana/constants.js +9 -0
- package/_cjs/actions/solana/constants.js.map +1 -0
- package/_cjs/actions/solana/transfer.js +117 -0
- package/_cjs/actions/solana/transfer.js.map +1 -0
- package/_cjs/actions/solana/utils.js +66 -0
- package/_cjs/actions/solana/utils.js.map +1 -0
- package/_cjs/analytics.js +70 -8
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/cdp.js +9 -3
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/evm/evm.js +133 -15
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/index.js +6 -0
- package/_cjs/client/policies/index.js.map +1 -0
- package/_cjs/client/policies/policies.js +232 -0
- package/_cjs/client/policies/policies.js.map +1 -0
- package/_cjs/client/policies/policies.types.js +3 -0
- package/_cjs/client/policies/policies.types.js.map +1 -0
- package/_cjs/client/solana/solana.js +76 -19
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +4 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +2 -2
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +6 -1
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/schema.js +245 -0
- package/_cjs/policies/schema.js.map +1 -0
- package/_cjs/policies/types.js +3 -0
- package/_cjs/policies/types.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +8 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +2 -39
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/evm/transfer/utils.js +0 -11
- package/_esm/actions/evm/transfer/utils.js.map +1 -1
- package/_esm/actions/solana/constants.js +6 -0
- package/_esm/actions/solana/constants.js.map +1 -0
- package/_esm/actions/solana/transfer.js +114 -0
- package/_esm/actions/solana/transfer.js.map +1 -0
- package/_esm/actions/solana/utils.js +61 -0
- package/_esm/actions/solana/utils.js.map +1 -0
- package/_esm/analytics.js +70 -7
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/cdp.js +10 -4
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/evm/evm.js +133 -15
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/index.js +2 -0
- package/_esm/client/policies/index.js.map +1 -0
- package/_esm/client/policies/policies.js +228 -0
- package/_esm/client/policies/policies.js.map +1 -0
- package/_esm/client/policies/policies.types.js +2 -0
- package/_esm/client/policies/policies.types.js.map +1 -0
- package/_esm/client/solana/solana.js +76 -19
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +2 -2
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +5 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/schema.js +242 -0
- package/_esm/policies/schema.js.map +1 -0
- package/_esm/policies/types.js +2 -0
- package/_esm/policies/types.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +6 -3
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +6 -4
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +8 -54
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/transfer/utils.d.ts +0 -619
- package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +140 -68
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/constants.d.ts +6 -0
- package/_types/actions/solana/constants.d.ts.map +1 -0
- package/_types/actions/solana/transfer.d.ts +36 -0
- package/_types/actions/solana/transfer.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +27 -0
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +34 -0
- package/_types/actions/solana/utils.d.ts.map +1 -0
- package/_types/analytics.d.ts +14 -5
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +3 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +89 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +33 -3
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/index.d.ts +2 -0
- package/_types/client/policies/index.d.ts.map +1 -0
- package/_types/client/policies/policies.d.ts +216 -0
- package/_types/client/policies/policies.d.ts.map +1 -0
- package/_types/client/policies/policies.types.d.ts +96 -0
- package/_types/client/policies/policies.types.d.ts.map +1 -0
- package/_types/client/solana/solana.d.ts +43 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +14 -2
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +176 -17
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +2 -2
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +18 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +1552 -0
- package/_types/policies/schema.d.ts.map +1 -0
- package/_types/policies/types.d.ts +19 -0
- package/_types/policies/types.d.ts.map +1 -0
- package/_types/types/misc.d.ts +39 -0
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +11 -7
- package/accounts/evm/toEvmSmartAccount.ts +1 -2
- package/accounts/evm/types.ts +6 -8
- package/accounts/solana/toSolanaAccount.ts +8 -0
- package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
- package/actions/evm/transfer/transfer.ts +10 -51
- package/actions/evm/transfer/types.ts +9 -67
- package/actions/evm/transfer/utils.ts +0 -13
- package/actions/evm/types.ts +143 -78
- package/actions/solana/constants.ts +6 -0
- package/actions/solana/transfer.ts +219 -0
- package/actions/solana/types.ts +28 -0
- package/actions/solana/utils.ts +79 -0
- package/analytics.ts +86 -11
- package/client/cdp.ts +11 -4
- package/client/evm/evm.ts +159 -17
- package/client/evm/evm.types.ts +38 -1
- package/client/policies/index.ts +1 -0
- package/client/policies/policies.ts +246 -0
- package/client/policies/policies.types.ts +109 -0
- package/client/solana/solana.ts +94 -20
- package/client/solana/solana.types.ts +16 -1
- package/index.ts +7 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +220 -18
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
- package/openapi-client/generated/index.msw.ts +2 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
- package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
- package/openapi-client/index.ts +6 -0
- package/package.json +4 -2
- package/policies/schema.ts +349 -0
- package/policies/types.ts +19 -0
- package/types/misc.ts +41 -0
- package/version.ts +1 -1
|
@@ -1,54 +1,80 @@
|
|
|
1
1
|
import { SendUserOperationOptions, SendUserOperationReturnType } from "./sendUserOperation.js";
|
|
2
2
|
import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Hex } from "../../types/misc.js";
|
|
4
4
|
import type { ListTokenBalancesOptions, ListTokenBalancesResult } from "./listTokenBalances.js";
|
|
5
5
|
import type { RequestFaucetOptions, RequestFaucetResult } from "./requestFaucet.js";
|
|
6
6
|
import type { SendTransactionOptions, TransactionResult } from "./sendTransaction.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { TransferOptions } from "./transfer/types.js";
|
|
8
8
|
import type { WaitForUserOperationOptions, WaitForUserOperationReturnType } from "./waitForUserOperation.js";
|
|
9
|
-
type Actions
|
|
9
|
+
type Actions = {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* List the token balances of an account.
|
|
12
12
|
*
|
|
13
|
-
* @param options - The options for the
|
|
14
|
-
* @param options.
|
|
15
|
-
* @param options.amount - The amount of the token to transfer.
|
|
16
|
-
* @param options.token - The token to transfer.
|
|
17
|
-
* @param options.network - The network to transfer the token on.
|
|
13
|
+
* @param options - The options for the list token balances.
|
|
14
|
+
* @param options.network - The network to list the token balances on.
|
|
18
15
|
*
|
|
19
|
-
* @returns The result of the
|
|
16
|
+
* @returns The result of the list token balances.
|
|
20
17
|
*
|
|
21
18
|
* @example
|
|
22
19
|
* ```typescript
|
|
23
|
-
* const
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* const balances = await account.listTokenBalances({
|
|
21
|
+
* network: "base-sepolia",
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
listTokenBalances: (options: Omit<ListTokenBalancesOptions, "address">) => Promise<ListTokenBalancesResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Requests funds from an EVM faucet.
|
|
28
|
+
*
|
|
29
|
+
* @param {RequestFaucetOptions} options - Parameters for requesting funds from the EVM faucet.
|
|
30
|
+
* @param {string} options.network - The network to request funds from.
|
|
31
|
+
* @param {string} options.token - The token to request funds for.
|
|
32
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves to the transaction hash.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const result = await account.requestFaucet({
|
|
27
39
|
* network: "base-sepolia",
|
|
40
|
+
* token: "eth",
|
|
28
41
|
* });
|
|
29
42
|
* ```
|
|
43
|
+
*/
|
|
44
|
+
requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<RequestFaucetResult>;
|
|
45
|
+
};
|
|
46
|
+
export type AccountActions = Actions & {
|
|
47
|
+
/**
|
|
48
|
+
* Transfer an amount of a token from an account to another account.
|
|
49
|
+
*
|
|
50
|
+
* @param options - The options for the transfer.
|
|
51
|
+
* @param options.to - The account or 0x-prefixed address to transfer the token to.
|
|
52
|
+
* @param options.amount - The amount of the token to transfer represented as an atomic unit.
|
|
53
|
+
* It's common to use `parseEther` or `parseUnits` utils from viem to convert to atomic units.
|
|
54
|
+
* Otherwise, you can pass atomic units directly. See examples below.
|
|
55
|
+
* @param options.token - The token to transfer. This can be 'eth', 'usdc', or a contract address.
|
|
56
|
+
* @param options.network - The network to transfer the token on.
|
|
57
|
+
*
|
|
58
|
+
* @returns An object containing the transaction hash.
|
|
30
59
|
*
|
|
31
60
|
* @example
|
|
32
|
-
* **Pass a bigint value**
|
|
33
61
|
* ```typescript
|
|
34
|
-
* const {
|
|
62
|
+
* const { transactionHash } = await sender.transfer({
|
|
35
63
|
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
36
|
-
* amount: 10000n, // equivalent to 0.01
|
|
64
|
+
* amount: 10000n, // equivalent to 0.01 USDC
|
|
37
65
|
* token: "usdc",
|
|
38
66
|
* network: "base-sepolia",
|
|
39
67
|
* });
|
|
40
68
|
* ```
|
|
41
69
|
*
|
|
42
70
|
* @example
|
|
43
|
-
* **
|
|
71
|
+
* **Using parseUnits to specify USDC amount**
|
|
44
72
|
* ```typescript
|
|
45
|
-
*
|
|
46
|
-
* owner: await cdp.evm.createAccount({ name: "Owner" }),
|
|
47
|
-
* });
|
|
73
|
+
* import { parseUnits } from "viem";
|
|
48
74
|
*
|
|
49
|
-
* const {
|
|
75
|
+
* const { transactionHash } = await sender.transfer({
|
|
50
76
|
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
51
|
-
* amount: "0.01",
|
|
77
|
+
* amount: parseUnits("0.01", 6), // USDC uses 6 decimal places
|
|
52
78
|
* token: "usdc",
|
|
53
79
|
* network: "base-sepolia",
|
|
54
80
|
* });
|
|
@@ -57,9 +83,11 @@ type Actions<T extends EvmAccount | EvmSmartAccount> = {
|
|
|
57
83
|
* @example
|
|
58
84
|
* **Transfer ETH**
|
|
59
85
|
* ```typescript
|
|
60
|
-
*
|
|
86
|
+
* import { parseEther } from "viem";
|
|
87
|
+
*
|
|
88
|
+
* const { transactionHash } = await sender.transfer({
|
|
61
89
|
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
62
|
-
* amount: "0.000001",
|
|
90
|
+
* amount: parseEther("0.000001"),
|
|
63
91
|
* token: "eth",
|
|
64
92
|
* network: "base-sepolia",
|
|
65
93
|
* });
|
|
@@ -68,9 +96,11 @@ type Actions<T extends EvmAccount | EvmSmartAccount> = {
|
|
|
68
96
|
* @example
|
|
69
97
|
* **Using a contract address**
|
|
70
98
|
* ```typescript
|
|
71
|
-
*
|
|
99
|
+
* import { parseEther } from "viem";
|
|
100
|
+
*
|
|
101
|
+
* const { transactionHash } = await sender.transfer({
|
|
72
102
|
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
73
|
-
* amount: "0.000001",
|
|
103
|
+
* amount: parseEther("0.000001"),
|
|
74
104
|
* token: "0x4200000000000000000000000000000000000006", // WETH on Base Sepolia
|
|
75
105
|
* network: "base-sepolia",
|
|
76
106
|
* });
|
|
@@ -82,52 +112,17 @@ type Actions<T extends EvmAccount | EvmSmartAccount> = {
|
|
|
82
112
|
* const sender = await cdp.evm.createAccount({ name: "Sender" });
|
|
83
113
|
* const receiver = await cdp.evm.createAccount({ name: "Receiver" });
|
|
84
114
|
*
|
|
85
|
-
* const {
|
|
115
|
+
* const { transactionHash } = await sender.transfer({
|
|
86
116
|
* to: receiver,
|
|
87
|
-
* amount:
|
|
117
|
+
* amount: 10000n, // equivalent to 0.01 USDC
|
|
88
118
|
* token: "usdc",
|
|
89
119
|
* network: "base-sepolia",
|
|
90
120
|
* });
|
|
91
121
|
* ```
|
|
92
122
|
*/
|
|
93
|
-
transfer: (options:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
* @param options - The options for the list token balances.
|
|
98
|
-
* @param options.network - The network to list the token balances on.
|
|
99
|
-
*
|
|
100
|
-
* @returns The result of the list token balances.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const balances = await account.listTokenBalances({
|
|
105
|
-
* network: "base-sepolia",
|
|
106
|
-
* });
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
listTokenBalances: (options: Omit<ListTokenBalancesOptions, "address">) => Promise<ListTokenBalancesResult>;
|
|
110
|
-
/**
|
|
111
|
-
* Requests funds from an EVM faucet.
|
|
112
|
-
*
|
|
113
|
-
* @param {RequestFaucetOptions} options - Parameters for requesting funds from the EVM faucet.
|
|
114
|
-
* @param {string} options.network - The network to request funds from.
|
|
115
|
-
* @param {string} options.token - The token to request funds for.
|
|
116
|
-
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
117
|
-
*
|
|
118
|
-
* @returns A promise that resolves to the transaction hash.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* const result = await account.requestFaucet({
|
|
123
|
-
* network: "base-sepolia",
|
|
124
|
-
* token: "eth",
|
|
125
|
-
* });
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<RequestFaucetResult>;
|
|
129
|
-
};
|
|
130
|
-
export type AccountActions = Actions<EvmAccount> & {
|
|
123
|
+
transfer: (options: TransferOptions) => Promise<{
|
|
124
|
+
transactionHash: Hex;
|
|
125
|
+
}>;
|
|
131
126
|
/**
|
|
132
127
|
* Signs an EVM transaction and sends it to the specified network using the Coinbase API.
|
|
133
128
|
* This method handles nonce management and gas estimation automatically.
|
|
@@ -174,7 +169,84 @@ export type AccountActions = Actions<EvmAccount> & {
|
|
|
174
169
|
*/
|
|
175
170
|
sendTransaction: (options: Omit<SendTransactionOptions, "address">) => Promise<TransactionResult>;
|
|
176
171
|
};
|
|
177
|
-
export type SmartAccountActions = Actions
|
|
172
|
+
export type SmartAccountActions = Actions & {
|
|
173
|
+
/**
|
|
174
|
+
* Transfer an amount of a token from an account to another account.
|
|
175
|
+
*
|
|
176
|
+
* @param options - The options for the transfer.
|
|
177
|
+
* @param options.to - The account or 0x-prefixed address to transfer the token to.
|
|
178
|
+
* @param options.amount - The amount of the token to transfer represented as an atomic unit.
|
|
179
|
+
* It's common to use `parseEther` or `parseUnits` utils from viem to convert to atomic units.
|
|
180
|
+
* Otherwise, you can pass atomic units directly. See examples below.
|
|
181
|
+
* @param options.token - The token to transfer. This can be 'eth', 'usdc', or a contract address.
|
|
182
|
+
* @param options.network - The network to transfer the token on.
|
|
183
|
+
*
|
|
184
|
+
* @returns The user operation result.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const { userOpHash } = await sender.transfer({
|
|
189
|
+
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
190
|
+
* amount: 10000n, // equivalent to 0.01 USDC
|
|
191
|
+
* token: "usdc",
|
|
192
|
+
* network: "base-sepolia",
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* **Using parseUnits to specify USDC amount**
|
|
198
|
+
* ```typescript
|
|
199
|
+
* import { parseUnits } from "viem";
|
|
200
|
+
*
|
|
201
|
+
* const { userOpHash } = await sender.transfer({
|
|
202
|
+
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
203
|
+
* amount: parseUnits("0.01", 6), // USDC uses 6 decimal places
|
|
204
|
+
* token: "usdc",
|
|
205
|
+
* network: "base-sepolia",
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* **Transfer ETH**
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { parseEther } from "viem";
|
|
213
|
+
*
|
|
214
|
+
* const { userOpHash } = await sender.transfer({
|
|
215
|
+
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
216
|
+
* amount: parseEther("0.000001"),
|
|
217
|
+
* token: "eth",
|
|
218
|
+
* network: "base-sepolia",
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* **Using a contract address**
|
|
224
|
+
* ```typescript
|
|
225
|
+
* import { parseEther } from "viem";
|
|
226
|
+
*
|
|
227
|
+
* const { userOpHash } = await sender.transfer({
|
|
228
|
+
* to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
229
|
+
* amount: parseEther("0.000001"),
|
|
230
|
+
* token: "0x4200000000000000000000000000000000000006", // WETH on Base Sepolia
|
|
231
|
+
* network: "base-sepolia",
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* **Transfer to another account**
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const sender = await cdp.evm.createAccount({ name: "Sender" });
|
|
239
|
+
* const receiver = await cdp.evm.createAccount({ name: "Receiver" });
|
|
240
|
+
*
|
|
241
|
+
* const { userOpHash } = await sender.transfer({
|
|
242
|
+
* to: receiver,
|
|
243
|
+
* amount: 10000n, // equivalent to 0.01 USDC
|
|
244
|
+
* token: "usdc",
|
|
245
|
+
* network: "base-sepolia",
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
transfer: (options: TransferOptions) => Promise<SendUserOperationReturnType>;
|
|
178
250
|
/**
|
|
179
251
|
* Sends a user operation.
|
|
180
252
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,uBAAuB,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mB,GAAG,OAAO,GAAG;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2EG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE7E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC,EAAE,cAAc,CAAC,KAC/D,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,oBAAoB,EAAE,CACpB,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,qBAAqB,CAAC,KAC9D,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,EAAE,CAChB,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,KACnD,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const GENESIS_HASH_MAINNET = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
2
|
+
export declare const GENESIS_HASH_DEVNET = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
3
|
+
export declare const GENESIS_HASH_TESTNET = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY";
|
|
4
|
+
export declare const USDC_MAINNET_MINT_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
5
|
+
export declare const USDC_DEVNET_MINT_ADDRESS = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../actions/solana/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,iDAAiD,CAAC;AACnF,eAAO,MAAM,mBAAmB,iDAAiD,CAAC;AAClF,eAAO,MAAM,oBAAoB,iDAAiD,CAAC;AAEnF,eAAO,MAAM,yBAAyB,iDAAiD,CAAC;AACxF,eAAO,MAAM,wBAAwB,iDAAiD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
import { type Network } from "./utils.js";
|
|
3
|
+
import type { SignatureResult } from "../../client/solana/solana.types.js";
|
|
4
|
+
import type { CdpOpenApiClientType } from "../../openapi-client/index.js";
|
|
5
|
+
export interface TransferOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The base58 encoded Solana address of the source account.
|
|
8
|
+
*/
|
|
9
|
+
from: string;
|
|
10
|
+
/**
|
|
11
|
+
* The base58 encoded Solana address of the destination account.
|
|
12
|
+
*/
|
|
13
|
+
to: string;
|
|
14
|
+
/**
|
|
15
|
+
* The amount to transfer, represented as an atomic unit of the token.
|
|
16
|
+
*/
|
|
17
|
+
amount: bigint;
|
|
18
|
+
/**
|
|
19
|
+
* The token to transfer, or mint address of the SPL token to transfer.
|
|
20
|
+
*/
|
|
21
|
+
token: "sol" | "usdc" | string;
|
|
22
|
+
/**
|
|
23
|
+
* The network to use which will be used to create a Connection, otherwise a Connection can be provided.
|
|
24
|
+
*/
|
|
25
|
+
network: Network | Connection;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transfers SOL or SPL tokens between accounts
|
|
29
|
+
*
|
|
30
|
+
* @param apiClient - The API client to use
|
|
31
|
+
* @param options - The transfer options
|
|
32
|
+
*
|
|
33
|
+
* @returns The transfer result
|
|
34
|
+
*/
|
|
35
|
+
export declare function transfer(apiClient: CdpOpenApiClientType, options: TransferOptions): Promise<SignatureResult>;
|
|
36
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../actions/solana/transfer.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,UAAU,EAOX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,eAAe,CAAC,CAoC1B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransferOptions } from "./transfer.js";
|
|
1
2
|
import { RequestFaucetOptions, SignatureResult, SignMessageOptions, SignTransactionOptions } from "../../client/solana/solana.types.js";
|
|
2
3
|
export type AccountActions = {
|
|
3
4
|
/**
|
|
@@ -76,5 +77,31 @@ export type AccountActions = {
|
|
|
76
77
|
* ```
|
|
77
78
|
*/
|
|
78
79
|
signTransaction: (options: Omit<SignTransactionOptions, "address">) => Promise<SignatureResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Transfers SOL or SPL tokens between accounts
|
|
82
|
+
*
|
|
83
|
+
* @param {TransferOptions} options - Parameters for the transfer.
|
|
84
|
+
* @param {string} options.to - The base58 encoded Solana address of the destination account.
|
|
85
|
+
* @param {sol|usdc|string} options.token - The token to transfer ("sol" or "usdc"), or mint address of the SPL token to transfer.
|
|
86
|
+
* @param {bigint} options.amount - The amount to transfer in atomic units of the token. For example, 0.01 * LAMPORTS_PER_SOL would transfer 0.01 SOL.
|
|
87
|
+
* @param {string | Connection} options.network - The network identifier to use, or a Solana Connection object.
|
|
88
|
+
*
|
|
89
|
+
* @returns A promise that resolves to the transaction signature, which can be used to wait for the transaction result.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { LAMPORTS_PER_SOL } from "@solana/web3.js";
|
|
94
|
+
*
|
|
95
|
+
* const account = await cdp.solana.getAccount({ name: "Account" });
|
|
96
|
+
*
|
|
97
|
+
* const { signature } = await account.transfer({
|
|
98
|
+
* token: "sol",
|
|
99
|
+
* amount: 5 * LAMPORTS_PER_SOL,
|
|
100
|
+
* to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
|
|
101
|
+
* network: "devnet",
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
|
|
79
106
|
};
|
|
80
107
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/solana/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5F;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/solana/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5F;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAEhG;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAChF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
export type Network = "mainnet" | "devnet" | "testnet";
|
|
3
|
+
type GetOrCreateConnectionOptions = {
|
|
4
|
+
networkOrConnection: Network | Connection;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Get a connection to the Solana network
|
|
8
|
+
*
|
|
9
|
+
* @param options - The options for the connection
|
|
10
|
+
*
|
|
11
|
+
* @param options.networkOrConnection - The network to use or a connection
|
|
12
|
+
*
|
|
13
|
+
* @returns The connection
|
|
14
|
+
*/
|
|
15
|
+
export declare function getOrCreateConnection({ networkOrConnection, }: GetOrCreateConnectionOptions): Connection;
|
|
16
|
+
/**
|
|
17
|
+
* Get the network of the connected Solana node
|
|
18
|
+
*
|
|
19
|
+
* @param connection - The connection to the Solana network
|
|
20
|
+
* @throws {Error} If the network is not mainnet, devnet, or testnet
|
|
21
|
+
*
|
|
22
|
+
* @returns The network of the connected Solana node
|
|
23
|
+
*/
|
|
24
|
+
export declare function getConnectedNetwork(connection: Connection): Promise<Network>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the USDC mint address for the given connection
|
|
27
|
+
*
|
|
28
|
+
* @param network - The network to use
|
|
29
|
+
*
|
|
30
|
+
* @returns The USDC mint address
|
|
31
|
+
*/
|
|
32
|
+
export declare function getUsdcMintAddress(network: Network): string;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../actions/solana/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAU7C,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEvD,KAAK,4BAA4B,GAAG;IAClC,mBAAmB,EAAE,OAAO,GAAG,UAAU,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,mBAAmB,GACpB,EAAE,4BAA4B,GAAG,UAAU,CAY3C;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAYlF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAQ3D"}
|
package/_types/analytics.d.ts
CHANGED
|
@@ -19,8 +19,12 @@ type ErrorEventData = {
|
|
|
19
19
|
*/
|
|
20
20
|
name: "error";
|
|
21
21
|
};
|
|
22
|
-
type EventData = ErrorEventData
|
|
23
|
-
|
|
22
|
+
type EventData = ErrorEventData;
|
|
23
|
+
export declare const Analytics: {
|
|
24
|
+
identifier: string;
|
|
25
|
+
wrapClassWithErrorTracking: typeof wrapClassWithErrorTracking;
|
|
26
|
+
wrapObjectMethodsWithErrorTracking: typeof wrapObjectMethodsWithErrorTracking;
|
|
27
|
+
sendEvent: typeof sendEvent;
|
|
24
28
|
};
|
|
25
29
|
/**
|
|
26
30
|
* Sends an analytics event to the default endpoint
|
|
@@ -28,13 +32,18 @@ type EventData = ErrorEventData & {
|
|
|
28
32
|
* @param event - The event data containing event-specific fields
|
|
29
33
|
* @returns Promise that resolves when the event is sent
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
declare function sendEvent(event: EventData): Promise<void>;
|
|
32
36
|
/**
|
|
33
37
|
* Wraps all methods of a class with error tracking.
|
|
34
38
|
*
|
|
35
39
|
* @param ClassToWrap - The class whose prototype methods should be wrapped.
|
|
36
|
-
* @param apiKeyId - The API key ID to use for the error tracking.
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
declare function wrapClassWithErrorTracking(ClassToWrap: any): void;
|
|
42
|
+
/**
|
|
43
|
+
* Wraps all methods of an object with error tracking.
|
|
44
|
+
*
|
|
45
|
+
* @param object - The object whose methods should be wrapped.
|
|
46
|
+
*/
|
|
47
|
+
declare function wrapObjectMethodsWithErrorTracking(object: any): void;
|
|
39
48
|
export {};
|
|
40
49
|
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,KAAK,SAAS,GAAG,cAAc,CAAC;AAKhC,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF;;;;;GAKG;AACH,iBAAe,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CxD;AAED;;;;GAIG;AAEH,iBAAS,0BAA0B,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,CAkC1D;AAED;;;;GAIG;AAEH,iBAAS,kCAAkC,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAkC7D"}
|
package/_types/client/cdp.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EvmClient } from "./evm/evm.js";
|
|
2
|
+
import { PoliciesClient } from "./policies/policies.js";
|
|
2
3
|
import { SolanaClient } from "./solana/solana.js";
|
|
3
4
|
interface CdpClientOptions {
|
|
4
5
|
/** The API key ID. */
|
|
@@ -20,6 +21,8 @@ export declare class CdpClient {
|
|
|
20
21
|
evm: EvmClient;
|
|
21
22
|
/** Namespace containing all Solana methods. */
|
|
22
23
|
solana: SolanaClient;
|
|
24
|
+
/** Namespace containing all Policies methods. */
|
|
25
|
+
policies: PoliciesClient;
|
|
23
26
|
/**
|
|
24
27
|
* The CdpClient is the main class for interacting with the CDP API.
|
|
25
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../../client/cdp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,UAAU,gBAAgB;IACxB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,4CAA4C;IACrC,GAAG,EAAE,SAAS,CAAC;IAEtB,+CAA+C;IACxC,MAAM,EAAE,YAAY,CAAC;IAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;gBACS,OAAO,GAAE,gBAAqB;
|
|
1
|
+
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../../client/cdp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,UAAU,gBAAgB;IACxB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,4CAA4C;IACrC,GAAG,EAAE,SAAS,CAAC;IAEtB,+CAA+C;IACxC,MAAM,EAAE,YAAY,CAAC;IAE5B,iDAAiD;IAC1C,QAAQ,EAAE,cAAc,CAAC;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;gBACS,OAAO,GAAE,gBAAqB;CA0D3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, WaitForUserOperationOptions, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, GetOrCreateServerAccountOptions } from "./evm.types.js";
|
|
1
|
+
import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, WaitForUserOperationOptions, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, GetOrCreateServerAccountOptions, SignTypedDataOptions, UpdateEvmAccountOptions } from "./evm.types.js";
|
|
2
2
|
import { ListTokenBalancesResult, ListTokenBalancesOptions } from "../../actions/evm/listTokenBalances.js";
|
|
3
3
|
import { RequestFaucetOptions, RequestFaucetResult } from "../../actions/evm/requestFaucet.js";
|
|
4
4
|
import { SendUserOperationOptions, SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
|
|
@@ -421,6 +421,52 @@ export declare class EvmClient implements EvmClientInterface {
|
|
|
421
421
|
* ```
|
|
422
422
|
*/
|
|
423
423
|
signMessage(options: SignMessageOptions): Promise<SignatureResult>;
|
|
424
|
+
/**
|
|
425
|
+
* Signs an EIP-712 message.
|
|
426
|
+
*
|
|
427
|
+
* @param {SignTypedDataOptions} options - Parameters for signing the EIP-712 message.
|
|
428
|
+
* @returns A promise that resolves to the signature.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* const signature = await cdp.evm.signTypedData({
|
|
433
|
+
* address: account.address,
|
|
434
|
+
* domain: {
|
|
435
|
+
* name: "Permit2",
|
|
436
|
+
* chainId: 1,
|
|
437
|
+
* verifyingContract: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
438
|
+
* },
|
|
439
|
+
* types: {
|
|
440
|
+
* EIP712Domain: [
|
|
441
|
+
* { name: "name", type: "string" },
|
|
442
|
+
* { name: "chainId", type: "uint256" },
|
|
443
|
+
* { name: "verifyingContract", type: "address" },
|
|
444
|
+
* ],
|
|
445
|
+
* PermitTransferFrom: [
|
|
446
|
+
* { name: "permitted", type: "TokenPermissions" },
|
|
447
|
+
* { name: "spender", type: "address" },
|
|
448
|
+
* { name: "nonce", type: "uint256" },
|
|
449
|
+
* { name: "deadline", type: "uint256" },
|
|
450
|
+
* ],
|
|
451
|
+
* TokenPermissions: [
|
|
452
|
+
* { name: "token", type: "address" },
|
|
453
|
+
* { name: "amount", type: "uint256" },
|
|
454
|
+
* ],
|
|
455
|
+
* },
|
|
456
|
+
* primaryType: "PermitTransferFrom",
|
|
457
|
+
* message: {
|
|
458
|
+
* permitted: {
|
|
459
|
+
* token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
460
|
+
* amount: "1000000",
|
|
461
|
+
* },
|
|
462
|
+
* spender: "0xFfFfFfFFfFFfFFfFFfFFFFFffFFFffffFfFFFfFf",
|
|
463
|
+
* nonce: "0",
|
|
464
|
+
* deadline: "1717123200",
|
|
465
|
+
* },
|
|
466
|
+
* });
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
signTypedData(options: SignTypedDataOptions): Promise<SignatureResult>;
|
|
424
470
|
/**
|
|
425
471
|
* Signs an EVM transaction.
|
|
426
472
|
*
|
|
@@ -452,6 +498,48 @@ export declare class EvmClient implements EvmClientInterface {
|
|
|
452
498
|
* ```
|
|
453
499
|
*/
|
|
454
500
|
signTransaction(options: SignTransactionOptions): Promise<SignatureResult>;
|
|
501
|
+
/**
|
|
502
|
+
* Updates a CDP EVM account.
|
|
503
|
+
*
|
|
504
|
+
* @param {UpdateEvmAccountOptions} [options] - Optional parameters for creating the account.
|
|
505
|
+
* @param {string} options.address - The address of the account to update
|
|
506
|
+
* @param {UpdateEvmAccountBody} options.update - An object containing account fields to update.
|
|
507
|
+
* @param {string} [options.update.name] - The new name for the account.
|
|
508
|
+
* @param {string} [options.update.accountPolicy] - The ID of a Policy to apply to the account.
|
|
509
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
510
|
+
*
|
|
511
|
+
* @returns A promise that resolves to the updated account.
|
|
512
|
+
*
|
|
513
|
+
* @example **With a name**
|
|
514
|
+
* ```ts
|
|
515
|
+
* const account = await cdp.evm.updateAccount({ address: "0x...", update: { name: "New Name" } });
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
518
|
+
* @example **With an account policy**
|
|
519
|
+
* ```ts
|
|
520
|
+
* const account = await cdp.evm.updateAccount({ address: "0x...", update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" } });
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* @example **With an idempotency key**
|
|
524
|
+
* ```ts
|
|
525
|
+
* const idempotencyKey = uuidv4();
|
|
526
|
+
*
|
|
527
|
+
* // First call
|
|
528
|
+
* await cdp.evm.updateAccount({
|
|
529
|
+
* address: "0x...",
|
|
530
|
+
* update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" },
|
|
531
|
+
* idempotencyKey,
|
|
532
|
+
* });
|
|
533
|
+
*
|
|
534
|
+
* // Second call with the same idempotency key will not update
|
|
535
|
+
* await cdp.evm.updateAccount({
|
|
536
|
+
* address: '0x...',
|
|
537
|
+
* update: { name: "" },
|
|
538
|
+
* idempotencyKey,
|
|
539
|
+
* });
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
updateAccount(options: UpdateEvmAccountOptions): Promise<ServerAccount>;
|
|
455
543
|
/**
|
|
456
544
|
* Waits for a user operation to complete or fail.
|
|
457
545
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAEL,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEL,8BAA8B,EAC/B,MAAM,2CAA2C,CAAC;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