@solarity/hardhat-migrate
Version:
The simplest way to deploy smart contracts
45 lines • 1.63 kB
JavaScript
import { MigrateError } from "../internal/utils/index.js";
export function ValidateKeyDeploymentFields(value, _context) {
return function (...args) {
const key = args[0];
baseTxValidation(key, "KeyDeploymentFields");
return value.apply(this, args);
};
}
export function ValidateKeyTxFields(value, _context) {
return function (...args) {
const key = args[0];
baseTxValidation(key, "KeyTransactionFields");
if (!key.to || key.to === "") {
throw new MigrateError(`KeyTransactionFields.to is not valid`);
}
if (key.name === undefined) {
throw new MigrateError(`KeyTransactionFields.name is not valid`);
}
return value.apply(this, args);
};
}
export function isTypechainFactoryClass(instance) {
return instance.createInterface !== undefined;
}
export function isBytecodeFactory(instance) {
return instance.contractName !== undefined;
}
export function isEthersContractFactory(instance) {
return instance.interface !== undefined && instance.bytecode !== undefined;
}
function baseTxValidation(key, namespace) {
if (!key.data || key.data === "") {
throw new MigrateError(`${namespace}.data is not valid`);
}
if (!key.from || key.from === "") {
throw new MigrateError(`${namespace}.from is not valid`);
}
if (!key.chainId || key.chainId === 0n) {
throw new MigrateError(`${namespace}.chainId is not valid`);
}
if (key.value === undefined) {
throw new MigrateError(`${namespace}.value is not valid`);
}
}
//# sourceMappingURL=type-checks.js.map