@nomicfoundation/hardhat-network-helpers
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors"; | ||
if (typeof hexString !== "string" || !/^0x[0-9a-fA-F]+$/.test(hexString)) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.INVALID_HEX_STRING, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_HEX_STRING, { | ||
value: hexString, | ||
@@ -14,3 +14,3 @@ }); | ||
if (hexString.length !== 66) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.INVALID_TX_HASH, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_TX_HASH, { | ||
value: hexString, | ||
@@ -22,3 +22,3 @@ }); | ||
if (!isAddress(address)) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.INVALID_ADDRESS, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_ADDRESS, { | ||
value: address, | ||
@@ -29,3 +29,3 @@ }); | ||
if (hasChecksum && !(await isValidChecksumAddress(address))) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.INVALID_CHECKSUM_ADDRESS, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_CHECKSUM_ADDRESS, { | ||
value: address, | ||
@@ -37,3 +37,3 @@ }); | ||
if (a <= b) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.BLOCK_NUMBER_SMALLER_THAN_CURRENT, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.BLOCK_NUMBER_SMALLER_THAN_CURRENT, { | ||
newValue: a, | ||
@@ -40,0 +40,0 @@ currentValue: b, |
@@ -13,3 +13,3 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors"; | ||
if (x < 0) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.CANNOT_CONVERT_NEGATIVE_NUMBER_TO_RPC_QUANTITY, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CANNOT_CONVERT_NEGATIVE_NUMBER_TO_RPC_QUANTITY, { | ||
value: x, | ||
@@ -22,3 +22,3 @@ }); | ||
if (!x.startsWith("0x")) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.ONLY_ALLOW_0X_PREFIXED_STRINGS); | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.ONLY_ALLOW_0X_PREFIXED_STRINGS); | ||
} | ||
@@ -28,3 +28,3 @@ hex = x; | ||
else { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.CANNOT_CONVERT_TO_RPC_QUANTITY, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CANNOT_CONVERT_TO_RPC_QUANTITY, { | ||
value: x, | ||
@@ -31,0 +31,0 @@ }); |
import { HardhatError } from "@nomicfoundation/hardhat-errors"; | ||
export async function loadFixture(networkHelpers, fixture, snapshots) { | ||
if (fixture.name === "") { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.FIXTURE_ANONYMOUS_FUNCTION_ERROR); | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.FIXTURE_ANONYMOUS_FUNCTION_ERROR); | ||
} | ||
@@ -14,4 +14,5 @@ const snapshot = snapshots.find((s) => s.fixture === fixture); | ||
if (HardhatError.isHardhatError(e) && | ||
e.number === HardhatError.ERRORS.NETWORK_HELPERS.INVALID_SNAPSHOT.number) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.FIXTURE_SNAPSHOT_ERROR); | ||
e.number === | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_SNAPSHOT.number) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.FIXTURE_SNAPSHOT_ERROR); | ||
} | ||
@@ -18,0 +19,0 @@ throw e; |
@@ -7,3 +7,3 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors"; | ||
if (typeof snapshotId !== "string") { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.EVM_SNAPSHOT_VALUE_NOT_A_STRING); | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.EVM_SNAPSHOT_VALUE_NOT_A_STRING); | ||
} | ||
@@ -17,6 +17,6 @@ return { | ||
if (typeof reverted !== "boolean") { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.EVM_REVERT_VALUE_NOT_A_BOOLEAN); | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.EVM_REVERT_VALUE_NOT_A_BOOLEAN); | ||
} | ||
if (!reverted) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.INVALID_SNAPSHOT); | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_SNAPSHOT); | ||
} | ||
@@ -23,0 +23,0 @@ // Re-take the snapshot so that `restore` can be called again |
@@ -117,3 +117,3 @@ import { assertHardhatInvariant, HardhatError, } from "@nomicfoundation/hardhat-errors"; | ||
if (this.#version !== undefined) { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK_VERSIONED, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK_VERSIONED, { | ||
networkName: this.#networkName, | ||
@@ -123,3 +123,3 @@ version: this.#version, | ||
} | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK, { | ||
throw new HardhatError(HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK, { | ||
networkName: this.#networkName, | ||
@@ -126,0 +126,0 @@ }); |
{ | ||
"name": "@nomicfoundation/hardhat-network-helpers", | ||
"version": "3.0.0-next.3", | ||
"version": "3.0.0-next.4", | ||
"description": "Hardhat utils for testing", | ||
@@ -34,3 +34,3 @@ "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-network-helpers", | ||
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0", | ||
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.3", | ||
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.4", | ||
"@types/debug": "^4.1.7", | ||
@@ -52,10 +52,10 @@ "@types/node": "^20.14.9", | ||
"typescript-eslint": "7.7.1", | ||
"@nomicfoundation/hardhat-test-utils": "^3.0.0-next.3" | ||
"@nomicfoundation/hardhat-test-utils": "^3.0.0-next.4" | ||
}, | ||
"dependencies": { | ||
"@nomicfoundation/hardhat-errors": "^3.0.0-next.3", | ||
"@nomicfoundation/hardhat-utils": "^3.0.0-next.3" | ||
"@nomicfoundation/hardhat-errors": "^3.0.0-next.4", | ||
"@nomicfoundation/hardhat-utils": "^3.0.0-next.4" | ||
}, | ||
"peerDependencies": { | ||
"hardhat": "^3.0.0-next.3" | ||
"hardhat": "^3.0.0-next.4" | ||
}, | ||
@@ -62,0 +62,0 @@ "scripts": { |
@@ -10,3 +10,3 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors"; | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.INVALID_HEX_STRING, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_HEX_STRING, | ||
{ | ||
@@ -24,3 +24,3 @@ value: hexString, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.INVALID_TX_HASH, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_TX_HASH, | ||
{ | ||
@@ -36,3 +36,3 @@ value: hexString, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.INVALID_ADDRESS, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_ADDRESS, | ||
{ | ||
@@ -48,3 +48,3 @@ value: address, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.INVALID_CHECKSUM_ADDRESS, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_CHECKSUM_ADDRESS, | ||
{ | ||
@@ -62,3 +62,3 @@ value: address, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.BLOCK_NUMBER_SMALLER_THAN_CURRENT, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.BLOCK_NUMBER_SMALLER_THAN_CURRENT, | ||
{ | ||
@@ -65,0 +65,0 @@ newValue: a, |
@@ -20,3 +20,3 @@ import type { NumberLike } from "../types.js"; | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.CANNOT_CONVERT_NEGATIVE_NUMBER_TO_RPC_QUANTITY, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CANNOT_CONVERT_NEGATIVE_NUMBER_TO_RPC_QUANTITY, | ||
{ | ||
@@ -32,3 +32,3 @@ value: x, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.ONLY_ALLOW_0X_PREFIXED_STRINGS, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.ONLY_ALLOW_0X_PREFIXED_STRINGS, | ||
); | ||
@@ -39,3 +39,3 @@ } | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.CANNOT_CONVERT_TO_RPC_QUANTITY, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CANNOT_CONVERT_TO_RPC_QUANTITY, | ||
{ | ||
@@ -42,0 +42,0 @@ value: x, |
@@ -15,3 +15,3 @@ import type { Fixture, NetworkHelpers, Snapshot } from "../../../types.js"; | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.FIXTURE_ANONYMOUS_FUNCTION_ERROR, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.FIXTURE_ANONYMOUS_FUNCTION_ERROR, | ||
); | ||
@@ -33,6 +33,7 @@ } | ||
HardhatError.isHardhatError(e) && | ||
e.number === HardhatError.ERRORS.NETWORK_HELPERS.INVALID_SNAPSHOT.number | ||
e.number === | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_SNAPSHOT.number | ||
) { | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.FIXTURE_SNAPSHOT_ERROR, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.FIXTURE_SNAPSHOT_ERROR, | ||
); | ||
@@ -39,0 +40,0 @@ } |
@@ -15,3 +15,3 @@ import type { SnapshotRestorer } from "../../../types.js"; | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.EVM_SNAPSHOT_VALUE_NOT_A_STRING, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.EVM_SNAPSHOT_VALUE_NOT_A_STRING, | ||
); | ||
@@ -29,3 +29,3 @@ } | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.EVM_REVERT_VALUE_NOT_A_BOOLEAN, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.EVM_REVERT_VALUE_NOT_A_BOOLEAN, | ||
); | ||
@@ -36,3 +36,3 @@ } | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.INVALID_SNAPSHOT, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.INVALID_SNAPSHOT, | ||
); | ||
@@ -39,0 +39,0 @@ } |
@@ -186,3 +186,3 @@ import type { | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK_VERSIONED, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK_VERSIONED, | ||
{ | ||
@@ -196,3 +196,3 @@ networkName: this.#networkName, | ||
throw new HardhatError( | ||
HardhatError.ERRORS.NETWORK_HELPERS.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK, | ||
HardhatError.ERRORS.NETWORK_HELPERS.GENERAL.CAN_ONLY_BE_USED_WITH_HARDHAT_NETWORK, | ||
{ | ||
@@ -199,0 +199,0 @@ networkName: this.#networkName, |
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
136111
0.33%2282
0.09%