hardhat-tracer
Advanced tools
Comparing version 2.3.5 to 2.4.0
@@ -11,53 +11,64 @@ "use strict"; | ||
const result_1 = require("./result"); | ||
const precompile_1 = require("./precompile"); | ||
async function formatCall(to, input, ret, value, gasUsed, gasLimit, success, dependencies) { | ||
let contractName; | ||
let contractDecimals; | ||
let strictlyHideAddress = false; | ||
let functionName; | ||
let inputResult; | ||
let returnResult; | ||
let fragment; | ||
try { | ||
({ | ||
fragment, | ||
contractName, | ||
inputResult, | ||
returnResult, | ||
} = await dependencies.tracerEnv.decoder.decodeFunction(input, ret)); | ||
// use just contract name | ||
contractName = contractName.split(":")[1]; | ||
let precompileResult = (0, precompile_1.formatPrecompile)(to, input, ret); | ||
if (precompileResult) { | ||
contractName = "Precompiles"; | ||
strictlyHideAddress = true; | ||
({ name: functionName, inputResult, returnResult } = precompileResult); | ||
} | ||
catch { } | ||
// find a better contract name | ||
if (to) { | ||
const betterContractName = await (0, utils_2.getBetterContractName)(to, dependencies); | ||
if (betterContractName) { | ||
contractName = betterContractName; | ||
else { | ||
try { | ||
({ | ||
fragment, | ||
contractName, | ||
inputResult, | ||
returnResult, | ||
} = await dependencies.tracerEnv.decoder.decodeFunction(input, ret)); | ||
// use just contract name | ||
contractName = contractName.split(":")[1]; | ||
} | ||
else if (contractName) { | ||
dependencies.tracerEnv.nameTags[to] = contractName; | ||
catch { } | ||
// find a better contract name | ||
if (to) { | ||
const betterContractName = await (0, utils_2.getBetterContractName)(to, dependencies); | ||
if (betterContractName) { | ||
contractName = betterContractName; | ||
} | ||
else if (contractName) { | ||
dependencies.tracerEnv.nameTags[to] = contractName; | ||
} | ||
} | ||
} | ||
// if ERC20 method found then fetch decimals | ||
if (to && | ||
(input.slice(0, 10) === "0x70a08231" || // balanceOf | ||
input.slice(0, 10) === "0xa9059cbb" || // transfer | ||
input.slice(0, 10) === "0x23b872dd") // transferFrom | ||
) { | ||
// see if we already know the decimals | ||
const { cache } = dependencies.tracerEnv._internal; | ||
const decimals = cache.tokenDecimals.get(to); | ||
if (decimals) { | ||
// if we know decimals then use it | ||
contractDecimals = decimals !== -1 ? decimals : undefined; | ||
} | ||
else { | ||
// otherwise fetch it | ||
contractDecimals = await (0, utils_2.fetchContractDecimals)(to, dependencies); | ||
// and cache it | ||
if (contractDecimals !== undefined) { | ||
cache.tokenDecimals.set(to, contractDecimals); | ||
// if ERC20 method found then fetch decimals | ||
if (to && | ||
(input.slice(0, 10) === "0x70a08231" || // balanceOf | ||
input.slice(0, 10) === "0xa9059cbb" || // transfer | ||
input.slice(0, 10) === "0x23b872dd") // transferFrom | ||
) { | ||
// see if we already know the decimals | ||
const { cache } = dependencies.tracerEnv._internal; | ||
const decimals = cache.tokenDecimals.get(to); | ||
if (decimals) { | ||
// if we know decimals then use it | ||
contractDecimals = decimals !== -1 ? decimals : undefined; | ||
} | ||
else { | ||
cache.tokenDecimals.set(to, -1); | ||
// otherwise fetch it | ||
contractDecimals = await (0, utils_2.fetchContractDecimals)(to, dependencies); | ||
// and cache it | ||
if (contractDecimals !== undefined) { | ||
cache.tokenDecimals.set(to, contractDecimals); | ||
} | ||
else { | ||
cache.tokenDecimals.set(to, -1); | ||
} | ||
cache.save(); | ||
} | ||
cache.save(); | ||
} | ||
@@ -76,6 +87,7 @@ } | ||
const colorFunction = success ? colors_1.colorFunctionSuccess : colors_1.colorFunctioFail; | ||
if (inputResult && fragment) { | ||
const inputArgs = (0, result_1.formatResult)(inputResult, fragment.inputs, { decimals: contractDecimals, shorten: false }, dependencies); | ||
if (inputResult && (functionName || fragment)) { | ||
// format known stuff | ||
const inputArgs = (0, result_1.formatResult)(inputResult, fragment?.inputs, { decimals: contractDecimals, shorten: false }, dependencies); | ||
const outputArgs = returnResult | ||
? (0, result_1.formatResult)(returnResult, fragment.outputs, { decimals: contractDecimals, shorten: true }, dependencies) | ||
? (0, result_1.formatResult)(returnResult, fragment?.outputs, { decimals: contractDecimals, shorten: true }, dependencies) | ||
: // if return data is not decoded, then show return data only if call was success | ||
@@ -87,8 +99,9 @@ ret !== "0x" && success !== false // success can be undefined | ||
return `${to && | ||
!strictlyHideAddress && | ||
(dependencies.tracerEnv.showAddresses || | ||
nameToPrint === "UnknownContract") | ||
? `${(0, colors_1.colorContract)(nameToPrint)}(${to})` | ||
: (0, colors_1.colorContract)(nameToPrint)}.${colorFunction(fragment.name)}${extra.length !== 0 ? (0, colors_1.colorExtra)(`{${extra.join(", ")}}`) : ""}(${inputArgs})${outputArgs ? ` => (${outputArgs})` : ""}`; | ||
: (0, colors_1.colorContract)(nameToPrint)}.${colorFunction(functionName ?? fragment?.name)}${extra.length !== 0 ? (0, colors_1.colorExtra)(`{${extra.join(", ")}}`) : ""}(${inputArgs})${outputArgs ? ` => (${outputArgs})` : ""}`; | ||
} | ||
// TODO add flag to hide unrecognized stuff | ||
// format unknown stuff | ||
if (contractName) { | ||
@@ -95,0 +108,0 @@ return `${to && dependencies.tracerEnv.showAddresses |
@@ -1,3 +0,3 @@ | ||
import { ParamType, Result } from "ethers/lib/utils"; | ||
import { TracerDependencies } from "../types"; | ||
import { ParamType } from "ethers/lib/utils"; | ||
import { Obj, TracerDependencies } from "../types"; | ||
interface FormatOptions { | ||
@@ -7,4 +7,4 @@ decimals?: number; | ||
} | ||
export declare function formatResult(result: Result, params: ParamType[] | undefined, { decimals, shorten }: FormatOptions, dependencies: TracerDependencies): string; | ||
export declare function formatResult(result: Obj<any>, params: ParamType[] | undefined, { decimals, shorten }: FormatOptions, dependencies: TracerDependencies): string; | ||
export {}; | ||
//# sourceMappingURL=result.d.ts.map |
@@ -11,28 +11,24 @@ "use strict"; | ||
shorten = shorten ?? false; | ||
const stringifiedArgs = []; | ||
// const params = isInput | ||
// ? fragment.inputs | ||
// : (fragment as FunctionFragment)?.outputs; | ||
if (!params) { | ||
return ""; | ||
} | ||
for (let i = 0; i < params.length; i++) { | ||
const param = params[i]; | ||
const name = param.name ?? `arg_${i}`; | ||
let value; | ||
if (decimals !== -1 && ethers_1.BigNumber.isBigNumber(result[i])) { | ||
value = (0, utils_1.formatUnits)(result[i], decimals); | ||
let stringifiedArgs = []; | ||
if (params) { | ||
// use abi params to query the keys | ||
for (let i = 0; i < params.length; i++) { | ||
const param = params[i]; | ||
const name = param.name ?? `arg_${i}`; | ||
let value; | ||
if (decimals !== -1 && ethers_1.BigNumber.isBigNumber(result[i])) { | ||
value = (0, utils_1.formatUnits)(result[i], decimals); | ||
} | ||
else { | ||
value = (0, param_1.formatParam)(result[i], dependencies); | ||
} | ||
stringifiedArgs.push([name, value]); | ||
} | ||
else { | ||
value = (0, param_1.formatParam)(result[i], dependencies); | ||
} | ||
stringifiedArgs.push([ | ||
name, | ||
value, | ||
// use decimals if available to format amount | ||
// decimals !== -1 && BigNumber.isBigNumber(result[i]) | ||
// ? formatUnits(result[i], decimals) | ||
// : formatParam(result[i], param.components, dependencies), | ||
]); | ||
} | ||
else { | ||
// consider all the entries in the object | ||
stringifiedArgs = Object.entries(result) | ||
.filter(([key]) => isNaN(Number(key))) | ||
.map(([key, value]) => [key, (0, param_1.formatParam)(value, dependencies)]); | ||
} | ||
return `${stringifiedArgs | ||
@@ -39,0 +35,0 @@ .map((entry) => `${stringifiedArgs.length > 1 || !shorten |
@@ -14,3 +14,3 @@ "use strict"; | ||
const dataSize = (0, utils_1.parseNumber)(stack.pop()); | ||
const topic0 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic0 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const data = (0, utils_1.hexPrefix)(step.memory.slice(dataOffset, dataOffset + dataSize).toString("hex")); | ||
@@ -17,0 +17,0 @@ return { |
@@ -14,4 +14,4 @@ "use strict"; | ||
const dataSize = (0, utils_1.parseNumber)(stack.pop()); | ||
const topic0 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic1 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic0 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic1 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const data = (0, utils_1.hexPrefix)(step.memory.slice(dataOffset, dataOffset + dataSize).toString("hex")); | ||
@@ -18,0 +18,0 @@ return { |
@@ -14,5 +14,5 @@ "use strict"; | ||
const dataSize = (0, utils_1.parseNumber)(stack.pop()); | ||
const topic0 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic1 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic2 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic0 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic1 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic2 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const data = (0, utils_1.hexPrefix)(step.memory.slice(dataOffset, dataOffset + dataSize).toString("hex")); | ||
@@ -19,0 +19,0 @@ return { |
@@ -14,6 +14,6 @@ "use strict"; | ||
const dataSize = (0, utils_1.parseNumber)(stack.pop()); | ||
const topic0 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic1 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic2 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic3 = (0, utils_1.parseHex)(stack.pop()); | ||
const topic0 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic1 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic2 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const topic3 = (0, utils_1.parseBytes32)(stack.pop()); | ||
const data = (0, utils_1.hexPrefix)(step.memory.slice(dataOffset, dataOffset + dataSize).toString("hex")); | ||
@@ -20,0 +20,0 @@ return { |
@@ -38,3 +38,2 @@ "use strict"; | ||
} | ||
this.addressStack.push(message.caller?.toString()); | ||
item = { | ||
@@ -50,5 +49,5 @@ opcode: "DELEGATECALL", | ||
}; | ||
this.addressStack.push(item.params.to); | ||
} | ||
else if (message.to) { | ||
this.addressStack.push(message.caller?.toString()); | ||
item = { | ||
@@ -65,2 +64,3 @@ opcode: message.isStatic ? "STATICCALL" : "CALL", | ||
}; | ||
this.addressStack.push(item.params.to); | ||
} | ||
@@ -67,0 +67,0 @@ else if (message.to === undefined && message.salt === undefined) { |
@@ -113,2 +113,14 @@ import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
} | ||
export declare type Obj<V> = { | ||
[key: string]: V; | ||
}; | ||
export declare type PrecompleResult = { | ||
name: string; | ||
inputResult?: { | ||
[key: string]: any; | ||
}; | ||
returnResult?: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
declare global { | ||
@@ -115,0 +127,0 @@ export namespace Chai { |
@@ -1,2 +0,2 @@ | ||
import { BigNumber } from "ethers"; | ||
import { BigNumber, BigNumberish } from "ethers"; | ||
export declare function parseHex(str: string): string; | ||
@@ -15,2 +15,3 @@ export declare function parseNumber(str: string): number; | ||
export declare function hexPrefix(str: string): string; | ||
export declare function toAddr(val: BigNumberish): string; | ||
//# sourceMappingURL=hex.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hexPrefix = exports.shallowCopyStack2 = exports.shallowCopyStack = exports.parseMemory = exports.parseBytes32 = exports.parseAddress = exports.parseUint = exports.parseNumber = exports.parseHex = void 0; | ||
exports.toAddr = exports.hexPrefix = exports.shallowCopyStack2 = exports.shallowCopyStack = exports.parseMemory = exports.parseBytes32 = exports.parseAddress = exports.parseUint = exports.parseNumber = exports.parseHex = void 0; | ||
const ethers_1 = require("ethers"); | ||
@@ -49,2 +49,6 @@ const utils_1 = require("ethers/lib/utils"); | ||
exports.hexPrefix = hexPrefix; | ||
function toAddr(val) { | ||
return (0, utils_1.hexZeroPad)((0, utils_1.hexlify)(val), 20); | ||
} | ||
exports.toAddr = toAddr; | ||
//# sourceMappingURL=hex.js.map |
{ | ||
"name": "hardhat-tracer", | ||
"version": "2.3.5", | ||
"version": "2.4.0", | ||
"description": "Hardhat Tracer plugin", | ||
@@ -5,0 +5,0 @@ "repository": "github:zemse/hardhat-tracer", |
import { BigNumber, BigNumberish } from "ethers"; | ||
import { | ||
formatEther, | ||
Fragment, | ||
FunctionFragment, | ||
Result, | ||
} from "ethers/lib/utils"; | ||
import { formatEther, Fragment, FunctionFragment } from "ethers/lib/utils"; | ||
import { SEPARATOR } from "../constants"; | ||
import { TracerDependencies } from "../types"; | ||
import { Obj, TracerDependencies } from "../types"; | ||
import { fetchContractDecimals, getBetterContractName } from "../utils"; | ||
@@ -23,2 +18,3 @@ import { | ||
import { formatResult } from "./result"; | ||
import { formatPrecompile } from "./precompile"; | ||
@@ -37,51 +33,60 @@ export async function formatCall( | ||
let contractDecimals: number | undefined; | ||
let inputResult: Result | undefined; | ||
let returnResult: Result | undefined; | ||
let strictlyHideAddress: boolean = false; | ||
let functionName: string | undefined; | ||
let inputResult: Obj<any> | undefined; | ||
let returnResult: Obj<any> | undefined; | ||
let fragment: Fragment | undefined; | ||
try { | ||
({ | ||
fragment, | ||
contractName, | ||
inputResult, | ||
returnResult, | ||
} = await dependencies.tracerEnv.decoder!.decodeFunction(input, ret)); | ||
let precompileResult = formatPrecompile(to, input, ret); | ||
if (precompileResult) { | ||
contractName = "Precompiles"; | ||
strictlyHideAddress = true; | ||
({ name: functionName, inputResult, returnResult } = precompileResult); | ||
} else { | ||
try { | ||
({ | ||
fragment, | ||
contractName, | ||
inputResult, | ||
returnResult, | ||
} = await dependencies.tracerEnv.decoder!.decodeFunction(input, ret)); | ||
// use just contract name | ||
contractName = contractName.split(":")[1]; | ||
} catch {} | ||
// use just contract name | ||
contractName = contractName.split(":")[1]; | ||
} catch {} | ||
// find a better contract name | ||
if (to) { | ||
const betterContractName = await getBetterContractName(to, dependencies); | ||
if (betterContractName) { | ||
contractName = betterContractName; | ||
} else if (contractName) { | ||
dependencies.tracerEnv.nameTags[to] = contractName; | ||
// find a better contract name | ||
if (to) { | ||
const betterContractName = await getBetterContractName(to, dependencies); | ||
if (betterContractName) { | ||
contractName = betterContractName; | ||
} else if (contractName) { | ||
dependencies.tracerEnv.nameTags[to] = contractName; | ||
} | ||
} | ||
} | ||
// if ERC20 method found then fetch decimals | ||
if ( | ||
to && | ||
(input.slice(0, 10) === "0x70a08231" || // balanceOf | ||
input.slice(0, 10) === "0xa9059cbb" || // transfer | ||
input.slice(0, 10) === "0x23b872dd") // transferFrom | ||
) { | ||
// see if we already know the decimals | ||
const { cache } = dependencies.tracerEnv._internal; | ||
const decimals = cache.tokenDecimals.get(to); | ||
if (decimals) { | ||
// if we know decimals then use it | ||
contractDecimals = decimals !== -1 ? decimals : undefined; | ||
} else { | ||
// otherwise fetch it | ||
contractDecimals = await fetchContractDecimals(to, dependencies); | ||
// and cache it | ||
if (contractDecimals !== undefined) { | ||
cache.tokenDecimals.set(to, contractDecimals); | ||
// if ERC20 method found then fetch decimals | ||
if ( | ||
to && | ||
(input.slice(0, 10) === "0x70a08231" || // balanceOf | ||
input.slice(0, 10) === "0xa9059cbb" || // transfer | ||
input.slice(0, 10) === "0x23b872dd") // transferFrom | ||
) { | ||
// see if we already know the decimals | ||
const { cache } = dependencies.tracerEnv._internal; | ||
const decimals = cache.tokenDecimals.get(to); | ||
if (decimals) { | ||
// if we know decimals then use it | ||
contractDecimals = decimals !== -1 ? decimals : undefined; | ||
} else { | ||
cache.tokenDecimals.set(to, -1); | ||
// otherwise fetch it | ||
contractDecimals = await fetchContractDecimals(to, dependencies); | ||
// and cache it | ||
if (contractDecimals !== undefined) { | ||
cache.tokenDecimals.set(to, contractDecimals); | ||
} else { | ||
cache.tokenDecimals.set(to, -1); | ||
} | ||
cache.save(); | ||
} | ||
cache.save(); | ||
} | ||
@@ -105,6 +110,7 @@ } | ||
if (inputResult && fragment) { | ||
if (inputResult && (functionName || fragment)) { | ||
// format known stuff | ||
const inputArgs = formatResult( | ||
inputResult, | ||
fragment.inputs, | ||
fragment?.inputs, | ||
{ decimals: contractDecimals, shorten: false }, | ||
@@ -116,3 +122,3 @@ dependencies | ||
returnResult, | ||
(fragment as FunctionFragment).outputs, | ||
(fragment as FunctionFragment)?.outputs, | ||
{ decimals: contractDecimals, shorten: true }, | ||
@@ -130,2 +136,3 @@ dependencies | ||
to && | ||
!strictlyHideAddress && | ||
(dependencies.tracerEnv.showAddresses || | ||
@@ -135,3 +142,3 @@ nameToPrint === "UnknownContract") | ||
: colorContract(nameToPrint) | ||
}.${colorFunction(fragment.name)}${ | ||
}.${colorFunction(functionName ?? fragment?.name)}${ | ||
extra.length !== 0 ? colorExtra(`{${extra.join(", ")}}`) : "" | ||
@@ -141,3 +148,3 @@ }(${inputArgs})${outputArgs ? ` => (${outputArgs})` : ""}`; | ||
// TODO add flag to hide unrecognized stuff | ||
// format unknown stuff | ||
if (contractName) { | ||
@@ -144,0 +151,0 @@ return `${ |
import { BigNumber } from "ethers"; | ||
import { formatUnits, ParamType, Result } from "ethers/lib/utils"; | ||
import { formatUnits, ParamType } from "ethers/lib/utils"; | ||
import { TracerDependencies } from "../types"; | ||
import { Obj, TracerDependencies } from "../types"; | ||
import { colorKey } from "../utils/colors"; | ||
@@ -15,3 +15,3 @@ | ||
export function formatResult( | ||
result: Result, | ||
result: Obj<any>, | ||
params: ParamType[] | undefined, | ||
@@ -23,28 +23,24 @@ { decimals, shorten }: FormatOptions, | ||
shorten = shorten ?? false; | ||
const stringifiedArgs: Array<[string, string]> = []; | ||
// const params = isInput | ||
// ? fragment.inputs | ||
// : (fragment as FunctionFragment)?.outputs; | ||
if (!params) { | ||
return ""; | ||
let stringifiedArgs: Array<[string, string]> = []; | ||
if (params) { | ||
// use abi params to query the keys | ||
for (let i = 0; i < params.length; i++) { | ||
const param = params[i]; | ||
const name = param.name ?? `arg_${i}`; | ||
let value; | ||
if (decimals !== -1 && BigNumber.isBigNumber(result[i])) { | ||
value = formatUnits(result[i], decimals); | ||
} else { | ||
value = formatParam(result[i], dependencies); | ||
} | ||
stringifiedArgs.push([name, value]); | ||
} | ||
} else { | ||
// consider all the entries in the object | ||
stringifiedArgs = Object.entries(result) | ||
.filter(([key]) => isNaN(Number(key))) | ||
.map(([key, value]) => [key, formatParam(value, dependencies)]); | ||
} | ||
for (let i = 0; i < params.length; i++) { | ||
const param = params[i]; | ||
const name = param.name ?? `arg_${i}`; | ||
let value; | ||
if (decimals !== -1 && BigNumber.isBigNumber(result[i])) { | ||
value = formatUnits(result[i], decimals); | ||
} else { | ||
value = formatParam(result[i], dependencies); | ||
} | ||
stringifiedArgs.push([ | ||
name, | ||
value, | ||
// use decimals if available to format amount | ||
// decimals !== -1 && BigNumber.isBigNumber(result[i]) | ||
// ? formatUnits(result[i], decimals) | ||
// : formatParam(result[i], param.components, dependencies), | ||
]); | ||
} | ||
return `${stringifiedArgs | ||
@@ -51,0 +47,0 @@ .map( |
import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
import { Item } from "../types"; | ||
import { hexPrefix, parseHex, parseNumber, shallowCopyStack2 } from "../utils"; | ||
import { | ||
hexPrefix, | ||
parseBytes32, | ||
parseNumber, | ||
shallowCopyStack2, | ||
} from "../utils"; | ||
@@ -26,3 +31,3 @@ import { LOG } from "./log"; | ||
const dataSize = parseNumber(stack.pop()!); | ||
const topic0 = parseHex(stack.pop()!); | ||
const topic0 = parseBytes32(stack.pop()!); | ||
@@ -29,0 +34,0 @@ const data = hexPrefix( |
import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
import { hexZeroPad } from "ethers/lib/utils"; | ||
import { Item } from "../types"; | ||
import { hexPrefix, parseHex, parseNumber, shallowCopyStack2 } from "../utils"; | ||
import { | ||
hexPrefix, | ||
parseBytes32, | ||
parseNumber, | ||
shallowCopyStack2, | ||
} from "../utils"; | ||
@@ -26,4 +32,4 @@ import { LOG } from "./log"; | ||
const dataSize = parseNumber(stack.pop()!); | ||
const topic0 = parseHex(stack.pop()!); | ||
const topic1 = parseHex(stack.pop()!); | ||
const topic0 = parseBytes32(stack.pop()!); | ||
const topic1 = parseBytes32(stack.pop()!); | ||
@@ -30,0 +36,0 @@ const data = hexPrefix( |
import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
import { hexZeroPad } from "ethers/lib/utils"; | ||
import { Item } from "../types"; | ||
import { hexPrefix, parseHex, parseNumber, shallowCopyStack2 } from "../utils"; | ||
import { | ||
hexPrefix, | ||
parseBytes32, | ||
parseNumber, | ||
shallowCopyStack2, | ||
} from "../utils"; | ||
@@ -26,5 +32,5 @@ import { LOG } from "./log"; | ||
const dataSize = parseNumber(stack.pop()!); | ||
const topic0 = parseHex(stack.pop()!); | ||
const topic1 = parseHex(stack.pop()!); | ||
const topic2 = parseHex(stack.pop()!); | ||
const topic0 = parseBytes32(stack.pop()!); | ||
const topic1 = parseBytes32(stack.pop()!); | ||
const topic2 = parseBytes32(stack.pop()!); | ||
@@ -31,0 +37,0 @@ const data = hexPrefix( |
import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
import { hexZeroPad } from "ethers/lib/utils"; | ||
import { Item } from "../types"; | ||
import { hexPrefix, parseHex, parseNumber, shallowCopyStack2 } from "../utils"; | ||
import { | ||
hexPrefix, | ||
parseBytes32, | ||
parseNumber, | ||
shallowCopyStack2, | ||
} from "../utils"; | ||
@@ -26,6 +32,6 @@ import { LOG } from "./log"; | ||
const dataSize = parseNumber(stack.pop()!); | ||
const topic0 = parseHex(stack.pop()!); | ||
const topic1 = parseHex(stack.pop()!); | ||
const topic2 = parseHex(stack.pop()!); | ||
const topic3 = parseHex(stack.pop()!); | ||
const topic0 = parseBytes32(stack.pop()!); | ||
const topic1 = parseBytes32(stack.pop()!); | ||
const topic2 = parseBytes32(stack.pop()!); | ||
const topic3 = parseBytes32(stack.pop()!); | ||
@@ -32,0 +38,0 @@ const data = hexPrefix( |
@@ -79,3 +79,2 @@ import { | ||
} | ||
this.addressStack.push(message.caller?.toString()!); | ||
item = { | ||
@@ -91,4 +90,4 @@ opcode: "DELEGATECALL", | ||
} as Item<DELEGATECALL>; | ||
this.addressStack.push(item.params.to); | ||
} else if (message.to) { | ||
this.addressStack.push(message.caller?.toString()!); | ||
item = { | ||
@@ -105,2 +104,3 @@ opcode: message.isStatic ? "STATICCALL" : "CALL", | ||
} as Item<CALL>; | ||
this.addressStack.push(item.params.to); | ||
} else if (message.to === undefined && message.salt === undefined) { | ||
@@ -107,0 +107,0 @@ item = { |
@@ -142,2 +142,10 @@ import { InterpreterStep } from "@nomicfoundation/ethereumjs-evm"; | ||
export type Obj<V> = { [key: string]: V }; | ||
export type PrecompleResult = { | ||
name: string; | ||
inputResult?: { [key: string]: any }; | ||
returnResult?: { [key: string]: any }; | ||
}; | ||
declare global { | ||
@@ -144,0 +152,0 @@ export namespace Chai { |
@@ -1,3 +0,3 @@ | ||
import { BigNumber } from "ethers"; | ||
import { arrayify, hexStripZeros, hexZeroPad } from "ethers/lib/utils"; | ||
import { BigNumber, BigNumberish } from "ethers"; | ||
import { arrayify, hexStripZeros, hexZeroPad, hexlify } from "ethers/lib/utils"; | ||
@@ -46,1 +46,5 @@ export function parseHex(str: string) { | ||
} | ||
export function toAddr(val: BigNumberish) { | ||
return hexZeroPad(hexlify(val), 20); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
435322
326
7650