FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

1419
node_modules/ox/erc4337/EntryPoint.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

6
node_modules/ox/erc4337/EntryPoint/package.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../../_types/erc4337/EntryPoint.d.ts",
"main": "../../_cjs/erc4337/EntryPoint.js",
"module": "../../_esm/erc4337/EntryPoint.js"
}

179
node_modules/ox/erc4337/RpcSchema.ts generated vendored Normal file
View File

@@ -0,0 +1,179 @@
import type * as Address from '../core/Address.js'
import type * as Hex from '../core/Hex.js'
import type * as RpcSchema from '../core/RpcSchema.js'
import type * as StateOverrides from '../core/StateOverrides.js'
import type * as EntryPoint from './EntryPoint.js'
import type * as UserOperation from './UserOperation.js'
import type * as UserOperationGas from './UserOperationGas.js'
import type * as UserOperationReceipt from './UserOperationReceipt.js'
/**
* Union of all JSON-RPC Methods for ERC-4337 Bundlers.
*
* @example
* ```ts twoslash
* import { RpcSchema } from 'ox'
*
* type Schema = RpcSchema.Bundler
* // ^?
*
*
*
*
*
*
*
*
*
*
*
* ```
*/
export type Bundler<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
> = RpcSchema.From<
| {
Request: {
method: 'eth_chainId'
params?: undefined
}
ReturnType: Hex.Hex
}
| {
Request: {
method: 'eth_estimateUserOperationGas'
params:
| [
userOperation: UserOperation.Rpc<entryPointVersion>,
entrypoint: Address.Address,
]
| [
userOperation: UserOperation.Rpc<entryPointVersion>,
entrypoint: Address.Address,
stateOverrides: StateOverrides.Rpc,
]
}
ReturnType: UserOperationGas.Rpc<entryPointVersion>
}
| {
Request: {
method: 'eth_getUserOperationByHash'
params: [hash: Hex.Hex]
}
ReturnType: UserOperation.Rpc<entryPointVersion> | null
}
| {
Request: {
method: 'eth_getUserOperationReceipt'
params: [hash: Hex.Hex]
}
ReturnType: UserOperationReceipt.Rpc<entryPointVersion> | null
}
| {
Request: {
method: 'eth_sendUserOperation'
params: [
userOperation: UserOperation.Rpc<entryPointVersion>,
entrypoint: Address.Address,
]
}
ReturnType: Hex.Hex
}
| {
Request: {
method: 'eth_supportedEntryPoints'
params?: undefined
}
ReturnType: readonly Address.Address[]
}
>
/**
* Union of all JSON-RPC Methods for the debug methods of ERC-4337 Bundlers.
*
* @example
* ```ts twoslash
* import { RpcSchema } from 'ox'
*
* type Schema = RpcSchema.BundlerDebug
* // ^?
*
*
*
*
*
*
*
*
*
*
*
* ```
*/
export type BundlerDebug<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
> = RpcSchema.From<
| {
Request: {
method: 'debug_bundler_clearState'
params?: undefined
}
ReturnType: undefined
}
| {
Request: {
method: 'debug_bundler_dumpMempool'
params: [entryPoint: Address.Address]
}
ReturnType: readonly { userOp: UserOperation.Rpc }[]
}
| {
Request: {
method: 'debug_bundler_sendBundleNow'
params?: undefined
}
ReturnType: Hex.Hex
}
| {
Request: {
method: 'debug_bundler_setBundlingMode'
params: [mode: 'auto' | 'manual']
}
ReturnType: undefined
}
| {
Request: {
method: 'debug_bundler_setReputation'
params: [
reputations: readonly {
address: Address.Address
opsSeen: Hex.Hex
opsIncluded: Hex.Hex
}[],
entryPoint: Address.Address,
]
}
ReturnType: undefined
}
| {
Request: {
method: 'debug_bundler_dumpReputation'
params: [entryPoint: Address.Address]
}
ReturnType: readonly {
address: Address.Address
opsSeen: Hex.Hex
opsIncluded: Hex.Hex
}[]
}
| {
Request: {
method: 'debug_bundler_addUserOps'
params: [
userOps: readonly UserOperation.Rpc<entryPointVersion>[],
entryPoint: Address.Address,
]
}
ReturnType: undefined
}
>

