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

14
node_modules/viem/utils/hash/hashSignature.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import type { ErrorType } from '../../errors/utils.js'
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
import { type Keccak256ErrorType, keccak256 } from './keccak256.js'
const hash = (value: string) => keccak256(toBytes(value))
export type HashSignatureErrorType =
| Keccak256ErrorType
| ToBytesErrorType
| ErrorType
export function hashSignature(sig: string) {
return hash(sig)
}

10
node_modules/viem/utils/hash/isHash.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { ErrorType } from '../../errors/utils.js'
import type { Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from '../data/isHex.js'
import { type SizeErrorType, size } from '../data/size.js'
export type IsHashErrorType = IsHexErrorType | SizeErrorType | ErrorType
export function isHash(hash: string): hash is Hex {
return isHex(hash) && size(hash) === 32
}

31
node_modules/viem/utils/hash/keccak256.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { keccak_256 } from '@noble/hashes/sha3'
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from '../data/isHex.js'
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
import { type ToHexErrorType, toHex } from '../encoding/toHex.js'
type To = 'hex' | 'bytes'
export type Keccak256Hash<to extends To> =
| (to extends 'bytes' ? ByteArray : never)
| (to extends 'hex' ? Hex : never)
export type Keccak256ErrorType =
| IsHexErrorType
| ToBytesErrorType
| ToHexErrorType
| ErrorType
export function keccak256<to extends To = 'hex'>(
value: Hex | ByteArray,
to_?: to | undefined,
): Keccak256Hash<to> {
const to = to_ || 'hex'
const bytes = keccak_256(
isHex(value, { strict: false }) ? toBytes(value) : value,
)
if (to === 'bytes') return bytes as Keccak256Hash<to>
return toHex(bytes) as Keccak256Hash<to>
}

64
node_modules/viem/utils/hash/normalizeSignature.ts generated vendored Normal file
View File

@@ -0,0 +1,64 @@
import { BaseError } from '../../errors/base.js'
import type { ErrorType } from '../../errors/utils.js'
type NormalizeSignatureParameters = string
type NormalizeSignatureReturnType = string
export type NormalizeSignatureErrorType = ErrorType
export function normalizeSignature(
signature: NormalizeSignatureParameters,
): NormalizeSignatureReturnType {
let active = true
let current = ''
let level = 0
let result = ''
let valid = false
for (let i = 0; i < signature.length; i++) {
const char = signature[i]
// If the character is a separator, we want to reactivate.
if (['(', ')', ','].includes(char)) active = true
// If the character is a "level" token, we want to increment/decrement.
if (char === '(') level++
if (char === ')') level--
// If we aren't active, we don't want to mutate the result.
if (!active) continue
// If level === 0, we are at the definition level.
if (level === 0) {
if (char === ' ' && ['event', 'function', ''].includes(result))
result = ''
else {
result += char
// If we are at the end of the definition, we must be finished.
if (char === ')') {
valid = true
break
}
}
continue
}
// Ignore spaces
if (char === ' ') {
// If the previous character is a separator, and the current section isn't empty, we want to deactivate.
if (signature[i - 1] !== ',' && current !== ',' && current !== ',(') {
current = ''
active = false
}
continue
}
result += char
current += char
}
if (!valid) throw new BaseError('Unable to normalize signature.')
return result
}

31
node_modules/viem/utils/hash/ripemd160.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { ripemd160 as noble_ripemd160 } from '@noble/hashes/ripemd160'
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from '../data/isHex.js'
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
import { type ToHexErrorType, toHex } from '../encoding/toHex.js'
type To = 'hex' | 'bytes'
export type Ripemd160Hash<to extends To> =
| (to extends 'bytes' ? ByteArray : never)
| (to extends 'hex' ? Hex : never)
export type Ripemd160ErrorType =
| IsHexErrorType
| ToBytesErrorType
| ToHexErrorType
| ErrorType
export function ripemd160<to extends To = 'hex'>(
value: Hex | ByteArray,
to_?: to | undefined,
): Ripemd160Hash<to> {
const to = to_ || 'hex'
const bytes = noble_ripemd160(
isHex(value, { strict: false }) ? toBytes(value) : value,
)
if (to === 'bytes') return bytes as Ripemd160Hash<to>
return toHex(bytes) as Ripemd160Hash<to>
}

31
node_modules/viem/utils/hash/sha256.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { sha256 as noble_sha256 } from '@noble/hashes/sha256'
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from '../data/isHex.js'
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
import { type ToHexErrorType, toHex } from '../encoding/toHex.js'
type To = 'hex' | 'bytes'
export type Sha256Hash<to extends To> =
| (to extends 'bytes' ? ByteArray : never)
| (to extends 'hex' ? Hex : never)
export type Sha256ErrorType =
| IsHexErrorType
| ToBytesErrorType
| ToHexErrorType
| ErrorType
export function sha256<to extends To = 'hex'>(
value: Hex | ByteArray,
to_?: to | undefined,
): Sha256Hash<to> {
const to = to_ || 'hex'
const bytes = noble_sha256(
isHex(value, { strict: false }) ? toBytes(value) : value,
)
if (to === 'bytes') return bytes as Sha256Hash<to>
return toHex(bytes) as Sha256Hash<to>
}

5
node_modules/viem/utils/hash/toEventHash.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// biome-ignore lint/performance/noBarrelFile: intentional
export {
type ToSignatureHashErrorType as ToEventHashErrorType,
toSignatureHash as toEventHash,
} from './toSignatureHash.js'

16
node_modules/viem/utils/hash/toEventSelector.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import type { ErrorType } from '../../errors/utils.js'
import {
type ToSignatureHashErrorType,
toSignatureHash,
} from './toSignatureHash.js'
export type ToEventSelectorErrorType = ToSignatureHashErrorType | ErrorType
/**
* Returns the event selector for a given event definition.
*
* @example
* const selector = toEventSelector('Transfer(address indexed from, address indexed to, uint256 amount)')
* // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
*/
export const toEventSelector = toSignatureHash

5
node_modules/viem/utils/hash/toEventSignature.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// biome-ignore lint/performance/noBarrelFile: intentional
export {
type ToSignatureErrorType as ToEventSignatureErrorType,
toSignature as toEventSignature,
} from './toSignature.js'

5
node_modules/viem/utils/hash/toFunctionHash.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// biome-ignore lint/performance/noBarrelFile: intentional
export {
type ToSignatureHashErrorType as ToFunctionHashErrorType,
toSignatureHash as toFunctionHash,
} from './toSignatureHash.js'

23
node_modules/viem/utils/hash/toFunctionSelector.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import type { AbiFunction } from 'abitype'
import type { ErrorType } from '../../errors/utils.js'
import { type SliceErrorType, slice } from '../data/slice.js'
import {
type ToSignatureHashErrorType,
toSignatureHash,
} from './toSignatureHash.js'
export type ToFunctionSelectorErrorType =
| ToSignatureHashErrorType
| SliceErrorType
| ErrorType
/**
* Returns the function selector for a given function definition.
*
* @example
* const selector = toFunctionSelector('function ownerOf(uint256 tokenId)')
* // 0x6352211e
*/
export const toFunctionSelector = (fn: string | AbiFunction) =>
slice(toSignatureHash(fn), 0, 4)

5
node_modules/viem/utils/hash/toFunctionSignature.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// biome-ignore lint/performance/noBarrelFile: intentional
export {
type ToSignatureErrorType as ToFunctionSignatureErrorType,
toSignature as toFunctionSignature,
} from './toSignature.js'

34
node_modules/viem/utils/hash/toSignature.ts generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import { type AbiEvent, type AbiFunction, formatAbiItem } from 'abitype'
import type { ErrorType } from '../../errors/utils.js'
import {
type NormalizeSignatureErrorType,
normalizeSignature,
} from './normalizeSignature.js'
export type ToSignatureErrorType = NormalizeSignatureErrorType | ErrorType
/**
* Returns the signature for a given function or event definition.
*
* @example
* const signature = toSignature('function ownerOf(uint256 tokenId)')
* // 'ownerOf(uint256)'
*
* @example
* const signature_3 = toSignature({
* name: 'ownerOf',
* type: 'function',
* inputs: [{ name: 'tokenId', type: 'uint256' }],
* outputs: [],
* stateMutability: 'view',
* })
* // 'ownerOf(uint256)'
*/
export const toSignature = (def: string | AbiFunction | AbiEvent) => {
const def_ = (() => {
if (typeof def === 'string') return def
return formatAbiItem(def)
})()
return normalizeSignature(def_)
}

17
node_modules/viem/utils/hash/toSignatureHash.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { AbiEvent, AbiFunction } from 'abitype'
import type { ErrorType } from '../../errors/utils.js'
import { type HashSignatureErrorType, hashSignature } from './hashSignature.js'
import { type ToSignatureErrorType, toSignature } from './toSignature.js'
export type ToSignatureHashErrorType =
| HashSignatureErrorType
| ToSignatureErrorType
| ErrorType
/**
* Returns the hash (of the function/event signature) for a given event or function definition.
*/
export function toSignatureHash(fn: string | AbiFunction | AbiEvent) {
return hashSignature(toSignature(fn))
}