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

241
node_modules/viem/_esm/utils/abi/decodeAbiParameters.js generated vendored Normal file
View File

@@ -0,0 +1,241 @@
import { AbiDecodingDataSizeTooSmallError, AbiDecodingZeroDataError, InvalidAbiDecodingTypeError, } from '../../errors/abi.js';
import { checksumAddress, } from '../address/getAddress.js';
import { createCursor, } from '../cursor.js';
import { size } from '../data/size.js';
import { sliceBytes } from '../data/slice.js';
import { trim } from '../data/trim.js';
import { bytesToBigInt, bytesToBool, bytesToNumber, bytesToString, } from '../encoding/fromBytes.js';
import { hexToBytes } from '../encoding/toBytes.js';
import { bytesToHex } from '../encoding/toHex.js';
import { getArrayComponents } from './encodeAbiParameters.js';
export function decodeAbiParameters(params, data) {
const bytes = typeof data === 'string' ? hexToBytes(data) : data;
const cursor = createCursor(bytes);
if (size(bytes) === 0 && params.length > 0)
throw new AbiDecodingZeroDataError();
if (size(data) && size(data) < 32)
throw new AbiDecodingDataSizeTooSmallError({
data: typeof data === 'string' ? data : bytesToHex(data),
params: params,
size: size(data),
});
let consumed = 0;
const values = [];
for (let i = 0; i < params.length; ++i) {
const param = params[i];
cursor.setPosition(consumed);
const [data, consumed_] = decodeParameter(cursor, param, {
staticPosition: 0,
});
consumed += consumed_;
values.push(data);
}
return values;
}
function decodeParameter(cursor, param, { staticPosition }) {
const arrayComponents = getArrayComponents(param.type);
if (arrayComponents) {
const [length, type] = arrayComponents;
return decodeArray(cursor, { ...param, type }, { length, staticPosition });
}
if (param.type === 'tuple')
return decodeTuple(cursor, param, { staticPosition });
if (param.type === 'address')
return decodeAddress(cursor);
if (param.type === 'bool')
return decodeBool(cursor);
if (param.type.startsWith('bytes'))
return decodeBytes(cursor, param, { staticPosition });
if (param.type.startsWith('uint') || param.type.startsWith('int'))
return decodeNumber(cursor, param);
if (param.type === 'string')
return decodeString(cursor, { staticPosition });
throw new InvalidAbiDecodingTypeError(param.type, {
docsPath: '/docs/contract/decodeAbiParameters',
});
}
////////////////////////////////////////////////////////////////////
// Type Decoders
const sizeOfLength = 32;
const sizeOfOffset = 32;
function decodeAddress(cursor) {
const value = cursor.readBytes(32);
return [checksumAddress(bytesToHex(sliceBytes(value, -20))), 32];
}
function decodeArray(cursor, param, { length, staticPosition }) {
// If the length of the array is not known in advance (dynamic array),
// this means we will need to wonder off to the pointer and decode.
if (!length) {
// Dealing with a dynamic type, so get the offset of the array data.
const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
// Start is the static position of current slot + offset.
const start = staticPosition + offset;
const startOfData = start + sizeOfLength;
// Get the length of the array from the offset.
cursor.setPosition(start);
const length = bytesToNumber(cursor.readBytes(sizeOfLength));
// Check if the array has any dynamic children.
const dynamicChild = hasDynamicChild(param);
let consumed = 0;
const value = [];
for (let i = 0; i < length; ++i) {
// If any of the children is dynamic, then all elements will be offset pointer, thus size of one slot (32 bytes).
// Otherwise, elements will be the size of their encoding (consumed bytes).
cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed));
const [data, consumed_] = decodeParameter(cursor, param, {
staticPosition: startOfData,
});
consumed += consumed_;
value.push(data);
}
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return [value, 32];
}
// If the length of the array is known in advance,
// and the length of an element deeply nested in the array is not known,
// we need to decode the offset of the array data.
if (hasDynamicChild(param)) {
// Dealing with dynamic types, so get the offset of the array data.
const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
// Start is the static position of current slot + offset.
const start = staticPosition + offset;
const value = [];
for (let i = 0; i < length; ++i) {
// Move cursor along to the next slot (next offset pointer).
cursor.setPosition(start + i * 32);
const [data] = decodeParameter(cursor, param, {
staticPosition: start,
});
value.push(data);
}
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return [value, 32];
}
// If the length of the array is known in advance and the array is deeply static,
// then we can just decode each element in sequence.
let consumed = 0;
const value = [];
for (let i = 0; i < length; ++i) {
const [data, consumed_] = decodeParameter(cursor, param, {
staticPosition: staticPosition + consumed,
});
consumed += consumed_;
value.push(data);
}
return [value, consumed];
}
function decodeBool(cursor) {
return [bytesToBool(cursor.readBytes(32), { size: 32 }), 32];
}
function decodeBytes(cursor, param, { staticPosition }) {
const [_, size] = param.type.split('bytes');
if (!size) {
// Dealing with dynamic types, so get the offset of the bytes data.
const offset = bytesToNumber(cursor.readBytes(32));
// Set position of the cursor to start of bytes data.
cursor.setPosition(staticPosition + offset);
const length = bytesToNumber(cursor.readBytes(32));
// If there is no length, we have zero data.
if (length === 0) {
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return ['0x', 32];
}
const data = cursor.readBytes(length);
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return [bytesToHex(data), 32];
}
const value = bytesToHex(cursor.readBytes(Number.parseInt(size, 10), 32));
return [value, 32];
}
function decodeNumber(cursor, param) {
const signed = param.type.startsWith('int');
const size = Number.parseInt(param.type.split('int')[1] || '256', 10);
const value = cursor.readBytes(32);
return [
size > 48
? bytesToBigInt(value, { signed })
: bytesToNumber(value, { signed }),
32,
];
}
function decodeTuple(cursor, param, { staticPosition }) {
// Tuples can have unnamed components (i.e. they are arrays), so we must
// determine whether the tuple is named or unnamed. In the case of a named
// tuple, the value will be an object where each property is the name of the
// component. In the case of an unnamed tuple, the value will be an array.
const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
// Initialize the value to an object or an array, depending on whether the
// tuple is named or unnamed.
const value = hasUnnamedChild ? [] : {};
let consumed = 0;
// If the tuple has a dynamic child, we must first decode the offset to the
// tuple data.
if (hasDynamicChild(param)) {
// Dealing with dynamic types, so get the offset of the tuple data.
const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
// Start is the static position of referencing slot + offset.
const start = staticPosition + offset;
for (let i = 0; i < param.components.length; ++i) {
const component = param.components[i];
cursor.setPosition(start + consumed);
const [data, consumed_] = decodeParameter(cursor, component, {
staticPosition: start,
});
consumed += consumed_;
value[hasUnnamedChild ? i : component?.name] = data;
}
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return [value, 32];
}
// If the tuple has static children, we can just decode each component
// in sequence.
for (let i = 0; i < param.components.length; ++i) {
const component = param.components[i];
const [data, consumed_] = decodeParameter(cursor, component, {
staticPosition,
});
value[hasUnnamedChild ? i : component?.name] = data;
consumed += consumed_;
}
return [value, consumed];
}
function decodeString(cursor, { staticPosition }) {
// Get offset to start of string data.
const offset = bytesToNumber(cursor.readBytes(32));
// Start is the static position of current slot + offset.
const start = staticPosition + offset;
cursor.setPosition(start);
const length = bytesToNumber(cursor.readBytes(32));
// If there is no length, we have zero data (empty string).
if (length === 0) {
cursor.setPosition(staticPosition + 32);
return ['', 32];
}
const data = cursor.readBytes(length, 32);
const value = bytesToString(trim(data));
// As we have gone wondering, restore to the original position + next slot.
cursor.setPosition(staticPosition + 32);
return [value, 32];
}
function hasDynamicChild(param) {
const { type } = param;
if (type === 'string')
return true;
if (type === 'bytes')
return true;
if (type.endsWith('[]'))
return true;
if (type === 'tuple')
return param.components?.some(hasDynamicChild);
const arrayComponents = getArrayComponents(param.type);
if (arrayComponents &&
hasDynamicChild({ ...param, type: arrayComponents[1] }))
return true;
return false;
}
//# sourceMappingURL=decodeAbiParameters.js.map

File diff suppressed because one or more lines are too long

18
node_modules/viem/_esm/utils/abi/decodeDeployData.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, } from '../../errors/abi.js';
import { decodeAbiParameters, } from './decodeAbiParameters.js';
const docsPath = '/docs/contract/decodeDeployData';
export function decodeDeployData(parameters) {
const { abi, bytecode, data } = parameters;
if (data === bytecode)
return { bytecode };
const description = abi.find((x) => 'type' in x && x.type === 'constructor');
if (!description)
throw new AbiConstructorNotFoundError({ docsPath });
if (!('inputs' in description))
throw new AbiConstructorParamsNotFoundError({ docsPath });
if (!description.inputs || description.inputs.length === 0)
throw new AbiConstructorParamsNotFoundError({ docsPath });
const args = decodeAbiParameters(description.inputs, `0x${data.replace(bytecode, '')}`);
return { args, bytecode };
}
//# sourceMappingURL=decodeDeployData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decodeDeployData.js","sourceRoot":"","sources":["../../../utils/abi/decodeDeployData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAE3B,iCAAiC,GAElC,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAEjC,MAAM,QAAQ,GAAG,iCAAiC,CAAA;AAyBlD,MAAM,UAAU,gBAAgB,CAC9B,UAA2C;IAE3C,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,UAAwC,CAAA;IACxE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,QAAQ,EAAqC,CAAA;IAE7E,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA;IAC5E,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrE,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,CAAC;QAC5B,MAAM,IAAI,iCAAiC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC3D,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QACxD,MAAM,IAAI,iCAAiC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAE3D,MAAM,IAAI,GAAG,mBAAmB,CAC9B,WAAW,CAAC,MAAM,EAClB,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAClC,CAAA;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAgD,CAAA;AACzE,CAAC"}

27
node_modules/viem/_esm/utils/abi/decodeErrorResult.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { solidityError, solidityPanic } from '../../constants/solidity.js';
import { AbiDecodingZeroDataError, AbiErrorSignatureNotFoundError, } from '../../errors/abi.js';
import { slice } from '../data/slice.js';
import { toFunctionSelector, } from '../hash/toFunctionSelector.js';
import { decodeAbiParameters, } from './decodeAbiParameters.js';
import { formatAbiItem } from './formatAbiItem.js';
export function decodeErrorResult(parameters) {
const { abi, data, cause } = parameters;
const signature = slice(data, 0, 4);
if (signature === '0x')
throw new AbiDecodingZeroDataError({ cause });
const abi_ = [...(abi || []), solidityError, solidityPanic];
const abiItem = abi_.find((x) => x.type === 'error' && signature === toFunctionSelector(formatAbiItem(x)));
if (!abiItem)
throw new AbiErrorSignatureNotFoundError(signature, {
docsPath: '/docs/contract/decodeErrorResult',
cause,
});
return {
abiItem,
args: 'inputs' in abiItem && abiItem.inputs && abiItem.inputs.length > 0
? decodeAbiParameters(abiItem.inputs, slice(data, 4))
: undefined,
errorName: abiItem.name,
};
}
//# sourceMappingURL=decodeErrorResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decodeErrorResult.js","sourceRoot":"","sources":["../../../utils/abi/decodeErrorResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC1E,OAAO,EACL,wBAAwB,EAExB,8BAA8B,GAE/B,MAAM,qBAAqB,CAAA;AAU5B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAEL,kBAAkB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izeTooSmallError, AbiEventSignatureEmptyTopicsError, AbiEventSignatureNotFoundError, DecodeLogDataMismatch, DecodeLogTopicsMismatch, } from '../../errors/abi.js';
import { PositionOutOfBoundsError } from '../../errors/cursor.js';
import { size } from '../data/size.js';
import { toEventSelector, } from '../hash/toEventSelector.js';
import { decodeAbiParameters, } from './decodeAbiParameters.js';
import { formatAbiItem } from './formatAbiItem.js';
const docsPath = '/docs/contract/decodeEventLog';
export function decodeEventLog(parameters) {
const { abi, data, strict: strict_, topics, } = parameters;
const strict = strict_ ?? true;
const [signature, ...argTopics] = topics;
if (!signature)
throw new AbiEventSignatureEmptyTopicsError({ docsPath });
const abiItem = abi.find((x) => x.type === 'event' &&
signature === toEventSelector(formatAbiItem(x)));
if (!(abiItem && 'name' in abiItem) || abiItem.type !== 'event')
throw new AbiEventSignatureNotFoundError(signature, { docsPath });
const { name, inputs } = abiItem;
const isUnnamed = inputs?.some((x) => !('name' in x && x.name));
const args = isUnnamed ? [] : {};
// Decode topics (indexed args).
const indexedInputs = inputs
.map((x, i) => [x, i])
.filter(([x]) => 'indexed' in x && x.indexed);
const missingIndexedInputs = [];
for (let i = 0; i < indexedInputs.length; i++) {
const [param, argIndex] = indexedInputs[i];
const topic = argTopics[i];
if (!topic) {
if (strict)
throw new DecodeLogTopicsMismatch({
abiItem,
param: param,
});
// Track missing indexed inputs to decode from data when strict is false
missingIndexedInputs.push([param, argIndex]);
continue;
}
args[isUnnamed ? argIndex : param.name || argIndex] = decodeTopic({
param,
value: topic,
});
}
// Decode data (non-indexed args + missing indexed args when strict is false).
const nonIndexedInputs = inputs.filter((x) => !('indexed' in x && x.indexed));
// When strict is false, missing indexed inputs should be decoded from data
const inputsToDecode = strict
? nonIndexedInputs
: [...missingIndexedInputs.map(([param]) => param), ...nonIndexedInputs];
if (inputsToDecode.length > 0) {
if (data && data !== '0x') {
try {
const decodedData = decodeAbiParameters(inputsToDecode, data);
if (decodedData) {
let dataIndex = 0;
// First, assign missing indexed parameters (when strict is false)
if (!strict) {
for (const [param, argIndex] of missingIndexedInputs) {
args[isUnnamed ? argIndex : param.name || argIndex] =
decodedData[dataIndex++];
}
}
// Then, assign non-indexed parameters
if (isUnnamed) {
for (let i = 0; i < inputs.length; i++)
if (args[i] === undefined && dataIndex < decodedData.length)
args[i] = decodedData[dataIndex++];
}
else
for (let i = 0; i < nonIndexedInputs.length; i++)
args[nonIndexedInputs[i].name] = decodedData[dataIndex++];
}
}
catch (err) {
if (strict) {
if (err instanceof AbiDecodingDataSizeTooSmallError ||
err instanceof PositionOutOfBoundsError)
throw new DecodeLogDataMismatch({
abiItem,
data: data,
params: inputsToDecode,
size: size(data),
});
throw err;
}
}
}
else if (strict) {
throw new DecodeLogDataMismatch({
abiItem,
data: '0x',
params: inputsToDecode,
size: 0,
});
}
}
return {
eventName: name,
args: Object.values(args).length > 0 ? args : undefined,
};
}
function decodeTopic({ param, value }) {
if (param.type === 'string' ||
param.type === 'bytes' ||
param.type === 'tuple' ||
param.type.match(/^(.*)\[(\d+)?\]$/))
return value;
const decodedArg = decodeAbiParameters([param], value) || [];
return decodedArg[0];
}
//# sourceMappingURL=decodeEventLog.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decodeEventLog.js","sourceRoot":"","sources":["../../../utils/abi/decodeEventLog.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gCAAgC,EAEhC,iCAAiC,EAEjC,8BAA8B,EAE9B,qBAAqB,EAErB,uBAAuB,GAExB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAajE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAEL,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA+B,aAAa,EAAE,MAAM,oBAAoB,CAAA;AA2D/E,MAAM,QAAQ,GAAG,+BAA+B,CAAA;AAE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IAAI,CAAC,IAAI,CAAC;yBACjB,CAAC,CAAA;oBACJ,MAAM,GAAG,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,qBAAqB,CAAC;gBAC9B,OAAO;gBACP,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,cAAc;gBACtB,IAAI,EAAE,CAAC;aACR,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACqB,CAAA;AAChF,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAuC;IACxE,IACE,KAAK,CAAC,IAAI,KAAK,QAAQ;QACvB,KAAK,CAAC,IAAI,KAAK,OAAO;QACtB,KAAK,CAAC,IAAI,KAAK,OAAO;QACtB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAEpC,OAAO,KAAK,CAAA;IACd,MAAM,UAAU,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,CAAA;IAC5D,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA;AACtB,CAAC"}

