@coinbase/cdp-sdk 1.38.4 → 1.38.5
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 +7 -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/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/evm/evm.js +49 -0
- package/_cjs/client/evm/evm.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/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/evm/evm.js +49 -0
- package/_esm/client/evm/evm.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/auth/utils/http.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/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/auth/utils/http.ts +5 -2
- package/auth/utils/jwt.ts +1 -1
- package/client/evm/evm.ts +61 -0
- package/client/evm/evm.types.ts +23 -0
- 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
|
@@ -8,8 +8,6 @@ import { transferWithViem } from "../../actions/evm/transfer/transferWithViem.js
|
|
|
8
8
|
import { Analytics } from "../../analytics.js";
|
|
9
9
|
|
|
10
10
|
import type { EvmServerAccount, NetworkScopedEvmServerAccount, DistributedOmit } from "./types.js";
|
|
11
|
-
import type { EvmFundOptions } from "../../actions/evm/fund/fund.js";
|
|
12
|
-
import type { EvmQuoteFundOptions } from "../../actions/evm/fund/quoteFund.js";
|
|
13
11
|
import type { ListTokenBalancesOptions } from "../../actions/evm/listTokenBalances.js";
|
|
14
12
|
import type { RequestFaucetOptions } from "../../actions/evm/requestFaucet.js";
|
|
15
13
|
import type {
|
|
@@ -19,7 +17,6 @@ import type {
|
|
|
19
17
|
import type { UseSpendPermissionOptions } from "../../actions/evm/spend-permissions/types.js";
|
|
20
18
|
import type { AccountQuoteSwapOptions, AccountSwapOptions } from "../../actions/evm/swap/types.js";
|
|
21
19
|
import type { TransferOptions } from "../../actions/evm/transfer/types.js";
|
|
22
|
-
import type { WaitForFundOperationOptions } from "../../actions/waitForFundOperationReceipt.js";
|
|
23
20
|
import type { EvmSwapsNetwork } from "../../openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
24
21
|
import type {
|
|
25
22
|
ListEvmTokenBalancesNetwork,
|
|
@@ -178,53 +175,6 @@ export async function toNetworkScopedEvmServerAccount<Network extends string>(
|
|
|
178
175
|
});
|
|
179
176
|
}
|
|
180
177
|
|
|
181
|
-
if (isMethodSupportedOnNetwork("quoteFund", resolvedNetworkName)) {
|
|
182
|
-
Object.assign(account, {
|
|
183
|
-
quoteFund: async (quoteFundOptions: Omit<EvmQuoteFundOptions, "address">) => {
|
|
184
|
-
Analytics.trackAction({
|
|
185
|
-
action: "quote_fund",
|
|
186
|
-
accountType: "evm_server",
|
|
187
|
-
properties: {
|
|
188
|
-
managed: true,
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
return options.account.quoteFund({
|
|
193
|
-
...quoteFundOptions,
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (isMethodSupportedOnNetwork("fund", resolvedNetworkName)) {
|
|
200
|
-
Object.assign(account, {
|
|
201
|
-
fund: async (fundOptions: Omit<EvmFundOptions, "address">) => {
|
|
202
|
-
Analytics.trackAction({
|
|
203
|
-
action: "fund",
|
|
204
|
-
accountType: "evm_server",
|
|
205
|
-
properties: {
|
|
206
|
-
managed: true,
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return options.account.fund({
|
|
211
|
-
...fundOptions,
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
waitForFundOperationReceipt: async (waitOptions: WaitForFundOperationOptions) => {
|
|
215
|
-
Analytics.trackAction({
|
|
216
|
-
action: "wait_for_fund_operation_receipt",
|
|
217
|
-
accountType: "evm_server",
|
|
218
|
-
properties: {
|
|
219
|
-
managed: true,
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return options.account.waitForFundOperationReceipt(waitOptions);
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
178
|
if (isMethodSupportedOnNetwork("quoteSwap", resolvedNetworkName)) {
|
|
229
179
|
Object.assign(account, {
|
|
230
180
|
quoteSwap: async (quoteSwapOptions: DistributedOmit<AccountQuoteSwapOptions, "network">) => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { getBaseNodeRpcUrl } from "./getBaseNodeRpcUrl.js";
|
|
2
2
|
import { isMethodSupportedOnNetwork } from "./networkCapabilities.js";
|
|
3
|
-
import { fund } from "../../actions/evm/fund/fund.js";
|
|
4
|
-
import { quoteFund } from "../../actions/evm/fund/quoteFund.js";
|
|
5
3
|
import { getUserOperation } from "../../actions/evm/getUserOperation.js";
|
|
6
4
|
import { listTokenBalances } from "../../actions/evm/listTokenBalances.js";
|
|
7
5
|
import { requestFaucet } from "../../actions/evm/requestFaucet.js";
|
|
@@ -12,7 +10,6 @@ import { sendSwapOperation } from "../../actions/evm/swap/sendSwapOperation.js";
|
|
|
12
10
|
import { smartAccountTransferStrategy } from "../../actions/evm/transfer/smartAccountTransferStrategy.js";
|
|
13
11
|
import { transfer } from "../../actions/evm/transfer/transfer.js";
|
|
14
12
|
import { waitForUserOperation } from "../../actions/evm/waitForUserOperation.js";
|
|
15
|
-
import { waitForFundOperationReceipt } from "../../actions/waitForFundOperationReceipt.js";
|
|
16
13
|
import { Analytics } from "../../analytics.js";
|
|
17
14
|
|
|
18
15
|
import type {
|
|
@@ -22,8 +19,6 @@ import type {
|
|
|
22
19
|
NetworkScopedEvmSmartAccount,
|
|
23
20
|
DistributedOmit,
|
|
24
21
|
} from "./types.js";
|
|
25
|
-
import type { EvmFundOptions } from "../../actions/evm/fund/fund.js";
|
|
26
|
-
import type { EvmQuoteFundOptions } from "../../actions/evm/fund/quoteFund.js";
|
|
27
22
|
import type { ListTokenBalancesOptions } from "../../actions/evm/listTokenBalances.js";
|
|
28
23
|
import type { RequestFaucetOptions } from "../../actions/evm/requestFaucet.js";
|
|
29
24
|
import type { SendUserOperationOptions } from "../../actions/evm/sendUserOperation.js";
|
|
@@ -34,7 +29,6 @@ import type {
|
|
|
34
29
|
} from "../../actions/evm/swap/types.js";
|
|
35
30
|
import type { SmartAccountTransferOptions } from "../../actions/evm/transfer/types.js";
|
|
36
31
|
import type { WaitForUserOperationOptions } from "../../actions/evm/waitForUserOperation.js";
|
|
37
|
-
import type { WaitForFundOperationOptions } from "../../actions/waitForFundOperationReceipt.js";
|
|
38
32
|
import type { GetUserOperationOptions } from "../../client/evm/evm.types.js";
|
|
39
33
|
import type {
|
|
40
34
|
CdpOpenApiClientType,
|
|
@@ -206,49 +200,6 @@ export async function toNetworkScopedEvmSmartAccount<Network extends KnownEvmNet
|
|
|
206
200
|
});
|
|
207
201
|
}
|
|
208
202
|
|
|
209
|
-
if (isMethodSupportedOnNetwork("quoteFund", options.network)) {
|
|
210
|
-
Object.assign(account, {
|
|
211
|
-
quoteFund: async (quoteOptions: Omit<EvmQuoteFundOptions, "address">) => {
|
|
212
|
-
Analytics.trackAction({
|
|
213
|
-
action: "quote_fund",
|
|
214
|
-
accountType: "evm_smart",
|
|
215
|
-
properties: {
|
|
216
|
-
network: options.network,
|
|
217
|
-
managed: true,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
return quoteFund(apiClient, {
|
|
222
|
-
...quoteOptions,
|
|
223
|
-
address: options.smartAccount.address,
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (isMethodSupportedOnNetwork("fund", options.network)) {
|
|
230
|
-
Object.assign(account, {
|
|
231
|
-
fund: async (fundOptions: Omit<EvmFundOptions, "address">) => {
|
|
232
|
-
Analytics.trackAction({
|
|
233
|
-
action: "fund",
|
|
234
|
-
accountType: "evm_smart",
|
|
235
|
-
properties: {
|
|
236
|
-
network: options.network,
|
|
237
|
-
managed: true,
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
return fund(apiClient, {
|
|
242
|
-
...fundOptions,
|
|
243
|
-
address: options.smartAccount.address,
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
waitForFundOperationReceipt: async (waitOptions: WaitForFundOperationOptions) => {
|
|
247
|
-
return waitForFundOperationReceipt(apiClient, waitOptions);
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
203
|
if (isMethodSupportedOnNetwork("quoteSwap", options.network)) {
|
|
253
204
|
Object.assign(account, {
|
|
254
205
|
quoteSwap: async (
|
package/accounts/evm/types.ts
CHANGED
|
@@ -5,14 +5,10 @@
|
|
|
5
5
|
import {
|
|
6
6
|
ListTokenBalancesNetworks,
|
|
7
7
|
RequestFaucetNetworks,
|
|
8
|
-
QuoteFundNetworks,
|
|
9
|
-
FundNetworks,
|
|
10
8
|
TransferNetworks,
|
|
11
|
-
QuoteSwapNetworks,
|
|
12
9
|
SwapNetworks,
|
|
10
|
+
QuoteSwapNetworks,
|
|
13
11
|
} from "./networkCapabilities.js";
|
|
14
|
-
import { EvmFundOptions } from "../../actions/evm/fund/fund.js";
|
|
15
|
-
import { EvmQuoteFundOptions } from "../../actions/evm/fund/quoteFund.js";
|
|
16
12
|
import {
|
|
17
13
|
ListTokenBalancesOptions,
|
|
18
14
|
ListTokenBalancesResult,
|
|
@@ -25,24 +21,19 @@ import {
|
|
|
25
21
|
} from "../../actions/evm/sendUserOperation.js";
|
|
26
22
|
import { UseSpendPermissionOptions } from "../../actions/evm/spend-permissions/types.js";
|
|
27
23
|
import {
|
|
28
|
-
AccountQuoteSwapOptions,
|
|
29
|
-
AccountQuoteSwapResult,
|
|
30
24
|
AccountSwapOptions,
|
|
31
25
|
AccountSwapResult,
|
|
26
|
+
AccountQuoteSwapOptions,
|
|
27
|
+
AccountQuoteSwapResult,
|
|
32
28
|
SmartAccountQuoteSwapOptions,
|
|
33
|
-
SmartAccountQuoteSwapResult,
|
|
34
29
|
SmartAccountSwapOptions,
|
|
35
30
|
SmartAccountSwapResult,
|
|
31
|
+
SmartAccountQuoteSwapResult,
|
|
36
32
|
} from "../../actions/evm/swap/types.js";
|
|
37
33
|
import {
|
|
38
34
|
WaitForUserOperationOptions,
|
|
39
35
|
WaitForUserOperationReturnType,
|
|
40
36
|
} from "../../actions/evm/waitForUserOperation.js";
|
|
41
|
-
import { FundOperationResult } from "../../actions/types.js";
|
|
42
|
-
import {
|
|
43
|
-
WaitForFundOperationOptions,
|
|
44
|
-
WaitForFundOperationResult,
|
|
45
|
-
} from "../../actions/waitForFundOperationReceipt.js";
|
|
46
37
|
import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
|
|
47
38
|
import { SpendPermissionNetwork } from "../../openapi-client/index.js";
|
|
48
39
|
|
|
@@ -51,7 +42,6 @@ import type {
|
|
|
51
42
|
TransferOptions,
|
|
52
43
|
} from "../../actions/evm/transfer/types.js";
|
|
53
44
|
import type { AccountActions, SmartAccountActions } from "../../actions/evm/types.js";
|
|
54
|
-
import type { EvmQuote } from "../../actions/Quote.js";
|
|
55
45
|
import type { Address, Hash, Hex } from "../../types/misc.js";
|
|
56
46
|
import type { Prettify } from "../../types/utils.js";
|
|
57
47
|
import type {
|
|
@@ -220,30 +210,11 @@ export type NetworkSpecificSmartAccountActions<Network extends string> = Prettif
|
|
|
220
210
|
) => Promise<RequestFaucetResult>;
|
|
221
211
|
}
|
|
222
212
|
: EmptyObject) &
|
|
223
|
-
// Conditionally include quoteFund
|
|
224
|
-
(Network extends QuoteFundNetworks
|
|
225
|
-
? {
|
|
226
|
-
quoteFund: (
|
|
227
|
-
options: Omit<EvmQuoteFundOptions, "address" | "network">,
|
|
228
|
-
) => Promise<EvmQuote>;
|
|
229
|
-
}
|
|
230
|
-
: EmptyObject) &
|
|
231
|
-
// Conditionally include fund
|
|
232
|
-
(Network extends FundNetworks
|
|
233
|
-
? {
|
|
234
|
-
fund: (
|
|
235
|
-
options: Omit<EvmFundOptions, "address" | "network">,
|
|
236
|
-
) => Promise<FundOperationResult>;
|
|
237
|
-
waitForFundOperationReceipt: (
|
|
238
|
-
options: Omit<WaitForFundOperationOptions, "network">,
|
|
239
|
-
) => Promise<WaitForFundOperationResult>;
|
|
240
|
-
}
|
|
241
|
-
: EmptyObject) &
|
|
242
213
|
// Conditionally include quoteSwap
|
|
243
214
|
(Network extends QuoteSwapNetworks
|
|
244
215
|
? {
|
|
245
216
|
quoteSwap: (
|
|
246
|
-
options:
|
|
217
|
+
options: DistributedOmit<SmartAccountQuoteSwapOptions, "network">,
|
|
247
218
|
) => Promise<SmartAccountQuoteSwapResult>;
|
|
248
219
|
}
|
|
249
220
|
: EmptyObject) &
|
|
@@ -314,21 +285,6 @@ export type NetworkSpecificAccountActions<Network extends string> = Prettify<
|
|
|
314
285
|
) => Promise<RequestFaucetResult>;
|
|
315
286
|
}
|
|
316
287
|
: EmptyObject) &
|
|
317
|
-
// Conditionally include quoteFund
|
|
318
|
-
(Network extends QuoteFundNetworks
|
|
319
|
-
? {
|
|
320
|
-
quoteFund: (options: Omit<EvmQuoteFundOptions, "address">) => Promise<EvmQuote>;
|
|
321
|
-
}
|
|
322
|
-
: EmptyObject) &
|
|
323
|
-
// Conditionally include fund
|
|
324
|
-
(Network extends FundNetworks
|
|
325
|
-
? {
|
|
326
|
-
fund: (options: Omit<EvmFundOptions, "address">) => Promise<FundOperationResult>;
|
|
327
|
-
waitForFundOperationReceipt: (
|
|
328
|
-
options: WaitForFundOperationOptions,
|
|
329
|
-
) => Promise<WaitForFundOperationResult>;
|
|
330
|
-
}
|
|
331
|
-
: EmptyObject) &
|
|
332
288
|
// Conditionally include transfer
|
|
333
289
|
(Network extends TransferNetworks
|
|
334
290
|
? {
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { Account, SolanaAccount } from "./types.js";
|
|
2
|
-
import { SolanaQuote } from "../../actions/Quote.js";
|
|
3
|
-
import { SolanaFundOptions, fund } from "../../actions/solana/fund/fund.js";
|
|
4
|
-
import { SolanaQuoteFundOptions, quoteFund } from "../../actions/solana/fund/quoteFund.js";
|
|
5
2
|
import { requestFaucet } from "../../actions/solana/requestFaucet.js";
|
|
6
3
|
import { sendTransaction, SendTransactionResult } from "../../actions/solana/sendTransaction.js";
|
|
7
4
|
import { signMessage } from "../../actions/solana/signMessage.js";
|
|
8
5
|
import { signTransaction, SignTransactionResult } from "../../actions/solana/signTransaction.js";
|
|
9
6
|
import { transfer, type TransferOptions } from "../../actions/solana/transfer.js";
|
|
10
|
-
import { FundOperationResult } from "../../actions/types.js";
|
|
11
|
-
import {
|
|
12
|
-
WaitForFundOperationOptions,
|
|
13
|
-
WaitForFundOperationResult,
|
|
14
|
-
waitForFundOperationReceipt,
|
|
15
|
-
} from "../../actions/waitForFundOperationReceipt.js";
|
|
16
7
|
import { Analytics } from "../../analytics.js";
|
|
17
8
|
import {
|
|
18
9
|
RequestFaucetOptions,
|
|
@@ -108,38 +99,6 @@ export function toSolanaAccount(
|
|
|
108
99
|
from: account.address,
|
|
109
100
|
});
|
|
110
101
|
},
|
|
111
|
-
async quoteFund(options: Omit<SolanaQuoteFundOptions, "address">): Promise<SolanaQuote> {
|
|
112
|
-
Analytics.trackAction({
|
|
113
|
-
action: "quote_fund",
|
|
114
|
-
accountType: "solana",
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return quoteFund(apiClient, {
|
|
118
|
-
...options,
|
|
119
|
-
address: account.address,
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
async fund(options: Omit<SolanaFundOptions, "address">): Promise<FundOperationResult> {
|
|
123
|
-
Analytics.trackAction({
|
|
124
|
-
action: "fund",
|
|
125
|
-
accountType: "solana",
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return fund(apiClient, {
|
|
129
|
-
...options,
|
|
130
|
-
address: account.address,
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
async waitForFundOperationReceipt(
|
|
134
|
-
options: WaitForFundOperationOptions,
|
|
135
|
-
): Promise<WaitForFundOperationResult> {
|
|
136
|
-
Analytics.trackAction({
|
|
137
|
-
action: "wait_for_fund_operation_receipt",
|
|
138
|
-
accountType: "solana",
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
return waitForFundOperationReceipt(apiClient, options);
|
|
142
|
-
},
|
|
143
102
|
};
|
|
144
103
|
|
|
145
104
|
return account;
|
|
@@ -63,6 +63,18 @@ export type SendUserOperationReturnType = {
|
|
|
63
63
|
userOpHash: Hex;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Return type for the prepareAndSendUserOperation function.
|
|
68
|
+
*/
|
|
69
|
+
export type PrepareAndSendUserOperationReturnType = {
|
|
70
|
+
/** The address of the smart wallet. */
|
|
71
|
+
smartAccountAddress: Address;
|
|
72
|
+
/** The status of the user operation. */
|
|
73
|
+
status: typeof EvmUserOperationStatus.broadcast;
|
|
74
|
+
/** The hash of the user operation. This is not the transaction hash which is only available after the operation is completed.*/
|
|
75
|
+
userOpHash: Hex;
|
|
76
|
+
};
|
|
77
|
+
|
|
66
78
|
/**
|
|
67
79
|
* Sends a user operation to the network.
|
|
68
80
|
*
|
|
@@ -132,6 +144,7 @@ export async function sendUserOperation<T extends readonly unknown[]>(
|
|
|
132
144
|
args: call.args,
|
|
133
145
|
}),
|
|
134
146
|
value,
|
|
147
|
+
overrideGasLimit: call.overrideGasLimit,
|
|
135
148
|
};
|
|
136
149
|
}
|
|
137
150
|
|
|
@@ -139,6 +152,7 @@ export async function sendUserOperation<T extends readonly unknown[]>(
|
|
|
139
152
|
to: call.to,
|
|
140
153
|
data: call.data ?? "0x",
|
|
141
154
|
value,
|
|
155
|
+
overrideGasLimit: call.overrideGasLimit,
|
|
142
156
|
};
|
|
143
157
|
});
|
|
144
158
|
|
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/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
|
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
|
*
|