Files
FrenoCorp/node_modules/viem/errors/chain.ts
Michael Freno 7c684a42cc 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>
2026-04-25 00:08:01 -04:00

106 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Chain } from '../types/chain.js'
import { BaseError } from './base.js'
export type ChainDoesNotSupportContractErrorType =
ChainDoesNotSupportContract & {
name: 'ChainDoesNotSupportContract'
}
export class ChainDoesNotSupportContract extends BaseError {
constructor({
blockNumber,
chain,
contract,
}: {
blockNumber?: bigint | undefined
chain: Chain
contract: { name: string; blockCreated?: number | undefined }
}) {
super(
`Chain "${chain.name}" does not support contract "${contract.name}".`,
{
metaMessages: [
'This could be due to any of the following:',
...(blockNumber &&
contract.blockCreated &&
contract.blockCreated > blockNumber
? [
`- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`,
]
: [
`- The chain does not have the contract "${contract.name}" configured.`,
]),
],
name: 'ChainDoesNotSupportContract',
},
)
}
}
export type ChainMismatchErrorType = ChainMismatchError & {
name: 'ChainMismatchError'
}
export class ChainMismatchError extends BaseError {
constructor({
chain,
currentChainId,
}: {
chain: Chain
currentChainId: number
}) {
super(
`The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} ${chain.name}).`,
{
metaMessages: [
`Current Chain ID: ${currentChainId}`,
`Expected Chain ID: ${chain.id} ${chain.name}`,
],
name: 'ChainMismatchError',
},
)
}
}
export type ChainNotFoundErrorType = ChainNotFoundError & {
name: 'ChainNotFoundError'
}
export class ChainNotFoundError extends BaseError {
constructor() {
super(
[
'No chain was provided to the request.',
'Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient.',
].join('\n'),
{
name: 'ChainNotFoundError',
},
)
}
}
export type ClientChainNotConfiguredErrorType =
ClientChainNotConfiguredError & {
name: 'ClientChainNotConfiguredError'
}
export class ClientChainNotConfiguredError extends BaseError {
constructor() {
super('No chain was provided to the Client.', {
name: 'ClientChainNotConfiguredError',
})
}
}
export type InvalidChainIdErrorType = InvalidChainIdError & {
name: 'InvalidChainIdError'
}
export class InvalidChainIdError extends BaseError {
constructor({ chainId }: { chainId?: number | undefined }) {
super(
typeof chainId === 'number'
? `Chain ID "${chainId}" is invalid.`
: 'Chain ID is invalid.',
{ name: 'InvalidChainIdError' },
)
}
}