@simbachain/hardhat
Version:
Simba Chain plugin for hardhat
69 lines (61 loc) • 2.3 kB
text/typescript
import { extendConfig, extendEnvironment } from "hardhat/config";
import { HardhatConfig, HardhatUserConfig } from "hardhat/types";
import path from "path";
import simba from "./tasks/simba";
import "./tasks/simba";
import {login} from "./tasks/login";
import "./tasks/login";
import {logout} from "./tasks/logout";
import "./tasks/logout";
import {exportContract} from "./tasks/exportcontract";
import "./tasks/exportcontract";
import {deployContract} from "./tasks/deploycontract";
import "./tasks/deploycontract";
import {setLogLevel} from "./tasks/loglevel";
import "./tasks/loglevel";
import {
viewContracts,
pull,
addLibrary,
}
from "./tasks/contract";
import "./tasks/contract";
// This import is needed to let the TypeScript compiler know that it should include your type
// extensions in your npm package's types file.
import "./type-extensions";
extendConfig(
(config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
// We apply our default config here. Any other kind of config resolution
// or normalization should be placed here.
//
// `config` is the resolved config, which will be used during runtime and
// you should modify.
// `userConfig` is the config as provided by the user. You should not modify
// it.
//
// If you extended the `HardhatConfig` type, you need to make sure that
// executing this function ensures that the `config` object is in a valid
// state for its type, including its extensions. For example, you may
// need to apply a default value, like in this example.
const userPath = userConfig.paths?.newPath;
let newPath: string;
if (userPath === undefined) {
newPath = path.join(config.paths.root, "newPath");
} else {
if (path.isAbsolute(userPath)) {
newPath = userPath;
} else {
// We resolve relative paths starting from the project's root.
// Please keep this convention to avoid confusion.
newPath = path.normalize(path.join(config.paths.root, userPath));
}
}
config.paths.newPath = newPath;
}
);
extendEnvironment((hre) => {
// We add a field to the Hardhat Runtime Environment here.
// We use lazyObject to avoid initializing things until they are actually
// needed.
hre.simba = simba;
});