Skip to content

Commit

Permalink
Deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
LorranSutter committed Jul 26, 2022
1 parent 48f4121 commit ea6729e
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 890 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
coverage
coverage.json
typechain
.openzeppelin

#Hardhat files
cache
Expand Down
78 changes: 78 additions & 0 deletions contracts/ChildToken/Dimo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

contract Dimo is
ERC20Upgradeable,
AccessControlUpgradeable,
PausableUpgradeable,
UUPSUpgradeable
{
bytes32 public constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

function initialize() public initializer {
__ERC20_init("Dimo", "DIMO");
__AccessControl_init();
__Pausable_init();
__UUPSUpgradeable_init();

_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
}

function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}

function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}


/// @notice called when token is deposited on root chain
/// @dev Should be callable only by ChildChainManager
/// Should handle deposit by minting the required amount for user
/// @param user user address for whom deposit is being done
/// @param depositData abi encoded amount
function deposit(address user, bytes calldata depositData)
external
onlyRole(DEPOSITOR_ROLE)
{
uint256 amount = abi.decode(depositData, (uint256));
_mint(user, amount);
}


/// @notice called when user wants to withdraw tokens back to root chain
/// @dev Should burn user's tokens. This transaction will be verified when exiting on root chain
/// @param amount amount of tokens to withdraw
function withdraw(uint256 amount) external {
_burn(_msgSender(), amount);
}


function mint(address user, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(user, amount);
}

function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override whenNotPaused {
super._beforeTokenTransfer(from, to, amount);
}

function _authorizeUpgrade(address newImplementation)
internal
override
onlyRole(UPGRADER_ROLE)
{}
}
98 changes: 65 additions & 33 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ require("dotenv").config();
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
require('@openzeppelin/hardhat-upgrades');
require("@openzeppelin/hardhat-upgrades");
require("hardhat-gas-reporter");
require("solidity-coverage");
require("hardhat-contract-sizer");
require("hardhat-storage-layout");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
Expand All @@ -23,48 +25,78 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
* @type import('hardhat/config').HardhatUserConfig
*/


/**
* @type import('hardhat/config').HardhatUserConfig
*/

require('dotenv').config();
require("@nomiclabs/hardhat-ethers");

const { ETH_RINKEBY_API_URL, ETH_RINKEBY_PRIVATE_KEY, ETH_MAINNET_API_URL, ETH_MAINNET_PRIVATE_KEY, ETHERSCAN_API_KEY } = process.env;
const {
GOERLI_URL,
MUMBAI_URL,
PRIVATE_KEY,
MAINNET_URL,
POLYGON_URL,
ETHERSCAN_API_KEY,
POLYGONSCAN_API_KEY,
} = process.env;

module.exports = {
solidity: {
version: "0.8.10",
compilers: [
{
version: "0.6.6",
},
{
version: "0.8.10",
},
],
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
defaultNetwork: "rinkeby",
networks: {
hardhat: {},
eth_rinkeby: {
url: ETH_RINKEBY_API_URL,
gas: 4000000,
accounts: [`0x${ETH_RINKEBY_PRIVATE_KEY}`]
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
eth_mainnet: {
url: ETH_MAINNET_API_URL,
gasPrice: 140000000000,
gas: 3800000,
accounts: [`0x${ETH_MAINNET_PRIVATE_KEY}`]
}
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: true,
},
goerli: {
url: GOERLI_URL || "",
accounts: PRIVATE_KEY !== undefined ? [`0x${PRIVATE_KEY}`] : [],
allowUnlimitedContractSize: true,
},
mumbai: {
url: MUMBAI_URL || "",
accounts: PRIVATE_KEY !== undefined ? [`0x${PRIVATE_KEY}`] : [],
},
mainnet: {
url: MAINNET_URL || "",
gasPrice: 70000000000,
gas: 3400000,
accounts: PRIVATE_KEY !== undefined ? [`0x${PRIVATE_KEY}`] : [],
},
polygon: {
url: POLYGON_URL || "",
accounts: PRIVATE_KEY !== undefined ? [`0x${PRIVATE_KEY}`] : [],
},
},
etherscan: {
apiKey: POLYGONSCAN_API_KEY,
},
contractSizer: {
alphaSort: true,
runOnCompile: process.env.CONTRACT_SIZER !== undefined,
disambiguatePaths: false,
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
artifacts: "./artifacts",
},
gasReporter: {
enabled: !!process.env.REPORT_GAS,
},
}
};
Loading

0 comments on commit ea6729e

Please sign in to comment.