@coinbase/cdp-sdk 1.38.4 → 1.38.6
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 +13 -0
- package/README.md +24 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +0 -36
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +0 -36
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +0 -42
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +0 -42
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +0 -30
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/sendUserOperation.js +2 -0
- package/_cjs/actions/evm/sendUserOperation.js.map +1 -1
- package/_cjs/analytics.js +164 -2
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/auth/utils/http.js +5 -2
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/auth/utils/jwt.js +1 -1
- package/_cjs/auth/utils/jwt.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +43 -0
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/evm/evm.js +49 -0
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +4 -0
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +6 -41
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js +10 -1
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +14 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +14 -1
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +1 -1
- package/_cjs/openapi-client/index.js +0 -3
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +0 -36
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +0 -36
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +0 -42
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +0 -42
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +0 -30
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/sendUserOperation.js +2 -0
- package/_esm/actions/evm/sendUserOperation.js.map +1 -1
- package/_esm/analytics.js +163 -1
- package/_esm/analytics.js.map +1 -1
- package/_esm/auth/utils/http.js +5 -2
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/auth/utils/jwt.js +1 -1
- package/_esm/auth/utils/jwt.js.map +1 -1
- package/_esm/client/end-user/endUser.js +44 -1
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/evm/evm.js +49 -0
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +4 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +5 -39
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js +8 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +12 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +12 -0
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +1 -1
- package/_esm/openapi-client/index.js +0 -3
- package/_esm/openapi-client/index.js.map +1 -1
- 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/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -18
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/sendUserOperation.d.ts +11 -0
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +1 -66
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +1 -62
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/analytics.d.ts +27 -0
- package/_types/analytics.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +36 -2
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +5 -0
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +29 -2
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +20 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +44 -246
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +8 -1
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts +11 -0
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +3 -6
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/types/calls.d.ts +1 -0
- package/_types/types/calls.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +0 -47
- package/accounts/evm/toEvmSmartAccount.ts +0 -47
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +0 -50
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +0 -49
- package/accounts/evm/types.ts +5 -49
- package/accounts/solana/toSolanaAccount.ts +0 -41
- package/actions/evm/sendUserOperation.ts +14 -0
- package/actions/evm/types.ts +1 -74
- package/actions/solana/types.ts +1 -70
- package/analytics.ts +225 -1
- package/auth/utils/http.ts +5 -2
- package/auth/utils/jwt.ts +1 -1
- package/client/end-user/endUser.ts +52 -2
- package/client/end-user/endUser.types.ts +7 -0
- package/client/evm/evm.ts +61 -0
- package/client/evm/evm.types.ts +23 -0
- package/index.ts +2 -1
- package/openapi-client/cdpApiClient.ts +5 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +53 -289
- package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +14 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
- package/openapi-client/generated/sql-api-alpha/sql-api-alpha.ts +13 -0
- package/openapi-client/index.ts +0 -3
- package/package.json +1 -1
- package/types/calls.ts +1 -0
- package/version.ts +1 -1
- package/_cjs/actions/Quote.js +0 -106
- package/_cjs/actions/Quote.js.map +0 -1
- package/_cjs/actions/evm/fund/fund.js +0 -51
- package/_cjs/actions/evm/fund/fund.js.map +0 -1
- package/_cjs/actions/evm/fund/quoteFund.js +0 -48
- package/_cjs/actions/evm/fund/quoteFund.js.map +0 -1
- package/_cjs/actions/solana/fund/fund.js +0 -51
- package/_cjs/actions/solana/fund/fund.js.map +0 -1
- package/_cjs/actions/solana/fund/quoteFund.js +0 -48
- package/_cjs/actions/solana/fund/quoteFund.js.map +0 -1
- package/_cjs/actions/types.js +0 -3
- package/_cjs/actions/types.js.map +0 -1
- package/_cjs/actions/waitForFundOperationReceipt.js +0 -65
- package/_cjs/actions/waitForFundOperationReceipt.js.map +0 -1
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.js +0 -50
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.js.map +0 -1
- package/_esm/actions/Quote.js +0 -101
- package/_esm/actions/Quote.js.map +0 -1
- package/_esm/actions/evm/fund/fund.js +0 -48
- package/_esm/actions/evm/fund/fund.js.map +0 -1
- package/_esm/actions/evm/fund/quoteFund.js +0 -45
- package/_esm/actions/evm/fund/quoteFund.js.map +0 -1
- package/_esm/actions/solana/fund/fund.js +0 -48
- package/_esm/actions/solana/fund/fund.js.map +0 -1
- package/_esm/actions/solana/fund/quoteFund.js +0 -45
- package/_esm/actions/solana/fund/quoteFund.js.map +0 -1
- package/_esm/actions/types.js +0 -2
- package/_esm/actions/types.js.map +0 -1
- package/_esm/actions/waitForFundOperationReceipt.js +0 -62
- package/_esm/actions/waitForFundOperationReceipt.js.map +0 -1
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.js +0 -42
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.js.map +0 -1
- package/_types/actions/Quote.d.ts +0 -97
- package/_types/actions/Quote.d.ts.map +0 -1
- package/_types/actions/evm/fund/fund.d.ts +0 -22
- package/_types/actions/evm/fund/fund.d.ts.map +0 -1
- package/_types/actions/evm/fund/quoteFund.d.ts +0 -23
- package/_types/actions/evm/fund/quoteFund.d.ts.map +0 -1
- package/_types/actions/solana/fund/fund.d.ts +0 -20
- package/_types/actions/solana/fund/fund.d.ts.map +0 -1
- package/_types/actions/solana/fund/quoteFund.d.ts +0 -21
- package/_types/actions/solana/fund/quoteFund.d.ts.map +0 -1
- package/_types/actions/types.d.ts +0 -37
- package/_types/actions/types.d.ts.map +0 -1
- package/_types/actions/waitForFundOperationReceipt.d.ts +0 -69
- package/_types/actions/waitForFundOperationReceipt.d.ts.map +0 -1
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.d.ts +0 -42
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.d.ts.map +0 -1
- package/actions/Quote.ts +0 -154
- package/actions/evm/fund/fund.ts +0 -74
- package/actions/evm/fund/quoteFund.ts +0 -80
- package/actions/solana/fund/fund.ts +0 -72
- package/actions/solana/fund/quoteFund.ts +0 -78
- package/actions/types.ts +0 -39
- package/actions/waitForFundOperationReceipt.ts +0 -119
- package/openapi-client/generated/payments-alpha/payments-alpha.ts +0 -96
package/actions/evm/types.ts
CHANGED
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
* @module Actions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { FundOperationResult } from "../types.js";
|
|
6
|
-
import {
|
|
7
|
-
WaitForFundOperationOptions,
|
|
8
|
-
WaitForFundOperationResult,
|
|
9
|
-
} from "../waitForFundOperationReceipt.js";
|
|
10
|
-
import { EvmFundOptions } from "./fund/fund.js";
|
|
11
|
-
import { EvmQuoteFundOptions } from "./fund/quoteFund.js";
|
|
12
5
|
import { SendUserOperationOptions, SendUserOperationReturnType } from "./sendUserOperation.js";
|
|
6
|
+
import { UseSpendPermissionOptions } from "./spend-permissions/types.js";
|
|
13
7
|
import { KnownEvmNetworks } from "../../accounts/evm/types.js";
|
|
14
8
|
import {
|
|
15
9
|
GetUserOperationOptions,
|
|
@@ -17,8 +11,6 @@ import {
|
|
|
17
11
|
UserOperation,
|
|
18
12
|
} from "../../client/evm/evm.types.js";
|
|
19
13
|
import { Hex } from "../../types/misc.js";
|
|
20
|
-
import { EvmQuote } from "../Quote.js";
|
|
21
|
-
import { UseSpendPermissionOptions } from "./spend-permissions/types.js";
|
|
22
14
|
|
|
23
15
|
import type { ListTokenBalancesOptions, ListTokenBalancesResult } from "./listTokenBalances.js";
|
|
24
16
|
import type { RequestFaucetOptions, RequestFaucetResult } from "./requestFaucet.js";
|
|
@@ -78,71 +70,6 @@ export type Actions = {
|
|
|
78
70
|
* ```
|
|
79
71
|
*/
|
|
80
72
|
requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<RequestFaucetResult>;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Gets a quote to fund an EVM account.
|
|
84
|
-
*
|
|
85
|
-
* @param options - The options for the quote fund.
|
|
86
|
-
* @param options.network - The network to fund the account on.
|
|
87
|
-
* @param options.token - The token to fund the account with.
|
|
88
|
-
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
89
|
-
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
90
|
-
* Otherwise, you can pass atomic units directly.
|
|
91
|
-
*
|
|
92
|
-
* @returns A promise that resolves to a Quote object containing details about the funding operation.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const quote = await account.quoteFund({
|
|
97
|
-
* network: "base",
|
|
98
|
-
* token: "usdc",
|
|
99
|
-
* amount: 1000000n,
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
quoteFund: (options: Omit<EvmQuoteFundOptions, "address">) => Promise<EvmQuote>;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Funds an EVM account with the specified token amount.
|
|
107
|
-
*
|
|
108
|
-
* @param options - The options for the fund operation.
|
|
109
|
-
* @param options.network - The network to fund the account on.
|
|
110
|
-
* @param options.token - The token to fund the account with (e.g., 'usdc').
|
|
111
|
-
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
112
|
-
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
113
|
-
* Otherwise, you can pass atomic units directly.
|
|
114
|
-
*
|
|
115
|
-
* @returns A promise that resolves to the fund operation result containing the transfer details.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```ts
|
|
119
|
-
* const fundOperation = await account.fund({
|
|
120
|
-
* network: "base",
|
|
121
|
-
* token: "usdc",
|
|
122
|
-
* amount: 1000000n,
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
fund: (options: Omit<EvmFundOptions, "address">) => Promise<FundOperationResult>;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Waits for a fund operation to complete and returns the transfer receipt.
|
|
130
|
-
*
|
|
131
|
-
* @param options - The options for the wait for fund operation.
|
|
132
|
-
* @param options.transferId - The ID of the transfer to wait for.
|
|
133
|
-
*
|
|
134
|
-
* @returns A promise that resolves to the completed transfer receipt containing details about the funding operation.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* const completedTransfer = await account.waitForFundOperationReceipt({
|
|
139
|
-
* transferId: "transfer_123",
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
waitForFundOperationReceipt(
|
|
144
|
-
options: WaitForFundOperationOptions,
|
|
145
|
-
): Promise<WaitForFundOperationResult>;
|
|
146
73
|
};
|
|
147
74
|
|
|
148
75
|
export type AccountActions = Actions & {
|
package/actions/solana/types.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @module Actions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { SendTransactionResult } from "./sendTransaction.js";
|
|
5
6
|
import { TransferOptions } from "./transfer.js";
|
|
6
7
|
import {
|
|
7
8
|
RequestFaucetOptions,
|
|
@@ -10,15 +11,6 @@ import {
|
|
|
10
11
|
SignMessageOptions,
|
|
11
12
|
SignTransactionOptions,
|
|
12
13
|
} from "../../client/solana/solana.types.js";
|
|
13
|
-
import { SolanaQuote } from "../Quote.js";
|
|
14
|
-
import { FundOperationResult } from "../types.js";
|
|
15
|
-
import {
|
|
16
|
-
WaitForFundOperationOptions,
|
|
17
|
-
WaitForFundOperationResult,
|
|
18
|
-
} from "../waitForFundOperationReceipt.js";
|
|
19
|
-
import { SolanaFundOptions } from "./fund/fund.js";
|
|
20
|
-
import { SolanaQuoteFundOptions } from "./fund/quoteFund.js";
|
|
21
|
-
import { SendTransactionResult } from "./sendTransaction.js";
|
|
22
14
|
|
|
23
15
|
import type { SignTransactionResult } from "./signTransaction.js";
|
|
24
16
|
|
|
@@ -166,65 +158,4 @@ export type AccountActions = {
|
|
|
166
158
|
* ```
|
|
167
159
|
*/
|
|
168
160
|
transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Gets a quote to fund a Solana account.
|
|
172
|
-
*
|
|
173
|
-
* @param options - The options for the quote fund.
|
|
174
|
-
* @param options.token - The token to fund the account with.
|
|
175
|
-
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
176
|
-
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
177
|
-
* Otherwise, you can pass atomic units directly.
|
|
178
|
-
*
|
|
179
|
-
* @returns A promise that resolves to a Quote object containing details about the funding operation.
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```ts
|
|
183
|
-
* const quote = await account.quoteFund({
|
|
184
|
-
* token: "usdc",
|
|
185
|
-
* amount: 1000000n,
|
|
186
|
-
* });
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
quoteFund: (options: Omit<SolanaQuoteFundOptions, "address">) => Promise<SolanaQuote>;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Funds a Solana account with the specified token amount.
|
|
193
|
-
*
|
|
194
|
-
* @param options - The options for the fund operation.
|
|
195
|
-
* @param options.token - The token to fund the account with (e.g., 'usdc').
|
|
196
|
-
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
197
|
-
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
198
|
-
* Otherwise, you can pass atomic units directly.
|
|
199
|
-
*
|
|
200
|
-
* @returns A promise that resolves to the fund operation result containing the transfer details.
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```ts
|
|
204
|
-
* const fundOperation = await account.fund({
|
|
205
|
-
* token: "usdc",
|
|
206
|
-
* amount: 1000000n,
|
|
207
|
-
* });
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
fund: (options: Omit<SolanaFundOptions, "address">) => Promise<FundOperationResult>;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Waits for a fund operation to complete and returns the transfer receipt.
|
|
214
|
-
*
|
|
215
|
-
* @param options - The options for the wait for fund operation.
|
|
216
|
-
* @param options.transferId - The ID of the transfer to wait for.
|
|
217
|
-
*
|
|
218
|
-
* @returns A promise that resolves to the completed transfer receipt containing details about the funding operation.
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```ts
|
|
222
|
-
* const completedTransfer = await account.waitForFundOperationReceipt({
|
|
223
|
-
* transferId: "transfer_123",
|
|
224
|
-
* });
|
|
225
|
-
* ```
|
|
226
|
-
*/
|
|
227
|
-
waitForFundOperationReceipt(
|
|
228
|
-
options: WaitForFundOperationOptions,
|
|
229
|
-
): Promise<WaitForFundOperationResult>;
|
|
230
161
|
};
|
package/analytics.ts
CHANGED
|
@@ -50,6 +50,9 @@ type ActionEventData = {
|
|
|
50
50
|
|
|
51
51
|
type EventData = ErrorEventData | ActionEventData;
|
|
52
52
|
|
|
53
|
+
// Symbol to store the original method on wrapped functions
|
|
54
|
+
const ORIGINAL_METHOD = Symbol("originalMethod");
|
|
55
|
+
|
|
53
56
|
// This is a public client id for the analytics service
|
|
54
57
|
const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
|
|
55
58
|
|
|
@@ -61,6 +64,23 @@ export const Analytics = {
|
|
|
61
64
|
trackAction,
|
|
62
65
|
};
|
|
63
66
|
|
|
67
|
+
/*
|
|
68
|
+
* Deprecated implementation - kept for test compatibility
|
|
69
|
+
* Shares the same identifier reference as Analytics
|
|
70
|
+
*/
|
|
71
|
+
export const AnalyticsDeprecated = {
|
|
72
|
+
get identifier() {
|
|
73
|
+
return Analytics.identifier;
|
|
74
|
+
},
|
|
75
|
+
set identifier(value: string) {
|
|
76
|
+
Analytics.identifier = value;
|
|
77
|
+
},
|
|
78
|
+
wrapClassWithErrorTracking: wrapClassWithErrorTrackingDeprecated,
|
|
79
|
+
wrapObjectMethodsWithErrorTracking: wrapObjectMethodsWithErrorTrackingDeprecated,
|
|
80
|
+
sendEvent,
|
|
81
|
+
trackAction,
|
|
82
|
+
};
|
|
83
|
+
|
|
64
84
|
/**
|
|
65
85
|
* Sends an analytics event to the default endpoint
|
|
66
86
|
*
|
|
@@ -150,6 +170,129 @@ function trackAction(params: {
|
|
|
150
170
|
});
|
|
151
171
|
}
|
|
152
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Gets the original method from a wrapped method, or returns the method itself if it's not wrapped.
|
|
175
|
+
*
|
|
176
|
+
* @param method - The method to get the original version of.
|
|
177
|
+
* @returns The original unwrapped method, or the method itself if it's not wrapped.
|
|
178
|
+
*/
|
|
179
|
+
function getOriginalMethod(
|
|
180
|
+
method: (this: unknown, ...args: unknown[]) => Promise<unknown>,
|
|
181
|
+
): (this: unknown, ...args: unknown[]) => Promise<unknown> {
|
|
182
|
+
return (
|
|
183
|
+
(method as { [ORIGINAL_METHOD]?: (this: unknown, ...args: unknown[]) => Promise<unknown> })[
|
|
184
|
+
ORIGINAL_METHOD
|
|
185
|
+
] || method
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Creates an interceptor function that prevents recursive calls by checking if the instance is already executing.
|
|
191
|
+
*
|
|
192
|
+
* @param executingInstances - A WeakSet tracking instances that are currently executing.
|
|
193
|
+
* @param fallbackMethod - The method to call if recursion is not detected.
|
|
194
|
+
* @returns A function that intercepts calls and prevents recursion.
|
|
195
|
+
*/
|
|
196
|
+
function createRecursiveInterceptor(
|
|
197
|
+
executingInstances: WeakSet<object>,
|
|
198
|
+
fallbackMethod: (...args: unknown[]) => Promise<unknown>,
|
|
199
|
+
): (...args: unknown[]) => Promise<unknown> {
|
|
200
|
+
return function (this: unknown, ...callArgs: unknown[]) {
|
|
201
|
+
if (executingInstances.has(this as object)) {
|
|
202
|
+
return Promise.resolve(callArgs[0]);
|
|
203
|
+
}
|
|
204
|
+
return fallbackMethod.apply(this, callArgs);
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Executes a method with recursion protection by tracking executing instances.
|
|
210
|
+
*
|
|
211
|
+
* @param executingInstances - A WeakSet tracking instances that are currently executing.
|
|
212
|
+
* @param originalMethod - The original method to execute.
|
|
213
|
+
* @param context - The context (this) to bind the method to.
|
|
214
|
+
* @param args - The arguments to pass to the method.
|
|
215
|
+
* @returns The result of executing the original method.
|
|
216
|
+
*/
|
|
217
|
+
async function executeWithRecursionProtection<T>(
|
|
218
|
+
executingInstances: WeakSet<object>,
|
|
219
|
+
originalMethod: (this: unknown, ...args: unknown[]) => Promise<T>,
|
|
220
|
+
context: unknown,
|
|
221
|
+
args: unknown[],
|
|
222
|
+
): Promise<T> {
|
|
223
|
+
if (executingInstances.has(context as object)) {
|
|
224
|
+
return args[0] as T;
|
|
225
|
+
}
|
|
226
|
+
executingInstances.add(context as object);
|
|
227
|
+
try {
|
|
228
|
+
return await originalMethod.apply(context, args);
|
|
229
|
+
} finally {
|
|
230
|
+
executingInstances.delete(context as object);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Handles an error that occurred in a method by sending an analytics event and rethrowing the error.
|
|
236
|
+
*
|
|
237
|
+
* @param error - The error that occurred.
|
|
238
|
+
* @param methodName - The name of the method where the error occurred.
|
|
239
|
+
*/
|
|
240
|
+
async function handleMethodError(error: unknown, methodName: string): Promise<void> {
|
|
241
|
+
if (!shouldTrackError(error)) {
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const { message, stack } = error as Error;
|
|
246
|
+
sendEvent({
|
|
247
|
+
method: methodName,
|
|
248
|
+
message,
|
|
249
|
+
stack,
|
|
250
|
+
name: "error",
|
|
251
|
+
}).catch(() => {
|
|
252
|
+
// ignore error
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Creates a wrapper function that adds error tracking and recursion protection to a method.
|
|
260
|
+
*
|
|
261
|
+
* @param originalMethod - The original method to wrap.
|
|
262
|
+
* @param methodName - The name of the method being wrapped.
|
|
263
|
+
* @param executingInstances - A WeakSet tracking instances that are currently executing.
|
|
264
|
+
* @param setMethod - A function to set the method implementation.
|
|
265
|
+
* @param getMethod - A function to get the current method implementation.
|
|
266
|
+
* @returns A wrapped version of the method with error tracking and recursion protection.
|
|
267
|
+
*/
|
|
268
|
+
function createErrorTrackingWrapper(
|
|
269
|
+
originalMethod: (this: unknown, ...args: unknown[]) => Promise<unknown>,
|
|
270
|
+
methodName: string,
|
|
271
|
+
executingInstances: WeakSet<object>,
|
|
272
|
+
setMethod: (method: (...args: unknown[]) => Promise<unknown>) => void,
|
|
273
|
+
getMethod: () => (...args: unknown[]) => Promise<unknown>,
|
|
274
|
+
): (this: unknown, ...args: unknown[]) => Promise<unknown> {
|
|
275
|
+
return async function (this: unknown, ...args: unknown[]) {
|
|
276
|
+
const previousMethod = getMethod();
|
|
277
|
+
const recursiveInterceptor = createRecursiveInterceptor(executingInstances, previousMethod);
|
|
278
|
+
setMethod(recursiveInterceptor);
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
const result = await executeWithRecursionProtection(
|
|
282
|
+
executingInstances,
|
|
283
|
+
originalMethod,
|
|
284
|
+
this,
|
|
285
|
+
args,
|
|
286
|
+
);
|
|
287
|
+
setMethod(previousMethod);
|
|
288
|
+
return result;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
setMethod(previousMethod);
|
|
291
|
+
return handleMethodError(error, methodName);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
153
296
|
/**
|
|
154
297
|
* Wraps all methods of a class with error tracking.
|
|
155
298
|
*
|
|
@@ -165,6 +308,83 @@ function wrapClassWithErrorTracking(ClassToWrap: any): void {
|
|
|
165
308
|
name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
|
|
166
309
|
);
|
|
167
310
|
|
|
311
|
+
for (const method of methods) {
|
|
312
|
+
const currentMethod = ClassToWrap.prototype[method];
|
|
313
|
+
const originalMethod = getOriginalMethod(currentMethod);
|
|
314
|
+
const executingInstances = new WeakSet<object>();
|
|
315
|
+
|
|
316
|
+
const wrappedMethod = createErrorTrackingWrapper(
|
|
317
|
+
originalMethod,
|
|
318
|
+
method,
|
|
319
|
+
executingInstances,
|
|
320
|
+
newMethod => {
|
|
321
|
+
ClassToWrap.prototype[method] = newMethod as (
|
|
322
|
+
this: unknown,
|
|
323
|
+
...args: unknown[]
|
|
324
|
+
) => Promise<unknown>;
|
|
325
|
+
},
|
|
326
|
+
() => ClassToWrap.prototype[method] as (...args: unknown[]) => Promise<unknown>,
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
(wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
|
|
330
|
+
ClassToWrap.prototype[method] = wrappedMethod;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Wraps all methods of an object with error tracking.
|
|
336
|
+
*
|
|
337
|
+
* @param object - The object whose methods should be wrapped.
|
|
338
|
+
*/
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
340
|
+
function wrapObjectMethodsWithErrorTracking(object: any): void {
|
|
341
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const methods = Object.getOwnPropertyNames(object).filter(
|
|
346
|
+
name => name !== "constructor" && typeof object[name] === "function",
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
for (const method of methods) {
|
|
350
|
+
const currentMethod = object[method];
|
|
351
|
+
const originalMethod = getOriginalMethod(currentMethod);
|
|
352
|
+
const executingInstances = new WeakSet<object>();
|
|
353
|
+
|
|
354
|
+
const wrappedMethod = createErrorTrackingWrapper(
|
|
355
|
+
originalMethod,
|
|
356
|
+
method,
|
|
357
|
+
executingInstances,
|
|
358
|
+
newMethod => {
|
|
359
|
+
object[method] = newMethod;
|
|
360
|
+
},
|
|
361
|
+
() => object[method] as (...args: unknown[]) => Promise<unknown>,
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
(wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
|
|
365
|
+
object[method] = wrappedMethod;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Wraps all methods of a class with error tracking.
|
|
371
|
+
*
|
|
372
|
+
* @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
|
|
373
|
+
* Use Analytics.wrapClassWithErrorTracking instead.
|
|
374
|
+
* Kept for test compatibility.
|
|
375
|
+
*
|
|
376
|
+
* @param ClassToWrap - The class whose prototype methods should be wrapped.
|
|
377
|
+
*/
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
379
|
+
function wrapClassWithErrorTrackingDeprecated(ClassToWrap: any): void {
|
|
380
|
+
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(
|
|
385
|
+
name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
|
|
386
|
+
);
|
|
387
|
+
|
|
168
388
|
for (const method of methods) {
|
|
169
389
|
const originalMethod = ClassToWrap.prototype[method];
|
|
170
390
|
ClassToWrap.prototype[method] = async function (...args: unknown[]) {
|
|
@@ -195,10 +415,14 @@ function wrapClassWithErrorTracking(ClassToWrap: any): void {
|
|
|
195
415
|
/**
|
|
196
416
|
* Wraps all methods of an object with error tracking.
|
|
197
417
|
*
|
|
418
|
+
* @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
|
|
419
|
+
* Use Analytics.wrapObjectMethodsWithErrorTracking instead.
|
|
420
|
+
* Kept for test compatibility.
|
|
421
|
+
*
|
|
198
422
|
* @param object - The object whose methods should be wrapped.
|
|
199
423
|
*/
|
|
200
424
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
-
function
|
|
425
|
+
function wrapObjectMethodsWithErrorTrackingDeprecated(object: any): void {
|
|
202
426
|
if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
|
|
203
427
|
return;
|
|
204
428
|
}
|
package/auth/utils/http.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { generateWalletJwt, generateJwt } from "./jwt.js";
|
|
6
|
+
import { UserInputValidationError } from "../../errors.js";
|
|
6
7
|
import { version } from "../../version.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -100,7 +101,7 @@ export async function getAuthHeaders(
|
|
|
100
101
|
// Add wallet auth if needed
|
|
101
102
|
if (requiresWalletAuth(options.requestMethod, options.requestPath)) {
|
|
102
103
|
if (!options.walletSecret) {
|
|
103
|
-
throw new
|
|
104
|
+
throw new UserInputValidationError(
|
|
104
105
|
"Wallet Secret not configured. Please set the CDP_WALLET_SECRET environment variable, or pass it as an option to the CdpClient constructor.",
|
|
105
106
|
);
|
|
106
107
|
}
|
|
@@ -130,7 +131,9 @@ export async function getAuthHeaders(
|
|
|
130
131
|
*/
|
|
131
132
|
function requiresWalletAuth(requestMethod: string, requestPath: string): boolean {
|
|
132
133
|
return (
|
|
133
|
-
(requestPath?.includes("/accounts") ||
|
|
134
|
+
(requestPath?.includes("/accounts") ||
|
|
135
|
+
requestPath?.includes("/spend-permissions") ||
|
|
136
|
+
requestPath?.includes("/user-operations/prepare-and-send")) &&
|
|
134
137
|
(requestMethod === "POST" || requestMethod === "DELETE" || requestMethod === "PUT")
|
|
135
138
|
);
|
|
136
139
|
}
|
package/auth/utils/jwt.ts
CHANGED
|
@@ -138,7 +138,7 @@ export async function generateJwt(options: JwtOptions): Promise<string> {
|
|
|
138
138
|
const claims: JWTPayload = {
|
|
139
139
|
sub: options.apiKeyId,
|
|
140
140
|
iss: "cdp",
|
|
141
|
-
aud: options.audience
|
|
141
|
+
aud: options.audience,
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// Add the uris claim only for REST API requests
|
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
import { type ValidateAccessTokenOptions } from "./endUser.types.js";
|
|
1
|
+
import { type ValidateAccessTokenOptions, type ListEndUsersOptions } from "./endUser.types.js";
|
|
2
2
|
import { Analytics } from "../../analytics.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CdpOpenApiClient,
|
|
5
|
+
type EndUser,
|
|
6
|
+
type ListEndUsers200,
|
|
7
|
+
} from "../../openapi-client/index.js";
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* The CDP end user client.
|
|
7
11
|
*/
|
|
8
12
|
export class CDPEndUserClient {
|
|
13
|
+
/**
|
|
14
|
+
* Lists end users belonging to the developer's CDP Project.
|
|
15
|
+
* By default, the response is sorted by creation date in ascending order and paginated to 20 users per page.
|
|
16
|
+
*
|
|
17
|
+
* @param options - The options for listing end users.
|
|
18
|
+
*
|
|
19
|
+
* @returns A promise that resolves to a paginated list of end users.
|
|
20
|
+
*
|
|
21
|
+
* @example **List all end users**
|
|
22
|
+
* ```ts
|
|
23
|
+
* const result = await cdp.endUsers.listEndUsers();
|
|
24
|
+
* console.log(result.endUsers);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example **With pagination**
|
|
28
|
+
* ```ts
|
|
29
|
+
* let page = await cdp.endUsers.listEndUsers({ pageSize: 10 });
|
|
30
|
+
*
|
|
31
|
+
* while (page.nextPageToken) {
|
|
32
|
+
* page = await cdp.endUsers.listEndUsers({
|
|
33
|
+
* pageSize: 10,
|
|
34
|
+
* pageToken: page.nextPageToken
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example **With sorting**
|
|
40
|
+
* ```ts
|
|
41
|
+
* const result = await cdp.endUsers.listEndUsers({
|
|
42
|
+
* sort: ['createdAt=desc']
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
async listEndUsers(options: ListEndUsersOptions = {}): Promise<ListEndUsers200> {
|
|
47
|
+
Analytics.trackAction({
|
|
48
|
+
action: "list_end_users",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const params = {
|
|
52
|
+
...options,
|
|
53
|
+
...(options.sort && { sort: options.sort.join(",") }),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return CdpOpenApiClient.listEndUsers(params as ListEndUsersOptions);
|
|
57
|
+
}
|
|
58
|
+
|
|
9
59
|
/**
|
|
10
60
|
* Validates an end user's access token. Throws an error if the access token is invalid.
|
|
11
61
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ListEndUsersParams } from "../../openapi-client/index.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The options for validating an access token.
|
|
3
5
|
*/
|
|
@@ -7,3 +9,8 @@ export interface ValidateAccessTokenOptions {
|
|
|
7
9
|
*/
|
|
8
10
|
accessToken: string;
|
|
9
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The options for listing end users.
|
|
15
|
+
*/
|
|
16
|
+
export type ListEndUsersOptions = ListEndUsersParams;
|
package/client/evm/evm.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
ListServerAccountsOptions,
|
|
26
26
|
ListSmartAccountResult,
|
|
27
27
|
ListSmartAccountsOptions,
|
|
28
|
+
PrepareAndSendUserOperationOptions,
|
|
28
29
|
PrepareUserOperationOptions,
|
|
29
30
|
ServerAccount,
|
|
30
31
|
SignatureResult,
|
|
@@ -58,6 +59,7 @@ import {
|
|
|
58
59
|
} from "../../actions/evm/requestFaucet.js";
|
|
59
60
|
import { sendTransaction } from "../../actions/evm/sendTransaction.js";
|
|
60
61
|
import {
|
|
62
|
+
PrepareAndSendUserOperationReturnType,
|
|
61
63
|
sendUserOperation,
|
|
62
64
|
SendUserOperationOptions,
|
|
63
65
|
SendUserOperationReturnType,
|
|
@@ -75,6 +77,7 @@ import { UserInputValidationError } from "../../errors.js";
|
|
|
75
77
|
import { APIError } from "../../openapi-client/errors.js";
|
|
76
78
|
import {
|
|
77
79
|
CdpOpenApiClient,
|
|
80
|
+
EvmUserOperationStatus,
|
|
78
81
|
EIP712Message as OpenAPIEIP712Message,
|
|
79
82
|
} from "../../openapi-client/index.js";
|
|
80
83
|
import { SPEND_PERMISSION_MANAGER_ADDRESS } from "../../spend-permissions/constants.js";
|
|
@@ -892,6 +895,7 @@ export class EvmClient implements EvmClientInterface {
|
|
|
892
895
|
to: call.to as Address,
|
|
893
896
|
value: call.value.toString(),
|
|
894
897
|
data: call.data as Hex,
|
|
898
|
+
overrideGasLimit: call.overrideGasLimit,
|
|
895
899
|
})),
|
|
896
900
|
paymasterUrl: options.paymasterUrl,
|
|
897
901
|
});
|
|
@@ -908,6 +912,63 @@ export class EvmClient implements EvmClientInterface {
|
|
|
908
912
|
};
|
|
909
913
|
}
|
|
910
914
|
|
|
915
|
+
/**
|
|
916
|
+
* Prepares and sends a user operation for a smart account.
|
|
917
|
+
*
|
|
918
|
+
* @param {PrepareAndSendUserOperationOptions} options - Parameters for preparing and sending the user operation.
|
|
919
|
+
* @param {SmartAccount} options.smartAccount - The smart account signing the user operation.
|
|
920
|
+
* @param {string} options.network - The network to prepare and send the user operation on.
|
|
921
|
+
* @param {EvmCall[]} options.calls - The calls to include in the user operation.
|
|
922
|
+
* @param {string} [options.paymasterUrl] - The optional paymaster URL to use for the user operation.
|
|
923
|
+
*
|
|
924
|
+
* @returns A promise that resolves to the smart account address, user operation hash, and status of the user operation.
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```ts
|
|
928
|
+
* const { userOpHash } = await cdp.evm.prepareAndSendUserOperation({
|
|
929
|
+
* smartAccount,
|
|
930
|
+
* network: "base-sepolia",
|
|
931
|
+
* calls: [
|
|
932
|
+
* {
|
|
933
|
+
* to: "0x1234567890123456789012345678901234567890",
|
|
934
|
+
* value: parseEther("0.000001"),
|
|
935
|
+
* data: "0x",
|
|
936
|
+
* },
|
|
937
|
+
* ],
|
|
938
|
+
* });
|
|
939
|
+
* ```
|
|
940
|
+
*/
|
|
941
|
+
async prepareAndSendUserOperation(
|
|
942
|
+
options: PrepareAndSendUserOperationOptions,
|
|
943
|
+
): Promise<PrepareAndSendUserOperationReturnType> {
|
|
944
|
+
Analytics.trackAction({
|
|
945
|
+
action: "prepare_and_send_user_operation",
|
|
946
|
+
properties: {
|
|
947
|
+
network: options.network,
|
|
948
|
+
},
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
const userOp = await CdpOpenApiClient.prepareAndSendUserOperation(
|
|
952
|
+
options.smartAccount.address,
|
|
953
|
+
{
|
|
954
|
+
network: options.network,
|
|
955
|
+
calls: options.calls.map(call => ({
|
|
956
|
+
to: call.to as Address,
|
|
957
|
+
value: call.value.toString(),
|
|
958
|
+
data: call.data as Hex,
|
|
959
|
+
})),
|
|
960
|
+
paymasterUrl: options.paymasterUrl,
|
|
961
|
+
},
|
|
962
|
+
options.idempotencyKey,
|
|
963
|
+
);
|
|
964
|
+
|
|
965
|
+
return {
|
|
966
|
+
smartAccountAddress: options.smartAccount.address as Address,
|
|
967
|
+
userOpHash: userOp.userOpHash as Hex,
|
|
968
|
+
status: userOp.status as typeof EvmUserOperationStatus.broadcast,
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
|
|
911
972
|
/**
|
|
912
973
|
* Requests funds from an EVM faucet.
|
|
913
974
|
*
|