@layerzerolabs/export-deployments
v0.0.14
Published
Export hardhat deploy deployments file into typescript
Downloads
2,639
Readme
Installation
yarn add @layerzerolabs/export-deployments
pnpm add @layerzerolabs/export-deployments
npm install @layerzerolabs/export-deployments
Usage
CLI
This package comes with a CLI interface and registers an executable called @layerzerolabs/export-deployments
:
# When installed locally
@layerzerolabs/export-deployments --help
# Or using npx, preferred
npx @layerzerolabs/export-deployments
Programmatic usage
// generateSafe is an error-safe function that returns an Either<Error, OutputFile[]> object
import { generateSafe } from "@layerzerolabs/export-deployments";
// if throwing an error is desired, generate is a better option
import { generate } from "@layerzerolabs/export-deployments";
generateSafe({
deploymentsDir: "./my/deployments",
outDir: "./generated",
});
If filtering of networks is necessary, createIncludeDirent
utility can be used to construct a quick filtering function:
import {
createIncludeDirent,
generateSafe,
} from "@layerzerolabs/export-deployments";
const includedNetworks = ["arbitrum-mainnet"];
const excludedNetworks = ["telos-testnet"];
generateSafe({
deploymentsDir: "./my/deployments",
outDir: "./generated",
includeNetworkDir: createIncludeDirent(includedNetworks, excludedNetworks),
});
Similar goes for deployment files:
import {
createIncludeDirent,
generateSafe,
} from "@layerzerolabs/export-deployments";
// createIncludeDirent will handle the json extension internally
const includedContracts = ["MyContract", "OtherContract.json"];
const excludedContracts = ["TopSecret"];
generateSafe({
deploymentsDir: "./my/deployments",
outDir: "./generated",
includeDeploymentFile: createIncludeDirent(
includedContracts,
excludedContracts,
),
});