diff --git a/contracts/gateway/EIP20CoGateway.sol b/contracts/gateway/EIP20CoGateway.sol index 3d18d2d4..1db7ab58 100644 --- a/contracts/gateway/EIP20CoGateway.sol +++ b/contracts/gateway/EIP20CoGateway.sol @@ -286,7 +286,7 @@ contract EIP20CoGateway is GatewayBase { require( _messageHash != bytes32(0), - "Message hash must not be zero" + "Message hash must not be zero." ); MessageBus.Message storage message = messages[_messageHash]; @@ -303,7 +303,7 @@ contract EIP20CoGateway is GatewayBase { stakeAmount_, mintedAmount_, rewardAmount_) = - progressMintInternal(_messageHash, initialGas, true, bytes32(0)); + progressMintInternal(_messageHash, initialGas, false, _unlockSecret); } /** @@ -745,6 +745,7 @@ contract EIP20CoGateway is GatewayBase { ); } + /* Public functions */ /** @@ -1060,6 +1061,7 @@ contract EIP20CoGateway is GatewayBase { /** * @notice This is internal method for process minting contains common logic. + * It doesn't mint reward if reward is 0. * * @param _messageHash Message hash. * @param _initialGas Initial gas during progress process. @@ -1078,7 +1080,6 @@ contract EIP20CoGateway is GatewayBase { * from the total amount. * @return rewardAmount_ Reward amount that is transferred to facilitator. */ - function progressMintInternal( bytes32 _messageHash, uint256 _initialGas, @@ -1116,11 +1117,13 @@ contract EIP20CoGateway is GatewayBase { mintedAmount_ ); - // Reward beneficiary with the reward amount. - UtilityTokenInterface(utilityToken).increaseSupply( - msg.sender, - rewardAmount_ - ); + if(rewardAmount_ > 0) { + // Reward beneficiary with the reward amount. + UtilityTokenInterface(utilityToken).increaseSupply( + msg.sender, + rewardAmount_ + ); + } // Delete the mint data. delete mints[_messageHash]; diff --git a/contracts/gateway/EIP20Gateway.sol b/contracts/gateway/EIP20Gateway.sol index 1ea4bde9..3db2419b 100644 --- a/contracts/gateway/EIP20Gateway.sol +++ b/contracts/gateway/EIP20Gateway.sol @@ -892,6 +892,9 @@ contract EIP20Gateway is GatewayBase { progressUnstakeInternal(_messageHash, initialGas, bytes32(0), true); } + + /** External methods */ + /** * @notice Declare redeem revert intent. * This will set message status to revoked. This method will also diff --git a/contracts/gateway/UtilityTokenInterface.sol b/contracts/gateway/UtilityTokenInterface.sol index fb0a727c..a7559965 100644 --- a/contracts/gateway/UtilityTokenInterface.sol +++ b/contracts/gateway/UtilityTokenInterface.sol @@ -61,4 +61,17 @@ contract UtilityTokenInterface { */ function decreaseSupply(uint256 _amount) external returns (bool success_); + /** + * @notice Sets the CoGateway contract address. + * + * @dev Function requires: + * - It is called by whitelisted workers. + * - coGateway address is set only once. + * - coGateway.utilityToken must match this contract. + * + * @param _coGateway CoGateway contract address. + * + */ + function setCoGateway(address _coGateway) external returns (bool); + } diff --git a/contracts/test/TestEIP20CoGateway.sol b/contracts/test/TestEIP20CoGateway.sol index 27999e40..4e0a4a75 100644 --- a/contracts/test/TestEIP20CoGateway.sol +++ b/contracts/test/TestEIP20CoGateway.sol @@ -70,7 +70,7 @@ contract TestEIP20CoGateway is EIP20CoGateway { /* Public Functions */ /** - * @notice It is used to set the message. + * @notice It is used to set the stake message. * * @dev This is used for testing purpose. * diff --git a/contracts/test/TestEIP20Gateway.sol b/contracts/test/TestEIP20Gateway.sol index bd4132c8..bf3eca7b 100644 --- a/contracts/test/TestEIP20Gateway.sol +++ b/contracts/test/TestEIP20Gateway.sol @@ -48,7 +48,7 @@ contract TestEIP20Gateway is EIP20Gateway { StateRootInterface _core, uint256 _bounty, IsMemberInterface _membersManager, - address _burner + address payable _burner ) EIP20Gateway( _token, diff --git a/contracts/test/gateway/MockUtilityToken.sol b/contracts/test/gateway/MockUtilityToken.sol new file mode 100644 index 00000000..638fc956 --- /dev/null +++ b/contracts/test/gateway/MockUtilityToken.sol @@ -0,0 +1,66 @@ +pragma solidity ^0.5.0; + +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ---------------------------------------------------------------------------- +// +// http://www.simpletoken.org/ +// +// ---------------------------------------------------------------------------- + +import "../../gateway/UtilityToken.sol"; + +/** + * @title MockUtilityToken contract. + * + * @notice This contract is used to mock certain functions of UtilityToken + * contract. + */ +contract MockUtilityToken is UtilityToken { + + /* Constructor */ + + /** + * @notice Constructor. + * + * @dev This is used for testing only. + * + * @param _token Address of branded token. + * @param _symbol Symbol of token. + * @param _name Name of token. + * @param _decimals Decimal of token. + * @param _membersManager Address of a contract that manages organization. + */ + constructor( + EIP20Interface _token, + string memory _symbol, + string memory _name, + uint8 _decimals, + IsMemberInterface _membersManager + ) + public + UtilityToken(_token, _symbol, _name, _decimals, _membersManager) + {} + + /** + * @notice Set the CoGateway address for testing. + * + * @param _coGatewayAddress CoGateway address. + */ + function setCoGatewayAddress(address _coGatewayAddress) external { + coGateway = _coGatewayAddress; + } + +} diff --git a/contracts/test/gateway/TestUtilityToken.sol b/contracts/test/gateway/TestUtilityToken.sol index f20b7c41..9c765339 100644 --- a/contracts/test/gateway/TestUtilityToken.sol +++ b/contracts/test/gateway/TestUtilityToken.sol @@ -29,16 +29,17 @@ import "../../gateway/UtilityToken.sol"; * contract. */ contract TestUtilityToken is UtilityToken { - + /* Constructor */ /** * @dev This is used for testing by mocking certain variables. * * @param _token Address of branded token. - * @param _symbol Symbol of token - * @param _name Name of token - * @param _decimals Decimal of token + * @param _symbol Symbol of token. + * @param _name Name of token. + * @param _decimals Decimal of token. + * @param _membersManager Address of a contract that manages organization. */ constructor( EIP20Interface _token, diff --git a/package-lock.json b/package-lock.json index 78747663..47879c26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@types/node": { - "version": "10.10.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.10.3.tgz", - "integrity": "sha512-dWk7F3b0m6uDLHero7tsnpAi9r2RGPQHGbb0/VCv7DPJRMFtk3RonY1/29vfJKnheRMBa7+uF+vunlg/mBGlxg==", + "version": "10.12.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.15.tgz", + "integrity": "sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", "dev": true }, "abbrev": { @@ -46,7 +46,7 @@ "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", "dev": true, "requires": { - "mime-types": "2.1.20", + "mime-types": "2.1.21", "negotiator": "0.6.1" } }, @@ -57,15 +57,15 @@ "dev": true }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", + "integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==", "dev": true, "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", + "fast-deep-equal": "2.0.1", "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "json-schema-traverse": "0.4.1", + "uri-js": "4.2.2" } }, "amdefine": { @@ -184,7 +184,6 @@ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "dev": true, - "optional": true, "requires": { "tweetnacl": "0.14.5" } @@ -194,9 +193,9 @@ "dev": true }, "bindings": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", - "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.1.tgz", + "integrity": "sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew==", "dev": true }, "bl": { @@ -219,9 +218,9 @@ } }, "bluebird": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz", - "integrity": "sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", + "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", "dev": true }, "bn.js": { @@ -453,12 +452,6 @@ "wrap-ansi": "2.1.0" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -474,6 +467,12 @@ "delayed-stream": "1.0.0" } }, + "command-exists": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.8.tgz", + "integrity": "sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==", + "dev": true + }, "commander": { "version": "2.17.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", @@ -488,7 +487,7 @@ }, "content-disposition": { "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "resolved": "http://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", "dev": true }, @@ -523,9 +522,9 @@ "dev": true }, "cors": { - "version": "2.8.4", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", - "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", "dev": true, "requires": { "object-assign": "4.1.1", @@ -550,7 +549,7 @@ "requires": { "cipher-base": "1.0.4", "inherits": "2.0.1", - "md5.js": "1.3.4", + "md5.js": "1.3.5", "ripemd160": "2.0.2", "sha.js": "2.4.11" } @@ -575,7 +574,7 @@ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { - "lru-cache": "4.1.3", + "lru-cache": "4.1.5", "shebang-command": "1.2.0", "which": "1.3.1" } @@ -593,8 +592,8 @@ "create-hmac": "1.1.7", "diffie-hellman": "5.0.3", "inherits": "2.0.1", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", + "pbkdf2": "3.0.17", + "public-encrypt": "4.0.3", "randombytes": "2.0.6", "randomfill": "1.0.4" } @@ -651,7 +650,7 @@ "decompress-tarbz2": "4.1.1", "decompress-targz": "4.1.1", "decompress-unzip": "4.0.1", - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "make-dir": "1.3.0", "pify": "2.3.0", "strip-dirs": "2.1.0" @@ -687,7 +686,7 @@ "file-type": "6.2.0", "is-stream": "1.1.0", "seek-bzip": "1.0.5", - "unbzip2-stream": "1.3.0" + "unbzip2-stream": "1.3.1" }, "dependencies": { "file-type": { @@ -807,7 +806,6 @@ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "dev": true, - "optional": true, "requires": { "jsbn": "0.1.1", "safer-buffer": "2.1.2" @@ -827,7 +825,7 @@ "requires": { "bn.js": "4.11.8", "brorand": "1.1.0", - "hash.js": "1.1.5", + "hash.js": "1.1.7", "hmac-drbg": "1.0.1", "inherits": "2.0.1", "minimalistic-assert": "1.0.1", @@ -967,7 +965,7 @@ "integrity": "sha512-SoYhktEbLxf+fiux5SfCEwdzWENMvgIbMZD90I62s4GZD9nEjgEWy8ZboI3hck193Vs0bDoTohDISx84f2H2tw==", "dev": true, "requires": { - "@types/node": "10.10.3", + "@types/node": "10.12.15", "aes-js": "3.0.0", "bn.js": "4.11.8", "elliptic": "6.3.3", @@ -1059,7 +1057,7 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "1.3.4", + "md5.js": "1.3.5", "safe-buffer": "5.1.2" } }, @@ -1079,14 +1077,14 @@ } }, "express": { - "version": "4.16.3", - "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", - "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", "dev": true, "requires": { "accepts": "1.3.5", "array-flatten": "1.1.1", - "body-parser": "1.18.2", + "body-parser": "1.18.3", "content-disposition": "0.5.2", "content-type": "1.0.4", "cookie": "0.3.1", @@ -1104,9 +1102,9 @@ "parseurl": "1.3.2", "path-to-regexp": "0.1.7", "proxy-addr": "2.0.4", - "qs": "6.5.1", + "qs": "6.5.2", "range-parser": "1.2.0", - "safe-buffer": "5.1.1", + "safe-buffer": "5.1.2", "send": "0.16.2", "serve-static": "1.13.2", "setprototypeof": "1.1.0", @@ -1116,24 +1114,6 @@ "vary": "1.1.2" }, "dependencies": { - "body-parser": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", - "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", - "dev": true, - "requires": { - "bytes": "3.0.0", - "content-type": "1.0.4", - "debug": "2.6.9", - "depd": "1.1.2", - "http-errors": "1.6.3", - "iconv-lite": "0.4.19", - "on-finished": "2.3.0", - "qs": "6.5.1", - "raw-body": "2.3.2", - "type-is": "1.6.16" - } - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1143,68 +1123,6 @@ "ms": "2.0.0" } }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", - "dev": true - }, - "raw-body": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", - "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", - "dev": true, - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.2", - "iconv-lite": "0.4.19", - "unpipe": "1.0.0" - }, - "dependencies": { - "depd": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", - "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", - "dev": true - }, - "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", - "dev": true, - "requires": { - "depd": "1.1.1", - "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": "1.4.0" - } - }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", - "dev": true - } - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, "statuses": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", @@ -1226,9 +1144,9 @@ "dev": true }, "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, "fast-json-stable-stringify": { @@ -1316,25 +1234,14 @@ "dev": true }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { "asynckit": "0.4.0", - "combined-stream": "1.0.6", - "mime-types": "2.1.20" - }, - "dependencies": { - "combined-stream": { - "version": "1.0.6", - "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - } + "combined-stream": "1.0.7", + "mime-types": "2.1.21" } }, "forwarded": { @@ -1361,7 +1268,7 @@ "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "jsonfile": "2.4.0", "klaw": "1.3.1", "path-is-absolute": "1.0.1", @@ -1386,7 +1293,7 @@ "integrity": "sha1-BGxwFjzvmq1GsOSn+kZ/si1x3jU=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "jsonfile": "2.4.0" } } @@ -1404,7 +1311,7 @@ "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "inherits": "2.0.1", "mkdirp": "0.5.1", "rimraf": "2.6.2" @@ -1486,9 +1393,9 @@ } }, "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, "graceful-readlink": { @@ -1533,12 +1440,12 @@ "dev": true }, "har-validator": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", - "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "dev": true, "requires": { - "ajv": "5.5.2", + "ajv": "6.6.2", "har-schema": "2.0.0" } }, @@ -1574,9 +1481,9 @@ } }, "hash.js": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", - "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, "requires": { "inherits": "2.0.3", @@ -1603,7 +1510,7 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "1.1.5", + "hash.js": "1.1.7", "minimalistic-assert": "1.0.1", "minimalistic-crypto-utils": "1.0.1" } @@ -1648,7 +1555,7 @@ "requires": { "assert-plus": "1.0.0", "jsprim": "1.4.1", - "sshpk": "1.14.2" + "sshpk": "1.15.2" } }, "iconv-lite": { @@ -1879,8 +1786,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true + "dev": true }, "json-schema": { "version": "0.2.3", @@ -1889,9 +1795,9 @@ "dev": true }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "json-stringify-safe": { @@ -1906,7 +1812,7 @@ "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "4.1.15" } }, "jsprim": { @@ -1927,9 +1833,9 @@ "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", "dev": true, "requires": { - "bindings": "1.3.0", + "bindings": "1.3.1", "inherits": "2.0.3", - "nan": "2.11.0", + "nan": "2.12.0", "safe-buffer": "5.1.2" }, "dependencies": { @@ -1957,7 +1863,7 @@ "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "4.1.15" } }, "lcid": { @@ -1985,7 +1891,7 @@ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "parse-json": "2.2.0", "pify": "2.3.0", "pinkie-promise": "2.0.1", @@ -2029,9 +1935,9 @@ "dev": true }, "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, "requires": { "pseudomap": "1.0.2", @@ -2056,13 +1962,14 @@ } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "3.0.4", - "inherits": "2.0.1" + "inherits": "2.0.1", + "safe-buffer": "5.1.2" } }, "media-typer": { @@ -2115,18 +2022,18 @@ "dev": true }, "mime-db": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", - "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==", + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", "dev": true }, "mime-types": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", - "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", "dev": true, "requires": { - "mime-db": "1.36.0" + "mime-db": "1.37.0" } }, "mimic-fn": { @@ -2288,9 +2195,9 @@ } }, "nan": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz", - "integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.0.tgz", + "integrity": "sha512-zT5nC0JhbljmyEf+Z456nvm7iO7XgRV2hYxoBtPpnyp+0Q4aCoP6uWNn76v/I6k2kCYNLWqWbwBWQcjsNI/bjw==", "dev": true }, "nano-json-stream-parser": { @@ -2322,7 +2229,7 @@ "requires": { "hosted-git-info": "2.7.1", "is-builtin-module": "1.0.0", - "semver": "5.5.1", + "semver": "5.6.0", "validate-npm-package-license": "3.0.4" } }, @@ -2445,6 +2352,12 @@ "lcid": "1.0.0" } }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, "p-cancelable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", @@ -2500,7 +2413,7 @@ "browserify-aes": "1.2.0", "create-hash": "1.2.0", "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" + "pbkdf2": "3.0.17" } }, "parse-headers": { @@ -2561,15 +2474,15 @@ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "pify": "2.3.0", "pinkie-promise": "2.0.1" } }, "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "1.2.0", @@ -2659,28 +2572,29 @@ "dev": true }, "psl": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", - "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==", + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", "dev": true }, "public-encrypt": { - "version": "4.0.2", - "resolved": "http://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "4.11.8", "browserify-rsa": "4.0.1", "create-hash": "1.2.0", "parse-asn1": "5.1.1", - "randombytes": "2.0.6" + "randombytes": "2.0.6", + "safe-buffer": "5.1.2" } }, "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, "qs": { @@ -2826,13 +2740,13 @@ "combined-stream": "1.0.7", "extend": "3.0.2", "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.1.0", + "form-data": "2.3.3", + "har-validator": "5.1.3", "http-signature": "1.2.0", "is-typedarray": "1.0.0", "isstream": "0.1.2", "json-stringify-safe": "5.0.1", - "mime-types": "2.1.20", + "mime-types": "2.1.21", "oauth-sign": "0.9.0", "performance-now": "2.1.0", "qs": "6.5.2", @@ -2862,7 +2776,7 @@ }, "resolve": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, @@ -2934,7 +2848,7 @@ "integrity": "sha1-BOAUpWgrU/pQwtXM4WfXGcBthw0=", "dev": true, "requires": { - "nan": "2.11.0" + "nan": "2.12.0" } }, "scrypt-js": { @@ -2959,7 +2873,7 @@ "integrity": "sha1-oyJfpLJST4AnAHYeKFW987LZIWM=", "dev": true, "requires": { - "pbkdf2": "3.0.16" + "pbkdf2": "3.0.17" } }, "seek-bzip": { @@ -2983,9 +2897,9 @@ } }, "semver": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", - "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "send": { @@ -3045,8 +2959,8 @@ "dev": true, "requires": { "body-parser": "1.18.3", - "cors": "2.8.4", - "express": "4.16.3", + "cors": "2.8.5", + "express": "4.16.4", "request": "2.88.0", "xhr": "2.5.0" } @@ -3168,16 +3082,18 @@ "dev": true }, "solc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/solc/-/solc-0.5.0.tgz", - "integrity": "sha512-mdLHDl9WeYrN+FIKcMc9PlPfnA9DG9ur5QpCDKcv6VC4RINAsTF4EMuXMZMKoQTvZhtLyJIVH/BZ+KU830Z8Xg==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/solc/-/solc-0.5.1.tgz", + "integrity": "sha512-+RJfa5zRpWBm8DhEiEScIzEzPHWppwHSp/2yV9qvM/lNr0Y8cCv2mcNiXy+R6SSV0OoskhPEfe6Fwa4QQEgxlg==", "dev": true, "requires": { + "command-exists": "1.2.8", "fs-extra": "0.30.0", "keccak": "1.4.0", "memorystream": "0.3.1", "require-from-string": "2.0.2", - "semver": "5.5.1", + "semver": "5.6.0", + "tmp": "0.0.33", "yargs": "11.1.0" }, "dependencies": { @@ -3300,7 +3216,7 @@ "shelljs": "0.7.8", "sol-explore": "1.6.2", "solidity-parser-sc": "0.4.11", - "tree-kill": "1.2.0", + "tree-kill": "1.2.1", "web3": "0.18.4" }, "dependencies": { @@ -3463,19 +3379,19 @@ } }, "spdx-correct": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", - "spdx-license-ids": "3.0.1" + "spdx-license-ids": "3.0.2" } }, "spdx-exceptions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, "spdx-expression-parse": { @@ -3484,26 +3400,26 @@ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { - "spdx-exceptions": "2.1.0", - "spdx-license-ids": "3.0.1" + "spdx-exceptions": "2.2.0", + "spdx-license-ids": "3.0.2" } }, "spdx-license-ids": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.1.tgz", - "integrity": "sha512-TfOfPcYGBB5sDuPn3deByxPhmfegAhpDYKSOXZQN81Oyrrif8ZCodOLzK3AesELnCx03kikhyDwh0pfvvQvF8w==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.2.tgz", + "integrity": "sha512-qky9CVt0lVIECkEsYbNILVnPvycuEBkXoMFLRWsREkomQLevYhtRKC+R91a5TOAQ3bCMjikRwhyaRqj1VYatYg==", "dev": true }, "sprintf-js": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "resolved": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, "sshpk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", - "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", "dev": true, "requires": { "asn1": "0.2.4", @@ -3531,7 +3447,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -3606,14 +3522,14 @@ "integrity": "sha512-G8gi5fcXP/2upwiuOShJ258sIufBVztekgobr3cVgYXObZwJ5AXLqZn52AI+/ffft29pJexF9WNdUxjlkVehoQ==", "dev": true, "requires": { - "bluebird": "3.5.2", + "bluebird": "3.5.3", "buffer": "5.2.1", "decompress": "4.2.0", "eth-lib": "0.1.27", "fs-extra": "2.1.2", "fs-promise": "2.0.3", "got": "7.1.0", - "mime-types": "2.1.20", + "mime-types": "2.1.21", "mkdirp-promise": "5.0.1", "mock-fs": "4.7.0", "setimmediate": "1.0.5", @@ -3627,7 +3543,7 @@ "integrity": "sha1-BGxwFjzvmq1GsOSn+kZ/si1x3jU=", "dev": true, "requires": { - "graceful-fs": "4.1.11", + "graceful-fs": "4.1.15", "jsonfile": "2.4.0" } } @@ -3710,6 +3626,15 @@ "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", "dev": true }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, "to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", @@ -3722,14 +3647,22 @@ "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "dev": true, "requires": { - "psl": "1.1.29", + "psl": "1.1.31", "punycode": "1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } } }, "tree-kill": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.0.tgz", - "integrity": "sha512-DlX6dR0lOIRDFxI0mjL9IYg6OTncLm/Zt+JiBhE5OlFcAR8yc9S7FFXU9so0oda47frdM/JFsk7UjNt9vscKcg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", + "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", "dev": true }, "trim": { @@ -3746,7 +3679,7 @@ "requires": { "mocha": "4.1.0", "original-require": "1.0.1", - "solc": "0.5.0" + "solc": "0.5.1" } }, "tunnel-agent": { @@ -3762,8 +3695,7 @@ "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true + "dev": true }, "type-check": { "version": "0.3.2", @@ -3781,7 +3713,7 @@ "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "2.1.20" + "mime-types": "2.1.21" } }, "typedarray-to-buffer": { @@ -3811,9 +3743,9 @@ "dev": true }, "unbzip2-stream": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.0.tgz", - "integrity": "sha512-kE2WkurNnPUMcryNioS68DDbhoPB8Qxsd8btHSj+sd5Pjh2GsjmeHLzMSqV9HHziAo8FzVxVCJl9ZYhk7yY1pA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.1.tgz", + "integrity": "sha512-fIZnvdjblYs7Cru/xC6tCPVhz7JkYcVQQkePwMLyQELzYTds2Xn8QefPVnvdVhhZqubxNA1cASXEH5wcK0Bucw==", "dev": true, "requires": { "buffer": "3.6.0", @@ -3841,7 +3773,7 @@ }, "underscore": { "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", "dev": true }, @@ -3851,6 +3783,15 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "2.1.1" + } + }, "url-parse-lax": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", @@ -3911,7 +3852,7 @@ "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { - "spdx-correct": "3.0.0", + "spdx-correct": "3.1.0", "spdx-expression-parse": "3.0.0" } }, @@ -4249,7 +4190,7 @@ "dev": true, "requires": { "debug": "2.6.9", - "nan": "2.11.0", + "nan": "2.12.0", "typedarray-to-buffer": "3.1.5", "yaeti": "0.0.6" }, diff --git a/test/gateway/eip20_cogateway/helpers/helper.js b/test/gateway/eip20_cogateway/helpers/helper.js new file mode 100644 index 00000000..a9e4626c --- /dev/null +++ b/test/gateway/eip20_cogateway/helpers/helper.js @@ -0,0 +1,80 @@ +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ---------------------------------------------------------------------------- +// +// http://www.simpletoken.org/ +// +// ---------------------------------------------------------------------------- + +'use strict'; + +const web3 = require('../../../test_lib/web3.js'); + + +const EIP20CoGatewayHelper = function () { + +}; + +EIP20CoGatewayHelper.prototype = { + + /** + * Generate the redeem type hash. This is as per EIP-712. + * + * @return {string} Message type hash. + */ + redeemTypeHash: async function () { + return web3.utils.soliditySha3( + 'string', + 'Redeem(uint256 amount,address beneficiary,MessageBus.Message message)', + ); + }, + + /** + * Generate the redeem intent hash. + * + * @param {object} amount Redeem amount. + * @param {string} beneficiary Beneficiary address. + * @param {string} redeemer Redeemer address. + * @param {object} nonce Nonce of staker (Big Number). + * @param {object} gasPrice Gas price (Big Number). + * @param {object} gasLimit Gas limit (Big Number). + * @param {string} token EIP20 token address. + * + * @return {string} Redeem intent hash. + */ + hashRedeemIntent: async function ( + amount, + beneficiary, + redeemer, + nonce, + gasPrice, + gasLimit, + token + ) { + + return web3.utils.soliditySha3( + {t: 'uint256', v: amount}, + {t: 'address', v: beneficiary}, + {t: 'address', v: redeemer}, + {t: 'uint256', v: nonce}, + {t: 'uint256', v: gasPrice}, + {t: 'uint256', v: gasLimit}, + {t: 'address', v: token}, + ); + }, + +}; + +module.exports = EIP20CoGatewayHelper; diff --git a/test/gateway/eip20_cogateway/progress_mint.js b/test/gateway/eip20_cogateway/progress_mint.js new file mode 100644 index 00000000..99cefbfc --- /dev/null +++ b/test/gateway/eip20_cogateway/progress_mint.js @@ -0,0 +1,419 @@ +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ---------------------------------------------------------------------------- +// +// http://www.simpletoken.org/ +// +// ---------------------------------------------------------------------------- + +const BN = require('bn.js'), + Utils = require('../../test_lib/utils'), + EIP20CoGatewayHelper = require('./helpers/helper'), + MessageBus = artifacts.require('MessageBus'), + EIP20Token = artifacts.require('EIP20Token'), + TestEIP20CoGateway = artifacts.require('TestEIP20CoGateway'), + TestUtilityToken = artifacts.require('TestUtilityToken'); + +let valueToken, + burner, + mockSafeCore, + membersManager, + coGateway, + testUtilityToken, + bountyAmount, + owner, + staker, + stakerBalance, + rewardAmount, + symbol = 'OST', + name = 'Simple Token', + decimals = 18, + helper; + +const zeroBytes = + "0x0000000000000000000000000000000000000000000000000000000000000000"; + +let MessageStatusEnum = { + Undeclared: 0, + Declared: 1, + Progressed: 2, + DeclaredRevocation: 3, + Revoked: 4 +}; + +async function _setup(accounts) { + + valueToken = accounts[0]; + burner = accounts[10]; + mockSafeCore = accounts[11]; + membersManager = accounts[2]; + coGateway = accounts[3]; + owner = accounts[8]; + testUtilityToken = await TestUtilityToken.new( + valueToken, + symbol, + name, + decimals, + membersManager + ); + bountyAmount = new BN(100); + staker = accounts[7]; + stakerBalance = new BN(1000000); + rewardAmount = new BN(100); + +} + +contract('EIP20CoGateway.progressMint() ', function (accounts) { + + let amount = new BN(200), + beneficiary = accounts[4], + gasPrice, + gasLimit, + nonce = new BN(1), + hashLockObj = Utils.generateHashLock(), + facilitator = accounts[5], + intentHash, + hashLock, + unlockSecret, + testEIP20CoGateway, + messageHash; + helper = new EIP20CoGatewayHelper(); + + beforeEach(async function () { + + await _setup(accounts); + amount = new BN(200); + hashLock = hashLockObj.l; + unlockSecret = hashLockObj.s; + gasPrice = new BN(10); + gasLimit = new BN(10); + + intentHash = await helper.hashRedeemIntent( + amount, + beneficiary, + facilitator, + nonce, + gasPrice, + gasLimit, + valueToken, + ); + testEIP20CoGateway = await TestEIP20CoGateway.new( + valueToken, + testUtilityToken.address, + mockSafeCore, + bountyAmount, + membersManager, + coGateway, + burner, + ); + + await testUtilityToken.setCoGatewayAddress(testEIP20CoGateway.address); + + messageHash = await testEIP20CoGateway.setStakeMessage.call( + intentHash, + nonce, + gasPrice, + gasLimit, + hashLock, + staker, + ); + await testEIP20CoGateway.setStakeMessage( + intentHash, + nonce, + gasPrice, + gasLimit, + hashLock, + staker, + ); + + await testEIP20CoGateway.setMints(messageHash, beneficiary, amount); + + }); + + it('should progress mint for non-zero facilitator reward', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Declared, + ); + + let progressMintValues = await testEIP20CoGateway.progressMint.call( + messageHash, + unlockSecret, + {from: facilitator}, + ); + + let expectedMintedToken = new BN(100), + expectedReward = new BN(100); + + assert.strictEqual( + progressMintValues.beneficiary_, + beneficiary, + `Beneficiary address should be ${beneficiary}`, + ); + + assert.strictEqual( + amount.eq(progressMintValues.stakeAmount_), + true, + `Staked amount should be ${amount}.`, + ); + + assert.strictEqual( + expectedMintedToken.eq(progressMintValues.mintedAmount_), + true, + `Minted amount should be ${expectedMintedToken}.`, + ); + + assert.strictEqual( + expectedReward.eq(progressMintValues.rewardAmount_), + true, + `Reward to facilitator should be ${expectedReward}.`, + ); + + let response = await testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ); + + let facilitatorBalance = await testUtilityToken.balanceOf(facilitator); + let beneficiaryBalance = await testUtilityToken.balanceOf(beneficiary); + + assert.strictEqual( + facilitatorBalance.eq(expectedReward), + true, + `Facilitator reward should be ${expectedReward}.`, + ); + + assert.strictEqual( + beneficiaryBalance.eq(amount.sub(expectedReward)), + true, + `Beneficiary balance should be ${amount.sub(expectedReward)}.` + ); + + let expectedEvent = { + MintProgressed: { + _messageHash: messageHash, + _staker: staker, + _stakeAmount: amount, + _mintedAmount: expectedMintedToken, + _rewardAmount: expectedReward, + _proofProgress: false, + _unlockSecret: unlockSecret + } + }; + + assert.equal( + response.receipt.status, + 1, + 'Receipt status is unsuccessful.', + ); + + let eventData = response.logs; + Utils.validateEvents(eventData, expectedEvent); + + }); + + it('should progress mint for zero facilitator reward', async function () { + + gasPrice = new BN(0); + + let messageHash = await testEIP20CoGateway.setStakeMessage.call( + intentHash, + nonce, + gasPrice, + gasLimit, + hashLock, + staker, + ); + + await testEIP20CoGateway.setStakeMessage( + intentHash, + nonce, + gasPrice, + gasLimit, + hashLock, + staker, + ); + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Declared, + ); + await testEIP20CoGateway.setMints(messageHash, beneficiary, amount); + + let response = await testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ); + + let facilitatorBalance = await testUtilityToken.balanceOf(facilitator); + let beneficiaryBalance = await testUtilityToken.balanceOf(beneficiary); + + assert.strictEqual( + beneficiaryBalance.eq(amount), + true, + `Balance for beneficiary should be ${amount}`, + ); + + assert.strictEqual( + facilitatorBalance.eq(new BN(0)), + true, + 'Facilitator reward should be zero', + ); + + let expectedEvent = { + MintProgressed: { + _messageHash: messageHash, + _staker: staker, + _stakeAmount: amount, + _mintedAmount: amount, + _rewardAmount: new BN(0), + _proofProgress: false, + _unlockSecret: unlockSecret + } + }; + + assert.equal( + response.receipt.status, + 1, + 'Receipt status is unsuccessful.', + ); + + let eventData = response.logs; + Utils.validateEvents(eventData, expectedEvent); + + }); + + it('should fail when messagehash is zero', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Declared, + ); + + messageHash = zeroBytes; + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Message hash must not be zero.', + ); + + }); + + it('should fail when message status is declared revocation', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.DeclaredRevocation, + ); + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Message on target status must be Declared.', + ); + + }); + + it('should fail when message status is revoked', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Revoked, + ); + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Message on target status must be Declared.', + ); + + }); + + it('should fail when message status is undeclared', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Undeclared, + ); + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Message on target status must be Declared.', + ); + + }); + + it('should fail when unlock secret is invalid', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Undeclared, + ); + + unlockSecret = zeroBytes; + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Invalid unlock secret.', + ); + + }); + + it('should fail when message status is already progressed', async function () { + + await testEIP20CoGateway.setInboxStatus( + messageHash, + MessageStatusEnum.Declared, + ); + + await testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ); + + await Utils.expectRevert( + testEIP20CoGateway.progressMint( + messageHash, + unlockSecret, + {from: facilitator}, + ), + 'Message on target status must be Declared.', + ); + + }); + +}); +