Skip to content

Commit

Permalink
Merge pull request #109 from BitGo/WIN-666-upgrade-solidity-version
Browse files Browse the repository at this point in the history
chore(contracts): upgrade solidity version to 0.8.20
  • Loading branch information
gianchandania authored Oct 6, 2023
2 parents 47976e3 + d032ea1 commit bebf6c7
Show file tree
Hide file tree
Showing 37 changed files with 957 additions and 396 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/deploy_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
- run: npm run lint
- run: npm run test
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
ALCHEMY_ETHER_API_KEY: ${{ secrets.ALCHEMY_ETHER_API_KEY }}
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }}
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }}
Expand All @@ -36,26 +38,28 @@ jobs:
result-encoding: string
script: |
const tag = process.env.GITHUB_REF_NAME;
const regex = /v.*\-(eth|gteth|matic|tmatic|bsc|tbsc)$/;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc)$/;
const network = tag.match(regex);
return network ? network[1] : "gteth";
return network ? network[1] : "hteth";
deploy-to-test:
runs-on: ubuntu-latest
needs: [lint-and-test, get-network]
if: ${{ (needs.get-network.outputs.network == 'gteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) }}
if: ${{ (needs.get-network.outputs.network == 'hteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) }}
environment: testnet
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
cache: 'npm'
- run: npm install
- run: npm run deploy-test --network ${{ needs.get-network.outputs.network }}
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
ALCHEMY_ETHER_API_KEY: ${{ secrets.ALCHEMY_ETHER_API_KEY }}
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }}
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }}
Expand Down Expand Up @@ -98,13 +102,15 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
cache: 'npm'
- run: npm install
- run: npm run deploy-prod --network ${{ needs.get-network.outputs.network }}
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
ALCHEMY_ETHER_API_KEY: ${{ secrets.ALCHEMY_ETHER_API_KEY }}
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }}
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }}
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -24,9 +24,12 @@ jobs:
- run: npm install
- run: npm run test
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
ALCHEMY_ETHER_API_KEY: ${{ secrets.ALCHEMY_ETHER_API_KEY }}
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }}
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }}
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
- run: npm run lint
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rules": {
"func-visibility": ["warn", { "ignoreConstructors": true }],
"avoid-low-level-calls": "off",
"compiler-version": ["error", "0.8.10"],
"compiler-version": ["error", "0.8.20"],
"const-name-snakecase": "off",
"not-rely-on-time": "off",
"quotes": ["error", "single"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Transfer batcher. Takes a list of recipients and amounts, and distributes ETH to

## Installation

NodeJS 14 is required.
NodeJS 16 is required.

```shell
yarn
Expand Down
2 changes: 1 addition & 1 deletion contracts/Batcher.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.10;
pragma solidity 0.8.20;

// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion contracts/CloneFactory.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
// from https://github.com/optionality/clone-factory
pragma solidity 0.8.10;
pragma solidity 0.8.20;

/*
The MIT License (MIT)
Expand Down
4 changes: 2 additions & 2 deletions contracts/ERC20Interface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;
pragma solidity 0.8.20;

/**
* Contract that exposes the needed erc20 token functions
Expand All @@ -15,7 +15,7 @@ abstract contract ERC20Interface {
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
virtual
returns (uint256 balance);
}
8 changes: 4 additions & 4 deletions contracts/Forwarder.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
Expand Down Expand Up @@ -52,15 +52,15 @@ contract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
modifier onlyParent() {
require(msg.sender == parentAddress, 'Only Parent');
_;
}

/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
modifier onlyUninitialized() {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
Expand Down Expand Up @@ -313,9 +313,9 @@ contract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155Receiver, IERC165)
view
returns (bool)
{
return
Expand Down
2 changes: 1 addition & 1 deletion contracts/ForwarderFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import './Forwarder.sol';
import './CloneFactory.sol';

Expand Down
3 changes: 2 additions & 1 deletion contracts/IForwarder.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.8.0;
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/TransferHelper.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '@openzeppelin/contracts/utils/Address.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/WalletFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import './WalletSimple.sol';
import './CloneFactory.sol';

Expand Down
17 changes: 8 additions & 9 deletions contracts/WalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import './TransferHelper.sol';
import './ERC20Interface.sol';
import './IForwarder.sol';
Expand Down Expand Up @@ -93,7 +93,7 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
* to allow this contract to be used by proxy with delegatecall, which will
* not pick up on state variables
*/
function getNetworkId() internal virtual pure returns (string memory) {
function getNetworkId() internal pure virtual returns (string memory) {
return 'ETHER';
}

Expand All @@ -105,7 +105,7 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
* to allow this contract to be used by proxy with delegatecall, which will
* not pick up on state variables
*/
function getTokenNetworkId() internal virtual pure returns (string memory) {
function getTokenNetworkId() internal pure virtual returns (string memory) {
return 'ERC20';
}

Expand All @@ -117,7 +117,7 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
* to allow this contract to be used by proxy with delegatecall, which will
* not pick up on state variables
*/
function getBatchNetworkId() internal virtual pure returns (string memory) {
function getBatchNetworkId() internal pure virtual returns (string memory) {
return 'ETHER-Batch';
}

Expand All @@ -133,15 +133,15 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
/**
* Modifier that will execute internal code block only if the sender is an authorized signer on this wallet
*/
modifier onlySigner {
modifier onlySigner() {
require(isSigner(msg.sender), 'Non-signer in onlySigner method');
_;
}

/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
modifier onlyUninitialized() {
require(!initialized, 'Contract already initialized');
_;
}
Expand Down Expand Up @@ -557,9 +557,8 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
uint256 lowestValueIndex = 0;
// fetch recentSequenceIds into memory for function context to avoid unnecessary sloads


uint256[SEQUENCE_ID_WINDOW_SIZE] memory _recentSequenceIds
= recentSequenceIds;
uint256[SEQUENCE_ID_WINDOW_SIZE]
memory _recentSequenceIds = recentSequenceIds;
for (uint256 i = 0; i < SEQUENCE_ID_WINDOW_SIZE; i++) {
require(_recentSequenceIds[i] != sequenceId, 'Sequence ID already used');

Expand Down
2 changes: 1 addition & 1 deletion contracts/coins/CeloWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/coins/EtcWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/coins/PolygonWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/coins/RskWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/recoveryContracts/RecoveryWalletFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import './RecoveryWalletSimple.sol';
import '../CloneFactory.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/recoveryContracts/RecoveryWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;
import '../IForwarder.sol';

/** ERC721, ERC1155 imports */
Expand Down
3 changes: 2 additions & 1 deletion contracts/test/AlwaysFalseERC165.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.8.10;
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts/interfaces/IERC165.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/Fail.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.10;
pragma solidity 0.8.20;

contract Fail {
fallback() external payable {
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/FixedSupplyToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

// ----------------------------------------------------------------------------------------------
// Sample fixed supply token contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/ForwarderTarget.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '../Forwarder.sol';

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

pragma solidity 0.8.10;
pragma solidity 0.8.20;

contract GasGuzzler {
uint256 public x = 1;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/GasHeavy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

contract GasHeavy {
uint256 public x = 1;
Expand Down
3 changes: 2 additions & 1 deletion contracts/test/MockERC1155.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Created with: https://wizard.openzeppelin.com/#erc1155
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
Expand Down
3 changes: 2 additions & 1 deletion contracts/test/MockERC721.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.8.10;
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/Reentry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '../Batcher.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/ReentryForwarder.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

// import "./MockERC1155.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/ReentryWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '../WalletSimple.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TestBatcherDriver.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;
pragma solidity 0.8.20;

import '../Batcher.sol';

Expand Down
Loading

0 comments on commit bebf6c7

Please sign in to comment.