24
node_modules/viem/_esm/utils/abi/decodeFunctionData.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';
import { slice } from '../data/slice.js';
import { toFunctionSelector, } from '../hash/toFunctionSelector.js';
import { decodeAbiParameters, } from './decodeAbiParameters.js';
import { formatAbiItem } from './formatAbiItem.js';
export function decodeFunctionData(parameters) {
const { abi, data } = parameters;
const signature = slice(data, 0, 4);
const description = abi.find((x) => x.type === 'function' &&
signature === toFunctionSelector(formatAbiItem(x)));
if (!description)
throw new AbiFunctionSignatureNotFoundError(signature, {
docsPath: '/docs/contract/decodeFunctionData',
});
return {
functionName: description.name,
args: ('inputs' in description &&
description.inputs &&
description.inputs.length > 0
? decodeAbiParameters(description.inputs, slice(data, 4))
: undefined),
};
}
//# sourceMappingURL=decodeFunctionData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decodeFunctionData.js","sourceRoot":"","sources":["../../../utils/abi/decodeFunctionData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAA;AAQvE,OAAO,EAAuB,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAEL,kBAAkB,GACnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA+B,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAoC/E,MAAM,UAAU,kBAAkB,CAChC,UAA6C;IAE7C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,UAA0C,CAAA;IAChE,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAC1B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,UAAU;QACrB,SAAS,KAAK,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CACrD,CAAA;IACD,IAAI,CAAC,WAAW;QACd,MAAM,IAAI,iCAAiC,CAAC,SAAS,EAAE;YACrD,QAAQ,EAAE,mCAAmC;SAC9C,CAAC,CAAA;IACJ,OAAO;QACL,YAAY,EAAG,WAAgC,CAAC,IAAI;QACpD,IAAI,EAAE,CAAC,QAAQ,IAAI,WAAW;YAC9B,WAAW,CAAC,MAAM;YAClB,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAC3B,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC,CAAC,SAAS,CAAmC;KACZ,CAAA;AACxC,CAAC"}

View File

@@ -0,0 +1,25 @@
import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, } from '../../errors/abi.js';
import { decodeAbiParameters, } from './decodeAbiParameters.js';
import { getAbiItem } from './getAbiItem.js';
const docsPath = '/docs/contract/decodeFunctionResult';
export function decodeFunctionResult(parameters) {
const { abi, args, functionName, data } = parameters;
let abiItem = abi[0];
if (functionName) {
const item = getAbiItem({ abi, args, name: functionName });
if (!item)
throw new AbiFunctionNotFoundError(functionName, { docsPath });
abiItem = item;
}
if (abiItem.type !== 'function')
throw new AbiFunctionNotFoundError(undefined, { docsPath });
if (!abiItem.outputs)
throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });
const values = decodeAbiParameters(abiItem.outputs, data);
if (values && values.length > 1)
return values;
if (values && values.length === 1)
return values[0];
return undefined;
}
//# sourceMappingURL=decodeFunctionResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decodeFunctionResult.js","sourceRoot":"","sources":["../../../utils/abi/decodeFunctionResult.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EAExB,+BAA+B,GAEhC,MAAM,qBAAqB,CAAA;AAU5B,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA4B,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEtE,MAAM,QAAQ,GAAG,qCAAqC,CAAA;AAsGtD,MAAM,UAAU,oBAAoB,CAiBlC,UAAmE;IAEnE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,GACrC,UAA4C,CAAA;IAE9C,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IACpB,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QAC1D,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,wBAAwB,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACzE,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;QAC7B,MAAM,IAAI,wBAAwB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC7D,IAAI,CAAC,OAAO,CAAC,OAAO;QAClB,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEvE,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACzD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAC7B,OAAO,MAAiE,CAAA;IAC1E,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAC/B,OAAO,MAAM,CAAC,CAAC,CAA4D,CAAA;IAC7E,OAAO,SAAoE,CAAA;AAC7E,CAAC"}

268
node_modules/viem/_esm/utils/abi/encodeAbiParameters.js generated vendored Normal file
View File

@@ -0,0 +1,268 @@
import { AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, InvalidAbiEncodingTypeError, InvalidArrayError, } from '../../errors/abi.js';
import { InvalidAddressError, } from '../../errors/address.js';
import { BaseError } from '../../errors/base.js';
import { IntegerOutOfRangeError } from '../../errors/encoding.js';
import { isAddress } from '../address/isAddress.js';
import { concat } from '../data/concat.js';
import { padHex } from '../data/pad.js';
import { size } from '../data/size.js';
import { slice } from '../data/slice.js';
import { boolToHex, numberToHex, stringToHex, } from '../encoding/toHex.js';
import { integerRegex } from '../regex.js';
/**
* @description Encodes a list of primitive values into an ABI-encoded hex value.
*
* - Docs: https://viem.sh/docs/abi/encodeAbiParameters#encodeabiparameters
*
* Generates ABI encoded data using the [ABI specification](https://docs.soliditylang.org/en/latest/abi-spec), given a set of ABI parameters (inputs/outputs) and their corresponding values.
*
* @param params - a set of ABI Parameters (params), that can be in the shape of the inputs or outputs attribute of an ABI Item.
* @param values - a set of values (values) that correspond to the given params.
* @example
* ```typescript
* import { encodeAbiParameters } from 'viem'
*
* const encodedData = encodeAbiParameters(
* [
* { name: 'x', type: 'string' },
* { name: 'y', type: 'uint' },
* { name: 'z', type: 'bool' }
* ],
* ['wagmi', 420n, true]
* )
* ```
*
* You can also pass in Human Readable parameters with the parseAbiParameters utility.
*
* @example
* ```typescript
* import { encodeAbiParameters, parseAbiParameters } from 'viem'
*
* const encodedData = encodeAbiParameters(
* parseAbiParameters('string x, uint y, bool z'),
* ['wagmi', 420n, true]
* )
* ```
*/
export function encodeAbiParameters(params, values) {
if (params.length !== values.length)
throw new AbiEncodingLengthMismatchError({
expectedLength: params.length,
givenLength: values.length,
});
// Prepare the parameters to determine dynamic types to encode.
const preparedParams = prepareParams({
params: params,
values: values,
});
const data = encodeParams(preparedParams);
if (data.length === 0)
return '0x';
return data;
}
function prepareParams({ params, values, }) {
const preparedParams = [];
for (let i = 0; i < params.length; i++) {
preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
}
return preparedParams;
}
function prepareParam({ param, value, }) {
const arrayComponents = getArrayComponents(param.type);
if (arrayComponents) {
const [length, type] = arrayComponents;
return encodeArray(value, { length, param: { ...param, type } });
}
if (param.type === 'tuple') {
return encodeTuple(value, {
param: param,
});
}
if (param.type === 'address') {
return encodeAddress(value);
}
if (param.type === 'bool') {
return encodeBool(value);
}
if (param.type.startsWith('uint') || param.type.startsWith('int')) {
const signed = param.type.startsWith('int');
const [, , size = '256'] = integerRegex.exec(param.type) ?? [];
return encodeNumber(value, {
signed,
size: Number(size),
});
}
if (param.type.startsWith('bytes')) {
return encodeBytes(value, { param });
}
if (param.type === 'string') {
return encodeString(value);
}
throw new InvalidAbiEncodingTypeError(param.type, {
docsPath: '/docs/contract/encodeAbiParameters',
});
}
function encodeParams(preparedParams) {
// 1. Compute the size of the static part of the parameters.
let staticSize = 0;
for (let i = 0; i < preparedParams.length; i++) {
const { dynamic, encoded } = preparedParams[i];
if (dynamic)
staticSize += 32;
else
staticSize += size(encoded);
}
// 2. Split the parameters into static and dynamic parts.
const staticParams = [];
const dynamicParams = [];
let dynamicSize = 0;
for (let i = 0; i < preparedParams.length; i++) {
const { dynamic, encoded } = preparedParams[i];
if (dynamic) {
staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
dynamicParams.push(encoded);
dynamicSize += size(encoded);
}
else {
staticParams.push(encoded);
}
}
// 3. Concatenate static and dynamic parts.
return concat([...staticParams, ...dynamicParams]);
}
function encodeAddress(value) {
if (!isAddress(value))
throw new InvalidAddressError({ address: value });
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
}
function encodeArray(value, { length, param, }) {
const dynamic = length === null;
if (!Array.isArray(value))
throw new InvalidArrayError(value);
if (!dynamic && value.length !== length)
throw new AbiEncodingArrayLengthMismatchError({
expectedLength: length,
givenLength: value.length,
type: `${param.type}[${length}]`,
});
let dynamicChild = false;
const preparedParams = [];
for (let i = 0; i < value.length; i++) {
const preparedParam = prepareParam({ param, value: value[i] });
if (preparedParam.dynamic)
dynamicChild = true;
preparedParams.push(preparedParam);
}
if (dynamic || dynamicChild) {
const data = encodeParams(preparedParams);
if (dynamic) {
const length = numberToHex(preparedParams.length, { size: 32 });
return {
dynamic: true,
encoded: preparedParams.length > 0 ? concat([length, data]) : length,
};
}
if (dynamicChild)
return { dynamic: true, encoded: data };
}
return {
dynamic: false,
encoded: concat(preparedParams.map(({ encoded }) => encoded)),
};
}
function encodeBytes(value, { param }) {
const [, paramSize] = param.type.split('bytes');
const bytesSize = size(value);
if (!paramSize) {
let value_ = value;
// If the size is not divisible by 32 bytes, pad the end
// with empty bytes to the ceiling 32 bytes.
if (bytesSize % 32 !== 0)
value_ = padHex(value_, {
dir: 'right',
size: Math.ceil((value.length - 2) / 2 / 32) * 32,
});
return {
dynamic: true,
encoded: concat([padHex(numberToHex(bytesSize, { size: 32 })), value_]),
};
}
if (bytesSize !== Number.parseInt(paramSize, 10))
throw new AbiEncodingBytesSizeMismatchError({
expectedSize: Number.parseInt(paramSize, 10),
value,
});
return { dynamic: false, encoded: padHex(value, { dir: 'right' }) };
}
function encodeBool(value) {
if (typeof value !== 'boolean')
throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
return { dynamic: false, encoded: padHex(boolToHex(value)) };
}
function encodeNumber(value, { signed, size = 256 }) {
if (typeof size === 'number') {
const max = 2n ** (BigInt(size) - (signed ? 1n : 0n)) - 1n;
const min = signed ? -max - 1n : 0n;
if (value > max || value < min)
throw new IntegerOutOfRangeError({
max: max.toString(),
min: min.toString(),
signed,
size: size / 8,
value: value.toString(),
});
}
return {
dynamic: false,
encoded: numberToHex(value, {
size: 32,
signed,
}),
};
}
function encodeString(value) {
const hexValue = stringToHex(value);
const partsLength = Math.ceil(size(hexValue) / 32);
const parts = [];
for (let i = 0; i < partsLength; i++) {
parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
dir: 'right',
}));
}
return {
dynamic: true,
encoded: concat([
padHex(numberToHex(size(hexValue), { size: 32 })),
...parts,
]),
};
}
function encodeTuple(value, { param }) {
let dynamic = false;
const preparedParams = [];
for (let i = 0; i < param.components.length; i++) {
const param_ = param.components[i];
const index = Array.isArray(value) ? i : param_.name;
const preparedParam = prepareParam({
param: param_,
value: value[index],
});
preparedParams.push(preparedParam);
if (preparedParam.dynamic)
dynamic = true;
}
return {
dynamic,
encoded: dynamic
? encodeParams(preparedParams)
: concat(preparedParams.map(({ encoded }) => encoded)),
};
}
export function getArrayComponents(type) {
const matches = type.match(/^(.*)\[(\d+)?\]$/);
return matches
? // Return `null` if the array is dynamic.
[matches[2] ? Number(matches[2]) : null, matches[1]]
: undefined;
}
//# sourceMappingURL=encodeAbiParameters.js.map

File diff suppressed because one or more lines are too long

19
node_modules/viem/_esm/utils/abi/encodeDeployData.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, } from '../../errors/abi.js';
import { concatHex } from '../data/concat.js';
import { encodeAbiParameters, } from './encodeAbiParameters.js';
const docsPath = '/docs/contract/encodeDeployData';
export function encodeDeployData(parameters) {
const { abi, args, bytecode } = parameters;
if (!args || args.length === 0)
return bytecode;
const description = abi.find((x) => 'type' in x && x.type === 'constructor');
if (!description)
throw new AbiConstructorNotFoundError({ docsPath });
if (!('inputs' in description))
throw new AbiConstructorParamsNotFoundError({ docsPath });
if (!description.inputs || description.inputs.length === 0)
throw new AbiConstructorParamsNotFoundError({ docsPath });
const data = encodeAbiParameters(description.inputs, args);
return concatHex([bytecode, data]);
}
//# sourceMappingURL=encodeDeployData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encodeDeployData.js","sourceRoot":"","sources":["../../../utils/abi/encodeDeployData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAE3B,iCAAiC,GAClC,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EAA2B,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAEjC,MAAM,QAAQ,GAAG,iCAAiC,CAAA;AAgClD,MAAM,UAAU,gBAAgB,CAC9B,UAA2C;IAE3C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAwC,CAAA;IACxE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAE/C,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA;IAC5E,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrE,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,CAAC;QAC5B,MAAM,IAAI,iCAAiC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC3D,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QACxD,MAAM,IAAI,iCAAiC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAE3D,MAAM,IAAI,GAAG,mBAAmB,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC1D,OAAO,SAAS,CAAC,CAAC,QAAQ,EAAE,IAAK,CAAC,CAAC,CAAA;AACrC,CAAC"}

