UNPKG

accounts

Version:

Tempo Accounts SDK

77 lines 3.27 kB
import type { Address, Client } from 'viem'; import type { LocalAccount } from 'viem/accounts'; import { Transaction } from 'viem/tempo'; /** Returns sponsor metadata for `eth_fillTransaction` responses. */ export declare function getSponsor(options: getSponsor.Options): getSponsor.ReturnType; export declare namespace getSponsor { type Options = { /** Account used for sponsorship. */ account: LocalAccount; /** Optional display name. */ name?: string | undefined; /** Optional display URL. */ url?: string | undefined; }; type ReturnType = { /** Sponsor address. */ address: Address; /** Sponsor display name. */ name?: string | undefined; /** Sponsor display URL. */ url?: string | undefined; }; } /** Returns whether the fee payer approves a filled transaction. */ export declare function shouldSponsor(options: shouldSponsor.Options): Promise<boolean>; export declare namespace shouldSponsor { type Options = { /** Sender address from the original request. */ sender?: Address | undefined; /** Filled transaction to validate. */ transaction: Record<string, unknown>; /** Optional sponsorship approval callback. */ validate?: ((request: Transaction.TransactionRequest) => boolean | Promise<boolean>) | undefined; }; } /** Returns whether a raw Tempo transaction is explicitly requesting sponsorship. */ export declare function requestsRawSponsorship(serialized: `0x${string}`): boolean; /** Returns `true` when a fill request already has the fields needed for sponsorship signing. */ export declare function isPreparedTransaction(value: Record<string, unknown>): boolean; /** Signs a filled transaction as the fee payer. */ export declare function sign(options: sign.Options): Promise<{ feePayerSignature: { r: bigint; s: bigint; yParity: number; }; from: `0x${string}` | undefined; }>; export declare namespace sign { type Options = { /** Account used as the fee payer. */ account: LocalAccount; /** Filled transaction to sign. */ transaction: Record<string, unknown>; /** Sender address from the original request. */ sender?: Address | undefined; }; } /** Handles `eth_signRawTransaction` and broadcast methods for sponsored Tempo transactions. */ export declare function handleRawTransaction(options: handleRawTransaction.Options): Promise<string>; export declare namespace handleRawTransaction { type Options = { /** Account used as the fee payer. */ account: LocalAccount; /** Client resolver keyed by transaction `chainId`. */ getClient: (chainId?: number | undefined) => Client; /** Raw transaction method to handle. */ method: 'eth_signRawTransaction' | 'eth_sendRawTransaction' | 'eth_sendRawTransactionSync'; /** Incoming JSON-RPC request. */ request: { params?: readonly unknown[] | undefined; }; /** Optional sponsorship approval callback. */ validate?: ((request: Transaction.TransactionRequest) => boolean | Promise<boolean>) | undefined; }; } //# sourceMappingURL=sponsorship.d.ts.map