Wrap Initia cli to support custom configuration just like Hardhat
Install
yarn add @layerzerolabs/lz-initia-cli
Config
Create a initia.config.ts
file in the root of your project. A full example is below:
import { LzInitiaConfig } from "@layerzerolabs/lz-initia-cli";
import {
Chain,
chainAndStageToNetwork,
Environment,
Stage,
} from "@layerzerolabs/lz-definitions";
import path from "path";
import { Account } from "@initia-labs/ts-sdk";
const INITIA_SANDBOX_LOCAL = chainAndStageToNetwork(
Chain.INITIA,
Stage.SANDBOX,
Environment.LOCAL,
);
const INITIA_TESTNET = chainAndStageToNetwork(
Chain.INITIA,
Stage.TESTNET,
Environment.TESTNET,
);
const INITIA_MAINNET = chainAndStageToNetwork(
Chain.INITIA,
Stage.MAINNET,
Environment.MAINNET,
);
const contractWorkspace = "./contracts";
const config: LzInitiaConfig = {
artifactsPath: "./artifacts",
deploymentPath: "./deployments",
compatibleVersions: ["v1"],
network: {
[Environment.LOCAL]: "http://127.0.0.1:8080",
},
defaultDeployer: {
[INITIA_SANDBOX_LOCAL]: Account.fromPrivateKey({
privateKey: process.env.LOCAL_DEPLOYER,
}),
[INITIA_TESTNET]: Account.fromPrivateKey({
privateKey: process.env.TESTNET_DEPLOYER,
}),
[INITIA_MAINNET]: Account.fromPrivateKey({
privateKey: process.env.MAINNET_DEPLOYER,
}),
},
gasPrice: {
[INITIA_SANDBOX_LOCAL]: 1000,
[INITIA_TESTNET]: 1000,
[INITIA_MAINNET]: 1000,
},
baseModules: ["PATH_TO_ANOTHER_LZ_INITIA_CONFIG_FILE"],
modules: {
layerzero_common: {
modulePath: path.join(contractWorkspace, "layerzero-common"),
deployer: {
"initia-sandbox-local": Account.fromPrivateKey({
privateKey: process.env.LAYERZERO_DEPLOYER,
}),
},
},
executor_v2: {
alias: "ExecutorV2",
modulePath: path.join(contractWorkspace, "executor/executor-v2"),
deployer: Account.fromPrivateKey({
privateKey: process.env.EXECUTOR_DEPLOYER,
}),
},
executor_auth: {
modulePath: path.join(contractWorkspace, "executor/executor-auth"),
variant: process.env.SUFFIX_EXECUTOR,
},
},
};
export default config;
Details of the configuration:
artifactsPath
: Path to store the artifacts(*.mv and package-metadata.bcs) generated by the compiler.deploymentPath
: Path to store the deployment files(*.json) recording the deployment information.compatibleVersions
: The compatible endpoint version. If not set, the default value is ['v1', 'v2']network
: The RPC for each environment.compileOptions
: The OPTIONS
for the initiad move build
. If not set, the default value is --skip-fetch-latest-git-deps=true
.defaultDeployer
: The default deployer. Deployer account address is also the address of the contract.gasPrice
: The gas price for each environment. If not set, the default value is 2 times the current gas price.baseModules
: The path to another lz-initia config file. The command tool will search the base modules recursively if module name not found in modules
. If not set, the default value is [].modules
: The module configuration. The key is the module name used in lz-initia-cli command. The key should be the same with package name in Move.toml.
alias
: Artifact/Deployment name for the module. If not set, the module name will be used.modulePath
: The path to the module's contract directory which contains Move.toml.deployer
: The deployer for the module. If not set, the default deployer will be used.variant
: The variant for the module. If not set, it means the module has no variant. It will be overridden by the variant in the command line.
Usage
cd path/to/your/project
yarn lz-initia-cli build -m layerzero_common -n initia-sandbox-local
yarn lz-initia-cli build -m dvn -n initia-sandbox-local --variant nethermind
yarn lz-initia-cli build -m layerzero_common -n initia-sandbox-local -p path/to/layerzero-common
yarn lz-initia-cli deploy -m layerzero_common -n initia-sandbox-local
yarn lz-initia-cli deploy -m layerzero_common -n initia-sandbox-local --variant nethermind