@nomicfoundation/hardhat-viem
Version:
Hardhat plugin for viem
102 lines (95 loc) • 5.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MissingLibraryAddressError = exports.UnnecessaryLibraryLinkError = exports.OverlappingLibraryNamesError = exports.AmbigousLibraryNameError = exports.DeployContractError = exports.InvalidConfirmationsError = exports.DefaultWalletClientNotFoundError = exports.MultipleMatchingNetworksError = exports.NetworkNotFoundError = exports.UnknownDevelopmentNetworkError = exports.HardhatViemError = void 0;
const plugins_1 = require("hardhat/plugins");
class HardhatViemError extends plugins_1.NomicLabsHardhatPluginError {
constructor(message, parent) {
super("@nomicfoundation/hardhat-viem", message, parent);
}
}
exports.HardhatViemError = HardhatViemError;
class UnknownDevelopmentNetworkError extends HardhatViemError {
constructor() {
super(`The chain id corresponds to a development network but we couldn't detect which one.
Please report this issue if you're using Hardhat or Foundry.`);
}
}
exports.UnknownDevelopmentNetworkError = UnknownDevelopmentNetworkError;
class NetworkNotFoundError extends HardhatViemError {
constructor(chainId) {
super(`No network with chain id ${chainId} found. You can override the chain by passing it as a parameter to the client getter:
import { someChain } from "viem/chains";
const client = await hre.viem.getPublicClient({
chain: someChain,
...
});
You can find a list of supported networks here: https://github.com/wevm/viem/blob/main/src/chains/index.ts`);
}
}
exports.NetworkNotFoundError = NetworkNotFoundError;
class MultipleMatchingNetworksError extends HardhatViemError {
constructor(chainId) {
super(`Multiple networks with chain id ${chainId} found. You can override the chain by passing it as a parameter to the client getter:
import { someChain } from "viem/chains";
const client = await hre.viem.getPublicClient({
chain: someChain,
...
});
You can find a list of supported networks here: https://github.com/wevm/viem/blob/main/src/chains/index.ts`);
}
}
exports.MultipleMatchingNetworksError = MultipleMatchingNetworksError;
class DefaultWalletClientNotFoundError extends HardhatViemError {
constructor(networkName) {
super(`Default wallet client not found. This can happen if no accounts were configured for this network (network: '${networkName}').
Alternatively, you can set a custom wallet client by passing it as a parameter in the deployContract function:
const walletClient = await hre.viem.getWalletClient(address);
const contractA = await hre.viem.deployContract("A", [], { walletClient });
const contractB = await hre.viem.getContractAt("B", address, { walletClient });`);
}
}
exports.DefaultWalletClientNotFoundError = DefaultWalletClientNotFoundError;
class InvalidConfirmationsError extends HardhatViemError {
constructor() {
super("deployContract does not support 0 confirmations. Use sendDeploymentTransaction if you want to handle the deployment transaction yourself.");
}
}
exports.InvalidConfirmationsError = InvalidConfirmationsError;
class DeployContractError extends HardhatViemError {
constructor(txHash, blockNumber) {
super(`The deployment transaction '${txHash}' was mined in block '${blockNumber}' but its receipt doesn't contain a contract address`);
}
}
exports.DeployContractError = DeployContractError;
class AmbigousLibraryNameError extends HardhatViemError {
constructor(contractName, libraryName, matchingLibraries) {
super(`The library name "${libraryName}" is ambiguous for the contract "${contractName}".
It may resolve to one of the following libraries:
${matchingLibraries.map((fqn) => `\n\t* ${fqn}`).join(",")}
To fix this, choose one of these fully qualified library names and replace where appropriate.`);
}
}
exports.AmbigousLibraryNameError = AmbigousLibraryNameError;
class OverlappingLibraryNamesError extends HardhatViemError {
constructor(sourceName, libraryName) {
super(`The library name "${libraryName}" and "${sourceName}:${libraryName}" are both linking to the same library. Please use one of them, or If they are not the same library, use fully qualified names instead.`);
}
}
exports.OverlappingLibraryNamesError = OverlappingLibraryNamesError;
class UnnecessaryLibraryLinkError extends HardhatViemError {
constructor(contractName, libraryName) {
super(`The library name "${libraryName}" was linked but it's not referenced by the "${contractName}" contract.`);
}
}
exports.UnnecessaryLibraryLinkError = UnnecessaryLibraryLinkError;
class MissingLibraryAddressError extends HardhatViemError {
constructor(contractName, missingLibraries) {
super(`The libraries needed are:
${missingLibraries
.map(({ sourceName, libraryName }) => `\t* "${sourceName}:${libraryName}"`)
.join(",\n")}
Please deploy them first and link them while deploying "${contractName}"`);
}
}
exports.MissingLibraryAddressError = MissingLibraryAddressError;
//# sourceMappingURL=errors.js.map