29
node_modules/viem/_esm/utils/abi/encodeErrorResult.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';
import { concatHex } from '../data/concat.js';
import { toFunctionSelector, } from '../hash/toFunctionSelector.js';
import { encodeAbiParameters, } from './encodeAbiParameters.js';
import { formatAbiItem } from './formatAbiItem.js';
import { getAbiItem } from './getAbiItem.js';
const docsPath = '/docs/contract/encodeErrorResult';
export function encodeErrorResult(parameters) {
const { abi, errorName, args } = parameters;
let abiItem = abi[0];
if (errorName) {
const item = getAbiItem({ abi, args, name: errorName });
if (!item)
throw new AbiErrorNotFoundError(errorName, { docsPath });
abiItem = item;
}
if (abiItem.type !== 'error')
throw new AbiErrorNotFoundError(undefined, { docsPath });
const definition = formatAbiItem(abiItem);
const signature = toFunctionSelector(definition);
let data = '0x';
if (args && args.length > 0) {
if (!abiItem.inputs)
throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });
data = encodeAbiParameters(abiItem.inputs, args);
}
return concatHex([signature, data]);
}
//# sourceMappingURL=encodeErrorResult.js.map

View File

@@ -0,0 +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E,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,MAAM;YACjB,MAAM,IAAI,2BAA2B,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACnE,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA;AACrC,CAAC"}

51
node_modules/viem/_esm/utils/abi/encodeEventTopics.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
import { AbiEventNotFoundError, } from '../../errors/abi.js';
import { FilterTypeNotSupportedError, } from '../../errors/log.js';
import { toBytes } from '../encoding/toBytes.js';
import { keccak256 } from '../hash/keccak256.js';
import { toEventSelector, } from '../hash/toEventSelector.js';
import { encodeAbiParameters, } from './encodeAbiParameters.js';
import { formatAbiItem } from './formatAbiItem.js';
import { getAbiItem } from './getAbiItem.js';
const docsPath = '/docs/contract/encodeEventTopics';
export function encodeEventTopics(parameters) {
const { abi, eventName, args } = parameters;
let abiItem = abi[0];
if (eventName) {
const item = getAbiItem({ abi, name: eventName });
if (!item)
throw new AbiEventNotFoundError(eventName, { docsPath });
abiItem = item;
}
if (abiItem.type !== 'event')
throw new AbiEventNotFoundError(undefined, { docsPath });
const definition = formatAbiItem(abiItem);
const signature = toEventSelector(definition);
let topics = [];
if (args && 'inputs' in abiItem) {
const indexedInputs = abiItem.inputs?.filter((param) => 'indexed' in param && param.indexed);
const args_ = Array.isArray(args)
? args
: Object.values(args).length > 0
? (indexedInputs?.map((x) => args[x.name]) ?? [])
: [];
if (args_.length > 0) {
topics =
indexedInputs?.map((param, i) => {
if (Array.isArray(args_[i]))
return args_[i].map((_, j) => encodeArg({ param, value: args_[i][j] }));
return typeof args_[i] !== 'undefined' && args_[i] !== null
? encodeArg({ param, value: args_[i] })
: null;
}) ?? [];
}
}
return [signature, ...topics];
}
function encodeArg({ param, value, }) {
if (param.type === 'string' || param.type === 'bytes')
return keccak256(toBytes(value));
if (param.type === 'tuple' || param.type.match(/^(.*)\[(\d+)?\]$/))
throw new FilterTypeNotSupportedError(param.type);
return encodeAbiParameters([param], [value]);
}
//# sourceMappingURL=encodeEventTopics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encodeEventTopics.js","sourceRoot":"","sources":["../../../utils/abi/encodeEventTopics.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,qBAAqB,GAEtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,2BAA2B,GAE5B,MAAM,qBAAqB,CAAA;AAS5B,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAA2B,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAEL,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA+B,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAA4B,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEtE,MAAM,QAAQ,GAAG,kCAAkC,CAAA;AA0CnD,MAAM,UAAU,iBAAiB,CAI/B,UAAuD;IAEvD,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAyC,CAAA;IAE1E,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IACpB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QACjD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,qBAAqB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACnE,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO;QAC1B,MAAM,IAAI,qBAAq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K,IAAI;wBACzD,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;wBACvC,CAAC,CAAC,IAAI,CAAA;gBACV,CAAC,CAAC,IAAI,EAAE,CAAA;QACZ,CAAC;IACH,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,CAAA;AAC/B,CAAC;AASD,SAAS,SAAS,CAAC,EACjB,KAAK,EACL,KAAK,GAIN;IACC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QACnD,OAAO,SAAS,CAAC,OAAO,CAAC,KAAe,CAAC,CAAC,CAAA;IAC5C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAChE,MAAM,IAAI,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACnD,OAAO,mBAAmB,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;AAC9C,CAAC"}

19
node_modules/viem/_esm/utils/abi/encodeFunctionData.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import { concatHex } from '../data/concat.js';
import { encodeAbiParameters, } from './encodeAbiParameters.js';
import { prepareEncodeFunctionData } from './prepareEncodeFunctionData.js';
export function encodeFunctionData(parameters) {
const { args } = parameters;
const { abi, functionName } = (() => {
if (parameters.abi.length === 1 &&
parameters.functionName?.startsWith('0x'))
return parameters;
return prepareEncodeFunctionData(parameters);
})();
const abiItem = abi[0];
const signature = functionName;
const data = 'inputs' in abiItem && abiItem.inputs
? encodeAbiParameters(abiItem.inputs, args ?? [])
: undefined;
return concatHex([signature, data ?? '0x']);
}
//# sourceMappingURL=encodeFunctionData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encodeFunctionData.js","sourceRoot":"","sources":["../../../utils/abi/encodeFunctionData.ts"],"names":[],"mappings":"AAUA,OAAO,EAA2B,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEtE,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAmD1E,MAAM,UAAU,kBAAkB,CAIhC,UAA2D;IAE3D,MAAM,EAAE,IAAI,EAAE,GAAG,UAA0C,CAAA;IAE3D,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,GAAG,EAAE;QAClC,IACE,UAAU,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;YAC3B,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC;YAEzC,OAAO,UAA6C,CAAA;QACtD,OAAO,yBAAyB,CAAC,UAAU,CAAC,CAAA;IAC9C,CAAC,CAAC,EAAE,CAAA;IAEJ,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IACtB,MAAM,SAAS,GAAG,YAAY,CAAA;IAE9B,MAAM,IAAI,GACR,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM;QACnC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACjD,CAAC,CAAC,SAAS,CAAA;IACf,OAAO,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA;AAC7C,CAAC"}

View File

@@ -0,0 +1,29 @@
import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';
import { encodeAbiParameters, } from './encodeAbiParameters.js';
import { getAbiItem } from './getAbiItem.js';
const docsPath = '/docs/contract/encodeFunctionResult';
export function encodeFunctionResult(parameters) {
const { abi, functionName, result } = parameters;
let abiItem = abi[0];
if (functionName) {
const item = getAbiItem({ abi, name: functionName });
if (!item)
throw new AbiFunctionNotFoundError(functionName, { docsPath });
abiItem = item;
}
if (abiItem.type !== 'function')
throw new AbiFunctionNotFoundError(undefined, { docsPath });
if (!abiItem.outputs)
throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });
const values = (() => {
if (abiItem.outputs.length === 0)
return [];
if (abiItem.outputs.length === 1)
return [result];
if (Array.isArray(result))
return result;
throw new InvalidArrayError(result);
})();
return encodeAbiParameters(abiItem.outputs, values);
}
//# sourceMappingURL=encodeFunctionResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encodeFunctionResult.js","sourceRoot":"","sources":["../../../utils/abi/encodeFunctionResult.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAQ5B,OAAO,EAEL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA4B,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEtE,MAAM,QAAQ,GAAG,qCAAqC,CAAA;AA8CtD,MAAM,UAAU,oBAAoB,CAIlC,UAA6D;IAE7D,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,GACjC,UAA4C,CAAA;IAE9C,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IACpB,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,wBAAwB,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACzE,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;QAC7B,MAAM,IAAI,wBAAwB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAE7D,IAAI,CAAC,OAAO,CAAC,OAAO;QAClB,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEvE,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;QACnB,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAA;QAC3C,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACjD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAA;QACxC,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AACrD,CAAC"}

69
node_modules/viem/_esm/utils/abi/encodePacked.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
import { AbiEncodingLengthMismatchError, BytesSizeMismatchError, UnsupportedPackedAbiType, } from '../../errors/abi.js';
import { InvalidAddressError, } from '../../errors/address.js';
import { isAddress } from '../address/isAddress.js';
import { concatHex } from '../data/concat.js';
import { pad } from '../data/pad.js';
import { boolToHex, numberToHex, stringToHex, } from '../encoding/toHex.js';
import { arrayRegex, bytesRegex, integerRegex } from '../regex.js';
export function encodePacked(types, values) {
if (types.length !== values.length)
throw new AbiEncodingLengthMismatchError({
expectedLength: types.length,
givenLength: values.length,
});
const data = [];
for (let i = 0; i < types.length; i++) {
const type = types[i];
const value = values[i];
data.push(encode(type, value));
}
return concatHex(data);
}
function encode(type, value, isArray = false) {
if (type === 'address') {
const address = value;
if (!isAddress(address))
throw new InvalidAddressError({ address });
return pad(address.toLowerCase(), {
size: isArray ? 32 : null,
});
}
if (type === 'string')
return stringToHex(value);
if (type === 'bytes')
return value;
if (type === 'bool')
return pad(boolToHex(value), { size: isArray ? 32 : 1 });
const intMatch = type.match(integerRegex);
if (intMatch) {
const [_type, baseType, bits = '256'] = intMatch;
const size = Number.parseInt(bits, 10) / 8;
return numberToHex(value, {
size: isArray ? 32 : size,
signed: baseType === 'int',
});
}
const bytesMatch = type.match(bytesRegex);
if (bytesMatch) {
const [_type, size] = bytesMatch;
if (Number.parseInt(size, 10) !== (value.length - 2) / 2)
throw new BytesSizeMismatchError({
expectedSize: Number.parseInt(size, 10),
givenSize: (value.length - 2) / 2,
});
return pad(value, { dir: 'right', size: isArray ? 32 : null });
}
const arrayMatch = type.match(arrayRegex);
if (arrayMatch && Array.isArray(value)) {
const [_type, childType] = arrayMatch;
const data = [];
for (let i = 0; i < value.length; i++) {
data.push(encode(childType, value[i], true));
}
if (data.length === 0)
return '0x';
return concatHex(data);
}
throw new UnsupportedPackedAbiType(type);
}
//# sourceMappingURL=encodePacked.js.map

1
node_modules/viem/_esm/utils/abi/encodePacked.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"encodePacked.js","sourceRoot":"","sources":["../../../utils/abi/encodePacked.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,8BAA8B,EAE9B,sBAAsB,EAEtB,wBAAwB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,mBAAmB,GAEpB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAA2B,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAA2B,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAqB,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAEL,SAAS,EAET,WAAW,EAEX,WAAW,GACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAwBlE,MAAM,UAAU,YAAY,CAE1B,KAAqB,EAAE,MAA0C;IACjE,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAChC,MAAM,IAAI,8BAA8B,CAAC;YACvC,cAAc,EAAE,KA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QACrC,MAAM,IAAI,GAAU,EAAE,CAAA;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAClC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAED,MAAM,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAA;AAC1C,CAAC"}

22
node_modules/viem/_esm/utils/abi/formatAbiItem.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { InvalidDefinitionTypeError, } from '../../errors/abi.js';
export function formatAbiItem(abiItem, { includeName = false } = {}) {
if (abiItem.type !== 'function' &&
abiItem.type !== 'event' &&
abiItem.type !== 'error')
throw new InvalidDefinitionTypeError(abiItem.type);
return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
}
export function formatAbiParams(params, { includeName = false } = {}) {
if (!params)
return '';
return params
.map((param) => formatAbiParam(param, { includeName }))
.join(includeName ? ', ' : ',');
}
function formatAbiParam(param, { includeName }) {
if (param.type.startsWith('tuple')) {
return `(${formatAbiParams(param.components, { includeName })})${param.type.slice('tuple'.length)}`;
}
return param.type + (includeName && param.name ? ` ${param.name}` : '');
}
//# sourceMappingURL=formatAbiItem.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"formatAbiItem.js","sourceRoot":"","sources":["../../../utils/abi/formatAbiItem.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,GAE3B,MAAM,qBAAqB,CAAA;AAS5B,MAAM,UAAU,aAAa,CAC3B,OAAgB,EAChB,EAAE,WAAW,GAAG,KAAK,KAA4C,EAAE;IAEnE,IACE,OAAO,CAAC,IAAI,KAAK,UAAU;QAC3B,OAAO,CAAC,IAAI,KAAK,OAAO;QACxB,OAAO,CAAC,IAAI,KAAK,OAAO;QAExB,MAAM,IAAI,0BAA0B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpD,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,GAAG,CAAA;AAC/E,CAAC;AAID,MAAM,UAAU,eAAe,CAC7B,MAA2C,EAC3C,EAAE,WAAW,GAAG,KAAK,KAA4C,EAAE;IAEnE,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;SACtD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACnC,CAAC;AAID,SAAS,cAAc,CACrB,KAAmB,EACnB,EAAE,WAAW,EAA4B;IAEzC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,eAAe,CACvB,KAAmD,CAAC,UAAU,EAC/D,EAAE,WAAW,EAAE,CAChB,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;IACzC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AACzE,CAAC"}

View File

@@ -0,0 +1,13 @@
import { stringify } from '../stringify.js';
export function formatAbiItemWithArgs({ abiItem, args, includeFunctionName = true, includeName = false, }) {
if (!('name' in abiItem))
return;
if (!('inputs' in abiItem))
return;
if (!abiItem.inputs)
return;
return `${includeFunctionName ? abiItem.name : ''}(${abiItem.inputs
.map((input, i) => `${includeName && input.name ? `${input.name}: ` : ''}${typeof args[i] === 'object' ? stringify(args[i]) : args[i]}`)
.join(', ')})`;
}
//# sourceMappingURL=formatAbiItemWithArgs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"formatAbiItemWithArgs.js","sourceRoot":"","sources":["../../../utils/abi/formatAbiItemWithArgs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,IAAI,EACJ,mBAAmB,GAAG,IAAI,EAC1B,WAAW,GAAG,KAAK,GAMpB;IACC,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC;QAAE,OAAM;IAChC,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC;QAAE,OAAM;IAClC,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAM;IAC3B,OAAO,GAAG,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,MAAM;SAChE,GAAG,CACF,CAAC,KAAmB,EAAE,CAAS,EAAE,EAAE,CACjC,GAAG,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GACnD,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAC3D,EAAE,CACL;SACA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;AAClB,CAAC"}

