hardhat-tracer
Version:
Hardhat Tracer plugin
30 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const utils_1 = require("ethers/lib/utils");
const config_1 = require("hardhat/config");
const log_1 = require("../format/log");
const utils_2 = require("../utils");
(0, utils_2.addCliParams)((0, config_1.task)("decodelog", "Decodes log data"))
.addOptionalParam("data", "data if any")
.addVariadicPositionalParam("topics", "list of topics if any")
.setAction(async (args, hre) => {
const td = {
artifacts: hre.artifacts,
tracerEnv: hre.tracer,
provider: hre.network.provider,
nameTags: hre.tracer.nameTags,
};
// see if the data is a log
const formattedlog = await (0, log_1.formatLog)({
data: args.data ?? "0x",
topics: args.topics.map(parseTopic),
}, undefined, td);
console.log(formattedlog);
});
// input can be a number string otherwise hex string
function parseTopic(input) {
const hex = (0, utils_1.isHexString)(input) ? input : ethers_1.BigNumber.from(input).toHexString();
return (0, utils_1.hexZeroPad)(hex, 32);
}
//# sourceMappingURL=decodelog.js.map