From 91828f8a4b04a9261e9e43202b1d8c1632af1862 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 19 Nov 2018 21:37:06 +0100 Subject: [PATCH 1/4] remix module fixed version --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f8c883cf5c..80c12c8f4e 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,11 @@ "npm-link-local": "^1.1.0", "npm-run-all": "^4.0.2", "onchange": "^3.2.1", - "remix-debug": "latest", - "remix-analyzer": "latest", - "remix-lib": "latest", - "remix-solidity": "latest", - "remix-tests": "latest", + "remix-debug": "0.2.13", + "remix-analyzer": "0.2.12", + "remix-lib": "0.3.12", + "remix-solidity": "0.2.13", + "remix-tests": "0.0.19", "remixd": "git+https://github.com/ethereum/remixd.git", "request": "^2.83.0", "rimraf": "^2.6.1", From 11b8eb67d5a77c3ce0ba884930fe66cdad6661cb Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 19 Nov 2018 22:17:56 +0100 Subject: [PATCH 2/4] import solc for generating compilation result for browser test --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 80c12c8f4e..48a01e9b5f 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "request": "^2.83.0", "rimraf": "^2.6.1", "selenium-standalone": "^6.0.1", + "solc": "^0.5.0", "standard": "^8.5.0", "swarmgw": "^0.3.1", "tape": "^4.5.1", From 78066dcd6ff34c7d011c0c2b2915467abc2ab6db Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 20 Nov 2018 10:45:39 +0100 Subject: [PATCH 3/4] fix browser test --- contracts/src/gmbh/company.sol | 2 +- contracts/src/gmbh/contract.sol | 2 +- contracts/src/gmbh/test.sol | 2 +- src/app/debugger/debugger/VmDebugger.js | 2 +- src/app/editor/example-contracts.js | 16 +- test-browser/tests/ballot.js | 2 +- test-browser/tests/compiling.js | 64 ++++---- test-browser/tests/sharedFolderExplorer.js | 9 +- test-browser/tests/simpleContract.js | 177 ++++++++++----------- test-browser/tests/staticanalysis.js | 2 +- test-browser/tests/units/testRecorder.js | 14 +- 11 files changed, 145 insertions(+), 147 deletions(-) diff --git a/contracts/src/gmbh/company.sol b/contracts/src/gmbh/company.sol index 3161bf74dd..1b2e827e43 100644 --- a/contracts/src/gmbh/company.sol +++ b/contracts/src/gmbh/company.sol @@ -1,7 +1,7 @@ import "./contract.sol"; contract Assets { uint[] proposals; - function add(uint8 _numProposals) { + function add(uint8 _numProposals) public { proposals.length = _numProposals; } } diff --git a/contracts/src/gmbh/contract.sol b/contracts/src/gmbh/contract.sol index 011523e562..480c1f4f77 100644 --- a/contracts/src/gmbh/contract.sol +++ b/contracts/src/gmbh/contract.sol @@ -1,6 +1,6 @@ contract gmbh { uint[] proposals; - function register(uint8 _numProposals) { + function register(uint8 _numProposals) public { proposals.length = _numProposals; } } diff --git a/contracts/src/gmbh/test.sol b/contracts/src/gmbh/test.sol index d1a6e04941..e04a8bc178 100644 --- a/contracts/src/gmbh/test.sol +++ b/contracts/src/gmbh/test.sol @@ -1,6 +1,6 @@ contract test { - function Test(uint8 _numProposals) { + function Test(uint8 _numProposals) public { proposals.length = _numProposals; } } diff --git a/src/app/debugger/debugger/VmDebugger.js b/src/app/debugger/debugger/VmDebugger.js index 63211823e9..ae6bbe902a 100644 --- a/src/app/debugger/debugger/VmDebugger.js +++ b/src/app/debugger/debugger/VmDebugger.js @@ -195,7 +195,7 @@ class VmDebuggerLogic { self.event.trigger('newTrace', []) }) - self.debugger.event.register('callTreeReady', function () { + self.debugger.event.register('callTreeReady', this, function () { if (self.debugger.callTree.reducedTrace.length) { return self.event.trigger('newCallTree', []) } diff --git a/src/app/editor/example-contracts.js b/src/app/editor/example-contracts.js index 1441b44c8b..6fdd16e246 100644 --- a/src/app/editor/example-contracts.js +++ b/src/app/editor/example-contracts.js @@ -1,7 +1,6 @@ 'use strict' -var ballot = `pragma solidity ^0.4.0; -contract Ballot { +var ballot = `contract Ballot { struct Voter { uint weight; @@ -18,7 +17,7 @@ contract Ballot { Proposal[] proposals; /// Create a new ballot with $(_numProposals) different proposals. - function Ballot(uint8 _numProposals) public { + constructor(uint8 _numProposals) public { chairperson = msg.sender; voters[chairperson].weight = 1; proposals.length = _numProposals; @@ -56,7 +55,7 @@ contract Ballot { proposals[toProposal].voteCount += sender.weight; } - function winningProposal() public constant returns (uint8 _winningProposal) { + function winningProposal() public view returns (uint8 _winningProposal) { uint256 winningVoteCount = 0; for (uint8 prop = 0; prop < proposals.length; prop++) if (proposals[prop].voteCount > winningVoteCount) { @@ -64,16 +63,17 @@ contract Ballot { _winningProposal = prop; } } -}` +} +` -var ballotTest = `pragma solidity ^0.4.7; +var ballotTest = ` import "remix_tests.sol"; // this import is automatically injected by Remix. import "./ballot.sol"; contract test3 { Ballot ballotToTest; - function beforeAll () { + function beforeAll () public { ballotToTest = new Ballot(2); } @@ -82,7 +82,7 @@ contract test3 { Assert.equal(ballotToTest.winningProposal(), uint(1), "1 should be the winning proposal"); } - function checkWinninProposalWithReturnValue () public constant returns (bool) { + function checkWinninProposalWithReturnValue () public view returns (bool) { return ballotToTest.winningProposal() == 1; } } diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index 424387f4f1..3fb9573ea7 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -48,7 +48,7 @@ function runTests (browser, testData) { .pause(2000) .perform(function (client, done) { console.log('goToVMtraceStep') - contractHelper.goToVMtraceStep(browser, 47, () => { + contractHelper.goToVMtraceStep(browser, 55, () => { done() }) }) diff --git a/test-browser/tests/compiling.js b/test-browser/tests/compiling.js index ef739bba9c..af09962aa8 100644 --- a/test-browser/tests/compiling.js +++ b/test-browser/tests/compiling.js @@ -89,12 +89,12 @@ function testReturnValues (browser, callback) { "1": "bytes2: _b2 0x1223", "2": "bytes3: _b3 0x000000", "3": "bytes: _blit 0x123498", - "4": "bytes5: _b5 0x0000043245", - "5": "bytes6: _b6 0x002345532532", + "4": "bytes5: _b5 0x0432450000", + "5": "bytes6: _b6 0x234553253200", "6": "string: _str this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string", "7": "bytes7: _b7 0x03252353253253", - "8": "bytes22: _b22 0x00000000000000000000325235235325325325235325", - "9": "bytes32: _b32 0x0000000000000000000000000000000000032523532532523532523532523532" + "8": "bytes22: _b22 0x32523523532532532523532500000000000000000000", + "9": "bytes32: _b32 0x0325235325325235325235325235320000000000000000000000000000000000" }`).pause(500).testFunction('retunValues3 - transact (not payable)', '0x94c4b4324bad773dec29af3ffe26a698c32b5caf8a1eedf8889563158639d28a', '[vm]\nfrom:0xca3...a733c\nto:testReturnValues.retunValues3() 0x5e7...26e9f\nvalue:0 wei\ndata:0x033...e0a7d\nlogs:0\nhash:0x94c...9d28a', null, `{ @@ -137,7 +137,7 @@ function testInputValues (browser, callback) { "indexed": true, "hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658" }, - "3": "0x00001234", + "3": "0x12340000", "4": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ", "_i": "-123", "_u": "123", @@ -145,7 +145,7 @@ function testInputValues (browser, callback) { "indexed": true, "hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658" }, - "_b": "0x00001234", + "_b": "0x12340000", "_notIndexed": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ", "length": 5 } @@ -158,37 +158,37 @@ function testInputValues (browser, callback) { // @TODO test: bytes8[3][] type as input var sources = [ - {'browser/Untitled.sol': {content: `pragma solidity ^0.4.0; - contract TestContract { function f() returns (uint) { return 8; } - function g() returns (uint, string, bool, uint) { + {'browser/Untitled.sol': {content: ` + contract TestContract { function f() public returns (uint) { return 8; } + function g() public returns (uint, string memory, bool, uint) { uint payment = 345; bool payed = true; string memory comment = "comment_comment_"; uint month = 4; return (payment, comment, payed, month); } }`}}, - {'browser/returnValues.sol': {content: `pragma solidity ^0.4.0; - contract testReturnValues { + {'browser/returnValues.sol': {content: ` + contract testReturnValues { enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } - function retunValues1 () returns (bool _b, uint _u, int _i, address _a) { + function retunValues1 () public returns (bool _b, uint _u, int _i, address _a) { _b = true; _u = 345; _i = -345; _a = msg.sender; } - function retunValues2 () returns (byte _b, bytes2 _b2, bytes3 _b3, bytes _blit, bytes5 _b5, bytes6 _b6, string _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) { + function retunValues2 () public returns (byte _b, bytes2 _b2, bytes3 _b3, bytes memory _blit, bytes5 _b5, bytes6 _b6, string memory _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) { _b = 0x12; _b2 = 0x1223; - _b5 = 0x43245; - _b6 = 0x2345532532; - _b7 = 0x3252353253253; - _b22 = 0x325235235325325325235325; - _b32 = 0x32523532532523532523532523532; + _b5 = hex"043245"; + _b6 = hex"2345532532"; + _b7 = hex"03252353253253"; + _b22 = hex"325235235325325325235325"; + _b32 = hex"032523532532523532523532523532"; _blit = hex"123498"; _str = "this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string"; } - function retunValues3 () returns (ActionChoices _en, int[5][] _a1) { + function retunValues3 () public returns (ActionChoices _en, int[5][] memory _a1) { _en = ActionChoices.GoStraight; int[5][] memory a = new int[5][](3); a[0] = [int(1),-45,-78,56,60]; @@ -197,18 +197,18 @@ var sources = [ _a1 = a; } }`}}, - {'browser/inputValues.sol': {content: `pragma solidity ^0.4.0; + {'browser/inputValues.sol': {content: ` contract test { - event event1(int _i, uint indexed _u, string indexed _str, bytes4 _b, string _notIndexed); - function inputValue1 (uint _u, int _i, string _str) returns (uint _uret, int _iret, string _strret) { - _uret = _u; - _iret = _i; - _strret = _str; - } - function inputValue2 (uint[3] _n, bytes8[4] _b8) returns (uint[3] _nret, bytes8[4] _b8ret){ - _nret = _n; - _b8ret = _b8; - event1(-123, 123, "test", 0x1234, "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test "); - } - }`}} + event event1(int _i, uint indexed _u, string indexed _str, bytes4 _b, string _notIndexed); + function inputValue1 (uint _u, int _i, string memory _str) public returns (uint _uret, int _iret, string memory _strret) { + _uret = _u; + _iret = _i; + _strret = _str; + } + function inputValue2 (uint[3] memory _n, bytes8[4] memory _b8) public returns (uint[3] memory _nret, bytes8[4] memory _b8ret){ + _nret = _n; + _b8ret = _b8; + emit event1(-123, 123, "test", hex"1234", "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test "); + } +}`}} ] diff --git a/test-browser/tests/sharedFolderExplorer.js b/test-browser/tests/sharedFolderExplorer.js index 711359d59c..0dd6028fb9 100644 --- a/test-browser/tests/sharedFolderExplorer.js +++ b/test-browser/tests/sharedFolderExplorer.js @@ -6,23 +6,22 @@ var sauce = require('./sauce') var assetsTestContract = `import "./contract.sol"; contract Assets { uint[] proposals; - function add(uint8 _numProposals) { + function add(uint8 _numProposals) public { proposals.length = _numProposals; } } ` -var gmbhTestContract = ` -contract gmbh { +var gmbhTestContract = `contract gmbh { uint[] proposals; - function register(uint8 _numProposals) { + function register(uint8 _numProposals) public { proposals.length = _numProposals; } } ` var sources = [ { - 'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () returns (uint) { return 11; }}'} + 'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () public returns (uint) { return 11; }}'} }, { 'localhost/src/gmbh/company.sol': {content: assetsTestContract} diff --git a/test-browser/tests/simpleContract.js b/test-browser/tests/simpleContract.js index 105fc08818..1cfef8c35c 100644 --- a/test-browser/tests/simpleContract.js +++ b/test-browser/tests/simpleContract.js @@ -169,16 +169,15 @@ function testGitHubImport (browser, callback) { } */ -var abstractENS = `pragma solidity ^0.4.0; - +var abstractENS = ` contract AbstractENS { - function owner(bytes32 node) constant returns(address); - function resolver(bytes32 node) constant returns(address); - function ttl(bytes32 node) constant returns(uint64); - function setOwner(bytes32 node, address owner); - function setSubnodeOwner(bytes32 node, bytes32 label, address owner); - function setResolver(bytes32 node, address resolver); - function setTTL(bytes32 node, uint64 ttl); + function owner(bytes32 node) public view returns(address); + function resolver(bytes32 node) public view returns(address); + function ttl(bytes32 node) public view returns(uint64); + function setOwner(bytes32 node, address owner) public; + function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public; + function setResolver(bytes32 node, address resolver) public; + function setTTL(bytes32 node, uint64 ttl) public; // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); @@ -198,94 +197,94 @@ var ENS = `pragma solidity ^0.4.0; import './AbstractENS.sol'; /** - * The ENS registry contract. - */ +* The ENS registry contract. +*/ contract ENS is AbstractENS { - struct Record { - address owner; - address resolver; - uint64 ttl; - } + struct Record { + address owner; + address resolver; + uint64 ttl; + } - mapping(bytes32=>Record) records; + mapping(bytes32=>Record) records; - // Permits modifications only by the owner of the specified node. - modifier only_owner(bytes32 node) { - if (records[node].owner != msg.sender) throw; - _; - } + // Permits modifications only by the owner of the specified node. + modifier only_owner(bytes32 node) { + if (records[node].owner != msg.sender) revert(); + _; + } - /** - * Constructs a new ENS registrar. - */ - function ENS() { - records[0].owner = msg.sender; - } + /** + * Constructs a new ENS registrar. + */ + constructor() public { + records[0].owner = msg.sender; + } - /** - * Returns the address that owns the specified node. - */ - function owner(bytes32 node) constant returns (address) { - return records[node].owner; - } + /** + * Returns the address that owns the specified node. + */ + function owner(bytes32 node) public view returns (address) { + return records[node].owner; + } - /** - * Returns the address of the resolver for the specified node. - */ - function resolver(bytes32 node) constant returns (address) { - return records[node].resolver; - } + /** + * Returns the address of the resolver for the specified node. + */ + function resolver(bytes32 node) public view returns (address) { + return records[node].resolver; + } - /** - * Returns the TTL of a node, and any records associated with it. - */ - function ttl(bytes32 node) constant returns (uint64) { - return records[node].ttl; - } + /** + * Returns the TTL of a node, and any records associated with it. + */ + function ttl(bytes32 node) public view returns (uint64) { + return records[node].ttl; + } - /** - * Transfers ownership of a node to a new address. May only be called by the current - * owner of the node. - * @param node The node to transfer ownership of. - * @param owner The address of the new owner. - */ - function setOwner(bytes32 node, address owner) only_owner(node) { - Transfer(node, owner); - records[node].owner = owner; - } + /** + * Transfers ownership of a node to a new address. May only be called by the current + * owner of the node. + * @param node The node to transfer ownership of. + * @param owner The address of the new owner. + */ + function setOwner(bytes32 node, address owner) public only_owner(node) { + emit Transfer(node, owner); + records[node].owner = owner; + } - /** - * Transfers ownership of a subnode sha3(node, label) to a new address. May only be - * called by the owner of the parent node. - * @param node The parent node. - * @param label The hash of the label specifying the subnode. - * @param owner The address of the new owner. - */ - function setSubnodeOwner(bytes32 node, bytes32 label, address owner) only_owner(node) { - var subnode = sha3(node, label); - NewOwner(node, label, owner); - records[subnode].owner = owner; - } + /** + * Transfers ownership of a subnode sha3(node, label) to a new address. May only be + * called by the owner of the parent node. + * @param node The parent node. + * @param label The hash of the label specifying the subnode. + * @param owner The address of the new owner. + */ + function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public only_owner(node) { + bytes32 subnode = keccak256(abi.encodePacked(node, label)); + emit NewOwner(node, label, owner); + records[subnode].owner = owner; + } - /** - * Sets the resolver address for the specified node. - * @param node The node to update. - * @param resolver The address of the resolver. - */ - function setResolver(bytes32 node, address resolver) only_owner(node) { - NewResolver(node, resolver); - records[node].resolver = resolver; - } + /** + * Sets the resolver address for the specified node. + * @param node The node to update. + * @param resolver The address of the resolver. + */ + function setResolver(bytes32 node, address resolver) public only_owner(node) { + emit NewResolver(node, resolver); + records[node].resolver = resolver; + } - /** - * Sets the TTL for the specified node. - * @param node The node to update. - * @param ttl The TTL in seconds. - */ - function setTTL(bytes32 node, uint64 ttl) only_owner(node) { - NewTTL(node, ttl); - records[node].ttl = ttl; - } + /** + * Sets the TTL for the specified node. + * @param node The node to update. + * @param ttl The TTL in seconds. + */ + function setTTL(bytes32 node, uint64 ttl) public only_owner(node) { + emit NewTTL(node, ttl); + records[node].ttl = ttl; + } }` var sources = [ @@ -310,14 +309,14 @@ var sources = [ }, { 'browser/Untitled5.sol': {content: `library lib { - function get () returns (uint) { + function getInt () public view returns (uint) { return 45; } } contract test { - function get () constant returns (uint) { - return lib.get(); + function get () public view returns (uint) { + return lib.getInt(); } }`} } diff --git a/test-browser/tests/staticanalysis.js b/test-browser/tests/staticanalysis.js index f5039951e6..182e3eccdd 100644 --- a/test-browser/tests/staticanalysis.js +++ b/test-browser/tests/staticanalysis.js @@ -11,7 +11,7 @@ contract test1 { address test = tx.origin; } contract test2 {} contract TooMuchGas { uint x; - function() { + function() external { x++; uint test; uint test1; diff --git a/test-browser/tests/units/testRecorder.js b/test-browser/tests/units/testRecorder.js index aca1892c48..41742bd9cc 100644 --- a/test-browser/tests/units/testRecorder.js +++ b/test-browser/tests/units/testRecorder.js @@ -61,13 +61,13 @@ module.exports = { } } -var sources = [{'browser/testRecorder.sol': {content: `pragma solidity ^0.4.0;contract testRecorder { - function testRecorder(uint p) { - - } - function set (uint _p) { - - } +var sources = [{'browser/testRecorder.sol': {content: `contract testRecorder { + constructor(uint p) public { + + } + function set (uint _p) public { + + } }`}}] var records = `{ From a2a90a9900fe8735d41ce6698a44eab714fbe9b2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 20 Nov 2018 17:40:08 +0100 Subject: [PATCH 4/4] Update simpleContract.js --- test-browser/tests/simpleContract.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-browser/tests/simpleContract.js b/test-browser/tests/simpleContract.js index 1cfef8c35c..d2f18c427f 100644 --- a/test-browser/tests/simpleContract.js +++ b/test-browser/tests/simpleContract.js @@ -197,8 +197,8 @@ var ENS = `pragma solidity ^0.4.0; import './AbstractENS.sol'; /** -* The ENS registry contract. -*/ + * The ENS registry contract. + */ contract ENS is AbstractENS { struct Record { address owner;