132
node_modules/viem/_esm/utils/abi/getAbiItem.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
import { AbiItemAmbiguityError, } from '../../errors/abi.js';
import { isHex } from '../../utils/data/isHex.js';
import { isAddress } from '../address/isAddress.js';
import { toEventSelector } from '../hash/toEventSelector.js';
import { toFunctionSelector, } from '../hash/toFunctionSelector.js';
export function getAbiItem(parameters) {
const { abi, args = [], name } = parameters;
const isSelector = isHex(name, { strict: false });
const abiItems = abi.filter((abiItem) => {
if (isSelector) {
if (abiItem.type === 'function')
return toFunctionSelector(abiItem) === name;
if (abiItem.type === 'event')
return toEventSelector(abiItem) === name;
return false;
}
return 'name' in abiItem && abiItem.name === name;
});
if (abiItems.length === 0)
return undefined;
if (abiItems.length === 1)
return abiItems[0];
let matchedAbiItem;
for (const abiItem of abiItems) {
if (!('inputs' in abiItem))
continue;
if (!args || args.length === 0) {
if (!abiItem.inputs || abiItem.inputs.length === 0)
return abiItem;
continue;
}
if (!abiItem.inputs)
continue;
if (abiItem.inputs.length === 0)
continue;
if (abiItem.inputs.length !== args.length)
continue;
const matched = args.every((arg, index) => {
const abiParameter = 'inputs' in abiItem && abiItem.inputs[index];
if (!abiParameter)
return false;
return isArgOfType(arg, abiParameter);
});
if (matched) {
// Check for ambiguity against already matched parameters (e.g. `address` vs `bytes20`).
if (matchedAbiItem &&
'inputs' in matchedAbiItem &&
matchedAbiItem.inputs) {
const ambiguousTypes = getAmbiguousTypes(abiItem.inputs, matchedAbiItem.inputs, args);
if (ambiguousTypes)
throw new AbiItemAmbiguityError({
abiItem,
type: ambiguousTypes[0],
}, {
abiItem: matchedAbiItem,
type: ambiguousTypes[1],
});
}
matchedAbiItem = abiItem;
}
}
if (matchedAbiItem)
return matchedAbiItem;
return abiItems[0];
}
/** @internal */
export function isArgOfType(arg, abiParameter) {
const argType = typeof arg;
const abiParameterType = abiParameter.type;
switch (abiParameterType) {
case 'address':
return isAddress(arg, { strict: false });
case 'bool':
return argType === 'boolean';
case 'function':
return argType === 'string';
case 'string':
return argType === 'string';
default: {
if (abiParameterType === 'tuple' && 'components' in abiParameter)
return Object.values(abiParameter.components).every((component, index) => {
return (argType === 'object' &&
isArgOfType(Object.values(arg)[index], component));
});
// `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`
// https://regexr.com/6v8hp
if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(abiParameterType))
return argType === 'number' || argType === 'bigint';
// `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`
// https://regexr.com/6va55
if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
return argType === 'string' || arg instanceof Uint8Array;
// fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays
// https://regexr.com/6va6i
if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
return (Array.isArray(arg) &&
arg.every((x) => isArgOfType(x, {
...abiParameter,
// Pop off `[]` or `[M]` from end of type
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, ''),
})));
}
return false;
}
}
}
/** @internal */
export function getAmbiguousTypes(sourceParameters, targetParameters, args) {
for (const parameterIndex in sourceParameters) {
const sourceParameter = sourceParameters[parameterIndex];
const targetParameter = targetParameters[parameterIndex];
if (sourceParameter.type === 'tuple' &&
targetParameter.type === 'tuple' &&
'components' in sourceParameter &&
'components' in targetParameter)
return getAmbiguousTypes(sourceParameter.components, targetParameter.components, args[parameterIndex]);
const types = [sourceParameter.type, targetParameter.type];
const ambiguous = (() => {
if (types.includes('address') && types.includes('bytes20'))
return true;
if (types.includes('address') && types.includes('string'))
return isAddress(args[parameterIndex], { strict: false });
if (types.includes('address') && types.includes('bytes'))
return isAddress(args[parameterIndex], { strict: false });
return false;
})();
if (ambiguous)
return types;
}
return;
}
//# sourceMappingURL=getAbiItem.js.map

1
node_modules/viem/_esm/utils/abi/getAbiItem.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"getAbiItem.js","sourceRoot":"","sources":["../../../utils/abi/getAbiItem.ts"],"names":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AC,IAAI,CAAC,cAAc,CAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;YACtE,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACtD,OAAO,SAAS,CAAC,IAAI,CAAC,cAAc,CAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;YACtE,OAAO,KAAK,CAAA;QACd,CAAC,CAAC,EAAE,CAAA;QAEJ,IAAI,SAAS;YAAE,OAAO,KAAK,CAAA;IAC7B,CAAC;IAED,OAAM;AACR,CAAC"}

159
node_modules/viem/_esm/utils/abi/parseEventLogs.js generated vendored Normal file
View File

@@ -0,0 +1,159 @@
// TODO(v3): checksum address.
import { isAddressEqual } from '../address/isAddressEqual.js';
import { toBytes } from '../encoding/toBytes.js';
import { formatLog } from '../formatters/log.js';
import { keccak256 } from '../hash/keccak256.js';
import { toEventSelector } from '../hash/toEventSelector.js';
import { decodeEventLog, } from './decodeEventLog.js';
/**
* Extracts & decodes logs matching the provided signature(s) (`abi` + optional `eventName`)
* from a set of opaque logs.
*
* @param parameters - {@link ParseEventLogsParameters}
* @returns The logs. {@link ParseEventLogsReturnType}
*
* @example
* import { createClient, http } from 'viem'
* import { mainnet } from 'viem/chains'
* import { parseEventLogs } from 'viem/op-stack'
*
* const client = createClient({
* chain: mainnet,
* transport: http(),
* })
*
* const receipt = await getTransactionReceipt(client, {
* hash: '0xec23b2ba4bc59ba61554507c1b1bc91649e6586eb2dd00c728e8ed0db8bb37ea',
* })
*
* const logs = parseEventLogs({ logs: receipt.logs })
* // [{ args: { ... }, eventName: 'TransactionDeposited', ... }, ...]
*/
export function parseEventLogs(parameters) {
const { abi, args, logs, strict = true } = parameters;
const eventName = (() => {
if (!parameters.eventName)
return undefined;
if (Array.isArray(parameters.eventName))
return parameters.eventName;
return [parameters.eventName];
})();
const abiTopics = abi
.filter((abiItem) => abiItem.type === 'event')
.map((abiItem) => ({
abi: abiItem,
selector: toEventSelector(abiItem),
}));
return logs
.map((log) => {
// Normalize RpcLog (hex-encoded quantities) to Log (bigint/number).
// When logs come directly from an RPC response (e.g. eth_getLogs),
// fields like blockNumber are hex strings instead of bigints.
const formattedLog = typeof log.blockNumber === 'string' ? formatLog(log) : log;
// Find all matching ABI items with the same selector.
// Multiple events can share the same selector but differ in indexed parameters
// (e.g., ERC20 vs ERC721 Transfer events).
const abiItems = abiTopics.filter((abiTopic) => formattedLog.topics[0] === abiTopic.selector);
if (abiItems.length === 0)
return null;
// Try each matching ABI item until one successfully decodes.
let event;
let abiItem;
for (const item of abiItems) {
try {
event = decodeEventLog({
...formattedLog,
abi: [item.abi],
strict: true,
});
abiItem = item;
break;
}
catch {
// Try next ABI item
}
}
// If strict decoding failed for all, and we're in non-strict mode,
// fall back to the first matching ABI item.
if (!event && !strict) {
abiItem = abiItems[0];
try {
event = decodeEventLog({
data: formattedLog.data,
topics: formattedLog.topics,
abi: [abiItem.abi],
strict: false,
});
}
catch {
// If decoding still fails, return partial log in non-strict mode.
const isUnnamed = abiItem.abi.inputs?.some((x) => !('name' in x && x.name));
return {
...formattedLog,
args: isUnnamed ? [] : {},
eventName: abiItem.abi.name,
};
}
}
// If no event was found, return null.
if (!event || !abiItem)
return null;
// Check that the decoded event name matches the provided event name.
if (eventName && !eventName.includes(event.eventName))
return null;
// Check that the decoded event args match the provided args.
if (!includesArgs({
args: event.args,
inputs: abiItem.abi.inputs,
matchArgs: args,
}))
return null;
return { ...event, ...formattedLog };
})
.filter(Boolean);
}
function includesArgs(parameters) {
const { args, inputs, matchArgs } = parameters;
if (!matchArgs)
return true;
if (!args)
return false;
function isEqual(input, value, arg) {
try {
if (input.type === 'address')
return isAddressEqual(value, arg);
if (input.type === 'string' || input.type === 'bytes')
return keccak256(toBytes(value)) === arg;
return value === arg;
}
catch {
return false;
}
}
if (Array.isArray(args) && Array.isArray(matchArgs)) {
return matchArgs.every((value, index) => {
if (value === null || value === undefined)
return true;
const input = inputs[index];
if (!input)
return false;
const value_ = Array.isArray(value) ? value : [value];
return value_.some((value) => isEqual(input, value, args[index]));
});
}
if (typeof args === 'object' &&
!Array.isArray(args) &&
typeof matchArgs === 'object' &&
!Array.isArray(matchArgs))
return Object.entries(matchArgs).every(([key, value]) => {
if (value === null || value === undefined)
return true;
const input = inputs.find((input) => input.name === key);
if (!input)
return false;
const value_ = Array.isArray(value) ? value : [value];
return value_.some((value) => isEqual(input, value, args[key]));
});
return false;
}
//# sourceMappingURL=parseEventLogs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parseEventLogs.js","sourceRoot":"","sources":["../../../utils/abi/parseEventLogs.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAO9B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAEL,cAAc,GACf,MAAM,qBAAqB,CAAA;AAsD5B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,cAAc,CAQ5B,UAA4D;IAE5D,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;IAErD,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE;QACtB,IAAI,CAAC,UAAU,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,UAAU,CAAC,SAAS,CAAA;QACpE,OAAO,CAAC,UAAU,CAAC,SAAmB,CAAC,CAAA;IACzC,CAAC,CAAC,EAAE,CAAA;IAEJ,MAAM,S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AAA;IACJ,CAAC;IAED,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,OAAO,SAAS,KAAK,QAAQ;QAC7B,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAEzB,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACtD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAA;YACtD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAA;YACxD,IAAI,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAA;YACxB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;YACrD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3B,OAAO,CAAC,KAAK,EAAE,KAAK,EAAG,IAAgC,CAAC,GAAG,CAAC,CAAC,CAC9D,CAAA;QACH,CAAC,CAAC,CAAA;IAEJ,OAAO,KAAK,CAAA;AACd,CAAC"}

View File

@@ -0,0 +1,26 @@
import { AbiFunctionNotFoundError, } from '../../errors/abi.js';
import { toFunctionSelector, } from '../hash/toFunctionSelector.js';
import { formatAbiItem } from './formatAbiItem.js';
import { getAbiItem } from './getAbiItem.js';
const docsPath = '/docs/contract/encodeFunctionData';
export function prepareEncodeFunctionData(parameters) {
const { abi, args, functionName } = parameters;
let abiItem = abi[0];
if (functionName) {
const item = getAbiItem({
abi,
args,
name: functionName,
});
if (!item)
throw new AbiFunctionNotFoundError(functionName, { docsPath });
abiItem = item;
}
if (abiItem.type !== 'function')
throw new AbiFunctionNotFoundError(undefined, { docsPath });
return {
abi: [abiItem],
functionName: toFunctionSelector(formatAbiItem(abiItem)),
};
}
//# sourceMappingURL=prepareEncodeFunctionData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"prepareEncodeFunctionData.js","sourceRoot":"","sources":["../../../utils/abi/prepareEncodeFunctionData.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,wBAAwB,GAEzB,MAAM,qBAAqB,CAAA;AAS5B,OAAO,EAEL,kBAAkB,GACnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAA4B,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEtE,MAAM,QAAQ,GAAG,mCAAmC,CAAA;AAyDpD,MAAM,UAAU,yBAAyB,CAIvC,UAAkE;IAElE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,GAC/B,UAAiD,CAAA;IAEnD,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IACpB,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,UAAU,CAAC;YACtB,GAAG;YACH,IAAI;YACJ,IAAI,EAAE,YAAY;SACnB,CAAC,CAAA;QACF,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,wBAAwB,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACzE,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;QAC7B,MAAM,IAAI,wBAAwB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAE7D,OAAO;QACL,GAAG,EAAE,CAAC,OAAO,CAAC;QACd,YAAY,EAAE,kBAAkB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;KACY,CAAA;AACxE,CAAC"}

54
node_modules/viem/_esm/utils/address/getAddress.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
import { InvalidAddressError } from '../../errors/address.js';
import { stringToBytes, } from '../encoding/toBytes.js';
import { keccak256 } from '../hash/keccak256.js';
import { LruMap } from '../lru.js';
import { isAddress } from './isAddress.js';
const checksumAddressCache = /*#__PURE__*/ new LruMap(8192);
export function checksumAddress(address_,
/**
* Warning: EIP-1191 checksum addresses are generally not backwards compatible with the
* wider Ethereum ecosystem, meaning it will break when validated against an application/tool
* that relies on EIP-55 checksum encoding (checksum without chainId).
*
* It is highly recommended to not use this feature unless you
* know what you are doing.
*
* See more: https://github.com/ethereum/EIPs/issues/1121
*/
chainId) {
if (checksumAddressCache.has(`${address_}.${chainId}`))
return checksumAddressCache.get(`${address_}.${chainId}`);
const hexAddress = chainId
? `${chainId}${address_.toLowerCase()}`
: address_.substring(2).toLowerCase();
const hash = keccak256(stringToBytes(hexAddress), 'bytes');
const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split('');
for (let i = 0; i < 40; i += 2) {
if (hash[i >> 1] >> 4 >= 8 && address[i]) {
address[i] = address[i].toUpperCase();
}
if ((hash[i >> 1] & 0x0f) >= 8 && address[i + 1]) {
address[i + 1] = address[i + 1].toUpperCase();
}
}
const result = `0x${address.join('')}`;
checksumAddressCache.set(`${address_}.${chainId}`, result);
return result;
}
export function getAddress(address,
/**
* Warning: EIP-1191 checksum addresses are generally not backwards compatible with the
* wider Ethereum ecosystem, meaning it will break when validated against an application/tool
* that relies on EIP-55 checksum encoding (checksum without chainId).
*
* It is highly recommended to not use this feature unless you
* know what you are doing.
*
* See more: https://github.com/ethereum/EIPs/issues/1121
*/
chainId) {
if (!isAddress(address, { strict: false }))
throw new InvalidAddressError({ address });
return checksumAddress(address, chainId);
}
//# sourceMappingURL=getAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAddress.js","sourceRoot":"","sources":["../../../utils/address/getAddress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;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AW,EAAE,CAAA;QACvC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;QAC/C,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAW,CAAA;IAC/C,oBAAoB,CAAC,GAAG,CAAC,GAAG,QAAQ,IAAI,OAAO,EAAE,EAAE,MAAM,CAAC,CAAA;IAC1D,OAAO,MAAM,CAAA;AACf,CAAC;AAOD,MAAM,UAAU,UAAU,CACxB,OAAe;AACf;;;;;;;;;GASG;AACH,OAAgB;IAEhB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACxC,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5C,OAAO,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC"}

View File

