refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
This commit is contained in:
53
dev/env/node_modules/@nomicfoundation/hardhat-errors/CHANGELOG.md
generated
vendored
Executable file
53
dev/env/node_modules/@nomicfoundation/hardhat-errors/CHANGELOG.md
generated
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
# @nomicfoundation/hardhat-errors
|
||||
|
||||
## 3.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6674b00: Bump `hardhat-utils` major
|
||||
- 4cd63e9: Introduce the `@nomicfoundation/hardhat-foundry` plugin for Hardhat 3
|
||||
- f1e9b05: Added support for `inline actions` in tasks [7851](https://github.com/NomicFoundation/hardhat/pull/7851).
|
||||
|
||||
## 3.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6b2ed9a: Add ability for task options to be hidden from the CLI ([#7426](https://github.com/NomicFoundation/hardhat/issues/7426))
|
||||
|
||||
## 3.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 03a4539: Export error descriptors for the website
|
||||
- 95684ac: Full links to documentation replaced by short links with redirects added to the Hardhat website ([#142](https://github.com/NomicFoundation/hardhat-website/issues/142))
|
||||
|
||||
## 3.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ce5c22a: Fail when a file isn't built neither as contract nor test
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a871e3e: Ported the `@nomicfoundation/hardhat-ledger` plugin to Hardhat 3 ([#5646](https://github.com/NomicFoundation/hardhat/issues/5646))
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- be469d6: Display an error message when attempting to use a global hardhat installation in a local repo ([#5362](https://github.com/NomicFoundation/hardhat/issues/5362))
|
||||
- 8d3b16c: Support for custom compilers ([#7130](https://github.com/NomicFoundation/hardhat/issues/7130))
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ddefbff: Added guard to stop multiple simultaneous calls to `ignition.deploy(...)` at once ([#6440](https://github.com/NomicFoundation/hardhat/issues/6440))
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 29cc141: First release of Hardhat 3!
|
||||
9
dev/env/node_modules/@nomicfoundation/hardhat-errors/LICENSE
generated
vendored
Executable file
9
dev/env/node_modules/@nomicfoundation/hardhat-errors/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Nomic Foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
12
dev/env/node_modules/@nomicfoundation/hardhat-errors/README.md
generated
vendored
Executable file
12
dev/env/node_modules/@nomicfoundation/hardhat-errors/README.md
generated
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
# hardhat-errors
|
||||
|
||||
> ⚠️ This package is an internal Hardhat component and it's not meant to be used directly.
|
||||
|
||||
This packages has the definition of the error classes used by Hardhat, and the list of possible errors.
|
||||
|
||||
This module exports:
|
||||
|
||||
1. The error class `HardhatError`, which has a static field `ERRORS`, with the different `ErrorDescriptors` that it accepts.
|
||||
2. The error class `HardhatPluginError`, which is the recommended way to handle errors in Hardhat plugins. For convenience, it is re-exported from `@nomicfoundation/hardhat/plugins`. Plugin developers should import it from this path.
|
||||
3. The interface `ErrorDescriptor`.
|
||||
4. The assertion helper `assertHardhatInvariant`.
|
||||
2108
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.d.ts
generated
vendored
Executable file
2108
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"descriptors.d.ts","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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAskFT,CAAC"}
|
||||
2732
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.js
generated
vendored
Executable file
2732
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.js.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/descriptors.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
66
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.d.ts
generated
vendored
Executable file
66
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.d.ts
generated
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
import type { ErrorDescriptor } from "./descriptors.js";
|
||||
import { CustomError } from "@nomicfoundation/hardhat-utils/error";
|
||||
import { ERRORS } from "./descriptors.js";
|
||||
export type ErrorMessageTemplateValue = string | number | boolean | bigint | undefined | null | ErrorMessageTemplateValue[] | {
|
||||
toString(): string;
|
||||
};
|
||||
export type MessagetTemplateArguments<MessageTemplateT extends string> = MessageTemplateT extends `${string}{${infer Tag}}${infer Rest}` ? {
|
||||
[K in Tag | keyof MessagetTemplateArguments<Rest>]: ErrorMessageTemplateValue;
|
||||
} : {};
|
||||
export type HardhatErrorConstructorArguments<ErrorDescriptorT extends ErrorDescriptor> = keyof MessagetTemplateArguments<ErrorDescriptorT["messageTemplate"]> extends never ? [ErrorDescriptorT, Error?] : [
|
||||
ErrorDescriptorT,
|
||||
MessagetTemplateArguments<ErrorDescriptorT["messageTemplate"]>,
|
||||
Error?
|
||||
];
|
||||
export declare const ERROR_PREFIX = "HHE";
|
||||
/**
|
||||
* An error thrown by Hardhat. This error is meant to be thrown by Hardhat
|
||||
* itself, and internal plugins. For errors thrown by community plugins, see
|
||||
* `HardhatPluginError`.
|
||||
*/
|
||||
export declare class HardhatError<ErrorDescriptorT extends ErrorDescriptor = ErrorDescriptor> extends CustomError {
|
||||
#private;
|
||||
static readonly ERRORS: typeof ERRORS;
|
||||
constructor(...[errorDescriptor, messageArgumentsOrParentError, parentError,]: HardhatErrorConstructorArguments<ErrorDescriptorT>);
|
||||
static isHardhatError(other: unknown): other is HardhatError<ErrorDescriptor>;
|
||||
static isHardhatError<ErrorDescriptorT extends ErrorDescriptor>(other: unknown, descriptor?: ErrorDescriptorT): other is HardhatError<ErrorDescriptorT>;
|
||||
get number(): number;
|
||||
get pluginId(): string | undefined;
|
||||
get descriptor(): ErrorDescriptor;
|
||||
get messageArguments(): MessagetTemplateArguments<ErrorDescriptorT["messageTemplate"]>;
|
||||
get errorCode(): string;
|
||||
get formattedMessage(): string;
|
||||
}
|
||||
/**
|
||||
* An error thrown by a Hardhat plugin. This error is meant to be thrown by
|
||||
* community plugins to signal that something went wrong.
|
||||
*/
|
||||
export declare class HardhatPluginError extends CustomError {
|
||||
readonly pluginId: string;
|
||||
constructor(pluginId: string, message: string, parentError?: Error);
|
||||
static isHardhatPluginError(other: unknown): other is HardhatPluginError;
|
||||
}
|
||||
/**
|
||||
* Asserts an internal invariant.
|
||||
*
|
||||
* @param invariant The condition to check.
|
||||
* @param message A message to show if the condition is false.
|
||||
*/
|
||||
export declare function assertHardhatInvariant(invariant: boolean, message: string): asserts invariant;
|
||||
/**
|
||||
* This function applies error messages templates like this:
|
||||
*
|
||||
* - Template is a string which contains a variable tags. A variable tag is a
|
||||
* a variable name surrounded by %. Eg: %plugin1%
|
||||
* - A variable name is a string of alphanumeric ascii characters.
|
||||
* - Every variable tag is replaced by its value.
|
||||
* - %% is replaced by %.
|
||||
* - Values can't contain variable tags.
|
||||
* - If a variable is not present in the template, but present in the values
|
||||
* object, an error is thrown.
|
||||
*
|
||||
* @param template The template string.
|
||||
* @param values A map of variable names to their values.
|
||||
*/
|
||||
export declare function applyErrorMessageTemplate(template: string, values: Record<string, ErrorMessageTemplateValue>): string;
|
||||
//# sourceMappingURL=errors.d.ts.map
|
||||
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAoB,MAAM,kBAAkB,CAAC;AAE5D,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,GACT,IAAI,GACJ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AAgB,CAAC,iBAAiB,CAAC,CACpC,CAEA;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,gBAAgB,IAAI,MAAM,CAEpC;CACF;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;aAE/B,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM,EAChC,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,KAAK;WAaP,oBAAoB,CAChC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,kBAAkB;CAY/B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAInB;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAChD,MAAM,CAsBR"}
|
||||
164
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.js
generated
vendored
Executable file
164
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.js
generated
vendored
Executable file
@@ -0,0 +1,164 @@
|
||||
import { CustomError } from "@nomicfoundation/hardhat-utils/error";
|
||||
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
||||
import { ERRORS, ERROR_CATEGORIES } from "./descriptors.js";
|
||||
export const ERROR_PREFIX = "HHE";
|
||||
const IS_HARDHAT_ERROR_PROPERTY_NAME = "_isHardhatError";
|
||||
const IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME = "_isHardhatPluginError";
|
||||
/**
|
||||
* An error thrown by Hardhat. This error is meant to be thrown by Hardhat
|
||||
* itself, and internal plugins. For errors thrown by community plugins, see
|
||||
* `HardhatPluginError`.
|
||||
*/
|
||||
export class HardhatError extends CustomError {
|
||||
static ERRORS = ERRORS;
|
||||
#descriptor;
|
||||
#arguments;
|
||||
#errorCode;
|
||||
#formattedMessage;
|
||||
constructor(...[errorDescriptor, messageArgumentsOrParentError, parentError,]) {
|
||||
const errorCode = getErrorCode(errorDescriptor);
|
||||
const formattedMessage = messageArgumentsOrParentError === undefined ||
|
||||
messageArgumentsOrParentError instanceof Error
|
||||
? errorDescriptor.messageTemplate
|
||||
: applyErrorMessageTemplate(errorDescriptor.messageTemplate, messageArgumentsOrParentError);
|
||||
super(`${errorCode}: ${formattedMessage}`, parentError instanceof Error
|
||||
? parentError
|
||||
: messageArgumentsOrParentError instanceof Error
|
||||
? messageArgumentsOrParentError
|
||||
: undefined);
|
||||
this.#descriptor = errorDescriptor;
|
||||
this.#errorCode = errorCode;
|
||||
this.#formattedMessage = formattedMessage;
|
||||
if (messageArgumentsOrParentError === undefined ||
|
||||
messageArgumentsOrParentError instanceof Error) {
|
||||
/* eslint-disable @typescript-eslint/consistent-type-assertions --
|
||||
Typescript inference get's lost here, but we know that if we didn't get
|
||||
arguments, it's because the error doesn't have any. */
|
||||
this.#arguments = {};
|
||||
}
|
||||
else {
|
||||
this.#arguments = messageArgumentsOrParentError;
|
||||
}
|
||||
// As this package is going to be used from most of our packages, there's a
|
||||
// change of users having multiple versions of it. If that happens, they may
|
||||
// have multiple `HardhatError` classes, so we can't reliably use
|
||||
// `instanceof` to check if an error is a `HardhatError`. We define a
|
||||
// pseudo-private field to use it for it. While this is not bulletproof, it
|
||||
// should be enough for our case, as we won't be changing this class often.
|
||||
Object.defineProperty(this, IS_HARDHAT_ERROR_PROPERTY_NAME, {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
static isHardhatError(other, descriptor) {
|
||||
if (!isObject(other)) {
|
||||
return false;
|
||||
}
|
||||
const isHardhatErrorProperty = Object.getOwnPropertyDescriptor(other, IS_HARDHAT_ERROR_PROPERTY_NAME);
|
||||
return (isHardhatErrorProperty?.value === true &&
|
||||
// If an error descriptor is provided, check if its number matches the Hardhat error number
|
||||
(descriptor === undefined
|
||||
? true
|
||||
: "number" in other && other.number === descriptor.number));
|
||||
}
|
||||
get number() {
|
||||
return this.#descriptor.number;
|
||||
}
|
||||
get pluginId() {
|
||||
for (const category of Object.values(ERROR_CATEGORIES)) {
|
||||
const isWithinCategoryRange = this.#descriptor.number >= category.min &&
|
||||
this.#descriptor.number <= category.max;
|
||||
if (isWithinCategoryRange) {
|
||||
return category.pluginId;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
get descriptor() {
|
||||
return this.#descriptor;
|
||||
}
|
||||
get messageArguments() {
|
||||
return this.#arguments;
|
||||
}
|
||||
get errorCode() {
|
||||
return this.#errorCode;
|
||||
}
|
||||
get formattedMessage() {
|
||||
return this.#formattedMessage;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* An error thrown by a Hardhat plugin. This error is meant to be thrown by
|
||||
* community plugins to signal that something went wrong.
|
||||
*/
|
||||
export class HardhatPluginError extends CustomError {
|
||||
pluginId;
|
||||
constructor(pluginId, message, parentError) {
|
||||
super(message, parentError);
|
||||
this.pluginId = pluginId;
|
||||
// See `HardhatError` constructor for an explanation of this property.
|
||||
Object.defineProperty(this, IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME, {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
static isHardhatPluginError(other) {
|
||||
if (!isObject(other)) {
|
||||
return false;
|
||||
}
|
||||
const isHardhatPluginErrorProperty = Object.getOwnPropertyDescriptor(other, IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME);
|
||||
return isHardhatPluginErrorProperty?.value === true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Asserts an internal invariant.
|
||||
*
|
||||
* @param invariant The condition to check.
|
||||
* @param message A message to show if the condition is false.
|
||||
*/
|
||||
export function assertHardhatInvariant(invariant, message) {
|
||||
if (!invariant) {
|
||||
throw new HardhatError(ERRORS.CORE.INTERNAL.ASSERTION_ERROR, { message });
|
||||
}
|
||||
}
|
||||
function getErrorCode(errorDescriptor) {
|
||||
return `${ERROR_PREFIX}${errorDescriptor.number}`;
|
||||
}
|
||||
/**
|
||||
* This function applies error messages templates like this:
|
||||
*
|
||||
* - Template is a string which contains a variable tags. A variable tag is a
|
||||
* a variable name surrounded by %. Eg: %plugin1%
|
||||
* - A variable name is a string of alphanumeric ascii characters.
|
||||
* - Every variable tag is replaced by its value.
|
||||
* - %% is replaced by %.
|
||||
* - Values can't contain variable tags.
|
||||
* - If a variable is not present in the template, but present in the values
|
||||
* object, an error is thrown.
|
||||
*
|
||||
* @param template The template string.
|
||||
* @param values A map of variable names to their values.
|
||||
*/
|
||||
export function applyErrorMessageTemplate(template, values) {
|
||||
return template.replaceAll(/{(.*?)}/g, (_match, variableName) => {
|
||||
const rawValue = values[variableName];
|
||||
if (rawValue === undefined) {
|
||||
return "undefined";
|
||||
}
|
||||
if (rawValue === null) {
|
||||
return "null";
|
||||
}
|
||||
if (typeof rawValue === "bigint") {
|
||||
return `${rawValue}n`;
|
||||
}
|
||||
if (Array.isArray(rawValue)) {
|
||||
return JSON.stringify(rawValue);
|
||||
}
|
||||
return rawValue.toString();
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=errors.js.map
|
||||
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.js.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/errors.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiC5D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAElC,MAAM,8BA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,MAAM,EAAE,YAAY,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAEtC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,OAAO,GAAG,QAAQ,GAAG,CAAC;QACxB,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
3
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.d.ts
generated
vendored
Executable file
3
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
export type { ErrorDescriptor } from "./descriptors.js";
|
||||
export { HardhatError, HardhatPluginError, assertHardhatInvariant, } from "./errors.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|
||||
2
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.js
generated
vendored
Executable file
2
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export { HardhatError, HardhatPluginError, assertHardhatInvariant, } from "./errors.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.js.map
generated
vendored
Executable file
1
dev/env/node_modules/@nomicfoundation/hardhat-errors/dist/src/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|
||||
58
dev/env/node_modules/@nomicfoundation/hardhat-errors/package.json
generated
vendored
Executable file
58
dev/env/node_modules/@nomicfoundation/hardhat-errors/package.json
generated
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "@nomicfoundation/hardhat-errors",
|
||||
"version": "3.0.7",
|
||||
"description": "The different errors that Hardhat can throw",
|
||||
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-errors",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/NomicFoundation/hardhat",
|
||||
"directory": "v-next/hardhat-errors"
|
||||
},
|
||||
"author": "Nomic Foundation",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/src/index.js",
|
||||
"./descriptors": "./dist/src/descriptors.js"
|
||||
},
|
||||
"keywords": [
|
||||
"ethereum",
|
||||
"smart-contracts",
|
||||
"hardhat"
|
||||
],
|
||||
"files": [
|
||||
"dist/src/",
|
||||
"src/",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"c8": "^9.1.0",
|
||||
"eslint": "9.25.1",
|
||||
"expect-type": "^1.2.1",
|
||||
"prettier": "3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "~5.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nomicfoundation/hardhat-utils": "^4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "pnpm prettier --check && pnpm eslint",
|
||||
"lint:fix": "pnpm prettier --write && pnpm eslint --fix",
|
||||
"eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
|
||||
"test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
||||
"test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
||||
"test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
||||
"pretest": "pnpm build",
|
||||
"pretest:only": "pnpm build",
|
||||
"build": "tsc --build .",
|
||||
"clean": "rimraf dist"
|
||||
}
|
||||
}
|
||||
2963
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/descriptors.ts
generated
vendored
Executable file
2963
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/descriptors.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
285
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/errors.ts
generated
vendored
Executable file
285
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/errors.ts
generated
vendored
Executable file
@@ -0,0 +1,285 @@
|
||||
import type { ErrorDescriptor } from "./descriptors.js";
|
||||
|
||||
import { CustomError } from "@nomicfoundation/hardhat-utils/error";
|
||||
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
||||
|
||||
import { ERRORS, ERROR_CATEGORIES } from "./descriptors.js";
|
||||
|
||||
export type ErrorMessageTemplateValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| bigint
|
||||
| undefined
|
||||
| null
|
||||
| ErrorMessageTemplateValue[]
|
||||
| { toString(): string };
|
||||
|
||||
export type MessagetTemplateArguments<MessageTemplateT extends string> =
|
||||
MessageTemplateT extends `${string}{${infer Tag}}${infer Rest}`
|
||||
? {
|
||||
[K in
|
||||
| Tag
|
||||
| keyof MessagetTemplateArguments<Rest>]: ErrorMessageTemplateValue;
|
||||
}
|
||||
: {};
|
||||
|
||||
export type HardhatErrorConstructorArguments<
|
||||
ErrorDescriptorT extends ErrorDescriptor,
|
||||
> = keyof MessagetTemplateArguments<
|
||||
ErrorDescriptorT["messageTemplate"]
|
||||
> extends never
|
||||
? [ErrorDescriptorT, Error?]
|
||||
: [
|
||||
ErrorDescriptorT,
|
||||
MessagetTemplateArguments<ErrorDescriptorT["messageTemplate"]>,
|
||||
Error?,
|
||||
];
|
||||
|
||||
export const ERROR_PREFIX = "HHE";
|
||||
|
||||
const IS_HARDHAT_ERROR_PROPERTY_NAME = "_isHardhatError";
|
||||
const IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME = "_isHardhatPluginError";
|
||||
|
||||
/**
|
||||
* An error thrown by Hardhat. This error is meant to be thrown by Hardhat
|
||||
* itself, and internal plugins. For errors thrown by community plugins, see
|
||||
* `HardhatPluginError`.
|
||||
*/
|
||||
export class HardhatError<
|
||||
ErrorDescriptorT extends ErrorDescriptor = ErrorDescriptor,
|
||||
> extends CustomError {
|
||||
public static readonly ERRORS: typeof ERRORS = ERRORS;
|
||||
|
||||
readonly #descriptor: ErrorDescriptorT;
|
||||
|
||||
readonly #arguments: MessagetTemplateArguments<
|
||||
ErrorDescriptorT["messageTemplate"]
|
||||
>;
|
||||
|
||||
readonly #errorCode: string;
|
||||
|
||||
readonly #formattedMessage: string;
|
||||
|
||||
constructor(
|
||||
...[
|
||||
errorDescriptor,
|
||||
messageArgumentsOrParentError,
|
||||
parentError,
|
||||
]: HardhatErrorConstructorArguments<ErrorDescriptorT>
|
||||
) {
|
||||
const errorCode = getErrorCode(errorDescriptor);
|
||||
|
||||
const formattedMessage =
|
||||
messageArgumentsOrParentError === undefined ||
|
||||
messageArgumentsOrParentError instanceof Error
|
||||
? errorDescriptor.messageTemplate
|
||||
: applyErrorMessageTemplate(
|
||||
errorDescriptor.messageTemplate,
|
||||
messageArgumentsOrParentError,
|
||||
);
|
||||
|
||||
super(
|
||||
`${errorCode}: ${formattedMessage}`,
|
||||
parentError instanceof Error
|
||||
? parentError
|
||||
: messageArgumentsOrParentError instanceof Error
|
||||
? messageArgumentsOrParentError
|
||||
: undefined,
|
||||
);
|
||||
|
||||
this.#descriptor = errorDescriptor;
|
||||
this.#errorCode = errorCode;
|
||||
this.#formattedMessage = formattedMessage;
|
||||
|
||||
if (
|
||||
messageArgumentsOrParentError === undefined ||
|
||||
messageArgumentsOrParentError instanceof Error
|
||||
) {
|
||||
/* eslint-disable @typescript-eslint/consistent-type-assertions --
|
||||
Typescript inference get's lost here, but we know that if we didn't get
|
||||
arguments, it's because the error doesn't have any. */
|
||||
this.#arguments = {} as MessagetTemplateArguments<
|
||||
ErrorDescriptorT["messageTemplate"]
|
||||
>;
|
||||
} else {
|
||||
this.#arguments = messageArgumentsOrParentError;
|
||||
}
|
||||
|
||||
// As this package is going to be used from most of our packages, there's a
|
||||
// change of users having multiple versions of it. If that happens, they may
|
||||
// have multiple `HardhatError` classes, so we can't reliably use
|
||||
// `instanceof` to check if an error is a `HardhatError`. We define a
|
||||
// pseudo-private field to use it for it. While this is not bulletproof, it
|
||||
// should be enough for our case, as we won't be changing this class often.
|
||||
Object.defineProperty(this, IS_HARDHAT_ERROR_PROPERTY_NAME, {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
|
||||
public static isHardhatError(
|
||||
other: unknown,
|
||||
): other is HardhatError<ErrorDescriptor>;
|
||||
public static isHardhatError<ErrorDescriptorT extends ErrorDescriptor>(
|
||||
other: unknown,
|
||||
descriptor?: ErrorDescriptorT,
|
||||
): other is HardhatError<ErrorDescriptorT>;
|
||||
public static isHardhatError(
|
||||
other: unknown,
|
||||
descriptor?: ErrorDescriptor,
|
||||
): other is HardhatError<ErrorDescriptor> {
|
||||
if (!isObject(other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isHardhatErrorProperty = Object.getOwnPropertyDescriptor(
|
||||
other,
|
||||
IS_HARDHAT_ERROR_PROPERTY_NAME,
|
||||
);
|
||||
|
||||
return (
|
||||
isHardhatErrorProperty?.value === true &&
|
||||
// If an error descriptor is provided, check if its number matches the Hardhat error number
|
||||
(descriptor === undefined
|
||||
? true
|
||||
: "number" in other && other.number === descriptor.number)
|
||||
);
|
||||
}
|
||||
|
||||
public get number(): number {
|
||||
return this.#descriptor.number;
|
||||
}
|
||||
|
||||
public get pluginId(): string | undefined {
|
||||
for (const category of Object.values(ERROR_CATEGORIES)) {
|
||||
const isWithinCategoryRange =
|
||||
this.#descriptor.number >= category.min &&
|
||||
this.#descriptor.number <= category.max;
|
||||
|
||||
if (isWithinCategoryRange) {
|
||||
return category.pluginId;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public get descriptor(): ErrorDescriptor {
|
||||
return this.#descriptor;
|
||||
}
|
||||
|
||||
public get messageArguments(): MessagetTemplateArguments<
|
||||
ErrorDescriptorT["messageTemplate"]
|
||||
> {
|
||||
return this.#arguments;
|
||||
}
|
||||
|
||||
public get errorCode(): string {
|
||||
return this.#errorCode;
|
||||
}
|
||||
|
||||
public get formattedMessage(): string {
|
||||
return this.#formattedMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An error thrown by a Hardhat plugin. This error is meant to be thrown by
|
||||
* community plugins to signal that something went wrong.
|
||||
*/
|
||||
export class HardhatPluginError extends CustomError {
|
||||
constructor(
|
||||
public readonly pluginId: string,
|
||||
message: string,
|
||||
parentError?: Error,
|
||||
) {
|
||||
super(message, parentError);
|
||||
|
||||
// See `HardhatError` constructor for an explanation of this property.
|
||||
Object.defineProperty(this, IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME, {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
|
||||
public static isHardhatPluginError(
|
||||
other: unknown,
|
||||
): other is HardhatPluginError {
|
||||
if (!isObject(other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isHardhatPluginErrorProperty = Object.getOwnPropertyDescriptor(
|
||||
other,
|
||||
IS_HARDHAT_PLUGIN_ERROR_PROPERTY_NAME,
|
||||
);
|
||||
|
||||
return isHardhatPluginErrorProperty?.value === true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts an internal invariant.
|
||||
*
|
||||
* @param invariant The condition to check.
|
||||
* @param message A message to show if the condition is false.
|
||||
*/
|
||||
export function assertHardhatInvariant(
|
||||
invariant: boolean,
|
||||
message: string,
|
||||
): asserts invariant {
|
||||
if (!invariant) {
|
||||
throw new HardhatError(ERRORS.CORE.INTERNAL.ASSERTION_ERROR, { message });
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorCode(errorDescriptor: ErrorDescriptor): string {
|
||||
return `${ERROR_PREFIX}${errorDescriptor.number}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function applies error messages templates like this:
|
||||
*
|
||||
* - Template is a string which contains a variable tags. A variable tag is a
|
||||
* a variable name surrounded by %. Eg: %plugin1%
|
||||
* - A variable name is a string of alphanumeric ascii characters.
|
||||
* - Every variable tag is replaced by its value.
|
||||
* - %% is replaced by %.
|
||||
* - Values can't contain variable tags.
|
||||
* - If a variable is not present in the template, but present in the values
|
||||
* object, an error is thrown.
|
||||
*
|
||||
* @param template The template string.
|
||||
* @param values A map of variable names to their values.
|
||||
*/
|
||||
export function applyErrorMessageTemplate(
|
||||
template: string,
|
||||
values: Record<string, ErrorMessageTemplateValue>,
|
||||
): string {
|
||||
return template.replaceAll(/{(.*?)}/g, (_match, variableName) => {
|
||||
const rawValue = values[variableName];
|
||||
|
||||
if (rawValue === undefined) {
|
||||
return "undefined";
|
||||
}
|
||||
|
||||
if (rawValue === null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
if (typeof rawValue === "bigint") {
|
||||
return `${rawValue}n`;
|
||||
}
|
||||
|
||||
if (Array.isArray(rawValue)) {
|
||||
return JSON.stringify(rawValue);
|
||||
}
|
||||
|
||||
return rawValue.toString();
|
||||
});
|
||||
}
|
||||
6
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/index.ts
generated
vendored
Executable file
6
dev/env/node_modules/@nomicfoundation/hardhat-errors/src/index.ts
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
export type { ErrorDescriptor } from "./descriptors.js";
|
||||
export {
|
||||
HardhatError,
|
||||
HardhatPluginError,
|
||||
assertHardhatInvariant,
|
||||
} from "./errors.js";
|
||||
Reference in New Issue
Block a user