Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deployment network type and naming #26

Merged
merged 6 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { vars } from "hardhat/config";
import {
getConfigEnvironmentVariable,
getNetworkChainId,
mapNetworkArgs,
sumedFees,
mapNetworkArgs,
} from "./utils";
import { AdapterABI } from "./adapterABI";
import { DeployOptions, NetworkArguments } from "./types";

export class MultichainHardhatRuntimeEnvironmentField {
private isValidated: boolean = false;
private isInitiated: boolean = false;
private domains: Domain[] = [];
private readonly web3: Web3 | null;

Expand All @@ -34,7 +34,7 @@ export class MultichainHardhatRuntimeEnvironmentField {
//current Sygma hardcoded gasLimit
private gasLimit = 1000000;

private async validateConfig(): Promise<void> {
private async initConfig(): Promise<void> {
const originChainId = await getNetworkChainId(
this.hre.network.name,
this.hre
Expand All @@ -46,7 +46,7 @@ export class MultichainHardhatRuntimeEnvironmentField {

this.domains = config.getDomains();

this.isValidated;
this.isInitiated;
}

/**
Expand Down Expand Up @@ -79,7 +79,7 @@ export class MultichainHardhatRuntimeEnvironmentField {
networkArgs: NetworkArguments<Abi>,
options?: DeployOptions
): Promise<Transaction | void> {
if (!this.isValidated) await this.validateConfig();
if (!this.isInitiated) await this.initConfig();
if (!this.web3) return;

//optional params
Expand Down
16 changes: 12 additions & 4 deletions packages/plugin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ import {
NonPayableCallOptions,
} from "web3";

export interface NetworkArguments<Abi extends ContractAbi = any> {
[network: string]: {
args?: ContractConstructorArgs<Abi>;
export type DeploymentNetwork =
| "ethereum"
| "sepolia"
| "mumbai"
| "goerli"
| "holesky"
| string;

export type NetworkArguments<Abi extends ContractAbi = any> = {
[network in DeploymentNetwork]: {
args: ContractConstructorArgs<Abi>;
initData?: {
initMethodName: keyof ContractMethods<Abi>;
//impossible to type unless we do something like this.getInitMethod(artifact, methodName).encode(args);
initMethodArgs: unknown[];
};
};
}
};

export interface DeployOptions {
salt?: MatchPrimitiveType<"bytes32", unknown>;
Expand Down
7 changes: 1 addition & 6 deletions packages/plugin/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ export function mapNetworkArgs<Abi extends ContractAbi = any>(
else {
throw new HardhatPluginError(
"@chainsafe/hardhat-plugin-multichain-deploy",
`Unavailable Networks in networkArgs: The following network ${networkName} is not supported as destination network.
Available networks: ${domains
.map((domain): string => `${domain.name}`)
.join(", ")
.replace(/, ([^,]*)$/, "")}\n
`
`Unavailable Networks in networkArgs: The following network ${networkName} is not supported as destination network.`
);
}

Expand Down
Loading