@@ -0,0 +1,36 @@
import { concat } from '../data/concat.js';
import { isBytes } from '../data/isBytes.js';
import { pad } from '../data/pad.js';
import { slice } from '../data/slice.js';
import { toBytes } from '../encoding/toBytes.js';
import { toRlp } from '../encoding/toRlp.js';
import { keccak256 } from '../hash/keccak256.js';
import { getAddress } from './getAddress.js';
export function getContractAddress(opts) {
if (opts.opcode === 'CREATE2')
return getCreate2Address(opts);
return getCreateAddress(opts);
}
export function getCreateAddress(opts) {
const from = toBytes(getAddress(opts.from));
let nonce = toBytes(opts.nonce);
if (nonce[0] === 0)
nonce = new Uint8Array([]);
return getAddress(`0x${keccak256(toRlp([from, nonce], 'bytes')).slice(26)}`);
}
export function getCreate2Address(opts) {
const from = toBytes(getAddress(opts.from));
const salt = pad(isBytes(opts.salt) ? opts.salt : toBytes(opts.salt), {
size: 32,
});
const bytecodeHash = (() => {
if ('bytecodeHash' in opts) {
if (isBytes(opts.bytecodeHash))
return opts.bytecodeHash;
return toBytes(opts.bytecodeHash);
}
return keccak256(opts.bytecode, 'bytes');
})();
return getAddress(slice(keccak256(concat([toBytes('0xff'), from, salt, bytecodeHash])), 12));
}
//# sourceMappingURL=getContractAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getContractAddress.js","sourceRoot":"","sources":["../../../utils/address/getContractAddress.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAyB,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAqB,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAuB,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAuB,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAA2B,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAA4B,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAyBtE,MAAM,UAAU,kBAAkB,CAAC,IAA+B;IAChE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAC7D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AASD,MAAM,UAAU,gBAAgB,CAAC,IAA6B;IAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAE3C,IAAI,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;IAE9C,OAAO,UAAU,CACf,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAa,CACrE,CAAA;AACH,CAAC;AAaD,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACpE,IAAI,EAAE,EAAE;KACT,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE;QACzB,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;gBAAE,OAAO,IAAI,CAAC,YAAY,CAAA;YACxD,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACnC,CAAC;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,UAAU,CACf,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAC1E,CAAA;AACH,CAAC"}

23
node_modules/viem/_esm/utils/address/isAddress.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { LruMap } from '../lru.js';
import { checksumAddress } from './getAddress.js';
const addressRegex = /^0x[a-fA-F0-9]{40}$/;
/** @internal */
export const isAddressCache = /*#__PURE__*/ new LruMap(8192);
export function isAddress(address, options) {
const { strict = true } = options ?? {};
const cacheKey = `${address}.${strict}`;
if (isAddressCache.has(cacheKey))
return isAddressCache.get(cacheKey);
const result = (() => {
if (!addressRegex.test(address))
return false;
if (address.toLowerCase() === address)
return true;
if (strict)
return checksumAddress(address) === address;
return true;
})();
isAddressCache.set(cacheKey, result);
return result;
}
//# sourceMappingURL=isAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isAddress.js","sourceRoot":"","sources":["../../../utils/address/isAddress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,YAAY,GAAG,qBAAqB,CAAA;AAE1C,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,MAAM,CAAU,IAAI,CAAC,CAAA;AAarE,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,OAAsC;IAEtC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IACvC,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,MAAM,EAAE,CAAA;IAEvC,IAAI,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAA;IAEtE,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAA;QAC7C,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,OAAO;YAAE,OAAO,IAAI,CAAA;QAClD,IAAI,MAAM;YAAE,OAAO,eAAe,CAAC,OAAkB,CAAC,KAAK,OAAO,CAAA;QAClE,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,EAAE,CAAA;IACJ,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACpC,OAAO,MAAM,CAAA;AACf,CAAC"}

10
node_modules/viem/_esm/utils/address/isAddressEqual.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import { InvalidAddressError, } from '../../errors/address.js';
import { isAddress } from './isAddress.js';
export function isAddressEqual(a, b) {
if (!isAddress(a, { strict: false }))
throw new InvalidAddressError({ address: a });
if (!isAddress(b, { strict: false }))
throw new InvalidAddressError({ address: b });
return a.toLowerCase() === b.toLowerCase();
}
//# sourceMappingURL=isAddressEqual.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isAddressEqual.js","sourceRoot":"","sources":["../../../utils/address/isAddressEqual.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,GAEpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,UAAU,cAAc,CAAC,CAAU,EAAE,CAAU;IACnD,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;AAC5C,CAAC"}

View File

@@ -0,0 +1,24 @@
import { concatHex } from '../data/concat.js';
import { hexToBytes } from '../encoding/toBytes.js';
import { numberToHex } from '../encoding/toHex.js';
import { toRlp } from '../encoding/toRlp.js';
import { keccak256 } from '../hash/keccak256.js';
/**
* Computes an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
*/
export function hashAuthorization(parameters) {
const { chainId, nonce, to } = parameters;
const address = parameters.contractAddress ?? parameters.address;
const hash = keccak256(concatHex([
'0x05',
toRlp([
chainId ? numberToHex(chainId) : '0x',
address,
nonce ? numberToHex(nonce) : '0x',
]),
]));
if (to === 'bytes')
return hexToBytes(hash);
return hash;
}
//# sourceMappingURL=hashAuthorization.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hashAuthorization.js","sourceRoot":"","sources":["../../../utils/authorization/hashAuthorization.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAA4B,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAA6B,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAuB,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAA2B,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAsBzE;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA2C;IAE3C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,IAAI,UAAU,CAAC,OAAO,CAAA;IAChE,MAAM,IAAI,GAAG,SAAS,CACpB,SAAS,CAAC;QACR,MAAM;QACN,KAAK,CAAC;YACJ,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;YACrC,OAAO;YACP,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;SAClC,CAAC;KACH,CAAC,CACH,CAAA;IACD,IAAI,EAAE,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC,IAAI,CAAoC,CAAA;IAC9E,OAAO,IAAuC,CAAA;AAChD,CAAC"}

View File

@@ -0,0 +1,10 @@
import { recoverAddress, } from '../signature/recoverAddress.js';
import { hashAuthorization, } from './hashAuthorization.js';
export async function recoverAuthorizationAddress(parameters) {
const { authorization, signature } = parameters;
return recoverAddress({
hash: hashAuthorization(authorization),
signature: (signature ?? authorization),
});
}
//# sourceMappingURL=recoverAuthorizationAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"recoverAuthorizationAddress.js","sourceRoot":"","sources":["../../../utils/authorization/recoverAuthorizationAddress.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,cAAc,GACf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAmC/B,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAK/C,UAAgE;IAEhE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;IAE/C,OAAO,cAAc,CAAC;QACpB,IAAI,EAAE,iBAAiB,CAAC,aAAqC,CAAC;QAC9D,SAAS,EAAE,CAAC,SAAS,IAAI,aAAa,CAAc;KACrD,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,22 @@
import { toHex } from '../encoding/toHex.js';
import { toYParitySignatureArray } from '../transaction/serializeTransaction.js';
/*
* Serializes an EIP-7702 authorization list.
*/
export function serializeAuthorizationList(authorizationList) {
if (!authorizationList || authorizationList.length === 0)
return [];
const serializedAuthorizationList = [];
for (const authorization of authorizationList) {
const { chainId, nonce, ...signature } = authorization;
const contractAddress = authorization.address;
serializedAuthorizationList.push([
chainId ? toHex(chainId) : '0x',
contractAddress,
nonce ? toHex(nonce) : '0x',
...toYParitySignatureArray({}, signature),
]);
}
return serializedAuthorizationList;
}
//# sourceMappingURL=serializeAuthorizationList.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"serializeAuthorizationList.js","sourceRoot":"","sources":["../../../utils/authorization/serializeAuthorizationList.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAMhF;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,iBAA+D;IAE/D,IAAI,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEnE,MAAM,2BAA2B,GAAG,EAAE,CAAA;IACtC,KAAK,MAAM,aAAa,IAAI,iBAAiB,EAAE,CAAC;QAC9C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,aAAa,CAAA;QACtD,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAA;QAC7C,2BAA2B,CAAC,IAAI,CAAC;YAC/B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;YAC/B,eAAe;YACf,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;YAC3B,GAAG,uBAAuB,CAAC,EAAE,EAAE,SAAS,CAAC;SAC1C,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,2BAAyE,CAAA;AAClF,CAAC"}

View File

@@ -0,0 +1,18 @@
import { getAddress } from '../address/getAddress.js';
import { isAddressEqual, } from '../address/isAddressEqual.js';
import { recoverAuthorizationAddress, } from './recoverAuthorizationAddress.js';
/**
* Verify that an Authorization object was signed by the provided address.
*
* - Docs {@link https://viem.sh/docs/utilities/verifyAuthorization}
*
* @param parameters - {@link VerifyAuthorizationParameters}
* @returns Whether or not the signature is valid. {@link VerifyAuthorizationReturnType}
*/
export async function verifyAuthorization({ address, authorization, signature, }) {
return isAddressEqual(getAddress(address), await recoverAuthorizationAddress({
authorization,
signature,
}));
}
//# sourceMappingURL=verifyAuthorization.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"verifyAuthorization.js","sourceRoot":"","sources":["../../../utils/authorization/verifyAuthorization.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAEL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,2BAA2B,GAC5B,MAAM,kCAAkC,CAAA;AAgBzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EACxC,OAAO,EACP,aAAa,EACb,SAAS,GACqB;IAC9B,OAAO,cAAc,CACnB,UAAU,CAAC,OAAO,CAAC,EACnB,MAAM,2BAA2B,CAAC;QAChC,aAAa;QACb,SAAS;KACV,CAAC,CACH,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,28 @@
import { hexToBytes } from '../encoding/toBytes.js';
import { bytesToHex } from '../encoding/toHex.js';
/**
* Compute commitments from a list of blobs.
*
* @example
* ```ts
* import { blobsToCommitments, toBlobs } from 'viem'
* import { kzg } from './kzg'
*
* const blobs = toBlobs({ data: '0x1234' })
* const commitments = blobsToCommitments({ blobs, kzg })
* ```
*/
export function blobsToCommitments(parameters) {
const { kzg } = parameters;
const to = parameters.to ?? (typeof parameters.blobs[0] === 'string' ? 'hex' : 'bytes');
const blobs = (typeof parameters.blobs[0] === 'string'
? parameters.blobs.map((x) => hexToBytes(x))
: parameters.blobs);
const commitments = [];
for (const blob of blobs)
commitments.push(Uint8Array.from(kzg.blobToKzgCommitment(blob)));
return (to === 'bytes'
? commitments
: commitments.map((x) => bytesToHex(x)));
}
//# sourceMappingURL=blobsToCommitments.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"blobsToCommitments.js","sourceRoot":"","sources":["../../../utils/blob/blobsToCommitments.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAA4B,UAAU,EAAE,MAAM,sBAAsB,CAAA;AA2B3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAMhC,UAAmD;IAEnD,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAA;IAE1B,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC9E,MAAM,KAAK,GAAG,CACZ,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;QACrC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,UAAU,CAAC,KAAK,CACN,CAAA;IAEhB,MAAM,WAAW,GAAgB,EAAE,CAAA;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK;QACtB,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAElE,OAAO,CAAC,EAAE,KAAK,OAAO;QACpB,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACpB,UAAU,CAAC,CAAC,CAAC,CACd,CAA2C,CAAA;AAClD,CAAC"}

38
node_modules/viem/_esm/utils/blob/blobsToProofs.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import { hexToBytes } from '../encoding/toBytes.js';
import { bytesToHex } from '../encoding/toHex.js';
/**
* Compute the proofs for a list of blobs and their commitments.
*
* @example
* ```ts
* import {
* blobsToCommitments,
* toBlobs
* } from 'viem'
* import { kzg } from './kzg'
*
* const blobs = toBlobs({ data: '0x1234' })
* const commitments = blobsToCommitments({ blobs, kzg })
* const proofs = blobsToProofs({ blobs, commitments, kzg })
* ```
*/
export function blobsToProofs(parameters) {
const { kzg } = parameters;
const to = parameters.to ?? (typeof parameters.blobs[0] === 'string' ? 'hex' : 'bytes');
const blobs = (typeof parameters.blobs[0] === 'string'
? parameters.blobs.map((x) => hexToBytes(x))
: parameters.blobs);
const commitments = (typeof parameters.commitments[0] === 'string'
? parameters.commitments.map((x) => hexToBytes(x))
: parameters.commitments);
const proofs = [];
for (let i = 0; i < blobs.length; i++) {
const blob = blobs[i];
const commitment = commitments[i];
proofs.push(Uint8Array.from(kzg.computeBlobKzgProof(blob, commitment)));
}
return (to === 'bytes'
? proofs
: proofs.map((x) => bytesToHex(x)));
}
//# sourceMappingURL=blobsToProofs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"blobsToProofs.js","sourceRoot":"","sources":["../../../utils/blob/blobsToProofs.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAA4B,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAqC3E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAO3B,UAA2D;IAE3D,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAA;IAE1B,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAE9E,MAAM,KAAK,GAAG,CACZ,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;QACrC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,UAAU,CAAC,KAAK,CACN,CAAA;IAChB,MAAM,WAAW,GAAG,CAClB,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ;QAC3C,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAQ,CAAC,CAAC;QACzD,CAAC,CAAC,UAAU,CAAC,WAAW,CACZ,CAAA;IAEhB,MAAM,MAAM,GAAgB,EAAE,CAAA;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACrB,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QACjC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,OAAO,CAAC,EAAE,KAAK,OAAO;QACpB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAsC,CAAA;AAC5E,CAAC"}

View File

@@ -0,0 +1,27 @@
import { bytesToHex } from '../encoding/toHex.js';
import { sha256 } from '../hash/sha256.js';
/**
* Transform a commitment to it's versioned hash.
*
* @example
* ```ts
* import {
* blobsToCommitments,
* commitmentToVersionedHash,
* toBlobs
* } from 'viem'
* import { kzg } from './kzg'
*
* const blobs = toBlobs({ data: '0x1234' })
* const [commitment] = blobsToCommitments({ blobs, kzg })
* const versionedHash = commitmentToVersionedHash({ commitment })
* ```
*/
export function commitmentToVersionedHash(parameters) {
const { commitment, version = 1 } = parameters;
const to = parameters.to ?? (typeof commitment === 'string' ? 'hex' : 'bytes');
const versionedHash = sha256(commitment, 'bytes');
versionedHash.set([version], 0);
return (to === 'bytes' ? versionedHash : bytesToHex(versionedHash));
}
//# sourceMappingURL=commitmentToVersionedHash.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"commitmentToVersionedHash.js","sourceRoot":"","sources":["../../../utils/blob/commitmentToVersionedHash.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAwB,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAyBhE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CAMvC,UAA+D;IAE/D,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,UAAU,CAAA;IAC9C,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAE9E,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACjD,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,OAAO,CACL,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAChB,CAAA;AAC9C,CAAC"}

View File

@@ -0,0 +1,32 @@
import { commitmentToVersionedHash, } from './commitmentToVersionedHash.js';
/**
* Transform a list of commitments to their versioned hashes.
*
* @example
* ```ts
* import {
* blobsToCommitments,
* commitmentsToVersionedHashes,
* toBlobs
* } from 'viem'
* import { kzg } from './kzg'
*
* const blobs = toBlobs({ data: '0x1234' })
* const commitments = blobsToCommitments({ blobs, kzg })
* const versionedHashes = commitmentsToVersionedHashes({ commitments })
* ```
*/
export function commitmentsToVersionedHashes(parameters) {
const { commitments, version } = parameters;
const to = parameters.to ?? (typeof commitments[0] === 'string' ? 'hex' : 'bytes');
const hashes = [];
for (const commitment of commitments) {
hashes.push(commitmentToVersionedHash({
commitment,
to,
version,
}));
}
return hashes;
}
//# sourceMappingURL=commitmentsToVersionedHashes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"commitmentsToVersionedHashes.js","sourceRoot":"","sources":["../../../utils/blob/commitmentsToVersionedHashes.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,yBAAyB,GAC1B,MAAM,gCAAgC,CAAA;AA0BvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,4BAA4B,CAM1C,UAAmE;IAEnE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,UAAU,CAAA;IAE3C,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAEzE,MAAM,MAAM,GAAyB,EAAE,CAAA;IACvC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CACT,yBAAyB,CAAC;YACxB,UAAU;YACV,EAAE;YACF,OAAO;SACR,CAAQ,CACV,CAAA;IACH,CAAC;IACD,OAAO,MAAa,CAAA;AACtB,CAAC"}

