@coinbase/cdp-sdk 1.28.0 → 1.30.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 +16 -0
- package/_cjs/accounts/evm/networkCapabilities.js +101 -0
- package/_cjs/accounts/evm/networkCapabilities.js.map +1 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js +12 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +12 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +11 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +41 -1
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/Quote.js +106 -0
- package/_cjs/actions/Quote.js.map +1 -0
- package/_cjs/actions/evm/fund/fund.js +5 -5
- package/_cjs/actions/evm/fund/fund.js.map +1 -1
- package/_cjs/actions/evm/fund/quoteFund.js +7 -7
- package/_cjs/actions/evm/fund/quoteFund.js.map +1 -1
- package/_cjs/actions/evm/getUserOperation.js +1 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -1
- package/_cjs/actions/evm/spend-permissions/account.use.js +33 -0
- package/_cjs/actions/evm/spend-permissions/account.use.js.map +1 -0
- package/_cjs/actions/evm/spend-permissions/smartAccount.use.js +35 -0
- package/_cjs/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
- package/_cjs/actions/evm/spend-permissions/types.js.map +1 -0
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +1 -0
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/solana/fund/fund.js +50 -0
- package/_cjs/actions/solana/fund/fund.js.map +1 -0
- package/_cjs/actions/solana/fund/quoteFund.js +47 -0
- package/_cjs/actions/solana/fund/quoteFund.js.map +1 -0
- package/_cjs/actions/solana/sendTransaction.js +1 -0
- package/_cjs/actions/solana/sendTransaction.js.map +1 -1
- package/_cjs/actions/solana/signTransaction.js +1 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -1
- package/_cjs/actions/types.js +3 -0
- package/{_esm/actions/evm/fund → _cjs/actions}/types.js.map +1 -1
- package/_cjs/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
- package/_cjs/actions/waitForFundOperationReceipt.js.map +1 -0
- package/_cjs/auth/hooks/axios/withAuth.js +3 -0
- package/_cjs/auth/hooks/axios/withAuth.js.map +1 -1
- package/_cjs/auth/utils/http.js +2 -1
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/client/evm/evm.js +51 -1
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +54 -7
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.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/evm-smart-accounts/evm-smart-accounts.msw.js +76 -4
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +2 -0
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js +30 -0
- package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -0
- package/_cjs/openapi-client/generated/onramp/onramp.msw.js +98 -0
- package/_cjs/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js +15 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +69 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +2 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/spend-permissions/constants.js +716 -0
- package/_cjs/spend-permissions/constants.js.map +1 -0
- package/_cjs/spend-permissions/types.js +3 -0
- package/_cjs/{actions/evm/fund → spend-permissions}/types.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/networkCapabilities.js +101 -0
- package/_esm/accounts/evm/networkCapabilities.js.map +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +12 -1
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +12 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +11 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +41 -1
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/Quote.js +101 -0
- package/_esm/actions/Quote.js.map +1 -0
- package/_esm/actions/evm/fund/fund.js +5 -5
- package/_esm/actions/evm/fund/fund.js.map +1 -1
- package/_esm/actions/evm/fund/quoteFund.js +7 -7
- package/_esm/actions/evm/fund/quoteFund.js.map +1 -1
- package/_esm/actions/evm/getUserOperation.js +1 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -1
- package/_esm/actions/evm/spend-permissions/account.use.js +30 -0
- package/_esm/actions/evm/spend-permissions/account.use.js.map +1 -0
- package/_esm/actions/evm/spend-permissions/smartAccount.use.js +32 -0
- package/_esm/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
- package/_esm/actions/evm/spend-permissions/types.js.map +1 -0
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +1 -0
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/solana/fund/fund.js +47 -0
- package/_esm/actions/solana/fund/fund.js.map +1 -0
- package/_esm/actions/solana/fund/quoteFund.js +44 -0
- package/_esm/actions/solana/fund/quoteFund.js.map +1 -0
- package/_esm/actions/solana/sendTransaction.js +1 -0
- package/_esm/actions/solana/sendTransaction.js.map +1 -1
- package/_esm/actions/solana/signTransaction.js +1 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -1
- package/_esm/actions/types.js +2 -0
- package/_esm/actions/types.js.map +1 -0
- package/_esm/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
- package/_esm/actions/waitForFundOperationReceipt.js.map +1 -0
- package/_esm/auth/hooks/axios/withAuth.js +3 -0
- package/_esm/auth/hooks/axios/withAuth.js.map +1 -1
- package/_esm/auth/utils/http.js +2 -1
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/client/evm/evm.js +51 -1
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +2 -2
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +2 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +52 -5
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.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/evm-smart-accounts/evm-smart-accounts.msw.js +73 -3
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +2 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/onramp/onramp.js +25 -0
- package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -0
- package/_esm/openapi-client/generated/onramp/onramp.msw.js +90 -0
- package/_esm/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js +11 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +63 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +2 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/spend-permissions/constants.js +713 -0
- package/_esm/spend-permissions/constants.js.map +1 -0
- package/_esm/spend-permissions/types.js +2 -0
- package/_esm/spend-permissions/types.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/networkCapabilities.d.ts +101 -0
- package/_types/accounts/evm/networkCapabilities.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +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 +15 -9
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/Quote.d.ts +97 -0
- package/_types/actions/Quote.d.ts.map +1 -0
- package/_types/actions/evm/fund/fund.d.ts +3 -7
- package/_types/actions/evm/fund/fund.d.ts.map +1 -1
- package/_types/actions/evm/fund/quoteFund.d.ts +4 -7
- package/_types/actions/evm/fund/quoteFund.d.ts.map +1 -1
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/spend-permissions/account.use.d.ts +15 -0
- package/_types/actions/evm/spend-permissions/account.use.d.ts.map +1 -0
- package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts +15 -0
- package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts.map +1 -0
- package/_types/actions/evm/spend-permissions/types.d.ts +13 -0
- package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -0
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +82 -7
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/fund/fund.d.ts +19 -0
- package/_types/actions/solana/fund/fund.d.ts.map +1 -0
- package/_types/actions/solana/fund/quoteFund.d.ts +20 -0
- package/_types/actions/solana/fund/quoteFund.d.ts.map +1 -0
- package/_types/actions/solana/sendTransaction.d.ts +8 -2
- package/_types/actions/solana/sendTransaction.d.ts.map +1 -1
- package/_types/actions/solana/signTransaction.d.ts +8 -2
- package/_types/actions/solana/signTransaction.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +99 -3
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/types.d.ts +37 -0
- package/_types/actions/types.d.ts.map +1 -0
- package/_types/actions/{evm/fund/waitForFundOperationReceipt.d.ts → waitForFundOperationReceipt.d.ts} +2 -2
- package/_types/actions/waitForFundOperationReceipt.d.ts.map +1 -0
- package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +19 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +29 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +5 -3
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +356 -20
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.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/evm-smart-accounts/evm-smart-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +2 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +28 -0
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -0
- package/_types/openapi-client/generated/onramp/onramp.msw.d.ts +8 -0
- package/_types/openapi-client/generated/onramp/onramp.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +20 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts +6 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +4 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/spend-permissions/constants.d.ts +1357 -0
- package/_types/spend-permissions/constants.d.ts.map +1 -0
- package/_types/spend-permissions/types.d.ts +30 -0
- package/_types/spend-permissions/types.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/accounts/evm/networkCapabilities.ts +101 -0
- package/accounts/evm/toEvmServerAccount.ts +26 -11
- package/accounts/evm/toEvmSmartAccount.ts +30 -15
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +20 -5
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +21 -6
- package/accounts/evm/types.ts +34 -12
- package/accounts/solana/toSolanaAccount.ts +58 -3
- package/actions/Quote.ts +154 -0
- package/actions/evm/fund/fund.ts +10 -14
- package/actions/evm/fund/quoteFund.ts +13 -16
- package/actions/evm/getUserOperation.ts +1 -0
- package/actions/evm/spend-permissions/account.use.ts +48 -0
- package/actions/evm/spend-permissions/smartAccount.use.ts +49 -0
- package/actions/evm/spend-permissions/types.ts +13 -0
- package/actions/evm/transfer/accountTransferStrategy.ts +2 -0
- package/actions/evm/types.ts +88 -7
- package/actions/solana/fund/fund.ts +71 -0
- package/actions/solana/fund/quoteFund.ts +77 -0
- package/actions/solana/sendTransaction.ts +10 -2
- package/actions/solana/signTransaction.ts +10 -2
- package/actions/solana/types.ts +113 -2
- package/actions/types.ts +39 -0
- package/actions/{evm/fund/waitForFundOperationReceipt.ts → waitForFundOperationReceipt.ts} +2 -2
- package/auth/hooks/axios/withAuth.ts +3 -0
- package/auth/utils/http.ts +2 -1
- package/client/evm/evm.ts +61 -1
- package/client/evm/evm.types.ts +31 -0
- package/client/solana/solana.ts +10 -5
- package/index.ts +6 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +400 -26
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +89 -3
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
- package/openapi-client/generated/index.msw.ts +2 -0
- package/openapi-client/generated/onramp/onramp.msw.ts +135 -0
- package/openapi-client/generated/onramp/onramp.ts +54 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.msw.ts +85 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +34 -0
- package/openapi-client/index.ts +2 -0
- package/package.json +1 -1
- package/spend-permissions/constants.ts +713 -0
- package/spend-permissions/types.ts +42 -0
- package/version.ts +1 -1
- package/_cjs/actions/evm/fund/Quote.js +0 -63
- package/_cjs/actions/evm/fund/Quote.js.map +0 -1
- package/_cjs/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
- package/_esm/actions/evm/fund/Quote.js +0 -59
- package/_esm/actions/evm/fund/Quote.js.map +0 -1
- package/_esm/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
- package/_types/actions/evm/fund/Quote.d.ts +0 -51
- package/_types/actions/evm/fund/Quote.d.ts.map +0 -1
- package/_types/actions/evm/fund/types.d.ts +0 -16
- package/_types/actions/evm/fund/types.d.ts.map +0 -1
- package/_types/actions/evm/fund/waitForFundOperationReceipt.d.ts.map +0 -1
- package/actions/evm/fund/Quote.ts +0 -83
- package/actions/evm/fund/types.ts +0 -16
- /package/_cjs/actions/evm/{fund → spend-permissions}/types.js +0 -0
- /package/_esm/actions/evm/{fund → spend-permissions}/types.js +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { formatUnits } from "viem";
|
|
2
|
+
|
|
3
|
+
import { UserInputValidationError } from "../../../errors.js";
|
|
4
|
+
import {
|
|
5
|
+
CreatePaymentTransferQuoteBodySourceType,
|
|
6
|
+
CreatePaymentTransferQuoteBodyTargetType,
|
|
7
|
+
type CdpOpenApiClientType,
|
|
8
|
+
} from "../../../openapi-client/index.js";
|
|
9
|
+
import { BaseFundOptions, FundOperationResult } from "../../types.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for funding a Solana account.
|
|
13
|
+
*/
|
|
14
|
+
export interface SolanaFundOptions extends BaseFundOptions {
|
|
15
|
+
/** The token to request funds for. */
|
|
16
|
+
token: "sol" | "usdc";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Funds a Solana account.
|
|
21
|
+
*
|
|
22
|
+
* @param apiClient - The API client.
|
|
23
|
+
* @param options - The options for funding a Solana account.
|
|
24
|
+
*
|
|
25
|
+
* @returns A promise that resolves to the fund operation result.
|
|
26
|
+
*/
|
|
27
|
+
export async function fund(
|
|
28
|
+
apiClient: CdpOpenApiClientType,
|
|
29
|
+
options: SolanaFundOptions,
|
|
30
|
+
): Promise<FundOperationResult> {
|
|
31
|
+
if (options.token !== "sol" && options.token !== "usdc") {
|
|
32
|
+
throw new UserInputValidationError("Invalid token, must be sol or usdc");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const decimals = options.token === "sol" ? 9 : 6;
|
|
36
|
+
const amount = formatUnits(options.amount, decimals);
|
|
37
|
+
|
|
38
|
+
const paymentMethods = await apiClient.getPaymentMethods();
|
|
39
|
+
const cardPaymentMethod = paymentMethods.find(
|
|
40
|
+
method => method.type === "card" && method.actions.includes("source"),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!cardPaymentMethod) {
|
|
44
|
+
throw new Error("No card found to fund account");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const response = await apiClient.createPaymentTransferQuote({
|
|
48
|
+
sourceType: CreatePaymentTransferQuoteBodySourceType.payment_method,
|
|
49
|
+
source: {
|
|
50
|
+
id: cardPaymentMethod.id,
|
|
51
|
+
},
|
|
52
|
+
targetType: CreatePaymentTransferQuoteBodyTargetType.crypto_rail,
|
|
53
|
+
target: {
|
|
54
|
+
currency: options.token,
|
|
55
|
+
network: "solana",
|
|
56
|
+
address: options.address,
|
|
57
|
+
},
|
|
58
|
+
amount,
|
|
59
|
+
currency: options.token,
|
|
60
|
+
execute: true,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
id: response.transfer.id,
|
|
65
|
+
network: response.transfer.target.network,
|
|
66
|
+
status: response.transfer.status,
|
|
67
|
+
targetAmount: response.transfer.targetAmount,
|
|
68
|
+
targetCurrency: response.transfer.targetCurrency,
|
|
69
|
+
transactionHash: response.transfer.transactionHash,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { formatUnits } from "viem";
|
|
2
|
+
|
|
3
|
+
import { UserInputValidationError } from "../../../errors.js";
|
|
4
|
+
import {
|
|
5
|
+
CdpOpenApiClientType,
|
|
6
|
+
CreatePaymentTransferQuoteBodySourceType,
|
|
7
|
+
CreatePaymentTransferQuoteBodyTargetType,
|
|
8
|
+
} from "../../../openapi-client/index.js";
|
|
9
|
+
import { SolanaQuote } from "../../Quote.js";
|
|
10
|
+
import { BaseQuoteFundOptions } from "../../types.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for getting a quote to fund a Solana account.
|
|
14
|
+
*/
|
|
15
|
+
export interface SolanaQuoteFundOptions extends BaseQuoteFundOptions {
|
|
16
|
+
/** The token to request funds for. */
|
|
17
|
+
token: "sol" | "usdc";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Gets a quote to fund a Solana account.
|
|
22
|
+
*
|
|
23
|
+
* @param apiClient - The API client.
|
|
24
|
+
* @param options - The options for getting a quote to fund a Solana account.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves to the quote.
|
|
27
|
+
*/
|
|
28
|
+
export async function quoteFund(
|
|
29
|
+
apiClient: CdpOpenApiClientType,
|
|
30
|
+
options: SolanaQuoteFundOptions,
|
|
31
|
+
): Promise<SolanaQuote> {
|
|
32
|
+
if (options.token !== "sol" && options.token !== "usdc") {
|
|
33
|
+
throw new UserInputValidationError("Invalid token, must be sol or usdc");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const decimals = options.token === "sol" ? 9 : 6;
|
|
37
|
+
const amount = formatUnits(options.amount, decimals);
|
|
38
|
+
|
|
39
|
+
const paymentMethods = await apiClient.getPaymentMethods();
|
|
40
|
+
const cardPaymentMethod = paymentMethods.find(
|
|
41
|
+
method => method.type === "card" && method.actions.includes("source"),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (!cardPaymentMethod) {
|
|
45
|
+
throw new Error("No card found to fund account");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const response = await apiClient.createPaymentTransferQuote({
|
|
49
|
+
sourceType: CreatePaymentTransferQuoteBodySourceType.payment_method,
|
|
50
|
+
source: {
|
|
51
|
+
id: cardPaymentMethod.id,
|
|
52
|
+
},
|
|
53
|
+
targetType: CreatePaymentTransferQuoteBodyTargetType.crypto_rail,
|
|
54
|
+
target: {
|
|
55
|
+
currency: options.token,
|
|
56
|
+
network: "solana",
|
|
57
|
+
address: options.address,
|
|
58
|
+
},
|
|
59
|
+
amount,
|
|
60
|
+
currency: options.token,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return new SolanaQuote(
|
|
64
|
+
apiClient,
|
|
65
|
+
response.transfer.id,
|
|
66
|
+
"solana",
|
|
67
|
+
response.transfer.sourceAmount,
|
|
68
|
+
response.transfer.sourceCurrency,
|
|
69
|
+
response.transfer.targetAmount,
|
|
70
|
+
response.transfer.targetCurrency,
|
|
71
|
+
response.transfer.fees.map(fee => ({
|
|
72
|
+
type: fee.type,
|
|
73
|
+
amount: fee.amount,
|
|
74
|
+
currency: fee.currency,
|
|
75
|
+
})),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { SendTransactionOptions
|
|
1
|
+
import { SendTransactionOptions } from "../../client/solana/solana.types.js";
|
|
2
2
|
import { CdpOpenApiClientType } from "../../openapi-client/index.js";
|
|
3
3
|
|
|
4
|
+
export interface SendTransactionResult {
|
|
5
|
+
/** The signature of the transaction base58 encoded. */
|
|
6
|
+
transactionSignature: string;
|
|
7
|
+
/** @deprecated Use transactionSignature instead. */
|
|
8
|
+
signature: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Sends a Solana transaction using the Coinbase API.
|
|
6
13
|
*
|
|
@@ -23,7 +30,7 @@ import { CdpOpenApiClientType } from "../../openapi-client/index.js";
|
|
|
23
30
|
export async function sendTransaction(
|
|
24
31
|
apiClient: CdpOpenApiClientType,
|
|
25
32
|
options: SendTransactionOptions,
|
|
26
|
-
): Promise<
|
|
33
|
+
): Promise<SendTransactionResult> {
|
|
27
34
|
const signature = await apiClient.sendSolanaTransaction(
|
|
28
35
|
{
|
|
29
36
|
network: options.network,
|
|
@@ -33,6 +40,7 @@ export async function sendTransaction(
|
|
|
33
40
|
);
|
|
34
41
|
|
|
35
42
|
return {
|
|
43
|
+
transactionSignature: signature.transactionSignature,
|
|
36
44
|
signature: signature.transactionSignature,
|
|
37
45
|
};
|
|
38
46
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { SignTransactionOptions
|
|
1
|
+
import { SignTransactionOptions } from "../../client/solana/solana.types.js";
|
|
2
2
|
import { CdpOpenApiClientType } from "../../openapi-client/index.js";
|
|
3
3
|
|
|
4
|
+
export interface SignTransactionResult {
|
|
5
|
+
/** The signature of the transaction base58 encoded. */
|
|
6
|
+
signedTransaction: string;
|
|
7
|
+
/** @deprecated Use signedTransaction instead. */
|
|
8
|
+
signature: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Signs a transaction.
|
|
6
13
|
*
|
|
@@ -38,7 +45,7 @@ import { CdpOpenApiClientType } from "../../openapi-client/index.js";
|
|
|
38
45
|
export async function signTransaction(
|
|
39
46
|
apiClient: CdpOpenApiClientType,
|
|
40
47
|
options: SignTransactionOptions,
|
|
41
|
-
): Promise<
|
|
48
|
+
): Promise<SignTransactionResult> {
|
|
42
49
|
const signature = await apiClient.signSolanaTransaction(
|
|
43
50
|
options.address,
|
|
44
51
|
{
|
|
@@ -48,6 +55,7 @@ export async function signTransaction(
|
|
|
48
55
|
);
|
|
49
56
|
|
|
50
57
|
return {
|
|
58
|
+
signedTransaction: signature.signedTransaction,
|
|
51
59
|
signature: signature.signedTransaction,
|
|
52
60
|
};
|
|
53
61
|
}
|
package/actions/solana/types.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { TransferOptions } from "./transfer.js";
|
|
2
2
|
import {
|
|
3
3
|
RequestFaucetOptions,
|
|
4
|
+
SendTransactionOptions,
|
|
4
5
|
SignatureResult,
|
|
5
6
|
SignMessageOptions,
|
|
6
7
|
SignTransactionOptions,
|
|
7
8
|
} from "../../client/solana/solana.types.js";
|
|
9
|
+
import { SolanaQuote } from "../Quote.js";
|
|
10
|
+
import { FundOperationResult } from "../types.js";
|
|
11
|
+
import {
|
|
12
|
+
WaitForFundOperationOptions,
|
|
13
|
+
WaitForFundOperationResult,
|
|
14
|
+
} from "../waitForFundOperationReceipt.js";
|
|
15
|
+
import { SolanaFundOptions } from "./fund/fund.js";
|
|
16
|
+
import { SolanaQuoteFundOptions } from "./fund/quoteFund.js";
|
|
17
|
+
import { SendTransactionResult } from "./sendTransaction.js";
|
|
18
|
+
|
|
19
|
+
import type { SignTransactionResult } from "./signTransaction.js";
|
|
8
20
|
|
|
9
21
|
export type AccountActions = {
|
|
10
22
|
/**
|
|
@@ -79,12 +91,50 @@ export type AccountActions = {
|
|
|
79
91
|
* const transaction = Buffer.from(serializedTransaction).toString("base64");
|
|
80
92
|
*
|
|
81
93
|
* // When you want to sign a transaction, you can do so by address and base64 encoded transaction
|
|
82
|
-
* const {
|
|
94
|
+
* const { signedTransaction } = await account.signTransaction({
|
|
95
|
+
* transaction,
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
signTransaction: (
|
|
100
|
+
options: Omit<SignTransactionOptions, "address">,
|
|
101
|
+
) => Promise<SignTransactionResult>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Sends a transaction.
|
|
105
|
+
*
|
|
106
|
+
* @param {SendTransactionOptions} options - Parameters for sending the transaction.
|
|
107
|
+
* @param {string} options.address - The address to send the transaction for.
|
|
108
|
+
* @param {string} options.transaction - The transaction to send.
|
|
109
|
+
* @param {string} [options.idempotencyKey] - An idempotency key.
|
|
110
|
+
*
|
|
111
|
+
* @returns A promise that resolves to the transaction signature.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* // Create a Solana account
|
|
116
|
+
* const account = await cdp.solana.createAccount();
|
|
117
|
+
*
|
|
118
|
+
* // Add your transaction instructions here
|
|
119
|
+
* const transaction = new Transaction()
|
|
120
|
+
*
|
|
121
|
+
* // Make sure to set requireAllSignatures to false, since signing will be done through the API
|
|
122
|
+
* const serializedTransaction = transaction.serialize({
|
|
123
|
+
* requireAllSignatures: false,
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* // Base64 encode the serialized transaction
|
|
127
|
+
* const transaction = Buffer.from(serializedTransaction).toString("base64");
|
|
128
|
+
*
|
|
129
|
+
* // When you want to sign a transaction, you can do so by address and base64 encoded transaction
|
|
130
|
+
* const { transactionSignature } = await account.sendTransaction({
|
|
83
131
|
* transaction,
|
|
84
132
|
* });
|
|
85
133
|
* ```
|
|
86
134
|
*/
|
|
87
|
-
|
|
135
|
+
sendTransaction: (
|
|
136
|
+
options: Omit<SendTransactionOptions, "address">,
|
|
137
|
+
) => Promise<SendTransactionResult>;
|
|
88
138
|
|
|
89
139
|
/**
|
|
90
140
|
* Transfers SOL or SPL tokens between accounts
|
|
@@ -112,4 +162,65 @@ export type AccountActions = {
|
|
|
112
162
|
* ```
|
|
113
163
|
*/
|
|
114
164
|
transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Gets a quote to fund a Solana account.
|
|
168
|
+
*
|
|
169
|
+
* @param options - The options for the quote fund.
|
|
170
|
+
* @param options.token - The token to fund the account with.
|
|
171
|
+
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
172
|
+
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
173
|
+
* Otherwise, you can pass atomic units directly.
|
|
174
|
+
*
|
|
175
|
+
* @returns A promise that resolves to a Quote object containing details about the funding operation.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const quote = await account.quoteFund({
|
|
180
|
+
* token: "usdc",
|
|
181
|
+
* amount: 1000000n,
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
quoteFund: (options: Omit<SolanaQuoteFundOptions, "address">) => Promise<SolanaQuote>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Funds a Solana account with the specified token amount.
|
|
189
|
+
*
|
|
190
|
+
* @param options - The options for the fund operation.
|
|
191
|
+
* @param options.token - The token to fund the account with (e.g., 'usdc').
|
|
192
|
+
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
193
|
+
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
194
|
+
* Otherwise, you can pass atomic units directly.
|
|
195
|
+
*
|
|
196
|
+
* @returns A promise that resolves to the fund operation result containing the transfer details.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const fundOperation = await account.fund({
|
|
201
|
+
* token: "usdc",
|
|
202
|
+
* amount: 1000000n,
|
|
203
|
+
* });
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
fund: (options: Omit<SolanaFundOptions, "address">) => Promise<FundOperationResult>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Waits for a fund operation to complete and returns the transfer receipt.
|
|
210
|
+
*
|
|
211
|
+
* @param options - The options for the wait for fund operation.
|
|
212
|
+
* @param options.transferId - The ID of the transfer to wait for.
|
|
213
|
+
*
|
|
214
|
+
* @returns A promise that resolves to the completed transfer receipt containing details about the funding operation.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* const completedTransfer = await account.waitForFundOperationReceipt({
|
|
219
|
+
* transferId: "transfer_123",
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
waitForFundOperationReceipt(
|
|
224
|
+
options: WaitForFundOperationOptions,
|
|
225
|
+
): Promise<WaitForFundOperationResult>;
|
|
115
226
|
};
|
package/actions/types.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TransferStatus } from "../openapi-client/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base options for getting a quote to fund an account.
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseQuoteFundOptions {
|
|
7
|
+
/** The address of the account. */
|
|
8
|
+
address: string;
|
|
9
|
+
/** The amount to fund the account with, in atomic units (e.g. wei for ETH, lamports for SOL) of the token. */
|
|
10
|
+
amount: bigint;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base options for funding an account.
|
|
15
|
+
*/
|
|
16
|
+
export interface BaseFundOptions {
|
|
17
|
+
/** The address of the account. */
|
|
18
|
+
address: string;
|
|
19
|
+
/** The amount to fund the account with, in atomic units (e.g. wei for ETH, lamports for SOL) of the token. */
|
|
20
|
+
amount: bigint;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The result of a fund operation.
|
|
25
|
+
*/
|
|
26
|
+
export type FundOperationResult = {
|
|
27
|
+
/** The transfer that was created to fund the account. */
|
|
28
|
+
id: string;
|
|
29
|
+
/** The network that the transfer was created on. */
|
|
30
|
+
network: string;
|
|
31
|
+
/** The target amount that will be received. */
|
|
32
|
+
targetAmount: string;
|
|
33
|
+
/** The currency that will be received. */
|
|
34
|
+
targetCurrency: string;
|
|
35
|
+
/** The status of the fund operation. */
|
|
36
|
+
status: TransferStatus;
|
|
37
|
+
/** The transaction hash of the transfer. */
|
|
38
|
+
transactionHash?: string;
|
|
39
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CdpOpenApiClientType, Transfer, TransferStatus } from "
|
|
2
|
-
import { wait, WaitOptions } from "
|
|
1
|
+
import { CdpOpenApiClientType, Transfer, TransferStatus } from "../openapi-client/index.js";
|
|
2
|
+
import { wait, WaitOptions } from "../utils/wait.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for waiting for a fund operation.
|
|
@@ -84,6 +84,7 @@ export function withAuth(axiosClient: AxiosInstance, options: AuthInterceptorOpt
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
if (options.debug) {
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
87
88
|
console.log("Request:", {
|
|
88
89
|
method,
|
|
89
90
|
url: fullyQualifiedURL,
|
|
@@ -98,6 +99,7 @@ export function withAuth(axiosClient: AxiosInstance, options: AuthInterceptorOpt
|
|
|
98
99
|
if (options.debug) {
|
|
99
100
|
axiosClient.interceptors.response.use(
|
|
100
101
|
response => {
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
101
103
|
console.log("Response:", {
|
|
102
104
|
status: response.status,
|
|
103
105
|
statusText: response.statusText,
|
|
@@ -117,6 +119,7 @@ export function withAuth(axiosClient: AxiosInstance, options: AuthInterceptorOpt
|
|
|
117
119
|
cause: error.cause,
|
|
118
120
|
};
|
|
119
121
|
|
|
122
|
+
// eslint-disable-next-line no-console
|
|
120
123
|
console.error("Response Error:", errorDetails);
|
|
121
124
|
return Promise.reject(error);
|
|
122
125
|
},
|
package/auth/utils/http.ts
CHANGED
|
@@ -126,7 +126,8 @@ export async function getAuthHeaders(
|
|
|
126
126
|
*/
|
|
127
127
|
function requiresWalletAuth(requestMethod: string, requestPath: string): boolean {
|
|
128
128
|
return (
|
|
129
|
-
requestPath?.includes("/accounts")
|
|
129
|
+
(requestPath?.includes("/accounts") || requestPath?.includes("/spend-permissions")) &&
|
|
130
|
+
(requestMethod === "POST" || requestMethod === "DELETE" || requestMethod === "PUT")
|
|
130
131
|
);
|
|
131
132
|
}
|
|
132
133
|
|
package/client/evm/evm.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type Address, getTypesForEIP712Domain } from "viem";
|
|
|
5
5
|
import {
|
|
6
6
|
CreateServerAccountOptions,
|
|
7
7
|
CreateSmartAccountOptions,
|
|
8
|
+
CreateSpendPermissionOptions,
|
|
8
9
|
CreateSwapQuoteOptions,
|
|
9
10
|
CreateSwapQuoteResult,
|
|
10
11
|
EvmClientInterface,
|
|
@@ -68,6 +69,7 @@ import {
|
|
|
68
69
|
CdpOpenApiClient,
|
|
69
70
|
EIP712Message as OpenAPIEIP712Message,
|
|
70
71
|
} from "../../openapi-client/index.js";
|
|
72
|
+
import { SPEND_PERMISSION_MANAGER_ADDRESS } from "../../spend-permissions/constants.js";
|
|
71
73
|
import { Hex } from "../../types/misc.js";
|
|
72
74
|
import { decryptWithPrivateKey, generateExportEncryptionKeyPair } from "../../utils/export.js";
|
|
73
75
|
|
|
@@ -341,9 +343,15 @@ export class EvmClient implements EvmClientInterface {
|
|
|
341
343
|
accountType: "evm_smart",
|
|
342
344
|
});
|
|
343
345
|
|
|
346
|
+
const owners = [options.owner.address];
|
|
347
|
+
|
|
348
|
+
if (options.__experimental_enableSpendPermission) {
|
|
349
|
+
owners.push(SPEND_PERMISSION_MANAGER_ADDRESS);
|
|
350
|
+
}
|
|
351
|
+
|
|
344
352
|
const openApiSmartAccount = await CdpOpenApiClient.createEvmSmartAccount(
|
|
345
353
|
{
|
|
346
|
-
owners:
|
|
354
|
+
owners: owners,
|
|
347
355
|
name: options.name,
|
|
348
356
|
},
|
|
349
357
|
options.idempotencyKey,
|
|
@@ -359,6 +367,58 @@ export class EvmClient implements EvmClientInterface {
|
|
|
359
367
|
return smartAccount;
|
|
360
368
|
}
|
|
361
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Creates a spend permission for a smart account.
|
|
372
|
+
*
|
|
373
|
+
* @param {CreateSpendPermissionOptions} options - Parameters for creating the spend permission.
|
|
374
|
+
* @param {SpendPermission} options.spendPermission - The spend permission to create.
|
|
375
|
+
* @param {string} [options.idempotencyKey] - The idempotency key to use for the spend permission.
|
|
376
|
+
*
|
|
377
|
+
* @returns A promise that resolves to the spend permission.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* const userOperation = await cdp.evm.createSpendPermission({
|
|
382
|
+
* spendPermission,
|
|
383
|
+
* network: "base-sepolia",
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
async createSpendPermission(options: CreateSpendPermissionOptions): Promise<UserOperation> {
|
|
388
|
+
Analytics.trackAction({
|
|
389
|
+
action: "create_spend_permission",
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const userOperation = await CdpOpenApiClient.createSpendPermission(
|
|
393
|
+
options.spendPermission.account,
|
|
394
|
+
{
|
|
395
|
+
account: options.spendPermission.account,
|
|
396
|
+
spender: options.spendPermission.spender,
|
|
397
|
+
token: options.spendPermission.token,
|
|
398
|
+
allowance: options.spendPermission.allowance.toString(),
|
|
399
|
+
period: options.spendPermission.period.toString(),
|
|
400
|
+
start: options.spendPermission.start.toString(),
|
|
401
|
+
end: options.spendPermission.end.toString(),
|
|
402
|
+
salt: options.spendPermission.salt.toString(),
|
|
403
|
+
extraData: options.spendPermission.extraData,
|
|
404
|
+
network: options.network,
|
|
405
|
+
paymasterUrl: options.paymasterUrl,
|
|
406
|
+
},
|
|
407
|
+
options.idempotencyKey,
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
network: userOperation.network,
|
|
412
|
+
userOpHash: userOperation.userOpHash as Hex,
|
|
413
|
+
status: userOperation.status,
|
|
414
|
+
calls: userOperation.calls.map(call => ({
|
|
415
|
+
to: call.to as Address,
|
|
416
|
+
value: BigInt(call.value),
|
|
417
|
+
data: call.data as Hex,
|
|
418
|
+
})),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
362
422
|
/**
|
|
363
423
|
* Gets a CDP EVM account.
|
|
364
424
|
*
|
package/client/evm/evm.types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SpendPermission } from "../../spend-permissions/types.js";
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
EvmAccount as Account,
|
|
3
5
|
EvmServerAccount as ServerAccount,
|
|
@@ -24,6 +26,7 @@ import type {
|
|
|
24
26
|
OpenApiEvmMethods,
|
|
25
27
|
UpdateEvmAccountBody as UpdateEvmAccount,
|
|
26
28
|
UpdateEvmSmartAccountBody as UpdateEvmSmartAccount,
|
|
29
|
+
UserOperationReceipt,
|
|
27
30
|
} from "../../openapi-client/index.js";
|
|
28
31
|
import type { Calls } from "../../types/calls.js";
|
|
29
32
|
import type { Address, EIP712Message, Hex } from "../../types/misc.js";
|
|
@@ -36,6 +39,7 @@ export type EvmClientInterface = Omit<
|
|
|
36
39
|
typeof OpenApiEvmMethods,
|
|
37
40
|
| "createEvmAccount" // mapped to createAccount
|
|
38
41
|
| "createEvmSmartAccount" // mapped to createSmartAccount
|
|
42
|
+
| "createSpendPermission" // mapped to createSpendPermission
|
|
39
43
|
| "importEvmAccount" // mapped to importAccount
|
|
40
44
|
| "exportEvmAccount" // mapped to exportAccount
|
|
41
45
|
| "exportEvmAccountByName" // mapped to exportAccount
|
|
@@ -256,6 +260,17 @@ export interface CreateSwapQuoteResult {
|
|
|
256
260
|
execute: (options?: ExecuteSwapQuoteOptions) => Promise<ExecuteSwapQuoteResult>;
|
|
257
261
|
}
|
|
258
262
|
|
|
263
|
+
export interface CreateSpendPermissionOptions {
|
|
264
|
+
/** The spend permission. */
|
|
265
|
+
spendPermission: SpendPermission;
|
|
266
|
+
/** The network. */
|
|
267
|
+
network: EvmUserOperationNetwork;
|
|
268
|
+
/** The paymaster URL. */
|
|
269
|
+
paymasterUrl?: string;
|
|
270
|
+
/** The idempotency key. */
|
|
271
|
+
idempotencyKey?: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
259
274
|
/**
|
|
260
275
|
* Options for getting a user operation.
|
|
261
276
|
*/
|
|
@@ -314,6 +329,10 @@ export interface UserOperation {
|
|
|
314
329
|
* The hash of the transaction that included this particular user operation. This gets set after the user operation is broadcasted and the transaction is included in a block.
|
|
315
330
|
*/
|
|
316
331
|
transactionHash?: Hex;
|
|
332
|
+
/**
|
|
333
|
+
* The receipts associated with the broadcasted user operation.
|
|
334
|
+
*/
|
|
335
|
+
receipts?: UserOperationReceipt[];
|
|
317
336
|
}
|
|
318
337
|
|
|
319
338
|
/**
|
|
@@ -392,6 +411,12 @@ export interface GetOrCreateSmartAccountOptions {
|
|
|
392
411
|
name: string;
|
|
393
412
|
/** The owner of the account. */
|
|
394
413
|
owner: Account;
|
|
414
|
+
/**
|
|
415
|
+
* @deprecated Experimental! This method name will change, and is subject to other breaking changes.
|
|
416
|
+
*
|
|
417
|
+
* The flag to enable spend permission.
|
|
418
|
+
*/
|
|
419
|
+
__experimental_enableSpendPermission?: boolean;
|
|
395
420
|
}
|
|
396
421
|
|
|
397
422
|
/**
|
|
@@ -487,6 +512,12 @@ export interface CreateSmartAccountOptions {
|
|
|
487
512
|
idempotencyKey?: string;
|
|
488
513
|
/** The name of the account. */
|
|
489
514
|
name?: string;
|
|
515
|
+
/**
|
|
516
|
+
* @deprecated Experimental! This method name will change, and is subject to other breaking changes.
|
|
517
|
+
*
|
|
518
|
+
* The flag to enable spend permission.
|
|
519
|
+
*/
|
|
520
|
+
__experimental_enableSpendPermission?: boolean;
|
|
490
521
|
}
|
|
491
522
|
|
|
492
523
|
/**
|
package/client/solana/solana.ts
CHANGED
|
@@ -18,15 +18,20 @@ import {
|
|
|
18
18
|
SignMessageOptions,
|
|
19
19
|
SignTransactionOptions,
|
|
20
20
|
SolanaClientInterface,
|
|
21
|
-
TransactionResult,
|
|
22
21
|
UpdateSolanaAccountOptions,
|
|
23
22
|
} from "./solana.types.js";
|
|
24
23
|
import { toSolanaAccount } from "../../accounts/solana/toSolanaAccount.js";
|
|
25
24
|
import { SolanaAccount } from "../../accounts/solana/types.js";
|
|
26
25
|
import { requestFaucet } from "../../actions/solana/requestFaucet.js";
|
|
27
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
sendTransaction,
|
|
28
|
+
type SendTransactionResult,
|
|
29
|
+
} from "../../actions/solana/sendTransaction.js";
|
|
28
30
|
import { signMessage } from "../../actions/solana/signMessage.js";
|
|
29
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
signTransaction,
|
|
33
|
+
type SignTransactionResult,
|
|
34
|
+
} from "../../actions/solana/signTransaction.js";
|
|
30
35
|
import { Analytics } from "../../analytics.js";
|
|
31
36
|
import { ImportAccountPublicRSAKey } from "../../constants.js";
|
|
32
37
|
import { UserInputValidationError } from "../../errors.js";
|
|
@@ -485,7 +490,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
485
490
|
* });
|
|
486
491
|
* ```
|
|
487
492
|
*/
|
|
488
|
-
async signTransaction(options: SignTransactionOptions): Promise<
|
|
493
|
+
async signTransaction(options: SignTransactionOptions): Promise<SignTransactionResult> {
|
|
489
494
|
Analytics.trackAction({
|
|
490
495
|
action: "sign_transaction",
|
|
491
496
|
accountType: "solana",
|
|
@@ -574,7 +579,7 @@ export class SolanaClient implements SolanaClientInterface {
|
|
|
574
579
|
* });
|
|
575
580
|
* ```
|
|
576
581
|
*/
|
|
577
|
-
async sendTransaction(options: SendTransactionOptions): Promise<
|
|
582
|
+
async sendTransaction(options: SendTransactionOptions): Promise<SendTransactionResult> {
|
|
578
583
|
Analytics.trackAction({
|
|
579
584
|
action: "send_transaction",
|
|
580
585
|
accountType: "solana",
|
package/index.ts
CHANGED
|
@@ -8,5 +8,10 @@ export {
|
|
|
8
8
|
type UpdatePolicyBody,
|
|
9
9
|
} from "./policies/schema.js";
|
|
10
10
|
export { NetworkError } from "./openapi-client/errors.js";
|
|
11
|
+
export type { SpendPermission } from "./spend-permissions/types.js";
|
|
12
|
+
export {
|
|
13
|
+
SPEND_PERMISSION_MANAGER_ABI as spendPermissionManagerAbi,
|
|
14
|
+
SPEND_PERMISSION_MANAGER_ADDRESS as spendPermissionManagerAddress,
|
|
15
|
+
} from "./spend-permissions/constants.js";
|
|
11
16
|
|
|
12
|
-
export { parseEther } from "viem";
|
|
17
|
+
export { parseEther, parseUnits } from "viem";
|