Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis/test-part.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -euxo pipefail

readonly test_part=${TEST_PART:-}

export NODE_OPTIONS=--max-old-space-size=4096

case "$test_part" in
All)
npx buidler test --no-compile
Expand Down
26 changes: 20 additions & 6 deletions buidler.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,31 @@ module.exports = {
}
},

solc: {
version: "0.6.6",
optimizer: require("./solcOptimiserSettings.js")
solidity: {
compilers: [{
version: "0.4.18",
settings: {
optimizer: require("./solcOptimiserSettings.js")
}
}, {
version: "0.5.11",
settings: {
optimizer: require("./solcOptimiserSettings.js")
}
}, {
version: "0.6.6",
settings: {
optimizer: require("./solcOptimiserSettings.js")
}
}]
},

paths: {
sources: "./contracts/sol6",
sources: "./contracts",
tests: "./test/",
},

mocha: {
enableTimeouts: false
timeout: 0
}
};
};
10 changes: 0 additions & 10 deletions buidlerConfigSol4.js

This file was deleted.

11 changes: 0 additions & 11 deletions buidlerConfigSol5.js

This file was deleted.

155 changes: 0 additions & 155 deletions buidlerConfigSol6.js

This file was deleted.

2 changes: 0 additions & 2 deletions cmp.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh
export NODE_OPTIONS=--max-old-space-size=4096
npx buidler compile &&
npx buidler compile --config buidlerConfigSol5.js &&
npx buidler compile --config buidlerConfigSol4.js &&
node contractSizeReport.js
3 changes: 0 additions & 3 deletions cmpSol6.sh

This file was deleted.

11 changes: 5 additions & 6 deletions contractSizeReport.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
'use strict';
const bre = require('@nomiclabs/buidler')
const { Artifacts } = require('@nomiclabs/buidler/plugins')
const fs = require('fs');
const util = require('util');
const got = require('got');
const yargs = require('yargs');

let path = 'artifacts';

const readdir = util.promisify(fs.readdir);
const artifacts = new Artifacts(bre.config.paths.artifacts)

let argv = yargs.default('branch', 'Katalyst').alias('b', 'branch').argv;

async function generateCodeSizeReport() {
let result = {};
let fileNames = await readdir(path);
let fileNames = await artifacts.getArtifacts();
for (let i = 0; i < fileNames.length; i++) {
let fileName = fileNames[i];
let rawData = fs.readFileSync(path + '/' + fileName);
let rawData = fs.readFileSync(fileName);
let contractData = JSON.parse(rawData);
let codeSize = contractData.deployedBytecode.length / 2 - 1;
if (codeSize > 0) {
Expand Down
33 changes: 29 additions & 4 deletions contracts/sol5/bridges/eth2dai/mock/WethToken.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@

pragma solidity 0.5.11;

import "../../../mock/Token.sol";
import "../../../mock/StandardToken.sol";


contract WethToken is Token {
contract WethToken is StandardToken {
string public name = "Test";
string public symbol = "TST";
uint256 public decimals = 18;
uint256 public INITIAL_SUPPLY = 10**(50 + 18);

constructor(string memory _name, string memory _symbol, uint _decimals) Token(_name, _symbol, _decimals) public {}
constructor(string memory _name, string memory _symbol, uint _decimals) public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
name = _name;
symbol = _symbol;
decimals = _decimals;
}

event Burn(address indexed _burner, uint256 _value);
event Deposit(address indexed dst, uint wad);

function deposit() public payable {
Expand All @@ -22,4 +33,18 @@ contract WethToken is Token {
msg.sender.transfer(wad);
emit Withdrawal(msg.sender, wad);
}

function burn(uint256 _value) public returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0x0), _value);
return true;
}

// save some gas by making only one contract call
function burnFrom(address _from, uint256 _value) public returns (bool) {
transferFrom(_from, msg.sender, _value);
return burn(_value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract ERC20 is ERC20Basic {
contract BasicToken is ERC20Basic {
using SafeMath for uint256;

mapping(address => uint256) balances;
mapping(address => uint256) public balances;

/*
* Fix for the ERC20 short address attack
Expand Down Expand Up @@ -140,7 +140,7 @@ contract BasicToken is ERC20Basic {
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is BasicToken, ERC20 {
mapping(address => mapping(address => uint256)) allowed;
mapping(address => mapping(address => uint256)) public allowed;

function transferFrom(
address _from,
Expand All @@ -149,7 +149,8 @@ contract StandardToken is BasicToken, ERC20 {
) public returns (bool) {
uint256 _allowance = allowed[_from][msg.sender];

// Check is not needed because sub(_allowance, _value) will already revert if this condition is not met
// Check is not needed because sub(_allowance, _value) will
// already revert if this condition is not met
require(_value <= _allowance, "transfer more then allowed");

balances[_to] = balances[_to].add(_value);
Expand All @@ -169,48 +170,3 @@ contract StandardToken is BasicToken, ERC20 {
return allowed[_owner][_spender];
}
}


////////////////////////////////////////////////////////////////////////////////

/*
* SimpleToken
*
* Very simple ERC20 Token example, where all tokens are pre-assigned
* to the creator. Note they can later distribute these tokens
* as they wish using `transfer` and other `StandardToken` functions.
*/
contract Token is StandardToken {
string public name = "Test";
string public symbol = "TST";
uint256 public decimals = 18;
uint256 public INITIAL_SUPPLY = 10**(50 + 18);

event Burn(address indexed _burner, uint256 _value);

constructor(
string memory _name,
string memory _symbol,
uint256 _decimals
) public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
name = _name;
symbol = _symbol;
decimals = _decimals;
}

function burn(uint256 _value) public returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0x0), _value);
return true;
}

// save some gas by making only one contract call
function burnFrom(address _from, uint256 _value) public returns (bool) {
transferFrom(_from, msg.sender, _value);
return burn(_value);
}
}
Loading