Skip to content

Commit

Permalink
Initial refactor to use hardhat and typescript and generate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwhitton committed May 21, 2022
1 parent 9b90df5 commit f7343ca
Show file tree
Hide file tree
Showing 120 changed files with 23,071 additions and 5,597 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
artifacts
cache
coverage
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
env: {
browser: false,
es2021: true,
mocha: true,
node: true,
},
plugins: ["@typescript-eslint"],
extends: [
"standard",
"plugin:prettier/recommended",
"plugin:node/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
},
rules: {
"node/no-unsupported-features/es-syntax": [
"error",
{ ignores: ["modules"] },
],
},
};
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ cache

node_modules
build/contracts

coverage
coverage.json
typechain

#Hardhat files
cache
artifacts
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hardhat.config.ts
scripts
test
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
artifacts
cache
coverage*
gasReporterOutput.json
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["warn", { "ignoreConstructors": true }]
}
}
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 5 additions & 3 deletions contracts/BridgedToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

Expand All @@ -14,7 +15,8 @@ contract BridgedToken is ERC20Upgradeable, ERC20BurnableUpgradeable, OwnableUpgr
) external initializer {
__ERC20_init(name, symbol);
__ERC20Burnable_init();
_setupDecimals(decimals);
// decimals(decimals);
// _setupDecimals(decimals);
}

function mint(address to, uint256 amount) external onlyOwner {
Expand Down
9 changes: 5 additions & 4 deletions contracts/EthereumLightClient.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "./EthereumParser.sol";
import "./lib/EthUtils.sol";
import "./ethash/ethash.sol";
Expand Down
4 changes: 3 additions & 1 deletion contracts/EthereumParser.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: UNLICENSED

/**
* Created on 2019-12-28
* @summary: The EthCommon library contains common structures / functions
* @author: Tuan Vu (tuanvd@gmail.com)
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;
pragma solidity ^0.8.0;

import "./lib/RLPReader.sol";
import "./lib/RLPEncode.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/EthereumProver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

import "./lib/RLPReader.sol";

Expand Down
5 changes: 3 additions & 2 deletions contracts/FaucetToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
Expand All @@ -11,7 +12,7 @@ contract FaucetToken is ERC20Upgradeable {
uint8 decimals
) external initializer {
__ERC20_init(name, symbol);
_setupDecimals(decimals);
// _setupDecimals(decimals);
}

function mint() public returns (bool) {
Expand Down
9 changes: 5 additions & 4 deletions contracts/HarmonyLightClient.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./HarmonyParser.sol";
import "./lib/SafeCast.sol";
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
// import "openzeppelin-solidity/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
// import "openzeppelin-solidity/contracts/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract HarmonyLightClient is
Initializable,
Expand Down
3 changes: 2 additions & 1 deletion contracts/HarmonyParser.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./lib/RLPReader.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/HarmonyProver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

// largely based on
Expand Down
5 changes: 3 additions & 2 deletions contracts/LightClient.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "openzeppelin-solidity/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

interface ILightClient {
function blocksByHeight(uint256, uint256) external returns (uint256); // block number => block hash[]
Expand Down
5 changes: 3 additions & 2 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

contract Migrations {
address public owner;
Expand Down
7 changes: 4 additions & 3 deletions contracts/TokenLocker.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./lib/RLPReader.sol";
import "./BridgedToken.sol";
import "./TokenRegistry.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/TokenLockerOnEthereum.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./HarmonyLightClient.sol";
Expand Down
5 changes: 3 additions & 2 deletions contracts/TokenLockerOnHarmony.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "./EthereumLightClient.sol";
import "./EthereumProver.sol";
import "./TokenLocker.sol";
Expand Down
5 changes: 3 additions & 2 deletions contracts/TokenRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./lib/RLPReader.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./BridgedToken.sol";

contract TokenRegistry {
Expand Down
3 changes: 2 additions & 1 deletion contracts/ethash/MerkelRoot.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

contract MerkelRoots {
Expand Down
3 changes: 2 additions & 1 deletion contracts/ethash/Prime.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

// from https://gist.github.com/lhartikk/c7bbc120aa8e58a0e0e781edb9a90497
Expand Down
3 changes: 2 additions & 1 deletion contracts/ethash/binary.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

library LittleEndian {
Expand Down
5 changes: 3 additions & 2 deletions contracts/ethash/ethash.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./binary.sol";
import "./keccak512.sol";
import "./Prime.sol";
import "@openzeppelin/contracts-upgradeable/cryptography/MerkleProofUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";

import "./MerkelRoot.sol"; // npm run merkelInit

Expand Down
3 changes: 2 additions & 1 deletion contracts/ethash/keccak512.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "./binary.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/ECVerify.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

library ECVerify {
function ecverify(
Expand Down
4 changes: 3 additions & 1 deletion contracts/lib/EthUtils.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: UNLICENSED

/**
* Created on 2019-12-28
* @summary: The EthUtils library contains utility functions
* @author: Tuan Vu (tuanvd@gmail.com)
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;
pragma solidity ^0.8.0;

library EthUtils {
function bytesToBytes32(bytes memory b, uint256 offset)
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/MMR.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

/**
* @author Wanseob Lim <email@wanseob.com>
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/MMRVerifier.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

/**
* @author Wanseob Lim <email@wanseob.com>
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/MMRWrapper.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

import "./MMR.sol";
import "./RLPReader.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/MPT.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

import "./RLPReader.sol";

Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/RLPEncode.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

/**
* @title RLPEncode
Expand Down
6 changes: 4 additions & 2 deletions contracts/lib/RLPReader.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

/*
* @author Hamdi Allam hamdi.allam97@gmail.com
Expand Down Expand Up @@ -168,7 +169,8 @@ library RLPReader {
// 1 byte for the length prefix
require(item.len == 21);

return address(toUint(item));
return address(uint160(toUint(item)));
// return address(toUint(item));
}

function toUint(RLPItem memory item) internal pure returns (uint256) {
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/SafeCast.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.3;

pragma solidity ^0.8.0;

library SafeCast {
function toUint200(uint256 value) internal pure returns (uint200) {
Expand Down
Loading

0 comments on commit f7343ca

Please sign in to comment.