34
node_modules/viem/_esm/utils/blob/fromBlobs.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import { createCursor } from '../cursor.js';
import { hexToBytes } from '../encoding/toBytes.js';
import { bytesToHex } from '../encoding/toHex.js';
export function fromBlobs(parameters) {
const to = parameters.to ?? (typeof parameters.blobs[0] === 'string' ? 'hex' : 'bytes');
const blobs = (typeof parameters.blobs[0] === 'string'
? parameters.blobs.map((x) => hexToBytes(x))
: parameters.blobs);
const length = blobs.reduce((length, blob) => length + blob.length, 0);
const data = createCursor(new Uint8Array(length));
let active = true;
for (const blob of blobs) {
const cursor = createCursor(blob);
while (active && cursor.position < blob.length) {
// First byte will be a zero 0x00 byte we can skip.
cursor.incrementPosition(1);
let consume = 31;
if (blob.length - cursor.position < 31)
consume = blob.length - cursor.position;
for (const _ in Array.from({ length: consume })) {
const byte = cursor.readByte();
const isTerminator = byte === 0x80 && !cursor.inspectBytes(cursor.remaining).includes(0x80);
if (isTerminator) {
active = false;
break;
}
data.pushByte(byte);
}
}
}
const trimmedData = data.bytes.slice(0, data.position);
return (to === 'hex' ? bytesToHex(trimmedData) : trimmedData);
}
//# sourceMappingURL=fromBlobs.js.map

1
node_modules/viem/_esm/utils/blob/fromBlobs.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"fromBlobs.js","sourceRoot":"","sources":["../../../utils/blob/fromBlobs.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,YAAY,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAA4B,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAA4B,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAyB3E,MAAM,UAAU,SAAS,CAKvB,UAA0C;IAC1C,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC9E,MAAM,KAAK,GAAG,CACZ,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;QACrC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,UAAU,CAAC,KAAK,CACN,CAAA;IAEhB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACtE,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;IACjD,IAAI,MAAM,GAAG,IAAI,CAAA;IAEjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QACjC,OAAO,MAAM,IAAI,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/C,qDAAqD;YACrD,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;YAE3B,IAAI,OAAO,GAAG,EAAE,CAAA;YAChB,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,GAAG,EAAE;gBACpC,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAA;YAEzC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;gBAChD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;gBAC9B,MAAM,YAAY,GAChB,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;gBACxE,IAAI,YAAY,EAAE,CAAC;oBACjB,MAAM,GAAG,KAAK,CAAA;oBACd,MAAK;gBACP,CAAC;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtD,OAAO,CACL,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAC1B,CAAA;AAC9B,CAAC"}

View File

@@ -0,0 +1,26 @@
import { commitmentToVersionedHash, } from './commitmentToVersionedHash.js';
/**
* Transforms a list of sidecars to their versioned hashes.
*
* @example
* ```ts
* import { toBlobSidecars, sidecarsToVersionedHashes, stringToHex } from 'viem'
*
* const sidecars = toBlobSidecars({ data: stringToHex('hello world') })
* const versionedHashes = sidecarsToVersionedHashes({ sidecars })
* ```
*/
export function sidecarsToVersionedHashes(parameters) {
const { sidecars, version } = parameters;
const to = parameters.to ?? (typeof sidecars[0].blob === 'string' ? 'hex' : 'bytes');
const hashes = [];
for (const { commitment } of sidecars) {
hashes.push(commitmentToVersionedHash({
commitment,
to,
version,
}));
}
return hashes;
}
//# sourceMappingURL=sidecarsToVersionedHashes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sidecarsToVersionedHashes.js","sourceRoot":"","sources":["../../../utils/blob/sidecarsToVersionedHashes.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,yBAAyB,GAC1B,MAAM,gCAAgC,CAAA;AAwBvC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,yBAAyB,CAMvC,UAA6D;IAE7D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAA;IAExC,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAE3E,MAAM,MAAM,GAAyB,EAAE,CAAA;IACvC,KAAK,MAAM,EAAE,UAAU,EAAE,IAAI,QAAQ,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CACT,yBAAyB,CAAC;YACxB,UAAU;YACV,EAAE;YACF,OAAO;SACR,CAAQ,CACV,CAAA;IACH,CAAC;IACD,OAAO,MAAa,CAAA;AACtB,CAAC"}

45
node_modules/viem/_esm/utils/blob/toBlobSidecars.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import { blobsToCommitments, } from './blobsToCommitments.js';
import { blobsToProofs } from './blobsToProofs.js';
import { toBlobs } from './toBlobs.js';
/**
* Transforms arbitrary data (or blobs, commitments, & proofs) into a sidecar array.
*
* @example
* ```ts
* import { toBlobSidecars, stringToHex } from 'viem'
*
* const sidecars = toBlobSidecars({ data: stringToHex('hello world') })
* ```
*
* @example
* ```ts
* import {
* blobsToCommitments,
* toBlobs,
* blobsToProofs,
* toBlobSidecars,
* stringToHex
* } from 'viem'
*
* const blobs = toBlobs({ data: stringToHex('hello world') })
* const commitments = blobsToCommitments({ blobs, kzg })
* const proofs = blobsToProofs({ blobs, commitments, kzg })
*
* const sidecars = toBlobSidecars({ blobs, commitments, proofs })
* ```
*/
export function toBlobSidecars(parameters) {
const { data, kzg, to } = parameters;
const blobs = parameters.blobs ?? toBlobs({ data: data, to });
const commitments = parameters.commitments ?? blobsToCommitments({ blobs, kzg: kzg, to });
const proofs = parameters.proofs ?? blobsToProofs({ blobs, commitments, kzg: kzg, to });
const sidecars = [];
for (let i = 0; i < blobs.length; i++)
sidecars.push({
blob: blobs[i],
commitment: commitments[i],
proof: proofs[i],
});
return sidecars;
}
//# sourceMappingURL=toBlobSidecars.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toBlobSidecars.js","sourceRoot":"","sources":["../../../utils/blob/toBlobSidecars.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAA+B,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAAyB,OAAO,EAAE,MAAM,cAAc,CAAA;AA4C7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,cAAc,CAY5B,UAAqD;IAErD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACpC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,IAAK,EAAE,EAAE,EAAE,CAAC,CAAA;IAC9D,MAAM,WAAW,GACf,UAAU,CAAC,WAAW,IAAI,kBAAkB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACxE,MAAM,MAAM,GACV,UAAU,CAAC,MAAM,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,GAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAE3E,MAAM,QAAQ,GAAiB,EAAE,CAAA;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QACnC,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACd,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;YAC1B,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;SACjB,CAAC,CAAA;IAEJ,OAAO,QAAwC,CAAA;AACjD,CAAC"}

58
node_modules/viem/_esm/utils/blob/toBlobs.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import { bytesPerBlob, bytesPerFieldElement, fieldElementsPerBlob, maxBytesPerTransaction, } from '../../constants/blob.js';
import { BlobSizeTooLargeError, EmptyBlobError, } from '../../errors/blob.js';
import { createCursor } from '../cursor.js';
import { size } from '../data/size.js';
import { hexToBytes } from '../encoding/toBytes.js';
import { bytesToHex } from '../encoding/toHex.js';
/**
* Transforms arbitrary data to blobs.
*
* @example
* ```ts
* import { toBlobs, stringToHex } from 'viem'
*
* const blobs = toBlobs({ data: stringToHex('hello world') })
* ```
*/
export function toBlobs(parameters) {
const to = parameters.to ?? (typeof parameters.data === 'string' ? 'hex' : 'bytes');
const data = (typeof parameters.data === 'string'
? hexToBytes(parameters.data)
: parameters.data);
const size_ = size(data);
if (!size_)
throw new EmptyBlobError();
if (size_ > maxBytesPerTransaction)
throw new BlobSizeTooLargeError({
maxSize: maxBytesPerTransaction,
size: size_,
});
const blobs = [];
let active = true;
let position = 0;
while (active) {
const blob = createCursor(new Uint8Array(bytesPerBlob));
let size = 0;
while (size < fieldElementsPerBlob) {
const bytes = data.slice(position, position + (bytesPerFieldElement - 1));
// Push a zero byte so the field element doesn't overflow the BLS modulus.
blob.pushByte(0x00);
// Push the current segment of data bytes.
blob.pushBytes(bytes);
// If we detect that the current segment of data bytes is less than 31 bytes,
// we can stop processing and push a terminator byte to indicate the end of the blob.
if (bytes.length < 31) {
blob.pushByte(0x80);
active = false;
break;
}
size++;
position += 31;
}
blobs.push(blob);
}
return (to === 'bytes'
? blobs.map((x) => x.bytes)
: blobs.map((x) => bytesToHex(x.bytes)));
}
//# sourceMappingURL=toBlobs.js.map

1
node_modules/viem/_esm/utils/blob/toBlobs.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"toBlobs.js","sourceRoot":"","sources":["../../../utils/blob/toBlobs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,qBAAqB,EAErB,cAAc,GAEf,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAA8B,YAAY,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAsB,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAA4B,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAA4B,UAAU,EAAE,MAAM,sBAAsB,CAAA;AA2B3E;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAKrB,UAAuC;IACvC,MAAM,EAAE,GACN,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC1E,MAAM,IAAI,GAAG,CACX,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ;QACjC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;QAC7B,CAAC,CAAC,UAAU,CAAC,IAAI,CACP,CAAA;IAEd,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,CAAC,KAAK;QAAE,MAAM,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,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CACnC,CAAA;AACV,CAAC"}

199
node_modules/viem/_esm/utils/buildRequest.js generated vendored Normal file
View File

@@ -0,0 +1,199 @@
import { BaseError } from '../errors/base.js';
import { HttpRequestError, } from '../errors/request.js';
import { AtomicityNotSupportedError, AtomicReadyWalletRejectedUpgradeError, BundleTooLargeError, ChainDisconnectedError, DuplicateIdError, InternalRpcError, InvalidInputRpcError, InvalidParamsRpcError, InvalidRequestRpcError, JsonRpcVersionUnsupportedError, LimitExceededRpcError, MethodNotFoundRpcError, MethodNotSupportedRpcError, ParseRpcError, ProviderDisconnectedError, ResourceNotFoundRpcError, ResourceUnavailableRpcError, SwitchChainError, TransactionRejectedRpcError, UnauthorizedProviderError, UnknownBundleIdError, UnknownRpcError, UnsupportedChainIdError, UnsupportedNonOptionalCapabilityError, UnsupportedProviderMethodError, UserRejectedRequestError, WalletConnectSessionSettlementError, } from '../errors/rpc.js';
import { withDedupe } from './promise/withDedupe.js';
import { withRetry } from './promise/withRetry.js';
import { stringify } from './stringify.js';
export function buildRequest(request, options = {}) {
return async (args, overrideOptions = {}) => {
const { dedupe = false, methods, retryDelay = 150, retryCount = 3, uid, } = {
...options,
...overrideOptions,
};
const { method } = args;
if (methods?.exclude?.includes(method))
throw new MethodNotSupportedRpcError(new Error('method not supported'), {
method,
});
if (methods?.include && !methods.include.includes(method))
throw new MethodNotSupportedRpcError(new Error('method not supported'), {
method,
});
const requestId = dedupe
? hashString(`${uid}.${stringify(args)}`)
: undefined;
return withDedupe(() => withRetry(async () => {
try {
return await request(args);
}
catch (err_) {
const err = err_;
switch (err.code) {
// -32700
case ParseRpcError.code:
throw new ParseRpcError(err);
// -32600
case InvalidRequestRpcError.code:
throw new InvalidRequestRpcError(err);
// -32601
case MethodNotFoundRpcError.code:
throw new MethodNotFoundRpcError(err, { method: args.method });
// -32602
case InvalidParamsRpcError.code:
throw new InvalidParamsRpcError(err);
// -32603
case InternalRpcError.code:
throw new InternalRpcError(err);
// -32000
case InvalidInputRpcError.code:
throw new InvalidInputRpcError(err);
// -32001
case ResourceNotFoundRpcError.code:
throw new ResourceNotFoundRpcError(err);
// -32002
case ResourceUnavailableRpcError.code:
throw new ResourceUnavailableRpcError(err);
// -32003
case TransactionRejectedRpcError.code:
throw new TransactionRejectedRpcError(err);
// -32004
case MethodNotSupportedRpcError.code:
throw new MethodNotSupportedRpcError(err, {
method: args.method,
});
// -32005
case LimitExceededRpcError.code:
throw new LimitExceededRpcError(err);
// -32006
case JsonRpcVersionUnsupportedError.code:
throw new JsonRpcVersionUnsupportedError(err);
// 4001
case UserRejectedRequestError.code:
throw new UserRejectedRequestError(err);
// 4100
case UnauthorizedProviderError.code:
throw new UnauthorizedProviderError(err);
// 4200
case UnsupportedProviderMethodError.code:
throw new UnsupportedProviderMethodError(err);
// 4900
case ProviderDisconnectedError.code:
throw new ProviderDisconnectedError(err);
// 4901
case ChainDisconnectedError.code:
throw new ChainDisconnectedError(err);
// 4902
case SwitchChainError.code:
throw new SwitchChainError(err);
// 5700
case UnsupportedNonOptionalCapabilityError.code:
throw new UnsupportedNonOptionalCapabilityError(err);
// 5710
case UnsupportedChainIdError.code:
throw new UnsupportedChainIdError(err);
// 5720
case DuplicateIdError.code:
throw new DuplicateIdError(err);
// 5730
case UnknownBundleIdError.code:
throw new UnknownBundleIdError(err);
// 5740
case BundleTooLargeError.code:
throw new BundleTooLargeError(err);
// 5750
case AtomicReadyWalletRejectedUpgradeError.code:
throw new AtomicReadyWalletRejectedUpgradeError(err);
// 5760
case AtomicityNotSupportedError.code:
throw new AtomicityNotSupportedError(err);
// CAIP-25: User Rejected Error
// https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25
case 5000:
throw new UserRejectedRequestError(err);
// WalletConnect: Session Settlement Failed
// https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes
case WalletConnectSessionSettlementError.code:
throw new WalletConnectSessionSettlementError(err);
default:
if (err_ instanceof BaseError)
throw err_;
throw new UnknownRpcError(err);
}
}
}, {
delay: ({ count, error }) => {
// If we find a Retry-After header, let's retry after the given time.
if (error && error instanceof HttpRequestError) {
const retryAfter = error?.headers?.get('Retry-After');
if (retryAfter?.match(/\d/))
return Number.parseInt(retryAfter, 10) * 1000;
}
// Otherwise, let's retry with an exponential backoff.
return ~~(1 << count) * retryDelay;
},
retryCount,
shouldRetry: ({ error }) => shouldRetry(error),
}), { enabled: dedupe, id: requestId });
};
}
/** @internal */
export function shouldRetry(error) {
if ('code' in error && typeof error.code === 'number') {
if (error.code === -1)
return true; // Unknown error
if (error.code === LimitExceededRpcError.code)
return true;
if (error.code === InternalRpcError.code)
return true;
// Too Many Requests — some providers (e.g. Alchemy in batch mode) return
// HTTP 200 with a JSON-RPC body of `{ code: 429 }` instead of an HTTP 429,
// so we need to handle this code in addition to the HTTP status check below.
if (error.code === 429)
return true;
return false;
}
if (error instanceof HttpRequestError && error.status) {
// Forbidden
if (error.status === 403)
return true;
// Request Timeout
if (error.status === 408)
return true;
// Request Entity Too Large
if (error.status === 413)
return true;
// Too Many Requests
if (error.status === 429)
return true;
// Internal Server Error
if (error.status === 500)
return true;
// Bad Gateway
if (error.status === 502)
return true;
// Service Unavailable
if (error.status === 503)
return true;
// Gateway Timeout
if (error.status === 504)
return true;
return false;
}
return true;
}
/** @internal cyrb53 fast, non-cryptographic 53-bit string hash */
function hashString(str, seed = 0) {
let h1 = 0xdeadbeef ^ seed;
let h2 = 0x41c6ce57 ^ seed;
for (let i = 0; i < str.length; i++) {
const ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
h1 ^= Math.imul(h2 ^ (h2 >>> 16), 3266489909);
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
h2 ^= Math.imul(h1 ^ (h1 >>> 16), 3266489909);
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
}
//# sourceMappingURL=buildRequest.js.map

1
node_modules/viem/_esm/utils/buildRequest.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

130
node_modules/viem/_esm/utils/ccip.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
import { call } from '../actions/public/call.js';
import { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';
import { HttpRequestError, } from '../errors/request.js';
import { decodeErrorResult } from './abi/decodeErrorResult.js';
import { encodeAbiParameters } from './abi/encodeAbiParameters.js';
import { isAddressEqual } from './address/isAddressEqual.js';
import { concat } from './data/concat.js';
import { isHex } from './data/isHex.js';
import { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';
import { stringify } from './stringify.js';
export const offchainLookupSignature = '0x556f1830';
export const offchainLookupAbiItem = {
name: 'OffchainLookup',
type: 'error',
inputs: [
{
name: 'sender',
type: 'address',
},
{
name: 'urls',
type: 'string[]',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'callbackFunction',
type: 'bytes4',
},
{
name: 'extraData',
type: 'bytes',
},
],
};
export async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {
const { args } = decodeErrorResult({
data,
abi: [offchainLookupAbiItem],
});
const [sender, urls, callData, callbackSelector, extraData] = args;
const { ccipRead } = client;
const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'
? ccipRead.request
: ccipRequest;
try {
if (!isAddressEqual(to, sender))
throw new OffchainLookupSenderMismatchError({ sender, to });
const result = urls.includes(localBatchGatewayUrl)
? await localBatchGatewayRequest({
data: callData,
ccipRequest: ccipRequest_,
})
: await ccipRequest_({ data: callData, sender, urls });
const { data: data_ } = await call(client, {
blockNumber,
blockTag,
data: concat([
callbackSelector,
encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),
]),
to,
});
return data_;
}
catch (err) {
throw new OffchainLookupError({
callbackSelector,
cause: err,
data,
extraData,
sender,
urls,
});
}
}
export async function ccipRequest({ data, sender, urls, }) {
let error = new Error('An unknown error occurred.');
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
const method = url.includes('{data}') ? 'GET' : 'POST';
const body = method === 'POST' ? { data, sender } : undefined;
const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};
try {
const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {
body: JSON.stringify(body),
headers,
method,
});
let result;
if (response.headers.get('Content-Type')?.startsWith('application/json')) {
result = (await response.json()).data;
}
else {
result = (await response.text());
}
if (!response.ok) {
error = new HttpRequestError({
body,
details: result?.error
? stringify(result.error)
: response.statusText,
headers: response.headers,
status: response.status,
url,
});
continue;
}
if (!isHex(result)) {
error = new OffchainLookupResponseMalformedError({
result,
url,
});
continue;
}
return result;
}
catch (err) {
error = new HttpRequestError({
body,
details: err.message,
url,
});
}
}
throw error;
}
//# sourceMappingURL=ccip.js.map

