Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
This commit runs linter for solidity and javascript files across the
repository
  • Loading branch information
Mark Toda committed Feb 18, 2021
1 parent aac3f4b commit bafd0d6
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 205 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"useTabs": false,
"printWidth": 80,
"tabWidth": 2,
"singleQuote": false,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": false,
"semi": true,
Expand Down
18 changes: 9 additions & 9 deletions app/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var account;
var balance;

function setStatus(message) {
var status = document.getElementById("status");
var status = document.getElementById('status');
status.innerHTML = message;
}

Expand All @@ -13,39 +13,39 @@ function refreshBalance() {
meta.getBalance
.call(account, { from: account })
.then(function (value) {
var balance_element = document.getElementById("balance");
var balance_element = document.getElementById('balance');
balance_element.innerHTML = value.valueOf();
})
.catch(function (e) {
console.log(e);
setStatus("Error getting balance; see log.");
setStatus('Error getting balance; see log.');
});
}

function sendCoin() {
var meta = MetaCoin.deployed();

var amount = parseInt(document.getElementById("amount").value);
var receiver = document.getElementById("receiver").value;
var amount = parseInt(document.getElementById('amount').value);
var receiver = document.getElementById('receiver').value;

setStatus("Initiating transaction... (please wait)");
setStatus('Initiating transaction... (please wait)');

meta
.sendCoin(receiver, amount, { from: account })
.then(function () {
setStatus("Transaction complete!");
setStatus('Transaction complete!');
refreshBalance();
})
.catch(function (e) {
console.log(e);
setStatus("Error sending coin; see log.");
setStatus('Error sending coin; see log.');
});
}

