import * as Address from 'ox/Address'; import * as Hex from 'ox/Hex'; import { Channel as ox_Channel, TokenId } from 'ox/tempo'; import type { Account } from '../../accounts/types.js'; import type { ReadContractReturnType } from '../../actions/public/readContract.js'; import type { WriteContractReturnType } from '../../actions/wallet/writeContract.js'; import { writeContract } from '../../actions/wallet/writeContract.js'; import { writeContractSync } from '../../actions/wallet/writeContractSync.js'; import type { Client } from '../../clients/createClient.js'; import type { Transport } from '../../clients/transports/createTransport.js'; import type { BaseErrorType } from '../../errors/base.js'; import type { Chain } from '../../types/chain.js'; import type { GetEventArgs } from '../../types/contract.js'; import type { Log } from '../../types/log.js'; import type { Compute } from '../../types/utils.js'; import * as Abis from '../Abis.js'; import type { GetAccountParameter, ReadParameters, WriteParameters } from '../internal/types.js'; import type { TransactionReceipt } from '../Transaction.js'; /** * Closes a TIP-20 channel reserve channel from the payee or operator side. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const hash = await Actions.channel.close(client, { * captureAmount: 100n, * cumulativeAmount: 100n, * channel, * signature: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function close(client: Client, parameters: close.Parameters): Promise; export declare namespace close { type Parameters = WriteParameters & Args; type Args = { /** Amount to capture for the payee during close. */ captureAmount: bigint; /** Total voucher amount signed for the channel. */ cumulativeAmount: bigint; /** TIP-20 channel. */ channel: ox_Channel.from.Value; /** Voucher signature. */ signature: Hex.Hex; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `close` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "close"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "tuple"; readonly name: "descriptor"; readonly components: readonly [{ readonly type: "address"; readonly name: "payer"; }, { readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }, { readonly type: "bytes32"; readonly name: "expiringNonceHash"; }]; }, { readonly type: "uint96"; readonly name: "cumulativeAmount"; }, { readonly type: "uint96"; readonly name: "captureAmount"; }, { readonly type: "bytes"; readonly name: "signature"; }]; readonly outputs: readonly []; }]; functionName: "close"; } & { args: readonly [{ payer: `0x${string}`; payee: `0x${string}`; operator: `0x${string}`; token: `0x${string}`; salt: `0x${string}`; authorizedSigner: `0x${string}`; expiringNonceHash: `0x${string}`; }, bigint, bigint, signature: `0x${string}`]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `ChannelClosed` event from logs. * * @param logs - The logs. * @returns The `ChannelClosed` event. */ function extractEvent(logs: Log[]): Log; } /** * Closes a TIP-20 channel reserve channel and waits for the transaction receipt. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const result = await Actions.channel.closeSync(client, { * captureAmount: 100n, * cumulativeAmount: 100n, * channel, * signature: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function closeSync(client: Client, parameters: closeSync.Parameters): Promise; export declare namespace closeSync { type Parameters = close.Parameters; type Args = close.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } /** * Gets TIP-20 channel reserve state for a channel ID or channel. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }), * transport: http(), * }) * * const state = await Actions.channel.getStates(client, { * channel: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns Channel state for a single channel, or channel states for multiple channels. */ export declare function getStates(client: Client, parameters: getStates.Parameters): Promise>; export declare namespace getStates { type Parameters = ReadParameters & { /** Channel ID, channel, or list of IDs and channels. */ channel: channel; }; type Args = { /** * Chain ID used to compute IDs for channel inputs. * * Required for channel inputs when using `getStates.call` directly. */ chainId?: number | undefined; /** Channel ID, channel, or list of IDs and channels. */ channel: channel; }; type Channel = Hex.Hex | ox_Channel.from.Value; type State = ReadContractReturnType; type ReturnValue = channel extends readonly Channel[] ? readonly State[] : State; type ErrorType = BaseErrorType; /** * Defines a call to the `getChannelState` or `getChannelStatesBatch` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }), * transport: http(), * }).extend(walletActions) * * const calls = [Actions.channel.getStates.call({ channel: '0x...' })] * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): ({ abi: [{ readonly name: "getChannelStatesBatch"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "bytes32[]"; readonly name: "channelIds"; }]; readonly outputs: readonly [{ readonly type: "tuple[]"; readonly components: readonly [{ readonly type: "uint96"; readonly name: "settled"; }, { readonly type: "uint96"; readonly name: "deposit"; }, { readonly type: "uint32"; readonly name: "closeRequestedAt"; }]; }]; }]; functionName: "getChannelStatesBatch"; } & { args: readonly [readonly `0x${string}`[]]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }) | ({ abi: [{ readonly name: "getChannelState"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "bytes32"; readonly name: "channelId"; }]; readonly outputs: readonly [{ readonly type: "tuple"; readonly components: readonly [{ readonly type: "uint96"; readonly name: "settled"; }, { readonly type: "uint96"; readonly name: "deposit"; }, { readonly type: "uint32"; readonly name: "closeRequestedAt"; }]; }]; }]; functionName: "getChannelState"; } & { args: readonly [channelId: `0x${string}`]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }); } /** * Opens and funds a TIP-20 channel reserve channel. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * import { privateKeyToAccount } from 'viem/accounts' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }), * transport: http(), * }) * * const hash = await Actions.channel.open(client, { * deposit: 100n, * payee: '0x...', * token: 1n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function open(client: Client, parameters: open.Parameters): Promise; export declare namespace open { type Parameters = WriteParameters & Args; type Args = { /** Optional signer for vouchers. Zero means `payer` signs. @default zeroAddress */ authorizedSigner?: Address.Address | undefined; /** Amount of TIP-20 token to deposit. */ deposit: bigint; /** Optional relayer allowed to submit `settle` for the payee. @default zeroAddress */ operator?: Address.Address | undefined; /** Account that receives settled voucher payments. */ payee: Address.Address; /** User-supplied salt to distinguish otherwise identical channels. @default Hex.random(32) */ salt?: Hex.Hex | undefined; /** TIP-20 token address or ID held by the channel. */ token: TokenId.TokenIdOrAddress; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `open` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "open"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "uint96"; readonly name: "deposit"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }]; readonly outputs: readonly [{ readonly type: "bytes32"; readonly name: "channelId"; }]; }]; functionName: "open"; } & { args: readonly [payee: `0x${string}`, operator: `0x${string}`, token: `0x${string}`, deposit: bigint, salt: `0x${string}`, `0x${string}`]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `ChannelOpened` event from logs. * * @param logs - The logs. * @returns The `ChannelOpened` event. */ function extractEvent(logs: Log[]): Log; } /** * Opens and funds a TIP-20 channel reserve channel and waits for the * transaction receipt. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * import { privateKeyToAccount } from 'viem/accounts' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }), * transport: http(), * }) * * const result = await Actions.channel.openSync(client, { * deposit: 100n, * payee: '0x...', * token: 1n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function openSync(client: Client, parameters: openSync.Parameters): Promise; export declare namespace openSync { type Parameters = open.Parameters; type Args = open.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } /** * Starts the payer close timer for a TIP-20 channel reserve channel. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const hash = await Actions.channel.requestClose(client, { * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function requestClose(client: Client, parameters: requestClose.Parameters): Promise; export declare namespace requestClose { type Parameters = WriteParameters & Args; type Args = { /** TIP-20 channel. */ channel: ox_Channel.from.Value; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `requestClose` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "requestClose"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "tuple"; readonly name: "descriptor"; readonly components: readonly [{ readonly type: "address"; readonly name: "payer"; }, { readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }, { readonly type: "bytes32"; readonly name: "expiringNonceHash"; }]; }]; readonly outputs: readonly []; }]; functionName: "requestClose"; } & { args: readonly [{ payer: `0x${string}`; payee: `0x${string}`; operator: `0x${string}`; token: `0x${string}`; salt: `0x${string}`; authorizedSigner: `0x${string}`; expiringNonceHash: `0x${string}`; }]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `CloseRequested` event from logs. * * @param logs - The logs. * @returns The `CloseRequested` event. */ function extractEvent(logs: Log[]): Log; } /** * Starts the payer close timer and waits for the transaction receipt. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const result = await Actions.channel.requestCloseSync(client, { * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function requestCloseSync(client: Client, parameters: requestCloseSync.Parameters): Promise; export declare namespace requestCloseSync { type Parameters = requestClose.Parameters; type Args = requestClose.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } /** * Settles a TIP-20 channel reserve voucher. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const hash = await Actions.channel.settle(client, { * cumulativeAmount: 100n, * channel, * signature: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function settle(client: Client, parameters: settle.Parameters): Promise; export declare namespace settle { type Parameters = WriteParameters & Args; type Args = { /** Total voucher amount signed for the channel. */ cumulativeAmount: bigint; /** TIP-20 channel. */ channel: ox_Channel.from.Value; /** Voucher signature. */ signature: Hex.Hex; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `settle` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "settle"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "tuple"; readonly name: "descriptor"; readonly components: readonly [{ readonly type: "address"; readonly name: "payer"; }, { readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }, { readonly type: "bytes32"; readonly name: "expiringNonceHash"; }]; }, { readonly type: "uint96"; readonly name: "cumulativeAmount"; }, { readonly type: "bytes"; readonly name: "signature"; }]; readonly outputs: readonly []; }]; functionName: "settle"; } & { args: readonly [{ payer: `0x${string}`; payee: `0x${string}`; operator: `0x${string}`; token: `0x${string}`; salt: `0x${string}`; authorizedSigner: `0x${string}`; expiringNonceHash: `0x${string}`; }, bigint, signature: `0x${string}`]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `Settled` event from logs. * * @param logs - The logs. * @returns The `Settled` event. */ function extractEvent(logs: Log[]): Log; } /** * Settles a TIP-20 channel reserve voucher and waits for the transaction receipt. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const result = await Actions.channel.settleSync(client, { * cumulativeAmount: 100n, * channel, * signature: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function settleSync(client: Client, parameters: settleSync.Parameters): Promise; export declare namespace settleSync { type Parameters = settle.Parameters; type Args = settle.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } /** * Signs a TIP-20 channel reserve voucher. * * @example * ```ts * import { parseUnits } from 'viem' * import { Actions } from 'viem/tempo' * * const signature = await Actions.channel.signVoucher(client, { * channel, * cumulativeAmount: parseUnits('40', 6), * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The voucher signature. */ export declare function signVoucher(client: Client, parameters: signVoucher.Parameters): Promise; export declare namespace signVoucher { type Parameters = GetAccountParameter & Args; type Args = { /** Channel ID or channel. */ channel: getStates.Channel; /** The chain ID. @default client.chain.id */ chainId?: number | bigint | undefined; /** Total voucher amount signed for the channel. */ cumulativeAmount: bigint; }; type ReturnValue = Hex.Hex; type ErrorType = BaseErrorType; } /** * Adds deposit to a TIP-20 channel reserve channel. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const hash = await Actions.channel.topUp(client, { * additionalDeposit: 100n, * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function topUp(client: Client, parameters: topUp.Parameters): Promise; export declare namespace topUp { type Parameters = WriteParameters & Args; type Args = { /** Additional deposit to lock in the channel. */ additionalDeposit: bigint; /** TIP-20 channel. */ channel: ox_Channel.from.Value; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `topUp` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "topUp"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "tuple"; readonly name: "descriptor"; readonly components: readonly [{ readonly type: "address"; readonly name: "payer"; }, { readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }, { readonly type: "bytes32"; readonly name: "expiringNonceHash"; }]; }, { readonly type: "uint96"; readonly name: "additionalDeposit"; }]; readonly outputs: readonly []; }]; functionName: "topUp"; } & { args: readonly [{ payer: `0x${string}`; payee: `0x${string}`; operator: `0x${string}`; token: `0x${string}`; salt: `0x${string}`; authorizedSigner: `0x${string}`; expiringNonceHash: `0x${string}`; }, bigint]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `TopUp` event from logs. * * @param logs - The logs. * @returns The `TopUp` event. */ function extractEvent(logs: Log[]): Log; } /** * Adds deposit to a TIP-20 channel reserve channel and waits for the * transaction receipt. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const result = await Actions.channel.topUpSync(client, { * additionalDeposit: 100n, * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function topUpSync(client: Client, parameters: topUpSync.Parameters): Promise; export declare namespace topUpSync { type Parameters = topUp.Parameters; type Args = topUp.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } /** * Withdraws payer funds after the close grace period elapses. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const hash = await Actions.channel.withdraw(client, { * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function withdraw(client: Client, parameters: withdraw.Parameters): Promise; export declare namespace withdraw { type Parameters = WriteParameters & Args; type Args = { /** TIP-20 channel. */ channel: ox_Channel.from.Value; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: Parameters): Promise>; /** * Defines a call to the `withdraw` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "withdraw"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "tuple"; readonly name: "descriptor"; readonly components: readonly [{ readonly type: "address"; readonly name: "payer"; }, { readonly type: "address"; readonly name: "payee"; }, { readonly type: "address"; readonly name: "operator"; }, { readonly type: "address"; readonly name: "token"; }, { readonly type: "bytes32"; readonly name: "salt"; }, { readonly type: "address"; readonly name: "authorizedSigner"; }, { readonly type: "bytes32"; readonly name: "expiringNonceHash"; }]; }]; readonly outputs: readonly []; }]; functionName: "withdraw"; } & { args: readonly [{ payer: `0x${string}`; payee: `0x${string}`; operator: `0x${string}`; token: `0x${string}`; salt: `0x${string}`; authorizedSigner: `0x${string}`; expiringNonceHash: `0x${string}`; }]; } & { address: import("abitype").Address; } & { data: import("../../index.js").Hex; to: import("abitype").Address; }; /** * Extracts the `ChannelClosed` event from logs. * * @param logs - The logs. * @returns The `ChannelClosed` event. */ function extractEvent(logs: Log[]): Log; } /** * Withdraws payer funds after the close grace period elapses and waits for the * transaction receipt. * * @example * ```ts * import { Actions } from 'viem/tempo' * * const result = await Actions.channel.withdrawSync(client, { * channel, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function withdrawSync(client: Client, parameters: withdrawSync.Parameters): Promise; export declare namespace withdrawSync { type Parameters = withdraw.Parameters; type Args = withdraw.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; } //# sourceMappingURL=channel.d.ts.map