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

46
node_modules/viem/utils/errors/getCallError.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import type { CallParameters } from '../../actions/public/call.js'
import type { BaseError } from '../../errors/base.js'
import {
CallExecutionError,
type CallExecutionErrorType,
} from '../../errors/contract.js'
import { UnknownNodeError } from '../../errors/node.js'
import type { ErrorType } from '../../errors/utils.js'
import type { Chain } from '../../types/chain.js'
import {
type GetNodeErrorParameters,
type GetNodeErrorReturnType,
getNodeError,
} from './getNodeError.js'
export type GetCallErrorReturnType<cause = ErrorType> = Omit<
CallExecutionErrorType,
'cause'
> & {
cause: cause | GetNodeErrorReturnType
}
export function getCallError<err extends ErrorType<string>>(
err: err,
{
docsPath,
...args
}: CallParameters & {
chain?: Chain | undefined
docsPath?: string | undefined
},
): GetCallErrorReturnType<err> {
const cause = (() => {
const cause = getNodeError(
err as {} as BaseError,
args as GetNodeErrorParameters,
)
if (cause instanceof UnknownNodeError) return err as {} as BaseError
return cause
})()
return new CallExecutionError(cause, {
docsPath,
...args,
}) as GetCallErrorReturnType<err>
}

90
node_modules/viem/utils/errors/getContractError.ts generated vendored Normal file
View File

@@ -0,0 +1,90 @@
import type { Abi, Address } from 'abitype'
import { AbiDecodingZeroDataError } from '../../errors/abi.js'
import { BaseError } from '../../errors/base.js'
import {
ContractFunctionExecutionError,
type ContractFunctionExecutionErrorType,
ContractFunctionRevertedError,
type ContractFunctionRevertedErrorType,
ContractFunctionZeroDataError,
type ContractFunctionZeroDataErrorType,
RawContractError,
} from '../../errors/contract.js'
import { RpcRequestError } from '../../errors/request.js'
import { InternalRpcError, InvalidInputRpcError } from '../../errors/rpc.js'
import type { ErrorType } from '../../errors/utils.js'
const EXECUTION_REVERTED_ERROR_CODE = 3
export type GetContractErrorReturnType<cause = ErrorType> = Omit<
ContractFunctionExecutionErrorType,
'cause'
> & {
cause:
| cause
| ContractFunctionZeroDataErrorType
| ContractFunctionRevertedErrorType
}
export function getContractError<err extends ErrorType<string>>(
err: err,
{
abi,
address,
args,
docsPath,
functionName,
sender,
}: {
abi: Abi
args: any
address?: Address | undefined
docsPath?: string | undefined
functionName: string
sender?: Address | undefined
},
): GetContractErrorReturnType {
const error = (
err instanceof RawContractError
? err
: err instanceof BaseError
? err.walk((err) => 'data' in (err as Error)) || err.walk()
: {}
) as BaseError
const { code, data, details, message, shortMessage } =
error as RawContractError
const cause = (() => {
if (err instanceof AbiDecodingZeroDataError)
return new ContractFunctionZeroDataError({ functionName, cause: err })
if (
([EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) &&
(data || details || message || shortMessage)) ||
(code === InvalidInputRpcError.code &&
details === 'execution reverted' &&
data)
) {
return new ContractFunctionRevertedError({
abi,
data: typeof data === 'object' ? data.data : data,
functionName,
message:
error instanceof RpcRequestError
? details
: (shortMessage ?? message),
cause: err,
})
}
return err
})()
return new ContractFunctionExecutionError(cause as BaseError, {
abi,
args,
contractAddress: address,
docsPath,
functionName,
sender,
}) as GetContractErrorReturnType
}

46
node_modules/viem/utils/errors/getEstimateGasError.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import type { Account } from '../../accounts/types.js'
import type { EstimateGasParameters } from '../../actions/public/estimateGas.js'
import type { BaseError } from '../../errors/base.js'
import {
EstimateGasExecutionError,
type EstimateGasExecutionErrorType,
} from '../../errors/estimateGas.js'
import { UnknownNodeError } from '../../errors/node.js'
import type { ErrorType } from '../../errors/utils.js'
import type { Chain } from '../../types/chain.js'
import {
type GetNodeErrorParameters,
type GetNodeErrorReturnType,
getNodeError,
} from './getNodeError.js'
export type GetEstimateGasErrorReturnType<cause = ErrorType> = Omit<
EstimateGasExecutionErrorType,
'cause'
> & { cause: cause | GetNodeErrorReturnType }
export function getEstimateGasError<err extends ErrorType<string>>(
err: err,
{
docsPath,
...args
}: Omit<EstimateGasParameters, 'account'> & {
account?: Account | undefined
chain?: Chain | undefined
docsPath?: string | undefined
},
): GetEstimateGasErrorReturnType<err> {
const cause = (() => {
const cause = getNodeError(
err as {} as BaseError,
args as GetNodeErrorParameters,
)
if (cause instanceof UnknownNodeError) return err as {} as BaseError
return cause
})()
return new EstimateGasExecutionError(cause, {
docsPath,
...args,
}) as GetEstimateGasErrorReturnType<err>
}

119
node_modules/viem/utils/errors/getNodeError.ts generated vendored Normal file
View File

