Socket
Socket
Sign inDemoInstall

hardhat

Package Overview
Dependencies
Maintainers
5
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hardhat - npm Package Compare versions

Comparing version 2.22.6 to 2.22.7

2

internal/core/errors-list.js

@@ -512,3 +512,3 @@ "use strict";

number: 206,
message: "Default value for param %paramName% of task %taskName% doesn't match the default one, try specifying it.",
message: "Default value for param %paramName% of task %taskName% doesn't match its expected type.",
title: "Default value has incorrect type",

@@ -515,0 +515,0 @@ description: `One of your tasks has a parameter whose default value doesn't match the expected type.

@@ -88,2 +88,3 @@ "use strict";

enableTransientStorage: hardhatNetConfig.enableTransientStorage ?? false,
enableRip7212: hardhatNetConfig.enableRip7212 ?? false,
}, {

@@ -90,0 +91,0 @@ enabled: hardhatNetConfig.loggingEnabled,

@@ -32,2 +32,3 @@ /// <reference types="node" />

enableTransientStorage: boolean;
enableRip7212: boolean;
}

@@ -38,3 +39,2 @@ export declare function getNodeConfig(config: HardhatNetworkProviderConfig, tracingConfig?: TracingConfig): NodeConfig;

private readonly _node;
private readonly _eventAdapter;
private readonly _vmTraceDecoder;

@@ -41,0 +41,0 @@ private readonly _common;

@@ -98,3 +98,3 @@ "use strict";

// we add this for backwards-compatibility with plugins like solidity-coverage
_node, _eventAdapter, _vmTraceDecoder,
_node, _vmTraceDecoder,
// The common configuration for EthereumJS VM is not used by EDR, but tests expect it as part of the provider.

@@ -105,3 +105,2 @@ _common, tracingConfig) {

this._node = _node;
this._eventAdapter = _eventAdapter;
this._vmTraceDecoder = _vmTraceDecoder;

@@ -157,2 +156,3 @@ this._common = _common;

coinbase: Buffer.from(coinbase.slice(2), "hex"),
enableRip7212: config.enableRip7212,
fork,

@@ -181,6 +181,3 @@ hardfork: (0, convertToEdr_1.ethereumsjsHardforkToEdrSpecId)(hardforkName),

enable: loggerConfig.enabled,
decodeConsoleLogInputsCallback: (inputs) => {
const consoleLogger = new consoleLogger_1.ConsoleLogger();
return consoleLogger.getDecodedLogs(inputs);
},
decodeConsoleLogInputsCallback: consoleLogger_1.ConsoleLogger.getDecodedLogs,
getContractAndFunctionNameCallback: (code, calldata) => {

@@ -204,3 +201,3 @@ return vmTraceDecoder.getContractAndFunctionNamesForCall(code, calldata);

const common = (0, makeCommon_1.makeCommon)(getNodeConfig(config));
const wrapper = new EdrProviderWrapper(provider, minimalEthereumJsNode, eventAdapter, vmTraceDecoder, common, tracingConfig);
const wrapper = new EdrProviderWrapper(provider, minimalEthereumJsNode, vmTraceDecoder, common, tracingConfig);
// Pass through all events from the provider

@@ -417,3 +414,8 @@ eventAdapter.addListener("ethEvent", wrapper._ethEventListener.bind(wrapper));

async function createHardhatNetworkProvider(hardhatNetworkProviderConfig, loggerConfig, artifacts) {
return EdrProviderWrapper.create(hardhatNetworkProviderConfig, loggerConfig, await makeTracingConfig(artifacts));
log("Making tracing config");
const tracingConfig = await makeTracingConfig(artifacts);
log("Creating EDR provider");
const provider = EdrProviderWrapper.create(hardhatNetworkProviderConfig, loggerConfig, tracingConfig);
log("EDR provider created");
return provider;
}

@@ -420,0 +422,0 @@ exports.createHardhatNetworkProvider = createHardhatNetworkProvider;

@@ -24,2 +24,3 @@ "use strict";

case 2 /* SuccessReason.SelfDestruct */:
case 3 /* SuccessReason.EofReturnContract */:
return new Exit(ExitCode.SUCCESS);

@@ -26,0 +27,0 @@ }

/// <reference types="node" />
import { MessageTrace } from "./message-trace";
interface ConsoleLogArray extends Array<ConsoleLogEntry> {
}
export type ConsoleLogEntry = string | ConsoleLogArray;
export type ConsoleLogs = ConsoleLogEntry[];
/** The decoded string representation of the arguments supplied to console.log */
export type ConsoleLogArgs = string[];
export type ConsoleLogs = ConsoleLogArgs[];
export declare class ConsoleLogger {
private readonly _consoleLogs;
constructor();
getLogMessages(maybeDecodedMessageTrace: MessageTrace): string[];
getExecutionLogs(maybeDecodedMessageTrace: MessageTrace): ConsoleLogs[];
private _collectExecutionLogs;
/**
* Temporary code to print console.sol messages that come from EDR
*/
getDecodedLogs(messages: Buffer[]): string[];
private _maybeConsoleLog;
private _replaceNumberFormatSpecifiers;
private _decode;
static getDecodedLogs(messages: Buffer[]): string[];
/**
* Returns a formatted string using the first argument as a `printf`-like
* format string which can contain zero or more format specifiers.
*
* If there are more arguments passed than the number of specifiers, the
* extra arguments are concatenated to the returned string, separated by spaces.
*/
static format(args?: ConsoleLogArgs): string;
private static _maybeConsoleLog;
/** Decodes parameters from `data` according to `types` into their string representation. */
private static _decode;
}
export declare function consoleLogToString(log: ConsoleLogs): string;
export {};
//# sourceMappingURL=consoleLogger.d.ts.map

@@ -6,50 +6,17 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.consoleLogToString = exports.ConsoleLogger = void 0;
exports.ConsoleLogger = void 0;
const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
const util_1 = __importDefault(require("util"));
const logger_1 = require("./logger");
const message_trace_1 = require("./message-trace");
const CONSOLE_ADDRESS = "0x000000000000000000636F6e736F6c652e6c6f67"; // toHex("console.log")
const REGISTER_SIZE = 32;
class ConsoleLogger {
constructor() {
this._consoleLogs = {};
this._consoleLogs = logger_1.ConsoleLogs;
}
getLogMessages(maybeDecodedMessageTrace) {
return this.getExecutionLogs(maybeDecodedMessageTrace).map(consoleLogToString);
}
getExecutionLogs(maybeDecodedMessageTrace) {
if ((0, message_trace_1.isPrecompileTrace)(maybeDecodedMessageTrace)) {
return [];
}
const logs = [];
this._collectExecutionLogs(maybeDecodedMessageTrace, logs);
return logs;
}
_collectExecutionLogs(trace, logs) {
for (const messageTrace of trace.steps) {
if ((0, message_trace_1.isEvmStep)(messageTrace) || (0, message_trace_1.isPrecompileTrace)(messageTrace)) {
continue;
}
if ((0, message_trace_1.isCallTrace)(messageTrace) &&
(0, ethereumjs_util_1.bytesToHex)(messageTrace.address) === CONSOLE_ADDRESS.toLowerCase()) {
const log = this._maybeConsoleLog(Buffer.from(messageTrace.calldata));
if (log !== undefined) {
logs.push(log);
}
continue;
}
this._collectExecutionLogs(messageTrace, logs);
}
}
/**
* Temporary code to print console.sol messages that come from EDR
*/
getDecodedLogs(messages) {
static getDecodedLogs(messages) {
const logs = [];
for (const message of messages) {
const log = this._maybeConsoleLog(message);
const log = ConsoleLogger._maybeConsoleLog(message);
if (log !== undefined) {
logs.push(consoleLogToString(log));
logs.push(ConsoleLogger.format(log));
}

@@ -59,15 +26,22 @@ }

}
_maybeConsoleLog(calldata) {
const sig = (0, ethereumjs_util_1.bytesToInt)(calldata.slice(0, 4));
/**
* Returns a formatted string using the first argument as a `printf`-like
* format string which can contain zero or more format specifiers.
*
* If there are more arguments passed than the number of specifiers, the
* extra arguments are concatenated to the returned string, separated by spaces.
*/
static format(args = []) {
return util_1.default.format(...args);
}
static _maybeConsoleLog(calldata) {
const selector = (0, ethereumjs_util_1.bytesToInt)(calldata.slice(0, 4));
const parameters = calldata.slice(4);
const types = this._consoleLogs[sig];
if (types === undefined) {
const argTypes = logger_1.CONSOLE_LOG_SIGNATURES[selector];
if (argTypes === undefined) {
return;
}
const consoleLogs = this._decode(parameters, types);
this._replaceNumberFormatSpecifiers(consoleLogs);
return consoleLogs;
}
_replaceNumberFormatSpecifiers(consoleLogs) {
const decodedArgs = ConsoleLogger._decode(parameters, argTypes);
/**
* The first argument is interpreted as the format string, which may need adjusting.
* Replace the occurrences of %d and %i with %s. This is necessary because if the arguments passed are numbers,

@@ -84,7 +58,9 @@ * they could be too large to be formatted as a Number or an Integer, so it is safer to use a String.

*/
if (consoleLogs.length > 0 && typeof consoleLogs[0] === "string") {
consoleLogs[0] = consoleLogs[0].replace(/((?<!%)(?:%%)*)(%[di])/g, "$1%s");
if (decodedArgs.length > 0) {
decodedArgs[0] = decodedArgs[0].replace(/((?<!%)(?:%%)*)(%[di])/g, "$1%s");
}
return decodedArgs;
}
_decode(data, types) {
/** Decodes parameters from `data` according to `types` into their string representation. */
static _decode(data, types) {
return types.map((type, i) => {

@@ -185,13 +161,2 @@ const position = i * 32;

exports.ConsoleLogger = ConsoleLogger;
function consoleLogToString(log) {
if (log === undefined) {
return "";
}
// special case for console.log()
if (log.length === 0) {
return "";
}
return util_1.default.format(log[0], ...log.slice(1));
}
exports.consoleLogToString = consoleLogToString;
//# sourceMappingURL=consoleLogger.js.map

@@ -39,600 +39,4 @@ export declare const Int256Ty = "Int256";

export declare const Bytes32Ty = "Bytes32";
export declare const ConsoleLogs: {
1368866505: never[];
760966329: string[];
1309416733: string[];
4163653873: string[];
4122065833: string[];
1093685164: string[];
843419373: string[];
741264322: string[];
199720790: string[];
1847107880: string[];
3921027734: string[];
763578662: string[];
3764340945: string[];
2793701517: string[];
2927928721: string[];
1322614312: string[];
1334060334: string[];
2428341456: string[];
20780939: string[];
67127854: string[];
2258660029: string[];
2488442420: string[];
2456219775: string[];
3667227872: string[];
1717330180: string[];
866084666: string[];
3302112666: string[];
1584093747: string[];
1367925737: string[];
3923391840: string[];
3589990556: string[];
2879508237: string[];
4055063348: string[];
193248344: string[];
4172368369: string[];
976705501: string[];
3358255854: string[];
1265222613: string[];
3994207469: string[];
3263516050: string[];
666357637: string[];
4133908826: string[];
1812949376: string[];
1681903839: string[];
262402885: string[];
480083635: string[];
510514412: string[];
1764191366: string[];
1491830284: string[];
3054400204: string[];
2534451664: string[];
1264337527: string[];
3283441205: string[];
832238387: string[];
965833939: string[];
910912146: string[];
2414527781: string[];
705760899: string[];
2235320393: string[];
2198464680: string[];
574869411: string[];
1973388987: string[];
1974863315: string[];
3673216170: string[];
3522001468: string[];
3884059252: string[];
1909476082: string[];
2104037094: string[];
1197922930: string[];
1733758967: string[];
1553380145: string[];
3191032091: string[];
933920076: string[];
1533929535: string[];
2970968351: string[];
1062716053: string[];
1290643290: string[];
1185403086: string[];
2063255897: string[];
529592906: string[];
537493524: string[];
1515034914: string[];
2239189025: string[];
2332955902: string[];
544310864: string[];
3587091680: string[];
889741179: string[];
1112473535: string[];
1520131797: string[];
2286109610: string[];
1674265081: string[];
3464692859: string[];
2607726658: string[];
2060456590: string[];
3170737120: string[];
2104993307: string[];
3393701099: string[];
2526862595: string[];
1500569737: string[];
2750793529: string[];
3396809649: string[];
4043501061: string[];
478069832: string[];
3817119609: string[];
1478619041: string[];
4083337817: string[];
753761519: string[];
2967534005: string[];
2515337621: string[];
3378075862: string[];
689682896: string[];
3801674877: string[];
2232122070: string[];
2469116728: string[];
220641573: string[];
130552343: string[];
3773410639: string[];
3374145236: string[];
4243355104: string[];
923808615: string[];
995886048: string[];
3288086896: string[];
3359211184: string[];
3906927529: string[];
464374251: string[];
143587794: string[];
3302110471: string[];
278130193: string[];
3224906412: string[];
2960557183: string[];
3686056519: string[];
2509355347: string[];
317855234: string[];
2954061243: string[];
626391622: string[];
1349555864: string[];
276362893: string[];
1601936123: string[];
3950005167: string[];
3734671984: string[];
415876934: string[];
3530962535: string[];
3063663350: string[];
2273710942: string[];
2717051050: string[];
3136907337: string[];
1736575400: string[];
3846889796: string[];
2076235848: string[];
2548867988: string[];
1742565361: string[];
484110986: string[];
4218888805: string[];
3473018801: string[];
4035396840: string[];
2622462459: string[];
742821141: string[];
555898316: string[];
3951234194: string[];
4044790253: string[];
402547077: string[];
1815506290: string[];
7426238: string[];
4070990470: string[];
25986242: string[];
423606272: string[];
1554033982: string[];
1506790371: string[];
2024634892: string[];
3315126661: string[];
1683143115: string[];
4202792367: string[];
3766828905: string[];
1570936811: string[];
949229117: string[];
668512210: string[];
2080582194: string[];
2062986021: string[];
2989403910: string[];
1121066423: string[];
1127384482: string[];
3950997458: string[];
1818524812: string[];
2780101785: string[];
4024028142: string[];
2869451494: string[];
2495495089: string[];
2592172675: string[];
3776410703: string[];
2297881778: string[];
1628154048: string[];
1826504888: string[];
3600994782: string[];
365610102: string[];
2833785006: string[];
1453707697: string[];
3398671136: string[];
2193775476: string[];
3221501959: string[];
3082360010: string[];
2730232985: string[];
1763348340: string[];
2270850606: string[];
992115124: string[];
2877020669: string[];
2955463101: string[];
1995203422: string[];
564987523: string[];
1474103825: string[];
3014047421: string[];
310782872: string[];
3582182914: string[];
3432549024: string[];
3472922752: string[];
2763295359: string[];
3537118157: string[];
2370346144: string[];
3126025628: string[];
1371286465: string[];
2922300801: string[];
2037328032: string[];
3906142605: string[];
2565338099: string[];
2621104033: string[];
4170733439: string[];
2428701270: string[];
4181720887: string[];
1634266465: string[];
2141537675: string[];
3333212072: string[];
1451396516: string[];
3724797812: string[];
3906845782: string[];
2443193898: string[];
3534472445: string[];
2295029825: string[];
1329595790: string[];
740099910: string[];
2438978344: string[];
1757984957: string[];
2754870525: string[];
3952250239: string[];
879671495: string[];
4015165464: string[];
1231956916: string[];
1952763427: string[];
3173363033: string[];
3722155361: string[];
831186331: string[];
3069540257: string[];
1315722005: string[];
1768164185: string[];
1392910941: string[];
125994997: string[];
1102442299: string[];
2917159623: string[];
2721084958: string[];
1162695845: string[];
2449150530: string[];
2716814523: string[];
2263728396: string[];
211605953: string[];
3399106228: string[];
3719324961: string[];
1054063912: string[];
1601452668: string[];
435581801: string[];
364980149: string[];
4256361684: string[];
1182952285: string[];
2697204968: string[];
1041403043: string[];
2373420580: string[];
3425872647: string[];
581204390: string[];
2629472255: string[];
3420819197: string[];
1522374954: string[];
2064181483: string[];
2432370346: string[];
1676730946: string[];
3813741583: string[];
2116501773: string[];
4017276179: string[];
3056677012: string[];
1936653238: string[];
2587672470: string[];
52195187: string[];
2034490470: string[];
153090805: string[];
22350596: string[];
612938772: string[];
1430734329: string[];
2812835923: string[];
149837414: string[];
2236298390: string[];
2773406909: string[];
1982258066: string[];
4147936829: string[];
3793609336: string[];
3201771711: string[];
3330189777: string[];
2697245221: string[];
1522028063: string[];
1821956834: string[];
2099530013: string[];
3919545039: string[];
2084975268: string[];
3144824297: string[];
3827003247: string[];
1427009269: string[];
2885106328: string[];
1993105508: string[];
894187222: string[];
3816813520: string[];
3773389720: string[];
3847527825: string[];
1325727174: string[];
1481210622: string[];
2684039059: string[];
844415720: string[];
2182163010: string[];
285649143: string[];
1587722158: string[];
3939013249: string[];
4099767596: string[];
3587119056: string[];
1562023706: string[];
2366909661: string[];
3282609748: string[];
3864418506: string[];
270792626: string[];
1565476480: string[];
2393878571: string[];
2681211381: string[];
3731419658: string[];
739726573: string[];
1834430276: string[];
3601791698: string[];
2256636538: string[];
1585754346: string[];
1081628777: string[];
3279013851: string[];
2093204999: string[];
1250010474: string[];
3944480640: string[];
1556958775: string[];
1134328815: string[];
1689631591: string[];
1572859960: string[];
1949134567: string[];
1119461927: string[];
2331496330: string[];
1019590099: string[];
2472413631: string[];
1909687565: string[];
620303461: string[];
885731469: string[];
2821114603: string[];
1066037277: string[];
3764542249: string[];
2386524329: string[];
2155164136: string[];
2636305885: string[];
2304440517: string[];
1905304873: string[];
1560853253: string[];
685723286: string[];
764294052: string[];
2508990662: string[];
870964509: string[];
4176812830: string[];
3668153533: string[];
1514632754: string[];
1280700980: string[];
4232594928: string[];
1522647356: string[];
1677429701: string[];
2741431424: string[];
2446397742: string[];
2405583849: string[];
609847026: string[];
1595265676: string[];
2864486961: string[];
1050642026: string[];
3318856587: string[];
72663161: string[];
2038975531: string[];
573965245: string[];
2398352281: string[];
1857524797: string[];
2148146279: string[];
3047013728: string[];
3985582326: string[];
927708338: string[];
853517604: string[];
2389310301: string[];
3657852616: string[];
3197649747: string[];
2753397214: string[];
14518201: string[];
4049711649: string[];
1779538402: string[];
1098907931: string[];
4122747465: string[];
3542771016: string[];
3857124139: string[];
2446522387: string[];
4275904511: string[];
2781285673: string[];
2140912802: string[];
3554563475: string[];
2437143473: string[];
3067439572: string[];
3468031191: string[];
2650928961: string[];
2597139990: string[];
1114097656: string[];
355982471: string[];
3399820138: string[];
464760986: string[];
403247937: string[];
3032683775: string[];
1705899016: string[];
653615272: string[];
2318373034: string[];
679886795: string[];
2387273838: string[];
450457062: string[];
2007084013: string[];
1796103507: string[];
549177775: string[];
362193358: string[];
1529002296: string[];
2078327787: string[];
1574643090: string[];
392356650: string[];
508266469: string[];
2547225816: string[];
369533843: string[];
2372902053: string[];
1211958294: string[];
3697185627: string[];
1401816747: string[];
2781534868: string[];
453743963: string[];
316065672: string[];
1842623690: string[];
724244700: string[];
196087467: string[];
1181212302: string[];
2111099104: string[];
1348569399: string[];
1637764366: string[];
2874982852: string[];
1420274080: string[];
201299213: string[];
3819555375: string[];
395003525: string[];
1830717265: string[];
3092715066: string[];
4188875657: string[];
1836074433: string[];
3259532109: string[];
719587540: string[];
992632032: string[];
2352126746: string[];
1276263767: string[];
1620281063: string[];
2695133539: string[];
3231908568: string[];
4102557348: string[];
2079424929: string[];
2617143996: string[];
1374724088: string[];
2691192883: string[];
3590430492: string[];
4002252402: string[];
325780957: string[];
1760647349: string[];
3256837319: string[];
194640930: string[];
2805734838: string[];
3804222987: string[];
1870422078: string[];
126031106: string[];
1287000017: string[];
1248250676: string[];
1788626827: string[];
474063670: string[];
208064958: string[];
1384430956: string[];
3625099623: string[];
1180699616: string[];
487903233: string[];
888202806: string[];
1024368100: string[];
1244184599: string[];
2301889963: string[];
1727118439: string[];
3964381346: string[];
551786573: string[];
519451700: string[];
3204577425: string[];
4111650715: string[];
2292761606: string[];
2119616147: string[];
3474460764: string[];
2751614737: string[];
1547898183: string[];
3698927108: string[];
586594713: string[];
1770996626: string[];
3316483577: string[];
2391690869: string[];
1005970743: string[];
4272018778: string[];
2736520652: string[];
602229106: string[];
269444366: string[];
2782496616: string[];
497649386: string[];
1567749022: string[];
2713504179: string[];
4051804649: string[];
1200430178: string[];
3961816175: string[];
499704248: string[];
2764647008: string[];
1149776040: string[];
1561552329: string[];
251125840: string[];
2116357467: string[];
1662531192: string[];
3755464715: string[];
362776871: string[];
2706362425: string[];
1560462603: string[];
900007711: string[];
2689478535: string[];
1365129398: string[];
3877655068: string[];
3154862590: string[];
1595759775: string[];
542667202: string[];
1166009295: string[];
2350461865: string[];
4158874181: string[];
233909110: string[];
221706784: string[];
946861556: string[];
3255869470: string[];
178704301: string[];
2606272204: string[];
3294903840: string[];
2244855215: string[];
3438776481: string[];
227337758: string[];
2162598411: string[];
2652011374: string[];
1197235251: string[];
1353532957: string[];
436029782: string[];
2353946086: string[];
3484780374: string[];
3754205928: string[];
3401856121: string[];
3476636805: string[];
2807847390: string[];
3698398930: string[];
769095910: string[];
2801077007: string[];
1711502813: string[];
3193255041: string[];
1425929188: string[];
4256496016: string[];
2647731885: string[];
2604815586: string[];
3270936812: string[];
2376523509: string[];
3603321462: string[];
4011651047: string[];
69767936: string[];
566079269: string[];
1863997774: string[];
2406706454: string[];
963766156: string[];
2513854225: string[];
2858762440: string[];
752096074: string[];
2669396846: string[];
2485456247: string[];
3982404743: string[];
4161329696: string[];
238520724: string[];
1717301556: string[];
};
/** Maps from a 4-byte function selector to a signature (argument types) */
export declare const CONSOLE_LOG_SIGNATURES: Record<number, string[]>;
//# sourceMappingURL=logger.d.ts.map
"use strict";
// ------------------------------------
// This code was autogenerated using
// scripts/console-library-generator.js
// scripts/console-library-generator.ts
// ------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleLogs = exports.Bytes32Ty = exports.Bytes31Ty = exports.Bytes30Ty = exports.Bytes29Ty = exports.Bytes28Ty = exports.Bytes27Ty = exports.Bytes26Ty = exports.Bytes25Ty = exports.Bytes24Ty = exports.Bytes23Ty = exports.Bytes22Ty = exports.Bytes21Ty = exports.Bytes20Ty = exports.Bytes19Ty = exports.Bytes18Ty = exports.Bytes17Ty = exports.Bytes16Ty = exports.Bytes15Ty = exports.Bytes14Ty = exports.Bytes13Ty = exports.Bytes12Ty = exports.Bytes11Ty = exports.Bytes10Ty = exports.Bytes9Ty = exports.Bytes8Ty = exports.Bytes7Ty = exports.Bytes6Ty = exports.Bytes5Ty = exports.Bytes4Ty = exports.Bytes3Ty = exports.Bytes2Ty = exports.Bytes1Ty = exports.BytesTy = exports.AddressTy = exports.BoolTy = exports.StringTy = exports.Uint256Ty = exports.Int256Ty = void 0;
exports.CONSOLE_LOG_SIGNATURES = exports.Bytes32Ty = exports.Bytes31Ty = exports.Bytes30Ty = exports.Bytes29Ty = exports.Bytes28Ty = exports.Bytes27Ty = exports.Bytes26Ty = exports.Bytes25Ty = exports.Bytes24Ty = exports.Bytes23Ty = exports.Bytes22Ty = exports.Bytes21Ty = exports.Bytes20Ty = exports.Bytes19Ty = exports.Bytes18Ty = exports.Bytes17Ty = exports.Bytes16Ty = exports.Bytes15Ty = exports.Bytes14Ty = exports.Bytes13Ty = exports.Bytes12Ty = exports.Bytes11Ty = exports.Bytes10Ty = exports.Bytes9Ty = exports.Bytes8Ty = exports.Bytes7Ty = exports.Bytes6Ty = exports.Bytes5Ty = exports.Bytes4Ty = exports.Bytes3Ty = exports.Bytes2Ty = exports.Bytes1Ty = exports.BytesTy = exports.AddressTy = exports.BoolTy = exports.StringTy = exports.Uint256Ty = exports.Int256Ty = void 0;
exports.Int256Ty = "Int256";

@@ -46,5 +46,4 @@ exports.Uint256Ty = "Uint256";

exports.Bytes32Ty = "Bytes32";
// In order to optimize map lookup
// we'll store 4byte signature as int
exports.ConsoleLogs = {
/** Maps from a 4-byte function selector to a signature (argument types) */
exports.CONSOLE_LOG_SIGNATURES = {
1368866505: [],

@@ -51,0 +50,0 @@ 760966329: [exports.Int256Ty],

{
"name": "hardhat",
"version": "2.22.6",
"version": "2.22.7",
"author": "Nomic Labs LLC",

@@ -88,3 +88,3 @@ "license": "MIT",

"@metamask/eth-sig-util": "^4.0.0",
"@nomicfoundation/edr": "^0.4.1",
"@nomicfoundation/edr": "^0.5.0",
"@nomicfoundation/ethereumjs-common": "4.0.4",

@@ -91,0 +91,0 @@ "@nomicfoundation/ethereumjs-tx": "5.0.4",

@@ -555,3 +555,3 @@ export const ERROR_PREFIX = "HH";

message:
"Default value for param %paramName% of task %taskName% doesn't match the default one, try specifying it.",
"Default value for param %paramName% of task %taskName% doesn't match its expected type.",
title: "Default value has incorrect type",

@@ -558,0 +558,0 @@ description: `One of your tasks has a parameter whose default value doesn't match the expected type.

