Skip to content

Commit

Permalink
fix: deploy once abi creation (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
killroy192 authored Mar 1, 2024
1 parent 461909a commit f0323ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dgma/hardhat-sol-bundler",
"version": "0.5.3",
"version": "0.5.4",
"description": "Declarative deployment tool for smart contracts",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down
18 changes: 12 additions & 6 deletions src/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
type IGlobalState,
type IDeployingContractState,
type ProxyUnsafeAllow,
type ProxyType,
} from "./types";
import {
getDeployment,
Expand Down Expand Up @@ -61,7 +60,7 @@ async function deployOrUpdateClassic(
}));
}

async function simpleDeploy(contractState: ContractState, proxy?: ProxyType) {
async function simpleDeploy(contractState: ContractState) {
const contract = await contractState
.value()
?.factory?.deploy(...contractState.value().constructorArguments)!;
Expand All @@ -71,20 +70,27 @@ async function simpleDeploy(contractState: ContractState, proxy?: ProxyType) {
contractState.update((prevState) => ({
...prevState,
contract,
proxy,
}));
}

async function deployOnce(
_: HardhatRuntimeEnvironment,
hre: HardhatRuntimeEnvironment,
state: GlobalState,
contractState: ContractState,
proxy = SupportedProxies.CUSTOM,
) {
const contractLockData = state.value().ctx[contractState.value().key];
const isFirstTimeDeploy = !contractLockData?.factoryByteCode;
if (isFirstTimeDeploy) {
await simpleDeploy(contractState, proxy);
await simpleDeploy(contractState);
} else {
const contract = await hre.ethers.getContractAt(
contractLockData.abi as any[],
contractLockData.address!,
);
contractState.update((prevState) => ({
...prevState,
contract,
}));
}
}

Expand Down

0 comments on commit f0323ea

Please sign in to comment.