Skip to content

Commit

Permalink
chore: [#1] Added UpgradeableProxy since hardhat-etherscan couldn't f…
Browse files Browse the repository at this point in the history
…ind the OZ one
  • Loading branch information
mdnorman committed May 7, 2022
1 parent ce98d1a commit 5313b72
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,32 @@ npm run build
Set up a `.secrets.json` file that looks similar to `example.secrets.json`:
After deploying your contract, you can verify it by running the following:
After deploying your contract, you can verify it by running the following.
### Rinkeby
```
npx hardhat verify --network rinkeby CONTRACT_ADDRESS
```
For a proxy contract, you'll need to pass the arguments to the proxy contract, and pass the contract as well:
```
npx hardhat verify --network rinkeby \
--contract contracts/common/UpgradeableProxy.sol:UpgradeableProxy \
--constructor-args examples/parcelNFTConstructorParams.js \
CONTRACT_ADDRESS
```
### Mainnet
```
npx hardhat verify --network rinkeby CONTRACT_ADDRESS
```
```
npx hardhat verify --network mainnet \
--contract contracts/common/UpgradeableProxy.sol:UpgradeableProxy \
--constructor-args examples/parcelNFTConstructorParams.js \
CONTRACT_ADDRESS
```
See [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) for more examples
11 changes: 11 additions & 0 deletions contracts/common/UpgradeableProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.9;

import '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol';

// needed to be able to use the proxy for verification
contract UpgradeableProxy is ERC1967Proxy {
// solhint-disable-next-line no-empty-blocks
constructor(address _logic, bytes memory _data) payable ERC1967Proxy(_logic, _data) {}
}
8 changes: 8 additions & 0 deletions examples/parcelNFTConstructorParams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { buildParcelNFTInitFunction } = require('../dist/src/contracts/parcelNFT');
module.exports = [
'0xc0cA359c8ce6De21B98fC6c7921a08703f453Fe9',
buildParcelNFTInitFunction({
name: 'ParcelNFT Test 2022-05-07-02',
symbol: 'PT050702',
}),
];
6 changes: 3 additions & 3 deletions src/contracts/upgradeableProxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TransactionRequest } from '@ethersproject/providers';
import { Signer } from 'ethers';
import { BytesLike } from 'ethers/lib/utils';
import { ERC1967Proxy__factory } from '../../types/contracts';
import { UpgradeableProxy__factory } from '../../types/contracts';
import { ContractAddress } from '../constants/accounts';

/**
Expand All @@ -16,7 +16,7 @@ export const deployUpgradeableProxy = async (
signer: Signer,
logicAddress: ContractAddress,
initFunction: BytesLike = '0x',
) => new ERC1967Proxy__factory(signer).deploy(logicAddress, initFunction);
) => new UpgradeableProxy__factory(signer).deploy(logicAddress, initFunction);

/**
* Build a transaction to deploy an upgradeable proxy contract with the given contract address
Expand All @@ -28,4 +28,4 @@ export const deployUpgradeableProxy = async (
export const buildDeployUpgradeableProxyTransactionRequest = (
logicAddress: ContractAddress,
initFunction: BytesLike = '0x',
): TransactionRequest => new ERC1967Proxy__factory().getDeployTransaction(logicAddress, initFunction);
): TransactionRequest => new UpgradeableProxy__factory().getDeployTransaction(logicAddress, initFunction);

0 comments on commit 5313b72

Please sign in to comment.