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

44
node_modules/viem/utils/data/concat.ts generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
export type ConcatReturnType<value extends Hex | ByteArray> = value extends Hex
? Hex
: ByteArray
export type ConcatErrorType =
| ConcatBytesErrorType
| ConcatHexErrorType
| ErrorType
export function concat<value extends Hex | ByteArray>(
values: readonly value[],
): ConcatReturnType<value> {
if (typeof values[0] === 'string')
return concatHex(values as readonly Hex[]) as ConcatReturnType<value>
return concatBytes(values as readonly ByteArray[]) as ConcatReturnType<value>
}
export type ConcatBytesErrorType = ErrorType
export function concatBytes(values: readonly ByteArray[]): ByteArray {
let length = 0
for (const arr of values) {
length += arr.length
}
const result = new Uint8Array(length)
let offset = 0
for (const arr of values) {
result.set(arr, offset)
offset += arr.length
}
return result
}
export type ConcatHexErrorType = ErrorType
export function concatHex(values: readonly Hex[]): Hex {
return `0x${(values as Hex[]).reduce(
(acc, x) => acc + x.replace('0x', ''),
'',
)}`
}

13
node_modules/viem/utils/data/isBytes.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray } from '../../types/misc.js'
export type IsBytesErrorType = ErrorType
export function isBytes(value: unknown): value is ByteArray {
if (!value) return false
if (typeof value !== 'object') return false
if (!('BYTES_PER_ELEMENT' in value)) return false
return (
value.BYTES_PER_ELEMENT === 1 && value.constructor.name === 'Uint8Array'
)
}

13
node_modules/viem/utils/data/isHex.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import type { ErrorType } from '../../errors/utils.js'
import type { Hex } from '../../types/misc.js'
export type IsHexErrorType = ErrorType
export function isHex(
value: unknown,
{ strict = true }: { strict?: boolean | undefined } = {},
): value is Hex {
if (!value) return false
if (typeof value !== 'string') return false
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x')
}

65
node_modules/viem/utils/data/pad.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
import {
SizeExceedsPaddingSizeError,
type SizeExceedsPaddingSizeErrorType,
} from '../../errors/data.js'
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
type PadOptions = {
dir?: 'left' | 'right' | undefined
size?: number | null | undefined
}
export type PadReturnType<value extends ByteArray | Hex> = value extends Hex
? Hex
: ByteArray
export type PadErrorType = PadHexErrorType | PadBytesErrorType | ErrorType
export function pad<value extends ByteArray | Hex>(
hexOrBytes: value,
{ dir, size = 32 }: PadOptions = {},
): PadReturnType<value> {
if (typeof hexOrBytes === 'string')
return padHex(hexOrBytes, { dir, size }) as PadReturnType<value>
return padBytes(hexOrBytes, { dir, size }) as PadReturnType<value>
}
export type PadHexErrorType = SizeExceedsPaddingSizeErrorType | ErrorType
export function padHex(hex_: Hex, { dir, size = 32 }: PadOptions = {}) {
if (size === null) return hex_
const hex = hex_.replace('0x', '')
if (hex.length > size * 2)
throw new SizeExceedsPaddingSizeError({
size: Math.ceil(hex.length / 2),
targetSize: size,
type: 'hex',
})
return `0x${hex[dir === 'right' ? 'padEnd' : 'padStart'](
size * 2,
'0',
)}` as Hex
}
export type PadBytesErrorType = SizeExceedsPaddingSizeErrorType | ErrorType
export function padBytes(
bytes: ByteArray,
{ dir, size = 32 }: PadOptions = {},
) {
if (size === null) return bytes
if (bytes.length > size)
throw new SizeExceedsPaddingSizeError({
size: bytes.length,
targetSize: size,
type: 'bytes',
})
const paddedBytes = new Uint8Array(size)
for (let i = 0; i < size; i++) {
const padEnd = dir === 'right'
paddedBytes[padEnd ? i : size - i - 1] =
bytes[padEnd ? i : bytes.length - i - 1]
}
return paddedBytes
}

17
node_modules/viem/utils/data/size.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from './isHex.js'
export type SizeErrorType = IsHexErrorType | ErrorType
/**
* @description Retrieves the size of the value (in bytes).
*
* @param value The value (hex or byte array) to retrieve the size of.
* @returns The size of the value (in bytes).
*/
export function size(value: Hex | ByteArray) {
if (isHex(value, { strict: false })) return Math.ceil((value.length - 2) / 2)
return value.length
}

128
node_modules/viem/utils/data/slice.ts generated vendored Normal file
View File

