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

chore: improve code docs #28

Merged
merged 17 commits into from
Feb 5, 2024
11 changes: 11 additions & 0 deletions docs/plugin/DeployOptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# DeployOptions

```ts
export interface DeployOptions {
salt?: MatchPrimitiveType<"bytes32", unknown>;
isUniquePerChain?: boolean;
customNonPayableTxOptions?: NonPayableCallOptions;
}
```

### TODO
10 changes: 10 additions & 0 deletions docs/plugin/NetworkArguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# NetworkArguments
irubido marked this conversation as resolved.
Show resolved Hide resolved

```ts
interface NetworkArgument<Abi extends ContractAbi = any> {
args: ContractConstructorArgs<Abi>;
initData?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain initData?

}
```

### TODO
28 changes: 21 additions & 7 deletions packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ export class MultichainHardhatRuntimeEnvironmentField {
}

/**
* @param contractName name of the contract
* @param networkArgs record key is name of the networks on which contract is being deployed
* @param args contract contructor args
* @param initData optional encoded initilize method, can be encoded with encodeInitData
* @param salt optional or generated by default from randombytes(32)
* @param isUniquePerChain optional
* @param customNonPayableTxOptions non payable options for web3 deploy.method.send(), payable summed fees are always calculated by the method
* Deploys a contract to multiple blockchain networks.
*
* @param contractName - The name of the contract to be deployed.
* @param networkArgs - An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param networkArgs - An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments}.
* @param networkArgs - An object mapping network identifiers to their constructor arguments. Each network can have unique settings for the deployment. See [NetworkArguments]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain what is the network identifier. Give example for one network

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example will be provided in the example section to reduce clutter parameters section.
Note it is deployment arguments as objects can contain constructor params and init params

* @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See [DeployOptions]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions}.
* @returns A Promise resolving to a Transaction object or void.
*
* @example
* // TODO
*/
public async deployMultichain<Abi extends ContractAbi = any>(
contractName: string,
Expand All @@ -82,6 +84,18 @@ export class MultichainHardhatRuntimeEnvironmentField {
);
}

/**
* Deploys a contract using its bytecode and ABI to multiple blockchain networks.
*
* @param contractBytecode - The bytecode of the contract to be deployed. This is the compiled code of the contract.
* @param contractAbi - The ABI (Application Binary Interface) of the contract. It defines the methods and structures used to interact with the binary contract.
* @param networkArgs - An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments}.
* @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See [DeployOptions]{@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions}.
* @returns A Promise resolving to a Transaction object or void.
*
* @example
* // TODO: Add example usage
*/
public async deployMultichainBytecode<Abi extends ContractAbi = any>(
contractBytecode: string,
contractAbi: Abi,
Expand Down
26 changes: 22 additions & 4 deletions packages/plugin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ import {
NonPayableCallOptions,
} from "web3";

/**
* NetworkArgument
* @property args - Indicates whether args is providing.
* @property initData - Indicates whether the init data.
*/
interface NetworkArgument<Abi extends ContractAbi = any> {
args: ContractConstructorArgs<Abi>;
initData?: string;
}

/**
* NetworkArguments
* @property [network] - NetworkArgument
*/
export interface NetworkArguments<Abi extends ContractAbi = any> {
[network: string]: {
args: ContractConstructorArgs<Abi>;
initData?: string;
};
[network: string]: NetworkArgument<Abi>;
}

/**
* Options used for contract deployment
*
* @property [salt] - Indicates whether salt is present, as Uint8Array or HexString.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain what salt does :)

* @property [isUniquePerChain] - Indicates whether contract address is uniq per deployment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @property [isUniquePerChain] - Indicates whether contract address is uniq per deployment.
* @property [isUniquePerChain] - Indicates whether contract address should be same or different on each chain

* @property [customNonPayableTxOptions] - Indicates whether the Wisdom component is present.
BeroBurny marked this conversation as resolved.
Show resolved Hide resolved
*/
export interface DeployOptions {
salt?: MatchPrimitiveType<"bytes32", unknown>;
isUniquePerChain?: boolean;
Expand Down
Loading