6
node_modules/ox/erc4337/RpcSchema/package.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../../_types/erc4337/RpcSchema.d.ts",
"main": "../../_cjs/erc4337/RpcSchema.js",
"module": "../../_esm/erc4337/RpcSchema.js"
}

617
node_modules/ox/erc4337/UserOperation.ts generated vendored Normal file
View File

@@ -0,0 +1,617 @@
import * as AbiParameters from '../core/AbiParameters.js'
import type * as Address from '../core/Address.js'
import type * as Errors from '../core/Errors.js'
import * as Hash from '../core/Hash.js'
import * as Hex from '../core/Hex.js'
import * as Signature from '../core/Signature.js'
import type { Assign, Compute, OneOf } from '../core/internal/types.js'
import type * as EntryPoint from './EntryPoint.js'
/** User Operation. */
export type UserOperation<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
signed extends boolean = boolean,
bigintType = bigint,
> = OneOf<
| (entryPointVersion extends '0.6' ? V06<signed, bigintType> : never)
| (entryPointVersion extends '0.7' ? V07<signed, bigintType> : never)
>
/**
* Packed User Operation.
*
* @see https://eips.ethereum.org/EIPS/eip-4337#entrypoint-definition
*/
export type Packed = {
/** Concatenation of `verificationGasLimit` (16 bytes) and `callGasLimit` (16 bytes) */
accountGasLimits: Hex.Hex
/** The data to pass to the `sender` during the main execution call. */
callData: Hex.Hex
/** Concatenation of `factory` and `factoryData`. */
initCode: Hex.Hex
/** Concatenation of `maxPriorityFee` (16 bytes) and `maxFeePerGas` (16 bytes) */
gasFees: Hex.Hex
/** Anti-replay parameter. */
nonce: bigint
/** Concatenation of paymaster fields (or empty). */
paymasterAndData: Hex.Hex
/** Extra gas to pay the Bundler. */
preVerificationGas: bigint
/** The account making the operation. */
sender: Address.Address
/** Data passed into the account to verify authorization. */
signature: Hex.Hex
}
/** RPC User Operation type. */
export type Rpc<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
signed extends boolean = true,
> = OneOf<
| (entryPointVersion extends '0.6' ? V06<signed, Hex.Hex> : never)
| (entryPointVersion extends '0.7' ? V07<signed, Hex.Hex> : never)
>
/** Transaction Info. */
export type TransactionInfo<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
bigintType = bigint,
> = {
blockHash: Hex.Hex
blockNumber: bigintType
entryPoint: Address.Address
transactionHash: Hex.Hex
userOperation: UserOperation<entryPointVersion, true, bigintType>
}
/** RPC Transaction Info. */
export type RpcTransactionInfo<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
> = TransactionInfo<entryPointVersion, Hex.Hex>
/** Type for User Operation on EntryPoint 0.6 */
export type V06<signed extends boolean = boolean, bigintType = bigint> = {
/** The data to pass to the `sender` during the main execution call. */
callData: Hex.Hex
/** The amount of gas to allocate the main execution call */
callGasLimit: bigintType
/** Account init code. Only for new accounts. */
initCode?: Hex.Hex | undefined
/** Maximum fee per gas. */
maxFeePerGas: bigintType
/** Maximum priority fee per gas. */
maxPriorityFeePerGas: bigintType
/** Anti-replay parameter. */
nonce: bigintType
/** Paymaster address with calldata. */
paymasterAndData?: Hex.Hex | undefined
/** Extra gas to pay the Bundler. */
preVerificationGas: bigintType
/** The account making the operation. */
sender: Address.Address
/** Data passed into the account to verify authorization. */
signature?: Hex.Hex | undefined
/** The amount of gas to allocate for the verification step. */
verificationGasLimit: bigintType
} & (signed extends true ? { signature: Hex.Hex } : {})
/** RPC User Operation on EntryPoint 0.6 */
export type RpcV06<signed extends boolean = true> = V06<signed, Hex.Hex>
/** Type for User Operation on EntryPoint 0.7 */
export type V07<signed extends boolean = boolean, bigintType = bigint> = {
/** The data to pass to the `sender` during the main execution call. */
callData: Hex.Hex
/** The amount of gas to allocate the main execution call */
callGasLimit: bigintType
/** Account factory. Only for new accounts. */
factory?: Address.Address | undefined
/** Data for account factory. */
factoryData?: Hex.Hex | undefined
/** Maximum fee per gas. */
maxFeePerGas: bigintType
/** Maximum priority fee per gas. */
maxPriorityFeePerGas: bigintType
/** Anti-replay parameter. */
nonce: bigintType
/** Address of paymaster contract. */
paymaster?: Address.Address | undefined
/** Data for paymaster. */
paymasterData?: Hex.Hex | undefined
/** The amount of gas to allocate for the paymaster post-operation code. */
paymasterPostOpGasLimit?: bigintType | undefined
/** The amount of gas to allocate for the paymaster validation code. */
paymasterVerificationGasLimit?: bigintType | undefined
/** Extra gas to pay the Bundler. */
preVerificationGas: bigintType
/** The account making the operation. */
sender: Address.Address
/** Data passed into the account to verify authorization. */
signature?: Hex.Hex | undefined
/** The amount of gas to allocate for the verification step. */
verificationGasLimit: bigintType
} & (signed extends true ? { signature: Hex.Hex } : {})
/** RPC User Operation on EntryPoint 0.7 */
export type RpcV07<signed extends boolean = true> = V07<signed, Hex.Hex>
/**
* Instantiates a {@link ox#UserOperation.UserOperation} from a provided input.
*
* @example
* ```ts twoslash
* import { Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.from({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* verificationGasLimit: 100_000n,
* })
* ```
*
* @example
* ### Attaching Signatures
*
* ```ts twoslash
* import { Secp256k1, Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.from({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* verificationGasLimit: 100_000n,
* })
*
* const payload = UserOperation.getSignPayload(userOperation, {
* chainId: 1,
* entryPointAddress: '0x1234567890123456789012345678901234567890',
* entryPointVersion: '0.7',
* })
*
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
*
* const userOperation_signed = UserOperation.from(userOperation, { signature }) // [!code focus]
* ```
*
* @param userOperation - The user operation to instantiate.
* @returns User Operation.
*/
export function from<
const userOperation extends UserOperation,
const signature extends Hex.Hex | undefined = undefined,
>(
userOperation: userOperation | UserOperation,
options: from.Options<signature> = {},
): from.ReturnType<userOperation, signature> {
const signature = (() => {
if (!options.signature) return undefined
if (typeof options.signature === 'string') return options.signature
return Signature.toHex(options.signature)
})()
return { ...userOperation, signature } as never
}
export declare namespace from {
export type Options<
signature extends Signature.Signature | Hex.Hex | undefined = undefined,
> = {
signature?: signature | Signature.Signature | Hex.Hex | undefined
}
export type ReturnType<
userOperation extends UserOperation = UserOperation,
signature extends Signature.Signature | Hex.Hex | undefined = undefined,
> = Compute<
Assign<
userOperation,
signature extends Signature.Signature | Hex.Hex
? Readonly<{ signature: Hex.Hex }>
: {}
>
>
export type ErrorType = Errors.GlobalErrorType
}
/**
* Converts an {@link ox#UserOperation.Rpc} to an {@link ox#UserOperation.UserOperation}.
*
* @example
* ```ts twoslash
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.fromRpc({
* callData: '0xdeadbeef',
* callGasLimit: '0x69420',
* maxFeePerGas: '0x2ca6ae494',
* maxPriorityFeePerGas: '0x41cc3c0',
* nonce: '0x357',
* preVerificationGas: '0x69420',
* signature: '0x',
* sender: '0x1234567890123456789012345678901234567890',
* verificationGasLimit: '0x69420',
* })
* ```
*
* @param rpc - The RPC user operation to convert.
* @returns An instantiated {@link ox#UserOperation.UserOperation}.
*/
export function fromRpc(rpc: Rpc): UserOperation {
return {
...rpc,
callGasLimit: BigInt(rpc.callGasLimit),
maxFeePerGas: BigInt(rpc.maxFeePerGas),
maxPriorityFeePerGas: BigInt(rpc.maxPriorityFeePerGas),
nonce: BigInt(rpc.nonce),
preVerificationGas: BigInt(rpc.preVerificationGas),
verificationGasLimit: BigInt(rpc.verificationGasLimit),
...(rpc.paymasterPostOpGasLimit && {
paymasterPostOpGasLimit: BigInt(rpc.paymasterPostOpGasLimit),
}),
...(rpc.paymasterVerificationGasLimit && {
paymasterVerificationGasLimit: BigInt(rpc.paymasterVerificationGasLimit),
}),
} as UserOperation
}
export declare namespace fromRpc {
type ErrorType = Errors.GlobalErrorType
}
/**
* Obtains the signing payload for a {@link ox#UserOperation.UserOperation}.
*
* @example
* ```ts twoslash
* import { Secp256k1, Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.from({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* verificationGasLimit: 100_000n,
* })
*
* const payload = UserOperation.getSignPayload(userOperation, { // [!code focus]
* chainId: 1, // [!code focus]
* entryPointAddress: '0x1234567890123456789012345678901234567890', // [!code focus]
* entryPointVersion: '0.6', // [!code focus]
* }) // [!code focus]
*
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
* ```
*
* @param userOperation - The user operation to get the sign payload for.
* @returns The signing payload for the user operation.
*/
export function getSignPayload<
entrypointVersion extends EntryPoint.Version = EntryPoint.Version,
>(
userOperation: UserOperation<entrypointVersion>,
options: getSignPayload.Options<entrypointVersion>,
): Hex.Hex {
return hash(userOperation, options)
}
export declare namespace getSignPayload {
type Options<
entrypointVersion extends EntryPoint.Version = EntryPoint.Version,
> = hash.Options<entrypointVersion>
type ErrorType = hash.ErrorType | Errors.GlobalErrorType
}
/**
* Hashes a {@link ox#UserOperation.UserOperation}. This is the "user operation hash".
*
* @example
* ```ts twoslash
* import { Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.hash({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* verificationGasLimit: 100_000n,
* }, {
* chainId: 1,
* entryPointAddress: '0x1234567890123456789012345678901234567890',
* entryPointVersion: '0.6',
* })
* ```
*
* @param userOperation - The user operation to hash.
* @returns The hash of the user operation.
*/
export function hash<
entrypointVersion extends EntryPoint.Version = EntryPoint.Version,
>(
userOperation: UserOperation<entrypointVersion>,
options: hash.Options<entrypointVersion>,
): Hex.Hex {
const { chainId, entryPointAddress, entryPointVersion } = options
const {
callData,
callGasLimit,
initCode,
factory,
factoryData,
maxFeePerGas,
maxPriorityFeePerGas,
nonce,
paymaster,
paymasterAndData,
paymasterData,
paymasterPostOpGasLimit,
paymasterVerificationGasLimit,
preVerificationGas,
sender,
verificationGasLimit,
} = userOperation as UserOperation
const packedUserOp = (() => {
if (entryPointVersion === '0.6') {
return AbiParameters.encode(
[
{ type: 'address' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'bytes32' },
],
[
sender,
nonce,
Hash.keccak256(initCode ?? '0x'),
Hash.keccak256(callData),
callGasLimit,
verificationGasLimit,
preVerificationGas,
maxFeePerGas,
maxPriorityFeePerGas,
Hash.keccak256(paymasterAndData ?? '0x'),
],
)
}
if (entryPointVersion === '0.7') {
const accountGasLimits = Hex.concat(
Hex.padLeft(Hex.fromNumber(verificationGasLimit), 16),
Hex.padLeft(Hex.fromNumber(callGasLimit), 16),
)
const gasFees = Hex.concat(
Hex.padLeft(Hex.fromNumber(maxPriorityFeePerGas), 16),
Hex.padLeft(Hex.fromNumber(maxFeePerGas), 16),
)
const initCode_hashed = Hash.keccak256(
factory && factoryData ? Hex.concat(factory, factoryData) : '0x',
)
const paymasterAndData_hashed = Hash.keccak256(
paymaster
? Hex.concat(
paymaster,
Hex.padLeft(
Hex.fromNumber(paymasterVerificationGasLimit || 0),
16,
),
Hex.padLeft(Hex.fromNumber(paymasterPostOpGasLimit || 0), 16),
paymasterData || '0x',
)
: '0x',
)
return AbiParameters.encode(
[
{ type: 'address' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
],
[
sender,
nonce,
initCode_hashed,
Hash.keccak256(callData),
accountGasLimits,
preVerificationGas,
gasFees,
paymasterAndData_hashed,
],
)
}
throw new Error(`entryPointVersion "${entryPointVersion}" not supported.`)
})()
return Hash.keccak256(
AbiParameters.encode(
[{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }],
[Hash.keccak256(packedUserOp), entryPointAddress, BigInt(chainId)],
),
)
}
export declare namespace hash {
type Options<
entrypointVersion extends EntryPoint.Version = EntryPoint.Version,
> = {
chainId: number
entryPointAddress: Address.Address
entryPointVersion: entrypointVersion | EntryPoint.Version
}
type ErrorType =
| AbiParameters.encode.ErrorType
| Hash.keccak256.ErrorType
| Hex.concat.ErrorType
| Hex.fromNumber.ErrorType
| Hex.padLeft.ErrorType
| Errors.GlobalErrorType
}
/**
* Transforms a User Operation into "packed" format.
*
* @example
* ```ts twoslash
* import { Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const packed = UserOperation.toPacked({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* signature: '0x...',
* verificationGasLimit: 100_000n,
* })
* ```
*
* @param userOperation - The user operation to transform.
* @returns The packed user operation.
*/
export function toPacked(userOperation: UserOperation<'0.7', true>): Packed {
const {
callGasLimit,
callData,
factory,
factoryData,
maxPriorityFeePerGas,
maxFeePerGas,
nonce,
paymaster,
paymasterData,
paymasterPostOpGasLimit,
paymasterVerificationGasLimit,
sender,
signature,
verificationGasLimit,
} = userOperation
const accountGasLimits = Hex.concat(
Hex.padLeft(Hex.fromNumber(verificationGasLimit || 0n), 16),
Hex.padLeft(Hex.fromNumber(callGasLimit || 0n), 16),
)
const initCode =
factory && factoryData ? Hex.concat(factory, factoryData) : '0x'
const gasFees = Hex.concat(
Hex.padLeft(Hex.fromNumber(maxPriorityFeePerGas || 0n), 16),
Hex.padLeft(Hex.fromNumber(maxFeePerGas || 0n), 16),
)
const paymasterAndData = paymaster
? Hex.concat(
paymaster,
Hex.padLeft(Hex.fromNumber(paymasterVerificationGasLimit || 0n), 16),
Hex.padLeft(Hex.fromNumber(paymasterPostOpGasLimit || 0n), 16),
paymasterData || '0x',
)
: '0x'
const preVerificationGas = userOperation.preVerificationGas ?? 0n
return {
accountGasLimits,
callData,
initCode,
gasFees,
nonce,
paymasterAndData,
preVerificationGas,
sender,
signature,
}
}
export declare namespace toPacked {
export type ErrorType = Errors.GlobalErrorType
}
/**
* Converts a {@link ox#UserOperation.UserOperation} to a {@link ox#UserOperation.Rpc}.
*
* @example
* ```ts twoslash
* import { Value } from 'ox'
* import { UserOperation } from 'ox/erc4337'
*
* const userOperation = UserOperation.toRpc({
* callData: '0xdeadbeef',
* callGasLimit: 300_000n,
* maxFeePerGas: Value.fromGwei('20'),
* maxPriorityFeePerGas: Value.fromGwei('2'),
* nonce: 69n,
* preVerificationGas: 100_000n,
* sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
* verificationGasLimit: 100_000n,
* })
* ```
*
* @param userOperation - The user operation to convert.
* @returns An RPC-formatted user operation.
*/
export function toRpc(userOperation: UserOperation): Rpc {
const rpc = {} as Rpc
rpc.callData = userOperation.callData
rpc.callGasLimit = Hex.fromNumber(userOperation.callGasLimit)
rpc.maxFeePerGas = Hex.fromNumber(userOperation.maxFeePerGas)
rpc.maxPriorityFeePerGas = Hex.fromNumber(userOperation.maxPriorityFeePerGas)
rpc.nonce = Hex.fromNumber(userOperation.nonce)
rpc.preVerificationGas = Hex.fromNumber(userOperation.preVerificationGas)
rpc.sender = userOperation.sender
rpc.verificationGasLimit = Hex.fromNumber(userOperation.verificationGasLimit)
if (userOperation.factory) rpc.factory = userOperation.factory
if (userOperation.factoryData) rpc.factoryData = userOperation.factoryData
if (userOperation.initCode) rpc.initCode = userOperation.initCode
if (userOperation.paymaster) rpc.paymaster = userOperation.paymaster
if (userOperation.paymasterData)
rpc.paymasterData = userOperation.paymasterData
if (typeof userOperation.paymasterPostOpGasLimit === 'bigint')
rpc.paymasterPostOpGasLimit = Hex.fromNumber(
userOperation.paymasterPostOpGasLimit,
)
if (typeof userOperation.paymasterVerificationGasLimit === 'bigint')
rpc.paymasterVerificationGasLimit = Hex.fromNumber(
userOperation.paymasterVerificationGasLimit,
)
if (userOperation.signature) rpc.signature = userOperation.signature
return rpc
}
export declare namespace toRpc {
export type ErrorType = Hex.fromNumber.ErrorType | Errors.GlobalErrorType
}

6
node_modules/ox/erc4337/UserOperation/package.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../../_types/erc4337/UserOperation.d.ts",
"main": "../../_cjs/erc4337/UserOperation.js",
"module": "../../_esm/erc4337/UserOperation.js"
}

