From 793870402649276fcf2651d3e95e8a3a220f3ae9 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Thu, 18 Jan 2024 16:26:07 +0100 Subject: [PATCH 01/14] v0 --- ...ultichainHardhatRuntimeEnvironmentField.ts | 18 ++++++++----- packages/plugin/src/types.ts | 26 ++++++++++++++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index 4f1998c..d556d4a 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -85,13 +85,11 @@ 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 + * deployMultichain deploy contract to multiple chains + * + * @param contractName - Name of contract developed in project + * @param networkArgs - object of network's with arguments where will be deployed, for more information check {@link NetworkArguments} + * @param [options] - Additional options that can be provided into deployer, for more information check {@link DeployOptions} */ public async deployMultichain( contractName: string, @@ -108,6 +106,12 @@ export class MultichainHardhatRuntimeEnvironmentField { ); } + /** + * @param contractBytecode - bytecode of contract + * @param contractAbi - abi of that contract + * @param networkArgs - record key is name of the networks on which contract is being deployed {@link NetworkArguments} + * @param [options] - Additional options that can be provided into method {@link DeployOptions} + */ public async deployMultichainBytecode( contractBytecode: string, contractAbi: Abi, diff --git a/packages/plugin/src/types.ts b/packages/plugin/src/types.ts index e4823e4..75da174 100644 --- a/packages/plugin/src/types.ts +++ b/packages/plugin/src/types.ts @@ -5,13 +5,31 @@ import { NonPayableCallOptions, } from "web3"; +/** + * NetworkArgument + * @property {boolean} args - Indicates whether the Courage component is present. + * @property {string} initData - Indicates whether the Power component is present. + */ +interface NetworkArgument { + args: ContractConstructorArgs; + initData?: string; +} + +/** + * NetworkArguments + * @property {NetworkArgument} [network] - NetworkArgument + */ export interface NetworkArguments { - [network: string]: { - args: ContractConstructorArgs; - initData?: string; - }; + [network: string]: NetworkArgument; } +/** + * Options used for contract deployment + * + * @property {Uint8Array | string} [salt] - Indicates whether the Courage component is present. + * @property {Boolean} [isUniquePerChain] - Indicates whether the Power component is present. + * @property {NonPayableCallOptions} [customNonPayableTxOptions] - Indicates whether the Wisdom component is present. + */ export interface DeployOptions { salt?: MatchPrimitiveType<"bytes32", unknown>; isUniquePerChain?: boolean; From 48918b908a3417eaf41c0edc0237848f24ebc1a1 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Thu, 18 Jan 2024 17:02:37 +0100 Subject: [PATCH 02/14] v0.1 --- ...ultichainHardhatRuntimeEnvironmentField.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index d556d4a..f7f337d 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -85,11 +85,17 @@ export class MultichainHardhatRuntimeEnvironmentField { } /** - * deployMultichain deploy contract to multiple chains + * Deploys a contract to multiple blockchain networks. * - * @param contractName - Name of contract developed in project - * @param networkArgs - object of network's with arguments where will be deployed, for more information check {@link NetworkArguments} - * @param [options] - Additional options that can be provided into deployer, for more information check {@link DeployOptions} + * @param contractName - The name of the contract to be deployed. + * @param networkArgs - An object mapping network identifiers to their deployment arguments. See {@link NetworkArguments}. + * @param options - Optional settings for the deployment process. See {@link DeployOptions}. + * @returns A Promise resolving to a Transaction object or void. + * + * @tutorial readme + * + * @example + * // TODO */ public async deployMultichain( contractName: string, @@ -107,10 +113,16 @@ export class MultichainHardhatRuntimeEnvironmentField { } /** - * @param contractBytecode - bytecode of contract - * @param contractAbi - abi of that contract - * @param networkArgs - record key is name of the networks on which contract is being deployed {@link NetworkArguments} - * @param [options] - Additional options that can be provided into method {@link DeployOptions} + * 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 {@link NetworkArguments}. + * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link DeployOptions}. + * @returns A Promise resolving to a Transaction object or void. + * + * @example + * // TODO: Add example usage */ public async deployMultichainBytecode( contractBytecode: string, From ea2551de21f6604c5f4191970495e410fa783ebd Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Fri, 19 Jan 2024 13:44:28 +0100 Subject: [PATCH 03/14] v1 --- docs/plugin/DeployOptions.md | 11 +++++++++++ docs/plugin/NetworkArguments.md | 10 ++++++++++ .../src/MultichainHardhatRuntimeEnvironmentField.ts | 10 ++++------ packages/plugin/src/types.ts | 12 ++++++------ 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 docs/plugin/DeployOptions.md create mode 100644 docs/plugin/NetworkArguments.md diff --git a/docs/plugin/DeployOptions.md b/docs/plugin/DeployOptions.md new file mode 100644 index 0000000..9b72532 --- /dev/null +++ b/docs/plugin/DeployOptions.md @@ -0,0 +1,11 @@ +# DeployOptions + +```ts +export interface DeployOptions { + salt?: MatchPrimitiveType<"bytes32", unknown>; + isUniquePerChain?: boolean; + customNonPayableTxOptions?: NonPayableCallOptions; +} +``` + +### TODO diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md new file mode 100644 index 0000000..9f4ea06 --- /dev/null +++ b/docs/plugin/NetworkArguments.md @@ -0,0 +1,10 @@ +# NetworkArguments + +```ts +interface NetworkArgument { + args: ContractConstructorArgs; + initData?: string; +} +``` + +### TODO \ No newline at end of file diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index f7f337d..fad8cd8 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -88,12 +88,10 @@ export class MultichainHardhatRuntimeEnvironmentField { * 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. See {@link NetworkArguments}. - * @param options - Optional settings for the deployment process. See {@link DeployOptions}. + * @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. * - * @tutorial readme - * * @example * // TODO */ @@ -117,8 +115,8 @@ export class MultichainHardhatRuntimeEnvironmentField { * * @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 {@link NetworkArguments}. - * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link DeployOptions}. + * @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 diff --git a/packages/plugin/src/types.ts b/packages/plugin/src/types.ts index 75da174..368602a 100644 --- a/packages/plugin/src/types.ts +++ b/packages/plugin/src/types.ts @@ -7,8 +7,8 @@ import { /** * NetworkArgument - * @property {boolean} args - Indicates whether the Courage component is present. - * @property {string} initData - Indicates whether the Power component is present. + * @property args - Indicates whether args is providing. + * @property initData - Indicates whether the init data. */ interface NetworkArgument { args: ContractConstructorArgs; @@ -17,7 +17,7 @@ interface NetworkArgument { /** * NetworkArguments - * @property {NetworkArgument} [network] - NetworkArgument + * @property [network] - NetworkArgument */ export interface NetworkArguments { [network: string]: NetworkArgument; @@ -26,9 +26,9 @@ export interface NetworkArguments { /** * Options used for contract deployment * - * @property {Uint8Array | string} [salt] - Indicates whether the Courage component is present. - * @property {Boolean} [isUniquePerChain] - Indicates whether the Power component is present. - * @property {NonPayableCallOptions} [customNonPayableTxOptions] - Indicates whether the Wisdom component is present. + * @property [salt] - Indicates whether salt is present, as Uint8Array or HexString. + * @property [isUniquePerChain] - Indicates whether contract address is uniq per deployment. + * @property [customNonPayableTxOptions] - Indicates whether the Wisdom component is present. */ export interface DeployOptions { salt?: MatchPrimitiveType<"bytes32", unknown>; From ff199bbea4d583fa8e5c92f77032c2895707fd83 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Tue, 23 Jan 2024 13:50:45 +0100 Subject: [PATCH 04/14] v1.1 --- ...ultichainHardhatRuntimeEnvironmentField.ts | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index 3a08472..9f9bf21 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -62,12 +62,24 @@ export class MultichainHardhatRuntimeEnvironmentField { * 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}. - * @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}. + * @param networkArgs - An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments NetworkArguments}. + * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions DeployOptions}. * @returns A Promise resolving to a Transaction object or void. * * @example - * // TODO + * ``` + * const networkArgs = { + * sepolia: { + * args: [ TODO ], + * }, + * goerli: { ... }, + * }; + * const options = { + * salt: "0xcafe00000000000000000000000000000000000000000000000000000000cafe", + * }; + * + * this.hre.multichain.deployMultichain("HelloContract", networkArgs, options); + * ``` */ public async deployMultichain( contractName: string, @@ -89,12 +101,27 @@ export class MultichainHardhatRuntimeEnvironmentField { * * @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}. + * @param networkArgs - An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments | NetworkArguments}. + * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions | DeployOptions}. * @returns A Promise resolving to a Transaction object or void. * * @example - * // TODO: Add example usage + * ``` + * const contractBytecode = "0x60a060405234801561001057600080fd5b5060405161052b38038061052b83398"; + * const contractAbi = [{ ... }, { ... }]; + * + * const networkArgs = { + * sepolia: { + * args: [ TODO ], + * }, + * goerli: { ... }, + * }; + * const options = { + * salt: "0xcafe00000000000000000000000000000000000000000000000000000000cafe", + * }; + * + * this.hre.multichain.deployMultichain(contractBytecode, contractAbi, networkArgs, options); + * ``` */ public async deployMultichainBytecode( contractBytecode: string, From 182176ecc1e19eba763de0997e76784656532cac Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Tue, 23 Jan 2024 13:52:18 +0100 Subject: [PATCH 05/14] v1.1.1 --- .../plugin/src/MultichainHardhatRuntimeEnvironmentField.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index 9f9bf21..7523397 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -107,12 +107,12 @@ export class MultichainHardhatRuntimeEnvironmentField { * * @example * ``` - * const contractBytecode = "0x60a060405234801561001057600080fd5b5060405161052b38038061052b83398"; + * const contractBytecode = "0x60a060405234801561001057600080fd5b5060405161052b38038061052b83..."; * const contractAbi = [{ ... }, { ... }]; * * const networkArgs = { * sepolia: { - * args: [ TODO ], + * args: [ 18, "token" ], * }, * goerli: { ... }, * }; From 38dab0897757d2627d3d4191ffdf34d936f38e3f Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Tue, 23 Jan 2024 13:59:41 +0100 Subject: [PATCH 06/14] v1.1.2 --- .../src/MultichainHardhatRuntimeEnvironmentField.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts index 7523397..4c0888c 100644 --- a/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts +++ b/packages/plugin/src/MultichainHardhatRuntimeEnvironmentField.ts @@ -70,7 +70,7 @@ export class MultichainHardhatRuntimeEnvironmentField { * ``` * const networkArgs = { * sepolia: { - * args: [ TODO ], + * args: [ 18, "token" ], * }, * goerli: { ... }, * }; @@ -100,9 +100,9 @@ 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 {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments | NetworkArguments}. - * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions | DeployOptions}. + * @param contractAbi - The ABI 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 {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/NetworkArguments NetworkArguments}. + * @param options - Optional settings for the deployment process. These can include various configurations specific to the deployment. See {@link https://github.com/ChainSafe/hardhat-plugin-multichain-deploy/docs/plugin/DeployOptions DeployOptions}. * @returns A Promise resolving to a Transaction object or void. * * @example From b6806550901788a6ead30a7aebc179ffb5bfd31b Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Tue, 23 Jan 2024 17:02:19 +0100 Subject: [PATCH 07/14] v1.2 --- docs/plugin/DeployOptions.md | 33 ++++++++++++++++++++++++++++++++- docs/plugin/NetworkArguments.md | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/plugin/DeployOptions.md b/docs/plugin/DeployOptions.md index 9b72532..ace893c 100644 --- a/docs/plugin/DeployOptions.md +++ b/docs/plugin/DeployOptions.md @@ -1,5 +1,9 @@ # DeployOptions +DeployOptions provides additional configuration settings for deploying smart contracts across multiple blockchain networks. These options allow for customization of the deployment process, including contract address generation, network-specific deployments, and transaction settings. + +## Interface + ```ts export interface DeployOptions { salt?: MatchPrimitiveType<"bytes32", unknown>; @@ -8,4 +12,31 @@ export interface DeployOptions { } ``` -### TODO +## Usages + +### salt +- **Description**: Provides entropy for generating a unique contract address. This can be a hexadecimal string `HexString` or a `Uint8Array`. +- **Purpose**: Used to create a predictable yet unique address for the smart contract across different deployments. + +### isUniquePerChain +- **Description**: A boolean flag that, when set to true, ensures the contract is deployed with distinct addresses on each blockchain network. + +### customNonPayableTxOptions +- **Details**: Customizes transaction settings for contract calls. This option allows setting sender details and other transaction parameters. +- **Reference**: For detailed information about `NonPayableCallOptions`, please refer to the [web3.js documentation](https://docs.web3js.org/api/web3-types/interface/NonPayableCallOptions/). + +## Example + +In this example, `DeployOptions` is configured to deploy a contract with a specified salt for address generation, ensuring unique addresses on each chain, and customizing the sender address for the deployment transaction. + +```ts +const options: DeployOptions = { + salt: "0x0d832502cc5af3e4cf5c9118b013acea29808616be3bd44f89d231c1c56af61f", + isUniquePerChain: true, + customNonPayableTxOptions: { + from: "0x1605B51d318bFfBFd246D565Ee55522b66ddc34a", + }, +}; +``` + +This setup ensures a predictable and unique deployment process tailored to specific requirements of a multichain environment. \ No newline at end of file diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md index 9f4ea06..4b109a6 100644 --- a/docs/plugin/NetworkArguments.md +++ b/docs/plugin/NetworkArguments.md @@ -7,4 +7,4 @@ interface NetworkArgument { } ``` -### TODO \ No newline at end of file +### TODO From 26904db0e8c731cb940b0fd7b9bbf1e78ae76487 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Tue, 23 Jan 2024 17:43:23 +0100 Subject: [PATCH 08/14] v1.3 --- docs/plugin/DeployOptions.md | 2 +- docs/plugin/NetworkArguments.md | 53 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/plugin/DeployOptions.md b/docs/plugin/DeployOptions.md index ace893c..7d2429f 100644 --- a/docs/plugin/DeployOptions.md +++ b/docs/plugin/DeployOptions.md @@ -5,7 +5,7 @@ DeployOptions provides additional configuration settings for deploying smart con ## Interface ```ts -export interface DeployOptions { +interface DeployOptions { salt?: MatchPrimitiveType<"bytes32", unknown>; isUniquePerChain?: boolean; customNonPayableTxOptions?: NonPayableCallOptions; diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md index 4b109a6..e8b9a7a 100644 --- a/docs/plugin/NetworkArguments.md +++ b/docs/plugin/NetworkArguments.md @@ -1,10 +1,61 @@ # NetworkArguments +NetworkArguments define the configuration for deploying smart contracts across various blockchain networks. This structure allows for specifying different deployment settings for each network, enabling more granular control over the deployment process. + +## Interface + ```ts +interface NetworkArguments { + [network: string]: NetworkArgument; +} + interface NetworkArgument { args: ContractConstructorArgs; initData?: string; } ``` -### TODO +## Usages + +### NetworkArguments +- **Description**: A collection mapping network names from `hardhat.config.ts` to their respective `NetworkArgument`. Only the networks intended for deployment need to be specified. +- **Purpose**: Facilitates the deployment of contracts to selected networks with customized settings. + +### NetworkArgument +- **args** + - **Description**: The arguments passed to the contract's constructor for the specified network. + - **Purpose**: Used to initialize and configure the contract upon deployment for each specific network. +- **initData** + - **Description**: An optional string for additional initialization data (often a hexadecimal string). + - **Purpose**: Enables providing extra setup or configuration data, usually used in conjunction with the contract's initialization method. + +## Example + +### Example `hardhat.config.ts` +```ts +const config: HardhatUserConfig = { + networks: { + sepolia: { ... }, + goerli: { ... } + }, + multichain: { + environment: Environment.TESTNET, + }, +}; +``` + +### Example Usage with Above Config +```ts +const abi = [ ... ] as const; + +const networks: NetworkArguments = { + sepolia: { + args: [18, "zToken"], + }, + goerli: { + args: [18, "zToken"] + }, +}; +``` + +This example demonstrates how to define `NetworkArguments` for deploying a contract with specific constructor arguments on the Sepolia and Goerli test networks. From e408db47f84b74f9bc407bb52593e5ee03ffb31a Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Wed, 24 Jan 2024 10:18:07 +0100 Subject: [PATCH 09/14] v1.4 --- packages/plugin/README.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/plugin/README.md b/packages/plugin/README.md index 89ad591..d404b97 100644 --- a/packages/plugin/README.md +++ b/packages/plugin/README.md @@ -28,11 +28,26 @@ import "@chainsafe/hardhat-plugin-multichain-deploy"; The package introduces a `multichain` namespace to the Hardhat Runtime Environment (HRE). New methods introduced: - * `async waitInitialization(): Promise`: Returns a promise. Wait for this promise to resolve to ensure readiness for using Sygma. - * `async deployMultichain(nameOrBytecode: string, arguments: string[], options?: Object): Promise`: Deploys a smart contract. - * `nameOrBytecode`: Name or bytecode of the smart contract. - * `arguments`: Arguments for the smart contract deployment. - * `options`: Additional deployment options (details TBD). +```ts +async deployMultichain( + contractName: string, + networkArgs: NetworkArguments, + options?: DeployOptions +): Promise + +async deployMultichainBytecode( + contractBytecode: string, + contractAbi: Abi, + networkArgs: NetworkArguments, + options?: DeployOptions +): Promise { +``` + + * `contractName`: The name of the contract to be deployed. + * `contractBytecode`: The bytecode of the contract to be deployed. This is the compiled code of the contract. + * `contractAbi`: The ABI of the contract. It defines the methods and structures used to interact with the binary contract. + * `networkArgs`: An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments.md](../../docs/plugin/NetworkArguments.md) + * `options`: Optional settings for the deployment process. These can include various configurations specific to the deployment. See [DeployOptions.md](../../docs/plugin/DeployOptions.md) ## Configuration @@ -42,9 +57,6 @@ This plugin extends introduce new name space called `multichain` with options: * `environment`: Specifies the Sygma environment for deployment. * Import `Environment` from `@buildwithsygma/sygma-sdk-core` for constant values. * Options: `mainnet`, `testnet`, `devnet`, `local`. - * `deploymentNetworks`: List of networks for deployment. - * Ensure network names match those in `networks`. - * Networks must correspond with Sygma routes. Refer to [Sygma documentation](https://docs.buildwithsygma.com/environments) for routes. Example configuration: @@ -61,7 +73,6 @@ const config: HardhatUserConfig = { }, multichain: { environment: Environment.TESTNET, - deploymentNetworks: ["sepolia", "optimisticGoerli"], }, }; ``` From 9095fccbf22382c2c22fcb6d2d414088b3b34753 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Wed, 24 Jan 2024 10:21:58 +0100 Subject: [PATCH 10/14] v1.4.1 --- docs/plugin/NetworkArguments.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md index e8b9a7a..90130c5 100644 --- a/docs/plugin/NetworkArguments.md +++ b/docs/plugin/NetworkArguments.md @@ -26,6 +26,7 @@ interface NetworkArgument { - **Description**: The arguments passed to the contract's constructor for the specified network. - **Purpose**: Used to initialize and configure the contract upon deployment for each specific network. - **initData** + - **TODO!!** - **Description**: An optional string for additional initialization data (often a hexadecimal string). - **Purpose**: Enables providing extra setup or configuration data, usually used in conjunction with the contract's initialization method. From 624654a57fa857cfd474040990baee53c0b668c4 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Thu, 1 Feb 2024 15:44:55 +0100 Subject: [PATCH 11/14] v1.5.0 --- docs/plugin/NetworkArguments.md | 42 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md index 90130c5..fd82826 100644 --- a/docs/plugin/NetworkArguments.md +++ b/docs/plugin/NetworkArguments.md @@ -1,39 +1,45 @@ # NetworkArguments -NetworkArguments define the configuration for deploying smart contracts across various blockchain networks. This structure allows for specifying different deployment settings for each network, enabling more granular control over the deployment process. +NetworkArguments define the configuration for deploying smart contracts across various blockchain networks. This setup allows for specifying different deployment settings for each network, providing detailed control over the deployment process. ## Interface -```ts +```typescript interface NetworkArguments { [network: string]: NetworkArgument; } interface NetworkArgument { args: ContractConstructorArgs; - initData?: string; + initData?: { + initMethodName: keyof ContractMethods; + initMethodArgs: unknown[]; + }; } ``` ## Usages ### NetworkArguments -- **Description**: A collection mapping network names from `hardhat.config.ts` to their respective `NetworkArgument`. Only the networks intended for deployment need to be specified. -- **Purpose**: Facilitates the deployment of contracts to selected networks with customized settings. +- **Description**: Maps network names from `hardhat.config.ts` to their respective `NetworkArgument`, allowing for network-specific deployment configurations. +- **Purpose**: Facilitates contract deployment across selected networks with customized settings. ### NetworkArgument - **args** - - **Description**: The arguments passed to the contract's constructor for the specified network. - - **Purpose**: Used to initialize and configure the contract upon deployment for each specific network. + - **Description**: Constructor arguments for the contract on each specified network. + - **Purpose**: Used for initializing the contract upon deployment. + - **initData** - - **TODO!!** - - **Description**: An optional string for additional initialization data (often a hexadecimal string). - - **Purpose**: Enables providing extra setup or configuration data, usually used in conjunction with the contract's initialization method. + - **Description**: An optional object that specifies additional initialization to be performed after the contract's deployment. When used, it must include both `initMethodName` and `initMethodArgs`. + - **initMethodName** + - **Description**: Specifies the contract method to call for further initialization. + - **initMethodArgs** + - **Description**: An array of values that correspond to the parameters required by the method named in `initMethodName`. These arguments are passed directly to the initialization method call. ## Example ### Example `hardhat.config.ts` -```ts +```typescript const config: HardhatUserConfig = { networks: { sepolia: { ... }, @@ -46,17 +52,25 @@ const config: HardhatUserConfig = { ``` ### Example Usage with Above Config -```ts +```typescript const abi = [ ... ] as const; const networks: NetworkArguments = { sepolia: { args: [18, "zToken"], + initData: { + initMethodName: "setName", + initMethodArgs: ["SuperToken"], + } }, goerli: { - args: [18, "zToken"] + args: [18, "zToken"], + initData: { + initMethodName: "setName", + initMethodArgs: ["GummyToken"], + } }, }; ``` -This example demonstrates how to define `NetworkArguments` for deploying a contract with specific constructor arguments on the Sepolia and Goerli test networks. +This example shows how `NetworkArguments` can be used to deploy a contract with specific constructor arguments on the Sepolia and Goerli test networks. It includes optional post-deployment initialization to set unique token names for each network through the `setName` method. From cd7800596fe2553db2d7ee5155c1d9289abc6723 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Fri, 2 Feb 2024 15:02:06 +0100 Subject: [PATCH 12/14] v1.6.0 --- packages/plugin/README.md | 41 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/plugin/README.md b/packages/plugin/README.md index d404b97..b4aa4a4 100644 --- a/packages/plugin/README.md +++ b/packages/plugin/README.md @@ -4,11 +4,10 @@ Experience the seamless integration of Hardhat with Sygma: the ultimate plugin f Embrace the power of Sygma protocol, and transform your deployment process into a streamlined, efficient, and multi-chain adventure. With this tool, you're not just deploying contracts; you're unlocking new horizons in the blockchain ecosystem. - ## Installation ```bash -npm install --save-dev @chainsafe/hardhat-plugin-multichain-deploy +npm install --save-dev @chainsafe/hardhat-plugin-multichain-deploy @buildwithsygma/sygma-sdk-core ``` Import the plugin in your `hardhat.config.js``: @@ -33,14 +32,20 @@ async deployMultichain( contractName: string, networkArgs: NetworkArguments, options?: DeployOptions -): Promise +): Promise<{ + deploymentInfo: DeploymentInfo[]; + receipt: Transaction; +} | void> async deployMultichainBytecode( contractBytecode: string, contractAbi: Abi, networkArgs: NetworkArguments, options?: DeployOptions -): Promise { +): Promise<{ + deploymentInfo: DeploymentInfo[]; + receipt: Transaction; +} | void> ``` * `contractName`: The name of the contract to be deployed. @@ -49,9 +54,13 @@ async deployMultichainBytecode( * `networkArgs`: An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments.md](../../docs/plugin/NetworkArguments.md) * `options`: Optional settings for the deployment process. These can include various configurations specific to the deployment. See [DeployOptions.md](../../docs/plugin/DeployOptions.md) +## Environment variable + + - `ADAPTER_ADDRESS` - address of adapter (adapter is used to propagate all deployment on other chains with help of sygma). It can be used in case if you deploy own adapters + ## Configuration -The Hardhat Plugin Multichain Deployment plugin requires specific configurations for successful multi-chain deployment. +The Hardhat Plugin Multichain Deployment plugin requires specific configurations for successful multichain deployment. This plugin extends introduce new name space called `multichain` with options: * `environment`: Specifies the Sygma environment for deployment. @@ -79,18 +88,24 @@ const config: HardhatUserConfig = { ## Usages -### TODO +With the setup complete, let’s deploy an ERC20 contract across multiple chains: -After familiarizing yourself with the capabilities, let's see how everything works together. - -Example scenario: You've created an ERC20 contract and want to deploy it across multiple chains using the configuration mentioned above. ```typescript -// Deploy the contract -const tx = await hre.multichain.deployMultichain('MySuperToken', [name, symbol, decimals], { singer: web3signer }); +const networkArgs = { + sepolia: { + args: [name, symbol, decimals], + }, + goerli: { + args: [name, symbol, decimals], + }, +}; +const options = { + salt: "0xcafe00000000000000000000000000000000000000000000000000000000cafe", +}; -console.log("Transaction Hash: ", tx); +this.hre.multichain.deployMultichain("MySuperToken", networkArgs, options); ``` ## Contribution -For contributing to the project, please refer to the [root readme](../../README.md) file. +For contributing to the project, please refer to the [monorepo readme](../../README.md) file. From 8e5ac04b201e751305df33a49ec34394cceae081 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Fri, 2 Feb 2024 15:08:21 +0100 Subject: [PATCH 13/14] v1.6.1 --- packages/plugin/README.md | 63 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/packages/plugin/README.md b/packages/plugin/README.md index b4aa4a4..b3d09fc 100644 --- a/packages/plugin/README.md +++ b/packages/plugin/README.md @@ -1,79 +1,78 @@ -# Chainsafe's Hardhat Plugin for Multichain deployment with Sygma +# ChainSafe's Hardhat Plugin for Multichain Deployment with Sygma -Experience the seamless integration of Hardhat with Sygma: the ultimate plugin for effortlessly deploying your Ethereum smart contracts across multiple chains. -Embrace the power of Sygma protocol, and transform your deployment process into a streamlined, efficient, and multi-chain adventure. -With this tool, you're not just deploying contracts; you're unlocking new horizons in the blockchain ecosystem. +Unlock the full potential of Hardhat with Sygma: the premier plugin for effortlessly deploying your Ethereum smart contracts across multiple blockchain networks. Leveraging the Sygma protocol, this tool revolutionizes your deployment process, making it efficient, streamlined, and truly multi-chain. With ChainSafe's plugin, you're not just deploying contracts—you're exploring new possibilities within the blockchain ecosystem. ## Installation +To install, run: + ```bash npm install --save-dev @chainsafe/hardhat-plugin-multichain-deploy @buildwithsygma/sygma-sdk-core ``` -Import the plugin in your `hardhat.config.js``: +### Importing the Plugin + +For JavaScript users, add this line to your `hardhat.config.js`: ```js require("@chainsafe/hardhat-plugin-multichain-deploy"); ``` -Or if you are using TypeScript, in your `hardhat.config.ts``: +For TypeScript users, include it in your `hardhat.config.ts`: ```js import "@chainsafe/hardhat-plugin-multichain-deploy"; ``` -## Environment extensions +## Environment Extensions -The package introduces a `multichain` namespace to the Hardhat Runtime Environment (HRE). +The plugin adds a `multichain` namespace to the Hardhat Runtime Environment (HRE), introducing new methods for deployment: -New methods introduced: ```ts async deployMultichain( - contractName: string, - networkArgs: NetworkArguments, - options?: DeployOptions + contractName: string, + networkArgs: NetworkArguments, + options?: DeployOptions ): Promise<{ deploymentInfo: DeploymentInfo[]; receipt: Transaction; } | void> async deployMultichainBytecode( - contractBytecode: string, - contractAbi: Abi, - networkArgs: NetworkArguments, - options?: DeployOptions + contractBytecode: string, + contractAbi: Abi, + networkArgs: NetworkArguments, + options?: DeployOptions ): Promise<{ deploymentInfo: DeploymentInfo[]; receipt: Transaction; } | void> ``` - * `contractName`: The name of the contract to be deployed. - * `contractBytecode`: The bytecode of the contract to be deployed. This is the compiled code of the contract. - * `contractAbi`: The ABI of the contract. It defines the methods and structures used to interact with the binary contract. - * `networkArgs`: An object mapping network identifiers to their deployment arguments. Each network can have unique settings for the deployment. See [NetworkArguments.md](../../docs/plugin/NetworkArguments.md) - * `options`: Optional settings for the deployment process. These can include various configurations specific to the deployment. See [DeployOptions.md](../../docs/plugin/DeployOptions.md) +- `contractName`: Name of the contract for deployment. +- `contractBytecode`: Compiled bytecode of the contract. +- `contractAbi`: Contract ABI, detailing methods and structures for interaction. +- `networkArgs`: Maps network identifiers to deployment arguments. Refer to [NetworkArguments.md](../../docs/plugin/NetworkArguments.md) for more. +- `options`: Optional deployment settings. Details in [DeployOptions.md](../../docs/plugin/DeployOptions.md). -## Environment variable +## Environment Variable - - `ADAPTER_ADDRESS` - address of adapter (adapter is used to propagate all deployment on other chains with help of sygma). It can be used in case if you deploy own adapters +- `ADAPTER_ADDRESS`: Address of the adapter, facilitating deployment across chains with Sygma. Use this if deploying custom adapters. ## Configuration -The Hardhat Plugin Multichain Deployment plugin requires specific configurations for successful multichain deployment. +To utilize the Multichain Deployment plugin, specific settings are required: -This plugin extends introduce new name space called `multichain` with options: - * `environment`: Specifies the Sygma environment for deployment. - * Import `Environment` from `@buildwithsygma/sygma-sdk-core` for constant values. - * Options: `mainnet`, `testnet`, `devnet`, `local`. +- `multichain` namespace: Configures deployment settings. + - `environment`: Defines the Sygma environment. Use `Environment` from `@buildwithsygma/sygma-sdk-core` for constants. -Example configuration: +### Example Configuration ```typescript import { Environment } from "@buildwithsygma/sygma-sdk-core"; const config: HardhatUserConfig = { - // ... other configurations ... + // Other configurations... defaultNetwork: "goerli", networks: { sepolia: { ... }, @@ -86,7 +85,7 @@ const config: HardhatUserConfig = { }; ``` -## Usages +## Usage With the setup complete, let’s deploy an ERC20 contract across multiple chains: @@ -108,4 +107,4 @@ this.hre.multichain.deployMultichain("MySuperToken", networkArgs, options); ## Contribution -For contributing to the project, please refer to the [monorepo readme](../../README.md) file. +To contribute to this project, please see the [monorepo readme](../../README.md) for guidelines. From ff39d1df27468487beba3df65c0d01378e31e6e7 Mon Sep 17 00:00:00 2001 From: BeroBurny Date: Mon, 5 Feb 2024 11:28:14 +0100 Subject: [PATCH 14/14] v1.6.2 --- docs/plugin/NetworkArguments.md | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/docs/plugin/NetworkArguments.md b/docs/plugin/NetworkArguments.md index fd82826..2db2bc5 100644 --- a/docs/plugin/NetworkArguments.md +++ b/docs/plugin/NetworkArguments.md @@ -21,8 +21,8 @@ interface NetworkArgument { ## Usages ### NetworkArguments -- **Description**: Maps network names from `hardhat.config.ts` to their respective `NetworkArgument`, allowing for network-specific deployment configurations. -- **Purpose**: Facilitates contract deployment across selected networks with customized settings. + - **Description**: An object where each key is a network name registered on Sygma, mapped to their respective `NetworkArgument`. This structure facilitates network-specific deployment configurations, allowing for deployment across networks recognized by the Sygma protocol. + - **Purpose**: Enables the deployment of contracts to specified networks, leveraging the configurations tailored for each network as recognized by Sygma. ### NetworkArgument - **args** @@ -38,20 +38,6 @@ interface NetworkArgument { ## Example -### Example `hardhat.config.ts` -```typescript -const config: HardhatUserConfig = { - networks: { - sepolia: { ... }, - goerli: { ... } - }, - multichain: { - environment: Environment.TESTNET, - }, -}; -``` - -### Example Usage with Above Config ```typescript const abi = [ ... ] as const;