@@ -117,2 +117,3 @@ import type {

hardhatNetConfig.enableTransientStorage ?? false,
enableRip7212: hardhatNetConfig.enableRip7212 ?? false,
},

@@ -119,0 +120,0 @@ {

@@ -123,2 +123,3 @@ import type {

enableTransientStorage: boolean;
enableRip7212: boolean;
}

@@ -180,3 +181,2 @@

},
private readonly _eventAdapter: EdrProviderEventAdapter,
private readonly _vmTraceDecoder: VmTraceDecoder,

@@ -261,2 +261,3 @@ // The common configuration for EthereumJS VM is not used by EDR, but tests expect it as part of the provider.

coinbase: Buffer.from(coinbase.slice(2), "hex"),
enableRip7212: config.enableRip7212,
fork,

@@ -287,6 +288,3 @@ hardfork: ethereumsjsHardforkToEdrSpecId(hardforkName),

enable: loggerConfig.enabled,
decodeConsoleLogInputsCallback: (inputs: Buffer[]) => {
const consoleLogger = new ConsoleLogger();
return consoleLogger.getDecodedLogs(inputs);
},
decodeConsoleLogInputsCallback: ConsoleLogger.getDecodedLogs,
getContractAndFunctionNameCallback: (

@@ -322,3 +320,2 @@ code: Buffer,

minimalEthereumJsNode,
eventAdapter,
vmTraceDecoder,

@@ -632,7 +629,13 @@ common,

): Promise<EIP1193Provider> {
return EdrProviderWrapper.create(
log("Making tracing config");
const tracingConfig = await makeTracingConfig(artifacts);
log("Creating EDR provider");
const provider = EdrProviderWrapper.create(
hardhatNetworkProviderConfig,
loggerConfig,
await makeTracingConfig(artifacts)
tracingConfig
);
log("EDR provider created");
return provider;
}

@@ -639,0 +642,0 @@

@@ -27,2 +27,3 @@ import type { ExceptionalHalt, SuccessReason } from "@nomicfoundation/edr";

case SuccessReason.SelfDestruct:
case SuccessReason.EofReturnContract:
return new Exit(ExitCode.SUCCESS);

@@ -29,0 +30,0 @@ }

