Skip to content

Commit

Permalink
encodeInitData
Browse files Browse the repository at this point in the history
  • Loading branch information
irubido committed Jan 24, 2024
1 parent 9c4b7b1 commit 52e87fe
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import Web3, {
Bytes,
utils,
PayableCallOptions,
ContractMethodInputParameters,
AbiFunctionFragment,
} from "web3";
import { vars } from "hardhat/config";
import { HardhatPluginError } from "hardhat/internal/core/errors";
import {
getConfigEnvironmentVariable,
getNetworkChainId,
Expand Down Expand Up @@ -47,19 +50,28 @@ export class MultichainHardhatRuntimeEnvironmentField {

this.domains = config.getDomains();

this.isValidated = true;
this.isValidated;
}

public static encodeInitData(
public encodeInitData<Abi extends ContractAbi = any>(
artifact: Artifact,
initMethodName: string,
initMethodArgs: string[]
initMethodArgs: ContractMethodInputParameters<Abi>
): Bytes {
//TODO
// const contract = new Contract(artifact.abi);
// const encodedInitMethod = contract.methods[initMethodName](initMethodArgs).encodeABI();
console.log(artifact, initMethodArgs, initMethodName);
return utils.hexToBytes("0x");
const initMethodAbiFragment: AbiFunctionFragment | undefined =
artifact.abi.find(
(fragment: AbiFunctionFragment) => fragment.name === initMethodName
) as AbiFunctionFragment | undefined;
if (!initMethodAbiFragment)
throw new HardhatPluginError(
"@chainsafe/hardhat-plugin-multichain-deploy",
`InitMethod ${initMethodName} not foud in ABI`
);

return this.web3!.eth.abi.encodeFunctionCall(
initMethodAbiFragment,
initMethodArgs
);
}

/**
Expand Down

0 comments on commit 52e87fe

Please sign in to comment.