109
node_modules/ox/erc4337/UserOperationGas.ts generated vendored Normal file
View File

@@ -0,0 +1,109 @@
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)
>
/** RPC User Operation Gas on EntryPoint 0.6 */
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>
/**
* 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 function fromRpc(rpc: Rpc): UserOperationGas {
return {
...rpc,
callGasLimit: BigInt(rpc.callGasLimit),
preVerificationGas: BigInt(rpc.preVerificationGas),
verificationGasLimit: BigInt(rpc.verificationGasLimit),
...(rpc.paymasterVerificationGasLimit && {
paymasterVerificationGasLimit: BigInt(rpc.paymasterVerificationGasLimit),
}),
...(rpc.paymasterPostOpGasLimit && {
paymasterPostOpGasLimit: BigInt(rpc.paymasterPostOpGasLimit),
}),
} as UserOperationGas
}
/**
* 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 function toRpc(userOperationGas: UserOperationGas): Rpc {
const rpc = {} as Rpc
rpc.callGasLimit = Hex.fromNumber(userOperationGas.callGasLimit)
rpc.preVerificationGas = Hex.fromNumber(userOperationGas.preVerificationGas)
rpc.verificationGasLimit = Hex.fromNumber(
userOperationGas.verificationGasLimit,
)
if (typeof userOperationGas.paymasterVerificationGasLimit === 'bigint')
rpc.paymasterVerificationGasLimit = Hex.fromNumber(
userOperationGas.paymasterVerificationGasLimit,
)
if (typeof userOperationGas.paymasterPostOpGasLimit === 'bigint')
rpc.paymasterPostOpGasLimit = Hex.fromNumber(
userOperationGas.paymasterPostOpGasLimit,
)
return rpc
}

View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../../_types/erc4337/UserOperationGas.d.ts",
"main": "../../_cjs/erc4337/UserOperationGas.js",
"module": "../../_esm/erc4337/UserOperationGas.js"
}

139
node_modules/ox/erc4337/UserOperationReceipt.ts generated vendored Normal file
View File

@@ -0,0 +1,139 @@
import type * as Address from '../core/Address.js'
import * as Hex from '../core/Hex.js'
import * as Log from '../core/Log.js'
import * as TransactionReceipt from '../core/TransactionReceipt.js'
import type * as EntryPoint from './EntryPoint.js'
/**
* User Operation Receipt type.
*
* @see https://eips.ethereum.org/EIPS/eip-4337#-eth_getuseroperationreceipt
*/
export type UserOperationReceipt<
_entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
bigIntType = bigint,
intType = number,
receipt = TransactionReceipt.TransactionReceipt<
TransactionReceipt.Status,
TransactionReceipt.Type,
bigIntType,
intType
>,
> = {
/** Actual gas cost. */
actualGasCost: bigIntType
/** Actual gas used. */
actualGasUsed: bigIntType
/** Entrypoint address. */
entryPoint: Address.Address
/** Logs emitted during execution. */
logs: Log.Log<false, bigIntType, intType>[]
/** Anti-replay parameter. */
nonce: bigIntType
/** Paymaster for the user operation. */
paymaster?: Address.Address | undefined
/** Revert reason, if unsuccessful. */
reason?: string | undefined
/** Transaction receipt of the user operation execution. */
receipt: receipt
/** The account sending the user operation. */
sender: Address.Address
/** If the user operation execution was successful. */
success: boolean
/** Hash of the user operation. */
userOpHash: Hex.Hex
}
/** RPC User Operation Receipt on EntryPoint 0.6 */
export type Rpc<
entryPointVersion extends EntryPoint.Version = EntryPoint.Version,
> = UserOperationReceipt<
entryPointVersion,
Hex.Hex,
Hex.Hex,
TransactionReceipt.TransactionReceipt<
TransactionReceipt.RpcStatus,
TransactionReceipt.RpcType,
Hex.Hex,
Hex.Hex
>
>
/**
* Converts an {@link ox#UserOperationReceipt.Rpc} to an {@link ox#UserOperationReceipt.UserOperationReceipt}.
*
* @example
* ```ts twoslash
* // @noErrors
* import { UserOperationReceipt } from 'ox/erc4337'
*
* const userOperationReceipt = UserOperationReceipt.fromRpc({
* actualGasCost: '0x1',
* actualGasUsed: '0x2',
* entryPoint: '0x0000000071727de22e5e9d8baf0edac6f37da032',
* logs: [],
* nonce: '0x1',
* receipt: { ... },
* sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
* success: true,
* userOpHash: '0x5ab163e9b2f30549274c7c567ca0696edf9ef1aa476d9784d22974468fdb24d8',
* })
* ```
*
* @param rpc - The RPC user operation receipt to convert.
* @returns An instantiated {@link ox#UserOperationReceipt.UserOperationReceipt}.
*/
export function fromRpc(rpc: Rpc): UserOperationReceipt {
return {
...rpc,
actualGasCost: BigInt(rpc.actualGasCost),
actualGasUsed: BigInt(rpc.actualGasUsed),
logs: rpc.logs.map((log) => Log.fromRpc(log)),
nonce: BigInt(rpc.nonce),
receipt: TransactionReceipt.fromRpc(rpc.receipt),
} as UserOperationReceipt
}
/**
* Converts a {@link ox#UserOperationReceipt.UserOperationReceipt} to a {@link ox#UserOperationReceipt.Rpc}.
*
* @example
* ```ts twoslash
* // @noErrors
* import { UserOperationReceipt } from 'ox/erc4337'
*
* const userOperationReceipt = UserOperationReceipt.toRpc({
* actualGasCost: 1n,
* actualGasUsed: 2n,
* entryPoint: '0x0000000071727de22e5e9d8baf0edac6f37da032',
* logs: [],
* nonce: 1n,
* receipt: { ... },
* sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
* success: true,
* userOpHash: '0x5ab163e9b2f30549274c7c567ca0696edf9ef1aa476d9784d22974468fdb24d8',
* })
* ```
*
* @param userOperationReceipt - The user operation receipt to convert.
* @returns An RPC-formatted user operation receipt.
*/
export function toRpc(userOperationReceipt: UserOperationReceipt): Rpc {
const rpc = {} as Rpc
rpc.actualGasCost = Hex.fromNumber(userOperationReceipt.actualGasCost)
rpc.actualGasUsed = Hex.fromNumber(userOperationReceipt.actualGasUsed)
rpc.entryPoint = userOperationReceipt.entryPoint
rpc.logs = userOperationReceipt.logs.map((log) => Log.toRpc(log))
rpc.nonce = Hex.fromNumber(userOperationReceipt.nonce)
rpc.receipt = TransactionReceipt.toRpc(userOperationReceipt.receipt)
rpc.sender = userOperationReceipt.sender
rpc.success = userOperationReceipt.success
rpc.userOpHash = userOperationReceipt.userOpHash
if (userOperationReceipt.paymaster)
rpc.paymaster = userOperationReceipt.paymaster
if (userOperationReceipt.reason) rpc.reason = userOperationReceipt.reason
return rpc
}