window.onload = function () {
web3.eth.getAccounts(function (err, accs) {
if (err != null) {
alert("There was an error fetching your accounts.");
alert('There was an error fetching your accounts.');
return;
}

Expand Down
177 changes: 99 additions & 78 deletions contracts/Batcher.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.7.5;

// SPDX-License-Identifier: Apache-2.0

/**
Expand All @@ -17,94 +18,114 @@ pragma solidity 0.7.5;
*/

contract Batcher {
event BatchTransfer(address sender, address recipient, uint256 value);
event OwnerChange(address prevOwner, address newOwner);
event TransferGasLimitChange(uint256 prevTransferGasLimit, uint256 newTransferGasLimit);
event BatchTransfer(address sender, address recipient, uint256 value);
event OwnerChange(address prevOwner, address newOwner);
event TransferGasLimitChange(
uint256 prevTransferGasLimit,
uint256 newTransferGasLimit
);

address public owner;
uint256 public lockCounter;
uint256 public transferGasLimit;
address public owner;
uint256 public lockCounter;
uint256 public transferGasLimit;

constructor() {
lockCounter = 1;
owner = msg.sender;
emit OwnerChange(address(0), owner);
transferGasLimit = 20000;
emit TransferGasLimitChange(0, transferGasLimit);
}
constructor() {
lockCounter = 1;
owner = msg.sender;
emit OwnerChange(address(0), owner);
transferGasLimit = 20000;
emit TransferGasLimitChange(0, transferGasLimit);
}

modifier lockCall() {
lockCounter++;
uint256 localCounter = lockCounter;
_;
require(localCounter == lockCounter, "Reentrancy attempt detected");
}
modifier lockCall() {
lockCounter++;
uint256 localCounter = lockCounter;
_;
require(localCounter == lockCounter, 'Reentrancy attempt detected');
}

modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
modifier onlyOwner() {
require(msg.sender == owner, 'Not owner');
_;
}

/**
* Transfer funds in a batch to each of recipients
* @param recipients The list of recipients to send to
* @param values The list of values to send to recipients.
* The recipient with index i in recipients array will be sent values[i].
* Thus, recipients and values must be the same length
*/
function batch(address[] calldata recipients, uint256[] calldata values) external payable lockCall {
require(recipients.length != 0, "Must send to at least one person");
require(recipients.length == values.length, "Unequal recipients and values");
require(recipients.length < 256, "Too many recipients");
/**
* Transfer funds in a batch to each of recipients
* @param recipients The list of recipients to send to
* @param values The list of values to send to recipients.
* The recipient with index i in recipients array will be sent values[i].
* Thus, recipients and values must be the same length
*/
function batch(address[] calldata recipients, uint256[] calldata values)
external
payable
lockCall
{
require(recipients.length != 0, 'Must send to at least one person');
require(
recipients.length == values.length,
'Unequal recipients and values'
);
require(recipients.length < 256, 'Too many recipients');

// Try to send all given amounts to all given recipients
// Revert everything if any transfer fails
for (uint8 i = 0; i < recipients.length; i++) {
require(recipients[i] != address(0), "Invalid recipient address");
(bool success,) = recipients[i].call{value: values[i], gas: transferGasLimit}("");
require(success, "Send failed");
emit BatchTransfer(msg.sender, recipients[i], values[i]);
}
// Try to send all given amounts to all given recipients
// Revert everything if any transfer fails
for (uint8 i = 0; i < recipients.length; i++) {
require(recipients[i] != address(0), 'Invalid recipient address');
(bool success, ) = recipients[i].call{
value: values[i],
gas: transferGasLimit
}('');
require(success, 'Send failed');
emit BatchTransfer(msg.sender, recipients[i], values[i]);
}
}

/**
* Recovery function for the contract owner to recover any ERC20 tokens or ETH that may get lost in the control of this contract.
* @param to The recipient to send to
* @param value The ETH value to send with the call
* @param data The data to send along with the call
*/
function recover(address to, uint256 value, bytes calldata data) external onlyOwner returns (bytes memory) {
(bool success, bytes memory returnData) = to.call{value: value}(data);
return returnData;
}
/**
* Recovery function for the contract owner to recover any ERC20 tokens or ETH that may get lost in the control of this contract.
* @param to The recipient to send to
* @param value The ETH value to send with the call
* @param data The data to send along with the call
*/
function recover(
address to,
uint256 value,
bytes calldata data
) external onlyOwner returns (bytes memory) {
(bool success, bytes memory returnData) = to.call{ value: value }(data);
return returnData;
}

/**
* Transfers ownership of the contract ot the new owner
* @param newOwner The address to transfer ownership of the contract to
*/
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Invalid new owner");
emit OwnerChange(owner, newOwner);
owner = newOwner;
}
/**
* Transfers ownership of the contract ot the new owner
* @param newOwner The address to transfer ownership of the contract to
*/
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), 'Invalid new owner');
emit OwnerChange(owner, newOwner);
owner = newOwner;
}

/**
* Change the gas limit that is sent along with batched transfers.
* This is intended to protect against any EVM level changes that would require
* a new amount of gas for an internal send to complete.
* @param newTransferGasLimit The new gas limit to send along with batched transfers
*/
function changeTransferGasLimit(uint256 newTransferGasLimit) external onlyOwner {
require(newTransferGasLimit >= 2300, "Transfer gas limit too low");
emit TransferGasLimitChange(transferGasLimit, newTransferGasLimit);
transferGasLimit = newTransferGasLimit;
}
/**
* Change the gas limit that is sent along with batched transfers.
* This is intended to protect against any EVM level changes that would require
* a new amount of gas for an internal send to complete.
* @param newTransferGasLimit The new gas limit to send along with batched transfers
*/
function changeTransferGasLimit(uint256 newTransferGasLimit)
external
onlyOwner
{
require(newTransferGasLimit >= 2300, 'Transfer gas limit too low');
emit TransferGasLimitChange(transferGasLimit, newTransferGasLimit);
transferGasLimit = newTransferGasLimit;
}

fallback() external payable {
revert("Invalid fallback");
}
fallback() external payable {
revert('Invalid fallback');
}

receive() external payable {
revert("Invalid receive");
}
receive() external payable {
revert('Invalid receive');
}
}
26 changes: 15 additions & 11 deletions contracts/Forwarder.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.7.5;
import "@uniswap/lib/contracts/libraries/TransferHelper.sol";
import "./ERC20Interface.sol";
import '@uniswap/lib/contracts/libraries/TransferHelper.sol';
import './ERC20Interface.sol';

/**
* Contract that will forward any incoming Ether to the creator of the contract
Expand All @@ -23,10 +23,10 @@ contract Forwarder {
return;
}

(bool success, ) = parentAddress.call{ value: value }("");
require(success, "Flush failed");
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
Expand All @@ -36,15 +36,15 @@ contract Forwarder {
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, "Only Parent");
require(msg.sender == parentAddress, 'Only Parent');
_;
}

/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), "Already initialized");
require(parentAddress == address(0x0), 'Already initialized');
_;
}

Expand Down Expand Up @@ -74,7 +74,11 @@ contract Forwarder {
return;
}

TransferHelper.safeTransfer(tokenContractAddress, parentAddress, forwarderBalance);
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}

/**
Expand All @@ -87,8 +91,8 @@ contract Forwarder {
return;
}

(bool success, ) = parentAddress.call{ value: value }("");
require(success, "Flush failed");
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
4 changes: 2 additions & 2 deletions contracts/ForwarderFactory.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.7.5;
import "./Forwarder.sol";
import "./CloneFactory.sol";
import './Forwarder.sol';
import './CloneFactory.sol';

contract ForwarderFactory is CloneFactory {
address public implementationAddress;
Expand Down
4 changes: 2 additions & 2 deletions contracts/WalletFactory.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.7.5;
import "./WalletSimple.sol";
import "./CloneFactory.sol";
import './WalletSimple.sol';
import './CloneFactory.sol';

contract WalletFactory is CloneFactory {
address public implementationAddress;
Expand Down
Loading

0 comments on commit bafd0d6

Please sign in to comment.