@@ -0,0 +1,119 @@
import type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'
import { BaseError } from '../../errors/base.js'
import {
ExecutionRevertedError,
type ExecutionRevertedErrorType,
FeeCapTooHighError,
type FeeCapTooHighErrorType,
FeeCapTooLowError,
type FeeCapTooLowErrorType,
InsufficientFundsError,
type InsufficientFundsErrorType,
IntrinsicGasTooHighError,
type IntrinsicGasTooHighErrorType,
IntrinsicGasTooLowError,
type IntrinsicGasTooLowErrorType,
NonceMaxValueError,
type NonceMaxValueErrorType,
NonceTooHighError,
type NonceTooHighErrorType,
NonceTooLowError,
type NonceTooLowErrorType,
TipAboveFeeCapError,
type TipAboveFeeCapErrorType,
TransactionTypeNotSupportedError,
type TransactionTypeNotSupportedErrorType,
UnknownNodeError,
type UnknownNodeErrorType,
} from '../../errors/node.js'
import { RpcRequestError } from '../../errors/request.js'
import {
InvalidInputRpcError,
TransactionRejectedRpcError,
} from '../../errors/rpc.js'
import type { ExactPartial } from '../../types/utils.js'
export function containsNodeError(err: BaseError) {
return (
err instanceof TransactionRejectedRpcError ||
err instanceof InvalidInputRpcError ||
(err instanceof RpcRequestError && err.code === ExecutionRevertedError.code)
)
}
export type GetNodeErrorParameters = ExactPartial<
SendTransactionParameters<any>
>
export type GetNodeErrorReturnType =
| ExecutionRevertedErrorType
| FeeCapTooHighErrorType
| FeeCapTooLowErrorType
| NonceTooHighErrorType
| NonceTooLowErrorType
| NonceMaxValueErrorType
| InsufficientFundsErrorType
| IntrinsicGasTooHighErrorType
| IntrinsicGasTooLowErrorType
| TransactionTypeNotSupportedErrorType
| TipAboveFeeCapErrorType
| UnknownNodeErrorType
export function getNodeError(
err: BaseError,
args: GetNodeErrorParameters,
): GetNodeErrorReturnType {
const message = (err.details || '').toLowerCase()
const executionRevertedError =
err instanceof BaseError
? err.walk(
(e) =>
(e as { code: number } | null | undefined)?.code ===
ExecutionRevertedError.code,
)
: err
if (executionRevertedError instanceof BaseError)
return new ExecutionRevertedError({
cause: err,
message: executionRevertedError.details,
}) as any
if (ExecutionRevertedError.nodeMessage.test(message))
return new ExecutionRevertedError({
cause: err,
message: err.details,
}) as any
if (FeeCapTooHighError.nodeMessage.test(message))
return new FeeCapTooHighError({
cause: err,
maxFeePerGas: args?.maxFeePerGas,
}) as any
if (FeeCapTooLowError.nodeMessage.test(message))
return new FeeCapTooLowError({
cause: err,
maxFeePerGas: args?.maxFeePerGas,
}) as any
if (NonceTooHighError.nodeMessage.test(message))
return new NonceTooHighError({ cause: err, nonce: args?.nonce }) as any
if (NonceTooLowError.nodeMessage.test(message))
return new NonceTooLowError({ cause: err, nonce: args?.nonce }) as any
if (NonceMaxValueError.nodeMessage.test(message))
return new NonceMaxValueError({ cause: err, nonce: args?.nonce }) as any
if (InsufficientFundsError.nodeMessage.test(message))
return new InsufficientFundsError({ cause: err }) as any
if (IntrinsicGasTooHighError.nodeMessage.test(message))
return new IntrinsicGasTooHighError({ cause: err, gas: args?.gas }) as any
if (IntrinsicGasTooLowError.nodeMessage.test(message))
return new IntrinsicGasTooLowError({ cause: err, gas: args?.gas }) as any
if (TransactionTypeNotSupportedError.nodeMessage.test(message))
return new TransactionTypeNotSupportedError({ cause: err }) as any
if (TipAboveFeeCapError.nodeMessage.test(message))
return new TipAboveFeeCapError({
cause: err,
maxFeePerGas: args?.maxFeePerGas,
maxPriorityFeePerGas: args?.maxPriorityFeePerGas,
}) as any
return new UnknownNodeError({
cause: err,
}) as any
}

48
node_modules/viem/utils/errors/getTransactionError.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import type { Account } from '../../accounts/types.js'
import type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'
import type { BaseError } from '../../errors/base.js'
import { UnknownNodeError } from '../../errors/node.js'
import {
TransactionExecutionError,
type TransactionExecutionErrorType,
} from '../../errors/transaction.js'
import type { ErrorType } from '../../errors/utils.js'
import type { Chain } from '../../types/chain.js'
import {
type GetNodeErrorParameters,
type GetNodeErrorReturnType,
getNodeError,
} from './getNodeError.js'
export type GetTransactionErrorParameters = Omit<
SendTransactionParameters,
'account' | 'chain'
> & {
account: Account | null
chain?: Chain | undefined
docsPath?: string | undefined
}
export type GetTransactionErrorReturnType<cause = ErrorType> = Omit<
TransactionExecutionErrorType,
'cause'
> & { cause: cause | GetNodeErrorReturnType }
export function getTransactionError<err extends ErrorType<string>>(
err: err,
{ docsPath, ...args }: GetTransactionErrorParameters,
): GetTransactionErrorReturnType<err> {
const cause = (() => {
const cause = getNodeError(
err as {} as BaseError,
args as GetNodeErrorParameters,
)
if (cause instanceof UnknownNodeError) return err as {} as BaseError
return cause
})()
return new TransactionExecutionError(cause, {
docsPath,
...args,
}) as GetTransactionErrorReturnType<err>
}