import { type Address as SolanaAddress, type Base64EncodedWireTransaction, createSolanaRpc } from "@solana/kit"; import { type KernelAccountClientActions, type SmartAccountClientConfig } from "@zerodev/sdk"; import { type Address, type ByteArray, type Chain, type Client, type Hex, type Prettify, type RpcSchema, type Transport } from "viem"; import { type BundlerActions, type BundlerClientConfig, type SmartAccount } from "viem/account-abstraction"; import type { EstimateUserIntentFeesParameters, EstimateUserIntentFeesResult } from "../actions/estimateUserIntentFees.js"; import type { GetCABParameters, GetCABResult } from "../actions/getCAB.js"; import type { GaslessCrossChainOrder, GetIntentParameters, GetIntentReturnType } from "../actions/getIntent.js"; import type { GetUserIntentStatusResult } from "../actions/getUserIntentStatus.js"; import type { RelayerSendUserIntentResult } from "../actions/sendUserIntent.js"; import type { GetUserIntentExecutionReceiptResult, GetUserIntentFillReceiptResult, GetUserIntentOpenReceiptResult } from "../actions/types.js"; import type { INTENT_VERSION_TYPE } from "../types/intent.js"; import { type IntentClientActions } from "./decorators/intent.js"; export type IntentRpcSchema = [ { Method: "ui_getIntent"; Parameters: [GetIntentParameters]; ReturnType: GetIntentReturnType; }, { Method: "ui_getCAB"; Parameters: [GetCABParameters]; ReturnType: GetCABResult; }, { Method: "ui_estimateIntentFees"; Parameters: [EstimateUserIntentFeesParameters]; ReturnType: EstimateUserIntentFeesResult; } ]; export type RelayerRpcSchema = [ { Method: "rl_sendUserIntent"; Parameters: [ { order: GaslessCrossChainOrder; signature: Hex; version: INTENT_VERSION_TYPE; solanaTransaction: string | undefined; } ]; ReturnType: RelayerSendUserIntentResult; }, { Method: "rl_getUserIntentStatus"; Parameters: [Hex, Address]; ReturnType: GetUserIntentStatusResult; }, { Method: "rl_getUserIntentOpenReceipt"; Parameters: [Hex, Address]; ReturnType: GetUserIntentOpenReceiptResult; }, { Method: "rl_getUserIntentExecutionReceipt"; Parameters: [Hex, Address]; ReturnType: GetUserIntentExecutionReceiptResult; }, { Method: "rl_getUserIntentFillReceipt"; Parameters: [Hex, Address]; ReturnType: GetUserIntentFillReceiptResult; } ]; export type CombinedIntentRpcSchema = [...IntentRpcSchema, ...RelayerRpcSchema]; type IntentClientExtension = { paymaster: BundlerClientConfig["paymaster"] | undefined; paymasterContext: BundlerClientConfig["paymasterContext"] | undefined; userOperation: BundlerClientConfig["userOperation"] | undefined; solana?: { rpc: ReturnType; address: SolanaAddress; signTransaction: (transaction: ByteArray) => Promise; sendTransaction: (transaction: Base64EncodedWireTransaction) => Promise; }; }; /** * A base intent client, only supporting the intent client extensions */ export type BaseIntentClient = Prettify>; /** * A fully built intent client with all the zerodev extensions applied */ export type IntentClient = Prettify & KernelAccountClientActions & IntentClientActions>>; /** * The configuration for the Intent client */ export type CreateIntentClientConfig = SmartAccountClientConfig & { bundlerTransport: transport; intentTransport?: transport; relayerTransport?: transport; projectId?: string; version: INTENT_VERSION_TYPE; solana?: { address: SolanaAddress; rpcUrl: string; signTransaction: (transaction: ByteArray) => Promise; }; }; /** * Creates an ZeroDev Intent client * @param parameters - The configuration for the Intent client * @returns An Intent client * * @example * ```ts * // Simple intent client than can send intent across any EVM chains * const client = createIntentClient({ * chain: mainnet, * account: kernelAccount, * version: INTENT_V0_3, * bundlerTransport: http(bundlerRpc), * }); * * // Intent client that can send intents across any EVM / Solana chain using the `@solana/kit` SDK * const client = createIntentClient({ * account: kernelAccount, * bundlerTransport: http(bundlerRpc), * version: INTENT_V0_3, * solana: { * rpcUrl: 'https://api.mainnet-beta.solana.com', * address: solanaSigner.address, * signTransaction: async (transaction) => { * const decoded = getTransactionDecoder().decode(transaction) * const [signatures] = await solanaSigner.signTransactions([decoded]) * const newTransaction = { * ...decoded, * signatures: Object.freeze({ * ...decoded.signatures, * ...signatures * }), * } * return getBase64EncodedWireTransaction(newTransaction); * }, * }, * }); * * // Intent client that can send intents across any EVM / Solana chain using the `@solana/web3js` SDK * // todo: Add guide around this * const client = createIntentClient({ * account: kernelAccount, * bundlerTransport: http(bundlerRpc), * version: INTENT_V0_3, * solana: { * rpcUrl: 'https://api.mainnet-beta.solana.com', * address: solanaSigner.address, * signTransaction: async (transaction) => { * const decoded = getTransactionDecoder().decode(transaction) * const [signatures] = await solanaSigner.signTransactions([decoded]) * const newTransaction = { * ...decoded, * signatures: Object.freeze({ * ...decoded.signatures, * ...signatures * }), * } * return getBase64EncodedWireTransaction(newTransaction); * }, * }, * }); * ``` */ export declare function createIntentClient(parameters: CreateIntentClientConfig): IntentClient; export {}; //# sourceMappingURL=intentClient.d.ts.map