View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../../_types/erc4337/UserOperationReceipt.d.ts",
"main": "../../_cjs/erc4337/UserOperationReceipt.js",
"module": "../../_esm/erc4337/UserOperationReceipt.js"
}

38
node_modules/ox/erc4337/index.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
/** @entrypointCategory ERCs */
// biome-ignore lint/complexity/noUselessEmptyExport: tsdoc
export type {}
/**
* Utility functions and types for working with [ERC-4337 EntryPoints](https://eips.ethereum.org/EIPS/eip-4337).
*
* @category ERC-4337
*/
export * as EntryPoint from './EntryPoint.js'
/**
* Utility types for working with ERC-4337 JSON-RPC schemas.
*
* @category ERC-4337
*/
export * as RpcSchema from './RpcSchema.js'
/**
* Utility functions and types for working with [ERC-4337 User Operations](https://eips.ethereum.org/EIPS/eip-4337).
*
* @category ERC-4337
*/
export * as UserOperation from './UserOperation.js'
/**
* Utility functions and types for working with [ERC-4337 User Operation Gas](https://eips.ethereum.org/EIPS/eip-4337).
*
* @category ERC-4337
*/
export * as UserOperationGas from './UserOperationGas.js'
/**
* Utility functions and types for working with [ERC-4337 User Operation Receipts](https://eips.ethereum.org/EIPS/eip-4337).
*
* @category ERC-4337
*/
export * as UserOperationReceipt from './UserOperationReceipt.js'

6
node_modules/ox/erc4337/package.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"type": "module",
"types": "../_types/erc4337/index.d.ts",
"main": "../_cjs/erc4337/index.js",
"module": "../_esm/erc4337/index.js"
}