Skip to content

Commit

Permalink
add custom proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
killroy192 committed Mar 1, 2024
1 parent c063434 commit b05f7f2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const config: HardhatUserConfig = {
export default config;
```

`contractName` property is optional and only needed if configuration includes multiple instances of one contract
`contractName` property is optional and only needed if configuration contract key is not the same as contract name

**note**: dependant contract must be located above

Expand All @@ -73,9 +73,7 @@ npx hardhat deploy-bundle --no-compile true

## Configuration

By default, hardhat-sol-bundler supports only deployment runtime accessability.

- To deploy only modified contracts, add `lockFile` property to deployment
- To deploy only modified contracts, add `lockFile` property to deployment:

```ts
const deployment = {
Expand All @@ -86,7 +84,24 @@ const deployment = {
};
```

- To verify deployed contracts during runtime.
- To deploy contract as a proxy:

```ts
import { SupportedProxies } from "@dgma/hardhat-sol-bundler";

const deployment = {
lockFile: "deployment-lock.json",
config: {
TestContract: {
proxy: {
type: SupportedProxies.CUSTOM
}
}
},
};
```

- To verify deployed contracts during runtime:

```ts
// no need @nomicfoundation/hardhat-verify if you use @nomicfoundation/hardhat-toolbox
Expand Down
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.0",
"version": "0.5.1",
"description": "Declarative deployment tool for smart contracts",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/deploy/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SupportedProxies = {
TRANSPARENT: "transparent",
UUPS: "uups",
CUSTOM: "custom",
} as const;
7 changes: 4 additions & 3 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 All @@ -18,13 +17,16 @@ import {

type ContractState = stateFabric.IState<IDeployingContractState>;
type GlobalState = stateFabric.IState<IGlobalState>;
type ClassicProxyTypes =
| typeof SupportedProxies.TRANSPARENT
| typeof SupportedProxies.UUPS;

async function deployOrUpdateClassic(
hre: HardhatRuntimeEnvironment,
state: GlobalState,
contractState: ContractState,
unsafeAllow: ProxyUnsafeAllow[],
kind: ProxyType = SupportedProxies.TRANSPARENT,
kind: ClassicProxyTypes = SupportedProxies.TRANSPARENT,
) {
const contractLockData = state.value().ctx[contractState.value().key];
const factory = contractState.value().factory!;
Expand Down Expand Up @@ -54,7 +56,6 @@ async function deployOrUpdateClassic(
contractState.update((prevState) => ({
...prevState,
contract,
proxy: SupportedProxies.TRANSPARENT,
}));
}

Expand Down

0 comments on commit b05f7f2

Please sign in to comment.