Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update to open-zeppelin v5, pass owner into constructor argument #9

Merged
merged 9 commits into from
Nov 13, 2023
4 changes: 2 additions & 2 deletions contracts/AddressToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
\__| \__| \_______| \_______|\__| \_______|\_______/ \_______/ \__| \__|\__| \__|
*/

pragma solidity 0.8.20;
pragma solidity 0.8.22;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IERC4906 } from "@openzeppelin/contracts/interfaces/IERC4906.sol";
Expand All @@ -74,7 +74,7 @@ contract AddressToken is ERC721("1inch Address NFT", "1ANFT"), Ownable, IERC4906
mapping(address /* tokenId */ => bytes32 /* salt */) public salts;
IAddressTokenMetadata public metadataContract;

constructor(IAddressTokenMetadata _metadataContract) {
constructor(IAddressTokenMetadata _metadataContract, address owner) Ownable(owner) {
metadataContract = _metadataContract;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/AddressTokenMetadata.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;
pragma solidity 0.8.22;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { IAddressTokenMetadata } from "./interfaces/IAddressTokenMetadata.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IAddressTokenMetadata.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;
pragma solidity 0.8.22;

interface IAddressTokenMetadata {
function tokenJSON(uint256 tokenId) external pure returns(string memory);
Expand Down
39 changes: 0 additions & 39 deletions deploy/deploy.js

This file was deleted.

8 changes: 7 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ require('solidity-coverage');

const { networks, etherscan } = require('./hardhat.networks');

function getNetwork () {
const index = process.argv.findIndex((arg) => arg === '--network') + 1;
return index !== 0 ? process.argv[index] : undefined;
}

module.exports = {
etherscan,
networks,
solidity: {
compilers: [
{
version: '0.8.20',
version: '0.8.22',
settings: {
optimizer: {
enabled: true,
runs: 1000000,
},
evmVersion: networks[getNetwork()]?.hardfork || 'shanghai',
viaIR: true,
},
},
Expand Down
9 changes: 5 additions & 4 deletions hardhat.networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const networks = {
};
const etherscan = { apiKey: {}, customChains: [] };

function register (name, chainId, url, privateKey, etherscanNetworkName, etherscanKey) {
function register (name, chainId, url, privateKey, etherscanNetworkName, etherscanKey, hardfork = 'paris') {
if (url && privateKey && etherscanKey) {
networks[name] = {
url,
Expand All @@ -20,6 +20,7 @@ function register (name, chainId, url, privateKey, etherscanNetworkName, ethersc
},
chainId,
accounts: [privateKey],
hardfork,
};
etherscan.apiKey[etherscanNetworkName] = etherscanKey;
console.log(`Network '${name}' registered`);
Expand All @@ -28,14 +29,14 @@ function register (name, chainId, url, privateKey, etherscanNetworkName, ethersc
}
}

function registerCustom (name, chainId, url, privateKey, etherscanKey, apiURL, browserURL) {
function registerCustom (name, chainId, url, privateKey, etherscanKey, apiURL, browserURL, hardfork = 'paris') {
if (url && privateKey && etherscanKey) {
register(name, chainId, url, privateKey, name, etherscanKey);
register(name, chainId, hardfork, url, privateKey, name, etherscanKey);
etherscan.customChains.push({ network: name, chainId, urls: { apiURL, browserURL } });
}
}

register('mainnet', 1, process.env.MAINNET_RPC_URL, process.env.MAINNET_PRIVATE_KEY, 'mainnet', process.env.MAINNET_ETHERSCAN_KEY);
register('mainnet', 1, process.env.MAINNET_RPC_URL, process.env.MAINNET_PRIVATE_KEY, 'mainnet', process.env.MAINNET_ETHERSCAN_KEY, 'shanghai');
register('bsc', 56, process.env.BSC_RPC_URL, process.env.BSC_PRIVATE_KEY, 'bsc', process.env.BSC_ETHERSCAN_KEY);
register('kovan', 42, process.env.KOVAN_RPC_URL, process.env.KOVAN_PRIVATE_KEY, 'kovan', process.env.KOVAN_ETHERSCAN_KEY);
register('optimistic', 10, process.env.OPTIMISTIC_RPC_URL, process.env.OPTIMISTIC_PRIVATE_KEY, 'optimisticEthereum', process.env.OPTIMISTIC_ETHERSCAN_KEY);
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
},
"license": "MIT",
"dependencies": {
"@1inch/solidity-utils": "2.2.27",
"@openzeppelin/contracts": "4.9.0",
"@openzeppelin/contracts": "5.0.0",
"solmate": "6.7.0"
},
"devDependencies": {
Expand All @@ -25,15 +24,15 @@
"eslint-plugin-n": "16.0.0",
"eslint-plugin-promise": "6.1.1",
"ethers": "5.7.2",
"hardhat": "2.14.1",
"hardhat": "2.19.0",
"hardhat-dependency-compiler": "1.1.3",
"hardhat-deploy": "0.11.30",
"hardhat-deploy": "0.11.43",
"hardhat-gas-reporter": "1.0.9",
"hardhat-tracer": "2.3.5",
"hardhat-tracer": "2.7.0",
"rimraf": "5.0.1",
"solc": "0.8.20",
"solhint": "3.4.1",
"solidity-coverage": "0.8.2",
"solc": "0.8.22",
"solhint": "4.0.0",
"solidity-coverage": "0.8.5",
"solidity-docgen": "0.5.17"
},
"scripts": {
Expand All @@ -48,6 +47,7 @@
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"lint:sol:fix": "solhint --max-warnings 0 \"contracts/**/*.sol\" --fix",
"test": "hardhat test --parallel",
"test:ci": "hardhat test"
"test:ci": "hardhat test",
"test:trace": "hardhat test --trace"
}
}
6 changes: 4 additions & 2 deletions test/AddressToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ const { expect } = require('chai');

describe('AddressToken', async function () {
async function initContracts () {
const [signer] = await ethers.getSigners();

const AddressToken = await ethers.getContractFactory('AddressToken');
const addressToken = await AddressToken.deploy(ethers.constants.AddressZero);
const addressToken = await AddressToken.deploy(ethers.constants.AddressZero, signer.address);
await addressToken.deployed();
const AddressTokenMetadata = await ethers.getContractFactory('AddressTokenMetadata');
const addressTokenMetadata = await AddressTokenMetadata.deploy();
await addressTokenMetadata.deployed();
// this is done in this particular order to keep AddressToken at 0x5FbDB2315678afecb367f032d93F642f64180aa3
await addressToken.upgradeMetadataContract(addressTokenMetadata.address);
const [signer] = await ethers.getSigners();

expect(signer.address).to.be.equal('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266');
expect(addressToken.address).to.be.equal('0x5FbDB2315678afecb367f032d93F642f64180aa3');
return { signer, addressToken };
Expand Down
Loading
Loading