Skip to content

Commit

Permalink
Merge pull request #16 from axieinfinity/feature/fix-deployment-script
Browse files Browse the repository at this point in the history
fix: hardhat deployment scripts
  • Loading branch information
huyhuynh3103 authored Jun 5, 2024
2 parents 32aaea6 + b0bc7e5 commit c2516f8
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const mainnet: NetworkUserConfig = {

const config: HardhatUserConfig = {
solidity: {
version: '0.8.17',
version: '0.8.19',
settings: {
optimizer: {
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
await deploy('SampleERC721CommonUpgradeableLogic', {
contract: 'ERC721CommonUpgradeable',
await deploy('SampleERC721UpgradeableLogic', {
contract: 'SampleERC721Upgradeable',
from: deployer,
log: true,
});
};

deploy.tags = ['SampleERC721CommonUpgradeableLogic'];
deploy.tags = ['SampleERC721UpgradeableLogic'];
deploy.dependencies = ['VerifyContracts'];

export default deploy;
4 changes: 3 additions & 1 deletion scripts/deploy/proxy-admin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import ProxyAdmin from 'hardhat-deploy/extendedArtifacts/ProxyAdmin.json';

const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
await deploy('ProxyAdmin', {
contract: 'ProxyAdmin',
contract: ProxyAdmin,
from: deployer,
log: true,
args: [deployer],
});
};

Expand Down
15 changes: 8 additions & 7 deletions scripts/deploy/proxy/erc721-upgradeable-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { ERC721CommonUpgradeable__factory } from '../../typechain-types';
import { SampleERC721Upgradeable__factory } from '../../typechain-types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import TransparentUpgradeableProxy from 'hardhat-deploy/extendedArtifacts/TransparentUpgradeableProxy.json';

const erc721Interface = ERC721CommonUpgradeable__factory.createInterface();
const erc721Interface = SampleERC721Upgradeable__factory.createInterface();

const deploy = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const proxyAdmin = await deployments.get('ProxyAdmin');
const logicContract = await deployments.get('SampleERC721CommonUpgradeableLogic');
const logicContract = await deployments.get('SampleERC721UpgradeableLogic');

const data = erc721Interface.encodeFunctionData('initialize', ['SampleERC721', 'NFT', 'http://example.com/']);

await deploy('SampleERC721CommonUpgradeableProxy', {
contract: 'TransparentUpgradeableProxy',
contract: TransparentUpgradeableProxy,
from: deployer,
log: true,
args: [logicContract.address, proxyAdmin, data],
args: [logicContract.address, proxyAdmin.address, data],
});
};

deploy.tags = ['SampleERC721CommonUpgradeableProxy'];
deploy.dependencies = ['VerifyContracts', 'ProxyAdmin', 'SampleERC721CommonUpgradeableLogic'];
deploy.tags = ['SampleERC721UpgradeableProxy'];
deploy.dependencies = ['VerifyContracts', 'ProxyAdmin', 'SampleERC721UpgradeableLogic'];

export default deploy;
2 changes: 1 addition & 1 deletion src/interfaces/launchpad/INFTLaunchpad.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

/// @dev Interface for the NFT contract that compatible with the NFT launchpad.
/// MUST be included ERC165 interface to support the detection of the contract's capabilities.
Expand Down
2 changes: 1 addition & 1 deletion src/mock/launchpad/SampleNFT1155Launchpad.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

import { ERC1155 } from "../../../lib/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import { AccessControl } from "../../../lib/openzeppelin-contracts/contracts/access/AccessControl.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/mock/launchpad/SampleNFT721Launchpad.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

import { SampleERC721 } from "../SampleERC721.sol";
import { ERC165 } from "../../../lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/upgradeable/ERC721CommonUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

import { ERC721Upgradeable } from
"../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

import { ERC721Upgradeable } from
"../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/upgradeable/refs/ERC721NonceUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
pragma solidity ^0.8.19;

import { ERC721Upgradeable } from
"../../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol";
Expand Down
5 changes: 3 additions & 2 deletions test/foundry/SampleERC721Upgradeable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ERC721NonceUpgradeable } from "src/upgradeable/refs/ERC721NonceUpgradea
import { Strings } from "../../lib/openzeppelin-contracts/contracts/utils/Strings.sol";
import { TransparentUpgradeableProxy } from
"../../lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import { ProxyAdmin } from "../../lib/openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol";
import { IERC721Upgradeable } from "lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC721Upgradeable.sol";
import { IAccessControlEnumerableUpgradeable } from
"lib/openzeppelin-contracts-upgradeable/contracts/access/IAccessControlEnumerableUpgradeable.sol";
Expand All @@ -29,12 +30,12 @@ contract SampleERC721Upgradeable_Test is Test {
string public constant SYMBOL = "NFT";
string public constant BASE_URI = "http://example.com/";

address _proxyAdmin;
address internal _proxyAdmin;
// token test
ERC721CommonUpgradeable internal _testToken;

function setUp() public virtual {
_proxyAdmin = makeAddr("proxy-admin");
_proxyAdmin = address(new ProxyAdmin());

bytes memory initializeData =
abi.encodeCall(ERC721PresetMinterPauserAutoIdCustomizedUpgradeable.initialize, (NAME, SYMBOL, BASE_URI));
Expand Down

0 comments on commit c2516f8

Please sign in to comment.