viem
Version:
111 lines • 4.67 kB
TypeScript
import type { LocalAccount } from '../accounts/types.js';
import { type Transport } from '../clients/transports/createTransport.js';
import { type HttpTransport, type HttpTransportConfig } from '../clients/transports/http.js';
import * as Multisig from './Multisig.js';
import type { Store } from './Store.js';
export type HttpConfig = Omit<HttpTransportConfig, 'batch' | 'raw' | 'rpcSchema'> & {
/** Store for reading Zone authorization tokens. Defaults to sessionStorage (web) or memory (server). */
store?: Store | undefined;
};
/**
* Creates an HTTP transport with support for Zone authentication tokens.
*
* Reads the authorization token from the store and injects the
* `X-Authorization-Token` header on every request.
*
* @example
* ```ts
* import { createPublicClient } from 'viem'
* import { http, Zone } from 'viem/tempo'
*
* const client = createPublicClient({
* chain: Zone.a,
* transport: http(),
* })
* ```
*/
export declare function http(url?: string | undefined, config?: HttpConfig): HttpTransport;
type RelayProxyParameters = {
/** Policy for how the relay should handle sponsored transactions. Defaults to `'sign-only'`. */
policy?: 'sign-only' | 'sign-and-broadcast' | undefined;
};
export type FeePayer = Transport<typeof withFeePayer.type>;
export type Relay = Transport<typeof withRelay.type, {
multisig: true;
}>;
/**
* Wraps a transport with native multisig request handling.
*
* @example
* ```ts
* import { http, Store, withMultisig } from 'viem/tempo'
*
* const transport = withMultisig(http(), {
* store: Store.memory(),
* })
* ```
*
* @param transport - Transport to wrap.
* @param parameters - Multisig request handler parameters.
* @returns The wrapped transport.
* @experimental
*/
export declare function withMultisig<transport extends Transport>(transport: transport, parameters: withMultisig.Parameters): withMultisig.ReturnValue<transport>;
export declare namespace withMultisig {
/** Multisig transport parameters. */
type Parameters = Multisig.handleRequest.Parameters;
/** Multisig transport return type. */
type ReturnValue<transport extends Transport = Transport> = transport extends Transport<infer type, infer rpcAttributes, infer eip1193RequestFn> ? Transport<type, rpcAttributes & {
/** Whether the transport coordinates native multisig approvals. */
multisig: true;
}, eip1193RequestFn> : never;
}
/**
* Creates a relay transport that routes requests between
* the default transport or the relay transport.
*
* All `eth_fillTransaction` requests are sent to the relay with the request's
* `feePayer` value preserved so the relay can decide whether to sponsor the transaction.
* Multisig approvals, configs, operations, and operation-aware transaction
* lookups are also sent to the relay so it can coordinate approvals in its store.
*
* The policy parameter controls how the relay handles sponsored transactions:
* - `'sign-only'`: Relay co-signs the transaction and returns it to the client transport, which then broadcasts it via the default transport
* - `'sign-and-broadcast'`: Relay co-signs and broadcasts the transaction directly
*
* @param defaultTransport - The default transport to use.
* @param relayTransport - The relay transport to use.
* @param parameters - Configuration parameters.
* @returns A relay transport.
*/
export declare function withRelay(defaultTransport: Transport, relayTransport: Transport, parameters?: withRelay.Parameters): withRelay.ReturnValue;
export declare namespace withRelay {
const type = "relay";
type Parameters = RelayProxyParameters;
type ReturnValue = Relay;
}
/** @deprecated Use `withRelay` instead. */
export declare function withFeePayer(defaultTransport: Transport, relayTransport: Transport, parameters?: withFeePayer.Parameters): withFeePayer.ReturnValue;
export declare namespace withFeePayer {
const type = "feePayer";
type Parameters = {
/** Policy for how the fee payer should handle transactions. Defaults to `'sign-only'`. */
policy?: 'sign-only' | 'sign-and-broadcast' | undefined;
};
type ReturnValue = FeePayer;
}
/**
* Creates a transport that instruments a compatibility layer for
* `wallet_` RPC actions (`sendCalls`, `getCallsStatus`, etc).
*
* @param transport - Transport to wrap.
* @returns Transport.
*/
export declare function walletNamespaceCompat(transport: Transport, options: walletNamespaceCompat.Parameters): Transport;
export declare namespace walletNamespaceCompat {
type Parameters = {
account: LocalAccount;
};
}
export {};
//# sourceMappingURL=Transport.d.ts.map