1
node_modules/viem/_esm/utils/ccip.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ccip.js","sourceRoot":"","sources":["../../utils/ccip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAIrE,OAAO,EACL,mBAAmB,EAEnB,oCAAoC,EAEpC,iCAAiC,GAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,gBAAgB,GAEjB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,SAAS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,MAAM;oBACN,GAAG;iBACJ,CAAC,CAAA;gBACF,SAAQ;YACV,CAAC;YAED,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,GAAG,IAAI,gBAAgB,CAAC;gBAC3B,IAAI;gBACJ,OAAO,EAAG,GAAa,CAAC,OAAO;gBAC/B,GAAG;aACJ,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,MAAM,KAAK,CAAA;AACb,CAAC"}

View File

@@ -0,0 +1,8 @@
import { ChainMismatchError, ChainNotFoundError, } from '../../errors/chain.js';
export function assertCurrentChain({ chain, currentChainId, }) {
if (!chain)
throw new ChainNotFoundError();
if (currentChainId !== chain.id)
throw new ChainMismatchError({ chain, currentChainId });
}
//# sourceMappingURL=assertCurrentChain.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"assertCurrentChain.js","sourceRoot":"","sources":["../../../utils/chain/assertCurrentChain.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,kBAAkB,GAEnB,MAAM,uBAAuB,CAAA;AAc9B,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,cAAc,GACe;IAC7B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,kBAAkB,EAAE,CAAA;IAC1C,IAAI,cAAc,KAAK,KAAK,CAAC,EAAE;QAC7B,MAAM,IAAI,kBAAkB,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAA;AAC3D,CAAC"}

22
node_modules/viem/_esm/utils/chain/defineChain.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
export function defineChain(chain) {
const chainInstance = {
formatters: undefined,
fees: undefined,
serializers: undefined,
...chain,
};
function extend(base) {
return (fnOrExtended) => {
const properties = (typeof fnOrExtended === 'function' ? fnOrExtended(base) : fnOrExtended);
const combined = { ...base, ...properties };
return Object.assign(combined, { extend: extend(combined) });
};
}
return Object.assign(chainInstance, {
extend: extend(chainInstance),
});
}
export function extendSchema() {
return {};
}
//# sourceMappingURL=defineChain.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defineChain.js","sourceRoot":"","sources":["../../../utils/chain/defineChain.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,WAAW,CAGzB,KAAY;IACZ,MAAM,aAAa,GAAG;QACpB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,SAAS;QACtB,GAAG,KAAK;KAC0B,CAAA;IAEpC,SAAS,MAAM,CAAC,IAA0B;QAExC,OAAO,CAAC,YAAgD,EAAE,EAAE;YAC1D,MAAM,UAAU,GAAG,CACjB,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAC7B,CAAA;YAC3C,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,EAAE,CAAA;YAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;QAClC,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;KAC9B,CAAU,CAAA;AACb,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,EAAY,CAAA;AACrB,CAAC"}

4
node_modules/viem/_esm/utils/chain/extractChain.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export function extractChain({ chains, id, }) {
return chains.find((chain) => chain.id === id);
}
//# sourceMappingURL=extractChain.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractChain.js","sourceRoot":"","sources":["../../../utils/chain/extractChain.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,YAAY,CAG1B,EACA,MAAM,EACN,EAAE,GACsC;IAIxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAG5C,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,22 @@
import { ChainDoesNotSupportContract, } from '../../errors/chain.js';
export function getChainContractAddress({ blockNumber, chain, contract: name, }) {
const contract = chain?.contracts?.[name];
if (!contract)
throw new ChainDoesNotSupportContract({
chain,
contract: { name },
});
if (blockNumber &&
contract.blockCreated &&
contract.blockCreated > blockNumber)
throw new ChainDoesNotSupportContract({
blockNumber,
chain,
contract: {
name,
blockCreated: contract.blockCreated,
},
});
return contract.address;
}
//# sourceMappingURL=getChainContractAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getChainContractAddress.js","sourceRoot":"","sources":["../../../utils/chain/getChainContractAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,uBAAuB,CAAA;AAM9B,MAAM,UAAU,uBAAuB,CAAC,EACtC,WAAW,EACX,KAAK,EACL,QAAQ,EAAE,IAAI,GAKf;IACC,MAAM,QAAQ,GAAI,KAAK,EAAE,SAA2C,EAAE,CAAC,IAAI,CAAC,CAAA;IAC5E,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,2BAA2B,CAAC;YACpC,KAAK;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE;SACnB,CAAC,CAAA;IAEJ,IACE,WAAW;QACX,QAAQ,CAAC,YAAY;QACrB,QAAQ,CAAC,YAAY,GAAG,WAAW;QAEnC,MAAM,IAAI,2BAA2B,CAAC;YACpC,WAAW;YACX,KAAK;YACL,QAAQ,EAAE;gBACR,IAAI;gBACJ,YAAY,EAAE,QAAQ,CAAC,YAAY;aACpC;SACF,CAAC,CAAA;IAEJ,OAAO,QAAQ,CAAC,OAAO,CAAA;AACzB,CAAC"}

170
node_modules/viem/_esm/utils/cursor.js generated vendored Normal file
View File

@@ -0,0 +1,170 @@
import { NegativeOffsetError, PositionOutOfBoundsError, RecursiveReadLimitExceededError, } from '../errors/cursor.js';
const staticCursor = {
bytes: new Uint8Array(),
dataView: new DataView(new ArrayBuffer(0)),
position: 0,
positionReadCount: new Map(),
recursiveReadCount: 0,
recursiveReadLimit: Number.POSITIVE_INFINITY,
assertReadLimit() {
if (this.recursiveReadCount >= this.recursiveReadLimit)
throw new RecursiveReadLimitExceededError({
count: this.recursiveReadCount + 1,
limit: this.recursiveReadLimit,
});
},
assertPosition(position) {
if (position < 0 || position > this.bytes.length - 1)
throw new PositionOutOfBoundsError({
length: this.bytes.length,
position,
});
},
decrementPosition(offset) {
if (offset < 0)
throw new NegativeOffsetError({ offset });
const position = this.position - offset;
this.assertPosition(position);
this.position = position;
},
getReadCount(position) {
return this.positionReadCount.get(position || this.position) || 0;
},
incrementPosition(offset) {
if (offset < 0)
throw new NegativeOffsetError({ offset });
const position = this.position + offset;
this.assertPosition(position);
this.position = position;
},
inspectByte(position_) {
const position = position_ ?? this.position;
this.assertPosition(position);
return this.bytes[position];
},
inspectBytes(length, position_) {
const position = position_ ?? this.position;
this.assertPosition(position + length - 1);
return this.bytes.subarray(position, position + length);
},
inspectUint8(position_) {
const position = position_ ?? this.position;
this.assertPosition(position);
return this.bytes[position];
},
inspectUint16(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 1);
return this.dataView.getUint16(position);
},
inspectUint24(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 2);
return ((this.dataView.getUint16(position) << 8) +
this.dataView.getUint8(position + 2));
},
inspectUint32(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 3);
return this.dataView.getUint32(position);
},
pushByte(byte) {
this.assertPosition(this.position);
this.bytes[this.position] = byte;
this.position++;
},
pushBytes(bytes) {
this.assertPosition(this.position + bytes.length - 1);
this.bytes.set(bytes, this.position);
this.position += bytes.length;
},
pushUint8(value) {
this.assertPosition(this.position);
this.bytes[this.position] = value;
this.position++;
},
pushUint16(value) {
this.assertPosition(this.position + 1);
this.dataView.setUint16(this.position, value);
this.position += 2;
},
pushUint24(value) {
this.assertPosition(this.position + 2);
this.dataView.setUint16(this.position, value >> 8);
this.dataView.setUint8(this.position + 2, value & ~4294967040);
this.position += 3;
},
pushUint32(value) {
this.assertPosition(this.position + 3);
this.dataView.setUint32(this.position, value);
this.position += 4;
},
readByte() {
this.assertReadLimit();
this._touch();
const value = this.inspectByte();
this.position++;
return value;
},
readBytes(length, size) {
this.assertReadLimit();
this._touch();
const value = this.inspectBytes(length);
this.position += size ?? length;
return value;
},
readUint8() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint8();
this.position += 1;
return value;
},
readUint16() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint16();
this.position += 2;
return value;
},
readUint24() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint24();
this.position += 3;
return value;
},
readUint32() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint32();
this.position += 4;
return value;
},
get remaining() {
return this.bytes.length - this.position;
},
setPosition(position) {
const oldPosition = this.position;
this.assertPosition(position);
this.position = position;
return () => (this.position = oldPosition);
},
_touch() {
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
return;
const count = this.getReadCount();
this.positionReadCount.set(this.position, count + 1);
if (count > 0)
this.recursiveReadCount++;
},
};
export function createCursor(bytes, { recursiveReadLimit = 8_192 } = {}) {
const cursor = Object.create(staticCursor);
cursor.bytes = bytes;
cursor.dataView = new DataView(bytes.buffer ?? bytes, bytes.byteOffset, bytes.byteLength);
cursor.positionReadCount = new Map();
cursor.recursiveReadLimit = recursiveReadLimit;
return cursor;
}
//# sourceMappingURL=cursor.js.map

1
node_modules/viem/_esm/utils/cursor.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

