From 72cb5cf80685222708a7710eebadf408e23bf4cd Mon Sep 17 00:00:00 2001 From: Tim Coulter Date: Mon, 8 May 2017 08:44:10 -0700 Subject: [PATCH] Upgrade truffle-compile, which provides Solidity 0.4.11. --- lib/testing/Assert.sol | 9 ++++----- lib/testing/deployed.js | 25 +++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/testing/Assert.sol b/lib/testing/Assert.sol index fc742e5c2eb..620381de2e0 100644 --- a/lib/testing/Assert.sol +++ b/lib/testing/Assert.sol @@ -64,7 +64,6 @@ library Assert { uint8 constant A = uint8(byte('a')); byte constant MINUS = byte('-'); - byte constant SPACE = byte(' '); /* Event: TestEvent @@ -853,7 +852,7 @@ library Assert { Returns: result (bool) - The result. */ - function notEqual(uint[] arrA, uint[] arrB, string message) constant returns (bool result) { + function notEqual(uint[] arrA, uint[] arrB, string message) constant returns (bool) { var r = arrA.length == arrB.length; if (r) { for (uint i = 0; i < arrA.length; i++) { @@ -965,7 +964,7 @@ library Assert { Returns: result (bool) - The result. */ - function notEqual(int[] arrA, int[] arrB, string message) constant returns (bool result) { + function notEqual(int[] arrA, int[] arrB, string message) constant returns (bool) { var r = arrA.length == arrB.length; if (r) { for (uint i = 0; i < arrA.length; i++) { @@ -1077,7 +1076,7 @@ library Assert { Returns: result (bool) - The result. */ - function notEqual(address[] arrA, address[] arrB, string message) constant returns (bool result) { + function notEqual(address[] arrA, address[] arrB, string message) constant returns (bool) { var r = arrA.length == arrB.length; if (r) { for (uint i = 0; i < arrA.length; i++) { @@ -1189,7 +1188,7 @@ library Assert { Returns: result (bool) - The result. */ - function notEqual(bytes32[] arrA, bytes32[] arrB, string message) constant returns (bool result) { + function notEqual(bytes32[] arrA, bytes32[] arrB, string message) constant returns (bool) { var r = arrA.length == arrB.length; if (r) { for (uint i = 0; i < arrA.length; i++) { diff --git a/lib/testing/deployed.js b/lib/testing/deployed.js index 04a49853de9..5742340089f 100644 --- a/lib/testing/deployed.js +++ b/lib/testing/deployed.js @@ -1,6 +1,11 @@ +// Using web3 for its sha function... +var Web3 = require("web3"); + var Deployed = { makeSolidityDeployedAddressesLibrary: function(mapping) { + var self = this; + var source = ""; source += "pragma solidity ^0.4.6; \n\n library DeployedAddresses {" + "\n"; @@ -10,6 +15,8 @@ var Deployed = { var body = "throw;"; if (address) { + address = self.toChecksumAddress(address); + body = "return " + address + ";"; } @@ -20,6 +27,24 @@ var Deployed = { source += "}"; return source; + }, + + // Pulled from ethereumjs-util, but I don't want all its dependencies at the moment. + toChecksumAddress: function (address) { + var web3 = new Web3(); + address = address.toLowerCase().replace("0x", ""); + var hash = web3.sha3(address).replace("0x", ""); + var ret = '0x' + + for (var i = 0; i < address.length; i++) { + if (parseInt(hash[i], 16) >= 8) { + ret += address[i].toUpperCase() + } else { + ret += address[i] + } + } + + return ret } }; diff --git a/package.json b/package.json index a85e7393f2e..e812d7760ed 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "spawn-args": "^0.1.0", "temp": "^0.8.3", "truffle-artifactor": "~2.1.4", - "truffle-compile": "~1.1.2", + "truffle-compile": "~2.0.0", "truffle-config": "~0.0.7", "truffle-contract": "~2.0.0", "truffle-contract-sources": "~0.0.1",