@@ -45,85 +45,25 @@ import {

BytesTy,
ConsoleLogs,
Int256Ty,
StringTy,
Uint256Ty,
CONSOLE_LOG_SIGNATURES,
} from "./logger";
import {
EvmMessageTrace,
isCallTrace,
isEvmStep,
isPrecompileTrace,
MessageTrace,
} from "./message-trace";
const CONSOLE_ADDRESS = "0x000000000000000000636F6e736F6c652e6c6f67"; // toHex("console.log")
const REGISTER_SIZE = 32;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ConsoleLogArray extends Array<ConsoleLogEntry> {}
/** The decoded string representation of the arguments supplied to console.log */
export type ConsoleLogArgs = string[];
export type ConsoleLogs = ConsoleLogArgs[];
export type ConsoleLogEntry = string | ConsoleLogArray;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ConsoleLogs = ConsoleLogEntry[];
export class ConsoleLogger {
private readonly _consoleLogs: {
[key: number]: string[];
} = {};
constructor() {
this._consoleLogs = ConsoleLogs;
}
public getLogMessages(maybeDecodedMessageTrace: MessageTrace): string[] {
return this.getExecutionLogs(maybeDecodedMessageTrace).map(
consoleLogToString
);
}
public getExecutionLogs(
maybeDecodedMessageTrace: MessageTrace
): ConsoleLogs[] {
if (isPrecompileTrace(maybeDecodedMessageTrace)) {
return [];
}
const logs: ConsoleLogs[] = [];
this._collectExecutionLogs(maybeDecodedMessageTrace, logs);
return logs;
}
private _collectExecutionLogs(trace: EvmMessageTrace, logs: ConsoleLogs) {
for (const messageTrace of trace.steps) {
if (isEvmStep(messageTrace) || isPrecompileTrace(messageTrace)) {
continue;
}
if (
isCallTrace(messageTrace) &&
bufferToHex(messageTrace.address) === CONSOLE_ADDRESS.toLowerCase()
) {
const log = this._maybeConsoleLog(Buffer.from(messageTrace.calldata));
if (log !== undefined) {
logs.push(log);
}
continue;
}
this._collectExecutionLogs(messageTrace, logs);
}
}
/**
* Temporary code to print console.sol messages that come from EDR
*/
public getDecodedLogs(messages: Buffer[]): string[] {
public static getDecodedLogs(messages: Buffer[]): string[] {
const logs: string[] = [];
for (const message of messages) {
const log = this._maybeConsoleLog(message);
const log = ConsoleLogger._maybeConsoleLog(message);
if (log !== undefined) {
logs.push(consoleLogToString(log));
logs.push(ConsoleLogger.format(log));
}

@@ -135,20 +75,28 @@ }

private _maybeConsoleLog(calldata: Buffer): ConsoleLogs | undefined {
const sig = bytesToInt(calldata.slice(0, 4));
/**
* Returns a formatted string using the first argument as a `printf`-like
* format string which can contain zero or more format specifiers.
*
* If there are more arguments passed than the number of specifiers, the
* extra arguments are concatenated to the returned string, separated by spaces.
*/
public static format(args: ConsoleLogArgs = []): string {
return util.format(...args);
}
private static _maybeConsoleLog(
calldata: Buffer
): ConsoleLogArgs | undefined {
const selector = bytesToInt(calldata.slice(0, 4));
const parameters = calldata.slice(4);
const types = this._consoleLogs[sig];
if (types === undefined) {
const argTypes = CONSOLE_LOG_SIGNATURES[selector];
if (argTypes === undefined) {
return;
}
const consoleLogs = this._decode(parameters, types);
const decodedArgs = ConsoleLogger._decode(parameters, argTypes);
this._replaceNumberFormatSpecifiers(consoleLogs);
return consoleLogs;
}
private _replaceNumberFormatSpecifiers(consoleLogs: ConsoleLogs) {
/**
* The first argument is interpreted as the format string, which may need adjusting.
* Replace the occurrences of %d and %i with %s. This is necessary because if the arguments passed are numbers,

@@ -165,4 +113,4 @@ * they could be too large to be formatted as a Number or an Integer, so it is safer to use a String.

*/
if (consoleLogs.length > 0 && typeof consoleLogs[0] === "string") {
consoleLogs[0] = consoleLogs[0].replace(
if (decodedArgs.length > 0) {
decodedArgs[0] = decodedArgs[0].replace(
/((?<!%)(?:%%)*)(%[di])/g,

@@ -172,5 +120,8 @@ "$1%s"

}
return decodedArgs;
}
private _decode(data: Buffer, types: string[]): ConsoleLogs {
/** Decodes parameters from `data` according to `types` into their string representation. */
private static _decode(data: Buffer, types: string[]): string[] {
return types.map((type, i) => {

@@ -289,14 +240,1 @@ const position: number = i * 32;

}
export function consoleLogToString(log: ConsoleLogs): string {
if (log === undefined) {
return "";
}
// special case for console.log()
if (log.length === 0) {
return "";
}
return util.format(log[0], ...log.slice(1));
}
// ------------------------------------
// This code was autogenerated using
// scripts/console-library-generator.js
// scripts/console-library-generator.ts
// ------------------------------------

@@ -45,5 +45,4 @@

// In order to optimize map lookup
// we'll store 4byte signature as int
export const ConsoleLogs = {
/** Maps from a 4-byte function selector to a signature (argument types) */
export const CONSOLE_LOG_SIGNATURES: Record<number, string[]> = {
1368866505: [],

@@ -50,0 +49,0 @@ 760966329: [Int256Ty],

@@ -61,2 +61,3 @@ // This file defines the different config types.

enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

@@ -159,2 +160,3 @@

enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

@@ -161,0 +163,0 @@

@@ -38,2 +38,3 @@ /// <reference types="mocha" />

enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

@@ -115,2 +116,3 @@ export type HardhatNetworkAccountsUserConfig = HardhatNetworkAccountUserConfig[] | HardhatNetworkHDAccountsUserConfig;

enableTransientStorage?: boolean;
enableRip7212?: boolean;
}

@@ -117,0 +119,0 @@ export type HardhatNetworkAccountsConfig = HardhatNetworkHDAccountsConfig | HardhatNetworkAccountConfig[];

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc