ox
Version:
Ethereum Standard Library
74 lines • 3.4 kB
TypeScript
import * as Hex from '../core/Hex.js';
import type { OneOf } from '../core/internal/types.js';
import type * as EntryPoint from './EntryPoint.js';
/** User Operation Gas type. */
export type UserOperationGas<entryPointVersion extends EntryPoint.Version = EntryPoint.Version, bigintType = bigint> = OneOf<(entryPointVersion extends '0.6' ? V06<bigintType> : never) | (entryPointVersion extends '0.7' ? V07<bigintType> : never) | (entryPointVersion extends '0.8' ? V08<bigintType> : never) | (entryPointVersion extends '0.9' ? V09<bigintType> : never)>;
/** RPC User Operation Gas. */
export type Rpc<entryPointVersion extends EntryPoint.Version = EntryPoint.Version> = UserOperationGas<entryPointVersion, Hex.Hex>;
/** Type for User Operation Gas on EntryPoint 0.6 */
export type V06<bigintType = bigint> = {
callGasLimit: bigintType;
preVerificationGas: bigintType;
verificationGasLimit: bigintType;
};
/** RPC User Operation Gas on EntryPoint 0.6 */
export type RpcV06 = V06<Hex.Hex>;
/** Type for User Operation Gas on EntryPoint 0.7 */
export type V07<bigintType = bigint> = {
callGasLimit: bigintType;
paymasterVerificationGasLimit?: bigintType | undefined;
paymasterPostOpGasLimit?: bigintType | undefined;
preVerificationGas: bigintType;
verificationGasLimit: bigintType;
};
/** RPC User Operation Gas on EntryPoint 0.7 */
export type RpcV07 = V07<Hex.Hex>;
/** Type for User Operation Gas on EntryPoint 0.8 */
export type V08<bigintType = bigint> = V07<bigintType>;
/** RPC User Operation Gas on EntryPoint 0.8 */
export type RpcV08 = V08<Hex.Hex>;
/** Type for User Operation Gas on EntryPoint 0.9 */
export type V09<bigintType = bigint> = V08<bigintType>;
/** RPC User Operation Gas on EntryPoint 0.9 */
export type RpcV09 = V09<Hex.Hex>;
/**
* Converts an {@link ox#UserOperationGas.Rpc} to an {@link ox#UserOperationGas.UserOperationGas}.
*
* @example
* ```ts twoslash
* import { UserOperationGas } from 'ox/erc4337'
*
* const userOperationGas = UserOperationGas.fromRpc({
* callGasLimit: '0x69420',
* preVerificationGas: '0x69420',
* verificationGasLimit: '0x69420'
* })
* ```
*
* @param rpc - The RPC user operation gas to convert.
* @returns An instantiated {@link ox#UserOperationGas.UserOperationGas}.
*/
export declare function fromRpc<entryPointVersion extends EntryPoint.Version = EntryPoint.Version>(rpc: Rpc<entryPointVersion>): UserOperationGas<entryPointVersion>;
/**
* Converts a {@link ox#UserOperationGas.UserOperationGas} to a {@link ox#UserOperationGas.Rpc}.
*
* @example
* ```ts twoslash
* import { UserOperationGas } from 'ox/erc4337'
*
* const userOperationGas = UserOperationGas.toRpc({
* callGasLimit: 300_000n,
* preVerificationGas: 100_000n,
* verificationGasLimit: 100_000n
* })
* ```
*
* @param userOperationGas - The user operation gas to convert.
* @returns An RPC-formatted user operation gas.
*/
export declare function toRpc<entryPointVersion extends EntryPoint.Version = EntryPoint.Version>(userOperationGas: toRpc.Input<entryPointVersion>): Rpc<entryPointVersion>;
export declare namespace toRpc {
/** Numberish input accepted by {@link ox#UserOperationGas.(toRpc:function)}. */
type Input<entryPointVersion extends EntryPoint.Version = EntryPoint.Version> = UserOperationGas<entryPointVersion, Hex.Hex | bigint | number>;
}
//# sourceMappingURL=UserOperationGas.d.ts.map