22
node_modules/viem/_esm/utils/data/concat.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
export function concat(values) {
if (typeof values[0] === 'string')
return concatHex(values);
return concatBytes(values);
}
export function concatBytes(values) {
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 function concatHex(values) {
return `0x${values.reduce((acc, x) => acc + x.replace('0x', ''), '')}`;
}
//# sourceMappingURL=concat.js.map

1
node_modules/viem/_esm/utils/data/concat.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../utils/data/concat.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,MAAM,CACpB,MAAwB;IAExB,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ;QAC/B,OAAO,SAAS,CAAC,MAAwB,CAA4B,CAAA;IACvE,OAAO,WAAW,CAAC,MAA8B,CAA4B,CAAA;AAC/E,CAAC;AAID,MAAM,UAAU,WAAW,CAAC,MAA4B;IACtD,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAA;IACtB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IACrC,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACvB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAA;IACtB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAID,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,KAAM,MAAgB,CAAC,MAAM,CAClC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EACrC,EAAE,CACH,EAAE,CAAA;AACL,CAAC"}

10
node_modules/viem/_esm/utils/data/isBytes.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
export function isBytes(value) {
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');
}
//# sourceMappingURL=isBytes.js.map

1
node_modules/viem/_esm/utils/data/isBytes.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"isBytes.js","sourceRoot":"","sources":["../../../utils/data/isBytes.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACxB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,CAAC,CAAC,mBAAmB,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACjD,OAAO,CACL,KAAK,CAAC,iBAAiB,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,YAAY,CACzE,CAAA;AACH,CAAC"}

8
node_modules/viem/_esm/utils/data/isHex.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export function isHex(value, { strict = true } = {}) {
if (!value)
return false;
if (typeof value !== 'string')
return false;
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x');
}
//# sourceMappingURL=isHex.js.map

1
node_modules/viem/_esm/utils/data/isHex.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"isHex.js","sourceRoot":"","sources":["../../../utils/data/isHex.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,KAAK,CACnB,KAAc,EACd,EAAE,MAAM,GAAG,IAAI,KAAuC,EAAE;IAExD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACxB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,OAAO,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AACzE,CAAC"}

36
node_modules/viem/_esm/utils/data/pad.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import { SizeExceedsPaddingSizeError, } from '../../errors/data.js';
export function pad(hexOrBytes, { dir, size = 32 } = {}) {
if (typeof hexOrBytes === 'string')
return padHex(hexOrBytes, { dir, size });
return padBytes(hexOrBytes, { dir, size });
}
export function padHex(hex_, { dir, size = 32 } = {}) {
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')}`;
}
export function padBytes(bytes, { dir, size = 32 } = {}) {
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;
}
//# sourceMappingURL=pad.js.map

1
node_modules/viem/_esm/utils/data/pad.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../../../utils/data/pad.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,sBAAsB,CAAA;AAc7B,MAAM,UAAU,GAAG,CACjB,UAAiB,EACjB,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE,KAAiB,EAAE;IAEnC,IAAI,OAAO,UAAU,KAAK,QAAQ;QAChC,OAAO,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAyB,CAAA;IAClE,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAyB,CAAA;AACpE,CAAC;AAID,MAAM,UAAU,MAAM,CAAC,IAAS,EAAE,EAAE,GAAG,E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AC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5C,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC"}

13
node_modules/viem/_esm/utils/data/size.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { isHex } from './isHex.js';
/**
* @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) {
if (isHex(value, { strict: false }))
return Math.ceil((value.length - 2) / 2);
return value.length;
}
//# sourceMappingURL=size.js.map

1
node_modules/viem/_esm/utils/data/size.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../../utils/data/size.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,EAAE,MAAM,YAAY,CAAA;AAIvD;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,KAAsB;IACzC,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7E,OAAO,KAAK,CAAC,MAAM,CAAA;AACrB,CAAC"}

69
node_modules/viem/_esm/utils/data/slice.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
import { SliceOffsetOutOfBoundsError, } from '../../errors/data.js';
import { isHex } from './isHex.js';
import { size } from './size.js';
/**
* @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, start, end, { strict } = {}) {
if (isHex(value, { strict: false }))
return sliceHex(value, start, end, {
strict,
});
return sliceBytes(value, start, end, {
strict,
});
}
function assertStartOffset(value, start) {
if (typeof start === 'number' && start > 0 && start > size(value) - 1)
throw new SliceOffsetOutOfBoundsError({
offset: start,
position: 'start',
size: size(value),
});
}
function assertEndOffset(value, start, end) {
if (typeof start === 'number' &&
typeof end === 'number' &&
size(value) !== end - start) {
throw new SliceOffsetOutOfBoundsError({
offset: end,
position: 'end',
size: size(value),
});
}
}
/**
* @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_, start, end, { strict } = {}) {
assertStartOffset(value_, start);
const value = value_.slice(start, end);
if (strict)
assertEndOffset(value, start, end);
return value;
}
/**
* @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_, start, end, { strict } = {}) {
assertStartOffset(value_, start);
const value = `0x${value_
.replace('0x', '')
.slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
if (strict)
assertEndOffset(value, start, end);
return value;
}
//# sourceMappingURL=slice.js.map

1
node_modules/viem/_esm/utils/data/slice.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"slice.js","sourceRoot":"","sources":["../../../utils/data/slice.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EAAuB,KAAK,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAsB,IAAI,EAAE,MAAM,WAAW,CAAA;AAYpD;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CACnB,KAAY,EACZ,KAA0B,EAC1B,GAAwB,EACxB,EAAE,MAAM,KAAuC,EAAE;IAEjD,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,KAAY,EAAE,KAAK,EAAE,GAAG,EAAE;YACxC,MAAM;SACP,CAA2B,CAAA;IAC9B,OAAO,UAAU,CAAC,KAAkB,EAAE,KAAK,EAAE,GAAG,EAAE;QA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IAChC,MAAM,KAAK,GAAG,KAAK,MAAM;SACtB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAW,CAAA;IACjE,IAAI,MAAM;QAAE,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IAC9C,OAAO,KAAK,CAAA;AACd,CAAC"}

21
node_modules/viem/_esm/utils/data/trim.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
export function trim(hexOrBytes, { dir = 'left' } = {}) {
let data = 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}`;
}
return data;
}
//# sourceMappingURL=trim.js.map

1
node_modules/viem/_esm/utils/data/trim.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../utils/data/trim.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,IAAI,CAClB,UAAiB,EACjB,EAAE,GAAG,GAAG,MAAM,KAAkB,EAAE;IAElC,IAAI,IAAI,GACN,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAE5E,IAAI,WAAW,GAAG,CAAC,CAAA;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,GAAG;YACnE,WAAW,EAAE,CAAA;;YACV,MAAK;IACZ,CAAC;IACD,IAAI;QACF,GAAG,KAAK,MAAM;YACZ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;YACzB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAA;IAE9C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,KAAK,OAAO;YAAE,IAAI,GAAG,GAAG,IAAI,GAAG,CAAA;QAC3D,OAAO,KACL,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IACvC,EAA2B,CAAA;IAC7B,CAAC;IACD,OAAO,IAA6B,CAAA;AACtC,CAAC"}

127
node_modules/viem/_esm/utils/encoding/fromBytes.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
import { InvalidBytesBooleanError } from '../../errors/encoding.js';
import { trim } from '../data/trim.js';
import { assertSize, hexToBigInt, hexToNumber, } from './fromHex.js';
import { bytesToHex } from './toHex.js';
/**
* Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
*
* - Docs: https://viem.sh/docs/utilities/fromBytes
* - Example: https://viem.sh/docs/utilities/fromBytes#usage
*
* @param bytes Byte array to decode.
* @param toOrOpts Type to convert to or options.
* @returns Decoded value.
*
* @example
* import { fromBytes } from 'viem'
* const data = fromBytes(new Uint8Array([1, 164]), 'number')
* // 420
*
* @example
* import { fromBytes } from 'viem'
* const data = fromBytes(
* new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]),
* 'string'
* )
* // 'Hello world'
*/
export function fromBytes(bytes, toOrOpts) {
const opts = typeof toOrOpts === 'string' ? { to: toOrOpts } : toOrOpts;
const to = opts.to;
if (to === 'number')
return bytesToNumber(bytes, opts);
if (to === 'bigint')
return bytesToBigInt(bytes, opts);
if (to === 'boolean')
return bytesToBool(bytes, opts);
if (to === 'string')
return bytesToString(bytes, opts);
return bytesToHex(bytes, opts);
}
/**
* Decodes a byte array into a bigint.
*
* - Docs: https://viem.sh/docs/utilities/fromBytes#bytestobigint
*
* @param bytes Byte array to decode.
* @param opts Options.
* @returns BigInt value.
*
* @example
* import { bytesToBigInt } from 'viem'
* const data = bytesToBigInt(new Uint8Array([1, 164]))
* // 420n
*/
export function bytesToBigInt(bytes, opts = {}) {
if (typeof opts.size !== 'undefined')
assertSize(bytes, { size: opts.size });
const hex = bytesToHex(bytes, opts);
return hexToBigInt(hex, opts);
}
/**
* Decodes a byte array into a boolean.
*
* - Docs: https://viem.sh/docs/utilities/fromBytes#bytestobool
*
* @param bytes Byte array to decode.
* @param opts Options.
* @returns Boolean value.
*
* @example
* import { bytesToBool } from 'viem'
* const data = bytesToBool(new Uint8Array([1]))
* // true
*/
export function bytesToBool(bytes_, opts = {}) {
let bytes = bytes_;
if (typeof opts.size !== 'undefined') {
assertSize(bytes, { size: opts.size });
bytes = trim(bytes);
}
if (bytes.length > 1 || bytes[0] > 1)
throw new InvalidBytesBooleanError(bytes);
return Boolean(bytes[0]);
}
/**
* Decodes a byte array into a number.
*
* - Docs: https://viem.sh/docs/utilities/fromBytes#bytestonumber
*
* @param bytes Byte array to decode.
* @param opts Options.
* @returns Number value.
*
* @example
* import { bytesToNumber } from 'viem'
* const data = bytesToNumber(new Uint8Array([1, 164]))
* // 420
*/
export function bytesToNumber(bytes, opts = {}) {
if (typeof opts.size !== 'undefined')
assertSize(bytes, { size: opts.size });
const hex = bytesToHex(bytes, opts);
return hexToNumber(hex, opts);
}
/**
* Decodes a byte array into a UTF-8 string.
*
* - Docs: https://viem.sh/docs/utilities/fromBytes#bytestostring
*
* @param bytes Byte array to decode.
* @param opts Options.
* @returns String value.
*
* @example
* import { bytesToString } from 'viem'
* const data = bytesToString(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
* // 'Hello world'
*/
export function bytesToString(bytes_, opts = {}) {
let bytes = bytes_;
if (typeof opts.size !== 'undefined') {
assertSize(bytes, { size: opts.size });
bytes = trim(bytes, { dir: 'right' });
}
return new TextDecoder().decode(bytes);
}
//# sourceMappingURL=fromBytes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fromBytes.js","sourceRoot":"","sources":["../../../utils/encoding/fromBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAGnE,OAAO,EAAsB,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAEL,UAAU,EAGV,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAA4B,UAAU,EAAE,MAAM,YAAY,CAAA;AAiCjE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,SAAS,CAGvB,KAAgB,EAChB,QAAiC;IAEjC,MAAM,IAAI,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;IACvE,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAElB,IAAI,EAAE,KAAK,QAAQ;QACjB,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAA4B,CAAA;IAC9D,IAAI,EAAE,KAAK,QAAQ;QACjB,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAA4B,CAAA;IAC9D,IAAI,EAAE,KAAK,SAAS;QAClB,OAAO,WAAW,CAAC,KAAK,EAAE,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,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACnC,OAAO,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAC/B,CAAC;AAYD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,OAA0B,EAAE;IAE5B,IAAI,KAAK,GAAG,MAAM,CAAA;IAClB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACrC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACtC,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC"}

177
node_modules/viem/_esm/utils/encoding/fromHex.js generated vendored Normal file
View File

@@ -0,0 +1,177 @@
import { IntegerOutOfRangeError, InvalidHexBooleanError, SizeOverflowError, } from '../../errors/encoding.js';
import { size as size_ } from '../data/size.js';
import { trim } from '../data/trim.js';
import { hexToBytes } from './toBytes.js';
export function assertSize(hexOrBytes, { size }) {
if (size_(hexOrBytes) > size)
throw new SizeOverflowError({
givenSize: size_(hexOrBytes),
maxSize: size,
});
}
/**
* Decodes a hex string into a string, number, bigint, boolean, or byte array.
*
* - Docs: https://viem.sh/docs/utilities/fromHex
* - Example: https://viem.sh/docs/utilities/fromHex#usage
*
* @param hex Hex string to decode.
* @param toOrOpts Type to convert to or options.
* @returns Decoded value.
*
* @example
* import { fromHex } from 'viem'
* const data = fromHex('0x1a4', 'number')
* // 420
*
* @example
* import { fromHex } from 'viem'
* const data = fromHex('0x48656c6c6f20576f726c6421', 'string')
* // 'Hello world'
*
* @example
* import { fromHex } from 'viem'
* const data = fromHex('0x48656c6c6f20576f726c64210000000000000000000000000000000000000000', {
* size: 32,
* to: 'string'
* })
* // 'Hello world'
*/
export function fromHex(hex, toOrOpts) {
const opts = typeof toOrOpts === 'string' ? { to: toOrOpts } : toOrOpts;
const to = opts.to;
if (to === 'number')
return hexToNumber(hex, opts);
if (to === 'bigint')
return hexToBigInt(hex, opts);
if (to === 'string')
return hexToString(hex, opts);
if (to === 'boolean')
return hexToBool(hex, opts);
return hexToBytes(hex, opts);
}
/**
* Decodes a hex value into a bigint.
*
* - Docs: https://viem.sh/docs/utilities/fromHex#hextobigint
*
* @param hex Hex value to decode.
* @param opts Options.
* @returns BigInt value.
*
* @example
* import { hexToBigInt } from 'viem'
* const data = hexToBigInt('0x1a4', { signed: true })
* // 420n
*
* @example
* import { hexToBigInt } from 'viem'
* const data = hexToBigInt('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })
* // 420n
*/
export function hexToBigInt(hex, opts = {}) {
const { signed } = opts;
if (opts.size)
assertSize(hex, { size: opts.size });
const value = BigInt(hex);
if (!signed)
return value;
const size = (hex.length - 2) / 2;
const max = (1n << (BigInt(size) * 8n - 1n)) - 1n;
if (value <= max)
return value;
return value - BigInt(`0x${'f'.padStart(size * 2, 'f')}`) - 1n;
}
/**
* Decodes a hex value into a boolean.
*
* - Docs: https://viem.sh/docs/utilities/fromHex#hextobool
*
* @param hex Hex value to decode.
* @param opts Options.
* @returns Boolean value.
*
* @example
* import { hexToBool } from 'viem'
* const data = hexToBool('0x01')
* // true
*
* @example
* import { hexToBool } from 'viem'
* const data = hexToBool('0x0000000000000000000000000000000000000000000000000000000000000001', { size: 32 })
* // true
*/
export function hexToBool(hex_, opts = {}) {
let hex = hex_;
if (opts.size) {
assertSize(hex, { size: opts.size });
hex = trim(hex);
}
if (trim(hex) === '0x00')
return false;
if (trim(hex) === '0x01')
return true;
throw new InvalidHexBooleanError(hex);
}
/**
* Decodes a hex string into a number.
*
* - Docs: https://viem.sh/docs/utilities/fromHex#hextonumber
*
* @param hex Hex value to decode.
* @param opts Options.
* @returns Number value.
*
* @example
* import { hexToNumber } from 'viem'
* const data = hexToNumber('0x1a4')
* // 420
*
* @example
* import { hexToNumber } from 'viem'
* const data = hexToBigInt('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })
* // 420
*/
export function hexToNumber(hex, opts = {}) {
const value = hexToBigInt(hex, opts);
const number = Number(value);
if (!Number.isSafeInteger(number))
throw new IntegerOutOfRangeError({
max: `${Number.MAX_SAFE_INTEGER}`,
min: `${Number.MIN_SAFE_INTEGER}`,
signed: opts.signed,
size: opts.size,
value: `${value}n`,
});
return number;
}
/**
* Decodes a hex value into a UTF-8 string.
*
* - Docs: https://viem.sh/docs/utilities/fromHex#hextostring
*
* @param hex Hex value to decode.
* @param opts Options.
* @returns String value.
*
* @example
* import { hexToString } from 'viem'
* const data = hexToString('0x48656c6c6f20576f726c6421')
* // 'Hello world!'
*
* @example
* import { hexToString } from 'viem'
* const data = hexToString('0x48656c6c6f20576f726c64210000000000000000000000000000000000000000', {
* size: 32,
* })
* // 'Hello world'
*/
export function hexToString(hex, opts = {}) {
let bytes = hexToBytes(hex);
if (opts.size) {
assertSize(bytes, { size: opts.size });
bytes = trim(bytes, { dir: 'right' });
}
return new TextDecoder().decode(bytes);
}
//# sourceMappingURL=fromHex.js.map

1
node_modules/viem/_esm/utils/encoding/fromHex.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"fromHex.js","sourceRoot":"","sources":["../../../utils/encoding/fromHex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,sBAAsB,EAEtB,iBAAiB,GAElB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAsB,IAAI,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAsB,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAA4B,UAAU,EAAE,MAAM,cAAc,CAAA;AAOnE,MAAM,UAAU,U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