@@ -0,0 +1,128 @@
import {
SliceOffsetOutOfBoundsError,
type SliceOffsetOutOfBoundsErrorType,
} from '../../errors/data.js'
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
import { type IsHexErrorType, isHex } from './isHex.js'
import { type SizeErrorType, size } from './size.js'
export type SliceReturnType<value extends ByteArray | Hex> = value extends Hex
? Hex
: ByteArray
export type SliceErrorType =
| IsHexErrorType
| SliceBytesErrorType
| SliceHexErrorType
| ErrorType
/**
* @description Returns a section of the hex or byte array given a start/end bytes offset.
*
* @param value The hex or byte array to slice.
* @param start The start offset (in bytes).
* @param end The end offset (in bytes).
*/
export function slice<value extends ByteArray | Hex>(
value: value,
start?: number | undefined,
end?: number | undefined,
{ strict }: { strict?: boolean | undefined } = {},
): SliceReturnType<value> {
if (isHex(value, { strict: false }))
return sliceHex(value as Hex, start, end, {
strict,
}) as SliceReturnType<value>
return sliceBytes(value as ByteArray, start, end, {
strict,
}) as SliceReturnType<value>
}
export type AssertStartOffsetErrorType =
| SliceOffsetOutOfBoundsErrorType
| SizeErrorType
| ErrorType
function assertStartOffset(value: Hex | ByteArray, start?: number | undefined) {
if (typeof start === 'number' && start > 0 && start > size(value) - 1)
throw new SliceOffsetOutOfBoundsError({
offset: start,
position: 'start',
size: size(value),
})
}
export type AssertEndOffsetErrorType =
| SliceOffsetOutOfBoundsErrorType
| SizeErrorType
| ErrorType
function assertEndOffset(
value: Hex | ByteArray,
start?: number | undefined,
end?: number | undefined,
) {
if (
typeof start === 'number' &&
typeof end === 'number' &&
size(value) !== end - start
) {
throw new SliceOffsetOutOfBoundsError({
offset: end,
position: 'end',
size: size(value),
})
}
}
export type SliceBytesErrorType =
| AssertStartOffsetErrorType
| AssertEndOffsetErrorType
| ErrorType
/**
* @description Returns a section of the byte array given a start/end bytes offset.
*
* @param value The byte array to slice.
* @param start The start offset (in bytes).
* @param end The end offset (in bytes).
*/
export function sliceBytes(
value_: ByteArray,
start?: number | undefined,
end?: number | undefined,
{ strict }: { strict?: boolean | undefined } = {},
): ByteArray {
assertStartOffset(value_, start)
const value = value_.slice(start, end)
if (strict) assertEndOffset(value, start, end)
return value
}
export type SliceHexErrorType =
| AssertStartOffsetErrorType
| AssertEndOffsetErrorType
| ErrorType
/**
* @description Returns a section of the hex value given a start/end bytes offset.
*
* @param value The hex value to slice.
* @param start The start offset (in bytes).
* @param end The end offset (in bytes).
*/
export function sliceHex(
value_: Hex,
start?: number | undefined,
end?: number | undefined,
{ strict }: { strict?: boolean | undefined } = {},
): Hex {
assertStartOffset(value_, start)
const value = `0x${value_
.replace('0x', '')
.slice((start ?? 0) * 2, (end ?? value_.length) * 2)}` as const
if (strict) assertEndOffset(value, start, end)
return value
}

38
node_modules/viem/utils/data/trim.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'
type TrimOptions = {
dir?: 'left' | 'right' | undefined
}
export type TrimReturnType<value extends ByteArray | Hex> = value extends Hex
? Hex
: ByteArray
export type TrimErrorType = ErrorType
export function trim<value extends ByteArray | Hex>(
hexOrBytes: value,
{ dir = 'left' }: TrimOptions = {},
): TrimReturnType<value> {
let data: any =
typeof hexOrBytes === 'string' ? hexOrBytes.replace('0x', '') : hexOrBytes
let sliceLength = 0
for (let i = 0; i < data.length - 1; i++) {
if (data[dir === 'left' ? i : data.length - i - 1].toString() === '0')
sliceLength++
else break
}
data =
dir === 'left'
? data.slice(sliceLength)
: data.slice(0, data.length - sliceLength)
if (typeof hexOrBytes === 'string') {
if (data.length === 1 && dir === 'right') data = `${data}0`
return `0x${
data.length % 2 === 1 ? `0${data}` : data
}` as TrimReturnType<value>
}
return data as TrimReturnType<value>
}