From 520d563eadc3b45d36163d5b5ad4ada0d0cbaee0 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 9 Oct 2019 17:14:21 +0300 Subject: [PATCH 01/80] use hex-identifiers directly --- contracts/mocks/FeeManagerMock.sol | 2 +- .../upgradeable_contracts/BaseBridgeValidators.sol | 4 ++-- contracts/upgradeable_contracts/BaseFeeManager.sol | 4 ++-- .../BaseOverdrawManagement.sol | 2 +- contracts/upgradeable_contracts/BasicBridge.sol | 5 +++-- .../upgradeable_contracts/BasicTokenBridge.sol | 13 +++++++------ .../upgradeable_contracts/BlockRewardBridge.sol | 3 ++- contracts/upgradeable_contracts/ERC20Bridge.sol | 2 +- contracts/upgradeable_contracts/ERC677Storage.sol | 2 +- contracts/upgradeable_contracts/FeeTypes.sol | 4 ++-- contracts/upgradeable_contracts/Initializable.sol | 4 ++-- contracts/upgradeable_contracts/Ownable.sol | 6 ++++-- contracts/upgradeable_contracts/ReentrancyGuard.sol | 2 +- .../upgradeable_contracts/RewardableBridge.sol | 2 +- .../upgradeable_contracts/ValidatorStorage.sol | 2 +- .../amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol | 10 +++++----- .../arbitrary_message/BasicAMB.sol | 4 ++-- .../arbitrary_message/MessageProcessor.sol | 4 ++-- .../erc20_to_erc20/BasicForeignBridgeErcToErc.sol | 2 +- .../erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol | 2 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 2 +- .../erc20_to_native/FeeManagerErcToNative.sol | 2 +- .../erc20_to_native/FeeManagerErcToNativePOSDAO.sol | 2 +- .../erc20_to_native/ForeignBridgeErcToNative.sol | 2 +- .../erc20_to_native/HomeBridgeErcToNative.sol | 4 ++-- .../native_to_erc20/FeeManagerNativeToErc.sol | 2 +- .../FeeManagerNativeToErcBothDirections.sol | 2 +- .../native_to_erc20/ForeignBridgeNativeToErc.sol | 2 +- .../native_to_erc20/HomeBridgeNativeToErc.sol | 2 +- 29 files changed, 52 insertions(+), 47 deletions(-) diff --git a/contracts/mocks/FeeManagerMock.sol b/contracts/mocks/FeeManagerMock.sol index 01af6b823..be5e57f73 100644 --- a/contracts/mocks/FeeManagerMock.sol +++ b/contracts/mocks/FeeManagerMock.sol @@ -12,7 +12,7 @@ contract FeeManagerMock is BaseFeeManager { } function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-one-direction"))); + return 0xf2aed8f7; // "manages-one-direction" } function randomTest(uint256 _count) external view returns (uint256) { diff --git a/contracts/upgradeable_contracts/BaseBridgeValidators.sol b/contracts/upgradeable_contracts/BaseBridgeValidators.sol index 854b6dfae..8d1a3208b 100644 --- a/contracts/upgradeable_contracts/BaseBridgeValidators.sol +++ b/contracts/upgradeable_contracts/BaseBridgeValidators.sol @@ -9,8 +9,8 @@ contract BaseBridgeValidators is Initializable, Ownable { address public constant F_ADDR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF; uint256 internal constant MAX_VALIDATORS = 100; - bytes32 internal constant REQUIRED_SIGNATURES = keccak256(abi.encodePacked("requiredSignatures")); - bytes32 internal constant VALIDATOR_COUNT = keccak256(abi.encodePacked("validatorCount")); + bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // "requiredSignatures" + bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // "validatorCount" event ValidatorAdded(address indexed validator); event ValidatorRemoved(address indexed validator); diff --git a/contracts/upgradeable_contracts/BaseFeeManager.sol b/contracts/upgradeable_contracts/BaseFeeManager.sol index 2a520bddc..38fc846f5 100644 --- a/contracts/upgradeable_contracts/BaseFeeManager.sol +++ b/contracts/upgradeable_contracts/BaseFeeManager.sol @@ -13,8 +13,8 @@ contract BaseFeeManager is EternalStorage, FeeTypes { // This is not a real fee value but a relative value used to calculate the fee percentage uint256 internal constant MAX_FEE = 1 ether; - bytes32 internal constant HOME_FEE_STORAGE_KEY = keccak256(abi.encodePacked("homeFee")); - bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = keccak256(abi.encodePacked("foreignFee")); + bytes32 internal constant HOME_FEE_STORAGE_KEY = 0xc3781f3cec62d28f56efe98358f59c2105504b194242dbcb2cc0806850c306e7; // "homeFee" + bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = 0x68c305f6c823f4d2fa4140f9cf28d32a1faccf9b8081ff1c2de11cf32c733efc; // "foreignFee" function calculateFee(uint256 _value, bool _recover, bytes32 _feeType) public view returns (uint256) { uint256 fee = _feeType == HOME_FEE ? getHomeFee() : getForeignFee(); diff --git a/contracts/upgradeable_contracts/BaseOverdrawManagement.sol b/contracts/upgradeable_contracts/BaseOverdrawManagement.sol index 4482e8ec0..c56765697 100644 --- a/contracts/upgradeable_contracts/BaseOverdrawManagement.sol +++ b/contracts/upgradeable_contracts/BaseOverdrawManagement.sol @@ -6,7 +6,7 @@ contract BaseOverdrawManagement is EternalStorage { event AmountLimitExceeded(address recipient, uint256 value, bytes32 transactionHash); event AssetAboveLimitsFixed(bytes32 indexed transactionHash, uint256 value, uint256 remaining); - bytes32 internal constant OUT_OF_LIMIT_AMOUNT = keccak256(abi.encodePacked("outOfLimitAmount")); + bytes32 internal constant OUT_OF_LIMIT_AMOUNT = 0x145286dc85799b6fb9fe322391ba2d95683077b2adf34dd576dedc437e537ba7; // "outOfLimitAmount" function outOfLimitAmount() public view returns (uint256) { return uintStorage[OUT_OF_LIMIT_AMOUNT]; diff --git a/contracts/upgradeable_contracts/BasicBridge.sol b/contracts/upgradeable_contracts/BasicBridge.sol index 35e07904b..23d62d859 100644 --- a/contracts/upgradeable_contracts/BasicBridge.sol +++ b/contracts/upgradeable_contracts/BasicBridge.sol @@ -12,8 +12,9 @@ contract BasicBridge is Initializable, Validatable, Ownable, Upgradeable, Claima event GasPriceChanged(uint256 gasPrice); event RequiredBlockConfirmationChanged(uint256 requiredBlockConfirmations); - bytes32 internal constant GAS_PRICE = keccak256(abi.encodePacked("gasPrice")); - bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = keccak256(abi.encodePacked("requiredBlockConfirmations")); + bytes32 internal constant GAS_PRICE = 0x55b3774520b5993024893d303890baa4e84b1244a43c60034d1ced2d3cf2b04b; // "gasPrice" + bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = + 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // "requiredBlockConfirmations" function setGasPrice(uint256 _gasPrice) external onlyOwner { require(_gasPrice > 0); diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 0b12e2866..823c93ec7 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -10,12 +10,13 @@ contract BasicTokenBridge is EternalStorage, Ownable { event DailyLimitChanged(uint256 newLimit); event ExecutionDailyLimitChanged(uint256 newLimit); - bytes32 internal constant MIN_PER_TX = keccak256(abi.encodePacked("minPerTx")); - bytes32 internal constant MAX_PER_TX = keccak256(abi.encodePacked("maxPerTx")); - bytes32 internal constant DAILY_LIMIT = keccak256(abi.encodePacked("dailyLimit")); - bytes32 internal constant EXECUTION_MAX_PER_TX = keccak256(abi.encodePacked("executionMaxPerTx")); - bytes32 internal constant EXECUTION_DAILY_LIMIT = keccak256(abi.encodePacked("executionDailyLimit")); - bytes32 internal constant DECIMAL_SHIFT = keccak256(abi.encodePacked("decimalShift")); + bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // "minPerTx" + bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // "maxPerTx" + bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // "dailyLimit" + bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // "executionMaxPerTx" + bytes32 internal constant EXECUTION_DAILY_LIMIT = + 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // "executionDailyLimit" + bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // "decimalShift" function totalSpentPerDay(uint256 _day) public view returns (uint256) { return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))]; diff --git a/contracts/upgradeable_contracts/BlockRewardBridge.sol b/contracts/upgradeable_contracts/BlockRewardBridge.sol index 1441f9a0c..91647d622 100644 --- a/contracts/upgradeable_contracts/BlockRewardBridge.sol +++ b/contracts/upgradeable_contracts/BlockRewardBridge.sol @@ -5,7 +5,8 @@ import "../upgradeability/EternalStorage.sol"; import "openzeppelin-solidity/contracts/AddressUtils.sol"; contract BlockRewardBridge is EternalStorage { - bytes32 internal constant BLOCK_REWARD_CONTRACT = keccak256(abi.encodePacked("blockRewardContract")); + bytes32 internal constant BLOCK_REWARD_CONTRACT = + 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // "blockRewardContract" bytes4 internal constant BLOCK_REWARD_CONTRACT_ID = 0x2ee57f8d; // blockRewardContractId() bytes4 internal constant BRIDGES_ALLOWED_LENGTH = 0x10f2ee7c; // bridgesAllowedLength() diff --git a/contracts/upgradeable_contracts/ERC20Bridge.sol b/contracts/upgradeable_contracts/ERC20Bridge.sol index b14a09516..12b826a14 100644 --- a/contracts/upgradeable_contracts/ERC20Bridge.sol +++ b/contracts/upgradeable_contracts/ERC20Bridge.sol @@ -5,7 +5,7 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; import "openzeppelin-solidity/contracts/AddressUtils.sol"; contract ERC20Bridge is EternalStorage { - bytes32 internal constant ERC20_TOKEN = keccak256(abi.encodePacked("erc20token")); + bytes32 internal constant ERC20_TOKEN = 0x15d63b18dbc21bf4438b7972d80076747e1d93c4f87552fe498c90cbde51665e; // "erc20token" function erc20token() public view returns (ERC20Basic) { return ERC20Basic(addressStorage[ERC20_TOKEN]); diff --git a/contracts/upgradeable_contracts/ERC677Storage.sol b/contracts/upgradeable_contracts/ERC677Storage.sol index ff9de3170..a65a818ce 100644 --- a/contracts/upgradeable_contracts/ERC677Storage.sol +++ b/contracts/upgradeable_contracts/ERC677Storage.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ERC677Storage { - bytes32 internal constant ERC677_TOKEN = keccak256(abi.encodePacked("erc677token")); + bytes32 internal constant ERC677_TOKEN = 0xa8b0ade3e2b734f043ce298aca4cc8d19d74270223f34531d0988b7d00cba21d; // "erc677token" } diff --git a/contracts/upgradeable_contracts/FeeTypes.sol b/contracts/upgradeable_contracts/FeeTypes.sol index 334980462..65365eee5 100644 --- a/contracts/upgradeable_contracts/FeeTypes.sol +++ b/contracts/upgradeable_contracts/FeeTypes.sol @@ -1,6 +1,6 @@ pragma solidity 0.4.24; contract FeeTypes { - bytes32 internal constant HOME_FEE = keccak256(abi.encodePacked("home-fee")); - bytes32 internal constant FOREIGN_FEE = keccak256(abi.encodePacked("foreign-fee")); + bytes32 internal constant HOME_FEE = 0x89d93e5e92f7e37e490c25f0e50f7f4aad7cc94b308a566553280967be38bcf1; // "home-fee" + bytes32 internal constant FOREIGN_FEE = 0xdeb7f3adca07d6d1f708c1774389db532a2b2f18fd05a62b957e4089f4696ed5; // "foreign-fee" } diff --git a/contracts/upgradeable_contracts/Initializable.sol b/contracts/upgradeable_contracts/Initializable.sol index 12b41b8c3..5fe22819b 100644 --- a/contracts/upgradeable_contracts/Initializable.sol +++ b/contracts/upgradeable_contracts/Initializable.sol @@ -3,8 +3,8 @@ pragma solidity 0.4.24; import "../upgradeability/EternalStorage.sol"; contract Initializable is EternalStorage { - bytes32 internal constant INITIALIZED = keccak256(abi.encodePacked("isInitialized")); - bytes32 internal constant DEPLOYED_AT_BLOCK = keccak256(abi.encodePacked("deployedAtBlock")); + bytes32 internal constant INITIALIZED = 0x0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba; // "isInitialized" + bytes32 internal constant DEPLOYED_AT_BLOCK = 0xb120ceec05576ad0c710bc6e85f1768535e27554458f05dcbb5c65b8c7a749b0; // "deployedAtBlock" function setInitialize() internal { boolStorage[INITIALIZED] = true; diff --git a/contracts/upgradeable_contracts/Ownable.sol b/contracts/upgradeable_contracts/Ownable.sol index bf2d7a744..b6efcf507 100644 --- a/contracts/upgradeable_contracts/Ownable.sol +++ b/contracts/upgradeable_contracts/Ownable.sol @@ -23,12 +23,14 @@ contract Ownable is EternalStorage { _; } + bytes32 internal constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; // "owner" + /** * @dev Tells the address of the owner * @return the address of the owner */ function owner() public view returns (address) { - return addressStorage[keccak256(abi.encodePacked("owner"))]; + return addressStorage[OWNER]; } /** @@ -45,6 +47,6 @@ contract Ownable is EternalStorage { */ function setOwner(address newOwner) internal { emit OwnershipTransferred(owner(), newOwner); - addressStorage[keccak256(abi.encodePacked("owner"))] = newOwner; + addressStorage[OWNER] = newOwner; } } diff --git a/contracts/upgradeable_contracts/ReentrancyGuard.sol b/contracts/upgradeable_contracts/ReentrancyGuard.sol index 8df9be0b1..9a76daffd 100644 --- a/contracts/upgradeable_contracts/ReentrancyGuard.sol +++ b/contracts/upgradeable_contracts/ReentrancyGuard.sol @@ -3,7 +3,7 @@ pragma solidity 0.4.24; import "../upgradeability/EternalStorage.sol"; contract ReentrancyGuard is EternalStorage { - bytes32 internal constant LOCK = keccak256(abi.encodePacked("lock")); + bytes32 internal constant LOCK = 0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92; // "lock" function lock() internal returns (bool) { return boolStorage[LOCK]; diff --git a/contracts/upgradeable_contracts/RewardableBridge.sol b/contracts/upgradeable_contracts/RewardableBridge.sol index e72ac30ae..443ed6f5c 100644 --- a/contracts/upgradeable_contracts/RewardableBridge.sol +++ b/contracts/upgradeable_contracts/RewardableBridge.sol @@ -8,7 +8,7 @@ contract RewardableBridge is Ownable, FeeTypes { event FeeDistributedFromAffirmation(uint256 feeAmount, bytes32 indexed transactionHash); event FeeDistributedFromSignatures(uint256 feeAmount, bytes32 indexed transactionHash); - bytes32 internal constant FEE_MANAGER_CONTRACT = keccak256(abi.encodePacked("feeManagerContract")); + bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3e2f2516078c38c68a3149787976ee837e5; // "feeManagerContract" bytes4 internal constant GET_HOME_FEE = 0x94da17cd; // getHomeFee() bytes4 internal constant GET_FOREIGN_FEE = 0xffd66196; // getForeignFee() bytes4 internal constant GET_FEE_MANAGER_MODE = 0xf2ba9561; // getFeeManagerMode() diff --git a/contracts/upgradeable_contracts/ValidatorStorage.sol b/contracts/upgradeable_contracts/ValidatorStorage.sol index c14d4a5af..4afd51140 100644 --- a/contracts/upgradeable_contracts/ValidatorStorage.sol +++ b/contracts/upgradeable_contracts/ValidatorStorage.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ValidatorStorage { - bytes32 internal constant VALIDATOR_CONTRACT = keccak256(abi.encodePacked("validatorContract")); + bytes32 internal constant VALIDATOR_CONTRACT = 0x5a74bb7e202fb8e4bf311841c7d64ec19df195fee77d7e7ae749b27921b6ddfe; // "validatorContract" } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 37607fe05..69079d3d1 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -24,10 +24,10 @@ contract BasicAMBErc677ToErc677 is { event FailedMessageFixed(bytes32 indexed dataHash, address recipient, uint256 value); - bytes32 internal constant BRIDGE_CONTRACT = keccak256(abi.encodePacked("bridgeContract")); - bytes32 internal constant MEDIATOR_CONTRACT = keccak256(abi.encodePacked("mediatorContract")); - bytes32 internal constant REQUEST_GAS_LIMIT = keccak256(abi.encodePacked("requestGasLimit")); - bytes32 internal constant NONCE = keccak256(abi.encodePacked("nonce")); + bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // "bridgeContract" + bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // "mediatorContract" + bytes32 internal constant REQUEST_GAS_LIMIT = 0x2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be; // "requestGasLimit" + bytes32 internal constant NONCE = 0x7ab1577440dd7bedf920cb6de2f9fc6bf7ba98c78c85a3fa1f8311aac95e1759; // "nonce" function initialize( address _bridgeContract, @@ -102,7 +102,7 @@ contract BasicAMBErc677ToErc677 is } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("erc-to-erc-amb"))); + return 0x76595b56; // "erc-to-erc-amb" } function setBridgeContract(address _bridgeContract) external onlyOwner { diff --git a/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol b/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol index 84eb575c8..d73f89b38 100644 --- a/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol +++ b/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol @@ -3,7 +3,7 @@ pragma solidity 0.4.24; import "../BasicBridge.sol"; contract BasicAMB is BasicBridge { - bytes32 internal constant MAX_GAS_PER_TX = keccak256(abi.encodePacked("maxGasPerTx")); + bytes32 internal constant MAX_GAS_PER_TX = 0x2670ecc91ec356e32067fd27b36614132d727b84a1e03e08f412a4f2cf075974; // "maxGasPerTx" function initialize( address _validatorContract, @@ -32,7 +32,7 @@ contract BasicAMB is BasicBridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("arbitrary-message-bridge-core"))); + return 0x2544fbb9; // "arbitrary-message-bridge-core" } function maxGasPerTx() public view returns (uint256) { diff --git a/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol b/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol index 16792b3c1..02d263dcb 100644 --- a/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol +++ b/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol @@ -4,8 +4,8 @@ import "../../upgradeability/EternalStorage.sol"; import "../../libraries/Bytes.sol"; contract MessageProcessor is EternalStorage { - bytes32 internal constant MESSAGE_SENDER = keccak256(abi.encodePacked("messageSender")); - bytes32 internal constant TRANSACTION_HASH = keccak256(abi.encodePacked("transactionHash")); + bytes32 internal constant MESSAGE_SENDER = 0x7b58b2a669d8e0992eae9eaef641092c0f686fd31070e7236865557fa1571b5b; // "messageSender" + bytes32 internal constant TRANSACTION_HASH = 0x7bce44346b9831b0c81437a092605c6fc51612016e2c51e62f21d829e434bcf6; // "transactionHash" function messageCallStatus(bytes32 _txHash) external view returns (bool) { return boolStorage[keccak256(abi.encodePacked("messageCallStatus", _txHash))]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index b6cbc1406..834de2919 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -38,7 +38,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("erc-to-erc-core"))); + return 0xba4690f5; // "erc-to-erc-core" } function claimTokens(address _token, address _to) public { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol index 5d1e83976..572ada424 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol @@ -4,7 +4,7 @@ import "../BlockRewardFeeManager.sol"; contract FeeManagerErcToErcPOSDAO is BlockRewardFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-both-directions"))); + return 0xd7de965f; // "manages-both-directions" } function blockRewardContract() external view returns (address) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 74b2cc492..9944cfd98 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -141,7 +141,7 @@ contract HomeBridgeErcToErc is } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("erc-to-erc-core"))); + return 0xba4690f5; // "erc-to-erc-core" } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol index 30a6cec51..ce7e951fe 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol @@ -7,7 +7,7 @@ import "../BlockRewardBridge.sol"; contract FeeManagerErcToNative is ValidatorsFeeManager, BlockRewardBridge { function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-both-directions"))); + return 0xd7de965f; // "manages-both-directions" } function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol index ef4e24f63..1bbcc1f03 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol @@ -5,7 +5,7 @@ import "../BlockRewardFeeManager.sol"; contract FeeManagerErcToNativePOSDAO is BlockRewardFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-both-directions"))); + return 0xd7de965f; // "manages-both-directions" } function distributeFeeFromBlockReward(uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 712174b89..18061f5c9 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -42,7 +42,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("erc-to-native-core"))); + return 0x18762d46; // "erc-to-native-core" } function claimTokens(address _token, address _to) public { diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index c8ec25739..cb227b416 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -16,7 +16,7 @@ contract HomeBridgeErcToNative is RewardableHomeBridgeErcToNative, BlockRewardBridge { - bytes32 internal constant TOTAL_BURNT_COINS = keccak256(abi.encodePacked("totalBurntCoins")); + bytes32 internal constant TOTAL_BURNT_COINS = 0x17f187b2e5d1f8770602b32c1159b85c9600859277fae1eaa9982e9bcf63384c; // "totalBurntCoins" function() public payable { nativeTransfer(); @@ -101,7 +101,7 @@ contract HomeBridgeErcToNative is } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("erc-to-native-core"))); + return 0x18762d46; // "erc-to-native-core" } function blockRewardContract() public view returns (IBlockReward) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol index 032c82ca5..c519c357a 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol @@ -7,7 +7,7 @@ import "../ERC677Storage.sol"; contract FeeManagerNativeToErc is ValidatorsFeeManager, ERC677Storage { function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-one-direction"))); + return 0xf2aed8f7; // "manages-one-direction" } function erc677token() public view returns (IBurnableMintableERC677Token) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol index b61f44599..6fb2e035f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol @@ -5,7 +5,7 @@ import "../ValidatorsFeeManager.sol"; contract FeeManagerNativeToErcBothDirections is ValidatorsFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return bytes4(keccak256(abi.encodePacked("manages-both-directions"))); + return 0xd7de965f; // "manages-both-directions" } function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index b77c9716d..19425a14f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -68,7 +68,7 @@ contract ForeignBridgeNativeToErc is } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("native-to-erc-core"))); + return 0x92a8d7fe; // "native-to-erc-core" } function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 07ea687e1..68cce44f8 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -76,7 +76,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom } function getBridgeMode() external pure returns (bytes4 _data) { - return bytes4(keccak256(abi.encodePacked("native-to-erc-core"))); + return 0x92a8d7fe; // "native-to-erc-core" } function _initialize( From 8f7bbb88acf4eda77683a09593e49c531ece773e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 10 Oct 2019 10:15:41 +0300 Subject: [PATCH 02/80] fix linter errors --- contracts/upgradeable_contracts/BasicBridge.sol | 3 +-- contracts/upgradeable_contracts/BasicTokenBridge.sol | 3 +-- contracts/upgradeable_contracts/BlockRewardBridge.sol | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/contracts/upgradeable_contracts/BasicBridge.sol b/contracts/upgradeable_contracts/BasicBridge.sol index 23d62d859..4a7ed8737 100644 --- a/contracts/upgradeable_contracts/BasicBridge.sol +++ b/contracts/upgradeable_contracts/BasicBridge.sol @@ -13,8 +13,7 @@ contract BasicBridge is Initializable, Validatable, Ownable, Upgradeable, Claima event RequiredBlockConfirmationChanged(uint256 requiredBlockConfirmations); bytes32 internal constant GAS_PRICE = 0x55b3774520b5993024893d303890baa4e84b1244a43c60034d1ced2d3cf2b04b; // "gasPrice" - bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = - 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // "requiredBlockConfirmations" + bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // "requiredBlockConfirmations" function setGasPrice(uint256 _gasPrice) external onlyOwner { require(_gasPrice > 0); diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 823c93ec7..6d7b77f81 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -14,8 +14,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // "maxPerTx" bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // "dailyLimit" bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // "executionMaxPerTx" - bytes32 internal constant EXECUTION_DAILY_LIMIT = - 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // "executionDailyLimit" + bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // "executionDailyLimit" bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // "decimalShift" function totalSpentPerDay(uint256 _day) public view returns (uint256) { diff --git a/contracts/upgradeable_contracts/BlockRewardBridge.sol b/contracts/upgradeable_contracts/BlockRewardBridge.sol index 91647d622..38f64450a 100644 --- a/contracts/upgradeable_contracts/BlockRewardBridge.sol +++ b/contracts/upgradeable_contracts/BlockRewardBridge.sol @@ -5,8 +5,7 @@ import "../upgradeability/EternalStorage.sol"; import "openzeppelin-solidity/contracts/AddressUtils.sol"; contract BlockRewardBridge is EternalStorage { - bytes32 internal constant BLOCK_REWARD_CONTRACT = - 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // "blockRewardContract" + bytes32 internal constant BLOCK_REWARD_CONTRACT = 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // "blockRewardContract" bytes4 internal constant BLOCK_REWARD_CONTRACT_ID = 0x2ee57f8d; // blockRewardContractId() bytes4 internal constant BRIDGES_ALLOWED_LENGTH = 0x10f2ee7c; // bridgesAllowedLength() From 9a20b50640eff6f23bc57ac8fc0f809e831bc557 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 10 Oct 2019 11:57:40 +0300 Subject: [PATCH 03/80] update comments --- contracts/mocks/FeeManagerMock.sol | 2 +- .../upgradeable_contracts/BaseBridgeValidators.sol | 4 ++-- contracts/upgradeable_contracts/BaseFeeManager.sol | 4 ++-- .../upgradeable_contracts/BaseOverdrawManagement.sol | 2 +- contracts/upgradeable_contracts/BasicBridge.sol | 4 ++-- contracts/upgradeable_contracts/BasicTokenBridge.sol | 12 ++++++------ .../upgradeable_contracts/BlockRewardBridge.sol | 2 +- contracts/upgradeable_contracts/ERC20Bridge.sol | 2 +- contracts/upgradeable_contracts/ERC677Storage.sol | 2 +- contracts/upgradeable_contracts/FeeTypes.sol | 4 ++-- contracts/upgradeable_contracts/Initializable.sol | 4 ++-- contracts/upgradeable_contracts/Ownable.sol | 2 +- contracts/upgradeable_contracts/ReentrancyGuard.sol | 2 +- contracts/upgradeable_contracts/RewardableBridge.sol | 2 +- contracts/upgradeable_contracts/ValidatorStorage.sol | 2 +- .../amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol | 10 +++++----- .../arbitrary_message/BasicAMB.sol | 4 ++-- .../arbitrary_message/MessageProcessor.sol | 4 ++-- .../erc20_to_erc20/BasicForeignBridgeErcToErc.sol | 2 +- .../erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol | 2 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 2 +- .../erc20_to_native/FeeManagerErcToNative.sol | 2 +- .../erc20_to_native/FeeManagerErcToNativePOSDAO.sol | 2 +- .../erc20_to_native/ForeignBridgeErcToNative.sol | 2 +- .../erc20_to_native/HomeBridgeErcToNative.sol | 4 ++-- .../native_to_erc20/FeeManagerNativeToErc.sol | 2 +- .../FeeManagerNativeToErcBothDirections.sol | 2 +- .../native_to_erc20/ForeignBridgeNativeToErc.sol | 2 +- .../native_to_erc20/HomeBridgeNativeToErc.sol | 2 +- 29 files changed, 46 insertions(+), 46 deletions(-) diff --git a/contracts/mocks/FeeManagerMock.sol b/contracts/mocks/FeeManagerMock.sol index be5e57f73..aa2ee1b2e 100644 --- a/contracts/mocks/FeeManagerMock.sol +++ b/contracts/mocks/FeeManagerMock.sol @@ -12,7 +12,7 @@ contract FeeManagerMock is BaseFeeManager { } function getFeeManagerMode() external pure returns (bytes4) { - return 0xf2aed8f7; // "manages-one-direction" + return 0xf2aed8f7; // bytes4(keccak256(abi.encodePacked("manages-one-direction"))) } function randomTest(uint256 _count) external view returns (uint256) { diff --git a/contracts/upgradeable_contracts/BaseBridgeValidators.sol b/contracts/upgradeable_contracts/BaseBridgeValidators.sol index 8d1a3208b..65d94fe36 100644 --- a/contracts/upgradeable_contracts/BaseBridgeValidators.sol +++ b/contracts/upgradeable_contracts/BaseBridgeValidators.sol @@ -9,8 +9,8 @@ contract BaseBridgeValidators is Initializable, Ownable { address public constant F_ADDR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF; uint256 internal constant MAX_VALIDATORS = 100; - bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // "requiredSignatures" - bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // "validatorCount" + bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // keccak256(abi.encodePacked("requiredSignatures")) + bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // keccak256(abi.encodePacked("validatorCount")) event ValidatorAdded(address indexed validator); event ValidatorRemoved(address indexed validator); diff --git a/contracts/upgradeable_contracts/BaseFeeManager.sol b/contracts/upgradeable_contracts/BaseFeeManager.sol index 38fc846f5..7af5b2497 100644 --- a/contracts/upgradeable_contracts/BaseFeeManager.sol +++ b/contracts/upgradeable_contracts/BaseFeeManager.sol @@ -13,8 +13,8 @@ contract BaseFeeManager is EternalStorage, FeeTypes { // This is not a real fee value but a relative value used to calculate the fee percentage uint256 internal constant MAX_FEE = 1 ether; - bytes32 internal constant HOME_FEE_STORAGE_KEY = 0xc3781f3cec62d28f56efe98358f59c2105504b194242dbcb2cc0806850c306e7; // "homeFee" - bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = 0x68c305f6c823f4d2fa4140f9cf28d32a1faccf9b8081ff1c2de11cf32c733efc; // "foreignFee" + bytes32 internal constant HOME_FEE_STORAGE_KEY = 0xc3781f3cec62d28f56efe98358f59c2105504b194242dbcb2cc0806850c306e7; // keccak256(abi.encodePacked("homeFee")) + bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = 0x68c305f6c823f4d2fa4140f9cf28d32a1faccf9b8081ff1c2de11cf32c733efc; // keccak256(abi.encodePacked("foreignFee")) function calculateFee(uint256 _value, bool _recover, bytes32 _feeType) public view returns (uint256) { uint256 fee = _feeType == HOME_FEE ? getHomeFee() : getForeignFee(); diff --git a/contracts/upgradeable_contracts/BaseOverdrawManagement.sol b/contracts/upgradeable_contracts/BaseOverdrawManagement.sol index c56765697..b7339369b 100644 --- a/contracts/upgradeable_contracts/BaseOverdrawManagement.sol +++ b/contracts/upgradeable_contracts/BaseOverdrawManagement.sol @@ -6,7 +6,7 @@ contract BaseOverdrawManagement is EternalStorage { event AmountLimitExceeded(address recipient, uint256 value, bytes32 transactionHash); event AssetAboveLimitsFixed(bytes32 indexed transactionHash, uint256 value, uint256 remaining); - bytes32 internal constant OUT_OF_LIMIT_AMOUNT = 0x145286dc85799b6fb9fe322391ba2d95683077b2adf34dd576dedc437e537ba7; // "outOfLimitAmount" + bytes32 internal constant OUT_OF_LIMIT_AMOUNT = 0x145286dc85799b6fb9fe322391ba2d95683077b2adf34dd576dedc437e537ba7; // keccak256(abi.encodePacked("outOfLimitAmount")) function outOfLimitAmount() public view returns (uint256) { return uintStorage[OUT_OF_LIMIT_AMOUNT]; diff --git a/contracts/upgradeable_contracts/BasicBridge.sol b/contracts/upgradeable_contracts/BasicBridge.sol index 4a7ed8737..54a30e9a5 100644 --- a/contracts/upgradeable_contracts/BasicBridge.sol +++ b/contracts/upgradeable_contracts/BasicBridge.sol @@ -12,8 +12,8 @@ contract BasicBridge is Initializable, Validatable, Ownable, Upgradeable, Claima event GasPriceChanged(uint256 gasPrice); event RequiredBlockConfirmationChanged(uint256 requiredBlockConfirmations); - bytes32 internal constant GAS_PRICE = 0x55b3774520b5993024893d303890baa4e84b1244a43c60034d1ced2d3cf2b04b; // "gasPrice" - bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // "requiredBlockConfirmations" + bytes32 internal constant GAS_PRICE = 0x55b3774520b5993024893d303890baa4e84b1244a43c60034d1ced2d3cf2b04b; // keccak256(abi.encodePacked("gasPrice")) + bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // keccak256(abi.encodePacked("requiredBlockConfirmations")) function setGasPrice(uint256 _gasPrice) external onlyOwner { require(_gasPrice > 0); diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 6d7b77f81..15723b45b 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -10,12 +10,12 @@ contract BasicTokenBridge is EternalStorage, Ownable { event DailyLimitChanged(uint256 newLimit); event ExecutionDailyLimitChanged(uint256 newLimit); - bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // "minPerTx" - bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // "maxPerTx" - bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // "dailyLimit" - bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // "executionMaxPerTx" - bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // "executionDailyLimit" - bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // "decimalShift" + bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // keccak256(abi.encodePacked("minPerTx")) + bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // keccak256(abi.encodePacked("maxPerTx")) + bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // keccak256(abi.encodePacked("dailyLimit")) + bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // keccak256(abi.encodePacked("executionMaxPerTx")) + bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // keccak256(abi.encodePacked("executionDailyLimit")) + bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // keccak256(abi.encodePacked("decimalShift")) function totalSpentPerDay(uint256 _day) public view returns (uint256) { return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))]; diff --git a/contracts/upgradeable_contracts/BlockRewardBridge.sol b/contracts/upgradeable_contracts/BlockRewardBridge.sol index 38f64450a..440aa19ad 100644 --- a/contracts/upgradeable_contracts/BlockRewardBridge.sol +++ b/contracts/upgradeable_contracts/BlockRewardBridge.sol @@ -5,7 +5,7 @@ import "../upgradeability/EternalStorage.sol"; import "openzeppelin-solidity/contracts/AddressUtils.sol"; contract BlockRewardBridge is EternalStorage { - bytes32 internal constant BLOCK_REWARD_CONTRACT = 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // "blockRewardContract" + bytes32 internal constant BLOCK_REWARD_CONTRACT = 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // keccak256(abi.encodePacked("blockRewardContract")) bytes4 internal constant BLOCK_REWARD_CONTRACT_ID = 0x2ee57f8d; // blockRewardContractId() bytes4 internal constant BRIDGES_ALLOWED_LENGTH = 0x10f2ee7c; // bridgesAllowedLength() diff --git a/contracts/upgradeable_contracts/ERC20Bridge.sol b/contracts/upgradeable_contracts/ERC20Bridge.sol index 12b826a14..86fdf9546 100644 --- a/contracts/upgradeable_contracts/ERC20Bridge.sol +++ b/contracts/upgradeable_contracts/ERC20Bridge.sol @@ -5,7 +5,7 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; import "openzeppelin-solidity/contracts/AddressUtils.sol"; contract ERC20Bridge is EternalStorage { - bytes32 internal constant ERC20_TOKEN = 0x15d63b18dbc21bf4438b7972d80076747e1d93c4f87552fe498c90cbde51665e; // "erc20token" + bytes32 internal constant ERC20_TOKEN = 0x15d63b18dbc21bf4438b7972d80076747e1d93c4f87552fe498c90cbde51665e; // keccak256(abi.encodePacked("erc20token")) function erc20token() public view returns (ERC20Basic) { return ERC20Basic(addressStorage[ERC20_TOKEN]); diff --git a/contracts/upgradeable_contracts/ERC677Storage.sol b/contracts/upgradeable_contracts/ERC677Storage.sol index a65a818ce..8ec53a028 100644 --- a/contracts/upgradeable_contracts/ERC677Storage.sol +++ b/contracts/upgradeable_contracts/ERC677Storage.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ERC677Storage { - bytes32 internal constant ERC677_TOKEN = 0xa8b0ade3e2b734f043ce298aca4cc8d19d74270223f34531d0988b7d00cba21d; // "erc677token" + bytes32 internal constant ERC677_TOKEN = 0xa8b0ade3e2b734f043ce298aca4cc8d19d74270223f34531d0988b7d00cba21d; // keccak256(abi.encodePacked("erc677token")) } diff --git a/contracts/upgradeable_contracts/FeeTypes.sol b/contracts/upgradeable_contracts/FeeTypes.sol index 65365eee5..7018c9ccb 100644 --- a/contracts/upgradeable_contracts/FeeTypes.sol +++ b/contracts/upgradeable_contracts/FeeTypes.sol @@ -1,6 +1,6 @@ pragma solidity 0.4.24; contract FeeTypes { - bytes32 internal constant HOME_FEE = 0x89d93e5e92f7e37e490c25f0e50f7f4aad7cc94b308a566553280967be38bcf1; // "home-fee" - bytes32 internal constant FOREIGN_FEE = 0xdeb7f3adca07d6d1f708c1774389db532a2b2f18fd05a62b957e4089f4696ed5; // "foreign-fee" + bytes32 internal constant HOME_FEE = 0x89d93e5e92f7e37e490c25f0e50f7f4aad7cc94b308a566553280967be38bcf1; // keccak256(abi.encodePacked("home-fee")) + bytes32 internal constant FOREIGN_FEE = 0xdeb7f3adca07d6d1f708c1774389db532a2b2f18fd05a62b957e4089f4696ed5; // keccak256(abi.encodePacked("foreign-fee")) } diff --git a/contracts/upgradeable_contracts/Initializable.sol b/contracts/upgradeable_contracts/Initializable.sol index 5fe22819b..bfdc895d5 100644 --- a/contracts/upgradeable_contracts/Initializable.sol +++ b/contracts/upgradeable_contracts/Initializable.sol @@ -3,8 +3,8 @@ pragma solidity 0.4.24; import "../upgradeability/EternalStorage.sol"; contract Initializable is EternalStorage { - bytes32 internal constant INITIALIZED = 0x0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba; // "isInitialized" - bytes32 internal constant DEPLOYED_AT_BLOCK = 0xb120ceec05576ad0c710bc6e85f1768535e27554458f05dcbb5c65b8c7a749b0; // "deployedAtBlock" + bytes32 internal constant INITIALIZED = 0x0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba; // keccak256(abi.encodePacked("isInitialized")) + bytes32 internal constant DEPLOYED_AT_BLOCK = 0xb120ceec05576ad0c710bc6e85f1768535e27554458f05dcbb5c65b8c7a749b0; // keccak256(abi.encodePacked("deployedAtBlock")) function setInitialize() internal { boolStorage[INITIALIZED] = true; diff --git a/contracts/upgradeable_contracts/Ownable.sol b/contracts/upgradeable_contracts/Ownable.sol index b6efcf507..e1220e8c6 100644 --- a/contracts/upgradeable_contracts/Ownable.sol +++ b/contracts/upgradeable_contracts/Ownable.sol @@ -23,7 +23,7 @@ contract Ownable is EternalStorage { _; } - bytes32 internal constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; // "owner" + bytes32 internal constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; // keccak256(abi.encodePacked("owner")) /** * @dev Tells the address of the owner diff --git a/contracts/upgradeable_contracts/ReentrancyGuard.sol b/contracts/upgradeable_contracts/ReentrancyGuard.sol index 9a76daffd..14c6874ac 100644 --- a/contracts/upgradeable_contracts/ReentrancyGuard.sol +++ b/contracts/upgradeable_contracts/ReentrancyGuard.sol @@ -3,7 +3,7 @@ pragma solidity 0.4.24; import "../upgradeability/EternalStorage.sol"; contract ReentrancyGuard is EternalStorage { - bytes32 internal constant LOCK = 0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92; // "lock" + bytes32 internal constant LOCK = 0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92; // keccak256(abi.encodePacked("lock")) function lock() internal returns (bool) { return boolStorage[LOCK]; diff --git a/contracts/upgradeable_contracts/RewardableBridge.sol b/contracts/upgradeable_contracts/RewardableBridge.sol index 443ed6f5c..48a349128 100644 --- a/contracts/upgradeable_contracts/RewardableBridge.sol +++ b/contracts/upgradeable_contracts/RewardableBridge.sol @@ -8,7 +8,7 @@ contract RewardableBridge is Ownable, FeeTypes { event FeeDistributedFromAffirmation(uint256 feeAmount, bytes32 indexed transactionHash); event FeeDistributedFromSignatures(uint256 feeAmount, bytes32 indexed transactionHash); - bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3e2f2516078c38c68a3149787976ee837e5; // "feeManagerContract" + bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3e2f2516078c38c68a3149787976ee837e5; // keccak256(abi.encodePacked("feeManagerContract")) bytes4 internal constant GET_HOME_FEE = 0x94da17cd; // getHomeFee() bytes4 internal constant GET_FOREIGN_FEE = 0xffd66196; // getForeignFee() bytes4 internal constant GET_FEE_MANAGER_MODE = 0xf2ba9561; // getFeeManagerMode() diff --git a/contracts/upgradeable_contracts/ValidatorStorage.sol b/contracts/upgradeable_contracts/ValidatorStorage.sol index 4afd51140..7230f047a 100644 --- a/contracts/upgradeable_contracts/ValidatorStorage.sol +++ b/contracts/upgradeable_contracts/ValidatorStorage.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ValidatorStorage { - bytes32 internal constant VALIDATOR_CONTRACT = 0x5a74bb7e202fb8e4bf311841c7d64ec19df195fee77d7e7ae749b27921b6ddfe; // "validatorContract" + bytes32 internal constant VALIDATOR_CONTRACT = 0x5a74bb7e202fb8e4bf311841c7d64ec19df195fee77d7e7ae749b27921b6ddfe; // keccak256(abi.encodePacked("validatorContract")) } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 69079d3d1..30645cd1e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -24,10 +24,10 @@ contract BasicAMBErc677ToErc677 is { event FailedMessageFixed(bytes32 indexed dataHash, address recipient, uint256 value); - bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // "bridgeContract" - bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // "mediatorContract" - bytes32 internal constant REQUEST_GAS_LIMIT = 0x2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be; // "requestGasLimit" - bytes32 internal constant NONCE = 0x7ab1577440dd7bedf920cb6de2f9fc6bf7ba98c78c85a3fa1f8311aac95e1759; // "nonce" + bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // keccak256(abi.encodePacked("bridgeContract")) + bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // keccak256(abi.encodePacked("mediatorContract")) + bytes32 internal constant REQUEST_GAS_LIMIT = 0x2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be; // keccak256(abi.encodePacked("requestGasLimit")) + bytes32 internal constant NONCE = 0x7ab1577440dd7bedf920cb6de2f9fc6bf7ba98c78c85a3fa1f8311aac95e1759; // keccak256(abi.encodePacked("nonce")) function initialize( address _bridgeContract, @@ -102,7 +102,7 @@ contract BasicAMBErc677ToErc677 is } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x76595b56; // "erc-to-erc-amb" + return 0x76595b56; // bytes4(keccak256(abi.encodePacked("erc-to-erc-amb"))) } function setBridgeContract(address _bridgeContract) external onlyOwner { diff --git a/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol b/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol index d73f89b38..fa48373d9 100644 --- a/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol +++ b/contracts/upgradeable_contracts/arbitrary_message/BasicAMB.sol @@ -3,7 +3,7 @@ pragma solidity 0.4.24; import "../BasicBridge.sol"; contract BasicAMB is BasicBridge { - bytes32 internal constant MAX_GAS_PER_TX = 0x2670ecc91ec356e32067fd27b36614132d727b84a1e03e08f412a4f2cf075974; // "maxGasPerTx" + bytes32 internal constant MAX_GAS_PER_TX = 0x2670ecc91ec356e32067fd27b36614132d727b84a1e03e08f412a4f2cf075974; // keccak256(abi.encodePacked("maxGasPerTx")) function initialize( address _validatorContract, @@ -32,7 +32,7 @@ contract BasicAMB is BasicBridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x2544fbb9; // "arbitrary-message-bridge-core" + return 0x2544fbb9; // bytes4(keccak256(abi.encodePacked("arbitrary-message-bridge-core"))) } function maxGasPerTx() public view returns (uint256) { diff --git a/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol b/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol index 02d263dcb..220e3a862 100644 --- a/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol +++ b/contracts/upgradeable_contracts/arbitrary_message/MessageProcessor.sol @@ -4,8 +4,8 @@ import "../../upgradeability/EternalStorage.sol"; import "../../libraries/Bytes.sol"; contract MessageProcessor is EternalStorage { - bytes32 internal constant MESSAGE_SENDER = 0x7b58b2a669d8e0992eae9eaef641092c0f686fd31070e7236865557fa1571b5b; // "messageSender" - bytes32 internal constant TRANSACTION_HASH = 0x7bce44346b9831b0c81437a092605c6fc51612016e2c51e62f21d829e434bcf6; // "transactionHash" + bytes32 internal constant MESSAGE_SENDER = 0x7b58b2a669d8e0992eae9eaef641092c0f686fd31070e7236865557fa1571b5b; // keccak256(abi.encodePacked("messageSender")) + bytes32 internal constant TRANSACTION_HASH = 0x7bce44346b9831b0c81437a092605c6fc51612016e2c51e62f21d829e434bcf6; // keccak256(abi.encodePacked("transactionHash")) function messageCallStatus(bytes32 _txHash) external view returns (bool) { return boolStorage[keccak256(abi.encodePacked("messageCallStatus", _txHash))]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 834de2919..57437d9b4 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -38,7 +38,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return 0xba4690f5; // "erc-to-erc-core" + return 0xba4690f5; // bytes4(keccak256(abi.encodePacked("erc-to-erc-core"))) } function claimTokens(address _token, address _to) public { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol index 572ada424..5573c64c1 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol @@ -4,7 +4,7 @@ import "../BlockRewardFeeManager.sol"; contract FeeManagerErcToErcPOSDAO is BlockRewardFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return 0xd7de965f; // "manages-both-directions" + return 0xd7de965f; // bytes4(keccak256(abi.encodePacked("manages-both-directions"))) } function blockRewardContract() external view returns (address) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 9944cfd98..65ed05952 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -141,7 +141,7 @@ contract HomeBridgeErcToErc is } function getBridgeMode() external pure returns (bytes4 _data) { - return 0xba4690f5; // "erc-to-erc-core" + return 0xba4690f5; // bytes4(keccak256(abi.encodePacked("erc-to-erc-core"))) } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol index ce7e951fe..7a3698587 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNative.sol @@ -7,7 +7,7 @@ import "../BlockRewardBridge.sol"; contract FeeManagerErcToNative is ValidatorsFeeManager, BlockRewardBridge { function getFeeManagerMode() external pure returns (bytes4) { - return 0xd7de965f; // "manages-both-directions" + return 0xd7de965f; // bytes4(keccak256(abi.encodePacked("manages-both-directions"))) } function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol index 1bbcc1f03..a4a43b3a8 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol @@ -5,7 +5,7 @@ import "../BlockRewardFeeManager.sol"; contract FeeManagerErcToNativePOSDAO is BlockRewardFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return 0xd7de965f; // "manages-both-directions" + return 0xd7de965f; // bytes4(keccak256(abi.encodePacked("manages-both-directions"))) } function distributeFeeFromBlockReward(uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 18061f5c9..03fbb5fdf 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -42,7 +42,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x18762d46; // "erc-to-native-core" + return 0x18762d46; // bytes4(keccak256(abi.encodePacked("erc-to-native-core"))) } function claimTokens(address _token, address _to) public { diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index cb227b416..5a0927c53 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -16,7 +16,7 @@ contract HomeBridgeErcToNative is RewardableHomeBridgeErcToNative, BlockRewardBridge { - bytes32 internal constant TOTAL_BURNT_COINS = 0x17f187b2e5d1f8770602b32c1159b85c9600859277fae1eaa9982e9bcf63384c; // "totalBurntCoins" + bytes32 internal constant TOTAL_BURNT_COINS = 0x17f187b2e5d1f8770602b32c1159b85c9600859277fae1eaa9982e9bcf63384c; // keccak256(abi.encodePacked("totalBurntCoins")) function() public payable { nativeTransfer(); @@ -101,7 +101,7 @@ contract HomeBridgeErcToNative is } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x18762d46; // "erc-to-native-core" + return 0x18762d46; // bytes4(keccak256(abi.encodePacked("erc-to-native-core"))) } function blockRewardContract() public view returns (IBlockReward) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol index c519c357a..9919526a5 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErc.sol @@ -7,7 +7,7 @@ import "../ERC677Storage.sol"; contract FeeManagerNativeToErc is ValidatorsFeeManager, ERC677Storage { function getFeeManagerMode() external pure returns (bytes4) { - return 0xf2aed8f7; // "manages-one-direction" + return 0xf2aed8f7; // bytes4(keccak256(abi.encodePacked("manages-one-direction"))) } function erc677token() public view returns (IBurnableMintableERC677Token) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol index 6fb2e035f..9a61cfafc 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/FeeManagerNativeToErcBothDirections.sol @@ -5,7 +5,7 @@ import "../ValidatorsFeeManager.sol"; contract FeeManagerNativeToErcBothDirections is ValidatorsFeeManager { function getFeeManagerMode() external pure returns (bytes4) { - return 0xd7de965f; // "manages-both-directions" + return 0xd7de965f; // bytes4(keccak256(abi.encodePacked("manages-both-directions"))) } function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 19425a14f..74b581649 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -68,7 +68,7 @@ contract ForeignBridgeNativeToErc is } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x92a8d7fe; // "native-to-erc-core" + return 0x92a8d7fe; // bytes4(keccak256(abi.encodePacked("native-to-erc-core"))) } function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 68cce44f8..4617f2407 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -76,7 +76,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom } function getBridgeMode() external pure returns (bytes4 _data) { - return 0x92a8d7fe; // "native-to-erc-core" + return 0x92a8d7fe; // bytes4(keccak256(abi.encodePacked("native-to-erc-core"))) } function _initialize( From 31b7923c773b8a445c8c87d348b53a7805523fe4 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 10 Oct 2019 12:39:13 +0300 Subject: [PATCH 04/80] convert missed hex-identifiers --- contracts/upgradeable_contracts/ValidatorsFeeManager.sol | 9 ++------- .../native_to_erc20/ClassicHomeBridgeNativeToErc.sol | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/contracts/upgradeable_contracts/ValidatorsFeeManager.sol b/contracts/upgradeable_contracts/ValidatorsFeeManager.sol index aa7e098a2..c30dac87f 100644 --- a/contracts/upgradeable_contracts/ValidatorsFeeManager.sol +++ b/contracts/upgradeable_contracts/ValidatorsFeeManager.sol @@ -5,13 +5,8 @@ import "../interfaces/IRewardableValidators.sol"; import "./ValidatorStorage.sol"; contract ValidatorsFeeManager is BaseFeeManager, ValidatorStorage { - bytes32 public constant REWARD_FOR_TRANSFERRING_FROM_HOME = keccak256( - abi.encodePacked("reward-transferring-from-home") - ); - - bytes32 public constant REWARD_FOR_TRANSFERRING_FROM_FOREIGN = keccak256( - abi.encodePacked("reward-transferring-from-foreign") - ); + bytes32 public constant REWARD_FOR_TRANSFERRING_FROM_HOME = 0x2a11db67c480122765825a7e4bc5428e8b7b9eca0d4e62b91aac194f99edd0d7; // keccak256(abi.encodePacked("reward-transferring-from-home")) + bytes32 public constant REWARD_FOR_TRANSFERRING_FROM_FOREIGN = 0xb14796d751eb4f2570065a479f9e526eabeb2077c564c8a1c5ea559883ea2fab; // keccak256(abi.encodePacked("reward-transferring-from-foreign")) function distributeFeeFromAffirmation(uint256 _fee) external { distributeFeeProportionally(_fee, REWARD_FOR_TRANSFERRING_FROM_FOREIGN); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol index 680b10d50..74ec8e291 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol @@ -21,7 +21,7 @@ contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { _owner, _decimalShift ); - uintStorage[keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("signature(bytes32,uint256)"))))] = 132; - uintStorage[keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("message(bytes32)"))))] = 210; + uintStorage[0x5e16d82565fc7ee8775cc18db290ff4010745d3fd46274a7bc7ddbebb727fa54] = 132; // keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("signature(bytes32,uint256)")))) + uintStorage[0x3b0a1ac531be1657049cf649eca2510ce9e3ef7df1be26d5c248fe8b298f4374] = 210; // keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("message(bytes32)")))) } } From 01a0d49ca22e5a91f0942c2be977d136a7b1c50a Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 11 Oct 2019 16:45:39 +0300 Subject: [PATCH 05/80] add relative daily limit for erc-to-native --- .../RelativeDailyLimit.sol | 48 +++++++++++++++++++ ...ignBridgeErcToNativeRelativeDailyLimit.sol | 11 +++++ ...omeBridgeErcToNativeRelativeDailyLimit.sol | 13 +++++ deploy/.env.example | 3 ++ deploy/src/erc_to_native/foreign.js | 13 +++-- deploy/src/erc_to_native/home.js | 8 ++-- deploy/src/loadContracts.js | 2 + deploy/src/loadEnv.js | 6 ++- 8 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 contracts/upgradeable_contracts/RelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol new file mode 100644 index 000000000..91a021d25 --- /dev/null +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -0,0 +1,48 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./BasicTokenBridge.sol"; + +contract RelativeDailyLimit is BasicTokenBridge { + using SafeMath for uint256; + + event TargetLimitChanged(uint256 newLimit); + event ThresholdChanged(uint256 newThreshold); + + bytes32 internal constant TARGET_LIMIT = keccak256(abi.encodePacked("targetLimit")); + bytes32 internal constant THRESHOLD = keccak256(abi.encodePacked("threshold")); + + function dailyLimit() public view returns (uint256) { + uint256 balance = _getTokenBalance(); + uint256 minBalance = targetLimit().mul(threshold()).div(100); + uint256 limit; + if (balance < minBalance) { + limit = 100; + } else if (balance >= minBalance && balance < threshold()) { + limit = targetLimit().mul(threshold()).div(balance); + } else { + limit = targetLimit(); + } + return balance.mul(limit).div(100); + } + + function targetLimit() public view returns (uint256) { + return uintStorage[TARGET_LIMIT]; + } + + function threshold() public view returns (uint256) { + return uintStorage[THRESHOLD]; + } + + function setTargetLimit(uint256 _targetLimit) external onlyOwner { + uintStorage[TARGET_LIMIT] = _targetLimit; + emit TargetLimitChanged(_targetLimit); + } + + function setThreshold(uint256 _threshold) external onlyOwner { + uintStorage[THRESHOLD] = _threshold; + emit ThresholdChanged(_threshold); + } + + function _getTokenBalance() internal view returns (uint256); +} diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol new file mode 100644 index 000000000..5d54b1734 --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -0,0 +1,11 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./ForeignBridgeErcToNative.sol"; +import "../RelativeDailyLimit.sol"; + +contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc20token().balanceOf(address(this)); + } +} diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol new file mode 100644 index 000000000..16da8b983 --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -0,0 +1,13 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./HomeBridgeErcToNative.sol"; +import "../RelativeDailyLimit.sol"; + +contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative { + function _getTokenBalance() internal view returns (uint256) { + uint256 totalMinted = blockRewardContract().mintedTotallyByBridge(address(this)); + uint256 totalBurnt = totalBurntCoins(); + return totalMinted.sub(totalBurnt); + } +} diff --git a/deploy/.env.example b/deploy/.env.example index fc7ec525b..c06c51281 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -58,6 +58,9 @@ FOREIGN_REWARDABLE=false #E.g. VALIDATORS_REWARD_ACCOUNTS=0x 0x 0x VALIDATORS_REWARD_ACCOUNTS=0x +# Relative or fixed daily limit +RELATIVE_DAILY_LIMIT=false + # Fee to be taken for every transaction directed from the Home network to the Foreign network # E.g. 0.1% fee HOME_TRANSACTIONS_FEE=0.001 diff --git a/deploy/src/erc_to_native/foreign.js b/deploy/src/erc_to_native/foreign.js index 76013547a..3d2c5abf7 100644 --- a/deploy/src/erc_to_native/foreign.js +++ b/deploy/src/erc_to_native/foreign.js @@ -13,7 +13,12 @@ const { } = require('../deploymentUtils') const { web3Foreign, deploymentPrivateKey, FOREIGN_RPC_URL } = require('../web3') const { - foreignContracts: { EternalStorageProxy, BridgeValidators, ForeignBridgeErcToNative: ForeignBridge } + foreignContracts: { + EternalStorageProxy, + BridgeValidators, + ForeignBridgeErcToNative: ForeignBridge, + ForeignBridgeErcToNativeRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + } } = require('../loadContracts') const VALIDATORS = env.VALIDATORS.split(' ') @@ -30,7 +35,8 @@ const { FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -144,7 +150,8 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const foreignBridgeImplementation = await deployContract(ForeignBridge, [], { + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index 253bf6aa4..d0592ee58 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -19,6 +19,7 @@ const { RewardableValidators, FeeManagerErcToNative, HomeBridgeErcToNative: HomeBridge, + HomeBridgeErcToNativeRelativeDailyLimit: HomeBridgeRelativeDailyLimit, FeeManagerErcToNativePOSDAO } } = require('../loadContracts') @@ -43,7 +44,8 @@ const { HOME_TRANSACTIONS_FEE, FOREIGN_TRANSACTIONS_FEE, HOME_FEE_MANAGER_TYPE, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -210,9 +212,9 @@ async function deployHome() { }) nonce++ console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) - console.log('\ndeploying homeBridge implementation\n') - const homeBridgeImplementation = await deployContract(HomeBridge, [], { + const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge + const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) diff --git a/deploy/src/loadContracts.js b/deploy/src/loadContracts.js index 3b5766044..acee3b0e9 100644 --- a/deploy/src/loadContracts.js +++ b/deploy/src/loadContracts.js @@ -22,9 +22,11 @@ function getContracts(evmVersion) { ERC677BridgeToken: require(`../../build/${buildPath}/ERC677BridgeToken.json`), ERC677BridgeTokenRewardable: require(`../../build/${buildPath}/ERC677BridgeTokenRewardable.json`), ForeignBridgeErcToNative: require(`../../build/${buildPath}/ForeignBridgeErcToNative.json`), + ForeignBridgeErcToNativeRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErcToNativeRelativeDailyLimit.json`), FeeManagerErcToNative: require(`../../build/${buildPath}/FeeManagerErcToNative.json`), FeeManagerErcToNativePOSDAO: require(`../../build/${buildPath}/FeeManagerErcToNativePOSDAO.json`), HomeBridgeErcToNative: require(`../../build/${buildPath}/HomeBridgeErcToNative.json`), + HomeBridgeErcToNativeRelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToNativeRelativeDailyLimit.json`), FeeManagerNativeToErc: require(`../../build/${buildPath}/FeeManagerNativeToErc.json`), ForeignBridgeNativeToErc: require(`../../build/${buildPath}/ForeignBridgeNativeToErc.json`), FeeManagerNativeToErcBothDirections: require(`../../build/${buildPath}/FeeManagerNativeToErcBothDirections.json`), diff --git a/deploy/src/loadEnv.js b/deploy/src/loadEnv.js index 1e92535ad..e9efc661a 100644 --- a/deploy/src/loadEnv.js +++ b/deploy/src/loadEnv.js @@ -77,7 +77,8 @@ const { HOME_FEE_MANAGER_TYPE, ERC20_EXTENDED_BY_ERC677, HOME_EVM_VERSION, - FOREIGN_EVM_VERSION + FOREIGN_EVM_VERSION, + RELATIVE_DAILY_LIMIT, } = process.env // Types validations @@ -111,7 +112,8 @@ let validations = { FOREIGN_RPC_URL: envalid.str(), FOREIGN_BRIDGE_OWNER: addressValidator(), FOREIGN_UPGRADEABLE_ADMIN: addressValidator(), - FOREIGN_MAX_AMOUNT_PER_TX: bigNumValidator() + FOREIGN_MAX_AMOUNT_PER_TX: bigNumValidator(), + RELATIVE_DAILY_LIMIT: envalid.bool(), } if (BRIDGE_MODE === 'AMB_ERC_TO_ERC') { From 689299fe73254e2882912a64079182d945df62ae Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 14 Oct 2019 14:19:03 +0300 Subject: [PATCH 06/80] add relative daily limit for native-to-erc --- ...ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol | 11 +++++++++++ .../ForeignBridgeNativeToErcRelativeDailyLimit.sol | 11 +++++++++++ .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 11 +++++++++++ deploy/src/loadContracts.js | 4 ++++ deploy/src/native_to_erc/foreign.js | 7 +++++-- deploy/src/native_to_erc/home.js | 7 +++++-- 6 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..bb9725db0 --- /dev/null +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol @@ -0,0 +1,11 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./ClassicHomeBridgeNativeToErc.sol"; +import "../RelativeDailyLimit.sol"; + +contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc { + function _getTokenBalance() internal view returns (uint256) { + return address(this).balance; + } +} diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..dffbf2aea --- /dev/null +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -0,0 +1,11 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./ForeignBridgeNativeToErc.sol"; +import "../RelativeDailyLimit.sol"; + +contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } +} diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..ab6ab9af3 --- /dev/null +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -0,0 +1,11 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./HomeBridgeNativeToErc.sol"; +import "../RelativeDailyLimit.sol"; + +contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc { + function _getTokenBalance() internal view returns (uint256) { + return address(this).balance; + } +} diff --git a/deploy/src/loadContracts.js b/deploy/src/loadContracts.js index acee3b0e9..62cea6e5b 100644 --- a/deploy/src/loadContracts.js +++ b/deploy/src/loadContracts.js @@ -29,10 +29,14 @@ function getContracts(evmVersion) { HomeBridgeErcToNativeRelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToNativeRelativeDailyLimit.json`), FeeManagerNativeToErc: require(`../../build/${buildPath}/FeeManagerNativeToErc.json`), ForeignBridgeNativeToErc: require(`../../build/${buildPath}/ForeignBridgeNativeToErc.json`), + ForeignBridgeNativeToErcRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeNativeToErcRelativeDailyLimit.json`), FeeManagerNativeToErcBothDirections: require(`../../build/${buildPath}/FeeManagerNativeToErcBothDirections.json`), HomeBridgeNativeToErc: useClassicProxy ? require(`../../build/${buildPath}/ClassicHomeBridgeNativeToErc.json`) : require(`../../build/${buildPath}/HomeBridgeNativeToErc.json`), + HomeBridgeNativeToErcRelativeDailyLimit: useClassicProxy + ? require(`../../build/${buildPath}/ClassicHomeBridgeNativeToErcRelativeDailyLimit.json`) + : require(`../../build/${buildPath}/HomeBridgeNativeToErcRelativeDailyLimit.json`), BlockReward: require(`../../build/${buildPath}/BlockReward.json`), HomeAMB: require(`../../build/${buildPath}/HomeAMB.json`), ForeignAMB: require(`../../build/${buildPath}/ForeignAMB`), diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index 6ede7a34f..bf3aa8760 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -20,6 +20,7 @@ const { BridgeValidators, RewardableValidators, ForeignBridgeNativeToErc: ForeignBridge, + ForeignBridgeNativeToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable, FeeManagerNativeToErc @@ -49,7 +50,8 @@ const { DPOS_STAKING_ADDRESS, FOREIGN_REWARDABLE, HOME_TRANSACTIONS_FEE, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -236,7 +238,8 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const foreignBridgeImplementation = await deployContract(ForeignBridge, [], { + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce diff --git a/deploy/src/native_to_erc/home.js b/deploy/src/native_to_erc/home.js index ab2cffef6..f6c84d127 100644 --- a/deploy/src/native_to_erc/home.js +++ b/deploy/src/native_to_erc/home.js @@ -19,6 +19,7 @@ const { RewardableValidators, FeeManagerNativeToErc, HomeBridgeNativeToErc: HomeBridge, + HomeBridgeNativeToErcRelativeDailyLimit: HomeBridgeRelativeDailyLimit, FeeManagerNativeToErcBothDirections } } = require('../loadContracts') @@ -41,7 +42,8 @@ const { HOME_REWARDABLE, HOME_TRANSACTIONS_FEE, FOREIGN_TRANSACTIONS_FEE, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -210,7 +212,8 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - const homeBridgeImplementation = await deployContract(HomeBridge, [], { + const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge + const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) From e9dedf3bca593f1566a6645e376fa88b26ef613c Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 14 Oct 2019 14:37:52 +0300 Subject: [PATCH 07/80] fix dependencies --- .../ForeignBridgeErcToNativeRelativeDailyLimit.sol | 1 - .../HomeBridgeErcToNativeRelativeDailyLimit.sol | 2 +- .../ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol | 2 +- .../ForeignBridgeNativeToErcRelativeDailyLimit.sol | 1 - .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 3 +-- 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 5d54b1734..d5219086d 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -1,6 +1,5 @@ pragma solidity 0.4.24; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ForeignBridgeErcToNative.sol"; import "../RelativeDailyLimit.sol"; diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index 16da8b983..4a89f4125 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -4,7 +4,7 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./HomeBridgeErcToNative.sol"; import "../RelativeDailyLimit.sol"; -contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative { +contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { function _getTokenBalance() internal view returns (uint256) { uint256 totalMinted = blockRewardContract().mintedTotallyByBridge(address(this)); uint256 totalBurnt = totalBurntCoins(); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol index bb9725db0..63493d372 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol @@ -4,7 +4,7 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ClassicHomeBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; -contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc { +contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, RelativeDailyLimit { function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index dffbf2aea..c8060a2d3 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -1,6 +1,5 @@ pragma solidity 0.4.24; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ForeignBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index ab6ab9af3..d18fae799 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -1,10 +1,9 @@ pragma solidity 0.4.24; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./HomeBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; -contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc { +contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeDailyLimit { function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } From 281f71d037b15252dbc0128744c30202220b7904 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 14 Oct 2019 16:25:37 +0300 Subject: [PATCH 08/80] add relative daily limit for erc-to-erc --- ...sicForeignBridgeErcToErcRelativeDailyLimit.sol | 10 ++++++++++ ...eignBridgeErc677ToErc677RelativeDailyLimit.sol | 9 +++++++++ .../ForeignBridgeErcToErcRelativeDailyLimit.sol | 9 +++++++++ ...HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol | 10 ++++++++++ .../HomeBridgeErcToErcRelativeDailyLimit.sol | 10 ++++++++++ deploy/src/erc_to_erc/foreign.js | 15 ++++++++++++--- deploy/src/erc_to_erc/home.js | 13 +++++++++++-- deploy/src/loadContracts.js | 4 ++++ 8 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..89547721a --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol @@ -0,0 +1,10 @@ +pragma solidity 0.4.24; + +import "./BasicForeignBridgeErcToErc.sol"; +import "../RelativeDailyLimit.sol"; + +contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc20token().balanceOf(address(this)); + } +} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol new file mode 100644 index 000000000..91902b6e8 --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -0,0 +1,9 @@ +pragma solidity 0.4.24; + +import "./ForeignBridgeErc677ToErc677.sol"; +import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; + +// solhint-disable-next-line no-empty-blocks +contract ForeignBridgeErc677ToErc677RelativeDailyLimit is + BasicForeignBridgeErcToErcRelativeDailyLimit, + ForeignBridgeErc677ToErc677 {} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..a1e0e9020 --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -0,0 +1,9 @@ +pragma solidity 0.4.24; + +import "./ForeignBridgeErcToErc.sol"; +import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; + +// solhint-disable-next-line no-empty-blocks +contract ForeignBridgeErcToErcRelativeDailyLimit is + BasicForeignBridgeErcToErcRelativeDailyLimit, + ForeignBridgeErcToErc {} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol new file mode 100644 index 000000000..355effc3c --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol @@ -0,0 +1,10 @@ +pragma solidity 0.4.24; + +import "./HomeBridgeErcToErcPOSDAO.sol"; +import "./HomeBridgeErcToErcRelativeDailyLimit.sol"; + +// solhint-disable-next-line no-empty-blocks +contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is + HomeBridgeErcToErcRelativeDailyLimit, + HomeBridgeErcToErcPOSDAO {} + diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol new file mode 100644 index 000000000..d4bc3dcb3 --- /dev/null +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -0,0 +1,10 @@ +pragma solidity 0.4.24; + +import "./HomeBridgeErcToErc.sol"; +import "../RelativeDailyLimit.sol"; + +contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } +} diff --git a/deploy/src/erc_to_erc/foreign.js b/deploy/src/erc_to_erc/foreign.js index cb59b9cf4..b64f874bb 100644 --- a/deploy/src/erc_to_erc/foreign.js +++ b/deploy/src/erc_to_erc/foreign.js @@ -17,7 +17,9 @@ const { EternalStorageProxy, BridgeValidators, ForeignBridgeErcToErc: ForeignBridge, - ForeignBridgeErc677ToErc677 + ForeignBridgeErcToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + ForeignBridgeErc677ToErc677, + ForeignBridgeErc677ToErc677: ForeignBridgeErc677ToErc677RelativeDailyLimit, } } = require('../loadContracts') @@ -38,7 +40,8 @@ const { FOREIGN_MIN_AMOUNT_PER_TX, FOREIGN_DAILY_LIMIT, ERC20_EXTENDED_BY_ERC677, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -169,7 +172,13 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const bridgeContract = ERC20_EXTENDED_BY_ERC677 ? ForeignBridgeErc677ToErc677 : ForeignBridge + let ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677 + let ForeignBridgeContract = ForeignBridge + if (RELATIVE_DAILY_LIMIT) { + ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677RelativeDailyLimit + ForeignBridgeContract = ForeignBridgeRelativeDailyLimit + } + const bridgeContract = ERC20_EXTENDED_BY_ERC677 ? ForeignBridgeErc677ToErc677Contract : ForeignBridgeContract const foreignBridgeImplementation = await deployContract(bridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index b57ec9117..b03647565 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -23,7 +23,9 @@ const { RewardableValidators, FeeManagerErcToErcPOSDAO, HomeBridgeErcToErc: HomeBridge, + HomeBridgeErcToErcRelativeDailyLimit: HomeBridgeRelativeDailyLimit, HomeBridgeErcToErcPOSDAO, + HomeBridgeErcToErcPOSDAORelativeDailyLimit: HomeBridgeErcToErcPOSDAORelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable } @@ -53,7 +55,8 @@ const { HOME_REWARDABLE, HOME_TRANSACTIONS_FEE, FOREIGN_TRANSACTIONS_FEE, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -209,8 +212,14 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') + let HomeBridgeErcToErcPOSDAOContract = HomeBridgeErcToErcPOSDAO + let HomeBridgeContract = HomeBridge + if (RELATIVE_DAILY_LIMIT) { + HomeBridgeErcToErcPOSDAOContract = HomeBridgeErcToErcPOSDAORelativeDailyLimit + HomeBridgeContract = HomeBridgeRelativeDailyLimit + } const bridgeContract = - isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgeErcToErcPOSDAO : HomeBridge + isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgeErcToErcPOSDAOContract : HomeBridgeContract const homeBridgeImplementation = await deployContract(bridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce diff --git a/deploy/src/loadContracts.js b/deploy/src/loadContracts.js index 62cea6e5b..1591764bf 100644 --- a/deploy/src/loadContracts.js +++ b/deploy/src/loadContracts.js @@ -16,9 +16,13 @@ function getContracts(evmVersion) { RewardableValidators: require(`../../build/${buildPath}/RewardableValidators.json`), FeeManagerErcToErcPOSDAO: require(`../../build/${buildPath}/FeeManagerErcToErcPOSDAO.json`), HomeBridgeErcToErc: require(`../../build/${buildPath}/HomeBridgeErcToErc.json`), + HomeBridgeErcToErcRelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToErcRelativeDailyLimit.json`), ForeignBridgeErcToErc: require(`../../build/${buildPath}/ForeignBridgeErcToErc.json`), + ForeignBridgeErcToErcRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErcToErcRelativeDailyLimit.json`), ForeignBridgeErc677ToErc677: require(`../../build/${buildPath}/ForeignBridgeErc677ToErc677.json`), + ForeignBridgeErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErc677ToErc677RelativeDailyLimit.json`), HomeBridgeErcToErcPOSDAO: require(`../../build/${buildPath}/HomeBridgeErcToErcPOSDAO.json`), + HomeBridgeErcToErcPOSDAORelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToErcPOSDAORelativeDailyLimit.json`), ERC677BridgeToken: require(`../../build/${buildPath}/ERC677BridgeToken.json`), ERC677BridgeTokenRewardable: require(`../../build/${buildPath}/ERC677BridgeTokenRewardable.json`), ForeignBridgeErcToNative: require(`../../build/${buildPath}/ForeignBridgeErcToNative.json`), From 0516397cf34d04ae56ffc869a70bddb6f204f819 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 14 Oct 2019 17:01:41 +0300 Subject: [PATCH 09/80] add relative daily limit for amb-erc-to-erc --- .../ForeignAMBErc677ToErc677RelativeDailyLimit.sol | 10 ++++++++++ .../HomeAMBErc677ToErc677RelativeDailyLimit.sol | 10 ++++++++++ deploy/src/amb_erc677_to_erc677/foreign.js | 14 +++++++++++--- deploy/src/amb_erc677_to_erc677/home.js | 7 +++++-- deploy/src/loadContracts.js | 4 +++- 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol new file mode 100644 index 000000000..245a7ac40 --- /dev/null +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -0,0 +1,10 @@ +pragma solidity 0.4.24; + +import "./ForeignAMBErc677ToErc677.sol"; +import "../RelativeDailyLimit.sol"; + +contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc677token().balanceOf(address(this)); + } +} diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol new file mode 100644 index 000000000..2f4dae04b --- /dev/null +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -0,0 +1,10 @@ +pragma solidity 0.4.24; + +import "./HomeAMBErc677ToErc677.sol"; +import "../RelativeDailyLimit.sol"; + +contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, RelativeDailyLimit { + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } +} diff --git a/deploy/src/amb_erc677_to_erc677/foreign.js b/deploy/src/amb_erc677_to_erc677/foreign.js index d1a5a43cc..9576ac2b9 100644 --- a/deploy/src/amb_erc677_to_erc677/foreign.js +++ b/deploy/src/amb_erc677_to_erc677/foreign.js @@ -2,9 +2,16 @@ const Web3Utils = require('web3-utils') const { web3Foreign, FOREIGN_RPC_URL } = require('../web3') const { deployContract, privateKeyToAddress, upgradeProxy } = require('../deploymentUtils') const { - foreignContracts: { EternalStorageProxy, ForeignAMBErc677ToErc677: ForeignBridge } + foreignContracts: { + EternalStorageProxy, + ForeignAMBErc677ToErc677: ForeignBridge, + ForeignAMBErc677ToErc677RelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + } } = require('../loadContracts') -const { DEPLOYMENT_ACCOUNT_PRIVATE_KEY } = require('../loadEnv') +const { + DEPLOYMENT_ACCOUNT_PRIVATE_KEY, + RELATIVE_DAILY_LIMIT, +} = require('../loadEnv') const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -21,7 +28,8 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\n[Foreign] Deploying foreignBridge implementation\n') - const foreignBridgeImplementation = await deployContract(ForeignBridge, [], { + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce diff --git a/deploy/src/amb_erc677_to_erc677/home.js b/deploy/src/amb_erc677_to_erc677/home.js index baff968c4..2036d0f7e 100644 --- a/deploy/src/amb_erc677_to_erc677/home.js +++ b/deploy/src/amb_erc677_to_erc677/home.js @@ -17,13 +17,15 @@ const { DEPLOYMENT_ACCOUNT_PRIVATE_KEY, DEPLOY_REWARDABLE_TOKEN, BLOCK_REWARD_ADDRESS, - DPOS_STAKING_ADDRESS + DPOS_STAKING_ADDRESS, + RELATIVE_DAILY_LIMIT, } = require('../loadEnv') const { homeContracts: { EternalStorageProxy, HomeAMBErc677ToErc677: HomeBridge, + HomeAMBErc677ToErc677RelativeDailyLimit: HomeBridgeRelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable } @@ -43,7 +45,8 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\n[Home] Deploying homeBridge implementation\n') - const homeBridgeImplementation = await deployContract(HomeBridge, [], { + const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge + const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) diff --git a/deploy/src/loadContracts.js b/deploy/src/loadContracts.js index 1591764bf..69720c79e 100644 --- a/deploy/src/loadContracts.js +++ b/deploy/src/loadContracts.js @@ -45,7 +45,9 @@ function getContracts(evmVersion) { HomeAMB: require(`../../build/${buildPath}/HomeAMB.json`), ForeignAMB: require(`../../build/${buildPath}/ForeignAMB`), HomeAMBErc677ToErc677: require(`../../build/${buildPath}/HomeAMBErc677ToErc677.json`), - ForeignAMBErc677ToErc677: require(`../../build/${buildPath}/ForeignAMBErc677ToErc677.json`) + HomeAMBErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/HomeAMBErc677ToErc677RelativeDailyLimit.json`), + ForeignAMBErc677ToErc677: require(`../../build/${buildPath}/ForeignAMBErc677ToErc677.json`), + ForeignAMBErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/ForeignAMBErc677ToErc677RelativeDailyLimit.json`) } } From d96b4d7c29939525f1cb0813016b56c59ea41fca Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 10:56:14 +0300 Subject: [PATCH 10/80] fix linter errors --- .../ForeignBridgeErc677ToErc677RelativeDailyLimit.sol | 3 ++- .../ForeignBridgeErcToErcRelativeDailyLimit.sol | 3 ++- .../HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol | 5 +---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index 91902b6e8..f679a6b39 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -6,4 +6,5 @@ import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; // solhint-disable-next-line no-empty-blocks contract ForeignBridgeErc677ToErc677RelativeDailyLimit is BasicForeignBridgeErcToErcRelativeDailyLimit, - ForeignBridgeErc677ToErc677 {} + ForeignBridgeErc677ToErc677 +{} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index a1e0e9020..755e4820c 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -6,4 +6,5 @@ import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; // solhint-disable-next-line no-empty-blocks contract ForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErcRelativeDailyLimit, - ForeignBridgeErcToErc {} + ForeignBridgeErcToErc +{} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol index 355effc3c..b60da9ff1 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol @@ -4,7 +4,4 @@ import "./HomeBridgeErcToErcPOSDAO.sol"; import "./HomeBridgeErcToErcRelativeDailyLimit.sol"; // solhint-disable-next-line no-empty-blocks -contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is - HomeBridgeErcToErcRelativeDailyLimit, - HomeBridgeErcToErcPOSDAO {} - +contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativeDailyLimit, HomeBridgeErcToErcPOSDAO {} From f2ab1d4853920314d880fd7e21ee89d59a3ebb5e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 11:10:47 +0300 Subject: [PATCH 11/80] use hexadecimal values --- contracts/upgradeable_contracts/RelativeDailyLimit.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index 91a021d25..e360a483a 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -9,8 +9,8 @@ contract RelativeDailyLimit is BasicTokenBridge { event TargetLimitChanged(uint256 newLimit); event ThresholdChanged(uint256 newThreshold); - bytes32 internal constant TARGET_LIMIT = keccak256(abi.encodePacked("targetLimit")); - bytes32 internal constant THRESHOLD = keccak256(abi.encodePacked("threshold")); + bytes32 internal constant TARGET_LIMIT = 0x192ac2d88a9de45ce541663ebe1aaf6d6b1d4a6299d3fd0abf2ba7e8b920342b; // keccak256(abi.encodePacked("targetLimit")) + bytes32 internal constant THRESHOLD = 0xd46c2b20c7303c2e50535d224276492e8a1eda2a3d7398e0bea254640c1154e7; // keccak256(abi.encodePacked("threshold")) function dailyLimit() public view returns (uint256) { uint256 balance = _getTokenBalance(); From a23ab522a3777a10f8b952ed897b4256c0b5488e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 11:44:06 +0300 Subject: [PATCH 12/80] use relative daily limit env variable only for token bridges --- deploy/src/loadEnv.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/deploy/src/loadEnv.js b/deploy/src/loadEnv.js index e9efc661a..54ce06e8e 100644 --- a/deploy/src/loadEnv.js +++ b/deploy/src/loadEnv.js @@ -78,7 +78,6 @@ const { ERC20_EXTENDED_BY_ERC677, HOME_EVM_VERSION, FOREIGN_EVM_VERSION, - RELATIVE_DAILY_LIMIT, } = process.env // Types validations @@ -113,7 +112,6 @@ let validations = { FOREIGN_BRIDGE_OWNER: addressValidator(), FOREIGN_UPGRADEABLE_ADMIN: addressValidator(), FOREIGN_MAX_AMOUNT_PER_TX: bigNumValidator(), - RELATIVE_DAILY_LIMIT: envalid.bool(), } if (BRIDGE_MODE === 'AMB_ERC_TO_ERC') { @@ -129,7 +127,8 @@ if (BRIDGE_MODE === 'AMB_ERC_TO_ERC') { BRIDGEABLE_TOKEN_DECIMALS: envalid.num(), FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator(), FOREIGN_DAILY_LIMIT: bigNumValidator(), - DEPLOY_REWARDABLE_TOKEN: envalid.bool() + DEPLOY_REWARDABLE_TOKEN: envalid.bool(), + RELATIVE_DAILY_LIMIT: envalid.bool(), } if (DEPLOY_REWARDABLE_TOKEN === 'true') { @@ -205,7 +204,8 @@ if (BRIDGE_MODE === 'NATIVE_TO_ERC') { BRIDGEABLE_TOKEN_SYMBOL: envalid.str(), BRIDGEABLE_TOKEN_DECIMALS: envalid.num(), FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator(), - DEPLOY_REWARDABLE_TOKEN: envalid.bool() + DEPLOY_REWARDABLE_TOKEN: envalid.bool(), + RELATIVE_DAILY_LIMIT: envalid.bool(), } if (DEPLOY_REWARDABLE_TOKEN === 'true') { @@ -225,7 +225,8 @@ if (BRIDGE_MODE === 'ERC_TO_ERC') { BRIDGEABLE_TOKEN_SYMBOL: envalid.str(), BRIDGEABLE_TOKEN_DECIMALS: envalid.num(), DEPLOY_REWARDABLE_TOKEN: envalid.bool(), - ERC20_EXTENDED_BY_ERC677: envalid.bool() + ERC20_EXTENDED_BY_ERC677: envalid.bool(), + RELATIVE_DAILY_LIMIT: envalid.bool(), } if (ERC20_EXTENDED_BY_ERC677 === 'true') { @@ -250,7 +251,8 @@ if (BRIDGE_MODE === 'ERC_TO_NATIVE') { ERC20_TOKEN_ADDRESS: addressValidator(), BLOCK_REWARD_ADDRESS: addressValidator({ default: ZERO_ADDRESS - }) + }), + RELATIVE_DAILY_LIMIT: envalid.bool(), } } From ecc6fca95342de372978a9c6e1ad894cfda95066 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 12:29:35 +0300 Subject: [PATCH 13/80] rename vars in deployment scripts --- deploy/src/amb_erc677_to_erc677/foreign.js | 4 ++-- deploy/src/amb_erc677_to_erc677/home.js | 4 ++-- deploy/src/erc_to_erc/foreign.js | 10 +++++----- deploy/src/erc_to_erc/home.js | 14 +++++++------- deploy/src/erc_to_native/foreign.js | 4 ++-- deploy/src/erc_to_native/home.js | 4 ++-- deploy/src/native_to_erc/foreign.js | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/deploy/src/amb_erc677_to_erc677/foreign.js b/deploy/src/amb_erc677_to_erc677/foreign.js index 9576ac2b9..2e1411279 100644 --- a/deploy/src/amb_erc677_to_erc677/foreign.js +++ b/deploy/src/amb_erc677_to_erc677/foreign.js @@ -4,7 +4,7 @@ const { deployContract, privateKeyToAddress, upgradeProxy } = require('../deploy const { foreignContracts: { EternalStorageProxy, - ForeignAMBErc677ToErc677: ForeignBridge, + ForeignAMBErc677ToErc677: ForeignBridgeAbsoluteDailyLimit, ForeignAMBErc677ToErc677RelativeDailyLimit: ForeignBridgeRelativeDailyLimit, } } = require('../loadContracts') @@ -28,7 +28,7 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\n[Foreign] Deploying foreignBridge implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', diff --git a/deploy/src/amb_erc677_to_erc677/home.js b/deploy/src/amb_erc677_to_erc677/home.js index 2036d0f7e..270a53d83 100644 --- a/deploy/src/amb_erc677_to_erc677/home.js +++ b/deploy/src/amb_erc677_to_erc677/home.js @@ -24,7 +24,7 @@ const { const { homeContracts: { EternalStorageProxy, - HomeAMBErc677ToErc677: HomeBridge, + HomeAMBErc677ToErc677: HomeBridgeAbsoluteDailyLimit, HomeAMBErc677ToErc677RelativeDailyLimit: HomeBridgeRelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable @@ -45,7 +45,7 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\n[Home] Deploying homeBridge implementation\n') - const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge + const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridgeAbsoluteDailyLimit const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce diff --git a/deploy/src/erc_to_erc/foreign.js b/deploy/src/erc_to_erc/foreign.js index b64f874bb..68f0be4dc 100644 --- a/deploy/src/erc_to_erc/foreign.js +++ b/deploy/src/erc_to_erc/foreign.js @@ -16,10 +16,10 @@ const { foreignContracts: { EternalStorageProxy, BridgeValidators, - ForeignBridgeErcToErc: ForeignBridge, + ForeignBridgeErcToErc: ForeignBridgeAbsoluteDailyLimit, ForeignBridgeErcToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, - ForeignBridgeErc677ToErc677, - ForeignBridgeErc677ToErc677: ForeignBridgeErc677ToErc677RelativeDailyLimit, + ForeignBridgeErc677ToErc677: ForeignBridgeErc677ToErc677AbsoluteDailyLimit, + ForeignBridgeErc677ToErc677RelativeDailyLimit: ForeignBridgeErc677ToErc677RelativeDailyLimit, } } = require('../loadContracts') @@ -172,8 +172,8 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - let ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677 - let ForeignBridgeContract = ForeignBridge + let ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677AbsoluteDailyLimit + let ForeignBridgeContract = ForeignBridgeAbsoluteDailyLimit if (RELATIVE_DAILY_LIMIT) { ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677RelativeDailyLimit ForeignBridgeContract = ForeignBridgeRelativeDailyLimit diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index b03647565..3ba969d72 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -22,10 +22,10 @@ const { BridgeValidators, RewardableValidators, FeeManagerErcToErcPOSDAO, - HomeBridgeErcToErc: HomeBridge, + HomeBridgeErcToErc: HomeBridgeAbsoluteDailyLimit, HomeBridgeErcToErcRelativeDailyLimit: HomeBridgeRelativeDailyLimit, - HomeBridgeErcToErcPOSDAO, - HomeBridgeErcToErcPOSDAORelativeDailyLimit: HomeBridgeErcToErcPOSDAORelativeDailyLimit, + HomeBridgeErcToErcPOSDAO: HomeBridgePOSDAOAbsoluteDailyLimit, + HomeBridgeErcToErcPOSDAORelativeDailyLimit: HomeBridgePOSDAORelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable } @@ -212,14 +212,14 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - let HomeBridgeErcToErcPOSDAOContract = HomeBridgeErcToErcPOSDAO - let HomeBridgeContract = HomeBridge + let HomeBridgePOSDAOContract = HomeBridgePOSDAOAbsoluteDailyLimit + let HomeBridgeContract = HomeBridgeAbsoluteDailyLimit if (RELATIVE_DAILY_LIMIT) { - HomeBridgeErcToErcPOSDAOContract = HomeBridgeErcToErcPOSDAORelativeDailyLimit + HomeBridgePOSDAOContract = HomeBridgePOSDAORelativeDailyLimit HomeBridgeContract = HomeBridgeRelativeDailyLimit } const bridgeContract = - isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgeErcToErcPOSDAOContract : HomeBridgeContract + isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgePOSDAOContract : HomeBridgeContract const homeBridgeImplementation = await deployContract(bridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce diff --git a/deploy/src/erc_to_native/foreign.js b/deploy/src/erc_to_native/foreign.js index 3d2c5abf7..db4dfbd4c 100644 --- a/deploy/src/erc_to_native/foreign.js +++ b/deploy/src/erc_to_native/foreign.js @@ -16,7 +16,7 @@ const { foreignContracts: { EternalStorageProxy, BridgeValidators, - ForeignBridgeErcToNative: ForeignBridge, + ForeignBridgeErcToNative: ForeignBridgeAbsoluteDailyLimit, ForeignBridgeErcToNativeRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, } } = require('../loadContracts') @@ -150,7 +150,7 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index d0592ee58..10f3f4370 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -18,7 +18,7 @@ const { BridgeValidators, RewardableValidators, FeeManagerErcToNative, - HomeBridgeErcToNative: HomeBridge, + HomeBridgeErcToNative: HomeBridgeAbsoluteDailyLimit, HomeBridgeErcToNativeRelativeDailyLimit: HomeBridgeRelativeDailyLimit, FeeManagerErcToNativePOSDAO } @@ -213,7 +213,7 @@ async function deployHome() { nonce++ console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge + const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridgeAbsoluteDailyLimit const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index bf3aa8760..11f7d8e6f 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -19,7 +19,7 @@ const { EternalStorageProxy, BridgeValidators, RewardableValidators, - ForeignBridgeNativeToErc: ForeignBridge, + ForeignBridgeNativeToErc: ForeignBridgeAbsoluteDailyLimit, ForeignBridgeNativeToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, ERC677BridgeToken, ERC677BridgeTokenRewardable, @@ -238,7 +238,7 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', From 57a128f0395caf3ef2d6aca11b8b22ae5077713a Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 13:46:10 +0300 Subject: [PATCH 14/80] change the function for calculating the limit --- .../RelativeDailyLimit.sol | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index e360a483a..4fcfb78d2 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -14,16 +14,23 @@ contract RelativeDailyLimit is BasicTokenBridge { function dailyLimit() public view returns (uint256) { uint256 balance = _getTokenBalance(); - uint256 minBalance = targetLimit().mul(threshold()).div(100); - uint256 limit; - if (balance < minBalance) { - limit = 100; - } else if (balance >= minBalance && balance < threshold()) { - limit = targetLimit().mul(threshold()).div(balance); - } else { - limit = targetLimit(); + uint256 unlimitedBalance = minPerTx(); + if (balance <= unlimitedBalance) { + return balance; } - return balance.mul(limit).div(100); + uint256 limit = targetLimit(); + uint256 thresh = threshold(); + if (balance > unlimitedBalance && balance < thresh) { + // to save the gas we don't need to use safe math here + // because we check in setters that limit is always less than 1 ether + // and threshold is greater than minPerTx + // and minPerTx is less than threshold + uint256 a = (1 ether - limit) / (thresh - unlimitedBalance) ** 2; + uint256 b = 2 * a * thresh; + uint256 c = limit + a * thresh ** 2; + limit = a * balance ** 2 - b * balance + c; + } + return balance * limit / 1 ether; } function targetLimit() public view returns (uint256) { @@ -35,11 +42,13 @@ contract RelativeDailyLimit is BasicTokenBridge { } function setTargetLimit(uint256 _targetLimit) external onlyOwner { + require(_targetLimit <= 1 ether); uintStorage[TARGET_LIMIT] = _targetLimit; emit TargetLimitChanged(_targetLimit); } function setThreshold(uint256 _threshold) external onlyOwner { + require(_threshold >= minPerTx()); uintStorage[THRESHOLD] = _threshold; emit ThresholdChanged(_threshold); } From 0138dcd2381f51a1b2eff334a3227c08809c9d21 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 15 Oct 2019 13:56:13 +0300 Subject: [PATCH 15/80] fix linter errors --- contracts/upgradeable_contracts/RelativeDailyLimit.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index 4fcfb78d2..dd715c2aa 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -25,12 +25,12 @@ contract RelativeDailyLimit is BasicTokenBridge { // because we check in setters that limit is always less than 1 ether // and threshold is greater than minPerTx // and minPerTx is less than threshold - uint256 a = (1 ether - limit) / (thresh - unlimitedBalance) ** 2; + uint256 a = (1 ether - limit) / (thresh - unlimitedBalance)**2; uint256 b = 2 * a * thresh; - uint256 c = limit + a * thresh ** 2; - limit = a * balance ** 2 - b * balance + c; + uint256 c = limit + a * thresh**2; + limit = a * balance**2 - b * balance + c; } - return balance * limit / 1 ether; + return (balance * limit) / 1 ether; } function targetLimit() public view returns (uint256) { From d442a8ca9ac25609e80578dfce7e1fdb763ebf1a Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 22 Oct 2019 13:15:24 +0300 Subject: [PATCH 16/80] add relative execution daily limit --- .../BaseRelativeDailyLimit.sol | 59 +++++++++++++++++++ .../BasicTokenBridge.sol | 10 ++++ .../RelativeDailyLimit.sol | 56 ++---------------- .../RelativeExecutionDailyLimit.sol | 13 ++++ 4 files changed, 88 insertions(+), 50 deletions(-) create mode 100644 contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol create mode 100644 contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol new file mode 100644 index 000000000..fc19e8f17 --- /dev/null +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -0,0 +1,59 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "./BasicTokenBridge.sol"; + +contract BaseRelativeDailyLimit is BasicTokenBridge { + using SafeMath for uint256; + + event TargetLimitChanged(uint256 newLimit); + event ThresholdChanged(uint256 newThreshold); + + bytes32 internal constant TARGET_LIMIT = 0x192ac2d88a9de45ce541663ebe1aaf6d6b1d4a6299d3fd0abf2ba7e8b920342b; // keccak256(abi.encodePacked("targetLimit")) + bytes32 internal constant THRESHOLD = 0xd46c2b20c7303c2e50535d224276492e8a1eda2a3d7398e0bea254640c1154e7; // keccak256(abi.encodePacked("threshold")) + + function _calculateLimit() internal view returns (uint256) { + uint256 balance = _getTokenBalance(); + uint256 unlimitedBalance = _minPerTx(); + if (balance <= unlimitedBalance) { + return balance; + } + uint256 limit = targetLimit(); + uint256 thresh = threshold(); + if (balance > unlimitedBalance && balance < thresh) { + // to save the gas we don't need to use safe math here + // because we check in setters that limit is always less than 1 ether + // and threshold is greater than minPerTx + // and minPerTx is less than threshold + uint256 a = (1 ether - limit) / (thresh - unlimitedBalance)**2; + uint256 b = 2 * a * thresh; + uint256 c = limit + a * thresh**2; + limit = a * balance**2 - b * balance + c; + } + return (balance * limit) / 1 ether; + } + + function targetLimit() public view returns (uint256) { + return uintStorage[TARGET_LIMIT]; + } + + function threshold() public view returns (uint256) { + return uintStorage[THRESHOLD]; + } + + function setTargetLimit(uint256 _targetLimit) external onlyOwner { + require(_targetLimit <= 1 ether); + uintStorage[TARGET_LIMIT] = _targetLimit; + emit TargetLimitChanged(_targetLimit); + } + + function setThreshold(uint256 _threshold) external onlyOwner { + require(_threshold >= minPerTx()); + uintStorage[THRESHOLD] = _threshold; + emit ThresholdChanged(_threshold); + } + + function _minPerTx() internal view returns (uint256); + + function _getTokenBalance() internal view returns (uint256); +} diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 15723b45b..ad6bef2bc 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -13,6 +13,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // keccak256(abi.encodePacked("minPerTx")) bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // keccak256(abi.encodePacked("maxPerTx")) bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // keccak256(abi.encodePacked("dailyLimit")) + bytes32 internal constant EXECUTION_MIN_PER_TX = 0x0fc9356d7bc6ba08bb648a3ab811cf6e7c168745644ba25095b79e4d8a0c65ec; // keccak256(abi.encodePacked("executionMinPerTx")) bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // keccak256(abi.encodePacked("executionMaxPerTx")) bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // keccak256(abi.encodePacked("executionDailyLimit")) bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // keccak256(abi.encodePacked("decimalShift")) @@ -45,6 +46,10 @@ contract BasicTokenBridge is EternalStorage, Ownable { return uintStorage[MIN_PER_TX]; } + function executionMinPerTx() public view returns (uint256) { + return uintStorage[EXECUTION_MIN_PER_TX]; + } + function decimalShift() public view returns (uint256) { return uintStorage[DECIMAL_SHIFT]; } @@ -89,6 +94,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; } + function setExecutionMinPerTx(uint256 _minPerTx) external onlyOwner { + require(_minPerTx < executionDailyLimit() && _minPerTx < executionMaxPerTx()); + uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; + } + function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { require(_maxPerTx < dailyLimit()); uintStorage[MAX_PER_TX] = _maxPerTx; diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index dd715c2aa..d838cddc7 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -1,57 +1,13 @@ pragma solidity 0.4.24; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "./BasicTokenBridge.sol"; +import "./BaseRelativeDailyLimit.sol"; -contract RelativeDailyLimit is BasicTokenBridge { - using SafeMath for uint256; - - event TargetLimitChanged(uint256 newLimit); - event ThresholdChanged(uint256 newThreshold); - - bytes32 internal constant TARGET_LIMIT = 0x192ac2d88a9de45ce541663ebe1aaf6d6b1d4a6299d3fd0abf2ba7e8b920342b; // keccak256(abi.encodePacked("targetLimit")) - bytes32 internal constant THRESHOLD = 0xd46c2b20c7303c2e50535d224276492e8a1eda2a3d7398e0bea254640c1154e7; // keccak256(abi.encodePacked("threshold")) - - function dailyLimit() public view returns (uint256) { - uint256 balance = _getTokenBalance(); - uint256 unlimitedBalance = minPerTx(); - if (balance <= unlimitedBalance) { - return balance; - } - uint256 limit = targetLimit(); - uint256 thresh = threshold(); - if (balance > unlimitedBalance && balance < thresh) { - // to save the gas we don't need to use safe math here - // because we check in setters that limit is always less than 1 ether - // and threshold is greater than minPerTx - // and minPerTx is less than threshold - uint256 a = (1 ether - limit) / (thresh - unlimitedBalance)**2; - uint256 b = 2 * a * thresh; - uint256 c = limit + a * thresh**2; - limit = a * balance**2 - b * balance + c; - } - return (balance * limit) / 1 ether; - } - - function targetLimit() public view returns (uint256) { - return uintStorage[TARGET_LIMIT]; +contract RelativeDailyLimit is BaseRelativeDailyLimit { + function _minPerTx() internal view returns (uint256) { + return minPerTx(); } - function threshold() public view returns (uint256) { - return uintStorage[THRESHOLD]; - } - - function setTargetLimit(uint256 _targetLimit) external onlyOwner { - require(_targetLimit <= 1 ether); - uintStorage[TARGET_LIMIT] = _targetLimit; - emit TargetLimitChanged(_targetLimit); - } - - function setThreshold(uint256 _threshold) external onlyOwner { - require(_threshold >= minPerTx()); - uintStorage[THRESHOLD] = _threshold; - emit ThresholdChanged(_threshold); + function dailyLimit() public view returns (uint256) { + return _calculateLimit(); } - - function _getTokenBalance() internal view returns (uint256); } diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol new file mode 100644 index 000000000..7eeb0674f --- /dev/null +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -0,0 +1,13 @@ +pragma solidity 0.4.24; + +import "./BaseRelativeDailyLimit.sol"; + +contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { + function _minPerTx() internal view returns (uint256) { + return executionMinPerTx(); + } + + function executionDailyLimit() public view returns (uint256) { + return _calculateLimit(); + } +} From f26aca20d69942286a4d13f5365c08db521c85ba Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 22 Oct 2019 19:48:00 +0300 Subject: [PATCH 17/80] add executionMinPerTx to initialize methods --- .../BasicAMBErc677ToErc677.sol | 15 +- .../BasicForeignBridgeErcToErc.sol | 17 ++- .../ForeignBridgeErc677ToErc677.sol | 11 +- .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 4 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 27 ++-- .../HomeBridgeErcToErcPOSDAO.sol | 4 +- .../ForeignBridgeErcToNative.sol | 17 ++- .../erc20_to_native/HomeBridgeErcToNative.sol | 23 +-- .../ClassicHomeBridgeNativeToErc.sol | 4 +- .../ForeignBridgeNativeToErc.sol | 23 +-- .../native_to_erc20/HomeBridgeNativeToErc.sol | 23 +-- .../AMBErc677ToErc677Behavior.test.js | 66 ++++++--- .../foreign_bridge.test.js | 7 +- test/amb_erc677_to_erc677/home_bridge.test.js | 7 +- test/erc_to_erc/foreign_bridge.test.js | 43 +++--- test/erc_to_erc/home_bridge.test.js | 85 ++++++----- test/erc_to_native/foreign_bridge.test.js | 45 ++++-- test/erc_to_native/home_bridge.test.js | 137 +++++++++++------- test/native_to_erc/foreign_bridge_test.js | 77 +++++----- test/native_to_erc/home_bridge_test.js | 95 ++++++------ test/poa20_test.js | 9 +- 21 files changed, 434 insertions(+), 305 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index dfccd5d4d..7988f8f1e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -34,7 +34,7 @@ contract BasicAMBErc677ToErc677 is address _mediatorContract, address _erc677token, uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionDailyLimitExecutionMaxPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx ] + uint256[] _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] uint256 _requestGasLimit, uint256 _decimalShift, address _owner @@ -45,7 +45,11 @@ contract BasicAMBErc677ToErc677 is _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - require(_executionDailyLimitExecutionMaxPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxArray[0]); // _executionMaxPerTx < _executionDailyLimit + require( + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] > 0 && // _executionMinPerTx > 0 + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] > _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0] // _executionMaxPerTx < _executionDailyLimit + ); _setBridgeContract(_bridgeContract); _setMediatorContractOnOtherSide(_mediatorContract); @@ -53,8 +57,9 @@ contract BasicAMBErc677ToErc677 is uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxArray[1]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2]; _setRequestGasLimit(_requestGasLimit); uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); @@ -62,7 +67,7 @@ contract BasicAMBErc677ToErc677 is setInitialize(); emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 57437d9b4..ef0701b3b 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -9,7 +9,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx ] + uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] address _owner, uint256 _decimalShift ) internal { @@ -17,7 +17,11 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); - require(_maxPerTxHomeDailyLimitHomeMaxPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]); // _homeMaxPerTx < _homeDailyLimit + require( + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -25,16 +29,17 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[2]; + uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setInitialize(); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]); + emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); } function getBridgeMode() external pure returns (bytes4 _data) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index 27fa5a326..8da9a9db5 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -12,7 +12,7 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc uint256 _requiredBlockConfirmations, uint256 _gasPrice, uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _homeDailyLimitHomeMaxPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx ] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -21,16 +21,17 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - uint256[] memory _maxPerTxHomeDailyLimitHomeMaxPerTxArray = new uint256[](3); + uint256[] memory _maxPerTxHomeDailyLimitHomeMaxPerTxArray = new uint256[](4); _maxPerTxHomeDailyLimitHomeMaxPerTxArray[0] = _dailyLimitMaxPerTxMinPerTxArray[1]; // _maxPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1] = _homeDailyLimitHomeMaxPerTxArray[0]; // _homeDailyLimit - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[2] = _homeDailyLimitHomeMaxPerTxArray[1]; // _homeMaxPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; // _homeDailyLimit + _maxPerTxHomeDailyLimitHomeMaxPerTxArray[2] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; // _homeMaxPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxArray[3] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; // _homeMinPerTx _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _maxPerTxHomeDailyLimitHomeMaxPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx ] + _maxPerTxHomeDailyLimitHomeMaxPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] _owner, _decimalShift ); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index a317fd835..35e2dd252 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -9,7 +9,7 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx ] + uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -18,7 +18,7 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { _erc20token, _requiredBlockConfirmations, _gasPrice, - _maxPerTxHomeDailyLimitHomeMaxPerTxArray, + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 65ed05952..c75683123 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -21,7 +21,7 @@ contract HomeBridgeErcToErc is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -31,7 +31,7 @@ contract HomeBridgeErcToErc is _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -46,7 +46,7 @@ contract HomeBridgeErcToErc is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -58,7 +58,7 @@ contract HomeBridgeErcToErc is _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _feeManager, _homeFeeForeignFeeArray, @@ -75,7 +75,7 @@ contract HomeBridgeErcToErc is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -87,7 +87,7 @@ contract HomeBridgeErcToErc is _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -103,7 +103,7 @@ contract HomeBridgeErcToErc is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -115,7 +115,11 @@ contract HomeBridgeErcToErc is _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - require(_foreignDailyLimitForeignMaxPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxArray[0]); // _foreignMaxPerTx < _foreignDailyLimit + require( + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; uintStorage[DEPLOYED_AT_BLOCK] = block.number; @@ -124,8 +128,9 @@ contract HomeBridgeErcToErc is uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; uintStorage[GAS_PRICE] = _homeGasPrice; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxArray[1]; + uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setErc677token(_erc677token); @@ -133,7 +138,7 @@ contract HomeBridgeErcToErc is emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 1451951bd..6f25cae39 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -12,7 +12,7 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -25,7 +25,7 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _feeManager, _homeFeeForeignFeeArray, diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 03fbb5fdf..519de8768 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -11,7 +11,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxArray, //[ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx ] + uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, //[ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -19,7 +19,11 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); - require(_maxPerTxHomeDailyLimitHomeMaxPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]); // _homeMaxPerTx < _homeDailyLimit + require( + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -27,16 +31,17 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxArray[2]; + uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setInitialize(); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxArray[1]); + emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index 5a0927c53..ba9624475 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -50,7 +50,7 @@ contract HomeBridgeErcToNative is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -60,7 +60,7 @@ contract HomeBridgeErcToNative is _homeGasPrice, _requiredBlockConfirmations, _blockReward, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -75,7 +75,7 @@ contract HomeBridgeErcToNative is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -87,7 +87,7 @@ contract HomeBridgeErcToNative is _homeGasPrice, _requiredBlockConfirmations, _blockReward, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -122,7 +122,7 @@ contract HomeBridgeErcToNative is uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -135,7 +135,11 @@ contract HomeBridgeErcToNative is _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); require(_blockReward == address(0) || AddressUtils.isContract(_blockReward)); - require(_foreignDailyLimitForeignMaxPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxArray[0]); // _foreignMaxPerTx < _foreignDailyLimit + require( + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -146,15 +150,16 @@ contract HomeBridgeErcToNative is uintStorage[GAS_PRICE] = _homeGasPrice; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxArray[1]; + uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol index 74ec8e291..ab203f708 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol @@ -8,7 +8,7 @@ contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -17,7 +17,7 @@ contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 74b581649..c12c87556 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -20,7 +20,7 @@ contract ForeignBridgeNativeToErc is uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx ] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -30,7 +30,7 @@ contract ForeignBridgeNativeToErc is _dailyLimitMaxPerTxMinPerTxArray, _foreignGasPrice, _requiredBlockConfirmations, - _homeDailyLimitHomeMaxPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); @@ -44,7 +44,7 @@ contract ForeignBridgeNativeToErc is uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx ] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, address _feeManager, uint256 _homeFee, @@ -56,7 +56,7 @@ contract ForeignBridgeNativeToErc is _dailyLimitMaxPerTxMinPerTxArray, _foreignGasPrice, _requiredBlockConfirmations, - _homeDailyLimitHomeMaxPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); @@ -81,7 +81,7 @@ contract ForeignBridgeNativeToErc is uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx ] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -94,7 +94,11 @@ contract ForeignBridgeNativeToErc is ); require(_requiredBlockConfirmations > 0); require(_foreignGasPrice > 0); - require(_homeDailyLimitHomeMaxPerTxArray[1] < _homeDailyLimitHomeMaxPerTxArray[0]); // _homeMaxPerTx < _homeDailyLimit + require( + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -105,15 +109,16 @@ contract ForeignBridgeNativeToErc is uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; uintStorage[GAS_PRICE] = _foreignGasPrice; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxArray[1]; + uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_foreignGasPrice); emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxArray[0]); + emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); } function onExecuteMessage(address _recipient, uint256 _amount, bytes32 _txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 4617f2407..795e11f07 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -30,7 +30,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -39,7 +39,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -52,7 +52,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -63,7 +63,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -84,7 +84,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -97,7 +97,11 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - require(_foreignDailyLimitForeignMaxPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxArray[0]); // _foreignMaxPerTx < _foreignDailyLimit + require( + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -107,15 +111,16 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; uintStorage[GAS_PRICE] = _homeGasPrice; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxArray[1]; + uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function onSignaturesCollected(bytes _message) internal { diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 270214824..207c61840 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -16,6 +16,7 @@ const maxPerTx = oneEther const minPerTx = ether('0.01') const executionDailyLimit = dailyLimit const executionMaxPerTx = maxPerTx +const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 @@ -43,6 +44,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(await contract.minPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(ZERO) + expect(await contract.executionMinPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO) expect(await contract.owner()).to.be.equal(ZERO_ADDRESS) @@ -53,7 +55,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -67,7 +69,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, ZERO_ADDRESS, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -81,7 +83,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [maxPerTx, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -95,7 +97,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, minPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -109,7 +111,21 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionMaxPerTx, executionMaxPerTx], + [executionMaxPerTx, executionMaxPerTx, executionMinPerTx], + maxGasPerTx, + decimalShiftZero, + owner + ) + .should.be.rejectedWith(ERROR_MSG) + + // executionMaxPerTx > executionMinPerTx + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + [dailyLimit, maxPerTx, minPerTx], + [executionDailyLimit, executionMinPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -123,7 +139,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], dailyLimit, decimalShiftZero, owner @@ -135,7 +151,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -148,7 +164,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -164,6 +180,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(await contract.minPerTx()).to.be.bignumber.equal(minPerTx) expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(executionMaxPerTx) + expect(await contract.executionMinPerTx()).to.be.bignumber.equal(executionMinPerTx) expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx) expect(await contract.owner()).to.be.equal(owner) @@ -180,7 +197,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -205,7 +222,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -231,7 +248,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -266,7 +283,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [3, 2, 1], - [3, 2], + [3, 2, 1], maxGasPerTx, decimalShiftZero, owner @@ -306,6 +323,13 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) }) + it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { + await contract.setExecutionMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setExecutionMinPerTx(1, { from: owner }).should.be.fulfilled + expect(await contract.executionMinPerTx()).to.be.bignumber.equal('1') + + await contract.setExecutionMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) it('setExecutionDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { await contract.setExecutionDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) await contract.setExecutionDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) @@ -348,7 +372,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -514,7 +538,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc20Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -537,7 +561,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc20Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -551,7 +575,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc20Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -577,7 +601,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -606,7 +630,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -640,7 +664,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -750,7 +774,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -866,7 +890,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner diff --git a/test/amb_erc677_to_erc677/foreign_bridge.test.js b/test/amb_erc677_to_erc677/foreign_bridge.test.js index 16c424ff1..f81725504 100644 --- a/test/amb_erc677_to_erc677/foreign_bridge.test.js +++ b/test/amb_erc677_to_erc677/foreign_bridge.test.js @@ -22,6 +22,7 @@ const maxPerTx = oneEther const minPerTx = ether('0.01') const executionDailyLimit = dailyLimit const executionMaxPerTx = maxPerTx +const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 @@ -56,7 +57,7 @@ contract('ForeignAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -100,7 +101,7 @@ contract('ForeignAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -160,7 +161,7 @@ contract('ForeignAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftTwo, owner diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index e73ed8fd5..113476eec 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -22,6 +22,7 @@ const maxPerTx = oneEther const minPerTx = ether('0.01') const executionDailyLimit = dailyLimit const executionMaxPerTx = maxPerTx +const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 @@ -56,7 +57,7 @@ contract('HomeAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -107,7 +108,7 @@ contract('HomeAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner @@ -167,7 +168,7 @@ contract('HomeAMBErc677ToErc677', async accounts => { mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftTwo, owner diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index 746aeda9d..e80f61604 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -15,6 +15,7 @@ const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const homeDailyLimit = oneEther const homeMaxPerTx = halfEther +const homeMinPerTx = ether('0.01') const maxPerTx = halfEther const minPerTx = ether('0.01') const dailyLimit = oneEther @@ -51,7 +52,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -62,7 +63,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { ZERO_ADDRESS, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -73,7 +74,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { owner, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -84,7 +85,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, 0, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -95,7 +96,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, 0, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -106,7 +107,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -117,7 +118,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, '9' ) @@ -157,7 +158,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -288,7 +289,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, { from: ownerOfValidatorContract } @@ -348,7 +349,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -408,7 +409,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -436,7 +437,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { tokenAddress, requireBlockConfirmations, gasPrice, - ['2', '3', '2'], + ['2', '3', '2', '1'], owner, decimalShiftZero ) @@ -460,7 +461,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -493,7 +494,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -516,7 +517,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -546,7 +547,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -581,7 +582,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -622,7 +623,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -660,7 +661,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) @@ -703,7 +704,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) @@ -754,7 +755,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index fa51afc79..4e31137b7 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -21,6 +21,7 @@ const oneEther = ether('1') const halfEther = ether('0.5') const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther +const foreignMinPerTx = minPerTx const ZERO = toBN(0) const decimalShiftZero = 0 const markedAsProcessed = toBN(2) @@ -58,7 +59,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, '9' ).should.be.fulfilled @@ -94,7 +95,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -106,7 +107,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -124,7 +125,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -149,7 +150,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, 0, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -161,7 +162,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -173,7 +174,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -185,7 +186,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, ZERO_ADDRESS, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -197,7 +198,19 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, owner, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [halfEther, oneEther, quarterEther], owner, decimalShiftZero ) @@ -209,7 +222,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [halfEther, oneEther], + [oneEther, halfEther, halfEther], owner, decimalShiftZero ) @@ -220,7 +233,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -238,7 +251,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { 0, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -258,7 +271,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -284,7 +297,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -315,7 +328,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -400,7 +413,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token2sig.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -485,7 +498,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token2sig.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -527,7 +540,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -683,7 +696,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token2sig.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -753,7 +766,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -860,7 +873,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1132,7 +1145,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1188,7 +1201,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1214,7 +1227,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, ZERO_ADDRESS, [homeFee, foreignFee], @@ -1227,7 +1240,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1273,7 +1286,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1299,7 +1312,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1329,7 +1342,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1369,7 +1382,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1391,7 +1404,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1431,7 +1444,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1468,7 +1481,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1512,7 +1525,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1706,7 +1719,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1911,7 +1924,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ) @@ -1961,7 +1974,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ).should.be.fulfilled diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index e83436337..453459625 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -8,12 +8,14 @@ const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, sign, signatureToVRS, ether, expectEventInLogs } = require('../helpers/helpers') +const quarterEther = ether('0.25') const halfEther = ether('0.5') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const oneEther = ether('1') const homeDailyLimit = oneEther const homeMaxPerTx = halfEther +const homeMinPerTx = quarterEther const maxPerTx = halfEther const ZERO = toBN(0) const decimalShiftZero = 0 @@ -48,7 +50,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -59,7 +61,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { ZERO_ADDRESS, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -70,7 +72,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, 0, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -81,7 +83,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, 0, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -92,7 +94,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { owner, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -103,7 +105,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -114,7 +116,18 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, halfEther, homeMaxPerTx], + [maxPerTx, halfEther, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMaxPerTx], owner, decimalShiftZero ) @@ -125,7 +138,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, '9' ) @@ -165,7 +178,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -309,7 +322,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, { from: ownerOfValidatorContract } @@ -375,7 +388,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -436,7 +449,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -460,7 +473,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { tokenAddress, requireBlockConfirmations, gasPrice, - ['2', '3', '2'], + ['2', '3', '2', '1'], owner, decimalShiftZero ) @@ -488,7 +501,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -530,7 +543,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) @@ -575,7 +588,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx], + [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo, { from: ownerOfValidatorContract } diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index 3cb22c3f2..a6ff38e46 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -20,6 +20,7 @@ const oneEther = ether('1') const halfEther = ether('0.5') const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther +const foreignMinPerTx = quarterEther const ZERO = toBN(0) const decimalShiftZero = 0 @@ -56,7 +57,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, '9' ).should.be.fulfilled @@ -94,7 +95,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -133,7 +134,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -145,7 +146,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -163,7 +164,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -189,7 +190,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - ['3', '2'], + ['3', '2', '1'], homeOwner, decimalShiftZero ) @@ -225,7 +226,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, 0, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -237,7 +238,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -249,7 +250,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -261,7 +262,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, owner, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -273,7 +274,19 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [halfEther, oneEther], + [halfEther, oneEther, quarterEther], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [oneEther, halfEther, halfEther], owner, decimalShiftZero ) @@ -284,7 +297,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -317,7 +330,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -357,7 +370,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, 0, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -371,7 +384,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -385,7 +398,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -399,7 +412,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, owner, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -413,7 +426,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [halfEther, oneEther], + [halfEther, oneEther, quarterEther], owner, feeManager.address, [homeFee, foreignFee], @@ -427,7 +440,21 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [oneEther, halfEther, halfEther], + owner, + feeManager.address, + [homeFee, foreignFee], + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .rewardableInitialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, ZERO_ADDRESS, [homeFee, foreignFee], @@ -440,7 +467,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -456,7 +483,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -481,7 +508,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -509,7 +536,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -545,7 +572,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -689,7 +716,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -727,6 +754,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { executionMaxPerTx.should.be.bignumber.equal(newValue) }) + it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { + const newValue = ether('0.1') + await homeContract.setExecutionMinPerTx(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setExecutionMinPerTx(newValue, { from: owner }).should.be.fulfilled + + await homeContract.setExecutionMinPerTx(ether('0.6'), { from: owner }).should.be.rejectedWith(ERROR_MSG) + const minPerTx = await homeContract.executionMinPerTx() + minPerTx.should.be.bignumber.equal(newValue) + }) + it('executionDailyLimit allows to set only to owner', async () => { const newValue = ether('1.5') @@ -758,7 +795,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -833,7 +870,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -897,7 +934,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, ZERO_ADDRESS, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -923,7 +960,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -1074,7 +1111,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -1142,7 +1179,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -1248,7 +1285,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -1486,7 +1523,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1556,7 +1593,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1640,7 +1677,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1714,7 +1751,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1819,7 +1856,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1921,7 +1958,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -1977,7 +2014,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2046,7 +2083,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2140,7 +2177,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2253,7 +2290,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2330,7 +2367,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2439,7 +2476,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2554,7 +2591,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2611,7 +2648,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2687,7 +2724,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2788,7 +2825,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2902,7 +2939,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ) @@ -2963,7 +3000,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ) diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index e39f43809..e23cac966 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -18,6 +18,7 @@ const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const homeDailyLimit = oneEther const homeMaxPerTx = halfEther +const homeMinPerTx = minPerTx const ZERO = toBN(0) const decimalShiftZero = 0 @@ -53,7 +54,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -65,7 +66,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -77,7 +78,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], 0, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -89,7 +90,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], requireBlockConfirmations, gasPrice, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -101,7 +102,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], requireBlockConfirmations, gasPrice, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -113,7 +114,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, 0, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -124,7 +125,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, '9' ) @@ -167,7 +168,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -312,7 +313,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, { from: ownerOfValidatorContract } @@ -376,7 +377,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -424,7 +425,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -472,7 +473,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -496,7 +497,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -531,7 +532,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -570,7 +571,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -602,7 +603,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -655,7 +656,7 @@ contract('ForeignBridge', async accounts => { [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -685,7 +686,7 @@ contract('ForeignBridge', async accounts => { [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -710,7 +711,7 @@ contract('ForeignBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -734,7 +735,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -766,7 +767,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -798,7 +799,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero ) @@ -850,7 +851,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -864,7 +865,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -878,7 +879,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], 0, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -892,7 +893,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], requireBlockConfirmations, gasPrice, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -906,7 +907,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], requireBlockConfirmations, gasPrice, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -920,7 +921,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], requireBlockConfirmations, gasPrice, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, ZERO_ADDRESS, homeFee, @@ -933,7 +934,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -970,7 +971,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -995,7 +996,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -1019,7 +1020,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -1052,7 +1053,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, homeFee, @@ -1094,7 +1095,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, feeInWei, @@ -1152,7 +1153,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, feeInWei, @@ -1238,7 +1239,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, feeManager.address, feeInWei, @@ -1320,7 +1321,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) @@ -1369,7 +1370,7 @@ contract('ForeignBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo ) diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index dddfc7a43..26d472670 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -20,6 +20,7 @@ const twoEther = ether('2') const halfEther = ether('0.5') const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther +const foreignMinPerTx = minPerTx const ZERO = toBN(0) const decimalShiftZero = 0 @@ -52,7 +53,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, '9' ).should.be.fulfilled @@ -87,7 +88,7 @@ contract('HomeBridge', async accounts => { ['1', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -98,7 +99,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '2'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -112,7 +113,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -137,7 +138,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -167,7 +168,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -191,7 +192,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, 0, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -202,7 +203,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -213,7 +214,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -223,7 +224,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -236,7 +237,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -262,7 +263,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -282,7 +283,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -373,7 +374,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -414,7 +415,7 @@ contract('HomeBridge', async accounts => { [twoEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -489,7 +490,7 @@ contract('HomeBridge', async accounts => { [twoEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -577,7 +578,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -651,7 +652,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -764,7 +765,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -824,7 +825,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -927,7 +928,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -956,7 +957,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2'], + ['3', '2', '1'], owner, decimalShiftZero ) @@ -985,7 +986,7 @@ contract('HomeBridge', async accounts => { [oneEther.toString(), halfEther.toString(), '1'], gasPrice, requireBlockConfirmations, - [oneEther.toString(), halfEther.toString()], + [oneEther.toString(), halfEther.toString(), '1'], owner, decimalShiftZero ) @@ -1033,7 +1034,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1046,7 +1047,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], 0, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1059,7 +1060,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, 0, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1072,7 +1073,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, ZERO_ADDRESS, [homeFee, foreignFee], @@ -1084,7 +1085,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1118,7 +1119,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1143,7 +1144,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1167,7 +1168,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1198,7 +1199,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1220,7 +1221,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [homeFee, foreignFee], @@ -1260,7 +1261,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [notUsedFee, feeInWei], @@ -1310,7 +1311,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [notUsedFee, feeInWei], @@ -1370,7 +1371,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [notUsedFee, feeInWei], @@ -1442,7 +1443,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [notUsedFee, feeInWei], @@ -1537,7 +1538,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [notUsedFee, feeInWei], @@ -1636,7 +1637,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -1691,7 +1692,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -1754,7 +1755,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -1838,7 +1839,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -1924,7 +1925,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -1995,7 +1996,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -2089,7 +2090,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, feeManager.address, [feeInWei, feeInWei], @@ -2176,7 +2177,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ) @@ -2226,7 +2227,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftTwo ) diff --git a/test/poa20_test.js b/test/poa20_test.js index 79cbfbae0..7cb8b158e 100644 --- a/test/poa20_test.js +++ b/test/poa20_test.js @@ -19,6 +19,7 @@ const oneEther = ether('1') const halfEther = ether('0.5') const executionDailyLimit = oneEther const executionMaxPerTx = halfEther +const executionMinPerTx = minPerTx const ZERO = new BN(0) const decimalShiftZero = 0 @@ -234,7 +235,7 @@ async function testERC677BridgeToken(accounts, rewardable) { gasPrice, requireBlockConfirmations, token.address, - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero ) @@ -245,7 +246,7 @@ async function testERC677BridgeToken(accounts, rewardable) { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero ) @@ -411,7 +412,7 @@ async function testERC677BridgeToken(accounts, rewardable) { gasPrice, requireBlockConfirmations, token.address, - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero ) @@ -422,7 +423,7 @@ async function testERC677BridgeToken(accounts, rewardable) { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero ) From 77a19d9de730db30f061900fba7ec3b12c30d76a Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 22 Oct 2019 21:41:19 +0300 Subject: [PATCH 18/80] update deployment scripts --- deploy/src/amb_erc677_to_erc677/initialize.js | 12 ++++++++---- deploy/src/erc_to_erc/foreign.js | 6 ++++-- deploy/src/erc_to_erc/home.js | 5 +++-- deploy/src/erc_to_native/foreign.js | 4 +++- deploy/src/erc_to_native/home.js | 11 +++++++++-- deploy/src/native_to_erc/foreign.js | 7 +++++-- deploy/src/native_to_erc/home.js | 11 +++++++++-- 7 files changed, 41 insertions(+), 15 deletions(-) diff --git a/deploy/src/amb_erc677_to_erc677/initialize.js b/deploy/src/amb_erc677_to_erc677/initialize.js index 9eb3959c2..beed5bb39 100644 --- a/deploy/src/amb_erc677_to_erc677/initialize.js +++ b/deploy/src/amb_erc677_to_erc677/initialize.js @@ -50,6 +50,7 @@ async function initialize({ minPerTx, executionDailyLimit, executionMaxPerTx, + executionMinPerTx, requestGasLimit, foreignToHomeDecimalShift, owner @@ -61,15 +62,16 @@ async function initialize({ const contract = new web3.eth.Contract(abi, address) console.log(` - AMB contract: ${bridgeContract}, - Mediator contract: ${mediatorContract}, + AMB contract: ${bridgeContract}, + Mediator contract: ${mediatorContract}, Token contract: ${erc677token}, DAILY_LIMIT : ${dailyLimit} which is ${Web3Utils.fromWei(dailyLimit)} in eth, MAX_AMOUNT_PER_TX: ${maxPerTx} which is ${Web3Utils.fromWei(maxPerTx)} in eth, MIN_AMOUNT_PER_TX: ${minPerTx} which is ${Web3Utils.fromWei(minPerTx)} in eth, EXECUTION_DAILY_LIMIT : ${executionDailyLimit} which is ${Web3Utils.fromWei(executionDailyLimit)} in eth, EXECUTION_MAX_AMOUNT_PER_TX: ${executionMaxPerTx} which is ${Web3Utils.fromWei(executionMaxPerTx)} in eth, - MEDIATOR_REQUEST_GAS_LIMIT : ${requestGasLimit}, + EXECUTION_MIN_AMOUNT_PER_TX: ${executionMinPerTx} which is ${Web3Utils.fromWei(executionMinPerTx)} in eth, + MEDIATOR_REQUEST_GAS_LIMIT : ${requestGasLimit}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} OWNER: ${owner} `) @@ -80,7 +82,7 @@ async function initialize({ mediatorContract, erc677token, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], requestGasLimit, foreignToHomeDecimalShift, owner @@ -130,6 +132,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { minPerTx: HOME_MIN_AMOUNT_PER_TX, executionDailyLimit: FOREIGN_DAILY_LIMIT, executionMaxPerTx: FOREIGN_MAX_AMOUNT_PER_TX, + executionMinPerTx: FOREIGN_MIN_AMOUNT_PER_TX, requestGasLimit: HOME_MEDIATOR_REQUEST_GAS_LIMIT, foreignToHomeDecimalShift, owner: HOME_BRIDGE_OWNER @@ -154,6 +157,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { minPerTx: FOREIGN_MIN_AMOUNT_PER_TX, executionDailyLimit: HOME_DAILY_LIMIT, executionMaxPerTx: HOME_MAX_AMOUNT_PER_TX, + executionMinPerTx: HOME_MIN_AMOUNT_PER_TX, requestGasLimit: FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT, foreignToHomeDecimalShift, owner: FOREIGN_BRIDGE_OWNER diff --git a/deploy/src/erc_to_erc/foreign.js b/deploy/src/erc_to_erc/foreign.js index 68f0be4dc..be769ce59 100644 --- a/deploy/src/erc_to_erc/foreign.js +++ b/deploy/src/erc_to_erc/foreign.js @@ -37,6 +37,7 @@ const { FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, + HOME_MIN_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX, FOREIGN_DAILY_LIMIT, ERC20_EXTENDED_BY_ERC677, @@ -57,6 +58,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, + HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) @@ -70,7 +72,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_GAS_PRICE, [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX], + [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift ) @@ -82,7 +84,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { ERC20_TOKEN_ADDRESS, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_GAS_PRICE, - [FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX], + [FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index 3ba969d72..b46e2a66c 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -49,6 +49,7 @@ const { BRIDGEABLE_TOKEN_DECIMALS, FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, + FOREIGN_MIN_AMOUNT_PER_TX, DEPLOY_REWARDABLE_TOKEN, BLOCK_REWARD_ADDRESS, DPOS_STAKING_ADDRESS, @@ -103,7 +104,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, erc677token.options.address, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], @@ -126,7 +127,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, erc677token.options.address, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/erc_to_native/foreign.js b/deploy/src/erc_to_native/foreign.js index db4dfbd4c..96aa98c9c 100644 --- a/deploy/src/erc_to_native/foreign.js +++ b/deploy/src/erc_to_native/foreign.js @@ -35,6 +35,7 @@ const { FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, + HOME_MIN_AMOUNT_PER_TX, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, } = env @@ -52,6 +53,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, + HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) @@ -61,7 +63,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { ERC20_TOKEN_ADDRESS, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_GAS_PRICE, - [FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX], + [FOREIGN_MAX_AMOUNT_PER_TX, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index 10f3f4370..49172e698 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -40,6 +40,7 @@ const { HOME_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, + FOREIGN_MIN_AMOUNT_PER_TX, HOME_REWARDABLE, HOME_TRANSACTIONS_FEE, FOREIGN_TRANSACTIONS_FEE, @@ -88,6 +89,9 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, + FOREIGN_MIN_AMOUNT_PER_TX: ${FOREIGN_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( + FOREIGN_MIN_AMOUNT_PER_TX + )} in eth,s HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}% @@ -100,7 +104,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, BLOCK_REWARD_ADDRESS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], @@ -119,6 +123,9 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, + FOREIGN_MIN_AMOUNT_PER_TX: ${FOREIGN_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( + FOREIGN_MIN_AMOUNT_PER_TX + )} in eth, HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) @@ -129,7 +136,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, BLOCK_REWARD_ADDRESS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index 11f7d8e6f..d738fd7db 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -45,6 +45,7 @@ const { BRIDGEABLE_TOKEN_DECIMALS, HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, + HOME_MIN_AMOUNT_PER_TX, DEPLOY_REWARDABLE_TOKEN, BLOCK_REWARD_ADDRESS, DPOS_STAKING_ADDRESS, @@ -94,6 +95,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, + HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}%, @@ -106,7 +108,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], FOREIGN_GAS_PRICE, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX], + [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, feeManager.options.address, homeFeeInWei, @@ -126,6 +128,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, + HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) @@ -137,7 +140,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], FOREIGN_GAS_PRICE, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX], + [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/native_to_erc/home.js b/deploy/src/native_to_erc/home.js index f6c84d127..83df6d551 100644 --- a/deploy/src/native_to_erc/home.js +++ b/deploy/src/native_to_erc/home.js @@ -39,6 +39,7 @@ const { HOME_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, + FOREIGN_MIN_AMOUNT_PER_TX, HOME_REWARDABLE, HOME_TRANSACTIONS_FEE, FOREIGN_TRANSACTIONS_FEE, @@ -87,6 +88,9 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, + FOREIGN_MIN_AMOUNT_PER_TX: ${FOREIGN_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( + FOREIGN_MIN_AMOUNT_PER_TX + )} in eth, HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${homeFee * 100}% @@ -99,7 +103,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], @@ -117,6 +121,9 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, + FOREIGN_MIN_AMOUNT_PER_TX: ${FOREIGN_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( + FOREIGN_MIN_AMOUNT_PER_TX + )} in eth, HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) @@ -126,7 +133,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, foreignToHomeDecimalShift ) From 9be85c30ada49c712f1628af9026eaed1517a297 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 23 Oct 2019 14:41:05 +0300 Subject: [PATCH 19/80] use relative daily limit only for withdrawal --- .../ForeignAMBErc677ToErc677RelativeDailyLimit.sol | 4 ++-- .../BasicForeignBridgeErcToErcRelativeDailyLimit.sol | 4 ++-- .../ForeignBridgeErcToNativeRelativeDailyLimit.sol | 4 ++-- .../ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol | 4 ++-- .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index 245a7ac40..1e3930eb2 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "./ForeignAMBErc677ToErc677.sol"; -import "../RelativeDailyLimit.sol"; +import "../RelativeExecutionDailyLimit.sol"; -contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeDailyLimit { +contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { function _getTokenBalance() internal view returns (uint256) { return erc677token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol index 89547721a..7e2871563 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "./BasicForeignBridgeErcToErc.sol"; -import "../RelativeDailyLimit.sol"; +import "../RelativeExecutionDailyLimit.sol"; -contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeDailyLimit { +contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeExecutionDailyLimit { function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index d5219086d..085c121eb 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "./ForeignBridgeErcToNative.sol"; -import "../RelativeDailyLimit.sol"; +import "../RelativeExecutionDailyLimit.sol"; -contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeDailyLimit { +contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeExecutionDailyLimit { function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol index 63493d372..4104669d8 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol @@ -2,9 +2,9 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ClassicHomeBridgeNativeToErc.sol"; -import "../RelativeDailyLimit.sol"; +import "../RelativeExecutionDailyLimit.sol"; -contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, RelativeDailyLimit { +contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, RelativeExecutionDailyLimit { function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index d18fae799..e15dcddd4 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "./HomeBridgeNativeToErc.sol"; -import "../RelativeDailyLimit.sol"; +import "../RelativeExecutionDailyLimit.sol"; -contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeDailyLimit { +contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } From 23b1fa33420aa958bfc8c0e0fe4ab0e3d6a3ac9e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 24 Oct 2019 14:19:00 +0300 Subject: [PATCH 20/80] rename array --- .../erc20_to_erc20/ForeignBridgeErc677ToErc677.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index 8da9a9db5..06f057e5a 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -21,17 +21,17 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - uint256[] memory _maxPerTxHomeDailyLimitHomeMaxPerTxArray = new uint256[](4); - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[0] = _dailyLimitMaxPerTxMinPerTxArray[1]; // _maxPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[1] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; // _homeDailyLimit - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[2] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; // _homeMaxPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxArray[3] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; // _homeMinPerTx + uint256[] memory _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray = new uint256[](4); + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] = _dailyLimitMaxPerTxMinPerTxArray[1]; // _maxPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; // _homeDailyLimit + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; // _homeMaxPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; // _homeMinPerTx _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _maxPerTxHomeDailyLimitHomeMaxPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] _owner, _decimalShift ); From 14f17e955a3b8484292cdc6add9870ce05530040 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 24 Oct 2019 21:54:11 +0300 Subject: [PATCH 21/80] fix --- contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol index fc19e8f17..96b917a4f 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -48,7 +48,7 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { } function setThreshold(uint256 _threshold) external onlyOwner { - require(_threshold >= minPerTx()); + require(_threshold >= _minPerTx()); uintStorage[THRESHOLD] = _threshold; emit ThresholdChanged(_threshold); } From f718acb92a2b4d2e068b36c39ed85c6a9b67a8fa Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 25 Oct 2019 16:30:41 +0300 Subject: [PATCH 22/80] Extend initialize methods --- .../BasicAMBErc677ToErc677.sol | 34 ++++++-- ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 42 +++++++++ ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 42 +++++++++ .../BasicForeignBridgeErcToErc.sol | 11 --- .../ForeignBridgeErc677ToErc677.sol | 25 +++--- ...BridgeErc677ToErc677RelativeDailyLimit.sol | 47 +++++++++- .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 15 +++- ...oreignBridgeErcToErcRelativeDailyLimit.sol | 37 +++++++- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 58 +++++++------ .../HomeBridgeErcToErcPOSDAO.sol | 6 +- ...BridgeErcToErcPOSDAORelativeDailyLimit.sol | 35 +++++++- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 83 ++++++++++++++++++ .../ForeignBridgeErcToNative.sol | 39 +++++++-- ...ignBridgeErcToNativeRelativeDailyLimit.sol | 30 +++++++ .../erc20_to_native/HomeBridgeErcToNative.sol | 58 +++++++------ ...omeBridgeErcToNativeRelativeDailyLimit.sol | 85 +++++++++++++++++++ .../ClassicHomeBridgeNativeToErc.sol | 2 - .../ForeignBridgeNativeToErc.sol | 58 +++++++------ ...ignBridgeNativeToErcRelativeDailyLimit.sol | 82 ++++++++++++++++++ .../native_to_erc20/HomeBridgeNativeToErc.sol | 54 +++++++----- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 79 +++++++++++++++++ 21 files changed, 781 insertions(+), 141 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 7988f8f1e..e09e89978 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -39,7 +39,6 @@ contract BasicAMBErc677ToErc677 is uint256 _decimalShift, address _owner ) external returns (bool) { - require(!isInitialized()); require( _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx @@ -51,24 +50,45 @@ contract BasicAMBErc677ToErc677 is _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0] // _executionMaxPerTx < _executionDailyLimit ); - _setBridgeContract(_bridgeContract); - _setMediatorContractOnOtherSide(_mediatorContract); - setErc677token(_erc677token); uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); + + return _initialize( + _bridgeContract, + _mediatorContract, + _erc677token, + _requestGasLimit, + _decimalShift, + _owner + ); + } + + function _initialize( + address _bridgeContract, + address _mediatorContract, + address _erc677token, + uint256 _requestGasLimit, + uint256 _decimalShift, + address _owner + ) internal returns (bool) { + require(!isInitialized()); + + _setBridgeContract(_bridgeContract); + _setMediatorContractOnOtherSide(_mediatorContract); + setErc677token(_erc677token); _setRequestGasLimit(_requestGasLimit); uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setNonce(keccak256(abi.encodePacked(address(this)))); setInitialize(); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); - return isInitialized(); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index 1e3930eb2..6d75ab27e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,6 +4,48 @@ import "./ForeignAMBErc677ToErc677.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { + function initialize( + address _bridgeContract, + address _mediatorContract, + address _erc677token, + uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256 _requestGasLimit, + uint256 _decimalShift, + address _owner + ) external returns (bool) { + require( + _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 + _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx + _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + ); + require( + _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3] > 0 && // _executionMinPerTx > 0 + _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[2] > _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3] // _executionMaxPerTx > _executionMinPerTx + ); + require(_targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[1] >= _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3]); // _threshold >= _executionMinPerTx + + uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; + uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; + uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + + return _initialize( + _bridgeContract, + _mediatorContract, + _erc677token, + _requestGasLimit, + _decimalShift, + _owner + ); + } + function _getTokenBalance() internal view returns (uint256) { return erc677token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index 2f4dae04b..eedaee528 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,6 +4,48 @@ import "./HomeAMBErc677ToErc677.sol"; import "../RelativeDailyLimit.sol"; contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, RelativeDailyLimit { + function initialize( + address _bridgeContract, + address _mediatorContract, + address _erc677token, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + uint256 _requestGasLimit, + uint256 _decimalShift, + address _owner + ) external returns (bool) { + require( + _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 + _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + ); + require( + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] > 0 && // _executionMinPerTx > 0 + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] > _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0] // _executionMaxPerTx < _executionDailyLimit + ); + require(_targetLimitThresholdMaxPerTxMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_targetLimitThresholdMaxPerTxMinPerTxArray[1] >= _targetLimitThresholdMaxPerTxMinPerTxArray[3]); // _threshold >= _executionMinPerTx + + uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; + uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; + uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2]; + + emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); + + return _initialize( + _bridgeContract, + _mediatorContract, + _erc677token, + _requestGasLimit, + _decimalShift, + _owner + ); + } + function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index ef0701b3b..6a9fb6761 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -9,7 +9,6 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] address _owner, uint256 _decimalShift ) internal { @@ -17,11 +16,6 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); - require( - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit - ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -29,17 +23,12 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setInitialize(); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); } function getBridgeMode() external pure returns (bytes4 _data) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index 06f057e5a..fc2e503e8 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -12,7 +12,7 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc uint256 _requiredBlockConfirmations, uint256 _gasPrice, uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -21,25 +21,30 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - uint256[] memory _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray = new uint256[](4); - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] = _dailyLimitMaxPerTxMinPerTxArray[1]; // _maxPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; // _homeDailyLimit - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; // _homeMaxPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; // _homeMinPerTx + require( + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + ); + + uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; + uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; + uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] _owner, _decimalShift ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index f679a6b39..09086b3c4 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -7,4 +7,49 @@ import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; contract ForeignBridgeErc677ToErc677RelativeDailyLimit is BasicForeignBridgeErcToErcRelativeDailyLimit, ForeignBridgeErc677ToErc677 -{} +{ + function initialize( + address _validatorContract, + address _erc20token, + uint256 _requiredBlockConfirmations, + uint256 _gasPrice, + uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + require( + _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 + _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx + _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + ); + require( + _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 + _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] > _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx + _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] < _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + ); + require(_targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] >= _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]); // _threshold >= _homeMinPerTx + + uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; + uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; + uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; + + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _owner, + _decimalShift + ); + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + + return isInitialized(); + } +} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index 35e2dd252..4bf709d25 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -13,15 +13,28 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { address _owner, uint256 _decimalShift ) external returns (bool) { + require( + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx + _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + ); + + uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; + _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); + + emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); + return isInitialized(); } } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index 755e4820c..726e50412 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -7,4 +7,39 @@ import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; contract ForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErcRelativeDailyLimit, ForeignBridgeErcToErc -{} +{ + function initialize( + address _validatorContract, + address _erc20token, + uint256 _requiredBlockConfirmations, + uint256 _gasPrice, + uint256[] _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + require( + _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] > 0 && // _homeMinPerTx > 0 + _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] && // _homeMaxPerTx > _homeMinPerTx + _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] < _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] // _homeMaxPerTx < _homeDailyLimit + ); + require(_maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] <= 1 ether); // _targetLimit <= 1 ether + require(_maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] >= _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]); // _threshold >= _homeMinPerTx + + uintStorage[MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[TARGET_LIMIT] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[THRESHOLD] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]; + + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _owner, + _decimalShift + ); + + return isInitialized(); + } +} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index c75683123..1da40d0f1 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -25,13 +25,15 @@ contract HomeBridgeErcToErc is address _owner, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -52,13 +54,15 @@ contract HomeBridgeErcToErc is uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _rewardableInitialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _feeManager, _homeFeeForeignFeeArray, @@ -71,11 +75,9 @@ contract HomeBridgeErcToErc is function _rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -83,11 +85,9 @@ contract HomeBridgeErcToErc is ) internal { _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -97,19 +97,10 @@ contract HomeBridgeErcToErc is _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); } - function _initialize( - address _validatorContract, + function _setLimits( uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations > 0); require( _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx @@ -120,25 +111,40 @@ contract HomeBridgeErcToErc is _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - require(_owner != address(0)); - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[GAS_PRICE] = _homeGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + } + + function _initialize( + address _validatorContract, + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _erc677token, + address _owner, + uint256 _decimalShift + ) internal { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_owner != address(0)); + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _homeGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setErc677token(_erc677token); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 6f25cae39..ccc095143 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -19,13 +19,15 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { address _blockReward, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _rewardableInitialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _erc677token, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _feeManager, _homeFeeForeignFeeArray, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol index b60da9ff1..e7f11503d 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol @@ -4,4 +4,37 @@ import "./HomeBridgeErcToErcPOSDAO.sol"; import "./HomeBridgeErcToErcRelativeDailyLimit.sol"; // solhint-disable-next-line no-empty-blocks -contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativeDailyLimit, HomeBridgeErcToErcPOSDAO {} +contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativeDailyLimit, HomeBridgeErcToErcPOSDAO { + function rewardableInitialize( + address _validatorContract, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _erc677token, + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _owner, + address _feeManager, + uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] + address _blockReward, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); + _rewardableInitialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _erc677token, + _owner, + _feeManager, + _homeFeeForeignFeeArray, + _decimalShift + ); + _setBlockRewardContract(_feeManager, _blockReward); + setInitialize(); + + return isInitialized(); + } +} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index d4bc3dcb3..e48d73ca1 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -4,6 +4,89 @@ import "./HomeBridgeErcToErc.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { + function initialize( + address _validatorContract, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _erc677token, + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); + _initialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _erc677token, + _owner, + _decimalShift + ); + setInitialize(); + + return isInitialized(); + } + + function rewardableInitialize( + address _validatorContract, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _erc677token, + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _owner, + address _feeManager, + uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); + _rewardableInitialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _erc677token, + _owner, + _feeManager, + _homeFeeForeignFeeArray, + _decimalShift + ); + setInitialize(); + + return isInitialized(); + } + + function _setLimits( + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + ) internal { + require( + _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 + _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + ); + require( + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + ); + + uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; + uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; + uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + } + function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 519de8768..075b37a54 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -15,15 +15,41 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { address _owner, uint256 _decimalShift ) external returns (bool) { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations != 0); - require(_gasPrice > 0); require( _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit ); + + uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; + + emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); + + return _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _owner, + _decimalShift + ); + } + + function _initialize( + address _validatorContract, + address _erc20token, + uint256 _requiredBlockConfirmations, + uint256 _gasPrice, + address _owner, + uint256 _decimalShift + ) internal returns (bool) { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations != 0); + require(_gasPrice > 0); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -31,17 +57,12 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setInitialize(); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 085c121eb..efd2f57a2 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -4,6 +4,36 @@ import "./ForeignBridgeErcToNative.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeExecutionDailyLimit { + function initialize( + address _validatorContract, + address _erc20token, + uint256 _requiredBlockConfirmations, + uint256 _gasPrice, + uint256[] _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, //[ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + require( + _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] > 0 && // _homeMinPerTx > 0 + _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] // _homeMaxPerTx > _homeMinPerTx + ); + + uintStorage[MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[TARGET_LIMIT] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[THRESHOLD] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; + uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]; + + return _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _owner, + _decimalShift + ); + } + function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index ba9624475..374bc8b5a 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -54,13 +54,15 @@ contract HomeBridgeErcToNative is address _owner, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _blockReward, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -81,13 +83,15 @@ contract HomeBridgeErcToNative is uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, _blockReward, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -116,50 +120,56 @@ contract HomeBridgeErcToNative is _setBlockRewardContract(_blockReward); } - function _initialize( - address _validatorContract, + function _setLimits( uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations > 0); require( _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - require(_blockReward == address(0) || AddressUtils.isContract(_blockReward)); require( _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - require(_owner != address(0)); - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[GAS_PRICE] = _homeGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + } + + function _initialize( + address _validatorContract, + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _blockReward, + address _owner, + uint256 _decimalShift + ) internal { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_blockReward == address(0) || AddressUtils.isContract(_blockReward)); + require(_owner != address(0)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _homeGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; + addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index 4a89f4125..b96279885 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -5,6 +5,91 @@ import "./HomeBridgeErcToNative.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { + function initialize( + address _validatorContract, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _blockReward, + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); + _initialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _blockReward, + _owner, + _decimalShift + ); + setInitialize(); + + return isInitialized(); + } + + function rewardableInitialize( + address _validatorContract, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _blockReward, + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _owner, + address _feeManager, + uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); + _initialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _blockReward, + _owner, + _decimalShift + ); + require(AddressUtils.isContract(_feeManager)); + addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; + _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); + _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); + setInitialize(); + + return isInitialized(); + } + + function _setLimits( + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + ) internal { + require( + _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 + _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + ); + require( + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + ); + + uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; + uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; + uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + } + function _getTokenBalance() internal view returns (uint256) { uint256 totalMinted = blockRewardContract().mintedTotallyByBridge(address(this)); uint256 totalBurnt = totalBurntCoins(); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol index ab203f708..86038e4ce 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol @@ -14,10 +14,8 @@ contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { ) internal { super._initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index c12c87556..c4ff3230e 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -24,13 +24,15 @@ contract ForeignBridgeNativeToErc is address _owner, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + ); _initialize( _validatorContract, _erc677token, - _dailyLimitMaxPerTxMinPerTxArray, _foreignGasPrice, _requiredBlockConfirmations, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); @@ -50,13 +52,15 @@ contract ForeignBridgeNativeToErc is uint256 _homeFee, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + ); _initialize( _validatorContract, _erc677token, - _dailyLimitMaxPerTxMinPerTxArray, _foreignGasPrice, _requiredBlockConfirmations, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, _owner, _decimalShift ); @@ -75,50 +79,56 @@ contract ForeignBridgeNativeToErc is IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to); } - function _initialize( - address _validatorContract, - address _erc677token, + function _setLimits( uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _foreignGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - address _owner, - uint256 _decimalShift + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); require( _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx ); - require(_requiredBlockConfirmations > 0); - require(_foreignGasPrice > 0); require( _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit ); - require(_owner != address(0)); - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - setErc677token(_erc677token); uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[GAS_PRICE] = _foreignGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); + } + + function _initialize( + address _validatorContract, + address _erc677token, + uint256 _foreignGasPrice, + uint256 _requiredBlockConfirmations, + address _owner, + uint256 _decimalShift + ) internal { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_foreignGasPrice > 0); + require(_owner != address(0)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + setErc677token(_erc677token); + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _foreignGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_foreignGasPrice); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); } function onExecuteMessage(address _recipient, uint256 _amount, bytes32 _txHash) internal returns (bool) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index c8060a2d3..271e3669f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -4,6 +4,88 @@ import "./ForeignBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { + function initialize( + address _validatorContract, + address _erc677token, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _foreignGasPrice, + uint256 _requiredBlockConfirmations, + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + ); + _initialize( + _validatorContract, + _erc677token, + _foreignGasPrice, + _requiredBlockConfirmations, + _owner, + _decimalShift + ); + setInitialize(); + return isInitialized(); + } + + function rewardableInitialize( + address _validatorContract, + address _erc677token, + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256 _foreignGasPrice, + uint256 _requiredBlockConfirmations, + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + address _owner, + address _feeManager, + uint256 _homeFee, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _targetLimitThresholdMaxPerTxMinPerTxArray, + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + ); + _initialize( + _validatorContract, + _erc677token, + _foreignGasPrice, + _requiredBlockConfirmations, + _owner, + _decimalShift + ); + require(AddressUtils.isContract(_feeManager)); + addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; + _setFee(_feeManager, _homeFee, HOME_FEE); + setInitialize(); + return isInitialized(); + } + + function _setLimits( + uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + ) internal { + require( + _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 + _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + ); + require( + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx + _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + ); + + uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; + uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; + uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + + emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); + } + function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 795e11f07..fcf7d7b86 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -34,12 +34,14 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom address _owner, uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -58,12 +60,14 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + ); _initialize( _validatorContract, - _dailyLimitMaxPerTxMinPerTxArray, _homeGasPrice, _requiredBlockConfirmations, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, _owner, _decimalShift ); @@ -79,19 +83,10 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom return 0x92a8d7fe; // bytes4(keccak256(abi.encodePacked("native-to-erc-core"))) } - function _initialize( - address _validatorContract, + function _setLimits( uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift + uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_homeGasPrice > 0); - require(_requiredBlockConfirmations > 0); require( _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx @@ -102,25 +97,40 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - require(_owner != address(0)); - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[GAS_PRICE] = _homeGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + } + + function _initialize( + address _validatorContract, + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + address _owner, + uint256 _decimalShift + ) internal { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_homeGasPrice > 0); + require(_requiredBlockConfirmations > 0); + require(_owner != address(0)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _homeGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); } function onSignaturesCollected(bytes _message) internal { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index e15dcddd4..01c787c89 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -4,6 +4,85 @@ import "./HomeBridgeNativeToErc.sol"; import "../RelativeExecutionDailyLimit.sol"; contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { + function initialize( + address _validatorContract, + uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + address _owner, + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray + ); + _initialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _owner, + _decimalShift + ); + setInitialize(); + return isInitialized(); + } + + function rewardableInitialize( + address _validatorContract, + uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256 _homeGasPrice, + uint256 _requiredBlockConfirmations, + uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + address _owner, + address _feeManager, + uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] + uint256 _decimalShift + ) external returns (bool) { + _setLimits( + _dailyLimitMaxPerTxMinPerTxArray, + _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray + ); + _initialize( + _validatorContract, + _homeGasPrice, + _requiredBlockConfirmations, + _owner, + _decimalShift + ); + require(AddressUtils.isContract(_feeManager)); + addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; + _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); + _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); + setInitialize(); + return isInitialized(); + } + + function _setLimits( + uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + ) internal { + require( + _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 + _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx + _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + ); + require( + _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3] > 0 && // _foreignMinPerTx > 0 + _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[2] > _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3] // _foreignMaxPerTx > _foreignMinPerTx + ); + + uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; + uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; + uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[0]; + uintStorage[THRESHOLD] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3]; + + emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + } + function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } From 4e0ecc0b67f2a1b1ac871ac7989819ee344ec997 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 25 Oct 2019 17:09:03 +0300 Subject: [PATCH 23/80] fix --- .../native_to_erc20/ClassicHomeBridgeNativeToErc.sol | 2 -- .../ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol index 86038e4ce..4e6e7e02b 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol @@ -5,10 +5,8 @@ import "./HomeBridgeNativeToErc.sol"; contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { function _initialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) internal { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol index 4104669d8..b5f70858f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol @@ -2,9 +2,9 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ClassicHomeBridgeNativeToErc.sol"; -import "../RelativeExecutionDailyLimit.sol"; +import "./HomeBridgeNativeToErcRelativeDailyLimit.sol"; -contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, RelativeExecutionDailyLimit { +contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, HomeBridgeNativeToErcRelativeDailyLimit { function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } From 37a9da0976970f1c30ee2a6ee9552b85b1df7068 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 25 Oct 2019 17:18:52 +0300 Subject: [PATCH 24/80] rename limits arrays --- .../BasicAMBErc677ToErc677.sol | 32 ++++++------- ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 34 ++++++------- ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 34 ++++++------- .../ForeignBridgeErc677ToErc677.sol | 32 ++++++------- ...BridgeErc677ToErc677RelativeDailyLimit.sol | 36 +++++++------- .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 18 +++---- ...oreignBridgeErcToErcRelativeDailyLimit.sol | 22 ++++----- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 48 +++++++++---------- .../HomeBridgeErcToErcPOSDAO.sol | 8 ++-- ...BridgeErcToErcPOSDAORelativeDailyLimit.sol | 8 ++-- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 46 +++++++++--------- .../ForeignBridgeErcToNative.sol | 18 +++---- ...ignBridgeErcToNativeRelativeDailyLimit.sol | 16 +++---- .../erc20_to_native/HomeBridgeErcToNative.sol | 48 +++++++++---------- ...omeBridgeErcToNativeRelativeDailyLimit.sol | 46 +++++++++--------- .../ForeignBridgeNativeToErc.sol | 48 +++++++++---------- ...ignBridgeNativeToErcRelativeDailyLimit.sol | 46 +++++++++--------- .../native_to_erc20/HomeBridgeNativeToErc.sol | 48 +++++++++---------- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 46 +++++++++--------- 19 files changed, 317 insertions(+), 317 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index e09e89978..7058a7260 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -33,32 +33,32 @@ contract BasicAMBErc677ToErc677 is address _bridgeContract, address _mediatorContract, address _erc677token, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] uint256 _requestGasLimit, uint256 _decimalShift, address _owner ) external returns (bool) { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] > 0 && // _executionMinPerTx > 0 - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] > _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0] // _executionMaxPerTx < _executionDailyLimit + _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); return _initialize( _bridgeContract, diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index 6d75ab27e..d646e4cfd 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -8,33 +8,33 @@ contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, address _bridgeContract, address _mediatorContract, address _erc677token, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] uint256 _requestGasLimit, uint256 _decimalShift, address _owner ) external returns (bool) { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3] > 0 && // _executionMinPerTx > 0 - _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[2] > _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3] // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[3] > 0 && // _executionMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] // _executionMaxPerTx > _executionMinPerTx ); - require(_targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[1] >= _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3]); // _threshold >= _executionMinPerTx + require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _executionMinPerTx - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[TARGET_LIMIT] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdExecutionMaxPerTxExecutionMinPerTxArray[3]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); return _initialize( _bridgeContract, diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index eedaee528..59c29a212 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -8,33 +8,33 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat address _bridgeContract, address _mediatorContract, address _erc677token, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] uint256 _requestGasLimit, uint256 _decimalShift, address _owner ) external returns (bool) { require( - _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 - _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[3] > 0 && // _minPerTx > 0 + _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx ); require( - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] > 0 && // _executionMinPerTx > 0 - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] > _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1] < _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0] // _executionMaxPerTx < _executionDailyLimit + _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit ); - require(_targetLimitThresholdMaxPerTxMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_targetLimitThresholdMaxPerTxMinPerTxArray[1] >= _targetLimitThresholdMaxPerTxMinPerTxArray[3]); // _threshold >= _executionMinPerTx + require(_requestLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_requestLimitsArray[1] >= _requestLimitsArray[3]); // _threshold >= _executionMinPerTx - uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; - uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; - uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; + uintStorage[THRESHOLD] = _requestLimitsArray[1]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit ExecutionDailyLimitChanged(_executionDailyLimitExecutionMaxPerTxExecutionMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); return _initialize( _bridgeContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index fc2e503e8..81486fcc0 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -11,28 +11,28 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; _initialize( _validatorContract, @@ -43,8 +43,8 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc _decimalShift ); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index 09086b3c4..05e800a17 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -13,31 +13,31 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 - _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] > _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx - _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] < _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[2] < _executionLimitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); - require(_targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] >= _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]); // _threshold >= _homeMinPerTx + require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether + require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _homeMinPerTx - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[TARGET_LIMIT] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; _initialize( _validatorContract, @@ -48,7 +48,7 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is _decimalShift ); - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index 4bf709d25..47414b224 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -9,20 +9,20 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] + uint256[] _limitsArray, // [ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[3] > 0 && // _homeMinPerTx > 0 + _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; + uintStorage[MAX_PER_TX] = _limitsArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _limitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[3]; _initialize( _validatorContract, @@ -33,7 +33,7 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { _decimalShift ); - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); + emit ExecutionDailyLimitChanged(_limitsArray[1]); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index 726e50412..97f71b53e 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -13,23 +13,23 @@ contract ForeignBridgeErcToErcRelativeDailyLimit is address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + uint256[] _limitsArray, // [ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] > 0 && // _homeMinPerTx > 0 - _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] && // _homeMaxPerTx > _homeMinPerTx - _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] < _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[4] > 0 && // _homeMinPerTx > 0 + _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[3] < _limitsArray[2] // _homeMaxPerTx < _homeDailyLimit ); - require(_maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1] <= 1 ether); // _targetLimit <= 1 ether - require(_maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] >= _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]); // _threshold >= _homeMinPerTx + require(_limitsArray[1] <= 1 ether); // _targetLimit <= 1 ether + require(_limitsArray[2] >= _limitsArray[4]); // _threshold >= _homeMinPerTx - uintStorage[MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[TARGET_LIMIT] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[THRESHOLD] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]; + uintStorage[MAX_PER_TX] = _limitsArray[0]; + uintStorage[TARGET_LIMIT] = _limitsArray[1]; + uintStorage[THRESHOLD] = _limitsArray[2]; + uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; + uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; _initialize( _validatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 1da40d0f1..c5ac24baa 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -17,17 +17,17 @@ contract HomeBridgeErcToErc is { function initialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -44,19 +44,19 @@ contract HomeBridgeErcToErc is function rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _rewardableInitialize( _validatorContract, @@ -98,29 +98,29 @@ contract HomeBridgeErcToErc is } function _setLimits( - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _initialize( diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index ccc095143..7c94a8f85 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -8,11 +8,11 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { function rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -20,8 +20,8 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _rewardableInitialize( _validatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol index e7f11503d..93b054f7a 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol @@ -7,11 +7,11 @@ import "./HomeBridgeErcToErcRelativeDailyLimit.sol"; contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativeDailyLimit, HomeBridgeErcToErcPOSDAO { function rewardableInitialize( address _validatorContract, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] @@ -19,8 +19,8 @@ contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativ uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _rewardableInitialize( _validatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index e48d73ca1..4594df068 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -6,17 +6,17 @@ import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { function initialize( address _validatorContract, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -33,19 +33,19 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai function rewardableInitialize( address _validatorContract, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _rewardableInitialize( _validatorContract, @@ -63,28 +63,28 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai } function _setLimits( - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { require( - _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 - _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[3] > 0 && // _minPerTx > 0 + _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx ); require( - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; - uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; - uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; + uintStorage[THRESHOLD] = _requestLimitsArray[1]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 075b37a54..d00e99878 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -11,22 +11,22 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray, //[ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] + uint256[] _limitsArray, //[ 0 = _maxPerTx, 1 = _homeDailyLimit, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] > 0 && // _homeMinPerTx > 0 - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3] && // _homeMaxPerTx > _homeMinPerTx - _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] < _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[3] > 0 && // _homeMinPerTx > 0 + _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); - uintStorage[MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_DAILY_LIMIT] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[3]; + uintStorage[MAX_PER_TX] = _limitsArray[0]; + uintStorage[EXECUTION_DAILY_LIMIT] = _limitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[3]; - emit ExecutionDailyLimitChanged(_maxPerTxHomeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]); + emit ExecutionDailyLimitChanged(_limitsArray[1]); return _initialize( _validatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index efd2f57a2..8e61de6c1 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -9,20 +9,20 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray, //[ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + uint256[] _limitsArray, //[ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4] > 0 && // _homeMinPerTx > 0 - _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3] > _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2] // _homeMaxPerTx > _homeMinPerTx + _limitsArray[4] > 0 && // _homeMinPerTx > 0 + _limitsArray[3] > _limitsArray[2] // _homeMaxPerTx > _homeMinPerTx ); - uintStorage[MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[TARGET_LIMIT] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[THRESHOLD] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[2]; - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[3]; - uintStorage[EXECUTION_MIN_PER_TX] = _maxPerTxTargetLimitThresholdHomeMaxPerTxHomeMinPerTxArray[4]; + uintStorage[MAX_PER_TX] = _limitsArray[0]; + uintStorage[TARGET_LIMIT] = _limitsArray[1]; + uintStorage[THRESHOLD] = _limitsArray[2]; + uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; + uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; return _initialize( _validatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index 374bc8b5a..49f2aa459 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -46,17 +46,17 @@ contract HomeBridgeErcToNative is function initialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -73,19 +73,19 @@ contract HomeBridgeErcToNative is function rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -121,29 +121,29 @@ contract HomeBridgeErcToNative is } function _setLimits( - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _initialize( diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index b96279885..50b95a5d1 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -7,17 +7,17 @@ import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { function initialize( address _validatorContract, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -34,19 +34,19 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat function rewardableInitialize( address _validatorContract, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -66,28 +66,28 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat } function _setLimits( - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { require( - _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 - _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[3] > 0 && // _minPerTx > 0 + _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx ); require( - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; - uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; - uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; + uintStorage[THRESHOLD] = _requestLimitsArray[1]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index c4ff3230e..8157bdd46 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -17,16 +17,16 @@ contract ForeignBridgeNativeToErc is function initialize( address _validatorContract, address _erc677token, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -43,18 +43,18 @@ contract ForeignBridgeNativeToErc is function rewardableInitialize( address _validatorContract, address _erc677token, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, address _feeManager, uint256 _homeFee, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -80,29 +80,29 @@ contract ForeignBridgeNativeToErc is } function _setLimits( - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] ) internal { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _initialize( diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index 271e3669f..cd4c93ff7 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -7,16 +7,16 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, function initialize( address _validatorContract, address _erc677token, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -33,18 +33,18 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, function rewardableInitialize( address _validatorContract, address _erc677token, - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, address _feeManager, uint256 _homeFee, uint256 _decimalShift ) external returns (bool) { _setLimits( - _targetLimitThresholdMaxPerTxMinPerTxArray, - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -62,28 +62,28 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, } function _setLimits( - uint256[] _targetLimitThresholdMaxPerTxMinPerTxArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] ) internal { require( - _targetLimitThresholdMaxPerTxMinPerTxArray[3] > 0 && // _minPerTx > 0 - _targetLimitThresholdMaxPerTxMinPerTxArray[2] > _targetLimitThresholdMaxPerTxMinPerTxArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[3] > 0 && // _minPerTx > 0 + _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx ); require( - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] > 0 && // _homeMinPerTx > 0 - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] > _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2] && // _homeMaxPerTx > _homeMinPerTx - _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1] < _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); - uintStorage[TARGET_LIMIT] = _targetLimitThresholdMaxPerTxMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdMaxPerTxMinPerTxArray[1]; - uintStorage[MAX_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[2]; - uintStorage[MIN_PER_TX] = _targetLimitThresholdMaxPerTxMinPerTxArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[2]; + uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; + uintStorage[THRESHOLD] = _requestLimitsArray[1]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit ExecutionDailyLimitChanged(_homeDailyLimitHomeMaxPerTxHomeMinPerTxArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index fcf7d7b86..f0acc446a 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -27,16 +27,16 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom function initialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -51,18 +51,18 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom function rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -84,29 +84,29 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom } function _setLimits( - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] ) internal { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] > 0 && // _foreignMinPerTx > 0 - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] > _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1] < _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[2]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); - emit ExecutionDailyLimitChanged(_foreignDailyLimitForeignMaxPerTxForeignMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); } function _initialize( diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index 01c787c89..883de5283 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -6,16 +6,16 @@ import "../RelativeExecutionDailyLimit.sol"; contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { function initialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -30,18 +30,18 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat function rewardableInitialize( address _validatorContract, - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { _setLimits( - _dailyLimitMaxPerTxMinPerTxArray, - _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray + _requestLimitsArray, + _executionLimitsArray ); _initialize( _validatorContract, @@ -59,28 +59,28 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat } function _setLimits( - uint256[] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] ) internal { require( - _dailyLimitMaxPerTxMinPerTxArray[2] > 0 && // _minPerTx > 0 - _dailyLimitMaxPerTxMinPerTxArray[1] > _dailyLimitMaxPerTxMinPerTxArray[2] && // _maxPerTx > _minPerTx - _dailyLimitMaxPerTxMinPerTxArray[0] > _dailyLimitMaxPerTxMinPerTxArray[1] // _dailyLimit > _maxPerTx + _requestLimitsArray[2] > 0 && // _minPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx ); require( - _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3] > 0 && // _foreignMinPerTx > 0 - _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[2] > _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3] // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[3] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] // _foreignMaxPerTx > _foreignMinPerTx ); - uintStorage[DAILY_LIMIT] = _dailyLimitMaxPerTxMinPerTxArray[0]; - uintStorage[MAX_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[1]; - uintStorage[MIN_PER_TX] = _dailyLimitMaxPerTxMinPerTxArray[2]; - uintStorage[TARGET_LIMIT] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[0]; - uintStorage[THRESHOLD] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _targetLimitThresholdForeignMaxPerTxForeignMinPerTxArray[3]; + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - emit DailyLimitChanged(_dailyLimitMaxPerTxMinPerTxArray[0]); + emit DailyLimitChanged(_requestLimitsArray[0]); } function _getTokenBalance() internal view returns (uint256) { From dea474803c95433666ceb1f11bab831dbcf15d40 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 25 Oct 2019 17:33:16 +0300 Subject: [PATCH 25/80] fix linter errors --- .../BasicAMBErc677ToErc677.sol | 13 ++------ ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 11 ++----- ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 13 ++------ .../ForeignBridgeErc677ToErc677.sol | 13 ++------ ...BridgeErc677ToErc677RelativeDailyLimit.sol | 13 ++------ .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 13 ++------ ...oreignBridgeErcToErcRelativeDailyLimit.sol | 13 ++------ .../erc20_to_erc20/HomeBridgeErcToErc.sol | 14 +++------ .../HomeBridgeErcToErcPOSDAO.sol | 5 +--- ...BridgeErcToErcPOSDAORelativeDailyLimit.sol | 5 +--- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 14 +++------ .../ForeignBridgeErcToNative.sol | 14 +++------ ...ignBridgeErcToNativeRelativeDailyLimit.sol | 12 ++------ .../erc20_to_native/HomeBridgeErcToNative.sol | 14 +++------ ...omeBridgeErcToNativeRelativeDailyLimit.sol | 14 +++------ .../ClassicHomeBridgeNativeToErc.sol | 8 +---- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 5 +++- .../ForeignBridgeNativeToErc.sol | 14 +++------ ...ignBridgeNativeToErcRelativeDailyLimit.sol | 14 +++------ .../native_to_erc20/HomeBridgeNativeToErc.sol | 30 ++++--------------- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 28 ++++------------- 21 files changed, 69 insertions(+), 211 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 7058a7260..53cfa46ef 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -46,8 +46,8 @@ contract BasicAMBErc677ToErc677 is ); require( _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; @@ -60,14 +60,7 @@ contract BasicAMBErc677ToErc677 is emit DailyLimitChanged(_requestLimitsArray[0]); emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - return _initialize( - _bridgeContract, - _mediatorContract, - _erc677token, - _requestGasLimit, - _decimalShift, - _owner - ); + return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); } function _initialize( diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index d646e4cfd..aaea1bb94 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -21,7 +21,7 @@ contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, ); require( _executionLimitsArray[3] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[2] > _executionLimitsArray[3] // _executionMaxPerTx > _executionMinPerTx ); require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _executionMinPerTx @@ -36,14 +36,7 @@ contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, emit DailyLimitChanged(_requestLimitsArray[0]); - return _initialize( - _bridgeContract, - _mediatorContract, - _erc677token, - _requestGasLimit, - _decimalShift, - _owner - ); + return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index 59c29a212..e2bd0c503 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -20,8 +20,8 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat ); require( _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit ); require(_requestLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether require(_requestLimitsArray[1] >= _requestLimitsArray[3]); // _threshold >= _executionMinPerTx @@ -36,14 +36,7 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - return _initialize( - _bridgeContract, - _mediatorContract, - _erc677token, - _requestGasLimit, - _decimalShift, - _owner - ); + return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index 81486fcc0..4d8e37ed3 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -23,8 +23,8 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc ); require( _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; @@ -34,14 +34,7 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); emit DailyLimitChanged(_requestLimitsArray[0]); emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index 05e800a17..1c21e8446 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -25,8 +25,8 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is ); require( _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[2] < _executionLimitsArray[1] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[2] < _executionLimitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _homeMinPerTx @@ -39,14 +39,7 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); emit DailyLimitChanged(_requestLimitsArray[0]); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index 47414b224..02a079321 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -15,8 +15,8 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { ) external returns (bool) { require( _limitsArray[3] > 0 && // _homeMinPerTx > 0 - _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); uintStorage[MAX_PER_TX] = _limitsArray[0]; @@ -24,14 +24,7 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[2]; uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[3]; - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); emit ExecutionDailyLimitChanged(_limitsArray[1]); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index 97f71b53e..9344ef88d 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -19,8 +19,8 @@ contract ForeignBridgeErcToErcRelativeDailyLimit is ) external returns (bool) { require( _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[3] < _limitsArray[2] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[3] < _limitsArray[2] // _homeMaxPerTx < _homeDailyLimit ); require(_limitsArray[1] <= 1 ether); // _targetLimit <= 1 ether require(_limitsArray[2] >= _limitsArray[4]); // _threshold >= _homeMinPerTx @@ -31,14 +31,7 @@ contract ForeignBridgeErcToErcRelativeDailyLimit is uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index c5ac24baa..647bf3165 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -25,10 +25,7 @@ contract HomeBridgeErcToErc is address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -54,10 +51,7 @@ contract HomeBridgeErcToErc is uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( _validatorContract, _homeGasPrice, @@ -108,8 +102,8 @@ contract HomeBridgeErcToErc is ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 7c94a8f85..7b99c3885 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -19,10 +19,7 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { address _blockReward, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( _validatorContract, _homeGasPrice, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol index 93b054f7a..ee2d42c21 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol @@ -18,10 +18,7 @@ contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativ address _blockReward, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( _validatorContract, _homeGasPrice, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index 4594df068..9188299ef 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -14,10 +14,7 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -43,10 +40,7 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( _validatorContract, _homeGasPrice, @@ -72,8 +66,8 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index d00e99878..806a10598 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -17,8 +17,8 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { ) external returns (bool) { require( _limitsArray[3] > 0 && // _homeMinPerTx > 0 - _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[2] > _limitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[2] < _limitsArray[1] // _homeMaxPerTx < _homeDailyLimit ); uintStorage[MAX_PER_TX] = _limitsArray[0]; @@ -28,14 +28,8 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge { emit ExecutionDailyLimitChanged(_limitsArray[1]); - return _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + return + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); } function _initialize( diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 8e61de6c1..36e3ab5ed 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -15,7 +15,7 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, ) external returns (bool) { require( _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[2] // _homeMaxPerTx > _homeMinPerTx + _limitsArray[3] > _limitsArray[2] // _homeMaxPerTx > _homeMinPerTx ); uintStorage[MAX_PER_TX] = _limitsArray[0]; @@ -24,14 +24,8 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; - return _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); + return + _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index 49f2aa459..0d27d5bf7 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -54,10 +54,7 @@ contract HomeBridgeErcToNative is address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -83,10 +80,7 @@ contract HomeBridgeErcToNative is uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -131,8 +125,8 @@ contract HomeBridgeErcToNative is ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index 50b95a5d1..d7e3de0e9 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -15,10 +15,7 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -44,10 +41,7 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _homeGasPrice, @@ -75,8 +69,8 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol index 4e6e7e02b..eeef2a6ad 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErc.sol @@ -10,13 +10,7 @@ contract ClassicHomeBridgeNativeToErc is HomeBridgeNativeToErc { address _owner, uint256 _decimalShift ) internal { - super._initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift - ); + super._initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); uintStorage[0x5e16d82565fc7ee8775cc18db290ff4010745d3fd46274a7bc7ddbebb727fa54] = 132; // keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("signature(bytes32,uint256)")))) uintStorage[0x3b0a1ac531be1657049cf649eca2510ce9e3ef7df1be26d5c248fe8b298f4374] = 210; // keccak256(abi.encodePacked("dataSizes", bytes4(keccak256("message(bytes32)")))) } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol index b5f70858f..ffcb4eb80 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol @@ -4,7 +4,10 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ClassicHomeBridgeNativeToErc.sol"; import "./HomeBridgeNativeToErcRelativeDailyLimit.sol"; -contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is ClassicHomeBridgeNativeToErc, HomeBridgeNativeToErcRelativeDailyLimit { +contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is + ClassicHomeBridgeNativeToErc, + HomeBridgeNativeToErcRelativeDailyLimit +{ function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 8157bdd46..31f6f185d 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -24,10 +24,7 @@ contract ForeignBridgeNativeToErc is address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc677token, @@ -52,10 +49,7 @@ contract ForeignBridgeNativeToErc is uint256 _homeFee, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc677token, @@ -90,8 +84,8 @@ contract ForeignBridgeNativeToErc is ); require( _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index cd4c93ff7..3eee693eb 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -14,10 +14,7 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc677token, @@ -42,10 +39,7 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, uint256 _homeFee, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc677token, @@ -71,8 +65,8 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, ); require( _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit ); uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index f0acc446a..6ed19c56d 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -34,17 +34,8 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); + _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); setInitialize(); return isInitialized(); } @@ -60,17 +51,8 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); + _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); @@ -94,8 +76,8 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index 883de5283..09894af78 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -13,17 +13,8 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat address _owner, uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); + _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); setInitialize(); return isInitialized(); } @@ -39,17 +30,8 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { - _setLimits( - _requestLimitsArray, - _executionLimitsArray - ); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift - ); + _setLimits(_requestLimitsArray, _executionLimitsArray); + _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); @@ -69,7 +51,7 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat ); require( _executionLimitsArray[3] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[2] > _executionLimitsArray[3] // _foreignMaxPerTx > _foreignMinPerTx ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; From 44fb7a8f0fe457eda5727c338ba249e787314844 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 28 Oct 2019 22:37:02 +0300 Subject: [PATCH 26/80] fix checks --- .../ForeignAMBErc677ToErc677RelativeDailyLimit.sol | 6 +++--- .../HomeAMBErc677ToErc677RelativeDailyLimit.sol | 6 +++--- .../ForeignBridgeErc677ToErc677RelativeDailyLimit.sol | 5 ++--- .../ForeignBridgeErcToErcRelativeDailyLimit.sol | 5 ++--- .../erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol | 4 +++- .../ForeignBridgeErcToNativeRelativeDailyLimit.sol | 4 +++- .../HomeBridgeErcToNativeRelativeDailyLimit.sol | 4 +++- .../ForeignBridgeNativeToErcRelativeDailyLimit.sol | 4 +++- .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 6 ++++-- 9 files changed, 26 insertions(+), 18 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index aaea1bb94..78799f56e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -21,10 +21,10 @@ contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, ); require( _executionLimitsArray[3] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[2] > _executionLimitsArray[3] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _executionMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); - require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _executionMinPerTx uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index e2bd0c503..19dfb66f6 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -16,15 +16,15 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat ) external returns (bool) { require( _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx + _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx + _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); require( _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit ); - require(_requestLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_requestLimitsArray[1] >= _requestLimitsArray[3]); // _threshold >= _executionMinPerTx uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; uintStorage[THRESHOLD] = _requestLimitsArray[1]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index 1c21e8446..09b9d2b55 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -26,10 +26,9 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is require( _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[2] < _executionLimitsArray[1] // _homeMaxPerTx < _homeDailyLimit + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); - require(_executionLimitsArray[0] <= 1 ether); // _targetLimit <= 1 ether - require(_executionLimitsArray[1] >= _executionLimitsArray[3]); // _threshold >= _homeMinPerTx uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index 9344ef88d..99aa7fb67 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -20,10 +20,9 @@ contract ForeignBridgeErcToErcRelativeDailyLimit is require( _limitsArray[4] > 0 && // _homeMinPerTx > 0 _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[3] < _limitsArray[2] // _homeMaxPerTx < _homeDailyLimit + _limitsArray[2] >= _limitsArray[4] && // _threshold >= _homeMinPerTx + _limitsArray[1] <= 1 ether // _targetLimit <= 1 ether ); - require(_limitsArray[1] <= 1 ether); // _targetLimit <= 1 ether - require(_limitsArray[2] >= _limitsArray[4]); // _threshold >= _homeMinPerTx uintStorage[MAX_PER_TX] = _limitsArray[0]; uintStorage[TARGET_LIMIT] = _limitsArray[1]; diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index 9188299ef..5778ae925 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -62,7 +62,9 @@ contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDai ) internal { require( _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx + _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx + _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 36e3ab5ed..1c87c5bf0 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -15,7 +15,9 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, ) external returns (bool) { require( _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[2] // _homeMaxPerTx > _homeMinPerTx + _limitsArray[3] > _limitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[2] >= _limitsArray[4] && // _threshold >= _homeMinPerTx + _limitsArray[1] <= 1 ether // _targetLimit <= 1 ether ); uintStorage[MAX_PER_TX] = _limitsArray[0]; diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index d7e3de0e9..5d9d0d4a8 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -65,7 +65,9 @@ contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, Relat ) internal { require( _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx + _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx + _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index 3eee693eb..f72508199 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -61,7 +61,9 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, ) internal { require( _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] // _maxPerTx > _minPerTx + _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx + _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx + _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); require( _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index 09894af78..2a15a780d 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -42,7 +42,7 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat function _setLimits( uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _executionLimitsArray // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] ) internal { require( _requestLimitsArray[2] > 0 && // _minPerTx > 0 @@ -51,7 +51,9 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat ); require( _executionLimitsArray[3] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[2] > _executionLimitsArray[3] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _foreignMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; From 06a3cf0254e169882e0ab5b9fb67b4ec8dce1956 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 29 Oct 2019 15:01:34 +0300 Subject: [PATCH 27/80] set relative daily limit once a day --- contracts/interfaces/ERC677Receiver.sol | 2 +- contracts/mocks/ERC677ReceiverTest.sol | 2 +- .../BaseERC677Bridge.sol | 2 +- .../BaseRelativeDailyLimit.sol | 25 +++++++++++++++++++ .../BasicForeignBridge.sol | 2 +- .../RelativeDailyLimit.sol | 2 +- .../RelativeExecutionDailyLimit.sol | 2 +- .../BasicAMBErc677ToErc677.sol | 4 +-- ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 23 +++++++++++++++++ ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 23 +++++++++++++++++ ...oreignBridgeErcToErcRelativeDailyLimit.sol | 10 ++++++++ ...ignBridgeErcToNativeRelativeDailyLimit.sol | 10 ++++++++ ...omeBridgeErcToNativeRelativeDailyLimit.sol | 5 ++++ ...ignBridgeNativeToErcRelativeDailyLimit.sol | 10 ++++++++ ...omeBridgeNativeToErcRelativeDailyLimit.sol | 5 ++++ 15 files changed, 119 insertions(+), 8 deletions(-) diff --git a/contracts/interfaces/ERC677Receiver.sol b/contracts/interfaces/ERC677Receiver.sol index a38b59f41..a12e03174 100644 --- a/contracts/interfaces/ERC677Receiver.sol +++ b/contracts/interfaces/ERC677Receiver.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ERC677Receiver { - function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool); + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool); } diff --git a/contracts/mocks/ERC677ReceiverTest.sol b/contracts/mocks/ERC677ReceiverTest.sol index 94c9aad9c..4b4fab69f 100644 --- a/contracts/mocks/ERC677ReceiverTest.sol +++ b/contracts/mocks/ERC677ReceiverTest.sol @@ -8,7 +8,7 @@ contract ERC677ReceiverTest is ERC677Receiver { bytes public data; uint256 public someVar = 0; - function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { from = _from; value = _value; data = _data; diff --git a/contracts/upgradeable_contracts/BaseERC677Bridge.sol b/contracts/upgradeable_contracts/BaseERC677Bridge.sol index 4f55c2e13..78641fb12 100644 --- a/contracts/upgradeable_contracts/BaseERC677Bridge.sol +++ b/contracts/upgradeable_contracts/BaseERC677Bridge.sol @@ -20,7 +20,7 @@ contract BaseERC677Bridge is BasicTokenBridge, ERC677Receiver, ERC677Storage { address _from, uint256 _value, bytes /*_data*/ - ) external returns (bool) { + ) public returns (bool) { ERC677 token = erc677token(); require(msg.sender == address(token)); require(withinLimit(_value)); diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol index 96b917a4f..07c66b2bb 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -8,6 +8,7 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { event TargetLimitChanged(uint256 newLimit); event ThresholdChanged(uint256 newThreshold); + event TodayLimitSet(uint256 limit); bytes32 internal constant TARGET_LIMIT = 0x192ac2d88a9de45ce541663ebe1aaf6d6b1d4a6299d3fd0abf2ba7e8b920342b; // keccak256(abi.encodePacked("targetLimit")) bytes32 internal constant THRESHOLD = 0xd46c2b20c7303c2e50535d224276492e8a1eda2a3d7398e0bea254640c1154e7; // keccak256(abi.encodePacked("threshold")) @@ -53,6 +54,30 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { emit ThresholdChanged(_threshold); } + function _updateTodayLimit() internal { + if (_todayLimit() == 0) { + uint256 limit = _calculateLimit(); + _setTodayLimit(limit); + emit TodayLimitSet(limit); + } + } + + function _getTodayLimit() internal view returns (uint256) { + uint256 limit = _todayLimit(); + if (limit == 0) { // not set yet + limit = _calculateLimit(); + } + return limit; + } + + function _todayLimit() internal view returns (uint256) { + return uintStorage[keccak256(abi.encodePacked("todayLimit", getCurrentDay()))]; + } + + function _setTodayLimit(uint256 _value) internal { + uintStorage[keccak256(abi.encodePacked("todayLimit", getCurrentDay()))] = _value; + } + function _minPerTx() internal view returns (uint256); function _getTokenBalance() internal view returns (uint256); diff --git a/contracts/upgradeable_contracts/BasicForeignBridge.sol b/contracts/upgradeable_contracts/BasicForeignBridge.sol index 9972a233f..6f793dd96 100644 --- a/contracts/upgradeable_contracts/BasicForeignBridge.sol +++ b/contracts/upgradeable_contracts/BasicForeignBridge.sol @@ -13,7 +13,7 @@ import "./MessageRelay.sol"; contract BasicForeignBridge is EternalStorage, Validatable, BasicBridge, BasicTokenBridge, MessageRelay { /// triggered when relay of deposit from HomeBridge is complete event RelayedMessage(address recipient, uint256 value, bytes32 transactionHash); - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) external { + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { Message.hasEnoughValidSignatures(message, vs, rs, ss, validatorContract(), false); address recipient; uint256 amount; diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index d838cddc7..b52ab7c34 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -8,6 +8,6 @@ contract RelativeDailyLimit is BaseRelativeDailyLimit { } function dailyLimit() public view returns (uint256) { - return _calculateLimit(); + return _getTodayLimit(); } } diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol index 7eeb0674f..be5612c0b 100644 --- a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -8,6 +8,6 @@ contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { } function executionDailyLimit() public view returns (uint256) { - return _calculateLimit(); + return _getTodayLimit(); } } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 53cfa46ef..de6c74501 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -97,7 +97,7 @@ contract BasicAMBErc677ToErc677 is bridgeContract().requireToPassMessage(mediatorContractOnOtherSide(), data, requestGasLimit()); } - function relayTokens(uint256 _value) external { + function relayTokens(uint256 _value) public { // This lock is to prevent calling passMessage twice if a ERC677 token is used. // When transferFrom is called, after the transfer, the ERC677 token will call onTokenTransfer from this contract // which will call passMessage. @@ -208,7 +208,7 @@ contract BasicAMBErc677ToErc677 is address _recipient, uint256 _value, bytes32 /* nonce */ - ) external { + ) public { require(msg.sender == address(bridgeContract())); require(messageSender() == mediatorContractOnOtherSide()); if (withinExecutionLimit(_value)) { diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index 78799f56e..2424ef4b7 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,6 +4,29 @@ import "./ForeignAMBErc677ToErc677.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { + function relayTokens(uint256 _value) public { + _updateTodayLimit(); + super.relayTokens(_value); + } + + function onTokenTransfer( + address _from, + uint256 _value, + bytes _data + ) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + + function handleBridgedTokens( + address _recipient, + uint256 _value, + bytes32 _nonce + ) public { + _updateTodayLimit(); + super.handleBridgedTokens(_recipient, _value, _nonce); + } + function initialize( address _bridgeContract, address _mediatorContract, diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index 19dfb66f6..add1b4cf1 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,6 +4,29 @@ import "./HomeAMBErc677ToErc677.sol"; import "../RelativeDailyLimit.sol"; contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, RelativeDailyLimit { + function relayTokens(uint256 _value) public { + _updateTodayLimit(); + super.relayTokens(_value); + } + + function onTokenTransfer( + address _from, + uint256 _value, + bytes _data + ) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + + function handleBridgedTokens( + address _recipient, + uint256 _value, + bytes32 _nonce + ) public { + _updateTodayLimit(); + super.handleBridgedTokens(_recipient, _value, _nonce); + } + function initialize( address _bridgeContract, address _mediatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol index 7e2871563..9d4a34502 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol @@ -4,6 +4,16 @@ import "./BasicForeignBridgeErcToErc.sol"; import "../RelativeExecutionDailyLimit.sol"; contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeExecutionDailyLimit { + function executeSignatures( + uint8[] vs, + bytes32[] rs, + bytes32[] ss, + bytes message + ) public { + _updateTodayLimit(); + super.executeSignatures(vs, rs, ss, message); + } + function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 1c87c5bf0..e3447be3b 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -4,6 +4,16 @@ import "./ForeignBridgeErcToNative.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeExecutionDailyLimit { + function executeSignatures( + uint8[] vs, + bytes32[] rs, + bytes32[] ss, + bytes message + ) public { + _updateTodayLimit(); + super.executeSignatures(vs, rs, ss, message); + } + function initialize( address _validatorContract, address _erc20token, diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index 5d9d0d4a8..044d1b3a6 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -5,6 +5,11 @@ import "./HomeBridgeErcToNative.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { + function nativeTransfer() internal { + _updateTodayLimit(); + super.nativeTransfer(); + } + function initialize( address _validatorContract, uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index f72508199..b62835f57 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -4,6 +4,16 @@ import "./ForeignBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { + function executeSignatures( + uint8[] vs, + bytes32[] rs, + bytes32[] ss, + bytes message + ) public { + _updateTodayLimit(); + super.executeSignatures(vs, rs, ss, message); + } + function initialize( address _validatorContract, address _erc677token, diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index 2a15a780d..c4ba142cf 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -4,6 +4,11 @@ import "./HomeBridgeNativeToErc.sol"; import "../RelativeExecutionDailyLimit.sol"; contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { + function nativeTransfer() internal { + _updateTodayLimit(); + super.nativeTransfer(); + } + function initialize( address _validatorContract, uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] From f7850fa222ecf8b61f6be3cf05f7135c2987ad13 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 29 Oct 2019 21:40:16 +0300 Subject: [PATCH 28/80] remove checks for relative limit --- contracts/upgradeable_contracts/RelativeDailyLimit.sol | 10 ++++++++++ .../RelativeExecutionDailyLimit.sol | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index b52ab7c34..27f361c9c 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -10,4 +10,14 @@ contract RelativeDailyLimit is BaseRelativeDailyLimit { function dailyLimit() public view returns (uint256) { return _getTodayLimit(); } + + function setMinPerTx(uint256 _minPerTx) external onlyOwner { + require(_minPerTx < maxPerTx()); + uintStorage[MIN_PER_TX] = _minPerTx; + } + + function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { + require(_maxPerTx > minPerTx()); + uintStorage[MAX_PER_TX] = _maxPerTx; + } } diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol index be5612c0b..3e40ebc9d 100644 --- a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -10,4 +10,14 @@ contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { function executionDailyLimit() public view returns (uint256) { return _getTodayLimit(); } + + function setExecutionMinPerTx(uint256 _minPerTx) external onlyOwner { + require(_minPerTx < executionMaxPerTx()); + uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; + } + + function setExecutionMaxPerTx(uint256 _maxPerTx) external onlyOwner { + require(_maxPerTx > executionMinPerTx()); + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; + } } From 4de7b72b120b27b08df0f1af73229241436fc3f5 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 31 Oct 2019 11:30:15 +0300 Subject: [PATCH 29/80] update amd_erc677_to_erc677 tests to work with relative limit --- .../AMBErc677ToErc677Behavior.test.js | 688 +++++++++--------- .../foreign_bridge.test.js | 45 +- test/amb_erc677_to_erc677/home_bridge.test.js | 104 +-- 3 files changed, 440 insertions(+), 397 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 207c61840..633af3112 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -19,13 +19,46 @@ const executionMaxPerTx = maxPerTx const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 - -function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accounts) { +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function shouldBehaveLikeBasicAMBErc677ToErc677( + otherSideMediatorContract, + accounts, + isRelativeDailyLimit, + isRelativeDailyLimitOnBridgeSide +) { let bridgeContract let mediatorContract let erc677Token + let contract const owner = accounts[0] const user = accounts[1] + + let limitsArray = [dailyLimit, maxPerTx, minPerTx] + let executionLimitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + + if (isRelativeDailyLimit) { + if (isRelativeDailyLimitOnBridgeSide) { + limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] + } else { + executionLimitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + } + } + + function initialize(tokenAddress) { + return contract.initialize( + bridgeContract.address, + mediatorContract.address, + tokenAddress, + limitsArray, + executionLimitsArray, + maxGasPerTx, + decimalShiftZero, + owner + ).should.be.fulfilled + } + describe('initialize', () => { beforeEach(async () => { bridgeContract = await AMBMock.new() @@ -34,28 +67,39 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) }) it('should initialize', async function() { - const contract = this.bridge + contract = this.bridge expect(await contract.isInitialized()).to.be.equal(false) expect(await contract.bridgeContract()).to.be.equal(ZERO_ADDRESS) expect(await contract.mediatorContractOnOtherSide()).to.be.equal(ZERO_ADDRESS) expect(await contract.erc677token()).to.be.equal(ZERO_ADDRESS) - expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await contract.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.minPerTx()).to.be.bignumber.equal(ZERO) - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.executionMinPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO) expect(await contract.owner()).to.be.equal(ZERO_ADDRESS) + if (isRelativeDailyLimit) { + expect(await contract.targetLimit()).to.be.bignumber.equal(ZERO) + expect(await contract.threshold()).to.be.bignumber.equal(ZERO) + if (isRelativeDailyLimitOnBridgeSide) { + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) + } else { + expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) + } + } else { + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) + expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) + } + // not valid bridge contract await contract .initialize( ZERO_ADDRESS, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, + executionLimitsArray, maxGasPerTx, decimalShiftZero, owner @@ -68,8 +112,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou bridgeContract.address, mediatorContract.address, ZERO_ADDRESS, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, + executionLimitsArray, maxGasPerTx, decimalShiftZero, owner @@ -77,13 +121,20 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou .should.be.rejectedWith(ERROR_MSG) // dailyLimit > maxPerTx + let limits = [maxPerTx, maxPerTx, minPerTx] + let executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + let relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } await contract .initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - [maxPerTx, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner @@ -91,41 +142,75 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou .should.be.rejectedWith(ERROR_MSG) // maxPerTx > minPerTx + limits = [dailyLimit, minPerTx, minPerTx] + executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } await contract .initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, minPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner ) .should.be.rejectedWith(ERROR_MSG) - // executionDailyLimit > executionMaxPerTx - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionMaxPerTx, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ) - .should.be.rejectedWith(ERROR_MSG) + // threshold <= 1 ether + if (isRelativeDailyLimit) { + limits = [dailyLimit, maxPerTx, minPerTx] + relativeDailyLimit = [ether('1.1'), threshold, executionMaxPerTx, executionMinPerTx] + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, + isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + maxGasPerTx, + decimalShiftZero, + owner + ) + .should.be.rejectedWith(ERROR_MSG) + + // threshold >= executionMinPerTx + limits = [dailyLimit, maxPerTx, minPerTx] + relativeDailyLimit = [targetLimit, ether('0.009'), executionMaxPerTx, executionMinPerTx] + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, + isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + maxGasPerTx, + decimalShiftZero, + owner + ) + .should.be.rejectedWith(ERROR_MSG) + } // executionMaxPerTx > executionMinPerTx + limits = [dailyLimit, maxPerTx, minPerTx] + executionLimits = [executionDailyLimit, executionMinPerTx, executionMinPerTx] + relativeDailyLimit = [targetLimit, threshold, executionMinPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } await contract .initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMinPerTx, executionMinPerTx], + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner @@ -138,24 +223,15 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou bridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, + executionLimitsArray, dailyLimit, decimalShiftZero, owner ) .should.be.rejectedWith(ERROR_MSG) - const { logs } = await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + const { logs } = await initialize(erc677Token.address) // already initialized await contract @@ -163,8 +239,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou bridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, + executionLimitsArray, maxGasPerTx, decimalShiftZero, owner @@ -175,33 +251,36 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(await contract.bridgeContract()).to.be.equal(bridgeContract.address) expect(await contract.mediatorContractOnOtherSide()).to.be.equal(mediatorContract.address) expect(await contract.erc677token()).to.be.equal(erc677Token.address) - expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) expect(await contract.maxPerTx()).to.be.bignumber.equal(maxPerTx) expect(await contract.minPerTx()).to.be.bignumber.equal(minPerTx) - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(executionMaxPerTx) expect(await contract.executionMinPerTx()).to.be.bignumber.equal(executionMinPerTx) expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx) expect(await contract.owner()).to.be.equal(owner) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) + if (isRelativeDailyLimit) { + expect(await contract.targetLimit()).to.be.bignumber.equal(targetLimit) + expect(await contract.threshold()).to.be.bignumber.equal(threshold) + if (isRelativeDailyLimitOnBridgeSide) { + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit }) + } else { + expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) + } + } else { + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) + expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit }) + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) + } }) it('only owner can set bridge contract', async function() { - const contract = this.bridge + contract = this.bridge const user = accounts[1] const notAContractAddress = accounts[2] - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) expect(await contract.bridgeContract()).to.be.equal(bridgeContract.address) @@ -214,19 +293,10 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(await contract.bridgeContract()).to.be.equal(newBridgeContract.address) }) it('only owner can set mediator contract', async function() { - const contract = this.bridge + contract = this.bridge const user = accounts[1] - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) expect(await contract.bridgeContract()).to.be.equal(bridgeContract.address) @@ -240,19 +310,10 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(await contract.mediatorContractOnOtherSide()).to.be.equal(newMediatorContract.address) }) it('only owner can set request Gas Limit', async function() { - const contract = this.bridge + contract = this.bridge const user = accounts[1] - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx) @@ -269,7 +330,6 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou }) }) describe('set limits', () => { - let contract beforeEach(async function() { bridgeContract = await AMBMock.new() await bridgeContract.setMaxGasPerTx(maxGasPerTx) @@ -278,12 +338,23 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou contract = this.bridge + let limits = [3, 2, 1] + let executionLimits = [3, 2, 1] + + if (isRelativeDailyLimit) { + if (isRelativeDailyLimitOnBridgeSide) { + limits = [ether('0.05'), 3, 2, 1] + } else { + executionLimits = [ether('0.05'), 3, 2, 1] + } + } + await contract.initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - [3, 2, 1], - [3, 2, 1], + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner @@ -294,7 +365,9 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou await contract.setMaxPerTx(2, { from: owner }).should.be.fulfilled expect(await contract.maxPerTx()).to.be.bignumber.equal('2') - await contract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + await contract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } }) it('setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { await contract.setMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) @@ -303,25 +376,29 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou await contract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) }) - it('setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { - await contract.setDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + it('setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { + await contract.setDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal('4') + await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal('4') - await contract.setDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) + await contract.setDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) - await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal('4') - }) + await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal('4') + }) + } it('setExecutionMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { await contract.setExecutionMaxPerTx(2, { from: user }).should.be.rejectedWith(ERROR_MSG) await contract.setExecutionMaxPerTx(2, { from: owner }).should.be.fulfilled expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('2') - await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { + await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } }) it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { await contract.setExecutionMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) @@ -330,23 +407,25 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou await contract.setExecutionMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) }) - it('setExecutionDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { - await contract.setExecutionDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { + it('setExecutionDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { + await contract.setExecutionDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setExecutionDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') + await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') - await contract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) + await contract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) - await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') - }) + await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') + }) + } }) describe('getBridgeMode', () => { it('should return arbitrary message bridging mode and interface', async function() { - const contract = this.bridge + contract = this.bridge const bridgeModeHash = '0x76595b56' // 4 bytes of keccak256('erc-to-erc-amb') expect(await contract.getBridgeMode()).to.be.equal(bridgeModeHash) @@ -357,7 +436,6 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou }) }) describe('fixAssetsAboveLimits', () => { - let contract const nonce = '0x96b6af865cdaa107ede916e237afbedffa5ed36bea84c0e77a33cc28fc2e9c01' beforeEach(async function() { bridgeContract = await AMBMock.new() @@ -367,16 +445,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou contract = this.proxyContract - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) const outOfLimitValueData = await contract.contract.methods .handleBridgedTokens(user, twoEthers.toString(), nonce) @@ -520,7 +589,6 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou }) }) describe('relayTokens', () => { - let contract let erc20Token beforeEach(async function() { bridgeContract = await AMBMock.new() @@ -531,55 +599,30 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou contract = this.bridge }) - it('should allow to bridge tokens using approve and transferFrom', async () => { - // Given - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc20Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + it('should allow to bridge tokens using approve and transferFrom', async () => { + // Given + await initialize(erc20Token.address) - const value = oneEther - await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - }) + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + }) + } it('should fail if user did not approve the transfer', async () => { - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc20Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc20Token.address) await contract.relayTokens(oneEther, { from: user }).should.be.rejectedWith(ERROR_MSG) }) it('should fail if value is not within limits', async () => { - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc20Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc20Token.address) const value = twoEthers await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled @@ -587,69 +630,52 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou await contract.relayTokens(value, { from: user }).should.be.rejectedWith(ERROR_MSG) }) - it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is owned by token manager', async function() { - // Given - const erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - await erc677Token.setBridgeContract(contract.address, { from: owner }).should.be.fulfilled - await erc677Token.transferOwnership(contract.address, { from: owner }).should.be.fulfilled + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is owned by token manager', async function() { + // Given + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + await erc677Token.setBridgeContract(contract.address, { from: owner }).should.be.fulfilled + await erc677Token.transferOwnership(contract.address, { from: owner }).should.be.fulfilled - contract = this.bridge + contract = this.bridge - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) - const value = oneEther - await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - }) - it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is not owned by token manager', async function() { - // Given - const erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + }) + it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is not owned by token manager', async function() { + // Given + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - contract = this.bridge + contract = this.bridge - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) - const value = oneEther - await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - }) + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + }) + } }) describe('requestFailedMessageFix', () => { - let contract const nonce = '0x96b6af865cdaa107ede916e237afbedffa5ed36bea84c0e77a33cc28fc2e9c01' beforeEach(async function() { bridgeContract = await AMBMock.new() @@ -659,16 +685,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou contract = this.proxyContract - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) }) it('should allow to request a failed message fix', async () => { // Given @@ -757,144 +774,127 @@ function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accou expect(allEvents[1].returnValues.encodedData.includes(strip0x(dataHash))).to.be.equal(true) }) }) - describe('fixFailedMessage', () => { - let dataHash - let contract - beforeEach(async function() { - bridgeContract = await AMBMock.new() - await bridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await otherSideMediatorContract.new() - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - - contract = this.bridge - - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled - await erc677Token.transferOwnership(contract.address) - - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - - // User transfer tokens - const transferTx = await erc677Token.transferAndCall(contract.address, oneEther, '0x00', { from: user }).should.be - .fulfilled - - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) - - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - const data = `0x${events[0].returnValues.encodedData.substr( - 148, - events[0].returnValues.encodedData.length - 148 - )}` - - // Bridge calls mediator from other side - await bridgeContract.executeMessageCall( - contract.address, - contract.address, - data, - transferTx.tx, - 100 - ).should.be.fulfilled - - expect(await bridgeContract.messageCallStatus(transferTx.tx)).to.be.equal(false) - - // mediator from other side should use this dataHash to request fix the failed message - dataHash = await bridgeContract.failedMessageDataHash(transferTx.tx) - }) - it('should fix burnt/locked tokens', async () => { - // Given - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) - - // When - const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() - - await bridgeContract.executeMessageCall( - contract.address, - mediatorContract.address, - fixData, - exampleTxHash, - 1000000 - ).should.be.fulfilled - - // Then - expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) - - const event = await getEvents(contract, { event: 'FailedMessageFixed' }) - expect(event.length).to.be.equal(1) - expect(event[0].returnValues.dataHash).to.be.equal(dataHash) - expect(event[0].returnValues.recipient).to.be.equal(user) - expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) - - const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + describe('fixFailedMessage', () => { + let dataHash + beforeEach(async function() { + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + + contract = this.bridge + + await initialize(erc677Token.address) + await erc677Token.transferOwnership(contract.address) + + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + + // User transfer tokens + const transferTx = await erc677Token.transferAndCall(contract.address, oneEther, '0x00', { from: user }).should.be + .fulfilled + + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) + + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + const data = `0x${events[0].returnValues.encodedData.substr( + 148, + events[0].returnValues.encodedData.length - 148 + )}` + + // Bridge calls mediator from other side + await bridgeContract.executeMessageCall( + contract.address, + contract.address, + data, + transferTx.tx, + 100 + ).should.be.fulfilled + + expect(await bridgeContract.messageCallStatus(transferTx.tx)).to.be.equal(false) + + // mediator from other side should use this dataHash to request fix the failed message + dataHash = await bridgeContract.failedMessageDataHash(transferTx.tx) + }) + it('should fix burnt/locked tokens', async () => { + // Given + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) - // can only fix it one time - await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) - .should.be.fulfilled + // When + const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() - expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(false) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - }) - it('should be called by bridge', async () => { - await contract.fixFailedMessage(dataHash, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - it('message sender should be mediator from other side', async () => { - // Given - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + await bridgeContract.executeMessageCall( + contract.address, + mediatorContract.address, + fixData, + exampleTxHash, + 1000000 + ).should.be.fulfilled + + // Then + expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) + + const event = await getEvents(contract, { event: 'FailedMessageFixed' }) + expect(event.length).to.be.equal(1) + expect(event[0].returnValues.dataHash).to.be.equal(dataHash) + expect(event[0].returnValues.recipient).to.be.equal(user) + expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) + + const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + + // can only fix it one time + await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) + .should.be.fulfilled + + expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(false) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + }) + it('should be called by bridge', async () => { + await contract.fixFailedMessage(dataHash, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('message sender should be mediator from other side', async () => { + // Given + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) - // When - const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() + // When + const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() - await bridgeContract.executeMessageCall(contract.address, contract.address, fixData, exampleTxHash, 1000000) - .should.be.fulfilled + await bridgeContract.executeMessageCall(contract.address, contract.address, fixData, exampleTxHash, 1000000) + .should.be.fulfilled - // Then - expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(false) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + // Then + expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(false) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) - const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) - .should.be.fulfilled + await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) + .should.be.fulfilled - expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(true) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) + expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(true) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) - const event = await getEvents(contract, { event: 'FailedMessageFixed' }) - expect(event.length).to.be.equal(1) - expect(event[0].returnValues.dataHash).to.be.equal(dataHash) - expect(event[0].returnValues.recipient).to.be.equal(user) - expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) + const event = await getEvents(contract, { event: 'FailedMessageFixed' }) + expect(event.length).to.be.equal(1) + expect(event[0].returnValues.dataHash).to.be.equal(dataHash) + expect(event[0].returnValues.recipient).to.be.equal(user) + expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) + }) }) - }) + } describe('#claimTokens', () => { it('should be able to claim tokens', async function() { - const contract = this.proxyContract + contract = this.proxyContract - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], - maxGasPerTx, - decimalShiftZero, - owner - ).should.be.fulfilled + await initialize(erc677Token.address) const tokenSecond = await ERC677BridgeToken.new('Test Token', 'TST', 18) diff --git a/test/amb_erc677_to_erc677/foreign_bridge.test.js b/test/amb_erc677_to_erc677/foreign_bridge.test.js index f81725504..3e16bba21 100644 --- a/test/amb_erc677_to_erc677/foreign_bridge.test.js +++ b/test/amb_erc677_to_erc677/foreign_bridge.test.js @@ -1,6 +1,8 @@ const ForeignAMBErc677ToErc677 = artifacts.require('ForeignAMBErc677ToErc677.sol') +const ForeignAMBErc677ToErc677RelativeDailyLimit = artifacts.require('ForeignAMBErc677ToErc677RelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const HomeAMBErc677ToErc677 = artifacts.require('HomeAMBErc677ToErc677.sol') +const HomeAMBErc677ToErc677RelativeDailyLimit = artifacts.require('HomeAMBErc677ToErc677RelativeDailyLimit.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const ForeignAMB = artifacts.require('ForeignAMB.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') @@ -25,21 +27,31 @@ const executionMaxPerTx = maxPerTx const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') -contract('ForeignAMBErc677ToErc677', async accounts => { +function test(accounts, isRelativeDailyLimit) { + const ForeignContract = isRelativeDailyLimit ? ForeignAMBErc677ToErc677RelativeDailyLimit : ForeignAMBErc677ToErc677 + const HomeContract = isRelativeDailyLimit ? HomeAMBErc677ToErc677RelativeDailyLimit : HomeAMBErc677ToErc677 const owner = accounts[0] const user = accounts[1] let ambBridgeContract let mediatorContract let erc677Token let foreignBridge + + let limitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + } + beforeEach(async function() { - this.bridge = await ForeignAMBErc677ToErc677.new() + this.bridge = await ForeignContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled - this.proxyContract = await ForeignAMBErc677ToErc677.at(storageProxy.address) + this.proxyContract = await ForeignContract.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeContract, accounts, isRelativeDailyLimit, false) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -47,17 +59,17 @@ contract('ForeignAMBErc677ToErc677', async accounts => { await validatorContract.initialize(1, authorities, owner) ambBridgeContract = await ForeignAMB.new() await ambBridgeContract.initialize(validatorContract.address, maxGasPerTx, '1', '1', owner) - mediatorContract = await HomeAMBErc677ToErc677.new() + mediatorContract = await HomeContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - foreignBridge = await ForeignAMBErc677ToErc677.new() + foreignBridge = await ForeignContract.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, maxGasPerTx, decimalShiftZero, owner @@ -92,16 +104,16 @@ contract('ForeignAMBErc677ToErc677', async accounts => { beforeEach(async () => { ambBridgeContract = await AMBMock.new() await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await HomeAMBErc677ToErc677.new() + mediatorContract = await HomeContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - foreignBridge = await ForeignAMBErc677ToErc677.new() + foreignBridge = await ForeignContract.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, maxGasPerTx, decimalShiftZero, owner @@ -110,6 +122,7 @@ contract('ForeignAMBErc677ToErc677', async accounts => { await erc677Token.transferOwnership(foreignBridge.address) }) it('should transfer locked tokens on message from amb', async () => { + if (isRelativeDailyLimit) return // Given const currentDay = await foreignBridge.getCurrentDay() expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) @@ -155,13 +168,13 @@ contract('ForeignAMBErc677ToErc677', async accounts => { const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 16) - foreignBridge = await ForeignAMBErc677ToErc677.new() + foreignBridge = await ForeignContract.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + limitsArray, maxGasPerTx, decimalShiftTwo, owner @@ -242,4 +255,12 @@ contract('ForeignAMBErc677ToErc677', async accounts => { expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) }) }) +} + +contract('ForeignAMBErc677ToErc677', async accounts => { + test(accounts, false) +}) + +contract('ForeignAMBErc677ToErc677RelativeDailyLimit', async accounts => { + test(accounts, true) }) diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index 113476eec..a807ab3b2 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -1,6 +1,8 @@ const HomeAMBErc677ToErc677 = artifacts.require('HomeAMBErc677ToErc677.sol') +const HomeAMBErc677ToErc677RelativeDailyLimit = artifacts.require('HomeAMBErc677ToErc677RelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const ForeignAMBErc677ToErc677 = artifacts.require('ForeignAMBErc677ToErc677.sol') +const ForeignAMBErc677ToErc677RelativeDailyLimit = artifacts.require('ForeignAMBErc677ToErc677RelativeDailyLimit.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const HomeAMB = artifacts.require('HomeAMB.sol') const AMBMock = artifacts.require('AMBMock.sol') @@ -25,21 +27,31 @@ const executionMaxPerTx = maxPerTx const executionMinPerTx = minPerTx const exampleTxHash = '0xf308b922ab9f8a7128d9d7bc9bce22cd88b2c05c8213f0e2d8104d78e0a9ecbb' const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') -contract('HomeAMBErc677ToErc677', async accounts => { +function test(accounts, isRelativeDailyLimit) { + const ForeignContract = isRelativeDailyLimit ? ForeignAMBErc677ToErc677RelativeDailyLimit : ForeignAMBErc677ToErc677 + const HomeContract = isRelativeDailyLimit ? HomeAMBErc677ToErc677RelativeDailyLimit : HomeAMBErc677ToErc677 const owner = accounts[0] const user = accounts[1] let ambBridgeContract let mediatorContract let erc677Token let homeBridge + + let limitsArray = [dailyLimit, maxPerTx, minPerTx] + if (isRelativeDailyLimit) { + limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] + } + beforeEach(async function() { - this.bridge = await HomeAMBErc677ToErc677.new() + this.bridge = await HomeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled - this.proxyContract = await HomeAMBErc677ToErc677.at(storageProxy.address) + this.proxyContract = await HomeContract.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(ForeignAMBErc677ToErc677, accounts) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeContract, accounts, isRelativeDailyLimit, true) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -47,67 +59,69 @@ contract('HomeAMBErc677ToErc677', async accounts => { await validatorContract.initialize(1, authorities, owner) ambBridgeContract = await HomeAMB.new() await ambBridgeContract.initialize(validatorContract.address, maxGasPerTx, '1', '1', owner) - mediatorContract = await ForeignAMBErc677ToErc677.new() + mediatorContract = await ForeignContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - homeBridge = await HomeAMBErc677ToErc677.new() + homeBridge = await HomeContract.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], + limitsArray, [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, owner ).should.be.fulfilled }) - it('should emit UserRequestForSignature in AMB bridge and burn transferred tokens', async () => { - // Given - const currentDay = await homeBridge.getCurrentDay() - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(initialEvents.length).to.be.equal(0) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - - // only token address can call it - await homeBridge.onTokenTransfer(user, oneEther, '0x00', { from: owner }).should.be.rejectedWith(ERROR_MSG) - - // must be within limits - await erc677Token - .transferAndCall(homeBridge.address, twoEthers, '0x00', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - - // When - const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, '0x00', { from: user }).should.be - .fulfilled - - // Then - const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(events.length).to.be.equal(1) - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) - expectEventInLogs(logs, 'Burn', { - burner: homeBridge.address, - value: oneEther + if (!isRelativeDailyLimit) { + it('should emit UserRequestForSignature in AMB bridge and burn transferred tokens', async () => { + // Given + const currentDay = await homeBridge.getCurrentDay() + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(initialEvents.length).to.be.equal(0) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + + // only token address can call it + await homeBridge.onTokenTransfer(user, oneEther, '0x00', { from: owner }).should.be.rejectedWith(ERROR_MSG) + + // must be within limits + await erc677Token + .transferAndCall(homeBridge.address, twoEthers, '0x00', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + + // When + const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, '0x00', { from: user }).should.be + .fulfilled + + // Then + const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(events.length).to.be.equal(1) + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + expectEventInLogs(logs, 'Burn', { + burner: homeBridge.address, + value: oneEther + }) }) - }) + } }) describe('handleBridgedTokens', () => { const nonce = '0x96b6af865cdaa107ede916e237afbedffa5ed36bea84c0e77a33cc28fc2e9c01' beforeEach(async () => { ambBridgeContract = await AMBMock.new() await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await ForeignAMBErc677ToErc677.new() + mediatorContract = await ForeignContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - homeBridge = await HomeAMBErc677ToErc677.new() + homeBridge = await HomeContract.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], + limitsArray, [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, @@ -162,12 +176,12 @@ contract('HomeAMBErc677ToErc677', async accounts => { const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - homeBridge = await HomeAMBErc677ToErc677.new() + homeBridge = await HomeContract.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, erc677Token.address, - [dailyLimit, maxPerTx, minPerTx], + limitsArray, [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftTwo, @@ -253,4 +267,12 @@ contract('HomeAMBErc677ToErc677', async accounts => { expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) }) }) +} + +contract('HomeAMBErc677ToErc677', async accounts => { + test(accounts, false) +}) + +contract('HomeAMBErc677ToErc677RelativeDailyLimit', async accounts => { + test(accounts, true) }) From 1c1eaf7a3adb23644136a65b0501e3a26298f952 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 31 Oct 2019 18:45:27 +0300 Subject: [PATCH 30/80] update foreign erc_to_erc tests --- test/erc_to_erc/foreign_bridge.test.js | 173 +++++++++++++++---------- 1 file changed, 103 insertions(+), 70 deletions(-) diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index e80f61604..07ac14121 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -1,5 +1,9 @@ const ForeignBridge = artifacts.require('ForeignBridgeErcToErc.sol') +const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeErcToErcRelativeDailyLimit.sol') const ForeignBridgeErc677ToErc677 = artifacts.require('ForeignBridgeErc677ToErc677.sol') +const ForeignBridgeErc677ToErc677RelativeDailyLimit = artifacts.require( + 'ForeignBridgeErc677ToErc677RelativeDailyLimit.sol' +) const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') @@ -21,8 +25,22 @@ const minPerTx = ether('0.01') const dailyLimit = oneEther const ZERO = toBN(0) const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge + const ForeignBridgeErc677ToErc677Contract = isRelativeDailyLimit + ? ForeignBridgeErc677ToErc677RelativeDailyLimit + : ForeignBridgeErc677ToErc677 + + let limitsArray = [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx] + let limitsArrayERC677 = [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + if (isRelativeDailyLimit) { + limitsArray = [maxPerTx, targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + limitsArrayERC677 = [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + } -contract('ForeignBridge_ERC20_to_ERC20', async accounts => { let validatorContract let authorities let owner @@ -37,7 +55,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { describe('#initialize', async () => { it('should initialize', async () => { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) @@ -52,7 +70,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -63,7 +81,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { ZERO_ADDRESS, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -74,7 +92,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { owner, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -83,9 +101,9 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { .initialize( validatorContract.address, token.address, - 0, + 0, // requireBlockConfirmations gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -95,19 +113,19 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { validatorContract.address, token.address, requireBlockConfirmations, - 0, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + 0, // gasPrice + limitsArray, owner, decimalShiftZero ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge .initialize( - owner, + owner, // validatorContract token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -118,7 +136,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, '9' ) @@ -143,7 +161,9 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + } }) }) @@ -151,22 +171,23 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const value = ether('0.25') let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) - await token.mint(foreignBridge.address, value) + await token.mint(foreignBridge.address, oneEther) }) it('should allow to executeSignatures', async () => { const recipientAccount = accounts[3] const balanceBefore = await token.balanceOf(recipientAccount) + const balanceBridgeBefore = await token.balanceOf(foreignBridge.address) const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) @@ -174,14 +195,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const vrs = signatureToVRS(signature) false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) const balanceAfter = await token.balanceOf(recipientAccount) - const balanceAfterBridge = await token.balanceOf(foreignBridge.address) + const balanceBridgeAfter = await token.balanceOf(foreignBridge.address) balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - balanceAfterBridge.should.be.bignumber.equal(ZERO) + balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(value)) true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) }) it('should allow second withdrawal with different transactionHash but same recipient and value', async () => { @@ -245,7 +266,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { it('should not allow withdraw over daily home limit', async () => { const recipientAccount = accounts[3] - await token.mint(foreignBridge.address, ether('5')) + await token.mint(foreignBridge.address, halfEther) const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) @@ -283,18 +304,18 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridge.new() + foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero, { from: ownerOfValidatorContract } ) - await token.mint(foreignBridgeWithMultiSignatures.address, value) + await token.mint(foreignBridgeWithMultiSignatures.address, oneEther) }) it('withdraw should fail if not enough signatures are provided', async () => { const recipientAccount = accounts[4] @@ -317,9 +338,9 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithMultiSignatures.relayedMessages(transactionHash)) }) it('withdraw should fail if duplicate signature is provided', async () => { @@ -342,18 +363,18 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) - await erc20Token.mint(foreignBridgeWithThreeSigs.address, value) + await erc20Token.mint(foreignBridgeWithThreeSigs.address, oneEther) const txHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipient, value, txHash, foreignBridgeWithThreeSigs.address) @@ -376,9 +397,9 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) }) }) @@ -400,16 +421,16 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) + foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -426,24 +447,25 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { ;(await foreignBridgeV2Proxy.something()).should.be.equal(accounts[2]) }) it('can be deployed via upgradeToAndCall', async () => { + const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const tokenAddress = token.address const validatorsAddress = validatorContract.address const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, tokenAddress, requireBlockConfirmations, gasPrice, - ['2', '3', '2', '1'], + isRelativeDailyLimit ? ['2', '1', '3', '2', '1'] : ['2', '3', '2', '1'], owner, decimalShiftZero ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridge.at(storageProxy.address) + const finalContract = await ForeignBridgeContract.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) }) @@ -452,16 +474,16 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { it('can send erc20', async () => { const owner = accounts[0] token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -487,14 +509,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { it('should emit correct events on initialize', async () => { const owner = accounts[3] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() const { logs } = await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftZero ) @@ -503,21 +525,23 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + } expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) }) it('can only be called from token contract', async () => { const owner = accounts[3] const user = accounts[4] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftZero ) @@ -540,14 +564,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftZero ) @@ -575,14 +599,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftZero ) @@ -616,14 +640,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftZero ) @@ -654,21 +678,22 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const valueOnForeign = toBN('1000') // Value is decimals shifted from foreign to home: Native on home = 16+2 shift = 18 decimals const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftTwo ) - await token.mint(foreignBridge.address, valueOnForeign) + await token.mint(foreignBridge.address, valueOnHome.mul(toBN('2'))) const recipientAccount = accounts[3] const balanceBefore = await token.balanceOf(recipientAccount) + const balanceBridgeBefore = await token.balanceOf(foreignBridge.address) const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' const message = createMessage(recipientAccount, valueOnHome, transactionHash, foreignBridge.address) @@ -676,14 +701,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const vrs = signatureToVRS(signature) false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(valueOnHome) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(valueOnHome) const balanceAfter = await token.balanceOf(recipientAccount) - const balanceAfterBridge = await token.balanceOf(foreignBridge.address) + const balanceBridgeAfter = await token.balanceOf(foreignBridge.address) balanceAfter.should.be.bignumber.equal(balanceBefore.add(valueOnForeign)) - balanceAfterBridge.should.be.bignumber.equal(ZERO) + balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(valueOnForeign)) true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) }) it('Home to Foreign : withdraw works with 5 validators and 3 required signatures with a decimalShift of 2', async () => { @@ -697,18 +722,18 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftTwo ) - await erc20Token.mint(foreignBridgeWithThreeSigs.address, valueOnForeign) + await erc20Token.mint(foreignBridgeWithThreeSigs.address, valueOnHome.mul(toBN('2'))) const balanceBeforeRecipient = await erc20Token.balanceOf(recipient) const balanceBeforeBridge = await erc20Token.balanceOf(foreignBridgeWithThreeSigs.address) @@ -734,9 +759,9 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(valueOnHome) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(valueOnHome) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) const balanceAfterRecipient = await erc20Token.balanceOf(recipient) balanceAfterRecipient.should.be.bignumber.equal(balanceBeforeRecipient.add(valueOnForeign)) @@ -748,14 +773,14 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const owner = accounts[3] const user = accounts[4] token = await ERC677BridgeToken.new('TEST', 'TST', 16, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArrayERC677, owner, decimalShiftTwo ) @@ -774,4 +799,12 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(value) }) }) +} + +contract('ForeignBridge_ERC20_to_ERC20', async accounts => { + test(accounts, false) +}) + +contract('ForeignBridge_ERC20_to_ERC20_RelativeDailyLimit', async accounts => { + test(accounts, true) }) From 95b1a926049223194c80c882dbf791ad9769f145 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 1 Nov 2019 13:32:38 +0300 Subject: [PATCH 31/80] update home erc_to_erc tests --- test/erc_to_erc/home_bridge.test.js | 240 ++++++++++++++++++---------- 1 file changed, 158 insertions(+), 82 deletions(-) diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index 4e31137b7..f2f513913 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -1,5 +1,7 @@ const HomeBridge = artifacts.require('HomeBridgeErcToErc.sol') +const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToErcRelativeDailyLimit.sol') const POSDAOHomeBridge = artifacts.require('HomeBridgeErcToErcPOSDAO.sol') +const POSDAOHomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') @@ -27,8 +29,17 @@ const decimalShiftZero = 0 const markedAsProcessed = toBN(2) .pow(toBN(255)) .add(toBN(1)) +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge + const POSDAOHomeBridgeContract = isRelativeDailyLimit ? POSDAOHomeBridgeRelativeDailyLimit : POSDAOHomeBridge + + const limitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, halfEther, minPerTx] + : [oneEther, halfEther, minPerTx] -contract('HomeBridge_ERC20_to_ERC20', async accounts => { let homeContract let validatorContract let authorities @@ -41,21 +52,26 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await validatorContract.initialize(1, authorities, owner) }) describe('#initialize', async () => { + const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) }) it('sets variables', async () => { expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) expect(await homeContract.isInitialized()).to.be.equal(false) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) + } + const { logs } = await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -67,7 +83,6 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { expect(await homeContract.isInitialized()).to.be.equal(true) expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') @@ -77,33 +92,42 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { expect(major).to.be.bignumber.gte(ZERO) expect(minor).to.be.bignumber.gte(ZERO) expect(patch).to.be.bignumber.gte(ZERO) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + } expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) + } }) - it('cant set maxPerTx > dailyLimit', async () => { + it('cant set wrong values', async () => { expect(await homeContract.isInitialized()).to.be.equal(false) + if (!isRelativeDailyLimit) { + // dailyLimit > maxPerTx + await homeContract + .initialize( + validatorContract.address, + ['1', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } + // maxPerTx > minPerTx await homeContract .initialize( validatorContract.address, - ['1', '2', '1'], - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - validatorContract.address, - ['3', '2', '2'], + isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], gasPrice, requireBlockConfirmations, token.address, @@ -113,6 +137,36 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { ) .should.be.rejectedWith(ERROR_MSG) + if (isRelativeDailyLimit) { + // threshold >= minPerTx + await homeContract + .initialize( + validatorContract.address, + ['1', '1', '3', '2'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + + // targetLimit <= 1 ether + await homeContract + .initialize( + validatorContract.address, + [ether('2'), '3', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } + expect(await homeContract.isInitialized()).to.be.equal(false) }) @@ -121,7 +175,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const data = homeContract.contract.methods .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -131,13 +185,15 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridge.at(storageProxy.address) + const finalContract = await HomeBridgeContract.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + } }) it('cant initialize with invalid arguments', async () => { @@ -146,7 +202,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, 0, token.address, @@ -158,7 +214,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( owner, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -170,7 +226,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( ZERO_ADDRESS, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -182,7 +238,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, ZERO_ADDRESS, @@ -194,7 +250,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, owner, @@ -206,7 +262,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -218,7 +274,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -229,7 +285,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { .should.be.rejectedWith(ERROR_MSG) await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -247,7 +303,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { // When await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, 0, requireBlockConfirmations, token.address, @@ -263,11 +319,11 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#fallback', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, token.address, @@ -289,11 +345,11 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#setting limits', async () => { let homeContract beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, token.address, @@ -306,7 +362,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled - await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + // in implementation with relative daily limit, maxPerTx can be more than current dailyLimit + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } }) it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { @@ -320,11 +379,11 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -406,10 +465,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token2sig.address, @@ -491,10 +550,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token2sig.address, @@ -533,10 +592,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -669,7 +728,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { }) describe('#isAlreadyProcessed', async () => { it('returns ', async () => { - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const bn = toBN(2).pow(toBN(255)) const processedNumbers = [bn.add(toBN(1)).toString(10), bn.add(toBN(100)).toString(10)] true.should.be.equal(await homeBridge.isAlreadyProcessed(processedNumbers[0])) @@ -689,10 +748,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridge.new() + homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token2sig.address, @@ -759,10 +818,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -851,7 +910,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() }) it('should return the required message length', async () => { @@ -863,13 +922,13 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#fixAssetsAboveLimits', async () => { let homeBridge beforeEach(async () => { - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1135,13 +1194,13 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { it('should be able to call claimTokens on tokenAddress', async () => { const token = await ERC677BridgeToken.new('Bridge Token', 'BT20', 18) - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1182,7 +1241,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - homeBridge = await POSDAOHomeBridge.new() + homeBridge = await POSDAOHomeBridgeContract.new() homeFee = ether('0.002') foreignFee = ether('0.002') blockRewardContract = await BlockReward.new() @@ -1191,13 +1250,15 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const feeManager = await FeeManagerErcToErcPOSDAO.new() expect(await homeBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await homeBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeBridge.isInitialized()).to.be.equal(false) + if (!isRelativeDailyLimit) { + expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(ZERO) + } await homeBridge.rewardableInitialize( ZERO_ADDRESS, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1210,7 +1271,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { ).should.be.rejected await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, [0, foreignDailyLimit], token.address, @@ -1223,7 +1284,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { ).should.be.rejected await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1236,7 +1297,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { ).should.be.rejected const { logs } = await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1251,7 +1312,6 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { expect(await homeBridge.isInitialized()).to.be.equal(true) expect(await homeBridge.validatorContract()).to.be.equal(rewardableValidators.address) expect(await homeBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(oneEther) expect(await homeBridge.maxPerTx()).to.be.bignumber.equal(halfEther) expect(await homeBridge.minPerTx()).to.be.bignumber.equal(minPerTx) expect(await homeBridge.decimalShift()).to.be.bignumber.equal('9') @@ -1261,6 +1321,9 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { expect(major).to.be.bignumber.gte(ZERO) expect(minor).to.be.bignumber.gte(ZERO) expect(patch).to.be.bignumber.gte(ZERO) + if (!isRelativeDailyLimit) { + expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(oneEther) + } const feeManagerContract = await homeBridge.feeManagerContract() feeManagerContract.should.be.equals(feeManager.address) @@ -1275,14 +1338,16 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) + } }) it('can update fee contract', async () => { const feeManager = await FeeManagerErcToErcPOSDAO.new() await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1308,7 +1373,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const feeManager = await FeeManagerErcToErcPOSDAO.new() await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1338,7 +1403,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const feeManager = await FeeManagerErcToErcPOSDAO.new() await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1378,7 +1443,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { // When await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1400,7 +1465,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1431,7 +1496,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { describe('#onTokenTransfer', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'TEST', 18) }) it('should trigger UserRequestForSignature with transfer value', async () => { @@ -1440,7 +1505,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1449,6 +1514,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { decimalShiftZero ).should.be.fulfilled const value = halfEther + await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.mint(user, value, { from: owner }).should.be.fulfilled // When @@ -1461,7 +1527,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { }) it('should trigger UserRequestForSignature with fee subtracted', async () => { // Given - const homeBridge = await POSDAOHomeBridge.new() + const homeBridge = await POSDAOHomeBridgeContract.new() const owner = accounts[0] const user = accounts[4] const validators = [accounts[1]] @@ -1477,7 +1543,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1491,6 +1557,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { const value = halfEther const finalValueCalc = 0.5 * (1 - fee) const finalValue = ether(finalValueCalc.toString()) + await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.mint(user, value, { from: owner }).should.be.fulfilled // When @@ -1514,14 +1581,14 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { token = await ERC677BridgeTokenRewardable.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() feeManager = await FeeManagerErcToErcPOSDAO.new() - homeBridge = await POSDAOHomeBridge.new() + homeBridge = await POSDAOHomeBridgeContract.new() fee = 0.001 homeFee = ether(fee.toString()) foreignFee = ether(fee.toString()) blockRewardContract = await BlockReward.new() await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1708,14 +1775,14 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { token = await ERC677BridgeTokenRewardable.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() feeManager = await FeeManagerErcToErcPOSDAO.new() - homeBridge = await POSDAOHomeBridge.new() + homeBridge = await POSDAOHomeBridgeContract.new() fee = 0.001 homeFee = ether(fee.toString()) foreignFee = ether(fee.toString()) blockRewardContract = await BlockReward.new() await homeBridge.rewardableInitialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1917,10 +1984,10 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1964,13 +2031,13 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { }) it('Foreign to Home: test decimal shift 2, no impact on UserRequestForSignature value', async () => { // Given - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'TEST', 16) const owner = accounts[0] const user = accounts[4] await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, @@ -1979,6 +2046,7 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { decimalShiftTwo ).should.be.fulfilled const value = halfEther + await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.mint(user, value, { from: owner }).should.be.fulfilled // When @@ -1990,4 +2058,12 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(value) }) }) +} + +contract('HomeBridge_ERC20_to_ERC20', async accounts => { + test(accounts, false) +}) + +contract('HomeBridge_ERC20_to_ERC20_RelativeDailyLimit', async accounts => { + test(accounts, true) }) From 4ae56b20ba2410997baeba3f60103227cfa9d59d Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 1 Nov 2019 15:16:11 +0300 Subject: [PATCH 32/80] fix check in contracts --- .../ForeignBridgeErcToNativeRelativeDailyLimit.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index e3447be3b..8da1d7d23 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -25,7 +25,7 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, ) external returns (bool) { require( _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[2] && // _homeMaxPerTx > _homeMinPerTx + _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx _limitsArray[2] >= _limitsArray[4] && // _threshold >= _homeMinPerTx _limitsArray[1] <= 1 ether // _targetLimit <= 1 ether ); From cc9fcfae7fac1ac33be3e9ce02ab05fb3268ffb7 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 1 Nov 2019 15:44:12 +0300 Subject: [PATCH 33/80] update foreign erc_to_native tests --- test/erc_to_native/foreign_bridge.test.js | 190 ++++++++++++++-------- 1 file changed, 118 insertions(+), 72 deletions(-) diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index 453459625..a1da53905 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -1,4 +1,5 @@ const ForeignBridge = artifacts.require('ForeignBridgeErcToNative.sol') +const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeErcToNativeRelativeDailyLimit.sol') const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') @@ -19,8 +20,16 @@ const homeMinPerTx = quarterEther const maxPerTx = halfEther const ZERO = toBN(0) const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge + + const limitsArray = isRelativeDailyLimit + ? [maxPerTx, targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx] -contract('ForeignBridge_ERC20_to_Native', async accounts => { let validatorContract let authorities let owner @@ -35,7 +44,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('#initialize', async () => { it('should initialize', async () => { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) @@ -50,7 +59,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -61,18 +70,18 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { ZERO_ADDRESS, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) .should.be.rejectedWith(ERROR_MSG) - await foreignBridge + await foreignBridge // eslint-disable-next-line .initialize( validatorContract.address, token.address, 0, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -83,7 +92,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, 0, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -94,40 +103,67 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { owner, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) .should.be.rejectedWith(ERROR_MSG) - await foreignBridge + await foreignBridge // eslint-disable-next-line .initialize( owner, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) .should.be.rejectedWith(ERROR_MSG) + if (isRelativeDailyLimit) { + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + [maxPerTx, ether('2'), threshold, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + [maxPerTx, targetLimit, ether('0.001'), homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } else { + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + [maxPerTx, halfEther, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } await foreignBridge .initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, halfEther, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMaxPerTx], + isRelativeDailyLimit + ? [maxPerTx, targetLimit, threshold, homeMaxPerTx, homeMaxPerTx] + : [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMaxPerTx], owner, decimalShiftZero ) @@ -138,7 +174,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, '9' ) @@ -163,7 +199,9 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + } }) }) @@ -171,14 +209,14 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const value = ether('0.25') let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -196,10 +234,9 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) const balanceAfter = await token.balanceOf(recipientAccount) const balanceAfterBridge = await token.balanceOf(foreignBridge.address) balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) @@ -210,6 +247,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { it('should allow second withdrawal with different transactionHash but same recipient and value', async () => { const recipientAccount = accounts[3] const balanceBefore = await token.balanceOf(recipientAccount) + await token.mint(foreignBridge.address, oneEther) // tx 1 const value = ether('0.25') @@ -222,7 +260,6 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled // tx 2 - await token.mint(foreignBridge.address, value) const transactionHash2 = '0x77a496628a776a03d58d7e6059a5937f04bebd8ba4ff89f76dd4bb8ba7e291ee' const message2 = createMessage(recipientAccount, value, transactionHash2, foreignBridge.address) const signature2 = await sign(authorities[0], message2) @@ -277,7 +314,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { it('should not allow withdraw over daily home limit', async () => { const recipientAccount = accounts[3] - await token.mint(foreignBridge.address, ether('5')) + await token.mint(foreignBridge.address, ether('1.25')) const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) @@ -316,18 +353,18 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridge.new() + foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero, { from: ownerOfValidatorContract } ) - await token.mint(foreignBridgeWithMultiSignatures.address, value) + await token.mint(foreignBridgeWithMultiSignatures.address, oneEther) }) it('withdraw should fail if not enough signatures are provided', async () => { @@ -354,10 +391,9 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { [vrs.s, vrs2.s], message ).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithMultiSignatures.relayedMessages(transactionHash)) }) @@ -381,18 +417,18 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) - await erc20Token.mint(foreignBridgeWithThreeSigs.address, value) + await erc20Token.mint(foreignBridgeWithThreeSigs.address, oneEther) const txHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipient, value, txHash, foreignBridgeWithThreeSigs.address) @@ -415,9 +451,9 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) }) }) @@ -440,16 +476,16 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) + foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -466,14 +502,14 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const validatorsAddress = validatorContract.address const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, tokenAddress, requireBlockConfirmations, gasPrice, - ['2', '3', '2', '1'], + isRelativeDailyLimit ? ['2', '1', '3', '2', '1'] : ['2', '3', '2', '1'], owner, decimalShiftZero ) @@ -481,7 +517,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridge.at(storageProxy.address) + const finalContract = await ForeignBridgeContract.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) }) @@ -491,17 +527,17 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { it('can send erc20', async () => { const owner = accounts[0] token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftZero ) @@ -533,24 +569,25 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) const owner = accounts[0] - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftTwo ) - await token.mint(foreignBridge.address, valueOnForeign) + await token.mint(foreignBridge.address, valueOnHome.mul(toBN('2'))) const recipientAccount = accounts[3] const balanceBefore = await token.balanceOf(recipientAccount) + const balanceBridgeBefore = await token.balanceOf(foreignBridge.address) const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' const message = createMessage(recipientAccount, valueOnHome, transactionHash, foreignBridge.address) @@ -559,14 +596,13 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(valueOnHome) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(valueOnHome) const balanceAfter = await token.balanceOf(recipientAccount) balanceAfter.should.be.bignumber.equal(balanceBefore.add(valueOnForeign)) - const balanceAfterBridge = await token.balanceOf(foreignBridge.address) - balanceAfterBridge.should.be.bignumber.equal(ZERO) + const balanceBridgeAfter = await token.balanceOf(foreignBridge.address) + balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(valueOnForeign)) true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) }) @@ -582,20 +618,21 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - const foreignBridgeWithMultiSignatures = await ForeignBridge.new() + const foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [maxPerTx, homeDailyLimit, homeMaxPerTx, homeMinPerTx], + limitsArray, owner, decimalShiftTwo, { from: ownerOfValidatorContract } ) - await token.mint(foreignBridgeWithMultiSignatures.address, valueOnForeign) + await token.mint(foreignBridgeWithMultiSignatures.address, valueOnHome.mul(toBN('2'))) const balanceBefore = await token.balanceOf(recipient) + const balanceBridgeBefore = await token.balanceOf(foreignBridgeWithMultiSignatures.address) const txHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipient, valueOnHome, txHash, foreignBridgeWithMultiSignatures.address) @@ -614,14 +651,23 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { [vrs.s, vrs2.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(valueOnHome) + const event = logs.find(item => item.event === 'RelayedMessage') + event.event.should.be.equal('RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(valueOnHome) const balanceAfter = await token.balanceOf(recipient) balanceAfter.should.be.bignumber.equal(balanceBefore.add(valueOnForeign)) - const balanceAfterBridge = await token.balanceOf(foreignBridgeWithMultiSignatures.address) - balanceAfterBridge.should.be.bignumber.equal(ZERO) + const balanceBridgeAfter = await token.balanceOf(foreignBridgeWithMultiSignatures.address) + balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(valueOnForeign)) true.should.be.equal(await foreignBridgeWithMultiSignatures.relayedMessages(txHash)) }) }) +} + +contract('ForeignBridge_ERC20_to_Native', async accounts => { + test(accounts, false) +}) + +contract('ForeignBridge_ERC20_to_Native_RelativeDailyLimit', async accounts => { + test(accounts, true) }) From 54f4519c2fea32af4e30e087400df44b34c5a40b Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Sun, 3 Nov 2019 19:08:05 +0300 Subject: [PATCH 34/80] update home erc_to_native tests --- test/erc_to_native/home_bridge.test.js | 352 +++++++++++++++---------- 1 file changed, 217 insertions(+), 135 deletions(-) diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index a6ff38e46..2a9e2eaed 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -1,4 +1,5 @@ const HomeBridge = artifacts.require('HomeBridgeErcToNative.sol') +const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToNativeRelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const BlockReward = artifacts.require('BlockReward') @@ -23,8 +24,16 @@ const foreignMaxPerTx = halfEther const foreignMinPerTx = quarterEther const ZERO = toBN(0) const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge + + const limitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, halfEther, minPerTx] + : [oneEther, halfEther, minPerTx] -contract('HomeBridge_ERC20_to_Native', async accounts => { let homeContract let validatorContract let blockRewardContract @@ -39,21 +48,25 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) describe('#initialize', async () => { + const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() }) it('sets variables', async () => { expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) expect(await homeContract.isInitialized()).to.be.equal(false) expect(await homeContract.blockRewardContract()).to.be.equal(ZERO_ADDRESS) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) + } const { logs } = await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -65,7 +78,9 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { expect(await homeContract.isInitialized()).to.be.equal(true) expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + } expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') @@ -83,7 +98,9 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) + } }) it('can update block reward contract', async () => { @@ -91,7 +108,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -127,22 +144,49 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { it('cant set maxPerTx > dailyLimit', async () => { false.should.be.equal(await homeContract.isInitialized()) + if (isRelativeDailyLimit) { + await homeContract + .initialize( + validatorContract.address, + [ether('2'), '3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + ['1', '1', '3', '2'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } else { + await homeContract + .initialize( + validatorContract.address, + ['1', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + .should.be.rejectedWith(ERROR_MSG) + } await homeContract .initialize( validatorContract.address, - ['1', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - validatorContract.address, - ['3', '2', '2'], + isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -160,7 +204,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const data = homeContract.contract.methods .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -171,11 +215,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridge.at(storageProxy.address) + const finalContract = await HomeBridgeContract.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + } expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) @@ -186,7 +232,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const data = homeContract.contract.methods .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -197,22 +243,26 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridge.at(storageProxy.address) + const finalContract = await HomeBridgeContract.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + } expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) - const homeContractV2 = await HomeBridge.new() + const homeContractV2 = await HomeBridgeContract.new() await storageProxy.upgradeTo('2', homeContractV2.address).should.be.fulfilled - const finalContractV2 = await HomeBridge.at(storageProxy.address) + const finalContractV2 = await HomeBridgeContract.at(storageProxy.address) expect(await finalContractV2.isInitialized()).to.be.equal(true) expect(await finalContractV2.validatorContract()).to.be.equal(validatorContract.address) - expect(await finalContractV2.dailyLimit()).to.be.bignumber.equal('3') + if (!isRelativeDailyLimit) { + expect(await finalContractV2.dailyLimit()).to.be.bignumber.equal('3') + } expect(await finalContractV2.maxPerTx()).to.be.bignumber.equal('2') expect(await finalContractV2.minPerTx()).to.be.bignumber.equal('1') expect(await finalContractV2.blockRewardContract()).to.be.equal(blockRewardContract.address) @@ -222,7 +272,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, 0, blockRewardContract.address, @@ -234,7 +284,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( owner, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -246,7 +296,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( ZERO_ADDRESS, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -258,7 +308,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, owner, @@ -270,7 +320,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -282,7 +332,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -293,7 +343,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { .should.be.rejectedWith(ERROR_MSG) await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -306,27 +356,30 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) describe('#rewardableInitialize', async () => { + const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] let feeManager let homeFee let foreignFee beforeEach(async () => { feeManager = await FeeManagerErcToNative.new() - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() homeFee = ether('0.001') foreignFee = ether('0.002') }) it('sets variables', async () => { expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) expect(await homeContract.isInitialized()).to.be.equal(false) expect(await homeContract.blockRewardContract()).to.be.equal(ZERO_ADDRESS) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) + } await homeContract.rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -340,7 +393,9 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { expect(await homeContract.isInitialized()).to.be.equal(true) expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + } expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') @@ -366,7 +421,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, 0, blockRewardContract.address, @@ -380,7 +435,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( owner, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -394,7 +449,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( ZERO_ADDRESS, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -408,7 +463,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, owner, @@ -422,7 +477,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -436,7 +491,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -450,7 +505,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract .rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -463,7 +518,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { .should.be.rejectedWith(ERROR_MSG) await homeContract.rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -479,7 +534,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { it('can update fee contract', async () => { await homeContract.rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -504,7 +559,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { it('can update fee', async () => { await homeContract.rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -532,7 +587,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { it('fee should be less than 100%', async () => { await homeContract.rewardableInitialize( validatorContract.address, - ['3', '2', '1'], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -565,10 +620,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { describe('#fallback', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -616,6 +671,18 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) it('doesnt let you send more than daily limit', async () => { + homeContract = await HomeBridgeContract.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) const currentDay = await homeContract.getCurrentDay() @@ -631,14 +698,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + } }) it('doesnt let you send more than max amount per tx', async () => { - await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) await homeContract.sendTransaction({ from: accounts[1], @@ -650,8 +719,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { value: 3 }) .should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + } await homeContract.setMaxPerTx(99).should.be.fulfilled // meets max per tx and daily limit await homeContract.sendTransaction({ @@ -690,7 +761,8 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - await blockRewardContract.addMintedTotallyByBridge(2, homeContract.address) + const amountToMint = isRelativeDailyLimit ? '3' : '2' + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled @@ -701,7 +773,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) const burnt = await homeContract.totalBurntCoins() - minted.should.be.bignumber.equal('2') + minted.should.be.bignumber.equal(amountToMint) burnt.should.be.bignumber.equal('2') }) }) @@ -709,10 +781,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { describe('#setting limits', async () => { let homeContract beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -725,7 +797,9 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled - await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } const maxPerTx = await homeContract.maxPerTx() maxPerTx.should.be.bignumber.equal(toBN(2)) }) @@ -788,10 +862,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -863,10 +937,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -927,10 +1001,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) it('should fail if the block reward contract is not set', async () => { - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, ZERO_ADDRESS, @@ -953,10 +1027,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1104,10 +1178,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridge.new() + homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1172,10 +1246,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1265,7 +1339,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() }) it('should return the required message length', async () => { @@ -1275,13 +1349,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { describe('#fixAssetsAboveLimits', async () => { let homeBridge beforeEach(async () => { - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1510,16 +1584,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1583,13 +1657,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1664,16 +1738,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1737,17 +1811,17 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 2 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const blockRewardContract = await BlockReward.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1843,16 +1917,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -1948,13 +2022,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2001,16 +2075,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2070,16 +2144,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2164,16 +2238,16 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2275,10 +2349,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2286,7 +2360,7 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2352,18 +2426,18 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 2 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const blockRewardContract = await BlockReward.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2462,17 +2536,17 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2581,13 +2655,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2634,17 +2708,17 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2710,17 +2784,17 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2811,17 +2885,17 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled await blockRewardContract.setValidatorsRewards(rewards) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2930,12 +3004,12 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() const currentDay = await homeBridgeWithTwoSigs.getCurrentDay() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -2993,10 +3067,10 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { }) it('Home to Foreign: test decimal shift 2, no impact on UserRequestForSignature value', async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? [ether('0.05'), '10000', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, blockRewardContract.address, @@ -3008,9 +3082,9 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const currentDay = await homeContract.getCurrentDay() expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(100, homeContract.address) const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - minted.should.be.bignumber.equal('10') + minted.should.be.bignumber.equal('100') const recipientAccount = accounts[1] @@ -3038,4 +3112,12 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { logsSubmitSignature[1].event.should.be.equal('CollectedSignatures') }) }) +} + +contract('HomeBridge_ERC20_to_Native', async accounts => { + test(accounts, false) +}) + +contract('HomeBridge_ERC20_to_Native_RelativeDailyLimit', async accounts => { + test(accounts, true) }) From 846e09ce984c52cc27a3ed33cd4032db5ed11028 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 4 Nov 2019 15:17:21 +0300 Subject: [PATCH 35/80] update foreign native_to_erc tests --- test/native_to_erc/foreign_bridge_test.js | 289 +++++++++++++--------- 1 file changed, 166 insertions(+), 123 deletions(-) diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index e23cac966..3b95b01f7 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -1,4 +1,5 @@ const ForeignBridge = artifacts.require('ForeignBridgeNativeToErc.sol') +const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeNativeToErcRelativeDailyLimit.sol') const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') @@ -21,8 +22,16 @@ const homeMaxPerTx = halfEther const homeMinPerTx = minPerTx const ZERO = toBN(0) const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge + + const limitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, halfEther, minPerTx] + : [oneEther, halfEther, minPerTx] -contract('ForeignBridge', async accounts => { let validatorContract let authorities let owner @@ -37,21 +46,23 @@ contract('ForeignBridge', async accounts => { describe('#initialize', async () => { it('should initialize', async () => { token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.isInitialized()).to.be.equal(false) expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) + } await foreignBridge .initialize( ZERO_ADDRESS, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -63,7 +74,7 @@ contract('ForeignBridge', async accounts => { .initialize( validatorContract.address, ZERO_ADDRESS, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -75,7 +86,7 @@ contract('ForeignBridge', async accounts => { .initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, 0, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -87,7 +98,7 @@ contract('ForeignBridge', async accounts => { .initialize( owner, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, requireBlockConfirmations, gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -99,7 +110,7 @@ contract('ForeignBridge', async accounts => { .initialize( validatorContract.address, owner, - [oneEther, halfEther, minPerTx], + limitsArray, requireBlockConfirmations, gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -111,7 +122,7 @@ contract('ForeignBridge', async accounts => { .initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, 0, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -122,7 +133,7 @@ contract('ForeignBridge', async accounts => { const { logs } = await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -137,7 +148,6 @@ contract('ForeignBridge', async accounts => { requireBlockConfirmations.toString() ) expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(halfEther) expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') @@ -147,25 +157,30 @@ contract('ForeignBridge', async accounts => { expect(major).to.be.bignumber.gte(ZERO) expect(minor).to.be.bignumber.gte(ZERO) expect(patch).to.be.bignumber.gte(ZERO) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) + } expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) + } }) }) describe('#executeSignatures', async () => { let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -185,10 +200,10 @@ contract('ForeignBridge', async accounts => { const vrs = signatureToVRS(signature) false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) - logs[0].args.transactionHash.should.be.equal(transactionHash) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) const balanceAfter = await token.balanceOf(recipientAccount) const totalSupplyAfter = await token.totalSupply() @@ -224,11 +239,10 @@ contract('ForeignBridge', async accounts => { const vrs2 = signatureToVRS(signature2) false.should.be.equal(await foreignBridge.relayedMessages(transactionHash2)) const { logs } = await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) - logs[0].args.transactionHash.should.be.equal(transactionHash2) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash2) const totalSupply = await token.totalSupply() const balanceAfter = await token.balanceOf(recipientAccount) balanceAfter.should.be.bignumber.equal(balanceBefore.add(value.mul(toBN(2)))) @@ -306,11 +320,11 @@ contract('ForeignBridge', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridge.new() + foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -341,11 +355,10 @@ contract('ForeignBridge', async accounts => { [vrs.s, vrs2.s], message ).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) - logs[0].args.transactionHash.should.be.equal(transactionHash) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) true.should.be.equal(await foreignBridgeWithMultiSignatures.relayedMessages(transactionHash)) }) it('deposit should fail if duplicate signature is provided', async () => { @@ -369,12 +382,12 @@ contract('ForeignBridge', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await POA20.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -404,9 +417,9 @@ contract('ForeignBridge', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) }) it('Should fail if length of signatures is not equal', async () => { @@ -417,12 +430,12 @@ contract('ForeignBridge', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await POA20.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -454,9 +467,9 @@ contract('ForeignBridge', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(value) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(value) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) }) }) @@ -466,11 +479,11 @@ contract('ForeignBridge', async accounts => { const owner = accounts[3] const user = accounts[4] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -478,10 +491,11 @@ contract('ForeignBridge', async accounts => { decimalShiftZero ) await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.transferOwnership(foreignBridge.address, { from: owner }) await foreignBridge.onTokenTransfer(user, halfEther, '0x00', { from: owner }).should.be.rejectedWith(ERROR_MSG) await token.transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) }) it('should not allow to burn more than the limit', async () => { @@ -489,12 +503,12 @@ contract('ForeignBridge', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -502,18 +516,20 @@ contract('ForeignBridge', async accounts => { decimalShiftZero ) await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled + + valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.transferOwnership(foreignBridge.address, { from: owner }) await token .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x00', { from: user }) .should.be.rejectedWith(ERROR_MSG) - valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - await token.transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal('1') + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) expect(await token.balanceOf(user)).to.be.bignumber.equal('1') const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) @@ -525,11 +541,11 @@ contract('ForeignBridge', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -537,6 +553,7 @@ contract('ForeignBridge', async accounts => { decimalShiftZero ) await token.mint(user, oneEther.add(toBN(1)), { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.transferOwnership(foreignBridge.address, { from: owner }) @@ -544,17 +561,18 @@ contract('ForeignBridge', async accounts => { .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x00', { from: user }) .should.be.rejectedWith(ERROR_MSG) - oneEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) + const twoEther = oneEther.mul(toBN(2)) + twoEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) oneEther.add(toBN(1)).should.be.bignumber.equal(await token.balanceOf(user)) await token.transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }).should.be.fulfilled - valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) await token.transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal('1') + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) expect(await token.balanceOf(user)).to.be.bignumber.equal('1') await token.transferAndCall(foreignBridge.address, '1', '0x00', { from: user }).should.be.rejectedWith(ERROR_MSG) }) @@ -564,11 +582,11 @@ contract('ForeignBridge', async accounts => { const user = accounts[4] const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -596,11 +614,11 @@ contract('ForeignBridge', async accounts => { let foreignBridge beforeEach(async () => { token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -613,7 +631,9 @@ contract('ForeignBridge', async accounts => { await foreignBridge.setMaxPerTx(halfEther, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) await foreignBridge.setMaxPerTx(halfEther, { from: owner }).should.be.fulfilled - await foreignBridge.setMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit) { + await foreignBridge.setMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } }) it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { @@ -632,6 +652,8 @@ contract('ForeignBridge', async accounts => { const FOREIGN_DAILY_LIMIT = oneEther const FOREIGN_MAX_AMOUNT_PER_TX = halfEther const FOREIGN_MIN_AMOUNT_PER_TX = minPerTx + const TARGET_LIMIT = targetLimit + const THRESHOLD = threshold // Validators Contract let validatorsProxy = await EternalStorageProxy.new().should.be.fulfilled const validatorsContractImpl = await BridgeValidators.new().should.be.fulfilled @@ -646,14 +668,16 @@ contract('ForeignBridge', async accounts => { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) + foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + isRelativeDailyLimit + ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -676,14 +700,18 @@ contract('ForeignBridge', async accounts => { const FOREIGN_DAILY_LIMIT = '3' const FOREIGN_MAX_AMOUNT_PER_TX = '2' const FOREIGN_MIN_AMOUNT_PER_TX = '1' + const TARGET_LIMIT = '1' + const THRESHOLD = '2' const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, tokenAddress, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + isRelativeDailyLimit + ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, ['3', '2', '1'], @@ -692,23 +720,25 @@ contract('ForeignBridge', async accounts => { ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridge.at(storageProxy.address) + const finalContract = await ForeignBridgeContract.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) - expect(await finalContract.dailyLimit()).to.be.bignumber.equal(FOREIGN_DAILY_LIMIT) + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal(FOREIGN_DAILY_LIMIT) + } expect(await finalContract.maxPerTx()).to.be.bignumber.equal(FOREIGN_MAX_AMOUNT_PER_TX) expect(await finalContract.minPerTx()).to.be.bignumber.equal(FOREIGN_MIN_AMOUNT_PER_TX) }) it('can transfer ownership', async () => { const token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled const data = foreignBridge.contract.methods .initialize( validatorContract.address, token.address, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, ['3', '2', '1'], @@ -725,14 +755,14 @@ contract('ForeignBridge', async accounts => { it('can send erc20', async () => { const owner = accounts[0] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -757,14 +787,14 @@ contract('ForeignBridge', async accounts => { it('also calls claimTokens on tokenAddress', async () => { const owner = accounts[0] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -789,14 +819,14 @@ contract('ForeignBridge', async accounts => { it('works with token that not return on transfer', async () => { const owner = accounts[0] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridge.at(storageProxy.address) + const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -831,7 +861,7 @@ contract('ForeignBridge', async accounts => { token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() homeFee = ether('0.001') }) it('sets variables', async () => { @@ -840,15 +870,17 @@ contract('ForeignBridge', async accounts => { expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.isInitialized()).to.be.equal(false) expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) + } await foreignBridge .rewardableInitialize( ZERO_ADDRESS, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -862,7 +894,7 @@ contract('ForeignBridge', async accounts => { .rewardableInitialize( rewardableValidators.address, ZERO_ADDRESS, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -876,7 +908,7 @@ contract('ForeignBridge', async accounts => { .rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, 0, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -890,7 +922,7 @@ contract('ForeignBridge', async accounts => { .rewardableInitialize( owner, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, requireBlockConfirmations, gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -904,7 +936,7 @@ contract('ForeignBridge', async accounts => { .rewardableInitialize( rewardableValidators.address, owner, - [oneEther, halfEther, minPerTx], + limitsArray, requireBlockConfirmations, gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -918,7 +950,7 @@ contract('ForeignBridge', async accounts => { .rewardableInitialize( rewardableValidators.address, owner, - [oneEther, halfEther, minPerTx], + limitsArray, requireBlockConfirmations, gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -931,7 +963,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -948,7 +980,9 @@ contract('ForeignBridge', async accounts => { requireBlockConfirmations.toString() ) expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) + } expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(halfEther) expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') @@ -968,7 +1002,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -993,7 +1027,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1017,7 +1051,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1050,7 +1084,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1074,7 +1108,7 @@ contract('ForeignBridge', async accounts => { feeManager = await FeeManagerNativeToErc.new() token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) rewardableValidators = await RewardableValidators.new() - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() }) it('should distribute fee to validator', async () => { const fee = 0.001 @@ -1092,7 +1126,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1114,14 +1148,14 @@ contract('ForeignBridge', async accounts => { const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - logs[0].event.should.be.equal('FeeDistributedFromSignatures') - logs[0].args.feeAmount.should.be.bignumber.equal(feeAmount) - logs[0].args.transactionHash.should.be.equal(transactionHash) + let event = logs.find(item => item.event === 'FeeDistributedFromSignatures') + event.args.feeAmount.should.be.bignumber.equal(feeAmount) + event.args.transactionHash.should.be.equal(transactionHash) - logs[1].event.should.be.equal('RelayedMessage') - logs[1].args.recipient.should.be.equal(recipientAccount) - logs[1].args.value.should.be.bignumber.equal(value) - logs[1].args.transactionHash.should.be.equal(transactionHash) + event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) const balanceAfter = await token.balanceOf(recipientAccount) const totalSupplyAfter = await token.totalSupply() @@ -1150,7 +1184,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1187,14 +1221,14 @@ contract('ForeignBridge', async accounts => { ).should.be.fulfilled // Then - logs[0].event.should.be.equal('FeeDistributedFromSignatures') - logs[0].args.feeAmount.should.be.bignumber.equal(feeAmount) - logs[0].args.transactionHash.should.be.equal(transactionHash) + let event = logs.find(item => item.event === 'FeeDistributedFromSignatures') + event.args.feeAmount.should.be.bignumber.equal(feeAmount) + event.args.transactionHash.should.be.equal(transactionHash) - logs[1].event.should.be.equal('RelayedMessage') - logs[1].args.recipient.should.be.equal(recipientAccount) - logs[1].args.value.should.be.bignumber.equal(value) - logs[1].args.transactionHash.should.be.equal(transactionHash) + event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) const balanceAfter = await token.balanceOf(recipientAccount) const totalSupplyAfter = await token.totalSupply() @@ -1236,7 +1270,7 @@ contract('ForeignBridge', async accounts => { await foreignBridge.rewardableInitialize( rewardableValidators.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1275,14 +1309,14 @@ contract('ForeignBridge', async accounts => { ).should.be.fulfilled // Then - logs[0].event.should.be.equal('FeeDistributedFromSignatures') - logs[0].args.feeAmount.should.be.bignumber.equal(feeAmount) - logs[0].args.transactionHash.should.be.equal(transactionHash) + let event = logs.find(item => item.event === 'FeeDistributedFromSignatures') + event.args.feeAmount.should.be.bignumber.equal(feeAmount) + event.args.transactionHash.should.be.equal(transactionHash) - logs[1].event.should.be.equal('RelayedMessage') - logs[1].args.recipient.should.be.equal(recipientAccount) - logs[1].args.value.should.be.bignumber.equal(value) - logs[1].args.transactionHash.should.be.equal(transactionHash) + event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) const balanceAfter = await token.balanceOf(recipientAccount) const totalSupplyAfter = await token.totalSupply() @@ -1313,12 +1347,12 @@ contract('ForeignBridge', async accounts => { const erc20Token = await POA20.new('Some ERC20', 'RSZT', 16) const valueOnForeign = toBN('1000') const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, erc20Token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1349,9 +1383,9 @@ contract('ForeignBridge', async accounts => { [vrs.s, vrs2.s, vrs3.s], message ).should.be.fulfilled - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipient) - logs[0].args.value.should.be.bignumber.equal(valueOnHome) + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipient) + event.args.value.should.be.bignumber.equal(valueOnHome) true.should.be.equal(await foreignBridgeWithThreeSigs.relayedMessages(txHash)) const balanceAfterRecipient = await erc20Token.balanceOf(recipient) balanceAfterRecipient.should.be.bignumber.equal(balanceBeforeRecipient.add(valueOnForeign)) @@ -1363,11 +1397,11 @@ contract('ForeignBridge', async accounts => { const user = accounts[4] const value = halfEther token = await POA20.new('POA ERC20 Foundation', 'POA20', 16, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], @@ -1375,6 +1409,7 @@ contract('ForeignBridge', async accounts => { decimalShiftTwo ) await token.mint(user, value, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, value, { from: owner }).should.be.fulfilled expect(await token.balanceOf(user)).to.be.bignumber.equal(value) await token.transferOwnership(foreignBridge.address, { from: owner }) const { logs } = await token.transferAndCall(foreignBridge.address, value, '0x00', { from: user }) @@ -1383,4 +1418,12 @@ contract('ForeignBridge', async accounts => { expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) }) }) +} + +contract('ForeignBridge', async accounts => { + test(accounts, false) +}) + +contract('ForeignBridgeRelativeDailyLimit', async accounts => { + test(accounts, true) }) From 25f95165d35d2ec2e63de3d9645594d6ad1a54ce Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 5 Nov 2019 00:23:02 +0300 Subject: [PATCH 36/80] fix limit update --- .../upgradeable_contracts/BasicHomeBridge.sol | 2 +- .../ForeignAMBErc677ToErc677RelativeDailyLimit.sol | 14 -------------- .../HomeAMBErc677ToErc677RelativeDailyLimit.sol | 9 --------- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 9 +++++++++ .../ForeignBridgeNativeToErcRelativeDailyLimit.sol | 13 ++++++------- .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 4 ++-- 6 files changed, 18 insertions(+), 33 deletions(-) diff --git a/contracts/upgradeable_contracts/BasicHomeBridge.sol b/contracts/upgradeable_contracts/BasicHomeBridge.sol index 5a8844dfa..8b6af4529 100644 --- a/contracts/upgradeable_contracts/BasicHomeBridge.sol +++ b/contracts/upgradeable_contracts/BasicHomeBridge.sol @@ -22,7 +22,7 @@ contract BasicHomeBridge is EternalStorage, Validatable, BasicBridge, BasicToken uint256 NumberOfCollectedSignatures ); - function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) external onlyValidator { + function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { if (withinExecutionLimit(value)) { bytes32 hashMsg = keccak256(abi.encodePacked(recipient, value, transactionHash)); bytes32 hashSender = keccak256(abi.encodePacked(msg.sender, hashMsg)); diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index 2424ef4b7..c9a152b1d 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,20 +4,6 @@ import "./ForeignAMBErc677ToErc677.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { - function relayTokens(uint256 _value) public { - _updateTodayLimit(); - super.relayTokens(_value); - } - - function onTokenTransfer( - address _from, - uint256 _value, - bytes _data - ) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - function handleBridgedTokens( address _recipient, uint256 _value, diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index add1b4cf1..8789903c6 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -18,15 +18,6 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat return super.onTokenTransfer(_from, _value, _data); } - function handleBridgedTokens( - address _recipient, - uint256 _value, - bytes32 _nonce - ) public { - _updateTodayLimit(); - super.handleBridgedTokens(_recipient, _value, _nonce); - } - function initialize( address _bridgeContract, address _mediatorContract, diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index 5778ae925..918364755 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -4,6 +4,15 @@ import "./HomeBridgeErcToErc.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { + function onTokenTransfer( + address _from, + uint256 _value, + bytes _data + ) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + function initialize( address _validatorContract, uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index b62835f57..17e1d1a8a 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -4,14 +4,13 @@ import "./ForeignBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { - function executeSignatures( - uint8[] vs, - bytes32[] rs, - bytes32[] ss, - bytes message - ) public { + function onTokenTransfer( + address _from, + uint256 _value, + bytes _data + ) public returns (bool) { _updateTodayLimit(); - super.executeSignatures(vs, rs, ss, message); + return super.onTokenTransfer(_from, _value, _data); } function initialize( diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index c4ba142cf..d3ee37b05 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -4,9 +4,9 @@ import "./HomeBridgeNativeToErc.sol"; import "../RelativeExecutionDailyLimit.sol"; contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { - function nativeTransfer() internal { + function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { _updateTodayLimit(); - super.nativeTransfer(); + super.executeAffirmation(recipient, value, transactionHash); } function initialize( From d3620fbddce30b81ff73674fe365329878d3b26c Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 5 Nov 2019 14:12:36 +0300 Subject: [PATCH 37/80] update home native_to_erc tests --- test/native_to_erc/home_bridge_test.js | 267 ++++++++++++++++--------- 1 file changed, 171 insertions(+), 96 deletions(-) diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index 26d472670..cac0115d0 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -1,4 +1,5 @@ const HomeBridge = artifacts.require('HomeBridgeNativeToErc.sol') +const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeNativeToErcRelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const RevertFallback = artifacts.require('RevertFallback.sol') @@ -23,8 +24,16 @@ const foreignMaxPerTx = halfEther const foreignMinPerTx = minPerTx const ZERO = toBN(0) const decimalShiftZero = 0 +const targetLimit = ether('0.05') +const threshold = ether('10000') + +function test(accounts, isRelativeDailyLimit) { + const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge + + const executionLimitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx] + : [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx] -contract('HomeBridge', async accounts => { let homeContract let validatorContract let authorities @@ -38,7 +47,7 @@ contract('HomeBridge', async accounts => { describe('#initialize', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() }) it('sets variables', async () => { expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) @@ -53,7 +62,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, '9' ).should.be.fulfilled @@ -77,7 +86,9 @@ contract('HomeBridge', async accounts => { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) + if (!isRelativeDailyLimit) { + expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) + } expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) }) it('cant set maxPerTx > dailyLimit', async () => { @@ -88,7 +99,7 @@ contract('HomeBridge', async accounts => { ['1', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -99,7 +110,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '2'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -113,7 +124,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ).should.be.fulfilled @@ -138,7 +149,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ).should.be.fulfilled @@ -168,7 +179,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], owner, decimalShiftZero ) @@ -176,7 +187,7 @@ contract('HomeBridge', async accounts => { await storageProxy.upgradeTo('1', accounts[5]).should.be.rejectedWith(ERROR_MSG) await storageProxy.upgradeToAndCall('1', accounts[5], data).should.be.rejectedWith(ERROR_MSG) await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridge.at(storageProxy.address) + const finalContract = await HomeBridgeContract.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) @@ -192,7 +203,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, 0, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -203,7 +214,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -214,7 +225,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -224,7 +235,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ).should.be.fulfilled @@ -237,7 +248,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ).should.be.fulfilled @@ -263,7 +274,7 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], owner, decimalShiftZero ) @@ -277,13 +288,13 @@ contract('HomeBridge', async accounts => { describe('#fallback', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -368,13 +379,13 @@ contract('HomeBridge', async accounts => { describe('#setting limits', async () => { let homeContract beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -409,13 +420,13 @@ contract('HomeBridge', async accounts => { describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() await homeBridge.initialize( validatorContract.address, [twoEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -427,6 +438,8 @@ contract('HomeBridge', async accounts => { it('should allow validator to executeAffirmation', async () => { const recipient = accounts[5] const value = halfEther + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }) + const balanceBefore = toBN(await web3.eth.getBalance(recipient)) const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { @@ -445,7 +458,7 @@ contract('HomeBridge', async accounts => { const homeBalanceAfter = toBN(await web3.eth.getBalance(homeBridge.address)) const balanceAfter = toBN(await web3.eth.getBalance(recipient)) balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - homeBalanceAfter.should.be.bignumber.equal(ZERO) + homeBalanceAfter.should.be.bignumber.equal(halfEther) const msgHash = web3.utils.soliditySha3(recipient, value, transactionHash) const senderHash = web3.utils.soliditySha3(authorities[0], msgHash) @@ -484,23 +497,23 @@ contract('HomeBridge', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, - [twoEther, halfEther, minPerTx], + [twoEther, ether('1.5'), minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) await homeBridgeWithTwoSigs.sendTransaction({ from: accounts[2], - value: halfEther + value: ether('1.5') }).should.be.fulfilled const homeBalanceBefore = toBN(await web3.eth.getBalance(homeBridgeWithTwoSigs.address)) - homeBalanceBefore.should.be.bignumber.equal(halfEther) + homeBalanceBefore.should.be.bignumber.equal(ether('1.5')) const recipient = accounts[5] const value = halfEther @@ -513,7 +526,7 @@ contract('HomeBridge', async accounts => { }).should.be.fulfilled expectEventInLogs(logs, 'SignedForAffirmation', { signer: authorities[0], transactionHash }) - halfEther.should.be.bignumber.equal(await web3.eth.getBalance(homeBridgeWithTwoSigs.address)) + ether('1.5').should.be.bignumber.equal(await web3.eth.getBalance(homeBridgeWithTwoSigs.address)) const notProcessed = await homeBridgeWithTwoSigs.numAffirmationsSigned(msgHash) notProcessed.should.be.bignumber.equal('1') @@ -526,7 +539,7 @@ contract('HomeBridge', async accounts => { const balanceAfter = toBN(await web3.eth.getBalance(recipient)) balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - expect(toBN(await web3.eth.getBalance(homeBridgeWithTwoSigs.address))).to.be.bignumber.equal(ZERO) + expect(toBN(await web3.eth.getBalance(homeBridgeWithTwoSigs.address))).to.be.bignumber.equal(oneEther) expectEventInLogs(secondSignature.logs, 'AffirmationCompleted', { recipient, @@ -572,13 +585,13 @@ contract('HomeBridge', async accounts => { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridge.new() + const homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -620,6 +633,8 @@ contract('HomeBridge', async accounts => { await revertFallbackContract.receiveEth({ from: accounts[0], value: halfEther }) expect(toBN(await web3.eth.getBalance(revertFallbackContract.address))).to.be.bignumber.equal(halfEther) + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }) + const transactionHash = '0x106335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' const { logs } = await homeBridge.executeAffirmation(revertFallbackContract.address, halfEther, transactionHash, { from: authorities[0] @@ -637,7 +652,7 @@ contract('HomeBridge', async accounts => { const homeBalanceAfter = toBN(await web3.eth.getBalance(homeBridge.address)) const balanceAfter = toBN(await web3.eth.getBalance(revertFallbackContract.address)) balanceAfter.should.be.bignumber.equal(halfEther.add(halfEther)) - homeBalanceAfter.should.be.bignumber.equal(ZERO) + homeBalanceAfter.should.be.bignumber.equal(halfEther) }) it('works with 5 validators and 3 required signatures', async () => { const recipient = accounts[8] @@ -646,13 +661,13 @@ contract('HomeBridge', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -660,6 +675,10 @@ contract('HomeBridge', async accounts => { const value = halfEther const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + await homeBridgeWithThreeSigs.sendTransaction({ + from: recipient, + value: halfEther + }).should.be.fulfilled await homeBridgeWithThreeSigs.sendTransaction({ from: recipient, value: halfEther @@ -740,7 +759,7 @@ contract('HomeBridge', async accounts => { describe('#isAlreadyProcessed', async () => { it('returns ', async () => { - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const bn = toBN(2).pow(toBN(255)) const processedNumbers = [bn.add(toBN(1)).toString(10), bn.add(toBN(100)).toString(10)] true.should.be.equal(await homeBridge.isAlreadyProcessed(processedNumbers[0])) @@ -759,13 +778,13 @@ contract('HomeBridge', async accounts => { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridge.new() + homeBridgeWithTwoSigs = await HomeBridgeContract.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -819,13 +838,13 @@ contract('HomeBridge', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -911,7 +930,7 @@ contract('HomeBridge', async accounts => { describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() }) it('should return the required message length', async () => { @@ -928,13 +947,13 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], owner, decimalShiftZero ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) const token = await ERC677BridgeToken.new('Test', 'TST', 18) @@ -957,13 +976,13 @@ contract('HomeBridge', async accounts => { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - ['3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], owner, decimalShiftZero ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) const tokenMock = await NoReturnTransferTokenMock.new() @@ -986,13 +1005,15 @@ contract('HomeBridge', async accounts => { [oneEther.toString(), halfEther.toString(), '1'], gasPrice, requireBlockConfirmations, - [oneEther.toString(), halfEther.toString(), '1'], + isRelativeDailyLimit + ? [targetLimit.toString(), threshold.toString(), halfEther.toString(), '1'] + : [oneEther.toString(), halfEther.toString(), '1'], owner, decimalShiftZero ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridge.at(storageProxy.address) + const homeBridge = await HomeBridgeContract.at(storageProxy.address) const balanceBefore = toBN(await web3.eth.getBalance(accounts[3])) @@ -1016,7 +1037,7 @@ contract('HomeBridge', async accounts => { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - homeBridge = await HomeBridge.new() + homeBridge = await HomeBridgeContract.new() homeFee = ZERO foreignFee = ether('0.002') }) @@ -1034,7 +1055,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1047,7 +1068,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], 0, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1060,7 +1081,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, 0, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1073,7 +1094,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, ZERO_ADDRESS, [homeFee, foreignFee], @@ -1085,7 +1106,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1119,7 +1140,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1144,7 +1165,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1168,7 +1189,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1199,7 +1220,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1221,7 +1242,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [homeFee, foreignFee], @@ -1243,7 +1264,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1261,7 +1282,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1291,7 +1312,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1311,7 +1332,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1349,7 +1370,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1371,7 +1392,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1381,6 +1402,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = accounts[5] const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -1433,7 +1458,7 @@ contract('HomeBridge', async accounts => { const feeAmountCalc = 0.5 * fee const feeAmount = ether(feeAmountCalc.toString()) - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const feeManager = await FeeManagerNativeToErc.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -1443,7 +1468,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1453,6 +1478,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = accounts[8] const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -1472,7 +1501,11 @@ contract('HomeBridge', async accounts => { }).should.be.fulfilled // Then - logsValidator1.length.should.be.equals(1) + if (isRelativeDailyLimit) { + logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet + } else { + logsValidator1.length.should.be.equals(1) + } expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[1], @@ -1509,7 +1542,7 @@ contract('HomeBridge', async accounts => { ).to.equal(true) const homeBridgeBalance = toBN(await web3.eth.getBalance(homeBridge.address)) - homeBridgeBalance.should.be.bignumber.equal(ZERO) + homeBridgeBalance.should.be.bignumber.equal(halfEther) }) it('should distribute fee to 5 validators', async () => { // Given @@ -1528,7 +1561,7 @@ contract('HomeBridge', async accounts => { const feePerValidator = feeAmount.div(toBN(5)) const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const feeManager = await FeeManagerNativeToErc.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -1538,7 +1571,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1548,6 +1581,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -1578,7 +1615,11 @@ contract('HomeBridge', async accounts => { }).should.be.fulfilled // Then - logsValidator1.length.should.be.equals(1) + if (isRelativeDailyLimit) { + logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet + } else { + logsValidator1.length.should.be.equals(1) + } expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[4], @@ -1620,7 +1661,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1637,7 +1678,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -1669,7 +1710,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1692,7 +1733,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -1732,7 +1773,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1744,7 +1785,6 @@ contract('HomeBridge', async accounts => { const feeInWei = ether(fee.toString()) const feePerValidator = toBN(166666666666666) const feePerValidatorPlusDiff = toBN(166666666666668) - const initialValue = halfEther const valueCalc = 0.5 * (1 - fee) const value = ether(valueCalc.toString()) const feeAmountCalc = 0.5 * fee @@ -1755,7 +1795,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -1764,7 +1804,11 @@ contract('HomeBridge', async accounts => { await homeBridge.sendTransaction({ from: user, - value: initialValue + value: halfEther + }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: user, + value: halfEther }).should.be.fulfilled const initialBalanceRewardAddress1 = toBN(await web3.eth.getBalance(rewards[0])) @@ -1817,7 +1861,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1827,7 +1871,6 @@ contract('HomeBridge', async accounts => { // 0.1% fee const fee = 0.001 const feeInWei = ether(fee.toString()) - const initialValue = halfEther const valueCalc = 0.5 * (1 - fee) const value = ether(valueCalc.toString()) const feeAmountCalc = 0.5 * fee @@ -1839,7 +1882,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -1848,7 +1891,11 @@ contract('HomeBridge', async accounts => { await homeBridge.sendTransaction({ from: user, - value: initialValue + value: halfEther + }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: user, + value: halfEther }).should.be.fulfilled const initialBalanceRewardAddress1 = toBN(await web3.eth.getBalance(rewards[0])) @@ -1904,7 +1951,7 @@ contract('HomeBridge', async accounts => { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1925,7 +1972,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -1935,6 +1982,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = accounts[5] const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -1986,7 +2037,7 @@ contract('HomeBridge', async accounts => { const feeAmountCalc = 0.5 * fee const feeAmount = ether(feeAmountCalc.toString()) - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const feeManager = await FeeManagerNativeToErcBothDirections.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -1996,7 +2047,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -2006,6 +2057,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = accounts[8] const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -2025,7 +2080,11 @@ contract('HomeBridge', async accounts => { }).should.be.fulfilled // Then - logsValidator1.length.should.be.equals(1) + if (isRelativeDailyLimit) { + logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet + } else { + logsValidator1.length.should.be.equals(1) + } expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[1], @@ -2062,7 +2121,7 @@ contract('HomeBridge', async accounts => { ).to.equal(true) const homeBridgeBalance = toBN(await web3.eth.getBalance(homeBridge.address)) - homeBridgeBalance.should.be.bignumber.equal('0') + homeBridgeBalance.should.be.bignumber.equal(halfEther) }) it('should distribute fee to 5 validators', async () => { // Given @@ -2080,7 +2139,7 @@ contract('HomeBridge', async accounts => { const feePerValidator = feeAmount.div(toBN(5)) const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() const feeManager = await FeeManagerNativeToErcBothDirections.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -2090,7 +2149,7 @@ contract('HomeBridge', async accounts => { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -2100,6 +2159,10 @@ contract('HomeBridge', async accounts => { from: accounts[0], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' const balanceBefore = toBN(await web3.eth.getBalance(recipient)) @@ -2130,7 +2193,11 @@ contract('HomeBridge', async accounts => { }).should.be.fulfilled // Then - logsValidator1.length.should.be.equals(1) + if (isRelativeDailyLimit) { + logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet + } else { + logsValidator1.length.should.be.equals(1) + } expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[4], @@ -2171,13 +2238,13 @@ contract('HomeBridge', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridge.new() + const homeBridgeWithThreeSigs = await HomeBridgeContract.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftTwo ) @@ -2221,13 +2288,13 @@ contract('HomeBridge', async accounts => { balanceAfterRecipient.should.be.bignumber.equal(balanceBeforeRecipient.add(valueOnHome)) }) it('Foreign to Home: test decimal shift 2, no impact on UserRequestForSignature value', async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + executionLimitsArray, owner, decimalShiftTwo ) @@ -2258,4 +2325,12 @@ contract('HomeBridge', async accounts => { expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') }) }) +} + +contract('HomeBridge', async accounts => { + test(accounts, false) +}) + +contract('HomeBridgeRelativeDailyLimit', async accounts => { + test(accounts, true) }) From 26046a162fb073dffb054c61d9c903af0bdd14c4 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 5 Nov 2019 17:41:44 +0300 Subject: [PATCH 38/80] add a multiplier to the daily limit calculation --- contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol index 07c66b2bb..86e9da4bd 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -21,15 +21,16 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { } uint256 limit = targetLimit(); uint256 thresh = threshold(); + uint256 multiplier = 1 ether ** 2; if (balance > unlimitedBalance && balance < thresh) { // to save the gas we don't need to use safe math here // because we check in setters that limit is always less than 1 ether // and threshold is greater than minPerTx // and minPerTx is less than threshold - uint256 a = (1 ether - limit) / (thresh - unlimitedBalance)**2; + uint256 a = ((1 ether - limit) * multiplier) / (thresh - unlimitedBalance)**2; uint256 b = 2 * a * thresh; - uint256 c = limit + a * thresh**2; - limit = a * balance**2 - b * balance + c; + uint256 c = (limit * multiplier) + a * thresh**2; + limit = (a * balance**2 - b * balance + c) / multiplier; } return (balance * limit) / 1 ether; } From 2bb04fc469ef3e039a1cf53653b360b1fea45dc6 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 5 Nov 2019 19:33:37 +0300 Subject: [PATCH 39/80] fix contracts after merge --- ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 4 +-- ...BridgeErc677ToErc677RelativeDailyLimit.sol | 20 +++++------ ...oreignBridgeErcToErcRelativeDailyLimit.sol | 30 ++++++++++------ ...ignBridgeErcToNativeRelativeDailyLimit.sol | 35 ++++++++++++------- ...omeBridgeErcToNativeRelativeDailyLimit.sol | 4 +-- ...ignBridgeNativeToErcRelativeDailyLimit.sol | 12 ++++--- 6 files changed, 62 insertions(+), 43 deletions(-) diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index 8789903c6..788cf106e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,9 +4,9 @@ import "./HomeAMBErc677ToErc677.sol"; import "../RelativeDailyLimit.sol"; contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, RelativeDailyLimit { - function relayTokens(uint256 _value) public { + function _relayTokens(address _from, address _receiver, uint256 _value) internal { _updateTodayLimit(); - super.relayTokens(_value); + super._relayTokens(_from, _receiver, _value); } function onTokenTransfer( diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol index 09b9d2b55..34cc43e59 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol @@ -18,11 +18,6 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is address _owner, uint256 _decimalShift ) external returns (bool) { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); require( _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx @@ -30,17 +25,20 @@ contract ForeignBridgeErc677ToErc677RelativeDailyLimit is _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; uintStorage[THRESHOLD] = _executionLimitsArray[1]; uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); - - emit DailyLimitChanged(_requestLimitsArray[0]); + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _requestLimitsArray, + _owner, + _decimalShift + ); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol index 99aa7fb67..7a93b95ab 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol @@ -13,24 +13,32 @@ contract ForeignBridgeErcToErcRelativeDailyLimit is address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _limitsArray, // [ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { require( - _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[2] >= _limitsArray[4] && // _threshold >= _homeMinPerTx - _limitsArray[1] <= 1 ether // _targetLimit <= 1 ether + _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); - uintStorage[MAX_PER_TX] = _limitsArray[0]; - uintStorage[TARGET_LIMIT] = _limitsArray[1]; - uintStorage[THRESHOLD] = _limitsArray[2]; - uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; - uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _requestLimitsArray, + _owner, + _decimalShift + ); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index 8da1d7d23..ad38b1eb7 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -19,25 +19,34 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _limitsArray, //[ 0 = _maxPerTx, 1 = _targetLimit, 2 = _threshold, 3 = _homeMaxPerTx, 4 = _homeMinPerTx ] + uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _executionLimitsArray, //[ 0 = _targetLimit, 1 = _threshold, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _bridgeOnOtherSide ) external returns (bool) { require( - _limitsArray[4] > 0 && // _homeMinPerTx > 0 - _limitsArray[3] > _limitsArray[4] && // _homeMaxPerTx > _homeMinPerTx - _limitsArray[2] >= _limitsArray[4] && // _threshold >= _homeMinPerTx - _limitsArray[1] <= 1 ether // _targetLimit <= 1 ether + _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether ); - uintStorage[MAX_PER_TX] = _limitsArray[0]; - uintStorage[TARGET_LIMIT] = _limitsArray[1]; - uintStorage[THRESHOLD] = _limitsArray[2]; - uintStorage[EXECUTION_MAX_PER_TX] = _limitsArray[3]; - uintStorage[EXECUTION_MIN_PER_TX] = _limitsArray[4]; + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - return - _initialize(_validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, _owner, _decimalShift); + return _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _requestLimitsArray, + _owner, + _decimalShift, + _bridgeOnOtherSide + ); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol index 044d1b3a6..c1bc4c4c2 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol @@ -5,9 +5,9 @@ import "./HomeBridgeErcToNative.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { - function nativeTransfer() internal { + function nativeTransfer(address _receiver) internal { _updateTodayLimit(); - super.nativeTransfer(); + super.nativeTransfer(_receiver); } function initialize( diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index 17e1d1a8a..17238e97c 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -21,7 +21,8 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, uint256 _requiredBlockConfirmations, uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _bridgeOnOtherSide ) external returns (bool) { _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( @@ -30,7 +31,8 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, _foreignGasPrice, _requiredBlockConfirmations, _owner, - _decimalShift + _decimalShift, + _bridgeOnOtherSide ); setInitialize(); return isInitialized(); @@ -46,7 +48,8 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, address _owner, address _feeManager, uint256 _homeFee, - uint256 _decimalShift + uint256 _decimalShift, + address _bridgeOnOtherSide ) external returns (bool) { _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( @@ -55,7 +58,8 @@ contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, _foreignGasPrice, _requiredBlockConfirmations, _owner, - _decimalShift + _decimalShift, + _bridgeOnOtherSide ); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; From a744087e7a0d44fce83c8e4fa43854508a1c4e5e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 6 Nov 2019 00:27:01 +0300 Subject: [PATCH 40/80] fix tests after merge --- .../AMBErc677ToErc677Behavior.test.js | 5 +- test/amb_erc677_to_erc677/home_bridge.test.js | 2 +- test/erc_to_erc/foreign_bridge.test.js | 33 ++-------- test/erc_to_erc/home_bridge.test.js | 5 +- test/erc_to_native/foreign_bridge.test.js | 8 ++- test/erc_to_native/home_bridge.test.js | 60 ++++++++++++------- test/native_to_erc/foreign_bridge_test.js | 20 ++++--- test/native_to_erc/home_bridge_test.js | 16 ++--- 8 files changed, 73 insertions(+), 76 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index fd36a3b1e..37422bdca 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -876,16 +876,15 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { describe('fixFailedMessage', () => { let dataHash - let contract beforeEach(async function() { + contract = this.bridge + bridgeContract = await AMBMock.new() await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - contract = this.bridge - await initialize(erc677Token.address) await erc677Token.transferOwnership(contract.address) diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index 13368619e..81aa5710a 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -118,7 +118,7 @@ function test(accounts, isRelativeDailyLimit) { // When await erc677Token - .transferAndCall(homeBridge.address, oneEther, '0x', { from: user }) + .transferAndCall(homeBridge.address, oneEther, '0x00', { from: user }) .should.be.rejectedWith(ERROR_MSG) const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, user2, { from: user }).should.be .fulfilled diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index 0346e19cb..d6f2040c3 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -134,31 +134,6 @@ function test(accounts, isRelativeDailyLimit) { ) .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - const { logs } = await foreignBridge.initialize( validatorContract.address, token.address, @@ -714,14 +689,14 @@ function test(accounts, isRelativeDailyLimit) { const user = accounts[4] const user2 = accounts[5] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, - [dailyLimit, maxPerTx, minPerTx], - [homeDailyLimit, homeMaxPerTx], + requestLimitsArray, + executionLimitsArray, owner, decimalShiftZero ) @@ -876,7 +851,7 @@ function test(accounts, isRelativeDailyLimit) { const recipient = accounts[8] let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index c8ee54479..fd582b58d 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -1532,15 +1532,16 @@ function test(accounts, isRelativeDailyLimit) { const user2 = accounts[5] await homeBridge.initialize( validatorContract.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, token.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled const value = halfEther + await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.mint(user, value, { from: owner }).should.be.fulfilled // When diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index c0a427a0e..ba7171b6e 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -174,7 +174,9 @@ function test(accounts, isRelativeDailyLimit) { expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(dailyLimit) expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(maxPerTx) expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) - expect(await foreignBridge.executionDailyLimit()).to.be.bignumber.equal(homeDailyLimit) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.executionDailyLimit()).to.be.bignumber.equal(homeDailyLimit) + } expect(await foreignBridge.executionMaxPerTx()).to.be.bignumber.equal(homeMaxPerTx) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) @@ -670,7 +672,7 @@ function test(accounts, isRelativeDailyLimit) { const recipient = accounts[8] let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -859,7 +861,7 @@ function test(accounts, isRelativeDailyLimit) { let dai let migrationContract beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeContract.new() sai = await ERC20Mock.new('sai', 'SAI', 18) dai = await ERC20Mock.new('dai', 'DAI', 18) const daiAdapterMock = await DaiAdapterMock.new(dai.address) diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index 3ea1501dd..ec2155bf3 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -777,14 +777,14 @@ function test(accounts, isRelativeDailyLimit) { describe('#relayTokens', () => { const recipient = accounts[7] beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, - ['3', '2', '1'], + isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ) @@ -825,6 +825,17 @@ function test(accounts, isRelativeDailyLimit) { homeContractBalance.should.be.bignumber.equal(ZERO) }) it('doesnt let you send more than daily limit', async () => { + homeContract = await HomeBridgeContract.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ) await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) const currentDay = await homeContract.getCurrentDay() @@ -840,13 +851,15 @@ function test(accounts, isRelativeDailyLimit) { await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + } }) it('doesnt let you send more than max amount per tx', async () => { - await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) await homeContract.relayTokens(recipient, { from: accounts[1], @@ -858,8 +871,10 @@ function test(accounts, isRelativeDailyLimit) { value: 3 }) .should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + } await homeContract.setMaxPerTx(99).should.be.fulfilled // meets max per tx and daily limit await homeContract.relayTokens(recipient, { @@ -881,7 +896,9 @@ function test(accounts, isRelativeDailyLimit) { await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) - await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + } await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled @@ -896,7 +913,8 @@ function test(accounts, isRelativeDailyLimit) { await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - await blockRewardContract.addMintedTotallyByBridge(2, homeContract.address) + const amountToMint = isRelativeDailyLimit ? '3' : '2' + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled @@ -907,7 +925,7 @@ function test(accounts, isRelativeDailyLimit) { const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) const burnt = await homeContract.totalBurntCoins() - minted.should.be.bignumber.equal('2') + minted.should.be.bignumber.equal(amountToMint) burnt.should.be.bignumber.equal('2') }) }) @@ -2206,17 +2224,17 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled @@ -2895,17 +2913,17 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridge.new() + const homeBridgeImpl = await HomeBridgeContract.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridge.at(storageProxy.address) + homeBridge = await HomeBridgeContract.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx], + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, decimalShiftZero ).should.be.fulfilled diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index 3ef8f641e..775f8db0f 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -533,20 +533,21 @@ function test(accounts, isRelativeDailyLimit) { otherSideBridgeAddress ) await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled - valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.transferOwnership(foreignBridge.address, { from: owner }) await token .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) .should.be.rejectedWith(ERROR_MSG) - valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) @@ -634,19 +635,20 @@ function test(accounts, isRelativeDailyLimit) { const user = accounts[4] const user2 = accounts[5] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridge.new() + const foreignBridge = await ForeignBridgeContract.new() await foreignBridge.initialize( validatorContract.address, token.address, - [oneEther, halfEther, minPerTx], + limitsArray, gasPrice, requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx], + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, otherSideBridgeAddress ) await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled await token.transferOwnership(foreignBridge.address, { from: owner }) await token .transferAndCall(foreignBridge.address, halfEther, otherSideBridgeAddress, { from: user }) @@ -655,7 +657,7 @@ function test(accounts, isRelativeDailyLimit) { .transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }) .should.be.rejectedWith(ERROR_MSG) await token.transferAndCall(foreignBridge.address, halfEther, user2, { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) expect(events[0].returnValues.recipient).to.be.equal(user2) @@ -1496,10 +1498,10 @@ function test(accounts, isRelativeDailyLimit) { }) } -contract('ForeignBridge', async accounts => { +contract('ForeignBridge_Native_to_ERC', async accounts => { test(accounts, false) }) -contract('ForeignBridgeRelativeDailyLimit', async accounts => { +contract('ForeignBridge_Native_to_ERC_RelativeDailyLimit', async accounts => { test(accounts, true) }) diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index 6243a03a9..20a23187a 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -380,13 +380,13 @@ function test(accounts, isRelativeDailyLimit) { const user = accounts[1] const user2 = accounts[2] beforeEach(async () => { - homeContract = await HomeBridge.new() + homeContract = await HomeBridgeContract.new() await homeContract.initialize( validatorContract.address, ['3', '2', '1'], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + executionLimitsArray, owner, decimalShiftZero ) @@ -1405,7 +1405,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1423,7 +1423,7 @@ function test(accounts, isRelativeDailyLimit) { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + executionLimitsArray, owner, feeManager.address, [notUsedFee, feeInWei], @@ -1852,7 +1852,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridge.new() + const homeBridge = await HomeBridgeContract.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1869,7 +1869,7 @@ function test(accounts, isRelativeDailyLimit) { [oneEther, halfEther, minPerTx], gasPrice, requireBlockConfirmations, - [foreignDailyLimit, foreignMaxPerTx], + executionLimitsArray, owner, feeManager.address, [feeInWei, feeInWei], @@ -2518,10 +2518,10 @@ function test(accounts, isRelativeDailyLimit) { }) } -contract('HomeBridge', async accounts => { +contract('HomeBridge_Native_to_ERC', async accounts => { test(accounts, false) }) -contract('HomeBridgeRelativeDailyLimit', async accounts => { +contract('HomeBridge_Native_to_ERC_RelativeDailyLimit', async accounts => { test(accounts, true) }) From 0f1ae3f58dccf898791360563f46de4e2ce999f8 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 6 Nov 2019 19:16:39 +0300 Subject: [PATCH 41/80] add tests for relative daily limit calculation --- .../AMBErc677ToErc677Behavior.test.js | 148 +++++++++++++++++- test/erc_to_erc/foreign_bridge.test.js | 89 ++++++++++- test/erc_to_erc/home_bridge.test.js | 84 +++++++++- test/erc_to_native/foreign_bridge.test.js | 90 ++++++++++- test/erc_to_native/home_bridge.test.js | 66 +++++++- test/helpers/helpers.js | 19 ++- test/native_to_erc/foreign_bridge_test.js | 80 +++++++++- test/native_to_erc/home_bridge_test.js | 66 +++++++- 8 files changed, 632 insertions(+), 10 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 37422bdca..2ec6ffac9 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -4,7 +4,7 @@ const AMBMock = artifacts.require('AMBMock.sol') const { expect } = require('chai') const { ZERO_ADDRESS, toBN, ERROR_MSG } = require('../setup') -const { getEvents, expectEventInLogs, ether, strip0x } = require('../helpers/helpers') +const { getEvents, expectEventInLogs, ether, strip0x, calculateDailyLimit } = require('../helpers/helpers') const ZERO = toBN(0) const oneEther = ether('1') @@ -1017,6 +1017,152 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) }) }) + if (isRelativeDailyLimit) { + // eslint-disable-next-line + function initialize(customLimits) { + return contract.initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? customLimits : limitsArray, + isRelativeDailyLimitOnBridgeSide ? executionLimitsArray : customLimits, + maxGasPerTx, + decimalShiftZero, + owner + ).should.be.fulfilled + } + if (isRelativeDailyLimitOnBridgeSide) { + describe('#dailyLimit (relative)', () => { + beforeEach(async function() { + contract = this.bridge + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + }) + it('should be calculated correctly - 1', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) + + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(minPerTx) + + const limit = await contract.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, threshold).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(threshold) + + const limit = await contract.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') + + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(accounts[0], amountToMint).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(amountToMint) + + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } else { + describe('#executionDailyLimit (relative)', () => { + beforeEach(async function() { + contract = this.bridge + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + }) + it('should be calculated correctly - 1', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await contract.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) + + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(minPerTx) + + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, threshold).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(threshold) + + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') + + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await erc677Token.mint(contract.address, amountToMint).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(amountToMint) + + const limit = await contract.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } + } } module.exports = { diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index d6f2040c3..29031907c 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -11,7 +11,15 @@ const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, signatureToVRS, ether, getEvents, expectEventInLogs } = require('../helpers/helpers') +const { + createMessage, + sign, + signatureToVRS, + ether, + getEvents, + expectEventInLogs, + calculateDailyLimit +} = require('../helpers/helpers') const oneEther = ether('1') const halfEther = ether('0.5') @@ -1002,6 +1010,85 @@ function test(accounts, isRelativeDailyLimit) { }) }) }) + if (isRelativeDailyLimit) { + describe('#executionDailyLimit (relative)', () => { + let token + let foreignBridge + + function initialize(customExecutionLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + customExecutionLimitsArray, + owner, + decimalShiftZero + ).should.be.fulfilled + } + + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + foreignBridge = await ForeignBridgeContract.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') + + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) + + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('ForeignBridge_ERC20_to_ERC20', async accounts => { diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index fd582b58d..c17ba0bfd 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -13,14 +13,15 @@ const OldBlockReward = artifacts.require('OldBlockReward') const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, getEvents, ether, expectEventInLogs } = require('../helpers/helpers') +const { createMessage, sign, getEvents, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') -const minPerTx = ether('0.01') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const quarterEther = ether('0.25') const oneEther = ether('1') const halfEther = ether('0.5') +const minPerTx = ether('0.01') +const maxPerTx = halfEther const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther const foreignMinPerTx = minPerTx @@ -2088,6 +2089,85 @@ function test(accounts, isRelativeDailyLimit) { expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(value) }) }) + if (isRelativeDailyLimit) { + describe('#dailyLimit (relative)', () => { + let token + let homeBridge + + function initialize(customLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ).should.be.fulfilled + } + + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + homeBridge = await HomeBridgeContract.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(homeBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await token.mint(homeBridge.address, minPerTx).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(minPerTx) + + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await token.mint(homeBridge.address, threshold).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(threshold) + + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') + + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await token.mint(accounts[0], amountToMint).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) + + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('HomeBridge_ERC20_to_ERC20', async accounts => { diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index ba7171b6e..7ceb782e7 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -10,7 +10,15 @@ const DaiAdapterMock = artifacts.require('DaiAdapterMock.sol') const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, signatureToVRS, ether, expectEventInLogs, getEvents } = require('../helpers/helpers') +const { + createMessage, + sign, + signatureToVRS, + ether, + expectEventInLogs, + getEvents, + calculateDailyLimit +} = require('../helpers/helpers') const quarterEther = ether('0.25') const halfEther = ether('0.5') @@ -922,6 +930,86 @@ function test(accounts, isRelativeDailyLimit) { expect(transferEvent[0].returnValues.value).to.be.equal(oneEther.toString()) }) }) + if (isRelativeDailyLimit) { + describe('#executionDailyLimit (relative)', () => { + let token + let foreignBridge + + function initialize(customExecutionLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + customExecutionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address + ).should.be.fulfilled + } + + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + foreignBridge = await ForeignBridgeContract.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) + + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') + + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) + + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('ForeignBridge_ERC20_to_Native', async accounts => { diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index ec2155bf3..98783ec36 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -11,14 +11,15 @@ const FeeManagerMock = artifacts.require('FeeManagerMock') const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, ether, expectEventInLogs } = require('../helpers/helpers') +const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') -const minPerTx = ether('0.01') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const quarterEther = ether('0.25') const oneEther = ether('1') const halfEther = ether('0.5') +const minPerTx = ether('0.01') +const maxPerTx = halfEther const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther const foreignMinPerTx = quarterEther @@ -3370,6 +3371,67 @@ function test(accounts, isRelativeDailyLimit) { logsSubmitSignature[1].event.should.be.equal('CollectedSignatures') }) }) + if (isRelativeDailyLimit) { + describe('#dailyLimit (relative)', () => { + let homeBridge + + function initialize(customLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero + ).should.be.fulfilled + } + + beforeEach(async () => { + homeBridge = await HomeBridgeContract.new() + }) + it('should be calculated correctly - 1', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await blockRewardContract.addMintedTotallyByBridge(halfEther, homeBridge.address) + + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await blockRewardContract.addMintedTotallyByBridge(minPerTx, homeBridge.address) + + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await blockRewardContract.addMintedTotallyByBridge(threshold, homeBridge.address) + + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') + + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeBridge.address) + + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('HomeBridge_ERC20_to_Native', async accounts => { diff --git a/test/helpers/helpers.js b/test/helpers/helpers.js index c66c07c6e..c495b8666 100644 --- a/test/helpers/helpers.js +++ b/test/helpers/helpers.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const { BN } = require('../setup') +const { BN, toBN } = require('../setup') // returns a Promise that resolves with a hex string that is the signature of // `data` signed with the key of `address` @@ -203,3 +203,20 @@ function addTxHashToAMBData(encodedData, transactionHash) { } module.exports.addTxHashToAMBData = addTxHashToAMBData + +function calculateDailyLimit(balance, targetLimit, threshold, minPerTx) { + if (balance.lte(minPerTx)) { + return balance + } + let limit = targetLimit + const multiplier = ether('1').pow(toBN(2)) + if (balance.gt(minPerTx) && balance.lt(threshold)) { + const a = ether('1').sub(limit).mul(multiplier).div(threshold.sub(minPerTx).pow(toBN(2))) // eslint-disable-line + const b = a.mul(threshold).mul(toBN(2)) + const c = limit.mul(multiplier).add(a.mul(threshold.pow(toBN(2)))) + limit = a.mul(balance.pow(toBN(2))).sub(b.mul(balance)).add(c).div(multiplier) // eslint-disable-line + } + return balance.mul(limit).div(ether('1')) +} + +module.exports.calculateDailyLimit = calculateDailyLimit diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index 775f8db0f..ba32df858 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -11,7 +11,15 @@ const NoReturnTransferTokenMock = artifacts.require('NoReturnTransferTokenMock.s const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, signatureToVRS, getEvents, ether, expectEventInLogs } = require('../helpers/helpers') +const { + createMessage, + sign, + signatureToVRS, + getEvents, + ether, + expectEventInLogs, + calculateDailyLimit +} = require('../helpers/helpers') const oneEther = ether('1') const halfEther = ether('0.5') @@ -1496,6 +1504,76 @@ function test(accounts, isRelativeDailyLimit) { expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) }) }) + if (isRelativeDailyLimit) { + describe('#dailyLimit (relative)', () => { + let token + let foreignBridge + + function initialize(customLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress + ).should.be.fulfilled + } + + beforeEach(async () => { + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + foreignBridge = await ForeignBridgeContract.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + + const limit = await foreignBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(homeMinPerTx) + + const limit = await foreignBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(threshold) + + const limit = await foreignBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') + + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) + + const limit = await foreignBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('ForeignBridge_Native_to_ERC', async accounts => { diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index 20a23187a..51cefbefe 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -11,7 +11,7 @@ const NoReturnTransferTokenMock = artifacts.require('NoReturnTransferTokenMock.s const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, ether, expectEventInLogs } = require('../helpers/helpers') +const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') const minPerTx = ether('0.01') const requireBlockConfirmations = 8 @@ -2516,6 +2516,70 @@ function test(accounts, isRelativeDailyLimit) { expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') }) }) + if (isRelativeDailyLimit) { + describe('#executionDailyLimit (relative)', () => { + let homeBridge + + function initialize(customExecutionLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + [threshold.add(toBN(1)), threshold, minPerTx], + gasPrice, + requireBlockConfirmations, + customExecutionLimitsArray, + owner, + decimalShiftZero + ).should.be.fulfilled + } + + beforeEach(async () => { + homeBridge = await HomeBridgeContract.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + + await homeBridge.sendTransaction({ from: accounts[4], value: halfEther }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(halfEther) + + const limit = await homeBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, foreignMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + + await homeBridge.sendTransaction({ from: accounts[4], value: foreignMinPerTx }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(foreignMinPerTx) + + const limit = await homeBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(foreignMinPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + + await homeBridge.sendTransaction({ from: accounts[4], value: threshold }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(threshold) + + const limit = await homeBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToSend = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const foreignMinPerTx = ether('0.1') + + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + + await homeBridge.sendTransaction({ from: accounts[4], value: amountToSend }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(amountToSend) + + const limit = await homeBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToSend, targetLimit, threshold, foreignMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + }) + } } contract('HomeBridge_Native_to_ERC', async accounts => { From a4ad5eeae4145689f72465838dae0c573186501b Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 7 Nov 2019 12:00:14 +0300 Subject: [PATCH 42/80] fix initialize method conflict --- .../AMBErc677ToErc677Behavior.test.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 2ec6ffac9..c556a8ed3 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -1019,7 +1019,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( }) if (isRelativeDailyLimit) { // eslint-disable-next-line - function initialize(customLimits) { + function initializeWithCustomLimits(customLimits) { return contract.initialize( bridgeContract.address, mediatorContract.address, @@ -1041,7 +1041,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) }) it('should be calculated correctly - 1', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled await erc677Token.mint(contract.address, halfEther).should.be.fulfilled @@ -1053,7 +1053,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(expectedLimit) }) it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, halfEther).should.be.fulfilled expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) @@ -1063,7 +1063,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(expectedLimit) }) it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled expect(await erc677Token.totalSupply()).to.be.bignumber.equal(minPerTx) @@ -1072,7 +1072,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(minPerTx) }) it('should be calculated correctly - 4', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, threshold).should.be.fulfilled expect(await erc677Token.totalSupply()).to.be.bignumber.equal(threshold) @@ -1086,7 +1086,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( const threshold = ether('100') const minPerTx = ether('0.1') - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(accounts[0], amountToMint).should.be.fulfilled expect(await erc677Token.totalSupply()).to.be.bignumber.equal(amountToMint) @@ -1106,7 +1106,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) }) it('should be calculated correctly - 1', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled await erc677Token.mint(contract.address, halfEther).should.be.fulfilled @@ -1118,7 +1118,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(expectedLimit) }) it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) @@ -1128,7 +1128,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(ZERO) }) it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(minPerTx) @@ -1137,7 +1137,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(limit).to.be.bignumber.equal(minPerTx) }) it('should be calculated correctly - 4', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, threshold).should.be.fulfilled expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(threshold) @@ -1151,7 +1151,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( const threshold = ether('100') const minPerTx = ether('0.1') - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) await erc677Token.mint(contract.address, amountToMint).should.be.fulfilled expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(amountToMint) From 3a69ab38e1b4d351164b962c928752243085bc02 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 7 Nov 2019 17:46:48 +0300 Subject: [PATCH 43/80] update deployment scripts --- deploy/.env.example | 3 + deploy/src/amb_erc677_to_erc677/initialize.js | 62 +++++++++++--- deploy/src/erc_to_erc/foreign.js | 15 +++- deploy/src/erc_to_erc/home.js | 27 +++++- deploy/src/erc_to_native/foreign.js | 16 +++- deploy/src/erc_to_native/home.js | 27 +++++- deploy/src/loadEnv.js | 85 +++++++++++++++---- deploy/src/native_to_erc/foreign.js | 31 +++++-- deploy/src/native_to_erc/home.js | 27 +++++- flatten.sh | 3 + 10 files changed, 246 insertions(+), 50 deletions(-) diff --git a/deploy/.env.example b/deploy/.env.example index c06c51281..3ec26f093 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -60,6 +60,9 @@ VALIDATORS_REWARD_ACCOUNTS=0x # Relative or fixed daily limit RELATIVE_DAILY_LIMIT=false +# Fixed percentage of balance after threshold (e.g. 5%) +TARGET_LIMIT=50000000000000000 +THRESHOLD=100000000000000000000000 # Fee to be taken for every transaction directed from the Home network to the Foreign network # E.g. 0.1% fee diff --git a/deploy/src/amb_erc677_to_erc677/initialize.js b/deploy/src/amb_erc677_to_erc677/initialize.js index beed5bb39..b1481d575 100644 --- a/deploy/src/amb_erc677_to_erc677/initialize.js +++ b/deploy/src/amb_erc677_to_erc677/initialize.js @@ -2,8 +2,16 @@ const Web3Utils = require('web3-utils') const assert = require('assert') const { web3Home, HOME_RPC_URL, web3Foreign, FOREIGN_RPC_URL, deploymentPrivateKey } = require('../web3') const { - homeContracts: { EternalStorageProxy, HomeAMBErc677ToErc677 }, - foreignContracts: { EternalStorageProxy: ForeignEternalStorageProxy, ForeignAMBErc677ToErc677 } + homeContracts: { + EternalStorageProxy, + HomeAMBErc677ToErc677, + HomeAMBErc677ToErc677RelativeDailyLimit + }, + foreignContracts: { + EternalStorageProxy: ForeignEternalStorageProxy, + ForeignAMBErc677ToErc677, + ForeignAMBErc677ToErc677RelativeDailyLimit + } } = require('../loadContracts') const { privateKeyToAddress, @@ -30,7 +38,10 @@ const { FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT, ERC20_TOKEN_ADDRESS, DEPLOYMENT_ACCOUNT_PRIVATE_KEY, - FOREIGN_TO_HOME_DECIMAL_SHIFT + FOREIGN_TO_HOME_DECIMAL_SHIFT, + RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD } = require('../loadEnv') const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -56,19 +67,33 @@ async function initialize({ owner }, upgradeableAdmin, - sendRawTx + sendRawTx, + isRelativeDailyLimitOnBridgeSide, }) { let nonce = await web3.eth.getTransactionCount(DEPLOYMENT_ACCOUNT_ADDRESS) const contract = new web3.eth.Contract(abi, address) + const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + console.log(` AMB contract: ${bridgeContract}, Mediator contract: ${mediatorContract}, Token contract: ${erc677token}, - DAILY_LIMIT : ${dailyLimit} which is ${Web3Utils.fromWei(dailyLimit)} in eth, + ${ + RELATIVE_DAILY_LIMIT && isRelativeDailyLimitOnBridgeSide + ? RELATIVE_DAILY_LIMIT_PARAMS + : `DAILY_LIMIT : ${dailyLimit} which is ${Web3Utils.fromWei(dailyLimit)} in eth,` + } MAX_AMOUNT_PER_TX: ${maxPerTx} which is ${Web3Utils.fromWei(maxPerTx)} in eth, MIN_AMOUNT_PER_TX: ${minPerTx} which is ${Web3Utils.fromWei(minPerTx)} in eth, - EXECUTION_DAILY_LIMIT : ${executionDailyLimit} which is ${Web3Utils.fromWei(executionDailyLimit)} in eth, + ${ + RELATIVE_DAILY_LIMIT && !isRelativeDailyLimitOnBridgeSide + ? RELATIVE_DAILY_LIMIT_PARAMS + : `EXECUTION_DAILY_LIMIT : ${executionDailyLimit} which is ${Web3Utils.fromWei(executionDailyLimit)} in eth,` + } EXECUTION_MAX_AMOUNT_PER_TX: ${executionMaxPerTx} which is ${Web3Utils.fromWei(executionMaxPerTx)} in eth, EXECUTION_MIN_AMOUNT_PER_TX: ${executionMinPerTx} which is ${Web3Utils.fromWei(executionMinPerTx)} in eth, MEDIATOR_REQUEST_GAS_LIMIT : ${requestGasLimit}, @@ -76,13 +101,24 @@ async function initialize({ OWNER: ${owner} `) + let requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] + let executionLimitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + + if (RELATIVE_DAILY_LIMIT) { + if (isRelativeDailyLimitOnBridgeSide) { + requestLimitsArray = [TARGET_LIMIT, THRESHOLD, maxPerTx, minPerTx] + } else { + executionLimitsArray = [TARGET_LIMIT, THRESHOLD, executionMaxPerTx, executionMinPerTx] + } + } + const initializeData = await contract.methods .initialize( bridgeContract, mediatorContract, erc677token, - [dailyLimit, maxPerTx, minPerTx], - [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + requestLimitsArray, + executionLimitsArray, requestGasLimit, foreignToHomeDecimalShift, owner @@ -121,7 +157,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { web3: web3Home, url: HOME_RPC_URL, address: homeBridge, - abi: HomeAMBErc677ToErc677.abi, + abi: RELATIVE_DAILY_LIMIT ? HomeAMBErc677ToErc677RelativeDailyLimit.abi : HomeAMBErc677ToErc677.abi, proxyAbi: EternalStorageProxy.abi, params: { bridgeContract: HOME_AMB_BRIDGE, @@ -138,7 +174,8 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { owner: HOME_BRIDGE_OWNER }, upgradeableAdmin: HOME_UPGRADEABLE_ADMIN, - sendRawTx: sendRawTxHome + sendRawTx: sendRawTxHome, + isRelativeDailyLimitOnBridgeSide: true, }) console.log('\n[Foreign] Initializing Foreign Bridge with following parameters:\n') @@ -146,7 +183,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { web3: web3Foreign, url: FOREIGN_RPC_URL, address: foreignBridge, - abi: ForeignAMBErc677ToErc677.abi, + abi: RELATIVE_DAILY_LIMIT ? ForeignAMBErc677ToErc677RelativeDailyLimit.abi : ForeignAMBErc677ToErc677.abi, proxyAbi: ForeignEternalStorageProxy.abi, params: { bridgeContract: FOREIGN_AMB_BRIDGE, @@ -163,7 +200,8 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { owner: FOREIGN_BRIDGE_OWNER }, upgradeableAdmin: FOREIGN_UPGRADEABLE_ADMIN, - sendRawTx: sendRawTxForeign + sendRawTx: sendRawTxForeign, + isRelativeDailyLimitOnBridgeSide: false, }) } diff --git a/deploy/src/erc_to_erc/foreign.js b/deploy/src/erc_to_erc/foreign.js index 466e82393..b5f5d9f60 100644 --- a/deploy/src/erc_to_erc/foreign.js +++ b/deploy/src/erc_to_erc/foreign.js @@ -43,6 +43,8 @@ const { ERC20_EXTENDED_BY_ERC677, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -56,13 +58,22 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { FOREIGN_MAX_AMOUNT_PER_TX )} in eth, FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, - HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? `TARGET_LIMIT: ${TARGET_LIMIT} which is ${Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100)))}%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + : `HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} `) + const executionLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + const initializeFBridgeData = await bridge.methods .initialize( validatorsBridge.options.address, @@ -70,7 +81,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_GAS_PRICE, [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + executionLimitsArray, FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index b46e2a66c..cc3ac6431 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -58,6 +58,8 @@ const { FOREIGN_TRANSACTIONS_FEE, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -76,6 +78,15 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial let nonce = initialNonce let initializeHomeBridgeData + const requestLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + + const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + if (isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS) { console.log('\ndeploying implementation for fee manager') const feeManager = await deployContract(FeeManagerErcToErcPOSDAO, [], { @@ -89,7 +100,11 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial const foreignFeeInWei = Web3Utils.toWei(FOREIGN_TRANSACTIONS_FEE.toString(), 'ether') console.log('\ninitializing Home Bridge with fee contract:\n') console.log(`Home Validators: ${validatorsBridge.options.address}, - HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, @@ -100,7 +115,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial initializeHomeBridgeData = await bridge.methods .rewardableInitialize( validatorsBridge.options.address, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + requestLimitsArray, HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, erc677token.options.address, @@ -114,7 +129,11 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial .encodeABI() } else { console.log(`Home Validators: ${validatorsBridge.options.address}, - HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, @@ -123,7 +142,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial initializeHomeBridgeData = await bridge.methods .initialize( validatorsBridge.options.address, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + requestLimitsArray, HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, erc677token.options.address, diff --git a/deploy/src/erc_to_native/foreign.js b/deploy/src/erc_to_native/foreign.js index f325ada3c..dd93b5f05 100644 --- a/deploy/src/erc_to_native/foreign.js +++ b/deploy/src/erc_to_native/foreign.js @@ -40,6 +40,8 @@ const { HOME_MIN_AMOUNT_PER_TX, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -57,13 +59,23 @@ async function initializeBridge({ validatorsBridge, bridge, nonce, homeBridgeAdd FOREIGN_MIN_AMOUNT_PER_TX )} in eth, FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, - HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? `TARGET_LIMIT: ${TARGET_LIMIT} which is ${Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100)))}%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + : `HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, Home bridge Address: ${homeBridgeAddress} `) + + const executionLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + const initializeFBridgeData = await bridge.methods .initialize( validatorsBridge.options.address, @@ -71,7 +83,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce, homeBridgeAdd FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, FOREIGN_GAS_PRICE, [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + executionLimitsArray, FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift, homeBridgeAddress diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index 49172e698..dbd7f24a7 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -47,6 +47,8 @@ const { HOME_FEE_MANAGER_TYPE, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -66,6 +68,15 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { let nonce = initialNonce let initializeHomeBridgeData + const requestLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] + + const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') const feeManagerContract = isFeeManagerPOSDAO ? FeeManagerErcToNativePOSDAO : FeeManagerErcToNative @@ -80,7 +91,11 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { const foreignFeeInWei = Web3Utils.toWei(FOREIGN_TRANSACTIONS_FEE.toString(), 'ether') console.log('\ninitializing Home Bridge with fee contract:\n') console.log(`Home Validators: ${validatorsBridge.options.address}, - HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, @@ -100,7 +115,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { initializeHomeBridgeData = await bridge.methods .rewardableInitialize( validatorsBridge.options.address, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + requestLimitsArray, HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, BLOCK_REWARD_ADDRESS, @@ -114,7 +129,11 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { } else { console.log('\ninitializing Home Bridge with following parameters:\n') console.log(`Home Validators: ${validatorsBridge.options.address}, - HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,` + } HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, @@ -132,7 +151,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { initializeHomeBridgeData = await bridge.methods .initialize( validatorsBridge.options.address, - [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], + requestLimitsArray, HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, BLOCK_REWARD_ADDRESS, diff --git a/deploy/src/loadEnv.js b/deploy/src/loadEnv.js index cb5a2e139..559542c6e 100644 --- a/deploy/src/loadEnv.js +++ b/deploy/src/loadEnv.js @@ -2,7 +2,7 @@ const path = require('path') require('dotenv').config({ path: path.join(__dirname, '..', '.env') }) -const { isAddress, toBN } = require('web3').utils +const { isAddress, toBN, toWei } = require('web3').utils const envalid = require('envalid') const { ZERO_ADDRESS, EVM_TYPES } = require('./constants') @@ -59,11 +59,19 @@ function checkBlockConfirmations(confirmations, prefix) { } } -function checkLimits(min, max, daily, prefix) { - if (min.isZero() || min.gte(max) || max.gte(daily)) { - throw new Error( - `Limit parameters should be defined as 0 < ${prefix}_MIN_AMOUNT_PER_TX < ${prefix}_MAX_AMOUNT_PER_TX < ${prefix}_DAILY_LIMIT` - ) +function checkLimits(min, max, daily, isRelativeDailyLimit, targetLimit, threshold, prefix) { + if (isRelativeDailyLimit) { + if (min.isZero() || min.gte(max) || min.gt(threshold) || targetLimit.gt(toBN(toWei('1', 'ether')))) { + throw new Error( + `Limit parameters should be defined as 0 < ${prefix}_MIN_AMOUNT_PER_TX < ${prefix}_MAX_AMOUNT_PER_TX and THRESHOLD >= ${prefix}_MIN_AMOUNT_PER_TX and TARGET_LIMIT <= 1 ether` + ) + } + } else { + if (min.isZero() || min.gte(max) || max.gte(daily)) { + throw new Error( + `Limit parameters should be defined as 0 < ${prefix}_MIN_AMOUNT_PER_TX < ${prefix}_MAX_AMOUNT_PER_TX < ${prefix}_DAILY_LIMIT` + ) + } } } @@ -77,6 +85,7 @@ const { HOME_FEE_MANAGER_TYPE, HOME_EVM_VERSION, FOREIGN_EVM_VERSION, + RELATIVE_DAILY_LIMIT, } = process.env // Types validations @@ -127,7 +136,6 @@ if (BRIDGE_MODE === 'AMB_ERC_TO_ERC') { FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator(), FOREIGN_DAILY_LIMIT: bigNumValidator(), DEPLOY_REWARDABLE_TOKEN: envalid.bool(), - RELATIVE_DAILY_LIMIT: envalid.bool(), } if (DEPLOY_REWARDABLE_TOKEN === 'true') { @@ -156,7 +164,15 @@ if (BRIDGE_MODE !== 'ARBITRARY_MESSAGE') { ...validations, HOME_DAILY_LIMIT: bigNumValidator(), HOME_MIN_AMOUNT_PER_TX: bigNumValidator(), - FOREIGN_DAILY_LIMIT: bigNumValidator() + FOREIGN_DAILY_LIMIT: bigNumValidator(), + RELATIVE_DAILY_LIMIT: envalid.bool() + } + if (RELATIVE_DAILY_LIMIT === 'true') { + validations = { + ...validations, + TARGET_LIMIT: bigNumValidator(), + THRESHOLD: bigNumValidator() + } } if (BRIDGE_MODE !== 'AMB_ERC_TO_ERC') { @@ -204,7 +220,6 @@ if (BRIDGE_MODE === 'NATIVE_TO_ERC') { BRIDGEABLE_TOKEN_DECIMALS: envalid.num(), FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator(), DEPLOY_REWARDABLE_TOKEN: envalid.bool(), - RELATIVE_DAILY_LIMIT: envalid.bool(), } if (DEPLOY_REWARDABLE_TOKEN === 'true') { @@ -225,7 +240,6 @@ if (BRIDGE_MODE === 'ERC_TO_ERC') { BRIDGEABLE_TOKEN_DECIMALS: envalid.num(), DEPLOY_REWARDABLE_TOKEN: envalid.bool(), ERC20_EXTENDED_BY_ERC677: envalid.bool(), - RELATIVE_DAILY_LIMIT: envalid.bool(), FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator() } @@ -245,7 +259,6 @@ if (BRIDGE_MODE === 'ERC_TO_NATIVE') { BLOCK_REWARD_ADDRESS: addressValidator({ default: ZERO_ADDRESS }), - RELATIVE_DAILY_LIMIT: envalid.bool(), FOREIGN_MIN_AMOUNT_PER_TX: bigNumValidator() } } @@ -268,12 +281,28 @@ if (env.BRIDGE_MODE === 'ARBITRARY_MESSAGE') { throw new Error(`FOREIGN_MAX_AMOUNT_PER_TX should be greater than 0`) } } else { - checkLimits(env.HOME_MIN_AMOUNT_PER_TX, env.HOME_MAX_AMOUNT_PER_TX, env.HOME_DAILY_LIMIT, homePrefix) + checkLimits( + env.HOME_MIN_AMOUNT_PER_TX, + env.HOME_MAX_AMOUNT_PER_TX, + env.HOME_DAILY_LIMIT, + env.RELATIVE_DAILY_LIMIT, + env.TARGET_LIMIT, + env.THRESHOLD, + homePrefix + ) } if (env.BRIDGE_MODE === 'NATIVE_TO_ERC') { checkGasPrices(env.HOME_GAS_PRICE, homePrefix) - checkLimits(env.FOREIGN_MIN_AMOUNT_PER_TX, env.FOREIGN_MAX_AMOUNT_PER_TX, env.FOREIGN_DAILY_LIMIT, foreignPrefix) + checkLimits( + env.FOREIGN_MIN_AMOUNT_PER_TX, + env.FOREIGN_MAX_AMOUNT_PER_TX, + env.FOREIGN_DAILY_LIMIT, + env.RELATIVE_DAILY_LIMIT, + env.TARGET_LIMIT, + env.THRESHOLD, + foreignPrefix + ) if (env.FOREIGN_REWARDABLE === 'BOTH_DIRECTIONS') { throw new Error(`FOREIGN_REWARDABLE: ${env.FOREIGN_REWARDABLE} is not supported on ${env.BRIDGE_MODE} bridge mode`) } @@ -286,7 +315,15 @@ if (env.BRIDGE_MODE === 'NATIVE_TO_ERC') { } if (env.BRIDGE_MODE === 'ERC_TO_ERC') { - checkLimits(env.FOREIGN_MIN_AMOUNT_PER_TX, env.FOREIGN_MAX_AMOUNT_PER_TX, env.FOREIGN_DAILY_LIMIT, foreignPrefix) + checkLimits( + env.FOREIGN_MIN_AMOUNT_PER_TX, + env.FOREIGN_MAX_AMOUNT_PER_TX, + env.FOREIGN_DAILY_LIMIT, + env.RELATIVE_DAILY_LIMIT, + env.TARGET_LIMIT, + env.THRESHOLD, + foreignPrefix + ) if (env.HOME_REWARDABLE === 'BOTH_DIRECTIONS' && env.BLOCK_REWARD_ADDRESS === ZERO_ADDRESS) { throw new Error( @@ -300,7 +337,15 @@ if (env.BRIDGE_MODE === 'ERC_TO_ERC') { } if (env.BRIDGE_MODE === 'ERC_TO_NATIVE') { - checkLimits(env.FOREIGN_MIN_AMOUNT_PER_TX, env.FOREIGN_MAX_AMOUNT_PER_TX, env.FOREIGN_DAILY_LIMIT, foreignPrefix) + checkLimits( + env.FOREIGN_MIN_AMOUNT_PER_TX, + env.FOREIGN_MAX_AMOUNT_PER_TX, + env.FOREIGN_DAILY_LIMIT, + env.RELATIVE_DAILY_LIMIT, + env.TARGET_LIMIT, + env.THRESHOLD, + foreignPrefix + ) if (HOME_REWARDABLE === 'ONE_DIRECTION') { throw new Error( @@ -322,7 +367,15 @@ if (env.BRIDGE_MODE === 'ERC_TO_NATIVE') { } if (env.BRIDGE_MODE === 'AMB_ERC_TO_ERC') { - checkLimits(env.FOREIGN_MIN_AMOUNT_PER_TX, env.FOREIGN_MAX_AMOUNT_PER_TX, env.FOREIGN_DAILY_LIMIT, foreignPrefix) + checkLimits( + env.FOREIGN_MIN_AMOUNT_PER_TX, + env.FOREIGN_MAX_AMOUNT_PER_TX, + env.FOREIGN_DAILY_LIMIT, + env.RELATIVE_DAILY_LIMIT, + env.TARGET_LIMIT, + env.THRESHOLD, + foreignPrefix + ) } module.exports = env diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index ca553988c..f76ceac49 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -53,6 +53,8 @@ const { HOME_TRANSACTIONS_FEE, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -71,6 +73,15 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i let nonce = initialNonce let initializeFBridgeData + const requestLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + + const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') const feeManager = await deployContract(FeeManagerNativeToErc, [], { @@ -85,7 +96,11 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i console.log('\ninitializing Foreign Bridge with fee contract:\n') console.log(`Foreign Validators: ${validatorsBridge.options.address}, - FOREIGN_DAILY_LIMIT : ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,` + } FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, @@ -93,7 +108,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i FOREIGN_MIN_AMOUNT_PER_TX )} in eth, FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, - HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, @@ -106,7 +121,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i .rewardableInitialize( validatorsBridge.options.address, erc677bridgeToken.options.address, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + requestLimitsArray, FOREIGN_GAS_PRICE, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], @@ -120,7 +135,11 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i } else { console.log('\ninitializing Foreign Bridge with following parameters:\n') console.log(`Foreign Validators: ${validatorsBridge.options.address}, - FOREIGN_DAILY_LIMIT : ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `FOREIGN_DAILY_LIMIT : ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,` + } FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, @@ -128,7 +147,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i FOREIGN_MIN_AMOUNT_PER_TX )} in eth, FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS}, - HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, + HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth, HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, @@ -140,7 +159,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i .initialize( validatorsBridge.options.address, erc677bridgeToken.options.address, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + requestLimitsArray, FOREIGN_GAS_PRICE, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS, [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], diff --git a/deploy/src/native_to_erc/home.js b/deploy/src/native_to_erc/home.js index 83df6d551..964ac7b19 100644 --- a/deploy/src/native_to_erc/home.js +++ b/deploy/src/native_to_erc/home.js @@ -45,6 +45,8 @@ const { FOREIGN_TRANSACTIONS_FEE, FOREIGN_TO_HOME_DECIMAL_SHIFT, RELATIVE_DAILY_LIMIT, + TARGET_LIMIT, + THRESHOLD, } = env const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -64,6 +66,15 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { let nonce = initialNonce let initializeHomeBridgeData + const executionLimitsArray = RELATIVE_DAILY_LIMIT + ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] + + const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') const feeManagerContract = isBothDirectionsFeeManager ? FeeManagerNativeToErcBothDirections : FeeManagerNativeToErc @@ -84,7 +95,11 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, - FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,` + } FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, @@ -103,7 +118,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + executionLimitsArray, HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], @@ -117,7 +132,11 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, - FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth, + ${ + RELATIVE_DAILY_LIMIT + ? RELATIVE_DAILY_LIMIT_PARAMS + : `FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,` + } FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( FOREIGN_MAX_AMOUNT_PER_TX )} in eth, @@ -133,7 +152,7 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], HOME_GAS_PRICE, HOME_REQUIRED_BLOCK_CONFIRMATIONS, - [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + executionLimitsArray, HOME_BRIDGE_OWNER, foreignToHomeDecimalShift ) diff --git a/flatten.sh b/flatten.sh index 1a0c9c45d..265d9f739 100755 --- a/flatten.sh +++ b/flatten.sh @@ -27,8 +27,11 @@ ${FLATTENER} ${VALIDATOR_CONTRACTS_DIR}/RewardableValidators.sol > flats/validat echo "Flattening contracts related to native-to-erc bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ForeignBridgeNativeToErc.sol > flats/native_to_erc20/ForeignBridgeNativeToErc_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/HomeBridgeNativeToErc.sol > flats/native_to_erc20/HomeBridgeNativeToErc_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ClassicHomeBridgeNativeToErc.sol > flats/native_to_erc20/ClassicHomeBridgeNativeToErc_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErc.sol > flats/native_to_erc20/FeeManagerNativeToErc_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErcBothDirections.sol > flats/native_to_erc20/FeeManagerNativeToErcBothDirections_flat.sol From b4fe09db7a5cd59edf1085056d360d28bb1feda7 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 7 Nov 2019 18:04:59 +0300 Subject: [PATCH 44/80] update flatten script --- flatten.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flatten.sh b/flatten.sh index 265d9f739..7e115a940 100755 --- a/flatten.sh +++ b/flatten.sh @@ -37,14 +37,20 @@ ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErcBothDi echo "Flattening contracts related to erc-to-erc bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErc.sol > flats/erc20_to_erc20/HomeBridgeErcToErc_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol > flats/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol > flats/erc20_to_erc20/HomeBridgeErcToErcPOSDAO_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol > flats/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErcToErc.sol > flats/erc20_to_erc20/ForeignBridgeErcToErc_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol > flats/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol > flats/erc20_to_erc20/ForeignBridgeErc677ToErc677_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol > flats/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol > flats/erc20_to_erc20/FeeManagerErcToErcPOSDAO_flat.sol echo "Flattening contracts related to erc-to-native bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/HomeBridgeErcToNative.sol > flats/erc20_to_native/HomeBridgeErcToNative_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol > flats/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/ForeignBridgeErcToNative.sol > flats/erc20_to_native/ForeignBridgeErcToNative_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol > flats/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/FeeManagerErcToNative.sol > flats/erc20_to_native/FeeManagerErcToNative_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/FeeManagerErcToNativePOSDAO.sol > flats/erc20_to_native/FeeManagerErcToNativePOSDAO_flat.sol @@ -54,4 +60,6 @@ ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/arbitrary_message/ForeignAMB.sol > flats/ar echo "Flattening contracts related to erc677 to erc677 on top of AMB bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol > flats/amb_erc677_to_erc677/HomeAMBErc677ToErc677_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol > flats/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol > flats/amb_erc677_to_erc677/ForeignAMBErc677ToErc677_flat.sol +${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol > flats/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit_flat.sol From e225c6c91c718dd71963d0a4174fdef09dc5b4d0 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 7 Nov 2019 18:16:12 +0300 Subject: [PATCH 45/80] update readme --- deploy/.env.example | 2 +- deploy/README.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/deploy/.env.example b/deploy/.env.example index 3ec26f093..28cdf1778 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -58,7 +58,7 @@ FOREIGN_REWARDABLE=false #E.g. VALIDATORS_REWARD_ACCOUNTS=0x 0x 0x VALIDATORS_REWARD_ACCOUNTS=0x -# Relative or fixed daily limit +# Relative or absolute daily limit RELATIVE_DAILY_LIMIT=false # Fixed percentage of balance after threshold (e.g. 5%) TARGET_LIMIT=50000000000000000 diff --git a/deploy/README.md b/deploy/README.md index 7daa913b0..eee8d3ec2 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -148,6 +148,13 @@ FOREIGN_REWARDABLE=false # Makes sense only when HOME_REWARDABLE!=false or FOREIGN_REWARDABLE!=false VALIDATORS_REWARD_ACCOUNTS=0x 0x 0x +# Relative or absolute daily limit. If true then TARGET_LIMIT and THRESHOLD will be used in the calculation +RELATIVE_DAILY_LIMIT=true +# Fixed percentage of balance after threshold (e.g. 5%). Must be less than or equal to 1 ether in wei +TARGET_LIMIT=50000000000000000 +# Must be greater than or equal to MIN_AMOUNT_PER_TX of the side on which relative daily limit is used +THRESHOLD=100000000000000000000000 + # Fee to be taken for every transaction directed from the Home network to the Foreign network # Makes sense only when FOREIGN_REWARDABLE=ONE_DIRECTION or HOME_REWARDABLE=BOTH_DIRECTIONS # e.g. 0.1% fee From d7834d09177b42075bf549d270d5de5e9cd23a1f Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 7 Nov 2019 19:08:59 +0300 Subject: [PATCH 46/80] remove unnecessary checks in tests --- .../AMBErc677ToErc677Behavior.test.js | 323 +++++++++--------- .../foreign_bridge.test.js | 1 - test/amb_erc677_to_erc677/home_bridge.test.js | 114 +++---- 3 files changed, 212 insertions(+), 226 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index c556a8ed3..452e9dacc 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -600,27 +600,25 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( contract = this.bridge }) - if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { - it('should allow to bridge tokens using approve and transferFrom', async () => { - // Given - await initialize(erc20Token.address) + it('should allow to bridge tokens using approve and transferFrom', async () => { + // Given + await initialize(erc20Token.address) - const currentDay = await contract.getCurrentDay() - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await contract.getCurrentDay() + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const value = oneEther - await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(user, value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(user, value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - }) - } + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + }) it('should allow user to specify a itself as receiver', async () => { // Given await initialize(erc20Token.address) @@ -721,58 +719,56 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await contract.relayTokens(user, value, { from: user }).should.be.rejectedWith(ERROR_MSG) }) - if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { - it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is owned by token manager', async function() { - // Given - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - await erc677Token.setBridgeContract(contract.address, { from: owner }).should.be.fulfilled - await erc677Token.transferOwnership(contract.address, { from: owner }).should.be.fulfilled + it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is owned by token manager', async function() { + // Given + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + await erc677Token.setBridgeContract(contract.address, { from: owner }).should.be.fulfilled + await erc677Token.transferOwnership(contract.address, { from: owner }).should.be.fulfilled - contract = this.bridge + contract = this.bridge - await initialize(erc677Token.address) + await initialize(erc677Token.address) - const currentDay = await contract.getCurrentDay() - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await contract.getCurrentDay() + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const value = oneEther - await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(user, value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(user, value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - }) - it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is not owned by token manager', async function() { - // Given - const erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + }) + it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is not owned by token manager', async function() { + // Given + const erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - contract = this.bridge + contract = this.bridge - await initialize(erc677Token.address) + await initialize(erc677Token.address) - const currentDay = await contract.getCurrentDay() - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await contract.getCurrentDay() + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const value = oneEther - await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc677Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc677Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(user, value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(user, value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - }) - } + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + }) }) describe('requestFailedMessageFix', () => { const nonce = '0x96b6af865cdaa107ede916e237afbedffa5ed36bea84c0e77a33cc28fc2e9c01' @@ -873,127 +869,120 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(allEvents[1].returnValues.encodedData.includes(strip0x(dataHash))).to.be.equal(true) }) }) - if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { - describe('fixFailedMessage', () => { - let dataHash - beforeEach(async function() { - contract = this.bridge - - bridgeContract = await AMBMock.new() - await bridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await otherSideMediatorContract.new() - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - - await initialize(erc677Token.address) - await erc677Token.transferOwnership(contract.address) - - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - - // User transfer tokens - const transferTx = await erc677Token.transferAndCall(contract.address, oneEther, '0x', { from: user }).should.be - .fulfilled - - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) - - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - const data = `0x${events[0].returnValues.encodedData.substr( - 148, - events[0].returnValues.encodedData.length - 148 - )}` - - // Bridge calls mediator from other side - await bridgeContract.executeMessageCall( - contract.address, - contract.address, - data, - transferTx.tx, - 100 - ).should.be.fulfilled - - expect(await bridgeContract.messageCallStatus(transferTx.tx)).to.be.equal(false) - - // mediator from other side should use this dataHash to request fix the failed message - dataHash = await bridgeContract.failedMessageDataHash(transferTx.tx) - }) - it('should fix burnt/locked tokens', async () => { - // Given - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + describe('fixFailedMessage', () => { + let dataHash + beforeEach(async function() { + contract = this.bridge + + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - // When - const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() + await initialize(erc677Token.address) + await erc677Token.transferOwnership(contract.address) - await bridgeContract.executeMessageCall( - contract.address, - mediatorContract.address, - fixData, - exampleTxHash, - 1000000 - ).should.be.fulfilled - - // Then - expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) - - const event = await getEvents(contract, { event: 'FailedMessageFixed' }) - expect(event.length).to.be.equal(1) - expect(event[0].returnValues.dataHash).to.be.equal(dataHash) - expect(event[0].returnValues.recipient).to.be.equal(user) - expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) - - const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - - // can only fix it one time - await bridgeContract.executeMessageCall( - contract.address, - mediatorContract.address, - fixData, - otherTxHash, - 1000000 - ).should.be.fulfilled + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(false) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - }) - it('should be called by bridge', async () => { - await contract.fixFailedMessage(dataHash, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - it('message sender should be mediator from other side', async () => { - // Given - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + // User transfer tokens + const transferTx = await erc677Token.transferAndCall(contract.address, oneEther, '0x', { from: user }).should.be + .fulfilled + + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) - // When - const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + const data = `0x${events[0].returnValues.encodedData.substr( + 148, + events[0].returnValues.encodedData.length - 148 + )}` - await bridgeContract.executeMessageCall(contract.address, contract.address, fixData, exampleTxHash, 1000000) - .should.be.fulfilled + // Bridge calls mediator from other side + await bridgeContract.executeMessageCall( + contract.address, + contract.address, + data, + transferTx.tx, + 100 + ).should.be.fulfilled - // Then - expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(false) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + expect(await bridgeContract.messageCallStatus(transferTx.tx)).to.be.equal(false) - const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + // mediator from other side should use this dataHash to request fix the failed message + dataHash = await bridgeContract.failedMessageDataHash(transferTx.tx) + }) + it('should fix burnt/locked tokens', async () => { + // Given + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) - await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) - .should.be.fulfilled + // When + const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() - expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(true) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) - expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) + await bridgeContract.executeMessageCall( + contract.address, + mediatorContract.address, + fixData, + exampleTxHash, + 1000000 + ).should.be.fulfilled - const event = await getEvents(contract, { event: 'FailedMessageFixed' }) - expect(event.length).to.be.equal(1) - expect(event[0].returnValues.dataHash).to.be.equal(dataHash) - expect(event[0].returnValues.recipient).to.be.equal(user) - expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) - }) + // Then + expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) + + const event = await getEvents(contract, { event: 'FailedMessageFixed' }) + expect(event.length).to.be.equal(1) + expect(event[0].returnValues.dataHash).to.be.equal(dataHash) + expect(event[0].returnValues.recipient).to.be.equal(user) + expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) + + const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + + // can only fix it one time + await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) + .should.be.fulfilled + + expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(false) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) }) - } + it('should be called by bridge', async () => { + await contract.fixFailedMessage(dataHash, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('message sender should be mediator from other side', async () => { + // Given + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + + // When + const fixData = await contract.contract.methods.fixFailedMessage(dataHash).encodeABI() + + await bridgeContract.executeMessageCall(contract.address, contract.address, fixData, exampleTxHash, 1000000) + .should.be.fulfilled + + // Then + expect(await bridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(false) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(oneEther) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(false) + + const otherTxHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + + await bridgeContract.executeMessageCall(contract.address, mediatorContract.address, fixData, otherTxHash, 1000000) + .should.be.fulfilled + + expect(await bridgeContract.messageCallStatus(otherTxHash)).to.be.equal(true) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(twoEthers) + expect(await contract.messageHashFixed(dataHash)).to.be.equal(true) + + const event = await getEvents(contract, { event: 'FailedMessageFixed' }) + expect(event.length).to.be.equal(1) + expect(event[0].returnValues.dataHash).to.be.equal(dataHash) + expect(event[0].returnValues.recipient).to.be.equal(user) + expect(event[0].returnValues.value).to.be.equal(oneEther.toString()) + }) + }) describe('#claimTokens', () => { it('should be able to claim tokens', async function() { contract = this.proxyContract diff --git a/test/amb_erc677_to_erc677/foreign_bridge.test.js b/test/amb_erc677_to_erc677/foreign_bridge.test.js index a721b2acb..594fe10ac 100644 --- a/test/amb_erc677_to_erc677/foreign_bridge.test.js +++ b/test/amb_erc677_to_erc677/foreign_bridge.test.js @@ -151,7 +151,6 @@ function test(accounts, isRelativeDailyLimit) { await erc677Token.transferOwnership(foreignBridge.address) }) it('should transfer locked tokens on message from amb', async () => { - if (isRelativeDailyLimit) return // Given const currentDay = await foreignBridge.getCurrentDay() expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index 81aa5710a..84bbcff37 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -75,66 +75,64 @@ function test(accounts, isRelativeDailyLimit) { owner ).should.be.fulfilled }) - if (!isRelativeDailyLimit) { - it('should emit UserRequestForSignature in AMB bridge and burn transferred tokens', async () => { - // Given - const currentDay = await homeBridge.getCurrentDay() - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(initialEvents.length).to.be.equal(0) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - - // only token address can call it - await homeBridge.onTokenTransfer(user, oneEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) - - // must be within limits - await erc677Token - .transferAndCall(homeBridge.address, twoEthers, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - - // When - const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, '0x', { from: user }).should.be - .fulfilled - - // Then - const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(events.length).to.be.equal(1) - expect(events[0].returnValues.encodedData.includes(strip0x(user).toLowerCase())).to.be.equal(true) - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) - expectEventInLogs(logs, 'Burn', { - burner: homeBridge.address, - value: oneEther - }) + it('should emit UserRequestForSignature in AMB bridge and burn transferred tokens', async () => { + // Given + const currentDay = await homeBridge.getCurrentDay() + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(initialEvents.length).to.be.equal(0) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + + // only token address can call it + await homeBridge.onTokenTransfer(user, oneEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) + + // must be within limits + await erc677Token + .transferAndCall(homeBridge.address, twoEthers, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + + // When + const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, '0x', { from: user }).should.be + .fulfilled + + // Then + const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(events.length).to.be.equal(1) + expect(events[0].returnValues.encodedData.includes(strip0x(user).toLowerCase())).to.be.equal(true) + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + expectEventInLogs(logs, 'Burn', { + burner: homeBridge.address, + value: oneEther }) - it('should be able to specify a different receiver', async () => { - const user2 = accounts[2] - // Given - const currentDay = await homeBridge.getCurrentDay() - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(initialEvents.length).to.be.equal(0) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) - - // When - await erc677Token - .transferAndCall(homeBridge.address, oneEther, '0x00', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, user2, { from: user }).should.be - .fulfilled - - // Then - const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) - expect(events.length).to.be.equal(1) - expect(events[0].returnValues.encodedData.includes(strip0x(user2).toLowerCase())).to.be.equal(true) - expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) - expectEventInLogs(logs, 'Burn', { - burner: homeBridge.address, - value: oneEther - }) + }) + it('should be able to specify a different receiver', async () => { + const user2 = accounts[2] + // Given + const currentDay = await homeBridge.getCurrentDay() + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const initialEvents = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(initialEvents.length).to.be.equal(0) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(twoEthers) + + // When + await erc677Token + .transferAndCall(homeBridge.address, oneEther, '0x00', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + const { logs } = await erc677Token.transferAndCall(homeBridge.address, oneEther, user2, { from: user }).should.be + .fulfilled + + // Then + const events = await getEvents(ambBridgeContract, { event: 'UserRequestForSignature' }) + expect(events.length).to.be.equal(1) + expect(events[0].returnValues.encodedData.includes(strip0x(user2).toLowerCase())).to.be.equal(true) + expect(await homeBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + expectEventInLogs(logs, 'Burn', { + burner: homeBridge.address, + value: oneEther }) - } + }) }) describe('handleBridgedTokens', () => { const nonce = '0x96b6af865cdaa107ede916e237afbedffa5ed36bea84c0e77a33cc28fc2e9c01' From 64c43669d9865c6c625db37fd97836074fc353d1 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 8 Nov 2019 17:46:06 +0300 Subject: [PATCH 47/80] fix typos --- .../HomeBridgeNativeToErcRelativeDailyLimit.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol index d3ee37b05..29af7a612 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol @@ -14,7 +14,7 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] address _owner, uint256 _decimalShift ) external returns (bool) { @@ -29,7 +29,7 @@ contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, Relat uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _tthreshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] From 7e8009b7eaf94badec96a866ef242ec5bd499f8d Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 8 Nov 2019 17:47:39 +0300 Subject: [PATCH 48/80] remove redundant check in relative daily limit calculation --- contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol index 86e9da4bd..9bd174d05 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -22,7 +22,7 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { uint256 limit = targetLimit(); uint256 thresh = threshold(); uint256 multiplier = 1 ether ** 2; - if (balance > unlimitedBalance && balance < thresh) { + if (balance < thresh) { // to save the gas we don't need to use safe math here // because we check in setters that limit is always less than 1 ether // and threshold is greater than minPerTx From 89aadfd9cb504f871451bfe1719acc15f533e27a Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 8 Nov 2019 18:12:31 +0300 Subject: [PATCH 49/80] add tests for setTargetLimit and setThreshold --- .../AMBErc677ToErc677Behavior.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 452e9dacc..562868d8f 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -422,6 +422,24 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') }) } + if (isRelativeDailyLimit) { + it('setThreshold allow to set by owner and should be greater than or equal to mixPerTx', async () => { + await contract.setThreshold('1', { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setThreshold('1', { from: owner }).should.be.fulfilled + + expect(await contract.threshold()).to.be.bignumber.equal('1') + + await contract.setThreshold('0', { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('setTargetLimit allow to set by owner and should be less than or equal to 1 ether', async () => { + await contract.setTargetLimit(ether('0.5'), { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setTargetLimit(ether('0.5'), { from: owner }).should.be.fulfilled + + expect(await contract.targetLimit()).to.be.bignumber.equal(ether('0.5')) + + await contract.setTargetLimit(ether('1.001'), { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + } }) describe('getBridgeMode', () => { it('should return arbitrary message bridging mode and interface', async function() { From c2c9f22b48f1f00d5e202011e3d9d27570d4b1f1 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 25 Nov 2019 13:15:39 +0300 Subject: [PATCH 50/80] allow to set max per tx to 0 --- contracts/upgradeable_contracts/RelativeDailyLimit.sol | 2 +- .../RelativeExecutionDailyLimit.sol | 2 +- .../AMBErc677ToErc677Behavior.test.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index 27f361c9c..b20933538 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -17,7 +17,7 @@ contract RelativeDailyLimit is BaseRelativeDailyLimit { } function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { - require(_maxPerTx > minPerTx()); + require(_maxPerTx > minPerTx() || _maxPerTx == 0); uintStorage[MAX_PER_TX] = _maxPerTx; } } diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol index 3e40ebc9d..10964fe43 100644 --- a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -17,7 +17,7 @@ contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { } function setExecutionMaxPerTx(uint256 _maxPerTx) external onlyOwner { - require(_maxPerTx > executionMinPerTx()); + require(_maxPerTx > executionMinPerTx() || _maxPerTx == 0); uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; } } diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 562868d8f..4a04ae8ab 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -365,6 +365,11 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await contract.setMaxPerTx(2, { from: owner }).should.be.fulfilled expect(await contract.maxPerTx()).to.be.bignumber.equal('2') + if (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide) { + await contract.setMaxPerTx(0, { from: owner }).should.be.fulfilled + expect(await contract.maxPerTx()).to.be.bignumber.equal('0') + } + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { await contract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) } @@ -396,6 +401,11 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await contract.setExecutionMaxPerTx(2, { from: owner }).should.be.fulfilled expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('2') + if (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide) { + await contract.setExecutionMaxPerTx(0, { from: owner }).should.be.fulfilled + expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('0') + } + if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) } From 506bdec84e39c5c6161729d43f45f3c333eff990 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 25 Nov 2019 13:33:15 +0300 Subject: [PATCH 51/80] fix linter errors --- .../BaseRelativeDailyLimit.sol | 5 ++-- ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 6 +--- ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 6 +--- ...oreignBridgeErcToErcRelativeDailyLimit.sol | 7 +---- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 6 +--- .../ForeignBridgeErcToNative.sol | 21 +++++++------- ...ignBridgeErcToNativeRelativeDailyLimit.sol | 28 ++++++++----------- ...ignBridgeNativeToErcRelativeDailyLimit.sol | 6 +--- test/native_to_erc/foreign_bridge_test.js | 1 - 9 files changed, 31 insertions(+), 55 deletions(-) diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol index 9bd174d05..28e708bce 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol @@ -21,7 +21,7 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { } uint256 limit = targetLimit(); uint256 thresh = threshold(); - uint256 multiplier = 1 ether ** 2; + uint256 multiplier = 1 ether**2; if (balance < thresh) { // to save the gas we don't need to use safe math here // because we check in setters that limit is always less than 1 ether @@ -65,7 +65,8 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { function _getTodayLimit() internal view returns (uint256) { uint256 limit = _todayLimit(); - if (limit == 0) { // not set yet + if (limit == 0) { + // not set yet limit = _calculateLimit(); } return limit; diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol index c9a152b1d..1fa39f435 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol @@ -4,11 +4,7 @@ import "./ForeignAMBErc677ToErc677.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { - function handleBridgedTokens( - address _recipient, - uint256 _value, - bytes32 _nonce - ) public { + function handleBridgedTokens(address _recipient, uint256 _value, bytes32 _nonce) public { _updateTodayLimit(); super.handleBridgedTokens(_recipient, _value, _nonce); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol index 788cf106e..fb8a05683 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol @@ -9,11 +9,7 @@ contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, Relat super._relayTokens(_from, _receiver, _value); } - function onTokenTransfer( - address _from, - uint256 _value, - bytes _data - ) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { _updateTodayLimit(); return super.onTokenTransfer(_from, _value, _data); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol index 9d4a34502..08e0fafe9 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol @@ -4,12 +4,7 @@ import "./BasicForeignBridgeErcToErc.sol"; import "../RelativeExecutionDailyLimit.sol"; contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeExecutionDailyLimit { - function executeSignatures( - uint8[] vs, - bytes32[] rs, - bytes32[] ss, - bytes message - ) public { + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { _updateTodayLimit(); super.executeSignatures(vs, rs, ss, message); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol index 918364755..a94d8dcc7 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol @@ -4,11 +4,7 @@ import "./HomeBridgeErcToErc.sol"; import "../RelativeDailyLimit.sol"; contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { - function onTokenTransfer( - address _from, - uint256 _value, - bytes _data - ) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { _updateTodayLimit(); return super.onTokenTransfer(_from, _value, _data); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index fd001952e..1b044b72d 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -31,16 +31,17 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - return _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _requestLimitsArray, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); + return + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _requestLimitsArray, + _owner, + _decimalShift, + _bridgeOnOtherSide + ); } function _initialize( diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol index ad38b1eb7..e66cede36 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol @@ -4,12 +4,7 @@ import "./ForeignBridgeErcToNative.sol"; import "../RelativeExecutionDailyLimit.sol"; contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeExecutionDailyLimit { - function executeSignatures( - uint8[] vs, - bytes32[] rs, - bytes32[] ss, - bytes message - ) public { + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { _updateTodayLimit(); super.executeSignatures(vs, rs, ss, message); } @@ -37,16 +32,17 @@ contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - return _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _requestLimitsArray, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); + return + _initialize( + _validatorContract, + _erc20token, + _requiredBlockConfirmations, + _gasPrice, + _requestLimitsArray, + _owner, + _decimalShift, + _bridgeOnOtherSide + ); } function _getTokenBalance() internal view returns (uint256) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol index 17238e97c..3932fabf0 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol @@ -4,11 +4,7 @@ import "./ForeignBridgeNativeToErc.sol"; import "../RelativeDailyLimit.sol"; contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { - function onTokenTransfer( - address _from, - uint256 _value, - bytes _data - ) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { _updateTodayLimit(); return super.onTokenTransfer(_from, _value, _data); } diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index ba32df858..1eed6aeb1 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -555,7 +555,6 @@ function test(accounts, isRelativeDailyLimit) { valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) From 28f4c0ac21bc87211787e2cfc7b309f5ee061f14 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 9 Dec 2019 17:54:08 +0300 Subject: [PATCH 52/80] move limits logic to external contract --- .../BaseERC677Bridge.sol | 2 +- .../upgradeable_contracts/BasicLimits.sol | 136 ++++++++++++ ...yLimit.sol => BasicRelativeDailyLimit.sol} | 8 +- .../BasicTokenBridge.sol | 193 +++++++++++++----- .../upgradeable_contracts/ERC20Bridge.sol | 2 +- .../RelativeDailyLimit.sol | 8 +- .../RelativeExecutionDailyLimit.sol | 8 +- .../BasicAMBErc677ToErc677.sol | 33 +-- .../BasicForeignBridgeErcToErc.sol | 13 +- .../ForeignBridgeErc677ToErc677.sol | 20 +- .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 20 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 59 ++---- .../HomeBridgeErcToErcPOSDAO.sol | 13 +- .../ForeignBridgeErcToNative.sol | 33 +-- .../erc20_to_native/HomeBridgeErcToNative.sol | 40 +--- .../ForeignBridgeNativeToErc.sol | 38 +--- .../native_to_erc20/HomeBridgeNativeToErc.sol | 40 +--- 17 files changed, 363 insertions(+), 303 deletions(-) create mode 100644 contracts/upgradeable_contracts/BasicLimits.sol rename contracts/upgradeable_contracts/{BaseRelativeDailyLimit.sol => BasicRelativeDailyLimit.sol} (92%) diff --git a/contracts/upgradeable_contracts/BaseERC677Bridge.sol b/contracts/upgradeable_contracts/BaseERC677Bridge.sol index d4d27e7e2..7be25f0f5 100644 --- a/contracts/upgradeable_contracts/BaseERC677Bridge.sol +++ b/contracts/upgradeable_contracts/BaseERC677Bridge.sol @@ -21,7 +21,7 @@ contract BaseERC677Bridge is BasicTokenBridge, ERC677Receiver, ERC677Storage { ERC677 token = erc677token(); require(msg.sender == address(token)); require(withinLimit(_value)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_value)); + _increaseTotalSpentPerDay(_value); bridgeSpecificActionsOnTokenTransfer(token, _from, _value, _data); return true; } diff --git a/contracts/upgradeable_contracts/BasicLimits.sol b/contracts/upgradeable_contracts/BasicLimits.sol new file mode 100644 index 000000000..2f57ab486 --- /dev/null +++ b/contracts/upgradeable_contracts/BasicLimits.sol @@ -0,0 +1,136 @@ +pragma solidity 0.4.24; + +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "../upgradeability/EternalStorage.sol"; + +contract BasicLimits is EternalStorage { + using SafeMath for uint256; + + event DailyLimitChanged(uint256 newLimit); + event ExecutionDailyLimitChanged(uint256 newLimit); + + bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // keccak256(abi.encodePacked("minPerTx")) + bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // keccak256(abi.encodePacked("maxPerTx")) + bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // keccak256(abi.encodePacked("dailyLimit")) + bytes32 internal constant EXECUTION_MIN_PER_TX = 0x0fc9356d7bc6ba08bb648a3ab811cf6e7c168745644ba25095b79e4d8a0c65ec; // keccak256(abi.encodePacked("executionMinPerTx")) + bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // keccak256(abi.encodePacked("executionMaxPerTx")) + bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // keccak256(abi.encodePacked("executionDailyLimit")) + + function setLimits( + uint256[] _requestLimitsArray, // [ 0 = _requestDailyLimit, 1 = _requestMaxPerTx, 2 = _requestMinPerTx ] + uint256[] _executionLimitsArray // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + ) external { + require( + _requestLimitsArray[2] > 0 && // _requestMinPerTx > 0 + _requestLimitsArray[1] > _requestLimitsArray[2] && // _requestMaxPerTx > _requestMinPerTx + _requestLimitsArray[0] > _requestLimitsArray[1] // _requestDailyLimit > _requestMaxPerTx + ); + require( + _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 + _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx + _executionLimitsArray[0] > _executionLimitsArray[1] // _foreignDailyLimit > _foreignMaxPerTx + ); + + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; + + emit DailyLimitChanged(_requestLimitsArray[0]); + emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); + + } + + function totalSpentPerDay(uint256 _day) public view returns (uint256) { + return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))]; + } + + function totalExecutedPerDay(uint256 _day) public view returns (uint256) { + return uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", _day))]; + } + + function dailyLimit() public view returns (uint256) { + return uintStorage[DAILY_LIMIT]; + } + + function executionDailyLimit() public view returns (uint256) { + return uintStorage[EXECUTION_DAILY_LIMIT]; + } + + function maxPerTx() public view returns (uint256) { + return uintStorage[MAX_PER_TX]; + } + + function executionMaxPerTx() public view returns (uint256) { + return uintStorage[EXECUTION_MAX_PER_TX]; + } + + function minPerTx() public view returns (uint256) { + return uintStorage[MIN_PER_TX]; + } + + function executionMinPerTx() public view returns (uint256) { + return uintStorage[EXECUTION_MIN_PER_TX]; + } + + function withinLimit(uint256 _amount) public view returns (bool) { + uint256 nextLimit = totalSpentPerDay(getCurrentDay()).add(_amount); + return dailyLimit() >= nextLimit && _amount <= maxPerTx() && _amount >= minPerTx(); + } + + function withinExecutionLimit(uint256 _amount) public view returns (bool) { + uint256 nextLimit = totalExecutedPerDay(getCurrentDay()).add(_amount); + return executionDailyLimit() >= nextLimit && _amount <= executionMaxPerTx(); + } + + function getCurrentDay() public view returns (uint256) { + // solhint-disable-next-line not-rely-on-time + return now / 1 days; + } + + function increaseTotalSpentPerDay(uint256 _value) external { + uint256 totalSpent = totalSpentPerDay(getCurrentDay()).add(_value); + uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", getCurrentDay()))] = totalSpent; + } + + function increaseTotalExecutedPerDay(uint256 _value) external { + uint256 totalExecuted = totalExecutedPerDay(getCurrentDay()).add(_value); + uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", getCurrentDay()))] = totalExecuted; + } + + function setDailyLimit(uint256 _dailyLimit) external { + require(_dailyLimit > maxPerTx() || _dailyLimit == 0); + uintStorage[DAILY_LIMIT] = _dailyLimit; + emit DailyLimitChanged(_dailyLimit); + } + + function setExecutionDailyLimit(uint256 _dailyLimit) external { + require(_dailyLimit > executionMaxPerTx() || _dailyLimit == 0); + uintStorage[EXECUTION_DAILY_LIMIT] = _dailyLimit; + emit ExecutionDailyLimitChanged(_dailyLimit); + } + + function setExecutionMaxPerTx(uint256 _maxPerTx) external { + require(_maxPerTx < executionDailyLimit()); + uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; + } + + function setExecutionMinPerTx(uint256 _minPerTx) external { + require(_minPerTx < executionDailyLimit() && _minPerTx < executionMaxPerTx()); + uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; + } + + function setMaxPerTx(uint256 _maxPerTx) external { + require(_maxPerTx < dailyLimit()); + uintStorage[MAX_PER_TX] = _maxPerTx; + } + + function setMinPerTx(uint256 _minPerTx) external { + require(_minPerTx < dailyLimit() && _minPerTx < maxPerTx()); + uintStorage[MIN_PER_TX] = _minPerTx; + } + + function updateTodayLimit() external {} +} diff --git a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol similarity index 92% rename from contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol rename to contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol index 28e708bce..52d028921 100644 --- a/contracts/upgradeable_contracts/BaseRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "./BasicTokenBridge.sol"; +import "./BasicLimits.sol"; -contract BaseRelativeDailyLimit is BasicTokenBridge { +contract BasicRelativeDailyLimit is BasicLimits { using SafeMath for uint256; event TargetLimitChanged(uint256 newLimit); @@ -43,13 +43,13 @@ contract BaseRelativeDailyLimit is BasicTokenBridge { return uintStorage[THRESHOLD]; } - function setTargetLimit(uint256 _targetLimit) external onlyOwner { + function setTargetLimit(uint256 _targetLimit) external { require(_targetLimit <= 1 ether); uintStorage[TARGET_LIMIT] = _targetLimit; emit TargetLimitChanged(_targetLimit); } - function setThreshold(uint256 _threshold) external onlyOwner { + function setThreshold(uint256 _threshold) external { require(_threshold >= _minPerTx()); uintStorage[THRESHOLD] = _threshold; emit ThresholdChanged(_threshold); diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index ad6bef2bc..90531975c 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -7,105 +7,186 @@ import "./Ownable.sol"; contract BasicTokenBridge is EternalStorage, Ownable { using SafeMath for uint256; - event DailyLimitChanged(uint256 newLimit); - event ExecutionDailyLimitChanged(uint256 newLimit); - - bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // keccak256(abi.encodePacked("minPerTx")) - bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // keccak256(abi.encodePacked("maxPerTx")) - bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // keccak256(abi.encodePacked("dailyLimit")) - bytes32 internal constant EXECUTION_MIN_PER_TX = 0x0fc9356d7bc6ba08bb648a3ab811cf6e7c168745644ba25095b79e4d8a0c65ec; // keccak256(abi.encodePacked("executionMinPerTx")) - bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // keccak256(abi.encodePacked("executionMaxPerTx")) - bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // keccak256(abi.encodePacked("executionDailyLimit")) bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // keccak256(abi.encodePacked("decimalShift")) + bytes32 internal constant LIMITS_CONTRACT = 0xa31e93f7d43dce967fc79ad66bd710eaf96d9f4737de61bb298c289276986887; // keccak256(abi.encodePacked("limitsContract")) + + bytes4 internal constant GET_MAX_PER_TX = 0xf968adbe; // maxPerTx() + bytes4 internal constant GET_MIN_PER_TX = 0xdf25f3f0; // minPerTx() + bytes4 internal constant GET_DAILY_LIMIT = 0x67eeba0c; // dailyLimit() + bytes4 internal constant GET_EXECUTION_MAX_PER_TX = 0x8aa1949a; // executionMaxPerTx() + bytes4 internal constant GET_EXECUTION_MIN_PER_TX = 0x35b00293; // executionMinPerTx() + bytes4 internal constant GET_EXECUTION_DAILY_LIMIT = 0x43b37dd3; // executionDailyLimit() + bytes4 internal constant GET_TARGET_LIMIT = 0xa70021f3; // targetLimit() + bytes4 internal constant GET_THRESHOLD = 0x42cde4e8; // threshold() + bytes4 internal constant GET_WITHIN_LIMIT = 0xea9f4968; // withinLimit(uint256) + bytes4 internal constant GET_WITHIN_EXECUTION_LIMIT = 0x879ce676; // withinExecutionLimit(uint256) + bytes4 internal constant GET_TOTAL_SPENT_PER_DAY = 0x2bd0bb05; // totalSpentPerDay(uint256) + bytes4 internal constant GET_TOTAL_EXECUTED_PER_DAY = 0x4fb3fef7; // totalExecutedPerDay(uint256) + bytes4 internal constant INCREASE_TOTAL_SPENT_PER_DAY = 0xb47584cd; // increaseTotalSpentPerDay(uint256) + bytes4 internal constant INCREASE_TOTAL_EXECUTED_PER_DAY = 0x79d9623a; // increaseTotalExecutedPerDay(uint256) + bytes4 internal constant SET_LIMITS = 0x1558bff0; // setLimits(uint256[],uint256[]) + bytes4 internal constant SET_MAX_PER_TX = 0xc6f6f216; // setMaxPerTx(uint256) + bytes4 internal constant SET_MIN_PER_TX = 0xa2a6ca27; // setMinPerTx(uint256) + bytes4 internal constant SET_DAILY_LIMIT = 0xb20d30a9; // setDailyLimit(uint256) + bytes4 internal constant SET_EXECUTION_MAX_PER_TX = 0xf20151e1; // setExecutionMaxPerTx(uint256) + bytes4 internal constant SET_EXECUTION_MIN_PER_TX = 0xf56d2fec; // setExecutionMinPerTx(uint256) + bytes4 internal constant SET_EXECUTION_DAILY_LIMIT = 0x3dd95d1b; // setExecutionDailyLimit(uint256) + bytes4 internal constant SET_TARGET_LIMIT = 0x8253a36a; // setTargetLimit(uint256) + bytes4 internal constant SET_THRESHOLD = 0x960bfe04; // setThreshold(uint256) + bytes4 internal constant UPDATE_TODAY_LIMIT = 0x561fe5e3; // updateTodayLimit() - function totalSpentPerDay(uint256 _day) public view returns (uint256) { - return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))]; + function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { + _execute(SET_MAX_PER_TX, _maxPerTx); } - function totalExecutedPerDay(uint256 _day) public view returns (uint256) { - return uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", _day))]; + function setMinPerTx(uint256 _minPerTx) external onlyOwner { + _execute(SET_MIN_PER_TX, _minPerTx); } - function dailyLimit() public view returns (uint256) { - return uintStorage[DAILY_LIMIT]; + function setDailyLimit(uint256 _dailyLimit) external onlyOwner { + _execute(SET_DAILY_LIMIT, _dailyLimit); } - function executionDailyLimit() public view returns (uint256) { - return uintStorage[EXECUTION_DAILY_LIMIT]; + function setExecutionMaxPerTx(uint256 _maxPerTx) external onlyOwner { + _execute(SET_EXECUTION_MAX_PER_TX, _maxPerTx); } - function maxPerTx() public view returns (uint256) { - return uintStorage[MAX_PER_TX]; + function setExecutionMinPerTx(uint256 _minPerTx) external onlyOwner { + _execute(SET_EXECUTION_MIN_PER_TX, _minPerTx); } - function executionMaxPerTx() public view returns (uint256) { - return uintStorage[EXECUTION_MAX_PER_TX]; + function setExecutionDailyLimit(uint256 _dailyLimit) external onlyOwner { + _execute(SET_EXECUTION_DAILY_LIMIT, _dailyLimit); } - function minPerTx() public view returns (uint256) { - return uintStorage[MIN_PER_TX]; + function setTargetLimit(uint256 _targetLimit) external onlyOwner { + _execute(SET_EXECUTION_DAILY_LIMIT, _targetLimit); } - function executionMinPerTx() public view returns (uint256) { - return uintStorage[EXECUTION_MIN_PER_TX]; + function setThreshold(uint256 _threshold) external onlyOwner { + _execute(SET_EXECUTION_DAILY_LIMIT, _threshold); + } + + function limitsContract() public view returns (address) { + return addressStorage[LIMITS_CONTRACT]; } function decimalShift() public view returns (uint256) { return uintStorage[DECIMAL_SHIFT]; } + function maxPerTx() public view returns (uint256) { + return _getUint(GET_MAX_PER_TX); + } + + function minPerTx() public view returns (uint256) { + return _getUint(GET_MIN_PER_TX); + } + + function dailyLimit() public view returns (uint256) { + return _getUint(GET_DAILY_LIMIT); + } + + function executionMaxPerTx() public view returns (uint256) { + return _getUint(GET_EXECUTION_MAX_PER_TX); + } + + function executionMinPerTx() public view returns (uint256) { + return _getUint(GET_EXECUTION_MIN_PER_TX); + } + + function executionDailyLimit() public view returns (uint256) { + return _getUint(GET_EXECUTION_DAILY_LIMIT); + } + + function targetLimit() public view returns (uint256) { + return _getUint(GET_EXECUTION_DAILY_LIMIT); + } + + function threshold() public view returns (uint256) { + return _getUint(GET_EXECUTION_DAILY_LIMIT); + } + function withinLimit(uint256 _amount) public view returns (bool) { - uint256 nextLimit = totalSpentPerDay(getCurrentDay()).add(_amount); - return dailyLimit() >= nextLimit && _amount <= maxPerTx() && _amount >= minPerTx(); + return _getWithinLimit(GET_WITHIN_LIMIT, _amount); } function withinExecutionLimit(uint256 _amount) public view returns (bool) { - uint256 nextLimit = totalExecutedPerDay(getCurrentDay()).add(_amount); - return executionDailyLimit() >= nextLimit && _amount <= executionMaxPerTx(); + return _getWithinLimit(GET_WITHIN_EXECUTION_LIMIT, _amount); } - function getCurrentDay() public view returns (uint256) { - // solhint-disable-next-line not-rely-on-time - return now / 1 days; + function getTotalSpentPerDay(uint256 _day) public view returns (uint256) { + return _getUint(GET_TOTAL_SPENT_PER_DAY, _day); } - function setTotalSpentPerDay(uint256 _day, uint256 _value) internal { - uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))] = _value; + function getTotalExecutedPerDay(uint256 _day) public view returns (uint256) { + return _getUint(GET_TOTAL_EXECUTED_PER_DAY, _day); } - function setTotalExecutedPerDay(uint256 _day, uint256 _value) internal { - uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", _day))] = _value; + function _increaseTotalSpentPerDay(uint256 _amount) internal { + _execute(INCREASE_TOTAL_SPENT_PER_DAY, _amount); } - function setDailyLimit(uint256 _dailyLimit) external onlyOwner { - require(_dailyLimit > maxPerTx() || _dailyLimit == 0); - uintStorage[DAILY_LIMIT] = _dailyLimit; - emit DailyLimitChanged(_dailyLimit); + function _increaseTotalExecutedPerDay(uint256 _amount) internal { + _execute(INCREASE_TOTAL_EXECUTED_PER_DAY, _amount); } - function setExecutionDailyLimit(uint256 _dailyLimit) external onlyOwner { - require(_dailyLimit > executionMaxPerTx() || _dailyLimit == 0); - uintStorage[EXECUTION_DAILY_LIMIT] = _dailyLimit; - emit ExecutionDailyLimitChanged(_dailyLimit); + function _updateTodayLimit() internal { + _execute(UPDATE_TODAY_LIMIT); } - function setExecutionMaxPerTx(uint256 _maxPerTx) external onlyOwner { - require(_maxPerTx < executionDailyLimit()); - uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; + function _setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) internal { + require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); } - function setExecutionMinPerTx(uint256 _minPerTx) external onlyOwner { - require(_minPerTx < executionDailyLimit() && _minPerTx < executionMaxPerTx()); - uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; + function _execute(bytes4 _method, uint256 _value) internal { + _execute(abi.encodeWithSelector(_method, _value)); } - function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { - require(_maxPerTx < dailyLimit()); - uintStorage[MAX_PER_TX] = _maxPerTx; + function _execute(bytes4 _method) internal { + _execute(abi.encodeWithSelector(_method)); } - function setMinPerTx(uint256 _minPerTx) external onlyOwner { - require(_minPerTx < dailyLimit() && _minPerTx < maxPerTx()); - uintStorage[MIN_PER_TX] = _minPerTx; + function _execute(bytes memory _calldata) internal { + require(limitsContract().delegatecall(_calldata)); + } + + function _getUint(bytes4 _method) internal view returns (uint256) { + return _getUint(abi.encodeWithSelector(_method)); + } + + function _getUint(bytes4 _method, uint256 _param) internal view returns (uint256) { + return _getUint(abi.encodeWithSelector(_method, _param)); + } + + function _getUint(bytes memory _calldata) internal view returns (uint256) { + uint256 value; + address contractAddress = limitsContract(); + assembly { + let result := callcode(gas, contractAddress, 0x0, add(_calldata, 0x20), mload(_calldata), 0, 32) + value := mload(0) + + switch result + case 0 { + revert(0, 0) + } + } + return value; + } + + function _getWithinLimit(bytes4 _method, uint256 _amount) internal view returns (bool) { + bool value; + bytes memory callData = abi.encodeWithSelector(_method, _amount); + address contractAddress = limitsContract(); + assembly { + let result := callcode(gas, contractAddress, 0x0, add(callData, 0x20), mload(callData), 0, 8) + value := mload(0) + + switch result + case 0 { + revert(0, 0) + } + } + return value; } } diff --git a/contracts/upgradeable_contracts/ERC20Bridge.sol b/contracts/upgradeable_contracts/ERC20Bridge.sol index 5f77b3476..84519871c 100644 --- a/contracts/upgradeable_contracts/ERC20Bridge.sol +++ b/contracts/upgradeable_contracts/ERC20Bridge.sol @@ -21,7 +21,7 @@ contract ERC20Bridge is BasicForeignBridge { require(_receiver != address(this)); require(_amount > 0); require(withinLimit(_amount)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_amount)); + _increaseTotalSpentPerDay(_amount); erc20token().transferFrom(_sender, address(this), _amount); emit UserRequestForAffirmation(_receiver, _amount); diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index b20933538..8df6b6395 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -1,8 +1,8 @@ pragma solidity 0.4.24; -import "./BaseRelativeDailyLimit.sol"; +import "./BasicRelativeDailyLimit.sol"; -contract RelativeDailyLimit is BaseRelativeDailyLimit { +contract RelativeDailyLimit is BasicRelativeDailyLimit { function _minPerTx() internal view returns (uint256) { return minPerTx(); } @@ -11,12 +11,12 @@ contract RelativeDailyLimit is BaseRelativeDailyLimit { return _getTodayLimit(); } - function setMinPerTx(uint256 _minPerTx) external onlyOwner { + function setMinPerTx(uint256 _minPerTx) external { require(_minPerTx < maxPerTx()); uintStorage[MIN_PER_TX] = _minPerTx; } - function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { + function setMaxPerTx(uint256 _maxPerTx) external { require(_maxPerTx > minPerTx() || _maxPerTx == 0); uintStorage[MAX_PER_TX] = _maxPerTx; } diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol index 10964fe43..f1cbf7b4a 100644 --- a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -1,8 +1,8 @@ pragma solidity 0.4.24; -import "./BaseRelativeDailyLimit.sol"; +import "./BasicRelativeDailyLimit.sol"; -contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { +contract RelativeExecutionDailyLimit is BasicRelativeDailyLimit { function _minPerTx() internal view returns (uint256) { return executionMinPerTx(); } @@ -11,12 +11,12 @@ contract RelativeExecutionDailyLimit is BaseRelativeDailyLimit { return _getTodayLimit(); } - function setExecutionMinPerTx(uint256 _minPerTx) external onlyOwner { + function setExecutionMinPerTx(uint256 _minPerTx) external { require(_minPerTx < executionMaxPerTx()); uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; } - function setExecutionMaxPerTx(uint256 _maxPerTx) external onlyOwner { + function setExecutionMaxPerTx(uint256 _maxPerTx) external { require(_maxPerTx > executionMinPerTx() || _maxPerTx == 0); uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 64ff7490d..3c204264e 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -37,29 +37,12 @@ contract BasicAMBErc677ToErc677 is uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] uint256 _requestGasLimit, uint256 _decimalShift, - address _owner + address _owner, + address _limitsContract ) external returns (bool) { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); } @@ -114,7 +97,7 @@ contract BasicAMBErc677ToErc677 is ERC677 token = erc677token(); address to = address(this); require(withinLimit(_value)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_value)); + _increaseTotalSpentPerDay(_value); setLock(true); token.transferFrom(_from, to, _value); @@ -131,7 +114,7 @@ contract BasicAMBErc677ToErc677 is require(msg.sender == address(token)); if (!lock()) { require(withinLimit(_value)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_value)); + _increaseTotalSpentPerDay(_value); } bridgeSpecificActionsOnTokenTransfer(token, _from, _value, _data); return true; @@ -235,7 +218,7 @@ contract BasicAMBErc677ToErc677 is require(msg.sender == address(bridgeContract())); require(messageSender() == mediatorContractOnOtherSide()); if (withinExecutionLimit(_value)) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_value)); + _increaseTotalExecutedPerDay(_value); executeActionOnBridgedTokens(_recipient, _value); } else { bytes32 txHash = transactionHash(); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 22bfefade..97c38a247 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -9,7 +9,6 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] address _owner, uint256 _decimalShift ) internal { @@ -17,11 +16,6 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[1] < _requestLimitsArray[0] // _maxPerTx < _dailyLimit - ); require(_owner != address(0)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; @@ -30,16 +24,11 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; uintStorage[DECIMAL_SHIFT] = _decimalShift; - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; setOwner(_owner); setInitialize(); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - - emit DailyLimitChanged(_requestLimitsArray[0]); } function getBridgeMode() external pure returns (bytes4 _data) { @@ -56,7 +45,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uint256 _amount, bytes32 /*_txHash*/ ) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_amount)); + _increaseTotalExecutedPerDay(_amount); uint256 amount = _amount.div(10**decimalShift()); return erc20token().transfer(_recipient, amount); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index a3004f91a..6c7881f88 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -12,30 +12,20 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { - require( - _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit - ); - - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _requestLimitsArray, _owner, _decimalShift ); - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - return isInitialized(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index 2adae3c10..7e178b723 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -12,30 +12,20 @@ contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { - require( - _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit - ); - - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _requestLimitsArray, _owner, _decimalShift ); - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - return isInitialized(); } } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 647bf3165..94bdef101 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -23,8 +23,11 @@ contract HomeBridgeErcToErc is address _erc677token, uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, @@ -40,25 +43,23 @@ contract HomeBridgeErcToErc is } function rewardableInitialize( - address _validatorContract, + address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract ] uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - address _erc677token, uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, - address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) external returns (bool) { + require(AddressUtils.isContract(_contracts[3])); + addressStorage[LIMITS_CONTRACT] = _contracts[3]; _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( - _validatorContract, + _contracts, _homeGasPrice, _requiredBlockConfirmations, - _erc677token, _owner, - _feeManager, _homeFeeForeignFeeArray, _decimalShift ); @@ -68,53 +69,25 @@ contract HomeBridgeErcToErc is } function _rewardableInitialize( - address _validatorContract, + address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract, 4 = _blockReward ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - address _erc677token, address _owner, - address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift ) internal { _initialize( - _validatorContract, + _contracts[0], _homeGasPrice, _requiredBlockConfirmations, - _erc677token, + _contracts[1], _owner, _decimalShift ); - require(AddressUtils.isContract(_feeManager)); - addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; - _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); - _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - } - - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); + require(AddressUtils.isContract(_contracts[2])); + addressStorage[FEE_MANAGER_CONTRACT] = _contracts[2]; + _setFee(_contracts[2], _homeFeeForeignFeeArray[0], HOME_FEE); + _setFee(_contracts[2], _homeFeeForeignFeeArray[1], FOREIGN_FEE); } function _initialize( @@ -150,7 +123,7 @@ contract HomeBridgeErcToErc is } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_value)); + _increaseTotalExecutedPerDay(_value); uint256 valueToMint = _value.mul(10**decimalShift()); address feeManager = feeManagerContract(); if (feeManager != address(0)) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 7b99c3885..293360dfb 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -7,30 +7,27 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { bytes4 internal constant SET_BLOCK_REWARD_CONTRACT = 0x27a3e16b; // setBlockRewardContract(address) function rewardableInitialize( - address _validatorContract, + address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract, 4 = _blockReward ] uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - address _erc677token, uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, - address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - address _blockReward, uint256 _decimalShift ) external returns (bool) { + require(AddressUtils.isContract(_contracts[3])); + addressStorage[LIMITS_CONTRACT] = _contracts[3]; _setLimits(_requestLimitsArray, _executionLimitsArray); _rewardableInitialize( - _validatorContract, + _contracts, _homeGasPrice, _requiredBlockConfirmations, - _erc677token, _owner, - _feeManager, _homeFeeForeignFeeArray, _decimalShift ); - _setBlockRewardContract(_feeManager, _blockReward); + _setBlockRewardContract(_contracts[2], _contracts[4]); setInitialize(); return isInitialized(); diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 1b044b72d..e71acf79b 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -14,30 +14,21 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB uint256 _requiredBlockConfirmations, uint256 _gasPrice, uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, //[ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift, - address _bridgeOnOtherSide + address _bridgeOnOtherSide, + address _limitsContract ) external returns (bool) { - require( - _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit - ); - - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); return _initialize( _validatorContract, _erc20token, _requiredBlockConfirmations, _gasPrice, - _requestLimitsArray, _owner, _decimalShift, _bridgeOnOtherSide @@ -49,7 +40,6 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] address _owner, uint256 _decimalShift, address _bridgeOnOtherSide @@ -58,11 +48,6 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); require(_owner != address(0)); require(_bridgeOnOtherSide != address(0)); @@ -71,9 +56,6 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB uintStorage[DEPLOYED_AT_BLOCK] = block.number; uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; uintStorage[GAS_PRICE] = _gasPrice; - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); @@ -81,7 +63,6 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); - emit DailyLimitChanged(_requestLimitsArray[0]); return isInitialized(); } @@ -100,7 +81,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB uint256 _amount, bytes32 /*_txHash*/ ) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_amount)); + _increaseTotalExecutedPerDay(_amount); uint256 amount = _amount.div(10**decimalShift()); return erc20token().transfer(_recipient, amount); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index f064f579b..ea7481c6c 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -29,7 +29,7 @@ contract HomeBridgeErcToNative is uint256 totalMinted = blockReward.mintedTotallyByBridge(address(this)); uint256 totalBurnt = totalBurntCoins(); require(msg.value <= totalMinted.sub(totalBurnt)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(msg.value)); + _increaseTotalSpentPerDay(msg.value); uint256 valueToTransfer = msg.value; address feeManager = feeManagerContract(); uint256 valueToBurn = msg.value; @@ -55,8 +55,11 @@ contract HomeBridgeErcToNative is address _blockReward, uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, @@ -81,8 +84,11 @@ contract HomeBridgeErcToNative is address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, @@ -117,32 +123,6 @@ contract HomeBridgeErcToNative is _setBlockRewardContract(_blockReward); } - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - function _initialize( address _validatorContract, uint256 _homeGasPrice, @@ -170,7 +150,7 @@ contract HomeBridgeErcToNative is } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_value)); + _increaseTotalExecutedPerDay(_value); IBlockReward blockReward = blockRewardContract(); require(blockReward != address(0)); uint256 valueToMint = _value.mul(10**decimalShift()); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 40afef089..ed43ccca4 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -20,8 +20,11 @@ contract ForeignBridgeNativeToErc is uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] address _owner, uint256 _decimalShift, - address _bridgeOnOtherSide + address _bridgeOnOtherSide, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, @@ -47,8 +50,11 @@ contract ForeignBridgeNativeToErc is address _feeManager, uint256 _homeFee, uint256 _decimalShift, - address _bridgeOnOtherSide + address _bridgeOnOtherSide, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize( _validatorContract, @@ -74,32 +80,6 @@ contract ForeignBridgeNativeToErc is IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to); } - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - ) internal { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - function _initialize( address _validatorContract, address _erc677token, @@ -129,7 +109,7 @@ contract ForeignBridgeNativeToErc is } function onExecuteMessage(address _recipient, uint256 _amount, bytes32 _txHash) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_amount)); + _increaseTotalExecutedPerDay(_amount); uint256 valueToMint = _amount.div(10**decimalShift()); address feeManager = feeManagerContract(); if (feeManager != address(0)) { diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 4f4fb1058..b53514997 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -15,7 +15,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom function nativeTransfer(address _receiver) internal { require(msg.value > 0); require(withinLimit(msg.value)); - setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(msg.value)); + _increaseTotalSpentPerDay(msg.value); uint256 valueToTransfer = msg.value; address feeManager = feeManagerContract(); if (feeManager != address(0)) { @@ -36,8 +36,11 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256 _requiredBlockConfirmations, uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] address _owner, - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); setInitialize(); @@ -53,8 +56,11 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift + uint256 _decimalShift, + address _limitsContract ) external returns (bool) { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); require(AddressUtils.isContract(_feeManager)); @@ -69,32 +75,6 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom return 0x92a8d7fe; // bytes4(keccak256(abi.encodePacked("native-to-erc-core"))) } - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - function _initialize( address _validatorContract, uint256 _homeGasPrice, @@ -135,7 +115,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom } function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { - setTotalExecutedPerDay(getCurrentDay(), totalExecutedPerDay(getCurrentDay()).add(_value)); + _increaseTotalExecutedPerDay(_value); uint256 valueToTransfer = _value.mul(10**decimalShift()); address feeManager = feeManagerContract(); From 9797e068c01ea0744c98567aded9a52e2bcf0196 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 10 Dec 2019 15:22:57 +0300 Subject: [PATCH 53/80] support absolute and relative limit in one implementation (remove duplicates) --- .../upgradeable_contracts/BasicLimits.sol | 46 ++++--- .../BasicRelativeDailyLimit.sol | 21 ++- .../BasicTokenBridge.sol | 36 ++--- .../RelativeDailyLimit.sol | 19 ++- .../RelativeExecutionDailyLimit.sol | 19 ++- .../BasicAMBErc677ToErc677.sol | 27 ++-- .../ForeignAMBErc677ToErc677.sol | 9 ++ ...ignAMBErc677ToErc677RelativeDailyLimit.sol | 50 ------- .../HomeAMBErc677ToErc677.sol | 14 ++ ...omeAMBErc677ToErc677RelativeDailyLimit.sol | 55 -------- .../BasicForeignBridgeErcToErc.sol | 28 +++- ...oreignBridgeErcToErcRelativeDailyLimit.sol | 15 -- .../ForeignBridgeErc677ToErc677.sol | 25 ---- ...BridgeErc677ToErc677RelativeDailyLimit.sol | 45 ------ .../erc20_to_erc20/ForeignBridgeErcToErc.sol | 28 +--- ...oreignBridgeErcToErcRelativeDailyLimit.sol | 45 ------ .../erc20_to_erc20/HomeBridgeErcToErc.sol | 128 ++++++++---------- .../HomeBridgeErcToErcPOSDAO.sol | 35 +++-- ...BridgeErcToErcPOSDAORelativeDailyLimit.sol | 37 ----- .../HomeBridgeErcToErcRelativeDailyLimit.sol | 94 ------------- .../ForeignBridgeErcToNative.sol | 45 +++--- ...ignBridgeErcToNativeRelativeDailyLimit.sol | 51 ------- .../erc20_to_native/HomeBridgeErcToNative.sol | 99 ++++++-------- ...omeBridgeErcToNativeRelativeDailyLimit.sol | 99 -------------- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 14 -- .../ForeignBridgeNativeToErc.sol | 105 +++++++------- ...ignBridgeNativeToErcRelativeDailyLimit.sol | 97 ------------- .../native_to_erc20/HomeBridgeNativeToErc.sol | 36 +++-- ...omeBridgeNativeToErcRelativeDailyLimit.sol | 78 ----------- 29 files changed, 361 insertions(+), 1039 deletions(-) delete mode 100644 contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol delete mode 100644 contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol diff --git a/contracts/upgradeable_contracts/BasicLimits.sol b/contracts/upgradeable_contracts/BasicLimits.sol index 2f57ab486..2274455f5 100644 --- a/contracts/upgradeable_contracts/BasicLimits.sol +++ b/contracts/upgradeable_contracts/BasicLimits.sol @@ -16,31 +16,37 @@ contract BasicLimits is EternalStorage { bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // keccak256(abi.encodePacked("executionMaxPerTx")) bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // keccak256(abi.encodePacked("executionDailyLimit")) - function setLimits( - uint256[] _requestLimitsArray, // [ 0 = _requestDailyLimit, 1 = _requestMaxPerTx, 2 = _requestMinPerTx ] - uint256[] _executionLimitsArray // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] - ) external { + function setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) external { + _setRequestLimits(_requestLimitsArray); + _setExecutionLimits(_executionLimitsArray); + } + + function _setRequestLimits( + uint256[] _requestLimitsArray // [ 0 = _requestDailyLimit, 1 = _requestMaxPerTx, 2 = _requestMinPerTx ] + ) internal { require( _requestLimitsArray[2] > 0 && // _requestMinPerTx > 0 _requestLimitsArray[1] > _requestLimitsArray[2] && // _requestMaxPerTx > _requestMinPerTx _requestLimitsArray[0] > _requestLimitsArray[1] // _requestDailyLimit > _requestMaxPerTx ); + uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; + emit DailyLimitChanged(_requestLimitsArray[0]); + } + + function _setExecutionLimits( + uint256[] _executionLimitsArray // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + ) internal { require( _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx _executionLimitsArray[0] > _executionLimitsArray[1] // _foreignDailyLimit > _foreignMaxPerTx ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit DailyLimitChanged(_requestLimitsArray[0]); emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } function totalSpentPerDay(uint256 _day) public view returns (uint256) { @@ -52,10 +58,18 @@ contract BasicLimits is EternalStorage { } function dailyLimit() public view returns (uint256) { + return dailyLimit(0); + } + + function dailyLimit(uint256) public view returns (uint256) { return uintStorage[DAILY_LIMIT]; } function executionDailyLimit() public view returns (uint256) { + return executionDailyLimit(0); + } + + function executionDailyLimit(uint256) public view returns (uint256) { return uintStorage[EXECUTION_DAILY_LIMIT]; } @@ -75,14 +89,14 @@ contract BasicLimits is EternalStorage { return uintStorage[EXECUTION_MIN_PER_TX]; } - function withinLimit(uint256 _amount) public view returns (bool) { + function withinLimit(uint256 _amount, uint256 _tokenBalance) public view returns (bool) { uint256 nextLimit = totalSpentPerDay(getCurrentDay()).add(_amount); - return dailyLimit() >= nextLimit && _amount <= maxPerTx() && _amount >= minPerTx(); + return dailyLimit(_tokenBalance) >= nextLimit && _amount <= maxPerTx() && _amount >= minPerTx(); } - function withinExecutionLimit(uint256 _amount) public view returns (bool) { + function withinExecutionLimit(uint256 _amount, uint256 _tokenBalance) public view returns (bool) { uint256 nextLimit = totalExecutedPerDay(getCurrentDay()).add(_amount); - return executionDailyLimit() >= nextLimit && _amount <= executionMaxPerTx(); + return executionDailyLimit(_tokenBalance) >= nextLimit && _amount <= executionMaxPerTx(); } function getCurrentDay() public view returns (uint256) { @@ -132,5 +146,5 @@ contract BasicLimits is EternalStorage { uintStorage[MIN_PER_TX] = _minPerTx; } - function updateTodayLimit() external {} + function updateTodayLimit(uint256) public {} } diff --git a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol index 52d028921..3170b57ca 100644 --- a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol @@ -13,16 +13,15 @@ contract BasicRelativeDailyLimit is BasicLimits { bytes32 internal constant TARGET_LIMIT = 0x192ac2d88a9de45ce541663ebe1aaf6d6b1d4a6299d3fd0abf2ba7e8b920342b; // keccak256(abi.encodePacked("targetLimit")) bytes32 internal constant THRESHOLD = 0xd46c2b20c7303c2e50535d224276492e8a1eda2a3d7398e0bea254640c1154e7; // keccak256(abi.encodePacked("threshold")) - function _calculateLimit() internal view returns (uint256) { - uint256 balance = _getTokenBalance(); + function _calculateLimit(uint256 _balance) internal view returns (uint256) { uint256 unlimitedBalance = _minPerTx(); - if (balance <= unlimitedBalance) { - return balance; + if (_balance <= unlimitedBalance) { + return _balance; } uint256 limit = targetLimit(); uint256 thresh = threshold(); uint256 multiplier = 1 ether**2; - if (balance < thresh) { + if (_balance < thresh) { // to save the gas we don't need to use safe math here // because we check in setters that limit is always less than 1 ether // and threshold is greater than minPerTx @@ -30,9 +29,9 @@ contract BasicRelativeDailyLimit is BasicLimits { uint256 a = ((1 ether - limit) * multiplier) / (thresh - unlimitedBalance)**2; uint256 b = 2 * a * thresh; uint256 c = (limit * multiplier) + a * thresh**2; - limit = (a * balance**2 - b * balance + c) / multiplier; + limit = (a * _balance**2 - b * _balance + c) / multiplier; } - return (balance * limit) / 1 ether; + return (_balance * limit) / 1 ether; } function targetLimit() public view returns (uint256) { @@ -55,19 +54,19 @@ contract BasicRelativeDailyLimit is BasicLimits { emit ThresholdChanged(_threshold); } - function _updateTodayLimit() internal { + function updateTodayLimit(uint256 _balance) public { if (_todayLimit() == 0) { - uint256 limit = _calculateLimit(); + uint256 limit = _calculateLimit(_balance); _setTodayLimit(limit); emit TodayLimitSet(limit); } } - function _getTodayLimit() internal view returns (uint256) { + function _getTodayLimit(uint256 _tokenBalance) internal view returns (uint256) { uint256 limit = _todayLimit(); if (limit == 0) { // not set yet - limit = _calculateLimit(); + limit = _calculateLimit(_tokenBalance); } return limit; } diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 90531975c..7b6a67003 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -12,15 +12,15 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes4 internal constant GET_MAX_PER_TX = 0xf968adbe; // maxPerTx() bytes4 internal constant GET_MIN_PER_TX = 0xdf25f3f0; // minPerTx() - bytes4 internal constant GET_DAILY_LIMIT = 0x67eeba0c; // dailyLimit() + bytes4 internal constant GET_DAILY_LIMIT = 0x56ee0405; // dailyLimit(uint256) bytes4 internal constant GET_EXECUTION_MAX_PER_TX = 0x8aa1949a; // executionMaxPerTx() bytes4 internal constant GET_EXECUTION_MIN_PER_TX = 0x35b00293; // executionMinPerTx() - bytes4 internal constant GET_EXECUTION_DAILY_LIMIT = 0x43b37dd3; // executionDailyLimit() + bytes4 internal constant GET_EXECUTION_DAILY_LIMIT = 0x5cd79c3a; // executionDailyLimit(uint256) bytes4 internal constant GET_TARGET_LIMIT = 0xa70021f3; // targetLimit() bytes4 internal constant GET_THRESHOLD = 0x42cde4e8; // threshold() - bytes4 internal constant GET_WITHIN_LIMIT = 0xea9f4968; // withinLimit(uint256) - bytes4 internal constant GET_WITHIN_EXECUTION_LIMIT = 0x879ce676; // withinExecutionLimit(uint256) - bytes4 internal constant GET_TOTAL_SPENT_PER_DAY = 0x2bd0bb05; // totalSpentPerDay(uint256) + bytes4 internal constant GET_WITHIN_LIMIT = 0x894d5ea8; // withinLimit(uint256) + bytes4 internal constant GET_WITHIN_EXECUTION_LIMIT = 0x879ce676; // withinExecutionLimit(uint256,uint256) + bytes4 internal constant GET_TOTAL_SPENT_PER_DAY = 0x84e43616; // totalSpentPerDay(uint256,uint256) bytes4 internal constant GET_TOTAL_EXECUTED_PER_DAY = 0x4fb3fef7; // totalExecutedPerDay(uint256) bytes4 internal constant INCREASE_TOTAL_SPENT_PER_DAY = 0xb47584cd; // increaseTotalSpentPerDay(uint256) bytes4 internal constant INCREASE_TOTAL_EXECUTED_PER_DAY = 0x79d9623a; // increaseTotalExecutedPerDay(uint256) @@ -33,7 +33,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes4 internal constant SET_EXECUTION_DAILY_LIMIT = 0x3dd95d1b; // setExecutionDailyLimit(uint256) bytes4 internal constant SET_TARGET_LIMIT = 0x8253a36a; // setTargetLimit(uint256) bytes4 internal constant SET_THRESHOLD = 0x960bfe04; // setThreshold(uint256) - bytes4 internal constant UPDATE_TODAY_LIMIT = 0x561fe5e3; // updateTodayLimit() + bytes4 internal constant UPDATE_TODAY_LIMIT = 0x0097eff6; // updateTodayLimit(uint256) function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { _execute(SET_MAX_PER_TX, _maxPerTx); @@ -84,7 +84,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function dailyLimit() public view returns (uint256) { - return _getUint(GET_DAILY_LIMIT); + return _getUint(GET_DAILY_LIMIT, _getTokenBalance()); } function executionMaxPerTx() public view returns (uint256) { @@ -96,7 +96,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function executionDailyLimit() public view returns (uint256) { - return _getUint(GET_EXECUTION_DAILY_LIMIT); + return _getUint(GET_EXECUTION_DAILY_LIMIT, _getTokenBalance()); } function targetLimit() public view returns (uint256) { @@ -108,11 +108,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function withinLimit(uint256 _amount) public view returns (bool) { - return _getWithinLimit(GET_WITHIN_LIMIT, _amount); + return _getWithinLimit(GET_WITHIN_LIMIT, _amount, _getTokenBalance()); } function withinExecutionLimit(uint256 _amount) public view returns (bool) { - return _getWithinLimit(GET_WITHIN_EXECUTION_LIMIT, _amount); + return _getWithinLimit(GET_WITHIN_EXECUTION_LIMIT, _amount, _getTokenBalance()); } function getTotalSpentPerDay(uint256 _day) public view returns (uint256) { @@ -132,7 +132,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function _updateTodayLimit() internal { - _execute(UPDATE_TODAY_LIMIT); + _execute(UPDATE_TODAY_LIMIT, _getTokenBalance()); } function _setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) internal { @@ -140,16 +140,10 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function _execute(bytes4 _method, uint256 _value) internal { - _execute(abi.encodeWithSelector(_method, _value)); - } - - function _execute(bytes4 _method) internal { - _execute(abi.encodeWithSelector(_method)); + require(limitsContract().delegatecall(abi.encodeWithSelector(_method, _value))); } - function _execute(bytes memory _calldata) internal { - require(limitsContract().delegatecall(_calldata)); - } + function _getTokenBalance() internal view returns (uint256) {} function _getUint(bytes4 _method) internal view returns (uint256) { return _getUint(abi.encodeWithSelector(_method)); @@ -174,9 +168,9 @@ contract BasicTokenBridge is EternalStorage, Ownable { return value; } - function _getWithinLimit(bytes4 _method, uint256 _amount) internal view returns (bool) { + function _getWithinLimit(bytes4 _method, uint256 _amount, uint256 _tokenBalance) internal view returns (bool) { bool value; - bytes memory callData = abi.encodeWithSelector(_method, _amount); + bytes memory callData = abi.encodeWithSelector(_method, _amount, _tokenBalance); address contractAddress = limitsContract(); assembly { let result := callcode(gas, contractAddress, 0x0, add(callData, 0x20), mload(callData), 0, 8) diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index 8df6b6395..a6a4adb8c 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -3,12 +3,27 @@ pragma solidity 0.4.24; import "./BasicRelativeDailyLimit.sol"; contract RelativeDailyLimit is BasicRelativeDailyLimit { + function _setRequestLimits( + uint256[] _requestLimitsArray // [ 0 = _targetLimit, 1 = _threshold, 2 = _requestMaxPerTx, 3 = _requestMinPerTx ] + ) internal { + require( + _requestLimitsArray[3] > 0 && // _requestMinPerTx > 0 + _requestLimitsArray[2] > _requestLimitsArray[3] && // _requestMaxPerTx > _requestMinPerTx + _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _requestMinPerTx + _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether + ); + uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; + uintStorage[THRESHOLD] = _requestLimitsArray[1]; + uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; + uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; + } + function _minPerTx() internal view returns (uint256) { return minPerTx(); } - function dailyLimit() public view returns (uint256) { - return _getTodayLimit(); + function dailyLimit(uint256 _tokenBalance) public view returns (uint256) { + return _getTodayLimit(_tokenBalance); } function setMinPerTx(uint256 _minPerTx) external { diff --git a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol index f1cbf7b4a..472b54aa8 100644 --- a/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol @@ -3,12 +3,27 @@ pragma solidity 0.4.24; import "./BasicRelativeDailyLimit.sol"; contract RelativeExecutionDailyLimit is BasicRelativeDailyLimit { + function _setExecutionLimits( + uint256[] _executionLimitsArray // [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + ) internal { + require( + _executionLimitsArray[3] > 0 && // _executionMinPerTx > 0 + _executionLimitsArray[2] > _executionLimitsArray[3] && // _executionMaxPerTx > _executionMinPerTx + _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _executionMinPerTx + _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether + ); + uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; + uintStorage[THRESHOLD] = _executionLimitsArray[1]; + uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; + uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; + } + function _minPerTx() internal view returns (uint256) { return executionMinPerTx(); } - function executionDailyLimit() public view returns (uint256) { - return _getTodayLimit(); + function executionDailyLimit(uint256 _tokenBalance) public view returns (uint256) { + return _getTodayLimit(_tokenBalance); } function setExecutionMinPerTx(uint256 _minPerTx) external { diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 3c204264e..cedbbb4be 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -33,28 +33,19 @@ contract BasicAMBErc677ToErc677 is address _bridgeContract, address _mediatorContract, address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, + // absolute: [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _executionLimitsArray, uint256 _requestGasLimit, uint256 _decimalShift, address _owner, address _limitsContract ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); - } - - function _initialize( - address _bridgeContract, - address _mediatorContract, - address _erc677token, - uint256 _requestGasLimit, - uint256 _decimalShift, - address _owner - ) internal returns (bool) { require(!isInitialized()); + require(AddressUtils.isContract(_limitsContract)); _setBridgeContract(_bridgeContract); _setMediatorContractOnOtherSide(_mediatorContract); @@ -63,8 +54,10 @@ contract BasicAMBErc677ToErc677 is uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); setNonce(keccak256(abi.encodePacked(address(this)))); - setInitialize(); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); + setInitialize(); return isInitialized(); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol index 7b79ecd62..e66e24c59 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol @@ -22,4 +22,13 @@ contract ForeignAMBErc677ToErc677 is BasicAMBErc677ToErc677 { function executeActionOnFixedTokens(address _recipient, uint256 _value) internal { erc677token().transfer(_recipient, _value); } + + function handleBridgedTokens(address _recipient, uint256 _value, bytes32 _nonce) public { + _updateTodayLimit(); + super.handleBridgedTokens(_recipient, _value, _nonce); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc677token().balanceOf(address(this)); + } } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol deleted file mode 100644 index 1fa39f435..000000000 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol +++ /dev/null @@ -1,50 +0,0 @@ -pragma solidity 0.4.24; - -import "./ForeignAMBErc677ToErc677.sol"; -import "../RelativeExecutionDailyLimit.sol"; - -contract ForeignAMBErc677ToErc677RelativeDailyLimit is ForeignAMBErc677ToErc677, RelativeExecutionDailyLimit { - function handleBridgedTokens(address _recipient, uint256 _value, bytes32 _nonce) public { - _updateTodayLimit(); - super.handleBridgedTokens(_recipient, _value, _nonce); - } - - function initialize( - address _bridgeContract, - address _mediatorContract, - address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] - uint256 _requestGasLimit, - uint256 _decimalShift, - address _owner - ) external returns (bool) { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[3] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _executionMaxPerTx > _executionMinPerTx - _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _executionMinPerTx - _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; - uintStorage[THRESHOLD] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - - return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc677token().balanceOf(address(this)); - } -} diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol index 8475523d6..9146981b3 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol @@ -19,4 +19,18 @@ contract HomeAMBErc677ToErc677 is BasicAMBErc677ToErc677 { function executeActionOnFixedTokens(address _recipient, uint256 _value) internal { IBurnableMintableERC677Token(erc677token()).mint(_recipient, _value); } + + function _relayTokens(address _from, address _receiver, uint256 _value) internal { + _updateTodayLimit(); + super._relayTokens(_from, _receiver, _value); + } + + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol deleted file mode 100644 index fb8a05683..000000000 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol +++ /dev/null @@ -1,55 +0,0 @@ -pragma solidity 0.4.24; - -import "./HomeAMBErc677ToErc677.sol"; -import "../RelativeDailyLimit.sol"; - -contract HomeAMBErc677ToErc677RelativeDailyLimit is HomeAMBErc677ToErc677, RelativeDailyLimit { - function _relayTokens(address _from, address _receiver, uint256 _value) internal { - _updateTodayLimit(); - super._relayTokens(_from, _receiver, _value); - } - - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - - function initialize( - address _bridgeContract, - address _mediatorContract, - address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] - uint256 _requestGasLimit, - uint256 _decimalShift, - address _owner - ) external returns (bool) { - require( - _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx - _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx - _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - require( - _executionLimitsArray[2] > 0 && // _executionMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _executionMaxPerTx > _executionMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _executionMaxPerTx < _executionDailyLimit - ); - - uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; - uintStorage[THRESHOLD] = _requestLimitsArray[1]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - - return _initialize(_bridgeContract, _mediatorContract, _erc677token, _requestGasLimit, _decimalShift, _owner); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc677token().totalSupply(); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 97c38a247..b7585383c 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -4,19 +4,26 @@ import "../BasicForeignBridge.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; contract BasicForeignBridgeErcToErc is BasicForeignBridge { - function _initialize( + function initialize( address _validatorContract, address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, + // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, + // absolute: [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _executionLimitsArray, address _owner, - uint256 _decimalShift - ) internal { + uint256 _decimalShift, + address _limitsContract + ) external returns (bool) { require(!isInitialized()); require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); require(_owner != address(0)); + require(AddressUtils.isContract(_limitsContract)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; setErc20token(_erc20token); @@ -25,10 +32,14 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[GAS_PRICE] = _gasPrice; uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); - setInitialize(); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); + + setInitialize(); + return isInitialized(); } function getBridgeMode() external pure returns (bytes4 _data) { @@ -54,6 +65,15 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { revert(); } + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { + _updateTodayLimit(); + super.executeSignatures(vs, rs, ss, message); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc20token().balanceOf(address(this)); + } + /* solcov ignore next */ function erc20token() public view returns (ERC20); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol deleted file mode 100644 index 08e0fafe9..000000000 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma solidity 0.4.24; - -import "./BasicForeignBridgeErcToErc.sol"; -import "../RelativeExecutionDailyLimit.sol"; - -contract BasicForeignBridgeErcToErcRelativeDailyLimit is BasicForeignBridgeErcToErc, RelativeExecutionDailyLimit { - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { - _updateTodayLimit(); - super.executeSignatures(vs, rs, ss, message); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc20token().balanceOf(address(this)); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol index 6c7881f88..1e3a8f809 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol @@ -4,31 +4,6 @@ import "./BasicForeignBridgeErcToErc.sol"; import "../ERC677Bridge.sol"; contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc { - function initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx] - address _owner, - uint256 _decimalShift, - address _limitsContract - ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); - return isInitialized(); - } - function erc20token() public view returns (ERC20) { return erc677token(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol deleted file mode 100644 index 34cc43e59..000000000 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol +++ /dev/null @@ -1,45 +0,0 @@ -pragma solidity 0.4.24; - -import "./ForeignBridgeErc677ToErc677.sol"; -import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; - -// solhint-disable-next-line no-empty-blocks -contract ForeignBridgeErc677ToErc677RelativeDailyLimit is - BasicForeignBridgeErcToErcRelativeDailyLimit, - ForeignBridgeErc677ToErc677 -{ - function initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx] - address _owner, - uint256 _decimalShift - ) external returns (bool) { - require( - _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx - _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - - uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; - uintStorage[THRESHOLD] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _requestLimitsArray, - _owner, - _decimalShift - ); - - return isInitialized(); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol index 7e178b723..5bcab457e 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErc.sol @@ -3,29 +3,5 @@ pragma solidity 0.4.24; import "./BasicForeignBridgeErcToErc.sol"; import "../ERC20Bridge.sol"; -contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge { - function initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - address _owner, - uint256 _decimalShift, - address _limitsContract - ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift - ); - return isInitialized(); - } -} +// solhint-disable-next-line no-empty-blocks +contract ForeignBridgeErcToErc is BasicForeignBridgeErcToErc, ERC20Bridge {} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol deleted file mode 100644 index 7a93b95ab..000000000 --- a/contracts/upgradeable_contracts/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,45 +0,0 @@ -pragma solidity 0.4.24; - -import "./ForeignBridgeErcToErc.sol"; -import "./BasicForeignBridgeErcToErcRelativeDailyLimit.sol"; - -// solhint-disable-next-line no-empty-blocks -contract ForeignBridgeErcToErcRelativeDailyLimit is - BasicForeignBridgeErcToErcRelativeDailyLimit, - ForeignBridgeErcToErc -{ - function initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _homeMaxPerTx, 3 = _homeMinPerTx ] - address _owner, - uint256 _decimalShift - ) external returns (bool) { - require( - _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx - _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - - uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; - uintStorage[THRESHOLD] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _requestLimitsArray, - _owner, - _decimalShift - ); - - return isInitialized(); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 94bdef101..dbdc98f9d 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -17,101 +17,72 @@ contract HomeBridgeErcToErc is { function initialize( address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, uint256 _decimalShift, address _limitsContract - ) external returns (bool) { + ) public returns (bool) { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_owner != address(0)); require(AddressUtils.isContract(_limitsContract)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _homeGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; + uintStorage[DECIMAL_SHIFT] = _decimalShift; + setOwner(_owner); + setErc677token(_erc677token); addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _erc677token, - _owner, - _decimalShift - ); - setInitialize(); - return isInitialized(); - } + emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); + emit GasPriceChanged(_homeGasPrice); - function rewardableInitialize( - address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract ] - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) external returns (bool) { - require(AddressUtils.isContract(_contracts[3])); - addressStorage[LIMITS_CONTRACT] = _contracts[3]; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _rewardableInitialize( - _contracts, - _homeGasPrice, - _requiredBlockConfirmations, - _owner, - _homeFeeForeignFeeArray, - _decimalShift - ); setInitialize(); - return isInitialized(); } - function _rewardableInitialize( - address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract, 4 = _blockReward ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _owner, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) internal { - _initialize( - _contracts[0], - _homeGasPrice, - _requiredBlockConfirmations, - _contracts[1], - _owner, - _decimalShift - ); - require(AddressUtils.isContract(_contracts[2])); - addressStorage[FEE_MANAGER_CONTRACT] = _contracts[2]; - _setFee(_contracts[2], _homeFeeForeignFeeArray[0], HOME_FEE); - _setFee(_contracts[2], _homeFeeForeignFeeArray[1], FOREIGN_FEE); - } - - function _initialize( + function rewardableInitialize( address _validatorContract, + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _erc677token, + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, - uint256 _decimalShift - ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations > 0); - require(_owner != address(0)); - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; - uintStorage[GAS_PRICE] = _homeGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - uintStorage[DECIMAL_SHIFT] = _decimalShift; - setOwner(_owner); - setErc677token(_erc677token); + address _feeManager, + uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] + uint256 _decimalShift, + address _limitsContract + ) public returns (bool) { + require(AddressUtils.isContract(_feeManager)); + addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; + _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); + _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); - emit GasPriceChanged(_homeGasPrice); + return + initialize( + _validatorContract, + _requestLimitsArray, + _homeGasPrice, + _requiredBlockConfirmations, + _erc677token, + _executionLimitsArray, + _owner, + _decimalShift, + _limitsContract + ); } function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner { @@ -166,4 +137,13 @@ contract HomeBridgeErcToErc is setTxAboveLimits(_recipient, _value, _txHash); emit AmountLimitExceeded(_recipient, _value, _txHash); } + + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 293360dfb..1654924c2 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -7,30 +7,35 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { bytes4 internal constant SET_BLOCK_REWARD_CONTRACT = 0x27a3e16b; // setBlockRewardContract(address) function rewardableInitialize( - address[] _contracts, // [ 0 = _validatorContract, 1 = _erc677token, 2 = _feeManager, 3 = _limitsContract, 4 = _blockReward ] - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + address _validatorContract, + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + address _erc677token, + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, + address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) external returns (bool) { - require(AddressUtils.isContract(_contracts[3])); - addressStorage[LIMITS_CONTRACT] = _contracts[3]; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _rewardableInitialize( - _contracts, + uint256 _decimalShift, + address _blockReward, + address _limitsContract + ) public returns (bool) { + _setBlockRewardContract(_feeManager, _blockReward); + return super.rewardableInitialize( + _validatorContract, + _requestLimitsArray, _homeGasPrice, _requiredBlockConfirmations, + _erc677token, + _executionLimitsArray, _owner, + _feeManager, _homeFeeForeignFeeArray, - _decimalShift + _decimalShift, + _limitsContract ); - _setBlockRewardContract(_contracts[2], _contracts[4]); - setInitialize(); - - return isInitialized(); } function blockRewardContract() public view returns (address) { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol deleted file mode 100644 index ee2d42c21..000000000 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol +++ /dev/null @@ -1,37 +0,0 @@ -pragma solidity 0.4.24; - -import "./HomeBridgeErcToErcPOSDAO.sol"; -import "./HomeBridgeErcToErcRelativeDailyLimit.sol"; - -// solhint-disable-next-line no-empty-blocks -contract HomeBridgeErcToErcPOSDAORelativeDailyLimit is HomeBridgeErcToErcRelativeDailyLimit, HomeBridgeErcToErcPOSDAO { - function rewardableInitialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _erc677token, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - address _feeManager, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - address _blockReward, - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _rewardableInitialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _erc677token, - _owner, - _feeManager, - _homeFeeForeignFeeArray, - _decimalShift - ); - _setBlockRewardContract(_feeManager, _blockReward); - setInitialize(); - - return isInitialized(); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol deleted file mode 100644 index a94d8dcc7..000000000 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,94 +0,0 @@ -pragma solidity 0.4.24; - -import "./HomeBridgeErcToErc.sol"; -import "../RelativeDailyLimit.sol"; - -contract HomeBridgeErcToErcRelativeDailyLimit is HomeBridgeErcToErc, RelativeDailyLimit { - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - - function initialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _erc677token, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _erc677token, - _owner, - _decimalShift - ); - setInitialize(); - - return isInitialized(); - } - - function rewardableInitialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _erc677token, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - address _feeManager, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _rewardableInitialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _erc677token, - _owner, - _feeManager, - _homeFeeForeignFeeArray, - _decimalShift - ); - setInitialize(); - - return isInitialized(); - } - - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx - _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx - _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - require( - _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit - ); - - uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; - uintStorage[THRESHOLD] = _requestLimitsArray[1]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc677token().totalSupply(); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index e71acf79b..b1e947da2 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -13,43 +13,23 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB address _erc20token, uint256 _requiredBlockConfirmations, uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + uint256[] _requestLimitsArray, + // absolute: [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _executionLimitsArray, address _owner, uint256 _decimalShift, address _bridgeOnOtherSide, address _limitsContract ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - return - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); - } - - function _initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - address _owner, - uint256 _decimalShift, - address _bridgeOnOtherSide - ) internal returns (bool) { require(!isInitialized()); require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); require(_gasPrice > 0); require(_owner != address(0)); require(_bridgeOnOtherSide != address(0)); + require(AddressUtils.isContract(_limitsContract)); addressStorage[VALIDATOR_CONTRACT] = _validatorContract; setErc20token(_erc20token); @@ -59,11 +39,13 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); - setInitialize(); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); + setInitialize(); return isInitialized(); } @@ -114,4 +96,13 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB emit TokensSwapped(saiContract, erc20token(), curBalance); boolStorage[storageAddress] = true; } + + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { + _updateTodayLimit(); + super.executeSignatures(vs, rs, ss, message); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc20token().balanceOf(address(this)); + } } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol deleted file mode 100644 index e66cede36..000000000 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol +++ /dev/null @@ -1,51 +0,0 @@ -pragma solidity 0.4.24; - -import "./ForeignBridgeErcToNative.sol"; -import "../RelativeExecutionDailyLimit.sol"; - -contract ForeignBridgeErcToNativeRelativeDailyLimit is ForeignBridgeErcToNative, RelativeExecutionDailyLimit { - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { - _updateTodayLimit(); - super.executeSignatures(vs, rs, ss, message); - } - - function initialize( - address _validatorContract, - address _erc20token, - uint256 _requiredBlockConfirmations, - uint256 _gasPrice, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray, //[ 0 = _targetLimit, 1 = _threshold, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - address _owner, - uint256 _decimalShift, - address _bridgeOnOtherSide - ) external returns (bool) { - require( - _executionLimitsArray[3] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _homeMinPerTx - _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - - uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; - uintStorage[THRESHOLD] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - - return - _initialize( - _validatorContract, - _erc20token, - _requiredBlockConfirmations, - _gasPrice, - _requestLimitsArray, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc20token().balanceOf(address(this)); - } -} diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index ea7481c6c..bbcc49e55 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -24,6 +24,7 @@ contract HomeBridgeErcToNative is function nativeTransfer(address _receiver) internal { require(msg.value > 0); + _updateTodayLimit(); require(withinLimit(msg.value)); IBlockReward blockReward = blockRewardContract(); uint256 totalMinted = blockReward.mintedTotallyByBridge(address(this)); @@ -49,62 +50,72 @@ contract HomeBridgeErcToNative is function initialize( address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, uint256 _decimalShift, address _limitsContract - ) external returns (bool) { + ) public returns (bool) { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_blockReward == address(0) || AddressUtils.isContract(_blockReward)); + require(_owner != address(0)); require(AddressUtils.isContract(_limitsContract)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _homeGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; + addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; + uintStorage[DECIMAL_SHIFT] = _decimalShift; + setOwner(_owner); addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _blockReward, - _owner, - _decimalShift - ); - setInitialize(); + emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); + emit GasPriceChanged(_homeGasPrice); + + setInitialize(); return isInitialized(); } function rewardableInitialize( address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, address _blockReward, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift, address _limitsContract ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _blockReward, - _owner, - _decimalShift - ); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - setInitialize(); - - return isInitialized(); + return + initialize( + _validatorContract, + _requestLimitsArray, + _homeGasPrice, + _requiredBlockConfirmations, + _blockReward, + _executionLimitsArray, + _owner, + _decimalShift, + _limitsContract + ); } function getBridgeMode() external pure returns (bytes4 _data) { @@ -123,32 +134,6 @@ contract HomeBridgeErcToNative is _setBlockRewardContract(_blockReward); } - function _initialize( - address _validatorContract, - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _blockReward, - address _owner, - uint256 _decimalShift - ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations > 0); - require(_blockReward == address(0) || AddressUtils.isContract(_blockReward)); - require(_owner != address(0)); - - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - uintStorage[DEPLOYED_AT_BLOCK] = block.number; - uintStorage[GAS_PRICE] = _homeGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; - uintStorage[DECIMAL_SHIFT] = _decimalShift; - setOwner(_owner); - - emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); - emit GasPriceChanged(_homeGasPrice); - } - function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) { _increaseTotalExecutedPerDay(_value); IBlockReward blockReward = blockRewardContract(); @@ -190,4 +175,10 @@ contract HomeBridgeErcToNative is setTxAboveLimits(_recipient, _value, _txHash); emit AmountLimitExceeded(_recipient, _value, _txHash); } + + function _getTokenBalance() internal view returns (uint256) { + uint256 totalMinted = blockRewardContract().mintedTotallyByBridge(address(this)); + uint256 totalBurnt = totalBurntCoins(); + return totalMinted.sub(totalBurnt); + } } diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol deleted file mode 100644 index c1bc4c4c2..000000000 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol +++ /dev/null @@ -1,99 +0,0 @@ -pragma solidity 0.4.24; - -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "./HomeBridgeErcToNative.sol"; -import "../RelativeDailyLimit.sol"; - -contract HomeBridgeErcToNativeRelativeDailyLimit is HomeBridgeErcToNative, RelativeDailyLimit { - function nativeTransfer(address _receiver) internal { - _updateTodayLimit(); - super.nativeTransfer(_receiver); - } - - function initialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _blockReward, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _blockReward, - _owner, - _decimalShift - ); - setInitialize(); - - return isInitialized(); - } - - function rewardableInitialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - address _blockReward, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - address _owner, - address _feeManager, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _homeGasPrice, - _requiredBlockConfirmations, - _blockReward, - _owner, - _decimalShift - ); - require(AddressUtils.isContract(_feeManager)); - addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; - _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); - _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - setInitialize(); - - return isInitialized(); - } - - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx - _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx - _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - require( - _executionLimitsArray[2] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _foreignMaxPerTx < _foreignDailyLimit - ); - - uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; - uintStorage[THRESHOLD] = _requestLimitsArray[1]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - - function _getTokenBalance() internal view returns (uint256) { - uint256 totalMinted = blockRewardContract().mintedTotallyByBridge(address(this)); - uint256 totalBurnt = totalBurntCoins(); - return totalMinted.sub(totalBurnt); - } -} diff --git a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol deleted file mode 100644 index ffcb4eb80..000000000 --- a/contracts/upgradeable_contracts/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity 0.4.24; - -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "./ClassicHomeBridgeNativeToErc.sol"; -import "./HomeBridgeNativeToErcRelativeDailyLimit.sol"; - -contract ClassicHomeBridgeNativeToErcRelativeDailyLimit is - ClassicHomeBridgeNativeToErc, - HomeBridgeNativeToErcRelativeDailyLimit -{ - function _getTokenBalance() internal view returns (uint256) { - return address(this).balance; - } -} diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index ed43ccca4..d2438bf73 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -14,27 +14,38 @@ contract ForeignBridgeNativeToErc is function initialize( address _validatorContract, address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, uint256 _decimalShift, address _bridgeOnOtherSide, address _limitsContract - ) external returns (bool) { + ) public returns (bool) { + require(!isInitialized()); + require(AddressUtils.isContract(_validatorContract)); + require(_requiredBlockConfirmations > 0); + require(_foreignGasPrice > 0); + require(_owner != address(0)); require(AddressUtils.isContract(_limitsContract)); + + addressStorage[VALIDATOR_CONTRACT] = _validatorContract; + setErc677token(_erc677token); + uintStorage[DEPLOYED_AT_BLOCK] = block.number; + uintStorage[GAS_PRICE] = _foreignGasPrice; + uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; + uintStorage[DECIMAL_SHIFT] = _decimalShift; + setOwner(_owner); + _setBridgeContractOnOtherSide(_bridgeOnOtherSide); addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc677token, - _foreignGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); + + emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); + emit GasPriceChanged(_foreignGasPrice); + setInitialize(); return isInitialized(); } @@ -42,10 +53,12 @@ contract ForeignBridgeNativeToErc is function rewardableInitialize( address _validatorContract, address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // absolute: [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] + // relative: [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] + uint256[] _requestLimitsArray, uint256 _foreignGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] + uint256[] _executionLimitsArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] address _owner, address _feeManager, uint256 _homeFee, @@ -53,23 +66,22 @@ contract ForeignBridgeNativeToErc is address _bridgeOnOtherSide, address _limitsContract ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc677token, - _foreignGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; _setFee(_feeManager, _homeFee, HOME_FEE); - setInitialize(); - return isInitialized(); + return + initialize( + _validatorContract, + _erc677token, + _requestLimitsArray, + _foreignGasPrice, + _requiredBlockConfirmations, + _executionLimitsArray, + _owner, + _decimalShift, + _bridgeOnOtherSide, + _limitsContract + ); } function getBridgeMode() external pure returns (bytes4 _data) { @@ -80,34 +92,6 @@ contract ForeignBridgeNativeToErc is IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to); } - function _initialize( - address _validatorContract, - address _erc677token, - uint256 _foreignGasPrice, - uint256 _requiredBlockConfirmations, - address _owner, - uint256 _decimalShift, - address _bridgeOnOtherSide - ) internal { - require(!isInitialized()); - require(AddressUtils.isContract(_validatorContract)); - require(_requiredBlockConfirmations > 0); - require(_foreignGasPrice > 0); - require(_owner != address(0)); - - addressStorage[VALIDATOR_CONTRACT] = _validatorContract; - setErc677token(_erc677token); - uintStorage[DEPLOYED_AT_BLOCK] = block.number; - uintStorage[GAS_PRICE] = _foreignGasPrice; - uintStorage[REQUIRED_BLOCK_CONFIRMATIONS] = _requiredBlockConfirmations; - uintStorage[DECIMAL_SHIFT] = _decimalShift; - setOwner(_owner); - _setBridgeContractOnOtherSide(_bridgeOnOtherSide); - - emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); - emit GasPriceChanged(_foreignGasPrice); - } - function onExecuteMessage(address _recipient, uint256 _amount, bytes32 _txHash) internal returns (bool) { _increaseTotalExecutedPerDay(_amount); uint256 valueToMint = _amount.div(10**decimalShift()); @@ -129,4 +113,13 @@ contract ForeignBridgeNativeToErc is function onFailedMessage(address, uint256, bytes32) internal { revert(); } + + function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + _updateTodayLimit(); + return super.onTokenTransfer(_from, _value, _data); + } + + function _getTokenBalance() internal view returns (uint256) { + return erc677token().totalSupply(); + } } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol deleted file mode 100644 index 3932fabf0..000000000 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,97 +0,0 @@ -pragma solidity 0.4.24; - -import "./ForeignBridgeNativeToErc.sol"; -import "../RelativeDailyLimit.sol"; - -contract ForeignBridgeNativeToErcRelativeDailyLimit is ForeignBridgeNativeToErc, RelativeDailyLimit { - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - - function initialize( - address _validatorContract, - address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _foreignGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - address _owner, - uint256 _decimalShift, - address _bridgeOnOtherSide - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc677token, - _foreignGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); - setInitialize(); - return isInitialized(); - } - - function rewardableInitialize( - address _validatorContract, - address _erc677token, - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256 _foreignGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - address _owner, - address _feeManager, - uint256 _homeFee, - uint256 _decimalShift, - address _bridgeOnOtherSide - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize( - _validatorContract, - _erc677token, - _foreignGasPrice, - _requiredBlockConfirmations, - _owner, - _decimalShift, - _bridgeOnOtherSide - ); - require(AddressUtils.isContract(_feeManager)); - addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; - _setFee(_feeManager, _homeFee, HOME_FEE); - setInitialize(); - return isInitialized(); - } - - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _targetLimit, 1 = threshold, 2 = _maxPerTx, 3 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _homeDailyLimit, 1 = _homeMaxPerTx, 2 = _homeMinPerTx ] - ) internal { - require( - _requestLimitsArray[3] > 0 && // _minPerTx > 0 - _requestLimitsArray[2] > _requestLimitsArray[3] && // _maxPerTx > _minPerTx - _requestLimitsArray[1] >= _requestLimitsArray[3] && // _threshold >= _minPerTx - _requestLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - require( - _executionLimitsArray[2] > 0 && // _homeMinPerTx > 0 - _executionLimitsArray[1] > _executionLimitsArray[2] && // _homeMaxPerTx > _homeMinPerTx - _executionLimitsArray[1] < _executionLimitsArray[0] // _homeMaxPerTx < _homeDailyLimit - ); - - uintStorage[TARGET_LIMIT] = _requestLimitsArray[0]; - uintStorage[THRESHOLD] = _requestLimitsArray[1]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[2]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[3]; - uintStorage[EXECUTION_DAILY_LIMIT] = _executionLimitsArray[0]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[2]; - - emit ExecutionDailyLimitChanged(_executionLimitsArray[0]); - } - - function _getTokenBalance() internal view returns (uint256) { - return erc677token().totalSupply(); - } -} diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index b53514997..d643a4c0e 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -34,11 +34,13 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + // absolute: [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _executionLimitsArray, address _owner, uint256 _decimalShift, address _limitsContract - ) external returns (bool) { + ) public returns (bool) { require(AddressUtils.isContract(_limitsContract)); addressStorage[LIMITS_CONTRACT] = _limitsContract; _setLimits(_requestLimitsArray, _executionLimitsArray); @@ -52,23 +54,30 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256 _homeGasPrice, uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _foreignDailyLimit, 1 = _foreignMaxPerTx, 2 = _foreignMinPerTx ] + // absolute: [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx, 2 = _executionMinPerTx ] + // relative: [ 0 = _targetLimit, 1 = _threshold, 2 = _executionMaxPerTx, 3 = _executionMinPerTx ] + uint256[] _executionLimitsArray, address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] uint256 _decimalShift, address _limitsContract ) external returns (bool) { - require(AddressUtils.isContract(_limitsContract)); - addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); require(AddressUtils.isContract(_feeManager)); addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - setInitialize(); - return isInitialized(); + return + initialize( + _validatorContract, + _requestLimitsArray, + _homeGasPrice, + _requiredBlockConfirmations, + _executionLimitsArray, + _owner, + _decimalShift, + _limitsContract + ); } function getBridgeMode() external pure returns (bytes4 _data) { @@ -138,4 +147,13 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom ) internal { revert(); } + + function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { + _updateTodayLimit(); + super.executeAffirmation(recipient, value, transactionHash); + } + + function _getTokenBalance() internal view returns (uint256) { + return address(this).balance; + } } diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol deleted file mode 100644 index 29af7a612..000000000 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol +++ /dev/null @@ -1,78 +0,0 @@ -pragma solidity 0.4.24; - -import "./HomeBridgeNativeToErc.sol"; -import "../RelativeExecutionDailyLimit.sol"; - -contract HomeBridgeNativeToErcRelativeDailyLimit is HomeBridgeNativeToErc, RelativeExecutionDailyLimit { - function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { - _updateTodayLimit(); - super.executeAffirmation(recipient, value, transactionHash); - } - - function initialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] - address _owner, - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); - setInitialize(); - return isInitialized(); - } - - function rewardableInitialize( - address _validatorContract, - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256 _homeGasPrice, - uint256 _requiredBlockConfirmations, - uint256[] _executionLimitsArray, // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] - address _owner, - address _feeManager, - uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift - ) external returns (bool) { - _setLimits(_requestLimitsArray, _executionLimitsArray); - _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); - require(AddressUtils.isContract(_feeManager)); - addressStorage[FEE_MANAGER_CONTRACT] = _feeManager; - _setFee(_feeManager, _homeFeeForeignFeeArray[0], HOME_FEE); - _setFee(_feeManager, _homeFeeForeignFeeArray[1], FOREIGN_FEE); - setInitialize(); - return isInitialized(); - } - - function _setLimits( - uint256[] _requestLimitsArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] - uint256[] _executionLimitsArray // [ 0 = _targetLimit, 1 = _threshold, 2 = _foreignMaxPerTx, 3 = _foreignMinPerTx ] - ) internal { - require( - _requestLimitsArray[2] > 0 && // _minPerTx > 0 - _requestLimitsArray[1] > _requestLimitsArray[2] && // _maxPerTx > _minPerTx - _requestLimitsArray[0] > _requestLimitsArray[1] // _dailyLimit > _maxPerTx - ); - require( - _executionLimitsArray[3] > 0 && // _foreignMinPerTx > 0 - _executionLimitsArray[2] > _executionLimitsArray[3] && // _foreignMaxPerTx > _foreignMinPerTx - _executionLimitsArray[1] >= _executionLimitsArray[3] && // _threshold >= _foreignMinPerTx - _executionLimitsArray[0] <= 1 ether // _targetLimit <= 1 ether - ); - - uintStorage[DAILY_LIMIT] = _requestLimitsArray[0]; - uintStorage[MAX_PER_TX] = _requestLimitsArray[1]; - uintStorage[MIN_PER_TX] = _requestLimitsArray[2]; - uintStorage[TARGET_LIMIT] = _executionLimitsArray[0]; - uintStorage[THRESHOLD] = _executionLimitsArray[1]; - uintStorage[EXECUTION_MAX_PER_TX] = _executionLimitsArray[2]; - uintStorage[EXECUTION_MIN_PER_TX] = _executionLimitsArray[3]; - - emit DailyLimitChanged(_requestLimitsArray[0]); - } - - function _getTokenBalance() internal view returns (uint256) { - return address(this).balance; - } -} From 4409193c9a47e32493b01e87cc0c5ecb9b75f466 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 10 Dec 2019 15:43:12 +0300 Subject: [PATCH 54/80] remove extensions of methods --- contracts/upgradeable_contracts/BaseERC677Bridge.sol | 1 + contracts/upgradeable_contracts/BasicForeignBridge.sol | 1 + contracts/upgradeable_contracts/BasicHomeBridge.sol | 1 + .../amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol | 3 +++ .../amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol | 5 ----- .../amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol | 10 ---------- .../erc20_to_erc20/BasicForeignBridgeErcToErc.sol | 5 ----- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 5 ----- .../erc20_to_native/ForeignBridgeErcToNative.sol | 5 ----- .../native_to_erc20/ForeignBridgeNativeToErc.sol | 5 ----- .../native_to_erc20/HomeBridgeNativeToErc.sol | 5 ----- 11 files changed, 6 insertions(+), 40 deletions(-) diff --git a/contracts/upgradeable_contracts/BaseERC677Bridge.sol b/contracts/upgradeable_contracts/BaseERC677Bridge.sol index 7be25f0f5..1868dcfac 100644 --- a/contracts/upgradeable_contracts/BaseERC677Bridge.sol +++ b/contracts/upgradeable_contracts/BaseERC677Bridge.sol @@ -20,6 +20,7 @@ contract BaseERC677Bridge is BasicTokenBridge, ERC677Receiver, ERC677Storage { function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { ERC677 token = erc677token(); require(msg.sender == address(token)); + _updateTodayLimit(); require(withinLimit(_value)); _increaseTotalSpentPerDay(_value); bridgeSpecificActionsOnTokenTransfer(token, _from, _value, _data); diff --git a/contracts/upgradeable_contracts/BasicForeignBridge.sol b/contracts/upgradeable_contracts/BasicForeignBridge.sol index 2d1d11e62..126a01af8 100644 --- a/contracts/upgradeable_contracts/BasicForeignBridge.sol +++ b/contracts/upgradeable_contracts/BasicForeignBridge.sol @@ -22,6 +22,7 @@ contract BasicForeignBridge is EternalStorage, Validatable, BasicBridge, BasicTo bytes32 txHash; address contractAddress; (recipient, amount, txHash, contractAddress) = Message.parseMessage(message); + _updateTodayLimit(); if (withinExecutionLimit(amount)) { require(contractAddress == address(this)); require(!relayedMessages(txHash)); diff --git a/contracts/upgradeable_contracts/BasicHomeBridge.sol b/contracts/upgradeable_contracts/BasicHomeBridge.sol index 952bcaf42..f1cba55e9 100644 --- a/contracts/upgradeable_contracts/BasicHomeBridge.sol +++ b/contracts/upgradeable_contracts/BasicHomeBridge.sol @@ -23,6 +23,7 @@ contract BasicHomeBridge is EternalStorage, Validatable, BasicBridge, BasicToken ); function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { + _updateTodayLimit(); if (withinExecutionLimit(value)) { bytes32 hashMsg = keccak256(abi.encodePacked(recipient, value, transactionHash)); bytes32 hashSender = keccak256(abi.encodePacked(msg.sender, hashMsg)); diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index cedbbb4be..2311fdd15 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -89,6 +89,7 @@ contract BasicAMBErc677ToErc677 is require(!lock()); ERC677 token = erc677token(); address to = address(this); + _updateTodayLimit(); require(withinLimit(_value)); _increaseTotalSpentPerDay(_value); @@ -106,6 +107,7 @@ contract BasicAMBErc677ToErc677 is ERC677 token = erc677token(); require(msg.sender == address(token)); if (!lock()) { + _updateTodayLimit(); require(withinLimit(_value)); _increaseTotalSpentPerDay(_value); } @@ -210,6 +212,7 @@ contract BasicAMBErc677ToErc677 is ) public { require(msg.sender == address(bridgeContract())); require(messageSender() == mediatorContractOnOtherSide()); + _updateTodayLimit(); if (withinExecutionLimit(_value)) { _increaseTotalExecutedPerDay(_value); executeActionOnBridgedTokens(_recipient, _value); diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol index e66e24c59..747d6943d 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol @@ -23,11 +23,6 @@ contract ForeignAMBErc677ToErc677 is BasicAMBErc677ToErc677 { erc677token().transfer(_recipient, _value); } - function handleBridgedTokens(address _recipient, uint256 _value, bytes32 _nonce) public { - _updateTodayLimit(); - super.handleBridgedTokens(_recipient, _value, _nonce); - } - function _getTokenBalance() internal view returns (uint256) { return erc677token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol index 9146981b3..d1a29ed0f 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol @@ -20,16 +20,6 @@ contract HomeAMBErc677ToErc677 is BasicAMBErc677ToErc677 { IBurnableMintableERC677Token(erc677token()).mint(_recipient, _value); } - function _relayTokens(address _from, address _receiver, uint256 _value) internal { - _updateTodayLimit(); - super._relayTokens(_from, _receiver, _value); - } - - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index b7585383c..3f849aede 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -65,11 +65,6 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { revert(); } - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { - _updateTodayLimit(); - super.executeSignatures(vs, rs, ss, message); - } - function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index dbdc98f9d..df5c7df70 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -138,11 +138,6 @@ contract HomeBridgeErcToErc is emit AmountLimitExceeded(_recipient, _value, _txHash); } - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index b1e947da2..a7a74b62a 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -97,11 +97,6 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB boolStorage[storageAddress] = true; } - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { - _updateTodayLimit(); - super.executeSignatures(vs, rs, ss, message); - } - function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index d2438bf73..9c2ccbda3 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -114,11 +114,6 @@ contract ForeignBridgeNativeToErc is revert(); } - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { - _updateTodayLimit(); - return super.onTokenTransfer(_from, _value, _data); - } - function _getTokenBalance() internal view returns (uint256) { return erc677token().totalSupply(); } diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index d643a4c0e..72767853f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -148,11 +148,6 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom revert(); } - function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { - _updateTodayLimit(); - super.executeAffirmation(recipient, value, transactionHash); - } - function _getTokenBalance() internal view returns (uint256) { return address(this).balance; } From f66b675dc17bc119d9fdffe33918ef5fa88421f3 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 10 Dec 2019 16:01:10 +0300 Subject: [PATCH 55/80] change modifiers --- contracts/interfaces/ERC677Receiver.sol | 2 +- contracts/mocks/ERC677ReceiverTest.sol | 2 +- contracts/upgradeable_contracts/BaseERC677Bridge.sol | 2 +- contracts/upgradeable_contracts/BasicForeignBridge.sol | 2 +- .../amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/interfaces/ERC677Receiver.sol b/contracts/interfaces/ERC677Receiver.sol index a12e03174..a38b59f41 100644 --- a/contracts/interfaces/ERC677Receiver.sol +++ b/contracts/interfaces/ERC677Receiver.sol @@ -1,5 +1,5 @@ pragma solidity 0.4.24; contract ERC677Receiver { - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool); + function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool); } diff --git a/contracts/mocks/ERC677ReceiverTest.sol b/contracts/mocks/ERC677ReceiverTest.sol index 4b4fab69f..94c9aad9c 100644 --- a/contracts/mocks/ERC677ReceiverTest.sol +++ b/contracts/mocks/ERC677ReceiverTest.sol @@ -8,7 +8,7 @@ contract ERC677ReceiverTest is ERC677Receiver { bytes public data; uint256 public someVar = 0; - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool) { from = _from; value = _value; data = _data; diff --git a/contracts/upgradeable_contracts/BaseERC677Bridge.sol b/contracts/upgradeable_contracts/BaseERC677Bridge.sol index 1868dcfac..2c00fd746 100644 --- a/contracts/upgradeable_contracts/BaseERC677Bridge.sol +++ b/contracts/upgradeable_contracts/BaseERC677Bridge.sol @@ -17,7 +17,7 @@ contract BaseERC677Bridge is BasicTokenBridge, ERC677Receiver, ERC677Storage { addressStorage[ERC677_TOKEN] = _token; } - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool) { ERC677 token = erc677token(); require(msg.sender == address(token)); _updateTodayLimit(); diff --git a/contracts/upgradeable_contracts/BasicForeignBridge.sol b/contracts/upgradeable_contracts/BasicForeignBridge.sol index 126a01af8..d4fd44f71 100644 --- a/contracts/upgradeable_contracts/BasicForeignBridge.sol +++ b/contracts/upgradeable_contracts/BasicForeignBridge.sol @@ -15,7 +15,7 @@ contract BasicForeignBridge is EternalStorage, Validatable, BasicBridge, BasicTo event RelayedMessage(address recipient, uint256 value, bytes32 transactionHash); event UserRequestForAffirmation(address recipient, uint256 value); - function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) public { + function executeSignatures(uint8[] vs, bytes32[] rs, bytes32[] ss, bytes message) external { Message.hasEnoughValidSignatures(message, vs, rs, ss, validatorContract(), false); address recipient; uint256 amount; diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index 2311fdd15..d105ec898 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -103,7 +103,7 @@ contract BasicAMBErc677ToErc677 is _relayTokens(msg.sender, _receiver, _value); } - function onTokenTransfer(address _from, uint256 _value, bytes _data) public returns (bool) { + function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns (bool) { ERC677 token = erc677token(); require(msg.sender == address(token)); if (!lock()) { @@ -209,7 +209,7 @@ contract BasicAMBErc677ToErc677 is address _recipient, uint256 _value, bytes32 /* nonce */ - ) public { + ) external { require(msg.sender == address(bridgeContract())); require(messageSender() == mediatorContractOnOtherSide()); _updateTodayLimit(); From d16f62c81bef97886a4875a7fcbd89dc8824b4f9 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 10 Dec 2019 20:38:17 +0300 Subject: [PATCH 56/80] rename limits contract --- .../{BasicLimits.sol => AbsoluteDailyLimit.sol} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename contracts/upgradeable_contracts/{BasicLimits.sol => AbsoluteDailyLimit.sol} (99%) diff --git a/contracts/upgradeable_contracts/BasicLimits.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol similarity index 99% rename from contracts/upgradeable_contracts/BasicLimits.sol rename to contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index 2274455f5..59f41851b 100644 --- a/contracts/upgradeable_contracts/BasicLimits.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -3,7 +3,7 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "../upgradeability/EternalStorage.sol"; -contract BasicLimits is EternalStorage { +contract AbsoluteDailyLimit is EternalStorage { using SafeMath for uint256; event DailyLimitChanged(uint256 newLimit); From 9f9140c62e753aa111ae41ba6cb062e8268c082e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 11 Dec 2019 17:34:39 +0300 Subject: [PATCH 57/80] fix contracts --- .../AbsoluteDailyLimit.sol | 16 ++------ .../BasicRelativeDailyLimit.sol | 6 +-- .../BasicTokenBridge.sol | 39 ++++++++++++------- .../BasicAMBErc677ToErc677.sol | 2 +- .../BasicForeignBridgeErcToErc.sol | 2 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 2 +- .../ForeignBridgeErcToNative.sol | 2 +- .../erc20_to_native/HomeBridgeErcToNative.sol | 2 +- .../ForeignBridgeNativeToErc.sol | 2 +- .../native_to_erc20/HomeBridgeNativeToErc.sol | 2 +- 10 files changed, 38 insertions(+), 37 deletions(-) diff --git a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index 59f41851b..44208feed 100644 --- a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -57,18 +57,10 @@ contract AbsoluteDailyLimit is EternalStorage { return uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", _day))]; } - function dailyLimit() public view returns (uint256) { - return dailyLimit(0); - } - function dailyLimit(uint256) public view returns (uint256) { return uintStorage[DAILY_LIMIT]; } - function executionDailyLimit() public view returns (uint256) { - return executionDailyLimit(0); - } - function executionDailyLimit(uint256) public view returns (uint256) { return uintStorage[EXECUTION_DAILY_LIMIT]; } @@ -127,22 +119,22 @@ contract AbsoluteDailyLimit is EternalStorage { } function setExecutionMaxPerTx(uint256 _maxPerTx) external { - require(_maxPerTx < executionDailyLimit()); + require(_maxPerTx < executionDailyLimit(0)); uintStorage[EXECUTION_MAX_PER_TX] = _maxPerTx; } function setExecutionMinPerTx(uint256 _minPerTx) external { - require(_minPerTx < executionDailyLimit() && _minPerTx < executionMaxPerTx()); + require(_minPerTx < executionDailyLimit(0) && _minPerTx < executionMaxPerTx()); uintStorage[EXECUTION_MIN_PER_TX] = _minPerTx; } function setMaxPerTx(uint256 _maxPerTx) external { - require(_maxPerTx < dailyLimit()); + require(_maxPerTx < dailyLimit(0)); uintStorage[MAX_PER_TX] = _maxPerTx; } function setMinPerTx(uint256 _minPerTx) external { - require(_minPerTx < dailyLimit() && _minPerTx < maxPerTx()); + require(_minPerTx < dailyLimit(0) && _minPerTx < maxPerTx()); uintStorage[MIN_PER_TX] = _minPerTx; } diff --git a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol index 3170b57ca..2be812f01 100644 --- a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol @@ -1,9 +1,9 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "./BasicLimits.sol"; +import "./AbsoluteDailyLimit.sol"; -contract BasicRelativeDailyLimit is BasicLimits { +contract BasicRelativeDailyLimit is AbsoluteDailyLimit { using SafeMath for uint256; event TargetLimitChanged(uint256 newLimit); @@ -80,6 +80,4 @@ contract BasicRelativeDailyLimit is BasicLimits { } function _minPerTx() internal view returns (uint256); - - function _getTokenBalance() internal view returns (uint256); } diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 7b6a67003..f71705c9e 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -1,6 +1,7 @@ pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "openzeppelin-solidity/contracts/AddressUtils.sol"; import "../upgradeability/EternalStorage.sol"; import "./Ownable.sol"; @@ -18,10 +19,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes4 internal constant GET_EXECUTION_DAILY_LIMIT = 0x5cd79c3a; // executionDailyLimit(uint256) bytes4 internal constant GET_TARGET_LIMIT = 0xa70021f3; // targetLimit() bytes4 internal constant GET_THRESHOLD = 0x42cde4e8; // threshold() - bytes4 internal constant GET_WITHIN_LIMIT = 0x894d5ea8; // withinLimit(uint256) - bytes4 internal constant GET_WITHIN_EXECUTION_LIMIT = 0x879ce676; // withinExecutionLimit(uint256,uint256) - bytes4 internal constant GET_TOTAL_SPENT_PER_DAY = 0x84e43616; // totalSpentPerDay(uint256,uint256) + bytes4 internal constant GET_WITHIN_LIMIT = 0x894d5ea8; // withinLimit(uint256,uint256) + bytes4 internal constant GET_WITHIN_EXECUTION_LIMIT = 0x84e43616; // withinExecutionLimit(uint256,uint256) + bytes4 internal constant GET_TOTAL_SPENT_PER_DAY = 0x2bd0bb05; // totalSpentPerDay(uint256) bytes4 internal constant GET_TOTAL_EXECUTED_PER_DAY = 0x4fb3fef7; // totalExecutedPerDay(uint256) + bytes4 internal constant GET_CURRENT_DAY = 0x3e6968b6; // getCurrentDay() bytes4 internal constant INCREASE_TOTAL_SPENT_PER_DAY = 0xb47584cd; // increaseTotalSpentPerDay(uint256) bytes4 internal constant INCREASE_TOTAL_EXECUTED_PER_DAY = 0x79d9623a; // increaseTotalExecutedPerDay(uint256) bytes4 internal constant SET_LIMITS = 0x1558bff0; // setLimits(uint256[],uint256[]) @@ -35,6 +37,15 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes4 internal constant SET_THRESHOLD = 0x960bfe04; // setThreshold(uint256) bytes4 internal constant UPDATE_TODAY_LIMIT = 0x0097eff6; // updateTodayLimit(uint256) + function setLimitsContract(address _limitsContract) external onlyOwner { + require(AddressUtils.isContract(_limitsContract)); + addressStorage[LIMITS_CONTRACT] = _limitsContract; + } + + function setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) public onlyOwner { + require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); + } + function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { _execute(SET_MAX_PER_TX, _maxPerTx); } @@ -60,11 +71,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function setTargetLimit(uint256 _targetLimit) external onlyOwner { - _execute(SET_EXECUTION_DAILY_LIMIT, _targetLimit); + _execute(SET_TARGET_LIMIT, _targetLimit); } function setThreshold(uint256 _threshold) external onlyOwner { - _execute(SET_EXECUTION_DAILY_LIMIT, _threshold); + _execute(SET_THRESHOLD, _threshold); } function limitsContract() public view returns (address) { @@ -100,11 +111,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function targetLimit() public view returns (uint256) { - return _getUint(GET_EXECUTION_DAILY_LIMIT); + return _getUint(GET_TARGET_LIMIT); } function threshold() public view returns (uint256) { - return _getUint(GET_EXECUTION_DAILY_LIMIT); + return _getUint(GET_THRESHOLD); } function withinLimit(uint256 _amount) public view returns (bool) { @@ -115,14 +126,18 @@ contract BasicTokenBridge is EternalStorage, Ownable { return _getWithinLimit(GET_WITHIN_EXECUTION_LIMIT, _amount, _getTokenBalance()); } - function getTotalSpentPerDay(uint256 _day) public view returns (uint256) { + function totalSpentPerDay(uint256 _day) public view returns (uint256) { return _getUint(GET_TOTAL_SPENT_PER_DAY, _day); } - function getTotalExecutedPerDay(uint256 _day) public view returns (uint256) { + function totalExecutedPerDay(uint256 _day) public view returns (uint256) { return _getUint(GET_TOTAL_EXECUTED_PER_DAY, _day); } + function getCurrentDay() public view returns (uint256) { + return _getUint(GET_CURRENT_DAY); + } + function _increaseTotalSpentPerDay(uint256 _amount) internal { _execute(INCREASE_TOTAL_SPENT_PER_DAY, _amount); } @@ -135,10 +150,6 @@ contract BasicTokenBridge is EternalStorage, Ownable { _execute(UPDATE_TODAY_LIMIT, _getTokenBalance()); } - function _setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) internal { - require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); - } - function _execute(bytes4 _method, uint256 _value) internal { require(limitsContract().delegatecall(abi.encodeWithSelector(_method, _value))); } @@ -173,7 +184,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { bytes memory callData = abi.encodeWithSelector(_method, _amount, _tokenBalance); address contractAddress = limitsContract(); assembly { - let result := callcode(gas, contractAddress, 0x0, add(callData, 0x20), mload(callData), 0, 8) + let result := callcode(gas, contractAddress, 0x0, add(callData, 0x20), mload(callData), 0, 32) value := mload(0) switch result diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index d105ec898..e6c172cea 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -55,7 +55,7 @@ contract BasicAMBErc677ToErc677 is setOwner(_owner); setNonce(keccak256(abi.encodePacked(address(this)))); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); setInitialize(); return isInitialized(); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 3f849aede..12031c51f 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -33,7 +33,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index df5c7df70..32a8b77ca 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -42,7 +42,7 @@ contract HomeBridgeErcToErc is setOwner(_owner); setErc677token(_erc677token); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index a7a74b62a..8510b2d02 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -40,7 +40,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index bbcc49e55..50fed2db1 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -76,7 +76,7 @@ contract HomeBridgeErcToNative is uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 9c2ccbda3..3778769f5 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -41,7 +41,7 @@ contract ForeignBridgeNativeToErc is setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_foreignGasPrice); diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 72767853f..4c0a9091b 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -43,7 +43,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom ) public returns (bool) { require(AddressUtils.isContract(_limitsContract)); addressStorage[LIMITS_CONTRACT] = _limitsContract; - _setLimits(_requestLimitsArray, _executionLimitsArray); + setLimits(_requestLimitsArray, _executionLimitsArray); _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); setInitialize(); return isInitialized(); From 9aff13dd791de846e73c8924922f0eedc963fe1d Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 12 Dec 2019 12:32:31 +0300 Subject: [PATCH 58/80] fix amb tests --- .../AMBErc677ToErc677Behavior.test.js | 85 +++++++++++-------- .../foreign_bridge.test.js | 40 +++++---- test/amb_erc677_to_erc677/home_bridge.test.js | 40 +++++---- 3 files changed, 97 insertions(+), 68 deletions(-) diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 4a04ae8ab..2bd8950c2 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -1,8 +1,12 @@ const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const ERC20Mock = artifacts.require('ERC20Mock.sol') const AMBMock = artifacts.require('AMBMock.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') +const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ZERO_ADDRESS, toBN, ERROR_MSG } = require('../setup') const { getEvents, expectEventInLogs, ether, strip0x, calculateDailyLimit } = require('../helpers/helpers') @@ -32,17 +36,21 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( let mediatorContract let erc677Token let contract + let limitsContract const owner = accounts[0] const user = accounts[1] let limitsArray = [dailyLimit, maxPerTx, minPerTx] let executionLimitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + let LimitsContract = AbsoluteDailyLimit if (isRelativeDailyLimit) { if (isRelativeDailyLimitOnBridgeSide) { limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] + LimitsContract = RelativeDailyLimit } else { executionLimitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + LimitsContract = RelativeExecutionDailyLimit } } @@ -55,7 +63,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled } @@ -65,6 +74,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() }) it('should initialize', async function() { contract = this.bridge @@ -72,25 +82,9 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(await contract.bridgeContract()).to.be.equal(ZERO_ADDRESS) expect(await contract.mediatorContractOnOtherSide()).to.be.equal(ZERO_ADDRESS) expect(await contract.erc677token()).to.be.equal(ZERO_ADDRESS) - expect(await contract.maxPerTx()).to.be.bignumber.equal(ZERO) - expect(await contract.minPerTx()).to.be.bignumber.equal(ZERO) - expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(ZERO) - expect(await contract.executionMinPerTx()).to.be.bignumber.equal(ZERO) expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO) expect(await contract.owner()).to.be.equal(ZERO_ADDRESS) - - if (isRelativeDailyLimit) { - expect(await contract.targetLimit()).to.be.bignumber.equal(ZERO) - expect(await contract.threshold()).to.be.bignumber.equal(ZERO) - if (isRelativeDailyLimitOnBridgeSide) { - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) - } else { - expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) - } - } else { - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) - expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) - } + expect(await contract.limitsContract()).to.be.equal(ZERO_ADDRESS) // not valid bridge contract await contract @@ -102,7 +96,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -116,7 +111,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -137,7 +133,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimits, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -158,7 +155,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimits, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -175,7 +173,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -191,7 +190,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) } @@ -213,7 +213,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimits, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -227,11 +228,12 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimitsArray, dailyLimit, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) - const { logs } = await initialize(erc677Token.address) + const { tx } = await initialize(erc677Token.address) // already initialized await contract @@ -243,7 +245,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) @@ -263,16 +266,20 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(await contract.threshold()).to.be.bignumber.equal(threshold) if (isRelativeDailyLimitOnBridgeSide) { expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit }) + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: executionDailyLimit.toString() + }) } else { expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) } } else { expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: executionDailyLimit.toString() + }) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) } }) it('only owner can set bridge contract', async function() { @@ -335,6 +342,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() contract = this.bridge @@ -357,7 +365,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( executionLimits, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled }) it('setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { @@ -470,6 +479,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() contract = this.proxyContract @@ -625,6 +635,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( mediatorContract = await otherSideMediatorContract.new() erc20Token = await ERC20Mock.new('test', 'TST', 18) await erc20Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + limitsContract = await LimitsContract.new() contract = this.bridge }) @@ -805,6 +816,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() contract = this.proxyContract @@ -907,6 +919,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + limitsContract = await LimitsContract.new() await initialize(erc677Token.address) await erc677Token.transferOwnership(contract.address) @@ -1013,6 +1026,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( }) describe('#claimTokens', () => { it('should be able to claim tokens', async function() { + limitsContract = await LimitsContract.new() contract = this.proxyContract await initialize(erc677Token.address) @@ -1045,7 +1059,8 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( isRelativeDailyLimitOnBridgeSide ? executionLimitsArray : customLimits, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled } if (isRelativeDailyLimitOnBridgeSide) { @@ -1056,6 +1071,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() }) it('should be calculated correctly - 1', async function() { await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) @@ -1121,6 +1137,7 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() }) it('should be calculated correctly - 1', async function() { await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) diff --git a/test/amb_erc677_to_erc677/foreign_bridge.test.js b/test/amb_erc677_to_erc677/foreign_bridge.test.js index 594fe10ac..1e0bab8ff 100644 --- a/test/amb_erc677_to_erc677/foreign_bridge.test.js +++ b/test/amb_erc677_to_erc677/foreign_bridge.test.js @@ -1,12 +1,12 @@ const ForeignAMBErc677ToErc677 = artifacts.require('ForeignAMBErc677ToErc677.sol') -const ForeignAMBErc677ToErc677RelativeDailyLimit = artifacts.require('ForeignAMBErc677ToErc677RelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const HomeAMBErc677ToErc677 = artifacts.require('HomeAMBErc677ToErc677.sol') -const HomeAMBErc677ToErc677RelativeDailyLimit = artifacts.require('HomeAMBErc677ToErc677RelativeDailyLimit.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const ForeignAMB = artifacts.require('ForeignAMB.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const AMBMock = artifacts.require('AMBMock.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') const { expect } = require('chai') const { shouldBehaveLikeBasicAMBErc677ToErc677 } = require('./AMBErc677ToErc677Behavior.test') @@ -31,27 +31,27 @@ const targetLimit = ether('0.05') const threshold = ether('10000') function test(accounts, isRelativeDailyLimit) { - const ForeignContract = isRelativeDailyLimit ? ForeignAMBErc677ToErc677RelativeDailyLimit : ForeignAMBErc677ToErc677 - const HomeContract = isRelativeDailyLimit ? HomeAMBErc677ToErc677RelativeDailyLimit : HomeAMBErc677ToErc677 const owner = accounts[0] const user = accounts[1] let ambBridgeContract let mediatorContract let erc677Token let foreignBridge + let limitsContract let limitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] if (isRelativeDailyLimit) { limitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] } + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit beforeEach(async function() { - this.bridge = await ForeignContract.new() + this.bridge = await ForeignAMBErc677ToErc677.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled - this.proxyContract = await ForeignContract.at(storageProxy.address) + this.proxyContract = await ForeignAMBErc677ToErc677.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(HomeContract, accounts, isRelativeDailyLimit, false) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, isRelativeDailyLimit, false) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -59,11 +59,12 @@ function test(accounts, isRelativeDailyLimit) { await validatorContract.initialize(1, authorities, owner) ambBridgeContract = await ForeignAMB.new() await ambBridgeContract.initialize(validatorContract.address, maxGasPerTx, '1', '1', owner) - mediatorContract = await HomeContract.new() + mediatorContract = await HomeAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + limitsContract = await LimitsContract.new() - foreignBridge = await ForeignContract.new() + foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -72,7 +73,8 @@ function test(accounts, isRelativeDailyLimit) { limitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled }) it('should emit UserRequestForAffirmation in AMB bridge', async () => { @@ -133,10 +135,11 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { ambBridgeContract = await AMBMock.new() await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await HomeContract.new() + mediatorContract = await HomeAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() - foreignBridge = await ForeignContract.new() + foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -145,7 +148,8 @@ function test(accounts, isRelativeDailyLimit) { limitsArray, maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled await erc677Token.mint(foreignBridge.address, twoEthers, { from: owner }).should.be.fulfilled await erc677Token.transferOwnership(foreignBridge.address) @@ -195,8 +199,9 @@ function test(accounts, isRelativeDailyLimit) { // Given const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 16) + limitsContract = await LimitsContract.new() - foreignBridge = await ForeignContract.new() + foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -205,7 +210,8 @@ function test(accounts, isRelativeDailyLimit) { limitsArray, maxGasPerTx, decimalShiftTwo, - owner + owner, + limitsContract.address ).should.be.fulfilled await erc677Token.mint(foreignBridge.address, twoEthers, { from: owner }).should.be.fulfilled await erc677Token.transferOwnership(foreignBridge.address) @@ -285,10 +291,10 @@ function test(accounts, isRelativeDailyLimit) { }) } -contract('ForeignAMBErc677ToErc677', async accounts => { +contract.only('ForeignAMBErc677ToErc677', async accounts => { test(accounts, false) }) -contract('ForeignAMBErc677ToErc677RelativeDailyLimit', async accounts => { +contract.only('ForeignAMBErc677ToErc677RelativeDailyLimit', async accounts => { test(accounts, true) }) diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index 84bbcff37..c88a2fc21 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -1,12 +1,12 @@ const HomeAMBErc677ToErc677 = artifacts.require('HomeAMBErc677ToErc677.sol') -const HomeAMBErc677ToErc677RelativeDailyLimit = artifacts.require('HomeAMBErc677ToErc677RelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const ForeignAMBErc677ToErc677 = artifacts.require('ForeignAMBErc677ToErc677.sol') -const ForeignAMBErc677ToErc677RelativeDailyLimit = artifacts.require('ForeignAMBErc677ToErc677RelativeDailyLimit.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const HomeAMB = artifacts.require('HomeAMB.sol') const AMBMock = artifacts.require('AMBMock.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') const { shouldBehaveLikeBasicAMBErc677ToErc677 } = require('./AMBErc677ToErc677Behavior.test') @@ -31,27 +31,27 @@ const targetLimit = ether('0.05') const threshold = ether('10000') function test(accounts, isRelativeDailyLimit) { - const ForeignContract = isRelativeDailyLimit ? ForeignAMBErc677ToErc677RelativeDailyLimit : ForeignAMBErc677ToErc677 - const HomeContract = isRelativeDailyLimit ? HomeAMBErc677ToErc677RelativeDailyLimit : HomeAMBErc677ToErc677 const owner = accounts[0] const user = accounts[1] let ambBridgeContract let mediatorContract let erc677Token let homeBridge + let limitsContract let limitsArray = [dailyLimit, maxPerTx, minPerTx] if (isRelativeDailyLimit) { limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] } + const LimitsContract = isRelativeDailyLimit ? RelativeDailyLimit : AbsoluteDailyLimit beforeEach(async function() { - this.bridge = await HomeContract.new() + this.bridge = await HomeAMBErc677ToErc677.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled - this.proxyContract = await HomeContract.at(storageProxy.address) + this.proxyContract = await HomeAMBErc677ToErc677.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(HomeContract, accounts, isRelativeDailyLimit, true) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, isRelativeDailyLimit, true) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -59,11 +59,12 @@ function test(accounts, isRelativeDailyLimit) { await validatorContract.initialize(1, authorities, owner) ambBridgeContract = await HomeAMB.new() await ambBridgeContract.initialize(validatorContract.address, maxGasPerTx, '1', '1', owner) - mediatorContract = await ForeignContract.new() + mediatorContract = await ForeignAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + limitsContract = await LimitsContract.new() - homeBridge = await HomeContract.new() + homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -72,7 +73,8 @@ function test(accounts, isRelativeDailyLimit) { [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled }) it('should emit UserRequestForSignature in AMB bridge and burn transferred tokens', async () => { @@ -139,10 +141,11 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { ambBridgeContract = await AMBMock.new() await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await ForeignContract.new() + mediatorContract = await ForeignAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() - homeBridge = await HomeContract.new() + homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -151,7 +154,8 @@ function test(accounts, isRelativeDailyLimit) { [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftZero, - owner + owner, + limitsContract.address ).should.be.fulfilled await erc677Token.transferOwnership(homeBridge.address) }) @@ -201,8 +205,9 @@ function test(accounts, isRelativeDailyLimit) { // Given const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await LimitsContract.new() - homeBridge = await HomeContract.new() + homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( ambBridgeContract.address, mediatorContract.address, @@ -211,7 +216,8 @@ function test(accounts, isRelativeDailyLimit) { [executionDailyLimit, executionMaxPerTx, executionMinPerTx], maxGasPerTx, decimalShiftTwo, - owner + owner, + limitsContract.address ).should.be.fulfilled await erc677Token.transferOwnership(homeBridge.address) @@ -295,10 +301,10 @@ function test(accounts, isRelativeDailyLimit) { }) } -contract('HomeAMBErc677ToErc677', async accounts => { +contract.only('HomeAMBErc677ToErc677', async accounts => { test(accounts, false) }) -contract('HomeAMBErc677ToErc677RelativeDailyLimit', async accounts => { +contract.only('HomeAMBErc677ToErc677RelativeDailyLimit', async accounts => { test(accounts, true) }) From 8e313ca223daa95d3908e6ab393d3a1c81ac3473 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 12 Dec 2019 17:15:41 +0300 Subject: [PATCH 59/80] remove duplicate amb tests --- package-lock.json | 13047 ++++++++++------ package.json | 1 + .../AMBErc677ToErc677Behavior.test.js | 967 +- .../foreign_bridge.test.js | 126 +- test/amb_erc677_to_erc677/home_bridge.test.js | 124 +- 5 files changed, 8700 insertions(+), 5565 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b307a4dd..2d5cd5c15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1163,6 +1163,71 @@ "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-4.61.0.tgz", "integrity": "sha512-AObEnA+tgzKEwY306i6FOT/hlc+zjF817Bty/IxG3f2wPJFRK9cJuD3Ijl4pfJP2pt7KubN4YbRGXREXhEsknQ==" }, + "@openzeppelin/contract-loader": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@openzeppelin/contract-loader/-/contract-loader-0.4.0.tgz", + "integrity": "sha512-K+Pl4tn0FbxMSP0H9sgi61ayCbecpqhQmuBshelC7A3q2MlpcqWRJan0xijpwdtv6TORNd5oZNe/+f3l+GD6tw==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "fs-extra": "^8.1.0", + "try-require": "^1.2.1" + }, + "dependencies": { + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + } + } + }, + "@openzeppelin/test-helpers": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@openzeppelin/test-helpers/-/test-helpers-0.5.4.tgz", + "integrity": "sha512-sSjft0CcmC6Pwsd/j1uakk2MLamEH4mmphVlF5hzUUVyoxL0KGCbxQgBoLoEpUbw2M9HtFAEMJJPGccEcb9Cog==", + "dev": true, + "requires": { + "@openzeppelin/contract-loader": "^0.4.0", + "@truffle/contract": "^4.0.35", + "ansi-colors": "^3.2.3", + "chai": "^4.2.0", + "chai-bn": "^0.2.0", + "ethjs-abi": "^0.2.1", + "lodash.flatten": "^4.4.0", + "semver": "^5.6.0", + "web3": "^1.2.1", + "web3-utils": "^1.2.1" + }, + "dependencies": { + "chai-bn": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.2.0.tgz", + "integrity": "sha512-h+XqIFikre13N3uiZSc50PZ0VztVjuD/Gytle07EUFkbd8z31tWp37DLAsR1dPozmOLA3yu4hi3IFjJDQ5CKBg==", + "dev": true + } + } + }, "@resolver-engine/core": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/@resolver-engine/core/-/core-0.2.1.tgz", @@ -1218,1043 +1283,962 @@ "defer-to-connect": "^1.0.1" } }, - "@types/bn.js": { - "version": "4.11.5", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", - "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", - "requires": { - "@types/node": "*" - } - }, - "@types/concat-stream": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=", + "@truffle/blockchain-utils": { + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/@truffle/blockchain-utils/-/blockchain-utils-0.0.16.tgz", + "integrity": "sha512-OAADN8dAEEGmEb2PzevKhDMMWMEpdU2udk8bzXa69cLjXgHDlnzlZN7RwMkd4KtsSgubGWQegXDll2p0AS2WLA==", "dev": true, "requires": { - "@types/node": "*" + "@truffle/provider": "^0.2.3" } }, - "@types/ethereum-protocol": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/ethereum-protocol/-/ethereum-protocol-1.0.0.tgz", - "integrity": "sha512-3DiI3Zxf81CgX+VhxNNFJBv/sfr1BFBKQK2sQ85hU9FwWJJMWV5gRDV79OUNShiwj3tYYIezU94qpucsb3dThQ==", + "@truffle/contract": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@truffle/contract/-/contract-4.1.1.tgz", + "integrity": "sha512-jze+xqFkiFYlFles6aLGjlgKkqyRFMH7GYyEetmtzst4zbyA6pIJ1+gqlo+q39qsKtdppMe1wehvlray3J3CEg==", + "dev": true, "requires": { - "bignumber.js": "7.2.1" + "@truffle/blockchain-utils": "^0.0.16", + "@truffle/contract-schema": "^3.0.19", + "@truffle/error": "^0.0.8", + "@truffle/interface-adapter": "^0.4.0", + "bignumber.js": "^7.2.1", + "ethereum-ens": "^0.7.7", + "ethers": "^4.0.0-beta.1", + "web3": "1.2.2", + "web3-core-promievent": "1.2.2", + "web3-eth-abi": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", + "dev": true + }, "bignumber.js": { "version": "7.2.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", - "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" + "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==", + "dev": true + }, + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + }, + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=", + "dev": true + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.2.tgz", + "integrity": "sha512-/ChbmB6qZpfGx6eNpczt5YSUBHEA5V2+iUCbn85EVb3Zv6FVxrOo5Tv7Lw0gE2tW7EEjASbCyp3mZeiZaCCngg==", + "dev": true, + "requires": { + "@types/node": "^12.6.1", + "web3-bzz": "1.2.2", + "web3-core": "1.2.2", + "web3-eth": "1.2.2", + "web3-eth-personal": "1.2.2", + "web3-net": "1.2.2", + "web3-shh": "1.2.2", + "web3-utils": "1.2.2" + } + }, + "web3-eth-abi": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.2.tgz", + "integrity": "sha512-Yn/ZMgoOLxhTVxIYtPJ0eS6pnAnkTAaJgUJh1JhZS4ekzgswMfEYXOwpMaD5eiqPJLpuxmZFnXnBZlnQ1JMXsw==", + "dev": true, + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.2" + }, + "dependencies": { + "@types/node": { + "version": "10.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.9.tgz", + "integrity": "sha512-+6VygF9LbG7Gaqeog2G7u1+RUcmo0q1rI+2ZxdIg2fAUngk5Vz9fOCHXdloNUOHEPd1EuuOpL5O0CdgN9Fx5UQ==", + "dev": true + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "dev": true, + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + } + } + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } } } }, - "@types/form-data": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", - "integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=", + "@truffle/contract-schema": { + "version": "3.0.19", + "resolved": "https://registry.npmjs.org/@truffle/contract-schema/-/contract-schema-3.0.19.tgz", + "integrity": "sha512-0fT3gBwJPCxO/B+k/xel8aKEGfvXm0nJ965KpCPEC6dpl+XHewJx6TZufiVmxuKTpOAytNfO/aDkQ8sjXs47Fw==", "dev": true, "requires": { - "@types/node": "*" - } - }, - "@types/hdkey": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@types/hdkey/-/hdkey-0.7.0.tgz", - "integrity": "sha512-hS/ueljJBb6i7r7VqhgmBVmDqGKMqQg2nlGIaf71CCG6+iGNE7yeaHgtBWR/wveD+o+K0ma0VE/XweUBHHTQFQ==", - "requires": { - "@types/node": "*" - } - }, - "@types/minimatch": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", - "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" - }, - "@types/node": { - "version": "10.14.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.4.tgz", - "integrity": "sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg==" - }, - "@types/prop-types": { - "version": "15.7.1", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.1.tgz", - "integrity": "sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==" - }, - "@types/qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-Jugo5V/1bS0fRhy2z8+cUAHEyWOATaz4rbyLVvcFs7+dXp5HfwpEwzF1Q11bB10ApUqHf+yTauxI0UXQDwGrbA==", - "dev": true - }, - "@types/react": { - "version": "16.8.20", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.20.tgz", - "integrity": "sha512-ZLmI+ubSJpfUIlQuULDDrdyuFQORBuGOvNnMue8HeA0GVrAJbWtZQhcBvnBPNRBI/GrfSfrKPFhthzC2SLEtLQ==", - "requires": { - "@types/prop-types": "*", - "csstype": "^2.2.0" - } - }, - "@types/solidity-parser-antlr": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@types/solidity-parser-antlr/-/solidity-parser-antlr-0.2.3.tgz", - "integrity": "sha512-FoSyZT+1TTaofbEtGW1oC9wHND1YshvVeHerME/Jh6gIdHbBAWFW8A97YYqO/dpHcFjIwEPEepX0Efl2ckJgwA==" - }, - "@types/web3-provider-engine": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@types/web3-provider-engine/-/web3-provider-engine-14.0.0.tgz", - "integrity": "sha512-yHr8mX2SoX3JNyfqdLXdO1UobsGhfiwSgtekbVxKLQrzD7vtpPkKbkIVsPFOhvekvNbPsCmDyeDCLkpeI9gSmA==", - "requires": { - "@types/ethereum-protocol": "*" - } - }, - "@types/yargs": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-11.1.2.tgz", - "integrity": "sha512-zG61PAp2OcoIBjRV44wftJj6AJgzJrOc32LCYOBqk9bdgcdzK5DCJHV9QZJ60+Fu+fOn79g8Ks3Gixm4CfkZ+w==" - }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" + "ajv": "^6.10.0", + "crypto-js": "^3.1.9-1", + "debug": "^4.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "@truffle/error": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@truffle/error/-/error-0.0.8.tgz", + "integrity": "sha512-x55rtRuNfRO1azmZ30iR0pf0OJ6flQqbax1hJz+Avk1K5fdmOv5cr22s9qFnwTWnS6Bw0jvJEoR0ITsM7cPKtQ==", "dev": true }, - "abi-decoder": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/abi-decoder/-/abi-decoder-2.2.0.tgz", - "integrity": "sha512-FVgkAvPRNa08E85Q+t52KlGto8XZeQITmCYdRIWHHth/t/pgdpAzZijy3LKUCBqmJjXnrosj4c6WGOB1q+KJ9w==", + "@truffle/interface-adapter": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@truffle/interface-adapter/-/interface-adapter-0.4.0.tgz", + "integrity": "sha512-3xCL38jOByT/CN/Sar9Yx0q3xXRzEYpd28eQfI/nTZk/+T1m+aYU7C4Dv2JSnqgB3mjQd++2rRnMYjE2uxYg5w==", "dev": true, "requires": { - "web3-eth-abi": "^1.2.1", - "web3-utils": "^1.2.1" - } - }, - "abortcontroller-polyfill": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.3.0.tgz", - "integrity": "sha512-lbWQgf+eRvku3va8poBlDBO12FigTQr9Zb7NIjXrePrhxWVKdCP2wbDl1tLDaYa18PWTom3UEWwdH13S46I+yA==" - }, - "abstract-leveldown": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz", - "integrity": "sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA==", - "requires": { - "xtend": "~4.0.0" - } - }, - "acorn": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz", - "integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==", - "dev": true - }, - "acorn-jsx": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz", - "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==", - "dev": true - }, - "aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" - }, - "agent-base": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", - "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "requires": { - "es6-promisify": "^5.0.0" - } - }, - "agentkeepalive": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-3.5.2.tgz", - "integrity": "sha512-e0L/HNe6qkQ7H19kTlRRqUibEAwDK5AFk6y3PtMsuut2VAH6+Q4xZml1tNDJD7kSAyqmbG/K08K5WEJYtUrSlQ==", - "requires": { - "humanize-ms": "^1.2.1" - } - }, - "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "optional": true - }, - "ansi-align": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", - "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", - "dev": true, - "requires": { - "string-width": "^2.0.0" + "bn.js": "^4.11.8", + "ethers": "^4.0.32", + "lodash": "^4.17.13", + "web3": "1.2.2" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "elliptic": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", + "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "ethers": { + "version": "4.0.40", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.40.tgz", + "integrity": "sha512-MC9BtV7Hpq4dgFONEfanx9aU9GhhoWU270F+/wegHZXA7FR+2KXFdt36YIQYLmVY5ykUWswDxd+f9EVkIa7JOA==", + "dev": true, + "requires": { + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.5.2", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", "dev": true }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.2.tgz", + "integrity": "sha512-/ChbmB6qZpfGx6eNpczt5YSUBHEA5V2+iUCbn85EVb3Zv6FVxrOo5Tv7Lw0gE2tW7EEjASbCyp3mZeiZaCCngg==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "@types/node": "^12.6.1", + "web3-bzz": "1.2.2", + "web3-core": "1.2.2", + "web3-eth": "1.2.2", + "web3-eth-personal": "1.2.2", + "web3-net": "1.2.2", + "web3-shh": "1.2.2", + "web3-utils": "1.2.2" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" } } } }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "ansicolors": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz", - "integrity": "sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=", - "dev": true - }, - "antlr4": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/antlr4/-/antlr4-4.7.1.tgz", - "integrity": "sha512-haHyTW7Y9joE5MVs37P2lNYfU2RWBLfcRDD8OWldcdZm5TiCE91B5Xl1oWSwiDUSd4rlExpt2pu1fksYQjRBYQ==", - "dev": true - }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "@truffle/provider": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@truffle/provider/-/provider-0.2.3.tgz", + "integrity": "sha512-EsAE7eiXMlTAQBNst12fuTKddMMtqB7d9jQmVvYvq+/G3ryZCf50dTiod0lhTIh0dIQ/tirFdvBRKDfc8c+hsQ==", "dev": true, "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" + "@truffle/error": "^0.0.8", + "@truffle/interface-adapter": "^0.4.0", + "web3": "1.2.2" }, "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", + "dev": true + }, + "web3": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.2.tgz", + "integrity": "sha512-/ChbmB6qZpfGx6eNpczt5YSUBHEA5V2+iUCbn85EVb3Zv6FVxrOo5Tv7Lw0gE2tW7EEjASbCyp3mZeiZaCCngg==", "dev": true, "requires": { - "remove-trailing-separator": "^1.0.1" + "@types/node": "^12.6.1", + "web3-bzz": "1.2.2", + "web3-core": "1.2.2", + "web3-eth": "1.2.2", + "web3-eth-personal": "1.2.2", + "web3-net": "1.2.2", + "web3-shh": "1.2.2", + "web3-utils": "1.2.2" + } + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" } } } }, - "app-module-path": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz", - "integrity": "sha1-ZBqlXft9am8KgUHEucCqULbCTdU=", - "dev": true - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + "@types/bignumber.js": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/bignumber.js/-/bignumber.js-5.0.0.tgz", + "integrity": "sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA==", + "dev": true, + "requires": { + "bignumber.js": "*" + } }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "optional": true, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" + "@types/node": "*" } }, - "arg": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", - "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", - "dev": true + "@types/concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=", + "dev": true, + "requires": { + "@types/node": "*" + } }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "@types/ethereum-protocol": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/ethereum-protocol/-/ethereum-protocol-1.0.0.tgz", + "integrity": "sha512-3DiI3Zxf81CgX+VhxNNFJBv/sfr1BFBKQK2sQ85hU9FwWJJMWV5gRDV79OUNShiwj3tYYIezU94qpucsb3dThQ==", "requires": { - "sprintf-js": "~1.0.2" + "bignumber.js": "7.2.1" + }, + "dependencies": { + "bignumber.js": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", + "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" + } } }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-includes": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", - "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "@types/form-data": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", + "integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.7.0" + "@types/node": "*" } }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", - "dev": true - }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "@types/hdkey": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@types/hdkey/-/hdkey-0.7.0.tgz", + "integrity": "sha512-hS/ueljJBb6i7r7VqhgmBVmDqGKMqQg2nlGIaf71CCG6+iGNE7yeaHgtBWR/wveD+o+K0ma0VE/XweUBHHTQFQ==", "requires": { - "safer-buffer": "~2.1.0" + "@types/node": "*" } }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" }, - "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true + "@types/node": { + "version": "10.14.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.4.tgz", + "integrity": "sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg==" }, - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + "@types/prop-types": { + "version": "15.7.1", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.1.tgz", + "integrity": "sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==" }, - "async-each": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.2.tgz", - "integrity": "sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg==", + "@types/qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-Jugo5V/1bS0fRhy2z8+cUAHEyWOATaz4rbyLVvcFs7+dXp5HfwpEwzF1Q11bB10ApUqHf+yTauxI0UXQDwGrbA==", "dev": true }, - "async-eventemitter": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", - "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", + "@types/react": { + "version": "16.8.20", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.20.tgz", + "integrity": "sha512-ZLmI+ubSJpfUIlQuULDDrdyuFQORBuGOvNnMue8HeA0GVrAJbWtZQhcBvnBPNRBI/GrfSfrKPFhthzC2SLEtLQ==", "requires": { - "async": "^2.4.0" - }, - "dependencies": { - "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", - "requires": { - "lodash": "^4.17.11" - } - } + "@types/prop-types": "*", + "csstype": "^2.2.0" } }, - "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "@types/solidity-parser-antlr": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@types/solidity-parser-antlr/-/solidity-parser-antlr-0.2.3.tgz", + "integrity": "sha512-FoSyZT+1TTaofbEtGW1oC9wHND1YshvVeHerME/Jh6gIdHbBAWFW8A97YYqO/dpHcFjIwEPEepX0Efl2ckJgwA==" }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + "@types/web3-provider-engine": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@types/web3-provider-engine/-/web3-provider-engine-14.0.0.tgz", + "integrity": "sha512-yHr8mX2SoX3JNyfqdLXdO1UobsGhfiwSgtekbVxKLQrzD7vtpPkKbkIVsPFOhvekvNbPsCmDyeDCLkpeI9gSmA==", + "requires": { + "@types/ethereum-protocol": "*" + } }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + "@types/yargs": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-11.1.2.tgz", + "integrity": "sha512-zG61PAp2OcoIBjRV44wftJj6AJgzJrOc32LCYOBqk9bdgcdzK5DCJHV9QZJ60+Fu+fOn79g8Ks3Gixm4CfkZ+w==" }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "@web3-js/scrypt-shim": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@web3-js/scrypt-shim/-/scrypt-shim-0.1.0.tgz", + "integrity": "sha512-ZtZeWCc/s0nMcdx/+rZwY1EcuRdemOK9ag21ty9UsHkFxsNb/AaoucUz0iPuyGe0Ku+PFuRmWZG7Z7462p9xPw==", + "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "scryptsy": "^2.1.0", + "semver": "^6.3.0" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true } } }, - "babel-core": { - "version": "6.26.3", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", - "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", + "@web3-js/websocket": { + "version": "1.0.30", + "resolved": "https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.30.tgz", + "integrity": "sha512-fDwrD47MiDrzcJdSeTLF75aCcxVVt8B1N74rA+vh2XCAvFy4tEWJjtnUtj2QG7/zlQ6g9cQ88bZFBxwd9/FmtA==", + "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-generator": "^6.26.0", - "babel-helpers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-register": "^6.26.0", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "convert-source-map": "^1.5.1", - "debug": "^2.6.9", - "json5": "^0.5.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "path-is-absolute": "^1.0.1", - "private": "^0.1.8", - "slash": "^1.0.0", - "source-map": "^0.5.7" + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "nan": "^2.14.0", + "typedarray-to-buffer": "^3.1.5", + "yaeti": "^0.0.6" }, "dependencies": { "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, "requires": { "ms": "2.0.0" } + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true } } }, - "babel-generator": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", + "JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" - }, - "dependencies": { - "jsesc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=" - } + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" } }, - "babel-helper-builder-binary-assignment-operator-visitor": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", - "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", - "requires": { - "babel-helper-explode-assignable-expression": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-call-delegate": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", - "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true }, - "babel-helper-define-map": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", - "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", + "abi-decoder": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/abi-decoder/-/abi-decoder-2.2.0.tgz", + "integrity": "sha512-FVgkAvPRNa08E85Q+t52KlGto8XZeQITmCYdRIWHHth/t/pgdpAzZijy3LKUCBqmJjXnrosj4c6WGOB1q+KJ9w==", + "dev": true, "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" + "web3-eth-abi": "^1.2.1", + "web3-utils": "^1.2.1" } }, - "babel-helper-explode-assignable-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", - "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } + "abortcontroller-polyfill": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.3.0.tgz", + "integrity": "sha512-lbWQgf+eRvku3va8poBlDBO12FigTQr9Zb7NIjXrePrhxWVKdCP2wbDl1tLDaYa18PWTom3UEWwdH13S46I+yA==" }, - "babel-helper-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", - "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", + "abstract-leveldown": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz", + "integrity": "sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA==", "requires": { - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "xtend": "~4.0.0" } }, - "babel-helper-get-function-arity": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", - "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + }, + "dependencies": { + "mime-db": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", + "dev": true + }, + "mime-types": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "dev": true, + "requires": { + "mime-db": "1.42.0" + } + } } }, - "babel-helper-hoist-variables": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", - "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } + "acorn": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz", + "integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==", + "dev": true }, - "babel-helper-optimise-call-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", - "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } + "acorn-jsx": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz", + "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==", + "dev": true }, - "babel-helper-regex": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", - "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", - "requires": { - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" }, - "babel-helper-remap-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", - "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", + "agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "es6-promisify": "^5.0.0" } }, - "babel-helper-replace-supers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", - "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", + "agentkeepalive": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-3.5.2.tgz", + "integrity": "sha512-e0L/HNe6qkQ7H19kTlRRqUibEAwDK5AFk6y3PtMsuut2VAH6+Q4xZml1tNDJD7kSAyqmbG/K08K5WEJYtUrSlQ==", "requires": { - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "humanize-ms": "^1.2.1" } }, - "babel-helpers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", - "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, - "babel-messages": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", - "requires": { - "babel-runtime": "^6.22.0" - } + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "optional": true }, - "babel-plugin-check-es2015-constants": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", - "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", + "ansi-align": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", + "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", + "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "string-width": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, - "babel-plugin-syntax-async-functions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", - "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=" + "ansi-colors": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", + "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==", + "dev": true }, - "babel-plugin-syntax-exponentiation-operator": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", - "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=" + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true }, - "babel-plugin-syntax-trailing-function-commas": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", - "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=" + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, - "babel-plugin-transform-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", - "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-functions": "^6.8.0", - "babel-runtime": "^6.22.0" + "color-convert": "^1.9.0" } }, - "babel-plugin-transform-es2015-arrow-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", - "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", - "requires": { - "babel-runtime": "^6.22.0" - } + "ansicolors": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz", + "integrity": "sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=", + "dev": true }, - "babel-plugin-transform-es2015-block-scoped-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", - "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", - "requires": { - "babel-runtime": "^6.22.0" - } + "antlr4": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/antlr4/-/antlr4-4.7.1.tgz", + "integrity": "sha512-haHyTW7Y9joE5MVs37P2lNYfU2RWBLfcRDD8OWldcdZm5TiCE91B5Xl1oWSwiDUSd4rlExpt2pu1fksYQjRBYQ==", + "dev": true }, - "babel-plugin-transform-es2015-block-scoping": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", - "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", - "requires": { - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", + "dev": true }, - "babel-plugin-transform-es2015-classes": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", - "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, "requires": { - "babel-helper-define-map": "^6.24.1", - "babel-helper-function-name": "^6.24.1", - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-helper-replace-supers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } } }, - "babel-plugin-transform-es2015-computed-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", - "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } + "app-module-path": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz", + "integrity": "sha1-ZBqlXft9am8KgUHEucCqULbCTdU=" }, - "babel-plugin-transform-es2015-destructuring": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", - "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", - "requires": { - "babel-runtime": "^6.22.0" - } + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" }, - "babel-plugin-transform-es2015-duplicate-keys": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", - "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, - "babel-plugin-transform-es2015-for-of": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", - "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", - "requires": { - "babel-runtime": "^6.22.0" - } + "arg": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", + "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", + "dev": true }, - "babel-plugin-transform-es2015-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", - "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "sprintf-js": "~1.0.2" } }, - "babel-plugin-transform-es2015-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", - "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", - "requires": { - "babel-runtime": "^6.22.0" - } + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true }, - "babel-plugin-transform-es2015-modules-amd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", - "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", - "requires": { - "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true }, - "babel-plugin-transform-es2015-modules-commonjs": { - "version": "6.26.2", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", - "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", - "requires": { - "babel-plugin-transform-strict-mode": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-types": "^6.26.0" - } + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true }, - "babel-plugin-transform-es2015-modules-systemjs": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", - "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dev": true }, - "babel-plugin-transform-es2015-modules-umd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", - "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, "requires": { - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" } }, - "babel-plugin-transform-es2015-object-super": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", - "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", - "requires": { - "babel-helper-replace-supers": "^6.24.1", - "babel-runtime": "^6.22.0" - } + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true }, - "babel-plugin-transform-es2015-parameters": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", - "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", - "requires": { - "babel-helper-call-delegate": "^6.24.1", - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true }, - "babel-plugin-transform-es2015-shorthand-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", - "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "safer-buffer": "~2.1.0" } }, - "babel-plugin-transform-es2015-spread": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", - "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", + "asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, - "babel-plugin-transform-es2015-sticky-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", - "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, - "babel-plugin-transform-es2015-template-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", - "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-typeof-symbol": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", - "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-unicode-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", - "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "regexpu-core": "^2.0.0" - } + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" }, - "babel-plugin-transform-exponentiation-operator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", - "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", - "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", - "babel-plugin-syntax-exponentiation-operator": "^6.8.0", - "babel-runtime": "^6.22.0" - } + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true }, - "babel-plugin-transform-regenerator": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", - "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", - "requires": { - "regenerator-transform": "^0.10.0" - } + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true }, - "babel-plugin-transform-strict-mode": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", - "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" }, - "babel-preset-env": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz", - "integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==", - "requires": { - "babel-plugin-check-es2015-constants": "^6.22.0", - "babel-plugin-syntax-trailing-function-commas": "^6.22.0", - "babel-plugin-transform-async-to-generator": "^6.22.0", - "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoping": "^6.23.0", - "babel-plugin-transform-es2015-classes": "^6.23.0", - "babel-plugin-transform-es2015-computed-properties": "^6.22.0", - "babel-plugin-transform-es2015-destructuring": "^6.23.0", - "babel-plugin-transform-es2015-duplicate-keys": "^6.22.0", - "babel-plugin-transform-es2015-for-of": "^6.23.0", - "babel-plugin-transform-es2015-function-name": "^6.22.0", - "babel-plugin-transform-es2015-literals": "^6.22.0", - "babel-plugin-transform-es2015-modules-amd": "^6.22.0", - "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", - "babel-plugin-transform-es2015-modules-systemjs": "^6.23.0", - "babel-plugin-transform-es2015-modules-umd": "^6.23.0", - "babel-plugin-transform-es2015-object-super": "^6.22.0", - "babel-plugin-transform-es2015-parameters": "^6.23.0", - "babel-plugin-transform-es2015-shorthand-properties": "^6.22.0", - "babel-plugin-transform-es2015-spread": "^6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "^6.22.0", - "babel-plugin-transform-es2015-template-literals": "^6.22.0", - "babel-plugin-transform-es2015-typeof-symbol": "^6.23.0", - "babel-plugin-transform-es2015-unicode-regex": "^6.22.0", - "babel-plugin-transform-exponentiation-operator": "^6.22.0", - "babel-plugin-transform-regenerator": "^6.22.0", - "browserslist": "^3.2.6", - "invariant": "^2.2.2", - "semver": "^5.3.0" - } + "async-each": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.2.tgz", + "integrity": "sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg==", + "dev": true }, - "babel-register": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", - "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "async-eventemitter": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", + "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", "requires": { - "babel-core": "^6.26.0", - "babel-runtime": "^6.26.0", - "core-js": "^2.5.0", - "home-or-tmp": "^2.0.0", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.15" + "async": "^2.4.0" }, "dependencies": { - "source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "requires": { - "source-map": "^0.5.6" + "lodash": "^4.17.11" } } } }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" }, - "babel-template": { + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "babel-code-frame": { "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", - "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } } }, - "babel-traverse": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "babel-core": { + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", + "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", "requires": { "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", "babel-types": "^6.26.0", "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" + "convert-source-map": "^1.5.1", + "debug": "^2.6.9", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.8", + "slash": "^1.0.0", + "source-map": "^0.5.7" }, "dependencies": { "debug": { @@ -2264,671 +2248,1312 @@ "requires": { "ms": "2.0.0" } - }, - "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==" } } }, - "babel-types": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "babel-generator": { + "version": "6.26.1", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", + "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "requires": { + "babel-messages": "^6.23.0", "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" - } - }, - "babelify": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", - "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", - "requires": { - "babel-core": "^6.0.14", - "object-assign": "^4.0.0" + "source-map": "^0.5.7", + "trim-right": "^1.0.1" + }, + "dependencies": { + "jsesc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=" + } } }, - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" + "babel-helper-builder-binary-assignment-operator-visitor": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", + "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", + "requires": { + "babel-helper-explode-assignable-expression": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "backoff": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz", - "integrity": "sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=", + "babel-helper-call-delegate": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", + "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", "requires": { - "precond": "0.2" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "babel-helper-define-map": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", + "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", + "requires": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + } }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, + "babel-helper-explode-assignable-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", + "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "babel-helper-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", + "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "requires": { - "tweetnacl": "^0.14.3" + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "bignumber.js": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-8.0.2.tgz", - "integrity": "sha512-EiuvFrnbv0jFixEQ9f58jo7X0qI2lNGIr/MxntmVzQc5JUweDSh8y8hbTCAomFtqwUPIOWcLXP0VEOSZTG7FFw==" + "babel-helper-get-function-arity": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", + "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true + "babel-helper-hoist-variables": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", + "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "babel-helper-optimise-call-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", + "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", "requires": { - "file-uri-to-path": "1.0.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, - "bip39": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", - "integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", + "babel-helper-regex": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", + "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", "requires": { - "create-hash": "^1.1.0", - "pbkdf2": "^3.0.9", - "randombytes": "^2.0.1", - "safe-buffer": "^5.0.1", - "unorm": "^1.3.3" + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, - "bip66": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", - "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "babel-helper-remap-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", + "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", "requires": { - "safe-buffer": "^5.0.1" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", - "optional": true, + "babel-helper-replace-supers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", + "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", "requires": { - "readable-stream": "^2.3.5", - "safe-buffer": "^5.1.1" + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "bluebird": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", - "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==" + "babel-helpers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", + "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "requires": { + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + "babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "boxen": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", - "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", - "dev": true, + "babel-plugin-check-es2015-constants": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", + "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", "requires": { - "ansi-align": "^2.0.0", - "camelcase": "^4.0.0", - "chalk": "^2.0.1", - "cli-boxes": "^1.0.0", - "string-width": "^2.0.0", - "term-size": "^1.2.0", - "widest-line": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } + "babel-runtime": "^6.22.0" } }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "babel-plugin-syntax-async-functions": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", + "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=" + }, + "babel-plugin-syntax-exponentiation-operator": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", + "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=" + }, + "babel-plugin-syntax-trailing-function-commas": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", + "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=" + }, + "babel-plugin-transform-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", + "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "babel-helper-remap-async-to-generator": "^6.24.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-runtime": "^6.22.0" } }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, + "babel-plugin-transform-es2015-arrow-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", + "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "babel-runtime": "^6.22.0" } }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + "babel-plugin-transform-es2015-block-scoped-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", + "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true + "babel-plugin-transform-es2015-block-scoping": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", + "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", + "requires": { + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + } }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "babel-plugin-transform-es2015-classes": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", + "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", "requires": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "babel-helper-define-map": "^6.24.1", + "babel-helper-function-name": "^6.24.1", + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-helper-replace-supers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "browserslist": { - "version": "3.2.8", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", - "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", + "babel-plugin-transform-es2015-computed-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", + "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", "requires": { - "caniuse-lite": "^1.0.30000844", - "electron-to-chromium": "^1.3.47" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, - "buffer-alloc": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", - "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", - "optional": true, + "babel-plugin-transform-es2015-destructuring": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", + "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", "requires": { - "buffer-alloc-unsafe": "^1.1.0", - "buffer-fill": "^1.0.0" + "babel-runtime": "^6.22.0" } }, - "buffer-alloc-unsafe": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", - "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", - "optional": true + "babel-plugin-transform-es2015-duplicate-keys": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", + "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", + "requires": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "buffer-fill": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", - "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=", - "optional": true + "babel-plugin-transform-es2015-for-of": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", + "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + "babel-plugin-transform-es2015-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", + "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", + "requires": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "buffer-to-arraybuffer": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", - "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=" + "babel-plugin-transform-es2015-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", + "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" + "babel-plugin-transform-es2015-modules-amd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", + "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", + "requires": { + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } }, - "builtins": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", - "integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=" + "babel-plugin-transform-es2015-modules-commonjs": { + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", + "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", + "requires": { + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" + } }, - "cacache": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.0.tgz", - "integrity": "sha512-0baf1FhCp16LhN+xDJsOrSiaPDCTD3JegZptVmLDoEbFcT5aT+BeFGt3wcDU3olCP5tpTCXU5sv0+TsKWT9WGQ==", + "babel-plugin-transform-es2015-modules-systemjs": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", + "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", "requires": { - "bluebird": "^3.5.5", - "chownr": "^1.1.1", - "figgy-pudding": "^3.5.1", - "glob": "^7.1.4", - "graceful-fs": "^4.1.15", - "lru-cache": "^5.1.1", - "mississippi": "^3.0.0", - "mkdirp": "^0.5.1", - "move-concurrently": "^1.0.1", - "promise-inflight": "^1.0.1", - "rimraf": "^2.6.3", - "ssri": "^6.0.1", - "unique-filename": "^1.1.1", - "y18n": "^4.0.0" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "requires": { - "yallist": "^3.0.2" - } - }, - "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" - } + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, + "babel-plugin-transform-es2015-modules-umd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", + "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, - "cacheable-request": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", - "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "babel-plugin-transform-es2015-object-super": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", + "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", "requires": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^3.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^4.1.0", - "responselike": "^1.0.2" - }, - "dependencies": { - "get-stream": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", - "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", - "requires": { - "pump": "^3.0.0" - } - }, - "http-cache-semantics": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", - "integrity": "sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew==" - }, - "lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" - }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - } + "babel-helper-replace-supers": "^6.24.1", + "babel-runtime": "^6.22.0" } }, - "caller-callsite": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", - "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", - "dev": true, + "babel-plugin-transform-es2015-parameters": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", + "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", "requires": { - "callsites": "^2.0.0" - }, - "dependencies": { - "callsites": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", - "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", - "dev": true - } + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, - "caller-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", - "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", - "dev": true, + "babel-plugin-transform-es2015-shorthand-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", + "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", "requires": { - "caller-callsite": "^2.0.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" - }, - "caniuse-lite": { - "version": "1.0.30000974", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000974.tgz", - "integrity": "sha512-xc3rkNS/Zc3CmpMKuczWEdY2sZgx09BkAxfvkxlAEBTqcMHeL8QnPqhKse+5sRTi3nrw2pJwToD2WvKn1Uhvww==" + "babel-plugin-transform-es2015-spread": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", + "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "capture-stack-trace": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", - "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==", - "dev": true + "babel-plugin-transform-es2015-sticky-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", + "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", + "requires": { + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } }, - "cardinal": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/cardinal/-/cardinal-2.1.1.tgz", - "integrity": "sha1-fMEFXYItISlU0HsIXeolHMe8VQU=", - "dev": true, + "babel-plugin-transform-es2015-template-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", + "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", "requires": { - "ansicolors": "~0.3.2", - "redeyed": "~2.1.0" + "babel-runtime": "^6.22.0" } }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + "babel-plugin-transform-es2015-typeof-symbol": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", + "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", + "requires": { + "babel-runtime": "^6.22.0" + } }, - "chai": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", - "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "babel-plugin-transform-es2015-unicode-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", + "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" } }, - "chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "dev": true, + "babel-plugin-transform-exponentiation-operator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", + "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", "requires": { - "check-error": "^1.0.2" + "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", + "babel-plugin-syntax-exponentiation-operator": "^6.8.0", + "babel-runtime": "^6.22.0" } }, - "chai-bn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.1.1.tgz", - "integrity": "sha512-e1npVXt3cQfZ6oQET9oP38vNj/4HeJ4ojeUpuC8YzhVbTJpIDqANVt7TKi7Dq9yKlHySk2FqbmiMih35iT4DYg==", - "dev": true + "babel-plugin-transform-regenerator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", + "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", + "requires": { + "regenerator-transform": "^0.10.0" + } }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "babel-plugin-transform-strict-mode": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", + "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "babel-preset-env": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz", + "integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==", + "requires": { + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-syntax-trailing-function-commas": "^6.22.0", + "babel-plugin-transform-async-to-generator": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.23.0", + "babel-plugin-transform-es2015-classes": "^6.23.0", + "babel-plugin-transform-es2015-computed-properties": "^6.22.0", + "babel-plugin-transform-es2015-destructuring": "^6.23.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.22.0", + "babel-plugin-transform-es2015-for-of": "^6.23.0", + "babel-plugin-transform-es2015-function-name": "^6.22.0", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.22.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-systemjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-umd": "^6.23.0", + "babel-plugin-transform-es2015-object-super": "^6.22.0", + "babel-plugin-transform-es2015-parameters": "^6.23.0", + "babel-plugin-transform-es2015-shorthand-properties": "^6.22.0", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.22.0", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.23.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.22.0", + "babel-plugin-transform-exponentiation-operator": "^6.22.0", + "babel-plugin-transform-regenerator": "^6.22.0", + "browserslist": "^3.2.6", + "invariant": "^2.2.2", + "semver": "^5.3.0" + } + }, + "babel-register": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", + "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "requires": { + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" + }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "requires": { - "has-flag": "^3.0.0" + "source-map": "^0.5.6" } } } }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } }, - "charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", - "dev": true + "babel-template": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", + "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "requires": { + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" + } }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + "babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "requires": { + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==" + } + } }, - "checkpoint-store": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/checkpoint-store/-/checkpoint-store-1.1.0.tgz", - "integrity": "sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY=", + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "requires": { - "functional-red-black-tree": "^1.0.1" + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" } }, - "chokidar": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", - "integrity": "sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==", + "babelify": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", + "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", + "requires": { + "babel-core": "^6.0.14", + "object-assign": "^4.0.0" + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" + }, + "backoff": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz", + "integrity": "sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=", + "requires": { + "precond": "0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { - "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, - "optional": true, "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "bignumber.js": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-8.0.2.tgz", + "integrity": "sha512-EiuvFrnbv0jFixEQ9f58jo7X0qI2lNGIr/MxntmVzQc5JUweDSh8y8hbTCAomFtqwUPIOWcLXP0VEOSZTG7FFw==" + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "dev": true + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bip39": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", + "integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", + "requires": { + "create-hash": "^1.1.0", + "pbkdf2": "^3.0.9", + "randombytes": "^2.0.1", + "safe-buffer": "^5.0.1", + "unorm": "^1.3.3" + } + }, + "bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "bl": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==" + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "dev": true, + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + } + } + }, + "boxen": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", + "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", + "dev": true, + "requires": { + "ansi-align": "^2.0.0", + "camelcase": "^4.0.0", + "chalk": "^2.0.1", + "cli-boxes": "^1.0.0", + "string-width": "^2.0.0", + "term-size": "^1.2.0", + "widest-line": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "requires": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserslist": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", + "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", + "requires": { + "caniuse-lite": "^1.0.30000844", + "electron-to-chromium": "^1.3.47" + } + }, + "buffer": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", + "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "dev": true + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "buffer-to-arraybuffer": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", + "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=" + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" + }, + "builtins": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", + "integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "dev": true + }, + "cacache": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.0.tgz", + "integrity": "sha512-0baf1FhCp16LhN+xDJsOrSiaPDCTD3JegZptVmLDoEbFcT5aT+BeFGt3wcDU3olCP5tpTCXU5sv0+TsKWT9WGQ==", + "requires": { + "bluebird": "^3.5.5", + "chownr": "^1.1.1", + "figgy-pudding": "^3.5.1", + "glob": "^7.1.4", + "graceful-fs": "^4.1.15", + "lru-cache": "^5.1.1", + "mississippi": "^3.0.0", + "mkdirp": "^0.5.1", + "move-concurrently": "^1.0.1", + "promise-inflight": "^1.0.1", + "rimraf": "^2.6.3", + "ssri": "^6.0.1", + "unique-filename": "^1.1.1", + "y18n": "^4.0.0" + }, + "dependencies": { + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "cacheable-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", + "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^3.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^1.0.2" + }, + "dependencies": { + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "requires": { + "pump": "^3.0.0" + } + }, + "http-cache-semantics": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", + "integrity": "sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew==" + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + } + } + }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "dev": true, + "requires": { + "callsites": "^2.0.0" + }, + "dependencies": { + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + } + } + }, + "caller-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", + "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "caniuse-lite": { + "version": "1.0.30000974", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000974.tgz", + "integrity": "sha512-xc3rkNS/Zc3CmpMKuczWEdY2sZgx09BkAxfvkxlAEBTqcMHeL8QnPqhKse+5sRTi3nrw2pJwToD2WvKn1Uhvww==" + }, + "capture-stack-trace": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", + "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==", + "dev": true + }, + "cardinal": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/cardinal/-/cardinal-2.1.1.tgz", + "integrity": "sha1-fMEFXYItISlU0HsIXeolHMe8VQU=", + "dev": true, + "requires": { + "ansicolors": "~0.3.2", + "redeyed": "~2.1.0" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chai-as-promised": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", + "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "dev": true, + "requires": { + "check-error": "^1.0.2" + } + }, + "chai-bn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.1.1.tgz", + "integrity": "sha512-e1npVXt3cQfZ6oQET9oP38vNj/4HeJ4ojeUpuC8YzhVbTJpIDqANVt7TKi7Dq9yKlHySk2FqbmiMih35iT4DYg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", + "dev": true + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "checkpoint-store": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/checkpoint-store/-/checkpoint-store-1.1.0.tgz", + "integrity": "sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY=", + "requires": { + "functional-red-black-tree": "^1.0.1" + } + }, + "chokidar": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", + "integrity": "sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==", + "dev": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + }, + "dependencies": { + "fsevents": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "chownr": { "version": "1.1.1", "bundled": true, @@ -3745,6 +4370,21 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dev": true + }, "convert-source-map": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", @@ -3753,6 +4393,24 @@ "safe-buffer": "~5.1.1" } }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "dev": true + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, + "cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==", + "dev": true + }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", @@ -3782,6 +4440,16 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cors": { + "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", + "vary": "^1" + } + }, "cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -3838,6 +4506,16 @@ } } }, + "create-ecdh": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, "create-error-class": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", @@ -3909,6 +4587,31 @@ "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", "dev": true }, + "crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + } + }, + "crypto-js": { + "version": "3.1.9-1", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz", + "integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg=", + "dev": true + }, "crypto-random-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", @@ -3924,6 +4627,16 @@ "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=" }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dev": true, + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -3950,6 +4663,22 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, + "decompress": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.0.tgz", + "integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=", + "dev": true, + "requires": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + } + }, "decompress-response": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", @@ -3958,6 +4687,79 @@ "mimic-response": "^1.0.0" } }, + "decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "dev": true, + "requires": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + } + }, + "decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "dev": true, + "requires": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "dependencies": { + "file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", + "dev": true + } + } + }, + "decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "dev": true, + "requires": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + } + }, + "decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=", + "dev": true, + "requires": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "dependencies": { + "file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=", + "dev": true + }, + "get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + } + } + } + }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -4059,6 +4861,28 @@ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "optional": true }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true + }, + "des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, "detect-indent": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", @@ -4081,8 +4905,18 @@ "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + }, + "diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } }, "dir-to-object": { "version": "2.0.0", @@ -4147,6 +4981,12 @@ "safer-buffer": "^2.1.0" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, "electron-to-chromium": { "version": "1.3.159", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.159.tgz", @@ -4171,6 +5011,12 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "dev": true + }, "encoding": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", @@ -4232,6 +5078,28 @@ "is-symbol": "^1.0.2" } }, + "es5-ext": { + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", + "dev": true, + "requires": { + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, "es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", @@ -4245,6 +5113,22 @@ "es6-promise": "^4.0.3" } }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dev": true, + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -4691,6 +5575,12 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "dev": true + }, "eth-block-tracker": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz", @@ -4705,6 +5595,24 @@ "tape": "^4.6.3" } }, + "eth-ens-namehash": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", + "integrity": "sha1-IprEbsqG1S4MmR58sq74P/D2i88=", + "dev": true, + "requires": { + "idna-uts46-hx": "^2.3.1", + "js-sha3": "^0.5.7" + }, + "dependencies": { + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + } + } + }, "eth-gas-reporter": { "version": "0.2.11", "resolved": "https://registry.npmjs.org/eth-gas-reporter/-/eth-gas-reporter-0.2.11.tgz", @@ -4824,11 +5732,50 @@ } } }, + "ethereum-bloom-filters": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.6.tgz", + "integrity": "sha512-dE9CGNzgOOsdh7msZirvv8qjHtnHpvBlKe2647kM8v+yeF71IRso55jpojemvHV+jMjr48irPWxMRaHuOWzAFA==", + "dev": true, + "requires": { + "js-sha3": "^0.8.0" + }, + "dependencies": { + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", + "dev": true + } + } + }, "ethereum-common": { "version": "0.0.18", "resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.0.18.tgz", "integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=" }, + "ethereum-ens": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/ethereum-ens/-/ethereum-ens-0.7.8.tgz", + "integrity": "sha512-HJBDmF5/abP/IIM6N7rGHmmlQ4yCKIVK4kzT/Mu05+eZn0i5ZlR25LTAE47SVZ7oyTBvOkNJhxhSkWRvjh7srg==", + "dev": true, + "requires": { + "bluebird": "^3.4.7", + "eth-ens-namehash": "^2.0.0", + "js-sha3": "^0.5.7", + "pako": "^1.0.4", + "underscore": "^1.8.3", + "web3": "^1.0.0-beta.34" + }, + "dependencies": { + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + } + } + }, "ethereum-types": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/ethereum-types/-/ethereum-types-2.1.5.tgz", @@ -5046,6 +5993,31 @@ } } }, + "ethjs-abi": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz", + "integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=", + "dev": true, + "requires": { + "bn.js": "4.11.6", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "dev": true + }, + "js-sha3": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", + "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=", + "dev": true + } + } + }, "ethjs-unit": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", @@ -5071,6 +6043,12 @@ "strip-hex-prefix": "1.0.0" } }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", + "dev": true + }, "events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", @@ -5138,16 +6116,88 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "optional": true + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "dev": true, + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true } } }, - "expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "optional": true + "ext": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", + "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", + "dev": true, + "requires": { + "type": "^2.0.0" + }, + "dependencies": { + "type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", + "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==", + "dev": true + } + } }, "extend": { "version": "3.0.2", @@ -5294,6 +6344,15 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, "fetch-ponyfill": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz", @@ -5325,6 +6384,12 @@ "flat-cache": "^2.0.1" } }, + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=", + "dev": true + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -5353,6 +6418,32 @@ } } }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -5448,6 +6539,12 @@ "mime-types": "^2.1.12" } }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "dev": true + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -5457,6 +6554,12 @@ "map-cache": "^0.2.2" } }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "dev": true + }, "from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -5469,8 +6572,7 @@ "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "optional": true + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" }, "fs-extra": { "version": "0.30.0", @@ -19415,6 +20517,12 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -19475,11 +20583,26 @@ "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, + "has-symbol-support-x": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz", + "integrity": "sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw==", + "dev": true + }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" }, + "has-to-string-tag-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", + "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "dev": true, + "requires": { + "has-symbol-support-x": "^1.4.1" + } + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -19553,8 +20676,7 @@ "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, "hmac-drbg": { "version": "1.0.1", @@ -19597,6 +20719,25 @@ "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==" }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "http-https": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz", + "integrity": "sha1-L5CN1fHbQGjAWM1ubUzjkskTOJs=", + "dev": true + }, "http-proxy-agent": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", @@ -19650,6 +20791,29 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "idna-uts46-hx": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz", + "integrity": "sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA==", + "dev": true, + "requires": { + "punycode": "2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", + "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=", + "dev": true + } + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "dev": true + }, "iferr": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", @@ -19800,28 +20964,210 @@ } } }, - "invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "requires": { + "loose-envify": "^1.0.0" + } + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", + "dev": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==" + }, + "is-ci": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", + "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "dev": true, + "requires": { + "ci-info": "^1.5.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-fn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fn/-/is-fn-1.0.0.tgz", + "integrity": "sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-function": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", + "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-hex-prefixed": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", + "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=" + }, + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", "requires": { - "loose-envify": "^1.0.0" + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" } }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + "is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=", + "dev": true }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "is-npm": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", + "dev": true }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -19838,1579 +21184,1992 @@ } } }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" + }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", "dev": true }, - "is-binary-path": { + "is-path-inside": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "requires": { + "path-is-inside": "^1.0.1" + } + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "binary-extensions": "^1.0.0" + "isobject": "^3.0.1" } }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==" + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", + "dev": true }, - "is-ci": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", - "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", - "dev": true, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", "requires": { - "ci-info": "^1.5.0" + "has": "^1.0.1" } }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", "requires": { - "kind-of": "^3.0.2" + "has-symbols": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-yarn-global": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", + "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "istanbul": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "requires": { + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" }, "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, + "abbrev": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=" + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "requires": { - "is-buffer": "^1.1.5" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1" + } + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=" + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "requires": { + "has-flag": "^1.0.0" } } } }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" + "isurl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", + "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", + "dev": true, + "requires": { + "has-to-string-tag-x": "^1.2.0", + "is-object": "^1.0.1" + } + }, + "jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=" + }, + "js-sha3": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.7.0.tgz", + "integrity": "sha512-Wpks3yBDm0UcL5qlVhwW9Jr9n9i4FfeWBFOOXP5puDS/SiudJGhw7DPyBqn3487qD4F0lsC0q3zxink37f7zeA==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" }, "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" } } }, - "is-directory": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", - "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", - "dev": true - }, - "is-extendable": { + "jsbn": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=" }, - "is-finite": { + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=" + }, + "json-parse-better-errors": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" + }, + "json-parse-helpfulerror": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/json-parse-helpfulerror/-/json-parse-helpfulerror-1.0.3.tgz", + "integrity": "sha1-E/FM4C7tTpgSl7ZOueO5MuLdE9w=", "requires": { - "number-is-nan": "^1.0.0" + "jju": "^1.1.0" } }, - "is-fn": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fn/-/is-fn-1.0.0.tgz", - "integrity": "sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw=" + "json-rpc-engine": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz", + "integrity": "sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA==", + "requires": { + "async": "^2.0.1", + "babel-preset-env": "^1.7.0", + "babelify": "^7.3.0", + "json-rpc-error": "^2.0.0", + "promise-to-callback": "^1.0.0", + "safe-event-emitter": "^1.0.1" + }, + "dependencies": { + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + } + } }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "json-rpc-error": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/json-rpc-error/-/json-rpc-error-2.0.0.tgz", + "integrity": "sha1-p6+cICg4tekFxyUOVH8a/3cligI=", "requires": { - "number-is-nan": "^1.0.0" + "inherits": "^2.0.1" } }, - "is-function": { + "json-rpc-random-id": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", - "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=" + "resolved": "https://registry.npmjs.org/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz", + "integrity": "sha1-uknZat7RRE27jaPSA3SKy7zeyMg=" }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "requires": { - "is-extglob": "^2.1.1" - } + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, - "is-hex-prefixed": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", - "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=" + "json-schema-traverse": { + "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==" }, - "is-installed-globally": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", - "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "requires": { - "global-dirs": "^0.1.0", - "is-path-inside": "^1.0.0" + "jsonify": "~0.0.0" } }, - "is-npm": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } + "graceful-fs": "^4.1.6" } }, - "is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" }, - "is-path-inside": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" + }, + "jsonschema": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.4.tgz", + "integrity": "sha512-lz1nOH69GbsVHeVgEdvyavc/33oymY1AZwtePMiMj4HZPMbP5OIKK3zT9INMWjwua/V4Z4yq7wSlBbSG+g4AEw==" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", "requires": { - "path-is-inside": "^1.0.1" + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" } }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, + "keccak": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz", + "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", "requires": { - "isobject": "^3.0.1" + "bindings": "^1.2.1", + "inherits": "^2.0.3", + "nan": "^2.2.1", + "safe-buffer": "^5.1.0" } }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, - "is-redirect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", - "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", - "dev": true - }, - "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "keyv": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", + "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", "requires": { - "has": "^1.0.1" + "json-buffer": "3.0.0" } }, - "is-retry-allowed": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", - "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", "requires": { - "has-symbols": "^1.0.0" + "graceful-fs": "^4.1.9" } }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==" }, - "is-yarn-global": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", - "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==" + "latest-version": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", + "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", + "dev": true, + "requires": { + "package-json": "^4.0.0" + } }, - "isarray": { + "lcid": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "^1.0.0" + } }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", "dev": true }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "level-codec": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz", + "integrity": "sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==" + }, + "level-errors": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.0.5.tgz", + "integrity": "sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==", "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" + "errno": "~0.1.1" } }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + "level-iterator-stream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz", + "integrity": "sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=", + "requires": { + "inherits": "^2.0.1", + "level-errors": "^1.0.3", + "readable-stream": "^1.0.33", + "xtend": "^4.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + } + } }, - "istanbul": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", - "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "level-ws": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/level-ws/-/level-ws-0.0.0.tgz", + "integrity": "sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos=", "requires": { - "abbrev": "1.0.x", - "async": "1.x", - "escodegen": "1.8.x", - "esprima": "2.7.x", - "glob": "^5.0.15", - "handlebars": "^4.0.1", - "js-yaml": "3.x", - "mkdirp": "0.5.x", - "nopt": "3.x", - "once": "1.x", - "resolve": "1.1.x", - "supports-color": "^3.1.0", - "which": "^1.1.1", - "wordwrap": "^1.0.0" + "readable-stream": "~1.0.15", + "xtend": "~2.1.1" }, "dependencies": { - "abbrev": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=" + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" }, - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "object-keys": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", + "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=" + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "xtend": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", + "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", "requires": { - "abbrev": "1" + "object-keys": "~0.4.0" + } + } + } + }, + "levelup": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/levelup/-/levelup-1.3.9.tgz", + "integrity": "sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==", + "requires": { + "deferred-leveldown": "~1.2.1", + "level-codec": "~7.0.0", + "level-errors": "~1.0.3", + "level-iterator-stream": "~1.3.0", + "prr": "~1.0.1", + "semver": "~5.4.1", + "xtend": "~4.0.0" + }, + "dependencies": { + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + } + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "libnpmconfig": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/libnpmconfig/-/libnpmconfig-1.2.1.tgz", + "integrity": "sha512-9esX8rTQAHqarx6qeZqmGQKBNZR5OIbl/Ayr0qQDy3oXja2iFVQQI81R6GZ2a02bSNZ9p3YOGX1O6HHCb1X7kA==", + "requires": { + "figgy-pudding": "^3.5.1", + "find-up": "^3.0.0", + "ini": "^1.3.5" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "^3.0.0" } }, - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=" + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } }, - "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "requires": { - "has-flag": "^1.0.0" + "p-limit": "^2.0.0" } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" } } }, - "jju": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", - "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=" - }, - "js-sha3": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.7.0.tgz", - "integrity": "sha512-Wpks3yBDm0UcL5qlVhwW9Jr9n9i4FfeWBFOOXP5puDS/SiudJGhw7DPyBqn3487qD4F0lsC0q3zxink37f7zeA==" - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" }, "dependencies": { - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" } } }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, - "jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=" + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", + "dev": true }, - "json-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", - "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=" + "lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", + "dev": true }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" + "lodash.values": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-4.3.0.tgz", + "integrity": "sha1-o6bCsOvsxcLLocF+bmIP6BtT00c=" }, - "json-parse-helpfulerror": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/json-parse-helpfulerror/-/json-parse-helpfulerror-1.0.3.tgz", - "integrity": "sha1-E/FM4C7tTpgSl7ZOueO5MuLdE9w=", + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "loglevel": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.4.tgz", + "integrity": "sha512-p0b6mOGKcGa+7nnmKbpzR6qloPbrgLcnio++E+14Vo/XffOGwZtRpUhr8dTH/x2oCMmEoIU0Zwm3ZauhvYD17g==" + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "jju": "^1.1.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, - "json-rpc-engine": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz", - "integrity": "sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA==", + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "requires": { - "async": "^2.0.1", - "babel-preset-env": "^1.7.0", - "babelify": "^7.3.0", - "json-rpc-error": "^2.0.0", - "promise-to-callback": "^1.0.0", - "safe-event-emitter": "^1.0.1" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "ltgt": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz", + "integrity": "sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=" + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "requires": { + "pify": "^3.0.0" }, "dependencies": { - "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + } + } + }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "dev": true + }, + "make-fetch-happen": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-5.0.0.tgz", + "integrity": "sha512-nFr/vpL1Jc60etMVKeaLOqfGjMMb3tAHFVJWxHOFCFS04Zmd7kGlMxo0l1tzfhoQje0/UPnd0X8OeGUiXXnfPA==", + "requires": { + "agentkeepalive": "^3.4.1", + "cacache": "^12.0.0", + "http-cache-semantics": "^3.8.1", + "http-proxy-agent": "^2.1.0", + "https-proxy-agent": "^2.2.1", + "lru-cache": "^5.1.1", + "mississippi": "^3.0.0", + "node-fetch-npm": "^2.0.2", + "promise-retry": "^1.1.1", + "socks-proxy-agent": "^4.0.0", + "ssri": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "requires": { - "lodash": "^4.17.11" + "yallist": "^3.0.2" } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, - "json-rpc-error": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/json-rpc-error/-/json-rpc-error-2.0.0.tgz", - "integrity": "sha1-p6+cICg4tekFxyUOVH8a/3cligI=", + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, "requires": { - "inherits": "^2.0.1" + "object-visit": "^1.0.0" } }, - "json-rpc-random-id": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz", - "integrity": "sha1-uknZat7RRE27jaPSA3SKy7zeyMg=" + "markdown-table": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz", + "integrity": "sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==", + "dev": true }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + "marked": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz", + "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==", + "dev": true }, - "json-schema-traverse": { - "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==" + "marked-terminal": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-3.3.0.tgz", + "integrity": "sha512-+IUQJ5VlZoAFsM5MHNT7g3RHSkA3eETqhRCdXv4niUMAKHQ7lb1yvAcuGPmm4soxhmtX13u4Li6ZToXtvSEH+A==", + "dev": true, + "requires": { + "ansi-escapes": "^3.1.0", + "cardinal": "^2.1.1", + "chalk": "^2.4.1", + "cli-table": "^0.3.1", + "node-emoji": "^1.4.1", + "supports-hyperlinks": "^1.0.1" + } }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "requires": { - "jsonify": "~0.0.0" + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "json5": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" - }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", "requires": { - "graceful-fs": "^4.1.6" + "mimic-fn": "^1.0.0" } }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + "memdown": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/memdown/-/memdown-1.4.1.tgz", + "integrity": "sha1-tOThkhdGZP+65BNhqlAPMRnv4hU=", + "requires": { + "abstract-leveldown": "~2.7.1", + "functional-red-black-tree": "^1.0.1", + "immediate": "^3.2.3", + "inherits": "~2.0.1", + "ltgt": "~2.2.0", + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "abstract-leveldown": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz", + "integrity": "sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w==", + "requires": { + "xtend": "~4.0.0" + } + } + } }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" + "memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=" }, - "jsonschema": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.4.tgz", - "integrity": "sha512-lz1nOH69GbsVHeVgEdvyavc/33oymY1AZwtePMiMj4HZPMbP5OIKK3zT9INMWjwua/V4Z4yq7wSlBbSG+g4AEw==" + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "merkle-patricia-tree": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz", + "integrity": "sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==", "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" + "async": "^1.4.2", + "ethereumjs-util": "^5.0.0", + "level-ws": "0.0.0", + "levelup": "^1.2.1", + "memdown": "^1.0.0", + "readable-stream": "^2.0.0", + "rlp": "^2.0.0", + "semaphore": ">=1.0.1" } }, - "keccak": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz", - "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, "requires": { - "bindings": "^1.2.1", - "inherits": "^2.0.3", - "nan": "^2.2.1", - "safe-buffer": "^5.1.0" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } }, - "keyv": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", - "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, "requires": { - "json-buffer": "3.0.0" + "bn.js": "^4.0.0", + "brorand": "^1.0.1" } }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "mime-db": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", + "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + }, + "mime-types": { + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", + "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", "requires": { - "graceful-fs": "^4.1.9" + "mime-db": "~1.38.0" } }, - "kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==" + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" }, - "latest-version": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", - "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", - "dev": true, - "requires": { - "package-json": "^4.0.0" - } + "mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", "requires": { - "invert-kv": "^1.0.0" + "dom-walk": "^0.1.0" } }, - "lcov-parse": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", - "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", - "dev": true + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, - "level-codec": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz", - "integrity": "sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==" + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" }, - "level-errors": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.0.5.tgz", - "integrity": "sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==", + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "errno": "~0.1.1" + "brace-expansion": "^1.1.7" } }, - "level-iterator-stream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz", - "integrity": "sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=", + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "requires": { - "inherits": "^2.0.1", - "level-errors": "^1.0.3", - "readable-stream": "^1.0.33", - "xtend": "^4.0.0" + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "requires": { + "minipass": "^2.2.1" + } + }, + "mississippi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", + "integrity": "sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==", + "requires": { + "concat-stream": "^1.5.0", + "duplexify": "^3.4.2", + "end-of-stream": "^1.1.0", + "flush-write-stream": "^1.0.0", + "from2": "^2.1.0", + "parallel-transform": "^1.1.0", + "pump": "^3.0.0", + "pumpify": "^1.3.3", + "stream-each": "^1.1.0", + "through2": "^2.0.0" + }, + "dependencies": { + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" } } }, - "level-ws": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/level-ws/-/level-ws-0.0.0.tgz", - "integrity": "sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos=", + "mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, "requires": { - "readable-stream": "~1.0.15", - "xtend": "~2.1.1" + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=" - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, "requires": { - "object-keys": "~0.4.0" + "is-plain-object": "^2.0.4" } } } }, - "levelup": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/levelup/-/levelup-1.3.9.tgz", - "integrity": "sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==", + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { - "deferred-leveldown": "~1.2.1", - "level-codec": "~7.0.0", - "level-errors": "~1.0.3", - "level-iterator-stream": "~1.3.0", - "prr": "~1.0.1", - "semver": "~5.4.1", - "xtend": "~4.0.0" - }, - "dependencies": { - "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" - } + "minimist": "0.0.8" } }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "mkdirp-promise": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz", + "integrity": "sha1-6bj2jlUsaKnBcTuEiD96HdA5uKE=", + "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "mkdirp": "*" } }, - "libnpmconfig": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/libnpmconfig/-/libnpmconfig-1.2.1.tgz", - "integrity": "sha512-9esX8rTQAHqarx6qeZqmGQKBNZR5OIbl/Ayr0qQDy3oXja2iFVQQI81R6GZ2a02bSNZ9p3YOGX1O6HHCb1X7kA==", + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "requires": { - "figgy-pudding": "^3.5.1", - "find-up": "^3.0.0", - "ini": "^1.3.5" + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" }, "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" } } }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", - "dev": true, + "mock-fs": { + "version": "4.10.4", + "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.10.4.tgz", + "integrity": "sha512-gDfZDLaPIvtOusbusLinfx6YSe2YpQsDT8qdP41P47dQ/NQggtkHukz7hwqgt8QvMBmAv+Z6DGmXPyb5BWX2nQ==", + "dev": true + }, + "move-concurrently": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", + "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", + "requires": { + "aproba": "^1.1.1", + "copy-concurrently": "^1.0.0", + "fs-write-stream-atomic": "^1.0.8", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.3" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "nan": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" + }, + "nano-json-stream-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", + "integrity": "sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18=", + "dev": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "napi-build-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.1.tgz", + "integrity": "sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==", + "optional": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "dev": true + }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" + }, + "nested-error-stacks": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-2.0.1.tgz", + "integrity": "sha512-SrQrok4CATudVzBS7coSz26QRSmlK9TzzoFbeKfcPBUFPjcQM9Rqvr/DlJkOrwI/0KcgvMub1n1g5Jt9EgRn4A==" + }, + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-abi": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.8.0.tgz", + "integrity": "sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==", + "optional": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" + "semver": "^5.4.1" } }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "node-alias": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/node-alias/-/node-alias-1.0.4.tgz", + "integrity": "sha1-HxuRa1a56iQcATX5fO1pQPVW8pI=", "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "chalk": "^1.1.1", + "lodash": "^4.2.0" }, "dependencies": { - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" } } }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" - }, - "lodash.toarray": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", - "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", - "dev": true - }, - "lodash.values": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-4.3.0.tgz", - "integrity": "sha1-o6bCsOvsxcLLocF+bmIP6BtT00c=" - }, - "log-driver": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", - "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", - "dev": true - }, - "loglevel": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.4.tgz", - "integrity": "sha512-p0b6mOGKcGa+7nnmKbpzR6qloPbrgLcnio++E+14Vo/XffOGwZtRpUhr8dTH/x2oCMmEoIU0Zwm3ZauhvYD17g==" - }, - "loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "node-emoji": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", + "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", + "dev": true, "requires": { - "js-tokens": "^3.0.0 || ^4.0.0" + "lodash.toarray": "^4.4.0" } }, - "lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" - }, - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "encoding": "^0.1.11", + "is-stream": "^1.0.1" } }, - "ltgt": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz", - "integrity": "sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=" + "node-fetch-npm": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz", + "integrity": "sha512-nJIxm1QmAj4v3nfCvEeCrYSoVwXyxLnaPBK5W1W5DGEJwjlKuC2VEUycGw5oxk+4zZahRrB84PUJJgEmhFTDFw==", + "requires": { + "encoding": "^0.1.11", + "json-parse-better-errors": "^1.0.0", + "safe-buffer": "^5.1.1" + } }, - "make-dir": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "node-hid": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/node-hid/-/node-hid-0.7.9.tgz", + "integrity": "sha512-vJnonTqmq3frCyTumJqG4g2IZcny3ynkfmbfDfQ90P3ZhRzcWYS/Um1ux6HFmAxmkaQnrZqIYHcGpL7kdqY8jA==", + "optional": true, "requires": { - "pify": "^3.0.0" + "bindings": "^1.5.0", + "nan": "^2.13.2", + "prebuild-install": "^5.3.0" }, "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "optional": true } } }, - "make-error": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", - "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", - "dev": true - }, - "make-fetch-happen": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-5.0.0.tgz", - "integrity": "sha512-nFr/vpL1Jc60etMVKeaLOqfGjMMb3tAHFVJWxHOFCFS04Zmd7kGlMxo0l1tzfhoQje0/UPnd0X8OeGUiXXnfPA==", + "nodemon": { + "version": "1.18.10", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.18.10.tgz", + "integrity": "sha512-we51yBb1TfEvZamFchRgcfLbVYgg0xlGbyXmOtbBzDwxwgewYS/YbZ5tnlnsH51+AoSTTsT3A2E/FloUbtH8cQ==", + "dev": true, "requires": { - "agentkeepalive": "^3.4.1", - "cacache": "^12.0.0", - "http-cache-semantics": "^3.8.1", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "lru-cache": "^5.1.1", - "mississippi": "^3.0.0", - "node-fetch-npm": "^2.0.2", - "promise-retry": "^1.1.1", - "socks-proxy-agent": "^4.0.0", - "ssri": "^6.0.0" + "chokidar": "^2.1.0", + "debug": "^3.1.0", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.0.4", + "pstree.remy": "^1.1.6", + "semver": "^5.5.0", + "supports-color": "^5.2.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.2", + "update-notifier": "^2.5.0" }, "dependencies": { - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "requires": { - "yallist": "^3.0.2" + "has-flag": "^3.0.0" } - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "markdown-table": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz", - "integrity": "sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==", - "dev": true - }, - "marked": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz", - "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==", - "dev": true + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=", + "optional": true }, - "marked-terminal": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-3.3.0.tgz", - "integrity": "sha512-+IUQJ5VlZoAFsM5MHNT7g3RHSkA3eETqhRCdXv4niUMAKHQ7lb1yvAcuGPmm4soxhmtX13u4Li6ZToXtvSEH+A==", + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", "dev": true, "requires": { - "ansi-escapes": "^3.1.0", - "cardinal": "^2.1.1", - "chalk": "^2.4.1", - "cli-table": "^0.3.1", - "node-emoji": "^1.4.1", - "supports-hyperlinks": "^1.0.1" - } - }, - "md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" + "abbrev": "1" } }, - "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "requires": { - "mimic-fn": "^1.0.0" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, - "memdown": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/memdown/-/memdown-1.4.1.tgz", - "integrity": "sha1-tOThkhdGZP+65BNhqlAPMRnv4hU=", + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "normalize-url": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.3.0.tgz", + "integrity": "sha512-0NLtR71o4k6GLP+mr6Ty34c5GA6CMoEsncKJxvQd8NzPxaHRJNnb5gZE8R1XF4CPIS7QPHLJ74IFszwtNVAHVQ==" + }, + "npm-bundled": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" + }, + "npm-check-updates": { + "version": "3.1.20", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-3.1.20.tgz", + "integrity": "sha512-mc9BAoOYSTwP/IvoA+ofdkWSipwRvhgC0qop1PvlMZojgzi7N/dykdxOIWrw0OlZPnEKvXkKFEuPk97LrvXE1A==", "requires": { - "abstract-leveldown": "~2.7.1", - "functional-red-black-tree": "^1.0.1", - "immediate": "^3.2.3", - "inherits": "~2.0.1", - "ltgt": "~2.2.0", - "safe-buffer": "~5.1.1" + "chalk": "^2.4.2", + "cint": "^8.2.1", + "cli-table": "^0.3.1", + "commander": "^2.20.0", + "fast-diff": "^1.2.0", + "find-up": "4.1.0", + "get-stdin": "^7.0.0", + "json-parse-helpfulerror": "^1.0.3", + "libnpmconfig": "^1.2.1", + "lodash": "^4.17.13", + "node-alias": "^1.0.4", + "pacote": "^9.5.1", + "progress": "^2.0.3", + "prompts": "^2.1.0", + "rc-config-loader": "^2.0.4", + "requireg": "^0.2.2", + "semver": "^6.2.0", + "semver-utils": "^1.1.4", + "spawn-please": "^0.3.0", + "update-notifier": "^3.0.1" }, "dependencies": { - "abstract-leveldown": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz", - "integrity": "sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w==", + "ansi-align": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", + "integrity": "sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==", + "requires": { + "string-width": "^3.0.0" + } + }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "boxen": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-3.2.0.tgz", + "integrity": "sha512-cU4J/+NodM3IHdSL2yN8bqYqnmlBTidDR4RC7nJs61ZmtGz8VZzM3HLQX0zY5mrSmPtR3xWwsq2jOUQqFZN8+A==", + "requires": { + "ansi-align": "^3.0.0", + "camelcase": "^5.3.1", + "chalk": "^2.4.2", + "cli-boxes": "^2.2.0", + "string-width": "^3.0.0", + "term-size": "^1.2.0", + "type-fest": "^0.3.0", + "widest-line": "^2.0.0" + } + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" + }, + "cli-boxes": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.0.tgz", + "integrity": "sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w==" + }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==" + }, + "configstore": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-4.0.0.tgz", + "integrity": "sha512-CmquAXFBocrzaSM8mtGPMM/HiWmyIpr4CcJl/rgY2uCObZ/S7cKU0silxslqJejl+t/T9HS8E0PUNQD81JGUEQ==", + "requires": { + "dot-prop": "^4.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "get-stdin": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", + "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==" + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "requires": { + "pump": "^3.0.0" + } + }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "requires": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + } + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-npm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-3.0.0.tgz", + "integrity": "sha512-wsigDr1Kkschp2opC4G3yA6r9EgVA6NjRpWzIi9axXqeIaAATPRJc4uLujXe3Nd9uO8KoDyA4MD6aZSeXTADhA==" + }, + "latest-version": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", + "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", + "requires": { + "package-json": "^6.3.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "package-json": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.4.0.tgz", + "integrity": "sha512-bd1T8OBG7hcvMd9c/udgv6u5v9wISP3Oyl9Cm7Weop8EFwrtcQDnS2sb6zhwqus2WslSr5wSTIPiTTpxxmPm7Q==", + "requires": { + "got": "^9.6.0", + "registry-auth-token": "^3.4.0", + "registry-url": "^5.0.0", + "semver": "^6.1.1" + } + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "registry-url": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", + "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", + "requires": { + "rc": "^1.2.8" + } + }, + "semver": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", + "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "update-notifier": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-3.0.1.tgz", + "integrity": "sha512-grrmrB6Zb8DUiyDIaeRTBCkgISYUgETNe7NglEbVsrLWXeESnlCSP50WfRSj/GmzMPl6Uchj24S/p80nP/ZQrQ==", + "requires": { + "boxen": "^3.0.0", + "chalk": "^2.0.1", + "configstore": "^4.0.0", + "has-yarn": "^2.1.0", + "import-lazy": "^2.1.0", + "is-ci": "^2.0.0", + "is-installed-globally": "^0.1.0", + "is-npm": "^3.0.0", + "is-yarn-global": "^0.3.0", + "latest-version": "^5.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", "requires": { - "xtend": "~4.0.0" + "prepend-http": "^2.0.0" } } } }, - "memorystream": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", - "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=" - }, - "merkle-patricia-tree": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz", - "integrity": "sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==", + "npm-package-arg": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-6.1.0.tgz", + "integrity": "sha512-zYbhP2k9DbJhA0Z3HKUePUgdB1x7MfIfKssC+WLPFMKTBZKpZh5m13PgexJjCq6KW7j17r0jHWcCpxEqnnncSA==", "requires": { - "async": "^1.4.2", - "ethereumjs-util": "^5.0.0", - "level-ws": "0.0.0", - "levelup": "^1.2.1", - "memdown": "^1.0.0", - "readable-stream": "^2.0.0", - "rlp": "^2.0.0", - "semaphore": ">=1.0.1" + "hosted-git-info": "^2.6.0", + "osenv": "^0.1.5", + "semver": "^5.5.0", + "validate-npm-package-name": "^3.0.0" } }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, + "npm-packlist": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", + "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" } }, - "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" - }, - "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "npm-pick-manifest": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.2.3.tgz", + "integrity": "sha512-+IluBC5K201+gRU85vFlUwX3PFShZAbAgDNp2ewJdWMVSppdo/Zih0ul2Ecky/X7b51J7LrrUAP+XOmOCvYZqA==", "requires": { - "mime-db": "~1.38.0" + "figgy-pudding": "^3.5.1", + "npm-package-arg": "^6.0.0", + "semver": "^5.4.1" } }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" - }, - "mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" - }, - "min-document": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", - "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "npm-registry-fetch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.0.tgz", + "integrity": "sha512-Jllq35Jag8dtv0M17ue74XtdQTyqKzuAYGiX9mAjOhkmNjib3bBUgK6mUY61+AHnXeSRobQkpY3/xIOS/omptw==", "requires": { - "dom-walk": "^0.1.0" + "JSONStream": "^1.3.4", + "bluebird": "^3.5.1", + "figgy-pudding": "^3.4.1", + "lru-cache": "^5.1.1", + "make-fetch-happen": "^5.0.0", + "npm-package-arg": "^6.1.0" + }, + "dependencies": { + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } } }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" - }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "^2.0.0" + } }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, "requires": { - "brace-expansion": "^1.1.7" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, - "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "number-to-bn": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", + "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" + "bn.js": "4.11.6", + "strip-hex-prefix": "1.0.0" }, "dependencies": { - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" } } }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "requires": { - "minipass": "^2.2.1" - } + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "mississippi": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", - "integrity": "sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==", + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, "requires": { - "concat-stream": "^1.5.0", - "duplexify": "^3.4.2", - "end-of-stream": "^1.1.0", - "flush-write-stream": "^1.0.0", - "from2": "^2.1.0", - "parallel-transform": "^1.1.0", - "pump": "^3.0.0", - "pumpify": "^1.3.3", - "stream-each": "^1.1.0", - "through2": "^2.0.0" + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" }, "dependencies": { - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" } } } }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==" + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", "dev": true, "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" } }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, "requires": { - "minimist": "0.0.8" + "isobject": "^3.0.1" } }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", "dev": true, "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "dependencies": { - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - } + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" } }, - "move-concurrently": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", - "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", + "oboe": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.4.tgz", + "integrity": "sha1-IMiM2wwVNxuwQRklfU/dNLCqSfY=", + "dev": true, "requires": { - "aproba": "^1.1.1", - "copy-concurrently": "^1.0.0", - "fs-write-stream-atomic": "^1.0.8", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.4", - "run-queue": "^1.0.3" + "http-https": "^1.0.0" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "ee-first": "1.1.1" } }, - "napi-build-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.1.tgz", - "integrity": "sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==", - "optional": true - }, - "natural-compare": { + "once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "neo-async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", - "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } }, - "nested-error-stacks": { + "onetime": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-2.0.1.tgz", - "integrity": "sha512-SrQrok4CATudVzBS7coSz26QRSmlK9TzzoFbeKfcPBUFPjcQM9Rqvr/DlJkOrwI/0KcgvMub1n1g5Jt9EgRn4A==" - }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, - "node-abi": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.8.0.tgz", - "integrity": "sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==", - "optional": true, + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, "requires": { - "semver": "^5.4.1" + "mimic-fn": "^1.0.0" } }, - "node-alias": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/node-alias/-/node-alias-1.0.4.tgz", - "integrity": "sha1-HxuRa1a56iQcATX5fO1pQPVW8pI=", + "openzeppelin-solidity": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/openzeppelin-solidity/-/openzeppelin-solidity-1.12.0.tgz", + "integrity": "sha512-WlorzMXIIurugiSdw121RVD5qA3EfSI7GybTn+/Du0mPNgairjt29NpVTAaH8eLjAeAwlw46y7uQKy0NYem/gA==" + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "requires": { - "chalk": "^1.1.1", - "lodash": "^4.2.0" + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" } } }, - "node-emoji": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", - "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", - "dev": true, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "requires": { - "lodash.toarray": "^4.4.0" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" } }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "original-require": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/original-require/-/original-require-1.0.1.tgz", + "integrity": "sha1-DxMEcVhM0zURxew4yNWSE/msXiA=" + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, - "node-fetch-npm": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz", - "integrity": "sha512-nJIxm1QmAj4v3nfCvEeCrYSoVwXyxLnaPBK5W1W5DGEJwjlKuC2VEUycGw5oxk+4zZahRrB84PUJJgEmhFTDFw==", + "p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==" + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "requires": { - "encoding": "^0.1.11", - "json-parse-better-errors": "^1.0.0", - "safe-buffer": "^5.1.1" + "p-try": "^1.0.0" } }, - "node-hid": { - "version": "0.7.9", - "resolved": "https://registry.npmjs.org/node-hid/-/node-hid-0.7.9.tgz", - "integrity": "sha512-vJnonTqmq3frCyTumJqG4g2IZcny3ynkfmbfDfQ90P3ZhRzcWYS/Um1ux6HFmAxmkaQnrZqIYHcGpL7kdqY8jA==", - "optional": true, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "requires": { - "bindings": "^1.5.0", - "nan": "^2.13.2", - "prebuild-install": "^5.3.0" - }, - "dependencies": { - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "optional": true - } + "p-limit": "^1.1.0" } }, - "nodemon": { - "version": "1.18.10", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.18.10.tgz", - "integrity": "sha512-we51yBb1TfEvZamFchRgcfLbVYgg0xlGbyXmOtbBzDwxwgewYS/YbZ5tnlnsH51+AoSTTsT3A2E/FloUbtH8cQ==", + "p-timeout": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-1.2.1.tgz", + "integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=", "dev": true, "requires": { - "chokidar": "^2.1.0", - "debug": "^3.1.0", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.0.4", - "pstree.remy": "^1.1.6", - "semver": "^5.5.0", - "supports-color": "^5.2.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.2", - "update-notifier": "^2.5.0" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "p-finally": "^1.0.0" } }, - "noop-logger": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", - "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=", - "optional": true + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" }, - "nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", "dev": true, "requires": { - "abbrev": "1" - } - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" + "got": "^6.7.1", + "registry-auth-token": "^3.0.1", + "registry-url": "^3.0.3", + "semver": "^5.1.0" } }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "normalize-url": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.3.0.tgz", - "integrity": "sha512-0NLtR71o4k6GLP+mr6Ty34c5GA6CMoEsncKJxvQd8NzPxaHRJNnb5gZE8R1XF4CPIS7QPHLJ74IFszwtNVAHVQ==" - }, - "npm-bundled": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" - }, - "npm-check-updates": { - "version": "3.1.20", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-3.1.20.tgz", - "integrity": "sha512-mc9BAoOYSTwP/IvoA+ofdkWSipwRvhgC0qop1PvlMZojgzi7N/dykdxOIWrw0OlZPnEKvXkKFEuPk97LrvXE1A==", + "pacote": { + "version": "9.5.4", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-9.5.4.tgz", + "integrity": "sha512-nWr0ari6E+apbdoN0hToTKZElO5h4y8DGFa2pyNA5GQIdcP0imC96bA0bbPw1gpeguVIiUgHHaAlq/6xfPp8Qw==", "requires": { - "chalk": "^2.4.2", - "cint": "^8.2.1", - "cli-table": "^0.3.1", - "commander": "^2.20.0", - "fast-diff": "^1.2.0", - "find-up": "4.1.0", - "get-stdin": "^7.0.0", - "json-parse-helpfulerror": "^1.0.3", - "libnpmconfig": "^1.2.1", - "lodash": "^4.17.13", - "node-alias": "^1.0.4", - "pacote": "^9.5.1", - "progress": "^2.0.3", - "prompts": "^2.1.0", - "rc-config-loader": "^2.0.4", - "requireg": "^0.2.2", - "semver": "^6.2.0", - "semver-utils": "^1.1.4", - "spawn-please": "^0.3.0", - "update-notifier": "^3.0.1" - }, - "dependencies": { - "ansi-align": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", - "integrity": "sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==", - "requires": { - "string-width": "^3.0.0" - } - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "boxen": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-3.2.0.tgz", - "integrity": "sha512-cU4J/+NodM3IHdSL2yN8bqYqnmlBTidDR4RC7nJs61ZmtGz8VZzM3HLQX0zY5mrSmPtR3xWwsq2jOUQqFZN8+A==", - "requires": { - "ansi-align": "^3.0.0", - "camelcase": "^5.3.1", - "chalk": "^2.4.2", - "cli-boxes": "^2.2.0", - "string-width": "^3.0.0", - "term-size": "^1.2.0", - "type-fest": "^0.3.0", - "widest-line": "^2.0.0" - } - }, - "ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" - }, - "cli-boxes": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.0.tgz", - "integrity": "sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w==" - }, - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==" - }, - "configstore": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-4.0.0.tgz", - "integrity": "sha512-CmquAXFBocrzaSM8mtGPMM/HiWmyIpr4CcJl/rgY2uCObZ/S7cKU0silxslqJejl+t/T9HS8E0PUNQD81JGUEQ==", - "requires": { - "dot-prop": "^4.1.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "unique-string": "^1.0.0", - "write-file-atomic": "^2.0.0", - "xdg-basedir": "^3.0.0" - } - }, - "get-stdin": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", - "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==" - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "requires": { - "pump": "^3.0.0" - } - }, - "got": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", - "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", - "requires": { - "@sindresorhus/is": "^0.14.0", - "@szmarczak/http-timer": "^1.1.2", - "cacheable-request": "^6.0.0", - "decompress-response": "^3.3.0", - "duplexer3": "^0.1.4", - "get-stream": "^4.1.0", - "lowercase-keys": "^1.0.1", - "mimic-response": "^1.0.1", - "p-cancelable": "^1.0.0", - "to-readable-stream": "^1.0.0", - "url-parse-lax": "^3.0.0" - } - }, - "is-ci": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", - "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "bluebird": "^3.5.3", + "cacache": "^12.0.0", + "figgy-pudding": "^3.5.1", + "get-stream": "^4.1.0", + "glob": "^7.1.3", + "lru-cache": "^5.1.1", + "make-fetch-happen": "^5.0.0", + "minimatch": "^3.0.4", + "minipass": "^2.3.5", + "mississippi": "^3.0.0", + "mkdirp": "^0.5.1", + "normalize-package-data": "^2.4.0", + "npm-package-arg": "^6.1.0", + "npm-packlist": "^1.1.12", + "npm-pick-manifest": "^2.2.3", + "npm-registry-fetch": "^4.0.0", + "osenv": "^0.1.5", + "promise-inflight": "^1.0.1", + "promise-retry": "^1.1.1", + "protoduck": "^5.0.1", + "rimraf": "^2.6.2", + "safe-buffer": "^5.1.2", + "semver": "^5.6.0", + "ssri": "^6.0.1", + "tar": "^4.4.8", + "unique-filename": "^1.1.1", + "which": "^1.3.1" + }, + "dependencies": { + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", "requires": { - "ci-info": "^2.0.0" + "pump": "^3.0.0" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "is-npm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-3.0.0.tgz", - "integrity": "sha512-wsigDr1Kkschp2opC4G3yA6r9EgVA6NjRpWzIi9axXqeIaAATPRJc4uLujXe3Nd9uO8KoDyA4MD6aZSeXTADhA==" - }, - "latest-version": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", - "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "requires": { - "package-json": "^6.3.0" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" - }, - "package-json": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.4.0.tgz", - "integrity": "sha512-bd1T8OBG7hcvMd9c/udgv6u5v9wISP3Oyl9Cm7Weop8EFwrtcQDnS2sb6zhwqus2WslSr5wSTIPiTTpxxmPm7Q==", + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "requires": { - "got": "^9.6.0", - "registry-auth-token": "^3.4.0", - "registry-url": "^5.0.0", - "semver": "^6.1.1" + "yallist": "^3.0.2" } }, - "prepend-http": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", - "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" - }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -21420,2930 +23179,3986 @@ "once": "^1.3.1" } }, - "registry-url": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", - "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", - "requires": { - "rc": "^1.2.8" - } - }, - "semver": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", - "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==" - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "update-notifier": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-3.0.1.tgz", - "integrity": "sha512-grrmrB6Zb8DUiyDIaeRTBCkgISYUgETNe7NglEbVsrLWXeESnlCSP50WfRSj/GmzMPl6Uchj24S/p80nP/ZQrQ==", - "requires": { - "boxen": "^3.0.0", - "chalk": "^2.0.1", - "configstore": "^4.0.0", - "has-yarn": "^2.1.0", - "import-lazy": "^2.1.0", - "is-ci": "^2.0.0", - "is-installed-globally": "^0.1.0", - "is-npm": "^3.0.0", - "is-yarn-global": "^0.3.0", - "latest-version": "^5.0.0", - "semver-diff": "^2.0.0", - "xdg-basedir": "^3.0.0" - } - }, - "url-parse-lax": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", - "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", - "requires": { - "prepend-http": "^2.0.0" - } + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, - "npm-package-arg": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-6.1.0.tgz", - "integrity": "sha512-zYbhP2k9DbJhA0Z3HKUePUgdB1x7MfIfKssC+WLPFMKTBZKpZh5m13PgexJjCq6KW7j17r0jHWcCpxEqnnncSA==", + "pako": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", + "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==", + "dev": true + }, + "parallel-transform": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", + "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", "requires": { - "hosted-git-info": "^2.6.0", - "osenv": "^0.1.5", - "semver": "^5.5.0", - "validate-npm-package-name": "^3.0.0" + "cyclist": "~0.2.2", + "inherits": "^2.0.3", + "readable-stream": "^2.1.5" } }, - "npm-packlist": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", - "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-asn1": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", + "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "dev": true, + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, + "parse-cache-control": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", + "integrity": "sha1-juqz5U+laSD+Fro493+iGqzC104=", + "dev": true + }, + "parse-code-context": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-code-context/-/parse-code-context-1.0.0.tgz", + "integrity": "sha512-OZQaqKaQnR21iqhlnPfVisFjBWjhnMl5J9MgbP8xC+EwoVqbXrq78lp+9Zb3ahmLzrIX5Us/qbvBnaS3hkH6OA==", + "dev": true + }, + "parse-headers": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.2.tgz", + "integrity": "sha512-/LypJhzFmyBIDYP9aDVgeyEb5sQfbfY5mnDq4hVhlQ69js87wXfmEI5V3xI6vvXasqebp0oCytYFLxsBVfCzSg==", + "requires": { + "for-each": "^0.3.3", + "string.prototype.trim": "^1.1.2" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + }, + "pbkdf2": { + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, - "npm-pick-manifest": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.2.3.tgz", - "integrity": "sha512-+IluBC5K201+gRU85vFlUwX3PFShZAbAgDNp2ewJdWMVSppdo/Zih0ul2Ecky/X7b51J7LrrUAP+XOmOCvYZqA==", + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "picomatch": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", + "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "requires": { - "figgy-pudding": "^3.5.1", - "npm-package-arg": "^6.0.0", - "semver": "^5.4.1" + "pinkie": "^2.0.0" } }, - "npm-registry-fetch": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.0.tgz", - "integrity": "sha512-Jllq35Jag8dtv0M17ue74XtdQTyqKzuAYGiX9mAjOhkmNjib3bBUgK6mUY61+AHnXeSRobQkpY3/xIOS/omptw==", + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, "requires": { - "JSONStream": "^1.3.4", - "bluebird": "^3.5.1", - "figgy-pudding": "^3.4.1", - "lru-cache": "^5.1.1", - "make-fetch-happen": "^5.0.0", - "npm-package-arg": "^6.1.0" + "find-up": "^2.1.0" }, "dependencies": { - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, "requires": { - "yallist": "^3.0.2" + "locate-path": "^2.0.0" } - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "requires": { - "path-key": "^2.0.0" - } + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } + "popper.js": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.3.tgz", + "integrity": "sha1-FDj5jQRqz3tNeM1QK/QYrGTU8JU=" }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true }, - "number-to-bn": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", - "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", + "prebuild-install": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.0.tgz", + "integrity": "sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==", + "optional": true, "requires": { - "bn.js": "4.11.6", - "strip-hex-prefix": "1.0.0" + "detect-libc": "^1.0.3", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "napi-build-utils": "^1.0.1", + "node-abi": "^2.7.0", + "noop-logger": "^0.1.1", + "npmlog": "^4.0.1", + "os-homedir": "^1.0.1", + "pump": "^2.0.1", + "rc": "^1.2.7", + "simple-get": "^2.7.0", + "tar-fs": "^1.13.0", + "tunnel-agent": "^0.6.0", + "which-pm-runs": "^1.0.0" }, "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true } } }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + "precond": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz", + "integrity": "sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw=" }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, + "prettier": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", + "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", "dev": true, "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" + "fast-diff": "^1.1.2" + } + }, + "prettier-plugin-solidity": { + "version": "1.0.0-alpha.32", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-alpha.32.tgz", + "integrity": "sha512-3gwIeiHyYUzPw9uLGrRTdYNd/3lmF8hUJtl7Dxygx6zHQ4NLP+uKE79MeCg49THFkLBcyJ+jYK1Wsk5fp+i2mA==", + "dev": true, + "requires": { + "dir-to-object": "^2.0.0", + "emoji-regex": "^8.0.0", + "escape-string-regexp": "^2.0.0", + "extract-comments": "^1.1.0", + "prettier": "^1.15.3", + "semver": "^6.3.0", + "solidity-parser-antlr": "^0.4.11", + "string-width": "^4.1.0" }, "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "solidity-parser-antlr": { + "version": "0.4.11", + "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz", + "integrity": "sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==", + "dev": true + }, + "string-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz", + "integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^5.2.0" } }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "ansi-regex": "^4.1.0" } } } }, - "object-inspect": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", - "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==" + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + "process": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", + "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=" }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "promise": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.3.tgz", + "integrity": "sha512-HeRDUL1RJiLhyA0/grn+PTShlBAcLuh/1BJGtrvjwbvRDCTLLMEz9rOGCV+R3vHY4MixIuoMEd9Yq/XvsTPcjw==", "dev": true, "requires": { - "isobject": "^3.0.0" + "asap": "~2.0.6" } }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, + "promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" + }, + "promise-retry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz", + "integrity": "sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=", "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" + "err-code": "^1.0.0", + "retry": "^0.10.0" } }, - "object.entries": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", - "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", - "dev": true, + "promise-to-callback": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/promise-to-callback/-/promise-to-callback-1.0.0.tgz", + "integrity": "sha1-XSp0kBC/tn2WNZj805YHRqaP7vc=", "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.12.0", - "function-bind": "^1.1.1", - "has": "^1.0.3" + "is-fn": "^1.0.0", + "set-immediate-shim": "^1.0.1" } }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, + "prompts": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", + "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", "requires": { - "isobject": "^3.0.1" + "kleur": "^3.0.2", + "sisteransi": "^1.0.0" } }, - "object.values": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", - "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", - "dev": true, + "protoduck": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/protoduck/-/protoduck-5.0.1.tgz", + "integrity": "sha512-WxoCeDCoCBY55BMvj4cAEjdVUFGRWed9ZxPlqTKYyw1nDDTQ4pqmnIMAGfJlg7Dx35uB/M+PHJPTmGOvaCaPTg==", "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.12.0", - "function-bind": "^1.1.1", - "has": "^1.0.3" + "genfun": "^5.0.0" } }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "dev": true, "requires": { - "wrappy": "1" + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" } }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "psl": { + "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==" + }, + "pstree.remy": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.6.tgz", + "integrity": "sha512-NdF35+QsqD7EgNEI5mkI/X+UwaxVEbQaz9f4IooEmMUv6ZPmlTQYGjBPJGgrlzNdjSvIy4MWMg6Q6vCgBO2K+w==", + "dev": true + }, + "public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" } }, - "openzeppelin-solidity": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/openzeppelin-solidity/-/openzeppelin-solidity-1.12.0.tgz", - "integrity": "sha512-WlorzMXIIurugiSdw121RVD5qA3EfSI7GybTn+/Du0mPNgairjt29NpVTAaH8eLjAeAwlw46y7uQKy0NYem/gA==" - }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" - } + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "pumpify": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" } }, - "original-require": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/original-require/-/original-require-1.0.1.tgz", - "integrity": "sha1-DxMEcVhM0zURxew4yNWSE/msXiA=", - "dev": true + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" } }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" + "safe-buffer": "^5.1.0" } }, - "p-cancelable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", - "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==" - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, "requires": { - "p-try": "^1.0.0" + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" } }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "randomhex": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/randomhex/-/randomhex-0.1.5.tgz", + "integrity": "sha1-us7vmCMpCRQA8qKRLGzQLxCU9YU=" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "dev": true, "requires": { - "p-limit": "^1.1.0" + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" } }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, - "package-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", - "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", - "dev": true, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "requires": { - "got": "^6.7.1", - "registry-auth-token": "^3.0.1", - "registry-url": "^3.0.3", - "semver": "^5.1.0" + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } } }, - "pacote": { - "version": "9.5.4", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-9.5.4.tgz", - "integrity": "sha512-nWr0ari6E+apbdoN0hToTKZElO5h4y8DGFa2pyNA5GQIdcP0imC96bA0bbPw1gpeguVIiUgHHaAlq/6xfPp8Qw==", + "rc-config-loader": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/rc-config-loader/-/rc-config-loader-2.0.4.tgz", + "integrity": "sha512-k06UzRbYDWgF4Mc/YrsZsmzSpDLuHoThJxep+vq5H09hiX8rbA5Ue/Ra0dwWm5MQvWYW4YBXgA186inNxuxidQ==", "requires": { - "bluebird": "^3.5.3", - "cacache": "^12.0.0", - "figgy-pudding": "^3.5.1", - "get-stream": "^4.1.0", - "glob": "^7.1.3", - "lru-cache": "^5.1.1", - "make-fetch-happen": "^5.0.0", - "minimatch": "^3.0.4", - "minipass": "^2.3.5", - "mississippi": "^3.0.0", - "mkdirp": "^0.5.1", - "normalize-package-data": "^2.4.0", - "npm-package-arg": "^6.1.0", - "npm-packlist": "^1.1.12", - "npm-pick-manifest": "^2.2.3", - "npm-registry-fetch": "^4.0.0", - "osenv": "^0.1.5", - "promise-inflight": "^1.0.1", - "promise-retry": "^1.1.1", - "protoduck": "^5.0.1", - "rimraf": "^2.6.2", - "safe-buffer": "^5.1.2", - "semver": "^5.6.0", - "ssri": "^6.0.1", - "tar": "^4.4.8", - "unique-filename": "^1.1.1", - "which": "^1.3.1" + "debug": "^4.1.1", + "js-yaml": "^3.12.0", + "json5": "^2.1.0", + "object-assign": "^4.1.0", + "object-keys": "^1.0.12", + "path-exists": "^3.0.0", + "require-from-string": "^2.0.2" }, "dependencies": { - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { - "pump": "^3.0.0" + "ms": "^2.1.1" } }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "json5": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimist": "^1.2.0" } }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "requires": { - "yallist": "^3.0.2" - } + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, - "pump": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "path-exists": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + } + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "locate-path": "^2.0.0" } - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, - "parallel-transform": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", - "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { - "cyclist": "~0.2.2", - "inherits": "^2.0.3", - "readable-stream": "^2.1.5" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, "requires": { - "callsites": "^3.0.0" + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" } }, - "parse-cache-control": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", - "integrity": "sha1-juqz5U+laSD+Fro493+iGqzC104=", - "dev": true + "redeyed": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/redeyed/-/redeyed-2.1.1.tgz", + "integrity": "sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs=", + "dev": true, + "requires": { + "esprima": "~4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } + } }, - "parse-code-context": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-code-context/-/parse-code-context-1.0.0.tgz", - "integrity": "sha512-OZQaqKaQnR21iqhlnPfVisFjBWjhnMl5J9MgbP8xC+EwoVqbXrq78lp+9Zb3ahmLzrIX5Us/qbvBnaS3hkH6OA==", + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, + "regenerator-transform": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", + "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "requires": { + "babel-runtime": "^6.18.0", + "babel-types": "^6.19.0", + "private": "^0.1.6" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, - "parse-headers": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.2.tgz", - "integrity": "sha512-/LypJhzFmyBIDYP9aDVgeyEb5sQfbfY5mnDq4hVhlQ69js87wXfmEI5V3xI6vvXasqebp0oCytYFLxsBVfCzSg==", + "regexpu-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", + "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", + "requires": { + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" + } + }, + "registry-auth-token": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.4.0.tgz", + "integrity": "sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A==", "requires": { - "for-each": "^0.3.3", - "string.prototype.trim": "^1.1.2" + "rc": "^1.1.6", + "safe-buffer": "^5.0.1" } }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", "dev": true, "requires": { - "error-ex": "^1.2.0" + "rc": "^1.0.1" } }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true + "regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=" }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true + "regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "requires": { + "jsesc": "~0.5.0" + } }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true }, - "path-key": { + "repeating": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" - }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", - "dev": true, + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "requires": { - "pify": "^2.0.0" + "is-finite": "^1.0.0" } }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" - }, - "pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "req-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/req-cwd/-/req-cwd-2.0.0.tgz", + "integrity": "sha1-1AgrTURZgDZkD7c93qAe1T20nrw=", + "dev": true, "requires": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" + "req-from": "^2.0.0" } }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, - "picomatch": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", - "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==" - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" - }, - "pkg-dir": { + "req-from": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "resolved": "https://registry.npmjs.org/req-from/-/req-from-2.0.0.tgz", + "integrity": "sha1-10GI5H+TeW9Kpx327jWuaJ8+DnA=", "dev": true, "requires": { - "find-up": "^2.1.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - } + "resolve-from": "^3.0.0" } }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" - }, - "popper.js": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.3.tgz", - "integrity": "sha1-FDj5jQRqz3tNeM1QK/QYrGTU8JU=" - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "prebuild-install": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.0.tgz", - "integrity": "sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==", - "optional": true, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "requires": { - "detect-libc": "^1.0.3", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "napi-build-utils": "^1.0.1", - "node-abi": "^2.7.0", - "noop-logger": "^0.1.1", - "npmlog": "^4.0.1", - "os-homedir": "^1.0.1", - "pump": "^2.0.1", - "rc": "^1.2.7", - "simple-get": "^2.7.0", - "tar-fs": "^1.13.0", + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", "tunnel-agent": "^0.6.0", - "which-pm-runs": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "optional": true - } + "uuid": "^3.3.2" } }, - "precond": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz", - "integrity": "sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw=" + "request-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.4.tgz", + "integrity": "sha512-8wgMrvE546PzbR5WbYxUQogUnUDfM0S7QIFZMID+J73vdFARkFy+HElj4T+MWYhpXwlLp0EQ8Zoj8xUA0he4Vg==", + "dev": true, + "requires": { + "bluebird": "^3.5.0", + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } }, - "prelude-ls": { + "request-promise-core": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "prettier": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", - "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", - "dev": true + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", + "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } }, - "prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "request-promise-native": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz", + "integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==", "dev": true, "requires": { - "fast-diff": "^1.1.2" + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" } }, - "prettier-plugin-solidity": { - "version": "1.0.0-alpha.32", - "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-alpha.32.tgz", - "integrity": "sha512-3gwIeiHyYUzPw9uLGrRTdYNd/3lmF8hUJtl7Dxygx6zHQ4NLP+uKE79MeCg49THFkLBcyJ+jYK1Wsk5fp+i2mA==", - "dev": true, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "requireg": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/requireg/-/requireg-0.2.2.tgz", + "integrity": "sha512-nYzyjnFcPNGR3lx9lwPPPnuQxv6JWEZd2Ci0u9opN7N5zUEPIhY/GbL3vMGOr2UXwEg9WwSyV9X9Y/kLFgPsOg==", "requires": { - "dir-to-object": "^2.0.0", - "emoji-regex": "^8.0.0", - "escape-string-regexp": "^2.0.0", - "extract-comments": "^1.1.0", - "prettier": "^1.15.3", - "semver": "^6.3.0", - "solidity-parser-antlr": "^0.4.11", - "string-width": "^4.1.0" + "nested-error-stacks": "~2.0.1", + "rc": "~1.2.7", + "resolve": "~1.7.1" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, - "solidity-parser-antlr": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz", - "integrity": "sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==", - "dev": true - }, - "string-width": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz", - "integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^5.2.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, + "resolve": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "requires": { - "ansi-regex": "^4.1.0" + "path-parse": "^1.0.5" } } } }, - "private": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", - "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" + "resolve": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", + "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "requires": { + "path-parse": "^1.0.6" + } }, - "process": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", - "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=" + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "requires": { + "lowercase-keys": "^1.0.0" + } }, - "promise": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.3.tgz", - "integrity": "sha512-HeRDUL1RJiLhyA0/grn+PTShlBAcLuh/1BJGtrvjwbvRDCTLLMEz9rOGCV+R3vHY4MixIuoMEd9Yq/XvsTPcjw==", + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "asap": "~2.0.6" + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" } }, - "promise-inflight": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" - }, - "promise-retry": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz", - "integrity": "sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=", + "resumer": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", + "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", "requires": { - "err-code": "^1.0.0", - "retry": "^0.10.0" + "through": "~2.3.4" } }, - "promise-to-callback": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/promise-to-callback/-/promise-to-callback-1.0.0.tgz", - "integrity": "sha1-XSp0kBC/tn2WNZj805YHRqaP7vc=", + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "retry": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz", + "integrity": "sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q=" + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "requires": { - "is-fn": "^1.0.0", - "set-immediate-shim": "^1.0.1" + "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, - "prompts": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", - "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", + "ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "requires": { - "kleur": "^3.0.2", - "sisteransi": "^1.0.0" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, - "protoduck": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/protoduck/-/protoduck-5.0.1.tgz", - "integrity": "sha512-WxoCeDCoCBY55BMvj4cAEjdVUFGRWed9ZxPlqTKYyw1nDDTQ4pqmnIMAGfJlg7Dx35uB/M+PHJPTmGOvaCaPTg==", + "rlp": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.3.tgz", + "integrity": "sha512-l6YVrI7+d2vpW6D6rS05x2Xrmq8oW7v3pieZOJKBEdjuTF4Kz/iwk55Zyh1Zaz+KOB2kC8+2jZlp2u9L4tTzCQ==", "requires": { - "genfun": "^5.0.0" + "bn.js": "^4.11.1", + "safe-buffer": "^5.1.1" } }, - "prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, - "psl": { - "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==" - }, - "pstree.remy": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.6.tgz", - "integrity": "sha512-NdF35+QsqD7EgNEI5mkI/X+UwaxVEbQaz9f4IooEmMUv6ZPmlTQYGjBPJGgrlzNdjSvIy4MWMg6Q6vCgBO2K+w==", - "dev": true + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } }, - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "run-queue": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", + "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "aproba": "^1.1.1" } }, - "pumpify": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", - "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", + "rustbn.js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/rustbn.js/-/rustbn.js-0.2.0.tgz", + "integrity": "sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==" + }, + "rxjs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", "requires": { - "duplexify": "^3.6.0", - "inherits": "^2.0.3", - "pump": "^2.0.0" + "tslib": "^1.9.0" } }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "safe-event-emitter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/safe-event-emitter/-/safe-event-emitter-1.0.1.tgz", + "integrity": "sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg==", + "requires": { + "events": "^3.0.0" + } }, - "query-string": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", - "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, "requires": { - "decode-uri-component": "^0.2.0", - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" + "ret": "~0.1.10" } }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "scrypt-js": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", + "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" + }, + "scrypt-shim": { + "version": "github:web3-js/scrypt-shim#be5e616323a8b5e568788bf94d03c1b8410eac54", + "from": "github:web3-js/scrypt-shim", + "dev": true, "requires": { - "safe-buffer": "^5.1.0" + "scryptsy": "^2.1.0", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } } }, - "randomhex": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/randomhex/-/randomhex-0.1.5.tgz", - "integrity": "sha1-us7vmCMpCRQA8qKRLGzQLxCU9YU=" + "scryptsy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-2.1.0.tgz", + "integrity": "sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w==", + "dev": true }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "secp256k1": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" + "bindings": "^1.5.0", + "bip66": "^1.1.5", + "bn.js": "^4.11.8", + "create-hash": "^1.2.0", + "drbg.js": "^1.0.1", + "elliptic": "^6.4.1", + "nan": "^2.14.0", + "safe-buffer": "^5.1.2" }, "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" } } }, - "rc-config-loader": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/rc-config-loader/-/rc-config-loader-2.0.4.tgz", - "integrity": "sha512-k06UzRbYDWgF4Mc/YrsZsmzSpDLuHoThJxep+vq5H09hiX8rbA5Ue/Ra0dwWm5MQvWYW4YBXgA186inNxuxidQ==", + "seek-bzip": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz", + "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", + "dev": true, "requires": { - "debug": "^4.1.1", - "js-yaml": "^3.12.0", - "json5": "^2.1.0", - "object-assign": "^4.1.0", - "object-keys": "^1.0.12", - "path-exists": "^3.0.0", - "require-from-string": "^2.0.2" + "commander": "~2.8.1" }, "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "json5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", - "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", + "commander": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", + "dev": true, "requires": { - "minimist": "^1.2.0" + "graceful-readlink": ">= 1.0.0" } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" } } }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", - "dev": true, + "semaphore": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semaphore/-/semaphore-1.1.0.tgz", + "integrity": "sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA==" + }, + "semaphore-async-await": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/semaphore-async-await/-/semaphore-async-await-1.5.1.tgz", + "integrity": "sha1-hXvvXjZEYBykuVcLh+nfXKEpdPo=" + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "semver-diff": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", + "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "semver": "^5.0.3" } }, - "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "semver-utils": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/semver-utils/-/semver-utils-1.1.4.tgz", + "integrity": "sha512-EjnoLE5OGmDAVV/8YDoN5KiajNadjzIp9BAHOhYeQHt7j0UWxjmgsx4YD48wp4Ue1Qogq38F1GNUJNqF1kKKxA==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "dev": true, "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" }, "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { - "locate-path": "^2.0.0" + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" } }, - "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "servify": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/servify/-/servify-0.1.12.tgz", + "integrity": "sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw==", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" + "body-parser": "^1.16.0", + "cors": "^2.8.1", + "express": "^4.14.0", + "request": "^2.79.0", + "xhr": "^2.3.3" } }, - "redeyed": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/redeyed/-/redeyed-2.1.1.tgz", - "integrity": "sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs=", + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { - "esprima": "~4.0.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" }, "dependencies": { - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } } } }, - "regenerate": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", - "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" + "setimmediate": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", + "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true }, - "regenerator-transform": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", - "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "requires": { - "babel-runtime": "^6.18.0", - "babel-types": "^6.19.0", - "private": "^0.1.6" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "sha1": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz", + "integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg=", "dev": true, "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" + "charenc": ">= 0.0.1", + "crypt": ">= 0.0.1" } }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, - "regexpu-core": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", - "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "requires": { - "regenerate": "^1.2.1", - "regjsgen": "^0.2.0", - "regjsparser": "^0.1.4" + "shebang-regex": "^1.0.0" } }, - "registry-auth-token": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.4.0.tgz", - "integrity": "sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A==", + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" + }, + "simple-get": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", + "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", "requires": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" + "decompress-response": "^3.3.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" } }, - "registry-url": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", - "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "sisteransi": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.2.tgz", + "integrity": "sha512-ZcYcZcT69nSLAR2oLN2JwNmLkJEKGooFMCdvOkFrToUt/WfcRWqhIg4P4KwY4dmLbuyXIx4o4YmPsvMRJYJd/w==" + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "requires": { - "rc": "^1.0.1" + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } } }, - "regjsgen": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", - "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=" + "smart-buffer": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.2.tgz", + "integrity": "sha512-JDhEpTKzXusOqXZ0BUIdH+CjFdO/CR3tLlf5CN34IypI+xMmXW1uB16OOY8z3cICbJlDAVJzNbwBhNO0wt9OAw==" }, - "regjsparser": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", - "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, "requires": { - "jsesc": "~0.5.0" + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } } }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, "requires": { - "is-finite": "^1.0.0" + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } } }, - "req-cwd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/req-cwd/-/req-cwd-2.0.0.tgz", - "integrity": "sha1-1AgrTURZgDZkD7c93qAe1T20nrw=", + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "req-from": "^2.0.0" + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } } }, - "req-from": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/req-from/-/req-from-2.0.0.tgz", - "integrity": "sha1-10GI5H+TeW9Kpx327jWuaJ8+DnA=", - "dev": true, + "socks": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.3.2.tgz", + "integrity": "sha512-pCpjxQgOByDHLlNqlnh/mNSAxIUkyBBuwwhTcV+enZGbDaClPvHdvm6uvOwZfFJkam7cGhBNbb4JxiP8UZkRvQ==", "requires": { - "resolve-from": "^3.0.0" + "ip": "^1.1.5", + "smart-buffer": "4.0.2" } }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "socks-proxy-agent": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz", + "integrity": "sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg==", "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.0", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" + "agent-base": "~4.2.1", + "socks": "~2.3.2" + }, + "dependencies": { + "agent-base": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "requires": { + "es6-promisify": "^5.0.0" + } + } } }, - "request-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.4.tgz", - "integrity": "sha512-8wgMrvE546PzbR5WbYxUQogUnUDfM0S7QIFZMID+J73vdFARkFy+HElj4T+MWYhpXwlLp0EQ8Zoj8xUA0he4Vg==", + "solhint": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.2.0.tgz", + "integrity": "sha512-KNi9qGu17XNV75q9eFftrWIpDVHbejyZ5vaDuNQwet0e9+k8Xw0BdckyVUjYRfFQXAQA3nBTafxUVUtkM4cfIA==", "dev": true, "requires": { - "bluebird": "^3.5.0", - "request-promise-core": "1.1.2", - "stealthy-require": "^1.1.1", - "tough-cookie": "^2.3.3" + "ajv": "^6.6.1", + "antlr4": "4.7.1", + "chalk": "^2.4.2", + "commander": "2.18.0", + "cosmiconfig": "^5.0.7", + "eslint": "^5.6.0", + "fast-diff": "^1.1.2", + "glob": "^7.1.3", + "ignore": "^4.0.6", + "js-yaml": "^3.12.0", + "lodash": "^4.17.11", + "prettier": "^1.14.3", + "semver": "^6.0.0" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.9.1", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", + "eslint-utils": "^1.3.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^5.0.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.2.2", + "js-yaml": "^3.13.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, - "request-promise-core": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", - "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "solhint-plugin-prettier": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/solhint-plugin-prettier/-/solhint-plugin-prettier-0.0.3.tgz", + "integrity": "sha512-kdg1c7d5/X/RKTBS9AskwAKOZLpFhwUBelwjrUq43EQXOLd2HR81WvENZWcVNmzewiPTEOoZo3CqqE/Hy/84WQ==", "dev": true, "requires": { - "lodash": "^4.17.11" + "prettier-linter-helpers": "^1.0.0" } }, - "request-promise-native": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz", - "integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==", - "dev": true, + "solidity-parser-antlr": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.8.tgz", + "integrity": "sha512-HkAAvzLfw2OPmkuGLcy8M5yVaO4PWagmV4t7DSKYi3pXQZG7TPQ2dWl1c0QTp56snX08FeKsBAsPhXY43yjZUQ==", "requires": { - "request-promise-core": "1.1.2", - "stealthy-require": "^1.1.1", - "tough-cookie": "^2.3.3" + "npm-check-updates": "^3.1.11" } }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } }, - "requireg": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/requireg/-/requireg-0.2.2.tgz", - "integrity": "sha512-nYzyjnFcPNGR3lx9lwPPPnuQxv6JWEZd2Ci0u9opN7N5zUEPIhY/GbL3vMGOr2UXwEg9WwSyV9X9Y/kLFgPsOg==", + "source-map-support": { + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "requires": { - "nested-error-stacks": "~2.0.1", - "rc": "~1.2.7", - "resolve": "~1.7.1" + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" }, "dependencies": { - "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", - "requires": { - "path-parse": "^1.0.5" - } + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" } } }, - "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "spawn-please": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/spawn-please/-/spawn-please-0.3.0.tgz", + "integrity": "sha1-2zOOxM/2Orxp8dDgjO6euL69nRE=" + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "requires": { - "path-parse": "^1.0.6" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, - "resolve-from": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", - "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", - "dev": true - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==" }, - "responselike": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", - "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "requires": { - "lowercase-keys": "^1.0.0" + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" } }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "spdx-license-ids": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", + "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==" + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" + "extend-shallow": "^3.0.0" } }, - "resumer": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", - "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "requires": { - "through": "~2.3.4" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" } }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "retry": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz", - "integrity": "sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q=" + "ssri": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", + "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "requires": { + "figgy-pudding": "^3.5.1" + } }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, "requires": { - "glob": "^7.1.3" + "define-property": "^0.2.5", + "object-copy": "^0.1.0" }, "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "is-descriptor": "^0.1.0" } } } }, - "ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true + }, + "stream-each": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", + "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "end-of-stream": "^1.1.0", + "stream-shift": "^1.0.0" } }, - "rlp": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.3.tgz", - "integrity": "sha512-l6YVrI7+d2vpW6D6rS05x2Xrmq8oW7v3pieZOJKBEdjuTF4Kz/iwk55Zyh1Zaz+KOB2kC8+2jZlp2u9L4tTzCQ==", - "requires": { - "bn.js": "^4.11.1", - "safe-buffer": "^5.1.1" + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=" + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, + "string.prototype.trim": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", + "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", "requires": { - "is-promise": "^2.1.0" + "define-properties": "^1.1.2", + "es-abstract": "^1.5.0", + "function-bind": "^1.0.2" } }, - "run-queue": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", - "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { - "aproba": "^1.1.1" + "safe-buffer": "~5.1.0" } }, - "rustbn.js": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/rustbn.js/-/rustbn.js-0.2.0.tgz", - "integrity": "sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==" - }, - "rxjs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", - "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { - "tslib": "^1.9.0" + "ansi-regex": "^2.0.0" } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true }, - "safe-event-emitter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/safe-event-emitter/-/safe-event-emitter-1.0.1.tgz", - "integrity": "sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg==", + "strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "dev": true, "requires": { - "events": "^3.0.0" + "is-natural-number": "^4.0.1" } }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + }, + "strip-hex-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", + "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", "requires": { - "ret": "~0.1.10" + "is-hex-prefixed": "1.0.0" } }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "scrypt-js": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", - "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, - "secp256k1": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", - "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "requires": { - "bindings": "^1.5.0", - "bip66": "^1.1.5", - "bn.js": "^4.11.8", - "create-hash": "^1.2.0", - "drbg.js": "^1.0.1", - "elliptic": "^6.4.1", - "nan": "^2.14.0", - "safe-buffer": "^5.1.2" + "has-flag": "^3.0.0" }, "dependencies": { - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" } } }, - "semaphore": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/semaphore/-/semaphore-1.1.0.tgz", - "integrity": "sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA==" - }, - "semaphore-async-await": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/semaphore-async-await/-/semaphore-async-await-1.5.1.tgz", - "integrity": "sha1-hXvvXjZEYBykuVcLh+nfXKEpdPo=" - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" - }, - "semver-diff": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", - "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "supports-hyperlinks": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-1.0.1.tgz", + "integrity": "sha512-HHi5kVSefKaJkGYXbDuKbUGRVxqnWGn3J2e39CYcNJEfWciGq2zYtOhXLTlvrOZW1QU7VX67w7fMmWafHX9Pfw==", + "dev": true, "requires": { - "semver": "^5.0.3" + "has-flag": "^2.0.0", + "supports-color": "^5.0.0" } }, - "semver-utils": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/semver-utils/-/semver-utils-1.1.4.tgz", - "integrity": "sha512-EjnoLE5OGmDAVV/8YDoN5KiajNadjzIp9BAHOhYeQHt7j0UWxjmgsx4YD48wp4Ue1Qogq38F1GNUJNqF1kKKxA==" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" - }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "swarm-js": { + "version": "0.1.39", + "resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.39.tgz", + "integrity": "sha512-QLMqL2rzF6n5s50BptyD6Oi0R1aWlJC5Y17SRIVXRj6OR1DRIPM7nepvrxxkjA1zNzFz6mUOMjfeqeDaWB7OOg==", "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" + "bluebird": "^3.5.0", + "buffer": "^5.0.5", + "decompress": "^4.0.0", + "eth-lib": "^0.1.26", + "fs-extra": "^4.0.2", + "got": "^7.1.0", + "mime-types": "^2.1.16", + "mkdirp-promise": "^5.0.1", + "mock-fs": "^4.1.0", + "setimmediate": "^1.0.5", + "tar": "^4.0.2", + "xhr-request-promise": "^0.1.2" }, "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "eth-lib": { + "version": "0.1.29", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.1.29.tgz", + "integrity": "sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ==", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "nano-json-stream-parser": "^0.1.2", + "servify": "^0.1.12", + "ws": "^3.0.0", + "xhr-request-promise": "^0.1.2" } - } - } - }, - "setimmediate": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", - "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" - }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "sha1": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz", - "integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg=", - "dev": true, - "requires": { - "charenc": ">= 0.0.1", - "crypt": ">= 0.0.1" - } - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "requires": { - "shebang-regex": "^1.0.0" + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "got": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/got/-/got-7.1.0.tgz", + "integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==", + "dev": true, + "requires": { + "decompress-response": "^3.2.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-plain-obj": "^1.1.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "isurl": "^1.0.0-alpha5", + "lowercase-keys": "^1.0.0", + "p-cancelable": "^0.3.0", + "p-timeout": "^1.1.1", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "url-parse-lax": "^1.0.0", + "url-to-options": "^1.0.1" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "p-cancelable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", + "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==", + "dev": true + }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + } + } } }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, - "simple-concat": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", - "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" - }, - "simple-get": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", - "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", + "sync-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz", + "integrity": "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==", + "dev": true, "requires": { - "decompress-response": "^3.3.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" + "http-response-object": "^3.0.1", + "sync-rpc": "^1.2.1", + "then-request": "^6.0.0" } }, - "sisteransi": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.2.tgz", - "integrity": "sha512-ZcYcZcT69nSLAR2oLN2JwNmLkJEKGooFMCdvOkFrToUt/WfcRWqhIg4P4KwY4dmLbuyXIx4o4YmPsvMRJYJd/w==" - }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" - }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "sync-rpc": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz", + "integrity": "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==", "dev": true, "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - } + "get-port": "^3.1.0" } }, - "smart-buffer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.2.tgz", - "integrity": "sha512-JDhEpTKzXusOqXZ0BUIdH+CjFdO/CR3tLlf5CN34IypI+xMmXW1uB16OOY8z3cICbJlDAVJzNbwBhNO0wt9OAw==" - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { - "ms": "2.0.0" + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" } }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "ansi-regex": "^4.1.0" } } } }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, + "tape": { + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/tape/-/tape-4.10.2.tgz", + "integrity": "sha512-mgl23h7W2yuk3N85FOYrin2OvThTYWdwbk6XQ1pr2PMJieyW2FM/4Bu/+kD/wecb3aZ0Enm+Syinyq467OPq2w==", "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" + "deep-equal": "~1.0.1", + "defined": "~1.0.0", + "for-each": "~0.3.3", + "function-bind": "~1.1.1", + "glob": "~7.1.4", + "has": "~1.0.3", + "inherits": "~2.0.3", + "minimist": "~1.2.0", + "object-inspect": "~1.6.0", + "resolve": "~1.10.1", + "resumer": "~0.0.0", + "string.prototype.trim": "~1.1.2", + "through": "~2.3.8" }, "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "requires": { - "is-descriptor": "^1.0.0" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, + "resolve": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", "requires": { - "kind-of": "^6.0.0" + "path-parse": "^1.0.6" } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, + } + } + }, + "tar": { + "version": "4.4.10", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", + "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.5", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + }, + "dependencies": { + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } + }, + "tar-fs": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", + "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "optional": true, + "requires": { + "chownr": "^1.0.1", + "mkdirp": "^0.5.1", + "pump": "^1.0.0", + "tar-stream": "^1.1.2" + }, + "dependencies": { + "pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "optional": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } } } }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + } + }, + "term-size": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", + "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", + "requires": { + "execa": "^0.7.0" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "then-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz", + "integrity": "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==", "dev": true, "requires": { - "kind-of": "^3.2.0" + "@types/concat-stream": "^1.6.0", + "@types/form-data": "0.0.33", + "@types/node": "^8.0.0", + "@types/qs": "^6.2.31", + "caseless": "~0.12.0", + "concat-stream": "^1.6.0", + "form-data": "^2.2.0", + "http-basic": "^8.1.1", + "http-response-object": "^3.0.1", + "promise": "^8.0.0", + "qs": "^6.4.0" }, "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } + "@types/node": { + "version": "8.10.53", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.53.tgz", + "integrity": "sha512-aOmXdv1a1/vYUn1OT1CED8ftbkmmYbKhKGSyMDeJiidLvKRKvZUQOdXwG/wcNY7T1Qb0XTlVdiYjIq00U7pLrQ==", + "dev": true } } }, - "socks": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.3.2.tgz", - "integrity": "sha512-pCpjxQgOByDHLlNqlnh/mNSAxIUkyBBuwwhTcV+enZGbDaClPvHdvm6uvOwZfFJkam7cGhBNbb4JxiP8UZkRvQ==", + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "requires": { - "ip": "^1.1.5", - "smart-buffer": "4.0.2" + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" } }, - "socks-proxy-agent": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz", - "integrity": "sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg==", + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "requires": { - "agent-base": "~4.2.1", - "socks": "~2.3.2" - }, - "dependencies": { - "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", - "requires": { - "es6-promisify": "^5.0.0" - } - } + "os-tmpdir": "~1.0.2" } }, - "solhint": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.2.0.tgz", - "integrity": "sha512-KNi9qGu17XNV75q9eFftrWIpDVHbejyZ5vaDuNQwet0e9+k8Xw0BdckyVUjYRfFQXAQA3nBTafxUVUtkM4cfIA==", + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=" + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "ajv": "^6.6.1", - "antlr4": "4.7.1", - "chalk": "^2.4.2", - "commander": "2.18.0", - "cosmiconfig": "^5.0.7", - "eslint": "^5.6.0", - "fast-diff": "^1.1.2", - "glob": "^7.1.3", - "ignore": "^4.0.6", - "js-yaml": "^3.12.0", - "lodash": "^4.17.11", - "prettier": "^1.14.3", - "semver": "^6.0.0" - }, - "dependencies": { - "acorn": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", - "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", - "dev": true - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", - "dev": true, - "requires": { - "acorn": "^6.0.7", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "is-buffer": "^1.1.5" } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + } + } + }, + "to-readable-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", + "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==" + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, + "touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "requires": { + "nopt": "~1.0.10" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" + }, + "truffle": { + "version": "5.0.35", + "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.35.tgz", + "integrity": "sha512-ewJPaeHyYgRpuVSvlzhlnalJkeLN0sz7c/P/8WLWpXC966M2o4vL5ov6MNdSHQFYiYQsDrCetrothzsYsg4HWQ==", + "requires": { + "app-module-path": "^2.2.0", + "mocha": "5.2.0", + "original-require": "1.0.1" + } + }, + "truffle-flattener": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/truffle-flattener/-/truffle-flattener-1.4.2.tgz", + "integrity": "sha512-7qUIzaW8a4vI4nui14wsytht2oaqvqnZ1Iet2wRq2T0bCJ0wb6HByMKQhZKpU46R+n5BMTY4K5n+0ITyeNlmuQ==", + "dev": true, + "requires": { + "@resolver-engine/imports-fs": "^0.2.2", + "find-up": "^2.1.0", + "mkdirp": "^0.5.1", + "solidity-parser-antlr": "^0.4.11", + "tsort": "0.0.1" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "locate-path": "^2.0.0" } + }, + "solidity-parser-antlr": { + "version": "0.4.11", + "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz", + "integrity": "sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==", + "dev": true } } }, - "solhint-plugin-prettier": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/solhint-plugin-prettier/-/solhint-plugin-prettier-0.0.3.tgz", - "integrity": "sha512-kdg1c7d5/X/RKTBS9AskwAKOZLpFhwUBelwjrUq43EQXOLd2HR81WvENZWcVNmzewiPTEOoZo3CqqE/Hy/84WQ==", + "try-require": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/try-require/-/try-require-1.2.1.tgz", + "integrity": "sha1-NEiaLKwMCcHMEO2RugEVlNQzO+I=", + "dev": true + }, + "ts-essentials": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-1.0.4.tgz", + "integrity": "sha512-q3N1xS4vZpRouhYHDPwO0bDW3EZ6SK9CrrDHxi/D6BPReSjpVgWIOpLS2o0gSBZm+7q/wyKp6RVM1AeeW7uyfQ==", + "dev": true + }, + "ts-node": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", + "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", "dev": true, "requires": { - "prettier-linter-helpers": "^1.0.0" + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.6", + "yn": "^3.0.0" + }, + "dependencies": { + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + } } }, - "solidity-parser-antlr": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.8.tgz", - "integrity": "sha512-HkAAvzLfw2OPmkuGLcy8M5yVaO4PWagmV4t7DSKYi3pXQZG7TPQ2dWl1c0QTp56snX08FeKsBAsPhXY43yjZUQ==", + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, + "tsort": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tsort/-/tsort-0.0.1.tgz", + "integrity": "sha1-4igPXoF/i/QnVlf9D5rr1E9aJ4Y=", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "npm-check-updates": "^3.1.11" + "safe-buffer": "^5.0.1" } }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, + "type-fest": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", + "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "dependencies": { + "mime-db": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", + "dev": true + }, + "mime-types": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "dev": true, + "requires": { + "mime-db": "1.42.0" + } + } } }, - "source-map-support": { - "version": "0.5.12", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", - "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" + "is-typedarray": "^1.0.0" + } + }, + "u2f-api": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/u2f-api/-/u2f-api-0.2.7.tgz", + "integrity": "sha512-fqLNg8vpvLOD5J/z4B6wpPg4Lvowz1nJ9xdHcCzdUPKcFE/qNCceV2gNZxSJd5vhAZemHr/K/hbzVA0zxB5mkg==" + }, + "uglify-js": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", + "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", + "optional": true, + "requires": { + "commander": "~2.20.0", + "source-map": "~0.6.1" }, "dependencies": { + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "optional": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true } } }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "ultron": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, - "spawn-please": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/spawn-please/-/spawn-please-0.3.0.tgz", - "integrity": "sha1-2zOOxM/2Orxp8dDgjO6euL69nRE=" - }, - "spdx-correct": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", - "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "unbzip2-stream": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", + "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", + "dev": true, "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" + "buffer": "^5.2.1", + "through": "^2.3.8" } }, - "spdx-exceptions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", - "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==" - }, - "spdx-expression-parse": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "undefsafe": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.2.tgz", + "integrity": "sha1-Il9rngM3Zj4Njnz9aG/Cg2zKznY=", + "dev": true, "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" + "debug": "^2.2.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, - "spdx-license-ids": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", - "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==" + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==", + "dev": true }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { - "extend-shallow": "^3.0.0" + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" } }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + "unique-filename": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", + "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", + "requires": { + "unique-slug": "^2.0.0" + } }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "unique-slug": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", + "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" + "imurmurhash": "^0.1.4" } }, - "ssri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", - "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", "requires": { - "figgy-pudding": "^3.5.1" + "crypto-random-string": "^1.0.0" } }, - "static-extend": { + "universalify": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "unorm": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.5.0.tgz", + "integrity": "sha512-sMfSWoiRaXXeDZSXC+YRZ23H4xchQpwxjpw1tmfR+kgbBCaOgln4NI0LXejJIhnBuKINrB3WRn+ZI8IWssirVw==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" + "has-value": "^0.3.1", + "isobject": "^3.0.0" }, "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true } } }, - "stealthy-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", - "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", "dev": true }, - "stream-each": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", - "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", - "requires": { - "end-of-stream": "^1.1.0", - "stream-shift": "^1.0.0" - } - }, - "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" - }, - "strict-uri-encode": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", - "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=" - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string.prototype.trim": { + "upath": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", - "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", - "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.5.0", - "function-bind": "^1.0.2" - } + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", + "dev": true }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "update-notifier": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", + "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", + "dev": true, "requires": { - "safe-buffer": "~5.1.0" + "boxen": "^1.2.1", + "chalk": "^2.0.1", + "configstore": "^3.0.0", + "import-lazy": "^2.1.0", + "is-ci": "^1.0.10", + "is-installed-globally": "^0.1.0", + "is-npm": "^1.0.0", + "latest-version": "^3.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" } }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "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==", "requires": { - "ansi-regex": "^2.0.0" + "punycode": "^2.1.0" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + "url-join": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", + "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==", + "dev": true }, - "strip-hex-prefix": { + "url-parse-lax": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", - "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "dev": true, "requires": { - "is-hex-prefixed": "1.0.0" + "prepend-http": "^1.0.1" } }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + "url-set-query": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", + "integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk=" }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, + "url-to-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", + "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=", + "dev": true + }, + "usb": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/usb/-/usb-1.6.0.tgz", + "integrity": "sha512-52DyWlCk9K+iw3LnvY95WXSnpHjxJoI++aGkV8HiMNPc4zmvDQlYvWAzrkbJ2JH3oUcx26XfU5sZcG4RAcVkMg==", + "optional": true, "requires": { - "has-flag": "^3.0.0" + "bindings": "^1.4.0", + "nan": "2.13.2", + "prebuild-install": "^5.2.4" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "nan": { + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", + "optional": true } } }, - "supports-hyperlinks": { + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "utf8": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", + "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-1.0.1.tgz", - "integrity": "sha512-HHi5kVSefKaJkGYXbDuKbUGRVxqnWGn3J2e39CYcNJEfWciGq2zYtOhXLTlvrOZW1QU7VX67w7fMmWafHX9Pfw==", - "dev": true, + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "dev": true + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, + "valid-url": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", + "integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=" + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "requires": { - "has-flag": "^2.0.0", - "supports-color": "^5.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, - "sync-request": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz", - "integrity": "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==", - "dev": true, + "validate-npm-package-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", + "integrity": "sha1-X6kS2B630MdK/BQN5zF/DKffQ34=", "requires": { - "http-response-object": "^3.0.1", - "sync-rpc": "^1.2.1", - "then-request": "^6.0.0" + "builtins": "^1.0.3" } }, - "sync-rpc": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz", - "integrity": "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==", - "dev": true, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "get-port": "^3.1.0" + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" } }, - "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "web3": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.4.tgz", + "integrity": "sha512-xPXGe+w0x0t88Wj+s/dmAdASr3O9wmA9mpZRtixGZxmBexAF0MjfqYM+MS4tVl5s11hMTN3AZb8cDD4VLfC57A==", "dev": true, "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" + "@types/node": "^12.6.1", + "web3-bzz": "1.2.4", + "web3-core": "1.2.4", + "web3-eth": "1.2.4", + "web3-eth-personal": "1.2.4", + "web3-net": "1.2.4", + "web3-shh": "1.2.4", + "web3-utils": "1.2.4" }, "dependencies": { - "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", + "dev": true + }, + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "ethereumjs-common": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.4.0.tgz", + "integrity": "sha512-ser2SAplX/YI5W2AnzU8wmSjKRy4KQd4uxInJ36BzjS3m18E/B9QedPUIresZN1CSEQb/RgNQ2gN7C/XbpTafA==", + "dev": true + }, + "ethereumjs-tx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.1.tgz", + "integrity": "sha512-QtVriNqowCFA19X9BCRPMgdVNJ0/gMBS91TQb1DfrhsbR748g4STwxZptFAwfqehMyrF8rDwB23w87PQwru0wA==", + "dev": true, + "requires": { + "ethereumjs-common": "^1.3.1", + "ethereumjs-util": "^6.0.0" + } + }, + "ethereumjs-util": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.0.tgz", + "integrity": "sha512-vb0XN9J2QGdZGIEKG2vXM+kUdEivUfU6Wmi5y0cg+LRhDYKnXIZ/Lz7XjFbHRR9VIKq2lVGLzGBkA++y2nOdOQ==", + "dev": true, + "requires": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "ethjs-util": "0.1.6", + "keccak": "^2.0.0", + "rlp": "^2.2.3", + "secp256k1": "^3.0.1" + } + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "dev": true, + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + }, + "dependencies": { + "@types/node": { + "version": "10.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.9.tgz", + "integrity": "sha512-+6VygF9LbG7Gaqeog2G7u1+RUcmo0q1rI+2ZxdIg2fAUngk5Vz9fOCHXdloNUOHEPd1EuuOpL5O0CdgN9Fx5UQ==", + "dev": true + } + } + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "dev": true, + "requires": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + }, + "keccak": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-2.1.0.tgz", + "integrity": "sha512-m1wbJRTo+gWbctZWay9i26v5fFnYkOn7D5PCxJ3fZUGUEb49dE1Pm4BREUYCt/aoO6di7jeoGmhvqN9Nzylm3Q==", + "dev": true, + "requires": { + "bindings": "^1.5.0", + "inherits": "^2.0.4", + "nan": "^2.14.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + } + } + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=", "dev": true }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", "dev": true, "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" + "prepend-http": "^2.0.0" } }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3-bzz": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.2.4.tgz", + "integrity": "sha512-MqhAo/+0iQSMBtt3/QI1rU83uvF08sYq8r25+OUZ+4VtihnYsmkkca+rdU0QbRyrXY2/yGIpI46PFdh0khD53A==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "@types/node": "^10.12.18", + "got": "9.6.0", + "swarm-js": "0.1.39", + "underscore": "1.9.1" + }, + "dependencies": { + "@types/node": { + "version": "10.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.9.tgz", + "integrity": "sha512-+6VygF9LbG7Gaqeog2G7u1+RUcmo0q1rI+2ZxdIg2fAUngk5Vz9fOCHXdloNUOHEPd1EuuOpL5O0CdgN9Fx5UQ==", + "dev": true + } } - } - } - }, - "tape": { - "version": "4.10.2", - "resolved": "https://registry.npmjs.org/tape/-/tape-4.10.2.tgz", - "integrity": "sha512-mgl23h7W2yuk3N85FOYrin2OvThTYWdwbk6XQ1pr2PMJieyW2FM/4Bu/+kD/wecb3aZ0Enm+Syinyq467OPq2w==", - "requires": { - "deep-equal": "~1.0.1", - "defined": "~1.0.0", - "for-each": "~0.3.3", - "function-bind": "~1.1.1", - "glob": "~7.1.4", - "has": "~1.0.3", - "inherits": "~2.0.3", - "minimist": "~1.2.0", - "object-inspect": "~1.6.0", - "resolve": "~1.10.1", - "resumer": "~0.0.0", - "string.prototype.trim": "~1.1.2", - "through": "~2.3.8" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + }, + "web3-core": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.2.4.tgz", + "integrity": "sha512-CHc27sMuET2cs1IKrkz7xzmTdMfZpYswe7f0HcuyneTwS1yTlTnHyqjAaTy0ZygAb/x4iaVox+Gvr4oSAqSI+A==", + "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "@types/bignumber.js": "^5.0.0", + "@types/bn.js": "^4.11.4", + "@types/node": "^12.6.1", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-requestmanager": "1.2.4", + "web3-utils": "1.2.4" } }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "web3-core-helpers": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.2.4.tgz", + "integrity": "sha512-U7wbsK8IbZvF3B7S+QMSNP0tni/6VipnJkB0tZVEpHEIV2WWeBHYmZDnULWcsS/x/jn9yKhJlXIxWGsEAMkjiw==", + "dev": true, + "requires": { + "underscore": "1.9.1", + "web3-eth-iban": "1.2.4", + "web3-utils": "1.2.4" + } }, - "resolve": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", - "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", + "web3-core-method": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.2.4.tgz", + "integrity": "sha512-8p9kpL7di2qOVPWgcM08kb+yKom0rxRCMv6m/K+H+yLSxev9TgMbCgMSbPWAHlyiF3SJHw7APFKahK5Z+8XT5A==", + "dev": true, "requires": { - "path-parse": "^1.0.6" + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-utils": "1.2.4" } - } - } - }, - "tar": { - "version": "4.4.10", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", - "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.5", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" - }, - "dependencies": { - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" - } - } - }, - "tar-fs": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", - "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", - "optional": true, - "requires": { - "chownr": "^1.0.1", - "mkdirp": "^0.5.1", - "pump": "^1.0.0", - "tar-stream": "^1.1.2" - }, - "dependencies": { - "pump": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", - "optional": true, + }, + "web3-core-promievent": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.2.4.tgz", + "integrity": "sha512-gEUlm27DewUsfUgC3T8AxkKi8Ecx+e+ZCaunB7X4Qk3i9F4C+5PSMGguolrShZ7Zb6717k79Y86f3A00O0VAZw==", + "dev": true, + "requires": { + "any-promise": "1.3.0", + "eventemitter3": "3.1.2" + } + }, + "web3-core-requestmanager": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.2.4.tgz", + "integrity": "sha512-eZJDjyNTDtmSmzd3S488nR/SMJtNnn/GuwxnMh3AzYCqG3ZMfOylqTad2eYJPvc2PM5/Gj1wAMQcRpwOjjLuPg==", + "dev": true, + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4", + "web3-providers-http": "1.2.4", + "web3-providers-ipc": "1.2.4", + "web3-providers-ws": "1.2.4" + } + }, + "web3-core-subscriptions": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.2.4.tgz", + "integrity": "sha512-3D607J2M8ymY9V+/WZq4MLlBulwCkwEjjC2U+cXqgVO1rCyVqbxZNCmHyNYHjDDCxSEbks9Ju5xqJxDSxnyXEw==", + "dev": true, + "requires": { + "eventemitter3": "3.1.2", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-eth": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.2.4.tgz", + "integrity": "sha512-+j+kbfmZsbc3+KJpvHM16j1xRFHe2jBAniMo1BHKc3lho6A8Sn9Buyut6odubguX2AxoRArCdIDCkT9hjUERpA==", + "dev": true, + "requires": { + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-eth-accounts": "1.2.4", + "web3-eth-contract": "1.2.4", + "web3-eth-ens": "1.2.4", + "web3-eth-iban": "1.2.4", + "web3-eth-personal": "1.2.4", + "web3-net": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-abi": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.4.tgz", + "integrity": "sha512-8eLIY4xZKoU3DSVu1pORluAw9Ru0/v4CGdw5so31nn+7fR8zgHMgwbFe0aOqWQ5VU42PzMMXeIJwt4AEi2buFg==", + "dev": true, + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.4" + } + }, + "web3-eth-accounts": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.2.4.tgz", + "integrity": "sha512-04LzT/UtWmRFmi4hHRewP5Zz43fWhuHiK5XimP86sUQodk/ByOkXQ3RoXyGXFMNoRxdcAeRNxSfA2DpIBc9xUw==", + "dev": true, + "requires": { + "@web3-js/scrypt-shim": "^0.1.0", + "any-promise": "1.3.0", + "crypto-browserify": "3.12.0", + "eth-lib": "0.2.7", + "ethereumjs-common": "^1.3.2", + "ethereumjs-tx": "^2.1.1", + "underscore": "1.9.1", + "uuid": "3.3.2", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-utils": "1.2.4" + }, + "dependencies": { + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + } + } + }, + "web3-eth-contract": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.2.4.tgz", + "integrity": "sha512-b/9zC0qjVetEYnzRA1oZ8gF1OSSUkwSYi5LGr4GeckLkzXP7osEnp9lkO/AQcE4GpG+l+STnKPnASXJGZPgBRQ==", + "dev": true, + "requires": { + "@types/bn.js": "^4.11.4", + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-ens": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.2.4.tgz", + "integrity": "sha512-g8+JxnZlhdsCzCS38Zm6R/ngXhXzvc3h7bXlxgKU4coTzLLoMpgOAEz71GxyIJinWTFbLXk/WjNY0dazi9NwVw==", + "dev": true, + "requires": { + "eth-ens-namehash": "2.0.8", + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-eth-contract": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-iban": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.2.4.tgz", + "integrity": "sha512-D9HIyctru/FLRpXakRwmwdjb5bWU2O6UE/3AXvRm6DCOf2e+7Ve11qQrPtaubHfpdW3KWjDKvlxV9iaFv/oTMQ==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "web3-utils": "1.2.4" + } + }, + "web3-eth-personal": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.2.4.tgz", + "integrity": "sha512-5Russ7ZECwHaZXcN3DLuLS7390Vzgrzepl4D87SD6Sn1DHsCZtvfdPIYwoTmKNp69LG3mORl7U23Ga5YxqkICw==", + "dev": true, + "requires": { + "@types/node": "^12.6.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-net": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-net": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.2.4.tgz", + "integrity": "sha512-wKOsqhyXWPSYTGbp7ofVvni17yfRptpqoUdp3SC8RAhDmGkX6irsiT9pON79m6b3HUHfLoBilFQyt/fTUZOf7A==", + "dev": true, + "requires": { + "web3-core": "1.2.4", + "web3-core-method": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-providers-http": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.2.4.tgz", + "integrity": "sha512-dzVCkRrR/cqlIrcrWNiPt9gyt0AZTE0J+MfAu9rR6CyIgtnm1wFUVVGaxYRxuTGQRO4Dlo49gtoGwaGcyxqiTw==", + "dev": true, + "requires": { + "web3-core-helpers": "1.2.4", + "xhr2-cookies": "1.1.0" + } + }, + "web3-providers-ipc": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.2.4.tgz", + "integrity": "sha512-8J3Dguffin51gckTaNrO3oMBo7g+j0UNk6hXmdmQMMNEtrYqw4ctT6t06YOf9GgtOMjSAc1YEh3LPrvgIsR7og==", + "dev": true, + "requires": { + "oboe": "2.1.4", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-providers-ws": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.2.4.tgz", + "integrity": "sha512-F/vQpDzeK+++oeeNROl1IVTufFCwCR2hpWe5yRXN0ApLwHqXrMI7UwQNdJ9iyibcWjJf/ECbauEEQ8CHgE+MYQ==", + "dev": true, + "requires": { + "@web3-js/websocket": "^1.0.29", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-shh": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.2.4.tgz", + "integrity": "sha512-z+9SCw0dE+69Z/Hv8809XDbLj7lTfEv9Sgu8eKEIdGntZf4v7ewj5rzN5bZZSz8aCvfK7Y6ovz1PBAu4QzS4IQ==", + "dev": true, + "requires": { + "web3-core": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-net": "1.2.4" + } + }, + "web3-utils": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.4.tgz", + "integrity": "sha512-+S86Ip+jqfIPQWvw2N/xBQq5JNqCO0dyvukGdJm8fEWHZbckT4WxSpHbx+9KLEWY4H4x9pUwnoRkK87pYyHfgQ==", + "dev": true, "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" } } } }, - "tar-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", - "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", - "optional": true, - "requires": { - "bl": "^1.0.0", - "buffer-alloc": "^1.2.0", - "end-of-stream": "^1.0.0", - "fs-constants": "^1.0.0", - "readable-stream": "^2.3.0", - "to-buffer": "^1.1.1", - "xtend": "^4.0.0" - } - }, - "term-size": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", - "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", - "requires": { - "execa": "^0.7.0" - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "then-request": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz", - "integrity": "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==", - "dev": true, - "requires": { - "@types/concat-stream": "^1.6.0", - "@types/form-data": "0.0.33", - "@types/node": "^8.0.0", - "@types/qs": "^6.2.31", - "caseless": "~0.12.0", - "concat-stream": "^1.6.0", - "form-data": "^2.2.0", - "http-basic": "^8.1.1", - "http-response-object": "^3.0.1", - "promise": "^8.0.0", - "qs": "^6.4.0" - }, - "dependencies": { - "@types/node": { - "version": "8.10.53", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.53.tgz", - "integrity": "sha512-aOmXdv1a1/vYUn1OT1CED8ftbkmmYbKhKGSyMDeJiidLvKRKvZUQOdXwG/wcNY7T1Qb0XTlVdiYjIq00U7pLrQ==", - "dev": true - } - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, - "timed-out": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "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", - "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", - "optional": true - }, - "to-fast-properties": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=" - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "web3-bzz": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.2.2.tgz", + "integrity": "sha512-b1O2ObsqUN1lJxmFSjvnEC4TsaCbmh7Owj3IAIWTKqL9qhVgx7Qsu5O9cD13pBiSPNZJ68uJPaKq380QB4NWeA==", "dev": true, "requires": { - "kind-of": "^3.0.2" + "@types/node": "^10.12.18", + "got": "9.6.0", + "swarm-js": "0.1.39", + "underscore": "1.9.1" }, "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "pump": "^3.0.0" } - } - } - }, - "to-readable-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", - "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==" - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "requires": { - "nopt": "~1.0.10" - } - }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - } - } - }, - "trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" - }, - "truffle": { - "version": "5.0.35", - "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.35.tgz", - "integrity": "sha512-ewJPaeHyYgRpuVSvlzhlnalJkeLN0sz7c/P/8WLWpXC966M2o4vL5ov6MNdSHQFYiYQsDrCetrothzsYsg4HWQ==", - "dev": true, - "requires": { - "app-module-path": "^2.2.0", - "mocha": "5.2.0", - "original-require": "1.0.1" - } - }, - "truffle-flattener": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/truffle-flattener/-/truffle-flattener-1.4.2.tgz", - "integrity": "sha512-7qUIzaW8a4vI4nui14wsytht2oaqvqnZ1Iet2wRq2T0bCJ0wb6HByMKQhZKpU46R+n5BMTY4K5n+0ITyeNlmuQ==", - "dev": true, - "requires": { - "@resolver-engine/imports-fs": "^0.2.2", - "find-up": "^2.1.0", - "mkdirp": "^0.5.1", - "solidity-parser-antlr": "^0.4.11", - "tsort": "0.0.1" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", "dev": true, "requires": { - "locate-path": "^2.0.0" + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" } }, - "solidity-parser-antlr": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz", - "integrity": "sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==", + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true - } - } - }, - "ts-essentials": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-1.0.4.tgz", - "integrity": "sha512-q3N1xS4vZpRouhYHDPwO0bDW3EZ6SK9CrrDHxi/D6BPReSjpVgWIOpLS2o0gSBZm+7q/wyKp6RVM1AeeW7uyfQ==", - "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "dev": true, + "requires": { + "prepend-http": "^2.0.0" + } + } + } }, - "ts-node": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", - "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", + "web3-core": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.2.2.tgz", + "integrity": "sha512-miHAX3qUgxV+KYfaOY93Hlc3kLW2j5fH8FJy6kSxAv+d4d5aH0wwrU2IIoJylQdT+FeenQ38sgsCnFu9iZ1hCQ==", "dev": true, "requires": { - "arg": "^4.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "source-map-support": "^0.5.6", - "yn": "^3.0.0" + "@types/bn.js": "^4.11.4", + "@types/node": "^12.6.1", + "web3-core-helpers": "1.2.2", + "web3-core-method": "1.2.2", + "web3-core-requestmanager": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { - "diff": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", - "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", "dev": true + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } } } }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" - }, - "tsort": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tsort/-/tsort-0.0.1.tgz", - "integrity": "sha1-4igPXoF/i/QnVlf9D5rr1E9aJ4Y=", - "dev": true - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" - }, - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" - }, - "u2f-api": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/u2f-api/-/u2f-api-0.2.7.tgz", - "integrity": "sha512-fqLNg8vpvLOD5J/z4B6wpPg4Lvowz1nJ9xdHcCzdUPKcFE/qNCceV2gNZxSJd5vhAZemHr/K/hbzVA0zxB5mkg==" - }, - "uglify-js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", - "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", - "optional": true, + "web3-core-helpers": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.2.2.tgz", + "integrity": "sha512-HJrRsIGgZa1jGUIhvGz4S5Yh6wtOIo/TMIsSLe+Xay+KVnbseJpPprDI5W3s7H2ODhMQTbogmmUFquZweW2ImQ==", + "dev": true, "requires": { - "commander": "~2.20.0", - "source-map": "~0.6.1" + "underscore": "1.9.1", + "web3-eth-iban": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "optional": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } } } }, - "undefsafe": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.2.tgz", - "integrity": "sha1-Il9rngM3Zj4Njnz9aG/Cg2zKznY=", + "web3-core-method": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.2.2.tgz", + "integrity": "sha512-szR4fDSBxNHaF1DFqE+j6sFR/afv9Aa36OW93saHZnrh+iXSrYeUUDfugeNcRlugEKeUCkd4CZylfgbK2SKYJA==", "dev": true, "requires": { - "debug": "^2.2.0" + "underscore": "1.9.1", + "web3-core-helpers": "1.2.2", + "web3-core-promievent": "1.2.2", + "web3-core-subscriptions": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", "dev": true, "requires": { - "ms": "2.0.0" + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" } } } }, - "union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "web3-core-promievent": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.2.2.tgz", + "integrity": "sha512-tKvYeT8bkUfKABcQswK6/X79blKTKYGk949urZKcLvLDEaWrM3uuzDwdQT3BNKzQ3vIvTggFPX9BwYh0F1WwqQ==", "dev": true, "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, - "unique-filename": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", - "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", - "requires": { - "unique-slug": "^2.0.0" + "any-promise": "1.3.0", + "eventemitter3": "3.1.2" } }, - "unique-slug": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", - "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", + "web3-core-requestmanager": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.2.2.tgz", + "integrity": "sha512-a+gSbiBRHtHvkp78U2bsntMGYGF2eCb6219aMufuZWeAZGXJ63Wc2321PCbA8hF9cQrZI4EoZ4kVLRI4OF15Hw==", + "dev": true, "requires": { - "imurmurhash": "^0.1.4" + "underscore": "1.9.1", + "web3-core-helpers": "1.2.2", + "web3-providers-http": "1.2.2", + "web3-providers-ipc": "1.2.2", + "web3-providers-ws": "1.2.2" } }, - "unique-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", - "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "web3-core-subscriptions": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.2.2.tgz", + "integrity": "sha512-QbTgigNuT4eicAWWr7ahVpJyM8GbICsR1Ys9mJqzBEwpqS+RXTRVSkwZ2IsxO+iqv6liMNwGregbJLq4urMFcQ==", + "dev": true, "requires": { - "crypto-random-string": "^1.0.0" + "eventemitter3": "3.1.2", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.2" } }, - "unorm": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.5.0.tgz", - "integrity": "sha512-sMfSWoiRaXXeDZSXC+YRZ23H4xchQpwxjpw1tmfR+kgbBCaOgln4NI0LXejJIhnBuKINrB3WRn+ZI8IWssirVw==" - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "web3-eth": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.2.2.tgz", + "integrity": "sha512-UXpC74mBQvZzd4b+baD4Ocp7g+BlwxhBHumy9seyE/LMIcMlePXwCKzxve9yReNpjaU16Mmyya6ZYlyiKKV8UA==", "dev": true, "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" + "underscore": "1.9.1", + "web3-core": "1.2.2", + "web3-core-helpers": "1.2.2", + "web3-core-method": "1.2.2", + "web3-core-subscriptions": "1.2.2", + "web3-eth-abi": "1.2.2", + "web3-eth-accounts": "1.2.2", + "web3-eth-contract": "1.2.2", + "web3-eth-ens": "1.2.2", + "web3-eth-iban": "1.2.2", + "web3-eth-personal": "1.2.2", + "web3-net": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", "dev": true, "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "dev": true, + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + }, + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=", + "dev": true + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3-eth-abi": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.2.tgz", + "integrity": "sha512-Yn/ZMgoOLxhTVxIYtPJ0eS6pnAnkTAaJgUJh1JhZS4ekzgswMfEYXOwpMaD5eiqPJLpuxmZFnXnBZlnQ1JMXsw==", + "dev": true, + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.2" } }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } } } }, - "unzip-response": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", - "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", - "dev": true - }, - "upath": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", - "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", - "dev": true - }, - "update-notifier": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", - "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", - "dev": true, - "requires": { - "boxen": "^1.2.1", - "chalk": "^2.0.1", - "configstore": "^3.0.0", - "import-lazy": "^2.1.0", - "is-ci": "^1.0.10", - "is-installed-globally": "^0.1.0", - "is-npm": "^1.0.0", - "latest-version": "^3.0.0", - "semver-diff": "^2.0.0", - "xdg-basedir": "^3.0.0" - } - }, - "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==", + "web3-eth-abi": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.1.tgz", + "integrity": "sha512-jI/KhU2a/DQPZXHjo2GW0myEljzfiKOn+h1qxK1+Y9OQfTcBMxrQJyH5AP89O6l6NZ1QvNdq99ThAxBFoy5L+g==", "requires": { - "punycode": "^2.1.0" + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.1" + }, + "dependencies": { + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + }, + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=" + }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" + } } }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url-join": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", - "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==", - "dev": true - }, - "url-parse-lax": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "web3-eth-accounts": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.2.2.tgz", + "integrity": "sha512-KzHOEyXOEZ13ZOkWN3skZKqSo5f4Z1ogPFNn9uZbKCz+kSp+gCAEKxyfbOsB/JMAp5h7o7pb6eYsPCUBJmFFiA==", "dev": true, "requires": { - "prepend-http": "^1.0.1" - } - }, - "url-set-query": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", - "integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk=" - }, - "usb": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/usb/-/usb-1.6.0.tgz", - "integrity": "sha512-52DyWlCk9K+iw3LnvY95WXSnpHjxJoI++aGkV8HiMNPc4zmvDQlYvWAzrkbJ2JH3oUcx26XfU5sZcG4RAcVkMg==", - "optional": true, - "requires": { - "bindings": "^1.4.0", - "nan": "2.13.2", - "prebuild-install": "^5.2.4" + "any-promise": "1.3.0", + "crypto-browserify": "3.12.0", + "eth-lib": "0.2.7", + "ethereumjs-common": "^1.3.2", + "ethereumjs-tx": "^2.1.1", + "scrypt-shim": "github:web3-js/scrypt-shim", + "underscore": "1.9.1", + "uuid": "3.3.2", + "web3-core": "1.2.2", + "web3-core-helpers": "1.2.2", + "web3-core-method": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { + "ethereumjs-common": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.4.0.tgz", + "integrity": "sha512-ser2SAplX/YI5W2AnzU8wmSjKRy4KQd4uxInJ36BzjS3m18E/B9QedPUIresZN1CSEQb/RgNQ2gN7C/XbpTafA==", + "dev": true + }, + "ethereumjs-tx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.1.tgz", + "integrity": "sha512-QtVriNqowCFA19X9BCRPMgdVNJ0/gMBS91TQb1DfrhsbR748g4STwxZptFAwfqehMyrF8rDwB23w87PQwru0wA==", + "dev": true, + "requires": { + "ethereumjs-common": "^1.3.1", + "ethereumjs-util": "^6.0.0" + } + }, + "ethereumjs-util": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.0.tgz", + "integrity": "sha512-vb0XN9J2QGdZGIEKG2vXM+kUdEivUfU6Wmi5y0cg+LRhDYKnXIZ/Lz7XjFbHRR9VIKq2lVGLzGBkA++y2nOdOQ==", + "dev": true, + "requires": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "ethjs-util": "0.1.6", + "keccak": "^2.0.0", + "rlp": "^2.2.3", + "secp256k1": "^3.0.1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "keccak": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-2.1.0.tgz", + "integrity": "sha512-m1wbJRTo+gWbctZWay9i26v5fFnYkOn7D5PCxJ3fZUGUEb49dE1Pm4BREUYCt/aoO6di7jeoGmhvqN9Nzylm3Q==", + "dev": true, + "requires": { + "bindings": "^1.5.0", + "inherits": "^2.0.4", + "nan": "^2.14.0", + "safe-buffer": "^5.2.0" + } + }, "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", - "optional": true - } - } - }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" - }, - "v8-compile-cache": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", - "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", - "dev": true - }, - "valid-url": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", - "integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=" - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "validate-npm-package-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", - "integrity": "sha1-X6kS2B630MdK/BQN5zF/DKffQ34=", - "requires": { - "builtins": "^1.0.3" + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "dev": true + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + } } }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "web3-eth-contract": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.2.2.tgz", + "integrity": "sha512-EKT2yVFws3FEdotDQoNsXTYL798+ogJqR2//CaGwx3p0/RvQIgfzEwp8nbgA6dMxCsn9KOQi7OtklzpnJMkjtA==", + "dev": true, "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" + "@types/bn.js": "^4.11.4", + "underscore": "1.9.1", + "web3-core": "1.2.2", + "web3-core-helpers": "1.2.2", + "web3-core-method": "1.2.2", + "web3-core-promievent": "1.2.2", + "web3-core-subscriptions": "1.2.2", + "web3-eth-abi": "1.2.2", + "web3-utils": "1.2.2" + }, + "dependencies": { + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "dev": true, + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true + }, + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=", + "dev": true + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3-eth-abi": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.2.tgz", + "integrity": "sha512-Yn/ZMgoOLxhTVxIYtPJ0eS6pnAnkTAaJgUJh1JhZS4ekzgswMfEYXOwpMaD5eiqPJLpuxmZFnXnBZlnQ1JMXsw==", + "dev": true, + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.2" + } + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + } } }, - "web3-eth-abi": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.1.tgz", - "integrity": "sha512-jI/KhU2a/DQPZXHjo2GW0myEljzfiKOn+h1qxK1+Y9OQfTcBMxrQJyH5AP89O6l6NZ1QvNdq99ThAxBFoy5L+g==", + "web3-eth-ens": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.2.2.tgz", + "integrity": "sha512-CFjkr2HnuyMoMFBoNUWojyguD4Ef+NkyovcnUc/iAb9GP4LHohKrODG4pl76R5u61TkJGobC2ij6TyibtsyVYg==", + "dev": true, "requires": { - "ethers": "4.0.0-beta.3", + "eth-ens-namehash": "2.0.8", "underscore": "1.9.1", - "web3-utils": "1.2.1" + "web3-core": "1.2.2", + "web3-core-helpers": "1.2.2", + "web3-core-promievent": "1.2.2", + "web3-eth-abi": "1.2.2", + "web3-eth-contract": "1.2.2", + "web3-utils": "1.2.2" }, "dependencies": { "elliptic": { "version": "6.3.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "dev": true, "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -24355,6 +27170,7 @@ "version": "4.0.0-beta.3", "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "dev": true, "requires": { "@types/node": "^10.3.2", "aes-js": "3.0.0", @@ -24372,6 +27188,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, "requires": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.0" @@ -24380,22 +27197,142 @@ "js-sha3": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", + "dev": true }, "scrypt-js": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", - "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=" - }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=", + "dev": true }, "uuid": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "dev": true + }, + "web3-eth-abi": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.2.tgz", + "integrity": "sha512-Yn/ZMgoOLxhTVxIYtPJ0eS6pnAnkTAaJgUJh1JhZS4ekzgswMfEYXOwpMaD5eiqPJLpuxmZFnXnBZlnQ1JMXsw==", + "dev": true, + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.2" + } + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + } + } + }, + "web3-eth-iban": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.2.2.tgz", + "integrity": "sha512-gxKXBoUhaTFHr0vJB/5sd4i8ejF/7gIsbM/VvemHT3tF5smnmY6hcwSMmn7sl5Gs+83XVb/BngnnGkf+I/rsrQ==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "web3-utils": "1.2.2" + }, + "dependencies": { + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + } + } + }, + "web3-eth-personal": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.2.2.tgz", + "integrity": "sha512-4w+GLvTlFqW3+q4xDUXvCEMU7kRZ+xm/iJC8gm1Li1nXxwwFbs+Y+KBK6ZYtoN1qqAnHR+plYpIoVo27ixI5Rg==", + "dev": true, + "requires": { + "@types/node": "^12.6.1", + "web3-core": "1.2.2", + "web3-core-helpers": "1.2.2", + "web3-core-method": "1.2.2", + "web3-net": "1.2.2", + "web3-utils": "1.2.2" + }, + "dependencies": { + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", + "dev": true + }, + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + } + } + }, + "web3-net": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.2.2.tgz", + "integrity": "sha512-K07j2DXq0x4UOJgae65rWZKraOznhk8v5EGSTdFqASTx7vWE/m+NqBijBYGEsQY1lSMlVaAY9UEQlcXK5HzXTw==", + "dev": true, + "requires": { + "web3-core": "1.2.2", + "web3-core-method": "1.2.2", + "web3-utils": "1.2.2" + }, + "dependencies": { + "web3-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.2.tgz", + "integrity": "sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + } } } }, @@ -24437,6 +27374,50 @@ } } }, + "web3-providers-http": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.2.2.tgz", + "integrity": "sha512-BNZ7Hguy3eBszsarH5gqr9SIZNvqk9eKwqwmGH1LQS1FL3NdoOn7tgPPdddrXec4fL94CwgNk4rCU+OjjZRNDg==", + "dev": true, + "requires": { + "web3-core-helpers": "1.2.2", + "xhr2-cookies": "1.1.0" + } + }, + "web3-providers-ipc": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.2.2.tgz", + "integrity": "sha512-t97w3zi5Kn/LEWGA6D9qxoO0LBOG+lK2FjlEdCwDQatffB/+vYrzZ/CLYVQSoyFZAlsDoBasVoYSWZK1n39aHA==", + "dev": true, + "requires": { + "oboe": "2.1.4", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.2" + } + }, + "web3-providers-ws": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.2.2.tgz", + "integrity": "sha512-Wb1mrWTGMTXOpJkL0yGvL/WYLt8fUIXx8k/l52QB2IiKzvyd42dTWn4+j8IKXGSYYzOm7NMqv6nhA5VDk12VfA==", + "dev": true, + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.2", + "websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" + } + }, + "web3-shh": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.2.2.tgz", + "integrity": "sha512-og258NPhlBn8yYrDWjoWBBb6zo1OlBgoWGT+LL5/LPqRbjPe09hlOYHgscAAr9zZGtohTOty7RrxYw6Z6oDWCg==", + "dev": true, + "requires": { + "web3-core": "1.2.2", + "web3-core-method": "1.2.2", + "web3-core-subscriptions": "1.2.2", + "web3-net": "1.2.2" + } + }, "web3-utils": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.1.tgz", @@ -24463,6 +27444,35 @@ } } }, + "websocket": { + "version": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e", + "from": "github:web3-js/WebSocket-Node#polyfill/globalThis", + "dev": true, + "requires": { + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "nan": "^2.14.0", + "typedarray-to-buffer": "^3.1.5", + "yaeti": "^0.0.6" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true + } + } + }, "whatwg-fetch": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", @@ -24617,6 +27627,15 @@ "xhr-request": "^1.0.1" } }, + "xhr2-cookies": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz", + "integrity": "sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg=", + "dev": true, + "requires": { + "cookiejar": "^2.1.1" + } + }, "xmlhttprequest": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", @@ -24632,6 +27651,12 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" }, + "yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=", + "dev": true + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", @@ -24725,6 +27750,16 @@ "decamelize": "^1.2.0" } }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "dev": true, + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/package.json b/package.json index 7de201ebc..aabf8708d 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "devDependencies": { "@codechecks/client": "^0.1.9", + "@openzeppelin/test-helpers": "^0.5.4", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "chai-bn": "^0.1.1", diff --git a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js index 2bd8950c2..54f277140 100644 --- a/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js +++ b/test/amb_erc677_to_erc677/AMBErc677ToErc677Behavior.test.js @@ -26,12 +26,7 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function shouldBehaveLikeBasicAMBErc677ToErc677( - otherSideMediatorContract, - accounts, - isRelativeDailyLimit, - isRelativeDailyLimitOnBridgeSide -) { +function shouldBehaveLikeBasicAMBErc677ToErc677(otherSideMediatorContract, accounts, isRelativeDailyLimitOnBridgeSide) { let bridgeContract let mediatorContract let erc677Token @@ -40,27 +35,37 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( const owner = accounts[0] const user = accounts[1] - let limitsArray = [dailyLimit, maxPerTx, minPerTx] - let executionLimitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] - let LimitsContract = AbsoluteDailyLimit - - if (isRelativeDailyLimit) { - if (isRelativeDailyLimitOnBridgeSide) { - limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] - LimitsContract = RelativeDailyLimit - } else { - executionLimitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] - LimitsContract = RelativeExecutionDailyLimit + const limitsArray = [dailyLimit, maxPerTx, minPerTx] + const executionLimitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + const LimitsContract = AbsoluteDailyLimit + + function getRequestLimits(isRelativeDailyLimit) { + if (!isRelativeDailyLimit || !isRelativeDailyLimitOnBridgeSide) { + return [dailyLimit, maxPerTx, minPerTx] } + return [targetLimit, threshold, maxPerTx, minPerTx] + } + + function getExecutionLimits(isRelativeDailyLimit) { + if (!isRelativeDailyLimit || isRelativeDailyLimitOnBridgeSide) { + return [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + } + return [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + } + + function getLimitsContract(isRelativeDailyLimit) { + if (!isRelativeDailyLimit) return AbsoluteDailyLimit + if (!isRelativeDailyLimitOnBridgeSide) return RelativeExecutionDailyLimit + return RelativeDailyLimit } - function initialize(tokenAddress) { + function initialize(tokenAddress, limits = limitsArray, executionLimits = executionLimitsArray) { return contract.initialize( bridgeContract.address, mediatorContract.address, tokenAddress, - limitsArray, - executionLimitsArray, + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner, @@ -74,103 +79,105 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await bridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await otherSideMediatorContract.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() }) - it('should initialize', async function() { - contract = this.bridge - expect(await contract.isInitialized()).to.be.equal(false) - expect(await contract.bridgeContract()).to.be.equal(ZERO_ADDRESS) - expect(await contract.mediatorContractOnOtherSide()).to.be.equal(ZERO_ADDRESS) - expect(await contract.erc677token()).to.be.equal(ZERO_ADDRESS) - expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO) - expect(await contract.owner()).to.be.equal(ZERO_ADDRESS) - expect(await contract.limitsContract()).to.be.equal(ZERO_ADDRESS) - - // not valid bridge contract - await contract - .initialize( - ZERO_ADDRESS, - mediatorContract.address, - erc677Token.address, - limitsArray, - executionLimitsArray, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) - - // not valid erc677 contract - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - ZERO_ADDRESS, - limitsArray, - executionLimitsArray, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) + const shouldInitialize = isRelativeDailyLimit => + async function() { + contract = this.bridge + expect(await contract.isInitialized()).to.be.equal(false) + expect(await contract.bridgeContract()).to.be.equal(ZERO_ADDRESS) + expect(await contract.mediatorContractOnOtherSide()).to.be.equal(ZERO_ADDRESS) + expect(await contract.erc677token()).to.be.equal(ZERO_ADDRESS) + expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO) + expect(await contract.owner()).to.be.equal(ZERO_ADDRESS) + expect(await contract.limitsContract()).to.be.equal(ZERO_ADDRESS) + + const limitsArray = getRequestLimits(isRelativeDailyLimit) + const executionLimitsArray = getExecutionLimits(isRelativeDailyLimit) + const LimitsContract = getLimitsContract(isRelativeDailyLimit) + limitsContract = await LimitsContract.new() + + // not valid bridge contract + await contract + .initialize( + ZERO_ADDRESS, + mediatorContract.address, + erc677Token.address, + limitsArray, + executionLimitsArray, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) - // dailyLimit > maxPerTx - let limits = [maxPerTx, maxPerTx, minPerTx] - let executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] - let relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] - if (isRelativeDailyLimit) { - limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits - executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit - } - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limits, - executionLimits, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) + // not valid erc677 contract + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + ZERO_ADDRESS, + limitsArray, + executionLimitsArray, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + // not valid limits contract + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + limitsArray, + executionLimitsArray, + maxGasPerTx, + decimalShiftZero, + owner, + ZERO_ADDRESS + ) + .should.be.rejectedWith(ERROR_MSG) - // maxPerTx > minPerTx - limits = [dailyLimit, minPerTx, minPerTx] - executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] - relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] - if (isRelativeDailyLimit) { - limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits - executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit - } - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limits, - executionLimits, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) + // dailyLimit > maxPerTx + let limits = [maxPerTx, maxPerTx, minPerTx] + let executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + let relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + limits, + executionLimits, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) - // threshold <= 1 ether - if (isRelativeDailyLimit) { - limits = [dailyLimit, maxPerTx, minPerTx] - relativeDailyLimit = [ether('1.1'), threshold, executionMaxPerTx, executionMinPerTx] + // maxPerTx > minPerTx + limits = [dailyLimit, minPerTx, minPerTx] + executionLimits = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] + relativeDailyLimit = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } await contract .initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, - isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner, @@ -178,110 +185,132 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( ) .should.be.rejectedWith(ERROR_MSG) - // threshold >= executionMinPerTx + // threshold <= 1 ether + if (isRelativeDailyLimit) { + limits = [dailyLimit, maxPerTx, minPerTx] + relativeDailyLimit = [ether('1.1'), threshold, executionMaxPerTx, executionMinPerTx] + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, + isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + + // threshold >= executionMinPerTx + limits = [dailyLimit, maxPerTx, minPerTx] + relativeDailyLimit = [targetLimit, ether('0.009'), executionMaxPerTx, executionMinPerTx] + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, + isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + } + + // executionMaxPerTx > executionMinPerTx limits = [dailyLimit, maxPerTx, minPerTx] - relativeDailyLimit = [targetLimit, ether('0.009'), executionMaxPerTx, executionMinPerTx] + executionLimits = [executionDailyLimit, executionMinPerTx, executionMinPerTx] + relativeDailyLimit = [targetLimit, threshold, executionMinPerTx, executionMinPerTx] + if (isRelativeDailyLimit) { + limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits + executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit + } await contract .initialize( bridgeContract.address, mediatorContract.address, erc677Token.address, - isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits, - isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit, + limits, + executionLimits, maxGasPerTx, decimalShiftZero, owner, limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) - } - - // executionMaxPerTx > executionMinPerTx - limits = [dailyLimit, maxPerTx, minPerTx] - executionLimits = [executionDailyLimit, executionMinPerTx, executionMinPerTx] - relativeDailyLimit = [targetLimit, threshold, executionMinPerTx, executionMinPerTx] - if (isRelativeDailyLimit) { - limits = isRelativeDailyLimitOnBridgeSide ? relativeDailyLimit : limits - executionLimits = isRelativeDailyLimitOnBridgeSide ? limits : relativeDailyLimit - } - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limits, - executionLimits, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) - // maxGasPerTx > bridge maxGasPerTx - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limitsArray, - executionLimitsArray, - dailyLimit, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) + // maxGasPerTx > bridge maxGasPerTx + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + limitsArray, + executionLimitsArray, + dailyLimit, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) - const { tx } = await initialize(erc677Token.address) + const { tx } = await initialize(erc677Token.address, limitsArray, executionLimitsArray).should.be.fulfilled - // already initialized - await contract - .initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limitsArray, - executionLimitsArray, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ) - .should.be.rejectedWith(ERROR_MSG) - - expect(await contract.isInitialized()).to.be.equal(true) - expect(await contract.bridgeContract()).to.be.equal(bridgeContract.address) - expect(await contract.mediatorContractOnOtherSide()).to.be.equal(mediatorContract.address) - expect(await contract.erc677token()).to.be.equal(erc677Token.address) - expect(await contract.maxPerTx()).to.be.bignumber.equal(maxPerTx) - expect(await contract.minPerTx()).to.be.bignumber.equal(minPerTx) - expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(executionMaxPerTx) - expect(await contract.executionMinPerTx()).to.be.bignumber.equal(executionMinPerTx) - expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx) - expect(await contract.owner()).to.be.equal(owner) + // already initialized + await contract + .initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + limitsArray, + executionLimitsArray, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) - if (isRelativeDailyLimit) { - expect(await contract.targetLimit()).to.be.bignumber.equal(targetLimit) - expect(await contract.threshold()).to.be.bignumber.equal(threshold) - if (isRelativeDailyLimitOnBridgeSide) { + expect(await contract.isInitialized()).to.be.equal(true) + expect(await contract.bridgeContract()).to.be.equal(bridgeContract.address) + expect(await contract.mediatorContractOnOtherSide()).to.be.equal(mediatorContract.address) + expect(await contract.erc677token()).to.be.equal(erc677Token.address) + expect(await contract.maxPerTx()).to.be.bignumber.equal(maxPerTx) + expect(await contract.minPerTx()).to.be.bignumber.equal(minPerTx) + expect(await contract.executionMaxPerTx()).to.be.bignumber.equal(executionMaxPerTx) + expect(await contract.executionMinPerTx()).to.be.bignumber.equal(executionMinPerTx) + expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx) + expect(await contract.owner()).to.be.equal(owner) + + if (isRelativeDailyLimit) { + expect(await contract.targetLimit()).to.be.bignumber.equal(targetLimit) + expect(await contract.threshold()).to.be.bignumber.equal(threshold) + if (isRelativeDailyLimitOnBridgeSide) { + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: executionDailyLimit.toString() + }) + } else { + expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { + newLimit: dailyLimit.toString() + }) + } + } else { expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) + expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit.toString() }) - } else { - expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) } - } else { - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(executionDailyLimit) - expect(await contract.dailyLimit()).to.be.bignumber.equal(dailyLimit) - await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { - newLimit: executionDailyLimit.toString() - }) - await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) } - }) + it('should initialize', shouldInitialize(false)) + it('should initialize (relative limits)', shouldInitialize(true)) it('only owner can set bridge contract', async function() { contract = this.bridge const user = accounts[1] @@ -336,130 +365,134 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( expect(await contract.requestGasLimit()).to.be.bignumber.equal(newMaxGasPerTx) }) }) - describe('set limits', () => { - beforeEach(async function() { - bridgeContract = await AMBMock.new() - await bridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await otherSideMediatorContract.new() - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() - - contract = this.bridge - - let limits = [3, 2, 1] - let executionLimits = [3, 2, 1] + const setLimits = isRelativeDailyLimit => + function() { + beforeEach(async function() { + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + const LimitsContract = getLimitsContract(isRelativeDailyLimit) + limitsContract = await LimitsContract.new() + + contract = this.bridge + + let limits = [3, 2, 1] + let executionLimits = [3, 2, 1] + + if (isRelativeDailyLimit) { + if (isRelativeDailyLimitOnBridgeSide) { + limits = [ether('0.05'), 3, 2, 1] + } else { + executionLimits = [ether('0.05'), 3, 2, 1] + } + } - if (isRelativeDailyLimit) { - if (isRelativeDailyLimitOnBridgeSide) { - limits = [ether('0.05'), 3, 2, 1] - } else { - executionLimits = [ether('0.05'), 3, 2, 1] + await contract.initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + limits, + executionLimits, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ).should.be.fulfilled + }) + it('setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await contract.setMaxPerTx(2, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setMaxPerTx(2, { from: owner }).should.be.fulfilled + expect(await contract.maxPerTx()).to.be.bignumber.equal('2') + + if (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide) { + await contract.setMaxPerTx(0, { from: owner }).should.be.fulfilled + expect(await contract.maxPerTx()).to.be.bignumber.equal('0') } - } - await contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - limits, - executionLimits, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ).should.be.fulfilled - }) - it('setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await contract.setMaxPerTx(2, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setMaxPerTx(2, { from: owner }).should.be.fulfilled - expect(await contract.maxPerTx()).to.be.bignumber.equal('2') - - if (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide) { - await contract.setMaxPerTx(0, { from: owner }).should.be.fulfilled - expect(await contract.maxPerTx()).to.be.bignumber.equal('0') - } + if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { + await contract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } + }) + it('setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { + await contract.setMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setMinPerTx(1, { from: owner }).should.be.fulfilled + expect(await contract.minPerTx()).to.be.bignumber.equal('1') + await contract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { - await contract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) - } - }) - it('setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { - await contract.setMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setMinPerTx(1, { from: owner }).should.be.fulfilled - expect(await contract.minPerTx()).to.be.bignumber.equal('1') + it('setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { + await contract.setDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - await contract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - if (!isRelativeDailyLimit || (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide)) { - it('setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { - await contract.setDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal('4') - await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal('4') + await contract.setDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) - await contract.setDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal(ZERO) + await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.dailyLimit()).to.be.bignumber.equal('4') + }) + } + it('setExecutionMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await contract.setExecutionMaxPerTx(2, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setExecutionMaxPerTx(2, { from: owner }).should.be.fulfilled + expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('2') + + if (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide) { + await contract.setExecutionMaxPerTx(0, { from: owner }).should.be.fulfilled + expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('0') + } - await contract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.dailyLimit()).to.be.bignumber.equal('4') + if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { + await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } }) - } - it('setExecutionMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await contract.setExecutionMaxPerTx(2, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionMaxPerTx(2, { from: owner }).should.be.fulfilled - expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('2') - - if (isRelativeDailyLimit && !isRelativeDailyLimitOnBridgeSide) { - await contract.setExecutionMaxPerTx(0, { from: owner }).should.be.fulfilled - expect(await contract.executionMaxPerTx()).to.be.bignumber.equal('0') - } + it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { + await contract.setExecutionMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setExecutionMinPerTx(1, { from: owner }).should.be.fulfilled + expect(await contract.executionMinPerTx()).to.be.bignumber.equal('1') + await contract.setExecutionMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { - await contract.setExecutionMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) - } - }) - it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { - await contract.setExecutionMinPerTx(1, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionMinPerTx(1, { from: owner }).should.be.fulfilled - expect(await contract.executionMinPerTx()).to.be.bignumber.equal('1') - - await contract.setExecutionMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - if (!isRelativeDailyLimit || (isRelativeDailyLimit && isRelativeDailyLimitOnBridgeSide)) { - it('setExecutionDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { - await contract.setExecutionDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + it('setExecutionDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { + await contract.setExecutionDailyLimit(4, { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setExecutionDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') + await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') - await contract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) + await contract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal(ZERO) - await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') - }) - } - if (isRelativeDailyLimit) { - it('setThreshold allow to set by owner and should be greater than or equal to mixPerTx', async () => { - await contract.setThreshold('1', { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setThreshold('1', { from: owner }).should.be.fulfilled + await contract.setExecutionDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await contract.executionDailyLimit()).to.be.bignumber.equal('4') + }) + } + if (isRelativeDailyLimit) { + it('setThreshold allow to set by owner and should be greater than or equal to mixPerTx', async () => { + await contract.setThreshold('1', { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setThreshold('1', { from: owner }).should.be.fulfilled - expect(await contract.threshold()).to.be.bignumber.equal('1') + expect(await contract.threshold()).to.be.bignumber.equal('1') - await contract.setThreshold('0', { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - it('setTargetLimit allow to set by owner and should be less than or equal to 1 ether', async () => { - await contract.setTargetLimit(ether('0.5'), { from: user }).should.be.rejectedWith(ERROR_MSG) - await contract.setTargetLimit(ether('0.5'), { from: owner }).should.be.fulfilled + await contract.setThreshold('0', { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('setTargetLimit allow to set by owner and should be less than or equal to 1 ether', async () => { + await contract.setTargetLimit(ether('0.5'), { from: user }).should.be.rejectedWith(ERROR_MSG) + await contract.setTargetLimit(ether('0.5'), { from: owner }).should.be.fulfilled - expect(await contract.targetLimit()).to.be.bignumber.equal(ether('0.5')) + expect(await contract.targetLimit()).to.be.bignumber.equal(ether('0.5')) - await contract.setTargetLimit(ether('1.001'), { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) + await contract.setTargetLimit(ether('1.001'), { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + } } - }) + describe('set limits', setLimits(false)) + describe('set limits (relative)', setLimits(true)) describe('getBridgeMode', () => { it('should return arbitrary message bridging mode and interface', async function() { contract = this.bridge @@ -639,25 +672,34 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( contract = this.bridge }) - it('should allow to bridge tokens using approve and transferFrom', async () => { - // Given - await initialize(erc20Token.address) + const shouldAllowToBridgeTokens = isRelativeDailyLimit => + async function() { + // Given + const LimitsContract = getLimitsContract(isRelativeDailyLimit) + limitsContract = await LimitsContract.new() + await initialize( + erc20Token.address, + getRequestLimits(isRelativeDailyLimit), + getExecutionLimits(isRelativeDailyLimit) + ) - const currentDay = await contract.getCurrentDay() - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await contract.getCurrentDay() + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const value = oneEther - await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled - expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + const value = oneEther + await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) - // When - await contract.relayTokens(user, value, { from: user }).should.be.fulfilled + // When + await contract.relayTokens(user, value, { from: user }).should.be.fulfilled - // Then - const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) - expect(events.length).to.be.equal(1) - expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - }) + // Then + const events = await getEvents(bridgeContract, { event: 'MockedEvent' }) + expect(events.length).to.be.equal(1) + expect(await contract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + } + it('should allow to bridge tokens using approve and transferFrom', shouldAllowToBridgeTokens(false)) + it('should allow to bridge tokens using approve and transferFrom (relative limit)', shouldAllowToBridgeTokens(true)) it('should allow user to specify a itself as receiver', async () => { // Given await initialize(erc20Token.address) @@ -758,6 +800,24 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( await contract.relayTokens(user, value, { from: user }).should.be.rejectedWith(ERROR_MSG) }) + const shouldFailIfValueIsNotWithinLimits = isRelativeDailyLimit => + async function() { + const LimitsContract = getLimitsContract(isRelativeDailyLimit) + limitsContract = await LimitsContract.new() + await initialize( + erc20Token.address, + getRequestLimits(isRelativeDailyLimit), + getExecutionLimits(isRelativeDailyLimit) + ) + + const value = twoEthers + await erc20Token.approve(contract.address, value, { from: user }).should.be.fulfilled + expect(await erc20Token.allowance(user, contract.address)).to.be.bignumber.equal(value) + + await contract.relayTokens(user, value, { from: user }).should.be.rejectedWith(ERROR_MSG) + } + it('should fail if value is not within limits', shouldFailIfValueIsNotWithinLimits(false)) + it('should fail if value is not within limits (relative)', shouldFailIfValueIsNotWithinLimits(true)) it('should prevent emitting the event twice when ERC677 used by relayTokens and ERC677 is owned by token manager', async function() { // Given erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) @@ -1025,177 +1085,184 @@ function shouldBehaveLikeBasicAMBErc677ToErc677( }) }) describe('#claimTokens', () => { - it('should be able to claim tokens', async function() { - limitsContract = await LimitsContract.new() - contract = this.proxyContract - - await initialize(erc677Token.address) + const shouldBeAbleToClaimTokens = isRelativeDailyLimit => + async function() { + const LimitsContract = getLimitsContract(isRelativeDailyLimit) + limitsContract = await LimitsContract.new() + contract = this.proxyContract + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled + + await initialize( + erc677Token.address, + getRequestLimits(isRelativeDailyLimit), + getExecutionLimits(isRelativeDailyLimit) + ) - const tokenSecond = await ERC677BridgeToken.new('Test Token', 'TST', 18) + const tokenSecond = await ERC677BridgeToken.new('Test Token', 'TST', 18) - await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - await tokenSecond.transfer(contract.address, halfEther) - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) + await tokenSecond.transfer(contract.address, halfEther) + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) - await contract - .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) - .should.be.rejectedWith(ERROR_MSG) - await contract.claimTokens(tokenSecond.address, accounts[3], { from: owner }).should.be.fulfilled - expect(await tokenSecond.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) + await contract + .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) + .should.be.rejectedWith(ERROR_MSG) + await contract.claimTokens(tokenSecond.address, accounts[3], { from: owner }).should.be.fulfilled + expect(await tokenSecond.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + } + it('should be able to claim tokens', shouldBeAbleToClaimTokens(false)) + it('should be able to claim tokens (relative limit)', shouldBeAbleToClaimTokens(true)) }) - if (isRelativeDailyLimit) { - // eslint-disable-next-line - function initializeWithCustomLimits(customLimits) { - return contract.initialize( - bridgeContract.address, - mediatorContract.address, - erc677Token.address, - isRelativeDailyLimitOnBridgeSide ? customLimits : limitsArray, - isRelativeDailyLimitOnBridgeSide ? executionLimitsArray : customLimits, - maxGasPerTx, - decimalShiftZero, - owner, - limitsContract.address - ).should.be.fulfilled - } - if (isRelativeDailyLimitOnBridgeSide) { - describe('#dailyLimit (relative)', () => { - beforeEach(async function() { - contract = this.bridge - bridgeContract = await AMBMock.new() - await bridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await otherSideMediatorContract.new() - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() - }) - it('should be calculated correctly - 1', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + function initializeWithCustomLimits(customLimits) { + return contract.initialize( + bridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimitOnBridgeSide ? customLimits : limitsArray, + isRelativeDailyLimitOnBridgeSide ? executionLimitsArray : customLimits, + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ).should.be.fulfilled + } + if (isRelativeDailyLimitOnBridgeSide) { + describe('#dailyLimit (relative)', () => { + beforeEach(async function() { + contract = this.bridge + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await RelativeDailyLimit.new() + }) + it('should be calculated correctly - 1', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled - await erc677Token.mint(contract.address, halfEther).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await contract.dailyLimit() - const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, halfEther).should.be.fulfilled - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) - const limit = await contract.dailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 3', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 3', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(minPerTx) + await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(minPerTx) - const limit = await contract.dailyLimit() - expect(limit).to.be.bignumber.equal(minPerTx) - }) - it('should be calculated correctly - 4', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, threshold).should.be.fulfilled - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(threshold) + await erc677Token.mint(contract.address, threshold).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(threshold) - const limit = await contract.dailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 5', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const minPerTx = ether('0.1') + const limit = await contract.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(accounts[0], amountToMint).should.be.fulfilled - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(amountToMint) + await erc677Token.mint(accounts[0], amountToMint).should.be.fulfilled + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(amountToMint) - const limit = await contract.dailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await contract.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } else { - describe('#executionDailyLimit (relative)', () => { - beforeEach(async function() { - contract = this.bridge - bridgeContract = await AMBMock.new() - await bridgeContract.setMaxGasPerTx(maxGasPerTx) - mediatorContract = await otherSideMediatorContract.new() - erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() - }) - it('should be calculated correctly - 1', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + }) + } else { + describe('#executionDailyLimit (relative)', () => { + beforeEach(async function() { + contract = this.bridge + bridgeContract = await AMBMock.new() + await bridgeContract.setMaxGasPerTx(maxGasPerTx) + mediatorContract = await otherSideMediatorContract.new() + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + limitsContract = await RelativeExecutionDailyLimit.new() + }) + it('should be calculated correctly - 1', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled - await erc677Token.mint(contract.address, halfEther).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + await erc677Token.mint(contract.address, halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(halfEther) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await contract.executionDailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) + await erc677Token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(ZERO) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(halfEther) - const limit = await contract.executionDailyLimit() - expect(limit).to.be.bignumber.equal(ZERO) - }) - it('should be calculated correctly - 3', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(minPerTx) + await erc677Token.mint(contract.address, minPerTx).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(minPerTx) - const limit = await contract.executionDailyLimit() - expect(limit).to.be.bignumber.equal(minPerTx) - }) - it('should be calculated correctly - 4', async function() { - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, threshold).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(threshold) + await erc677Token.mint(contract.address, threshold).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(threshold) - const limit = await contract.executionDailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 5', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const minPerTx = ether('0.1') + const limit = await contract.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') - await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) + await initializeWithCustomLimits([targetLimit, threshold, maxPerTx, minPerTx]) - await erc677Token.mint(contract.address, amountToMint).should.be.fulfilled - expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(amountToMint) + await erc677Token.mint(contract.address, amountToMint).should.be.fulfilled + expect(await erc677Token.balanceOf(contract.address)).to.be.bignumber.equal(amountToMint) - const limit = await contract.executionDailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await contract.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } + }) } } diff --git a/test/amb_erc677_to_erc677/foreign_bridge.test.js b/test/amb_erc677_to_erc677/foreign_bridge.test.js index 1e0bab8ff..e02a1f0f7 100644 --- a/test/amb_erc677_to_erc677/foreign_bridge.test.js +++ b/test/amb_erc677_to_erc677/foreign_bridge.test.js @@ -30,7 +30,7 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { +contract('ForeignAMBErc677ToErc677', accounts => { const owner = accounts[0] const user = accounts[1] let ambBridgeContract @@ -39,11 +39,7 @@ function test(accounts, isRelativeDailyLimit) { let foreignBridge let limitsContract - let limitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] - if (isRelativeDailyLimit) { - limitsArray = [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] - } - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsArray = [executionDailyLimit, executionMaxPerTx, executionMinPerTx] beforeEach(async function() { this.bridge = await ForeignAMBErc677ToErc677.new() @@ -51,7 +47,7 @@ function test(accounts, isRelativeDailyLimit) { await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled this.proxyContract = await ForeignAMBErc677ToErc677.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, isRelativeDailyLimit, false) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, false) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -62,7 +58,7 @@ function test(accounts, isRelativeDailyLimit) { mediatorContract = await HomeAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( @@ -137,7 +133,7 @@ function test(accounts, isRelativeDailyLimit) { await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await HomeAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( @@ -199,7 +195,7 @@ function test(accounts, isRelativeDailyLimit) { // Given const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 16) - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() foreignBridge = await ForeignAMBErc677ToErc677.new() await foreignBridge.initialize( @@ -252,49 +248,71 @@ function test(accounts, isRelativeDailyLimit) { expect(await erc677Token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers.sub(valueOnForeign)) expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(valueOnForeign) }) - it('should emit AmountLimitExceeded and not transfer tokens when out of execution limits', async () => { - // Given - const currentDay = await foreignBridge.getCurrentDay() - expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const initialEvents = await getEvents(erc677Token, { event: 'Transfer' }) - expect(initialEvents.length).to.be.equal(0) - expect(await erc677Token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) - - const outOfLimitValueData = await foreignBridge.contract.methods - .handleBridgedTokens(user, twoEthers.toString(), nonce) - .encodeABI() - - // When - await ambBridgeContract.executeMessageCall( - foreignBridge.address, - mediatorContract.address, - outOfLimitValueData, - exampleTxHash, - 1000000 - ).should.be.fulfilled - - expect(await ambBridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) - - // Then - expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) - expect(await erc677Token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) - - expect(await foreignBridge.outOfLimitAmount()).to.be.bignumber.equal(twoEthers) - const outOfLimitEvent = await getEvents(foreignBridge, { event: 'AmountLimitExceeded' }) - expect(outOfLimitEvent.length).to.be.equal(1) - expect(outOfLimitEvent[0].returnValues.recipient).to.be.equal(user) - expect(outOfLimitEvent[0].returnValues.value).to.be.equal(twoEthers.toString()) - expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) - }) + const shouldEmitAmountLimitExceededAndNotTransferTokens = isRelativeDailyLimit => + async function() { + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + limitsContract = await LimitsContract.new() + + foreignBridge = await ForeignAMBErc677ToErc677.new() + await foreignBridge.initialize( + ambBridgeContract.address, + mediatorContract.address, + erc677Token.address, + [dailyLimit, maxPerTx, minPerTx], + isRelativeDailyLimit + ? [targetLimit, threshold, executionMaxPerTx, executionMinPerTx] + : [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ).should.be.fulfilled + await erc677Token.mint(foreignBridge.address, twoEthers, { from: owner }).should.be.fulfilled + await erc677Token.transferOwnership(foreignBridge.address) + + // Given + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const initialEvents = await getEvents(erc677Token, { event: 'Transfer' }) + expect(initialEvents.length).to.be.equal(0) + expect(await erc677Token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) + + const outOfLimitValueData = await foreignBridge.contract.methods + .handleBridgedTokens(user, twoEthers.toString(), nonce) + .encodeABI() + + // When + await ambBridgeContract.executeMessageCall( + foreignBridge.address, + mediatorContract.address, + outOfLimitValueData, + exampleTxHash, + 1000000 + ).should.be.fulfilled + + expect(await ambBridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) + + // Then + expect(await foreignBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) + expect(await erc677Token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) + + expect(await foreignBridge.outOfLimitAmount()).to.be.bignumber.equal(twoEthers) + const outOfLimitEvent = await getEvents(foreignBridge, { event: 'AmountLimitExceeded' }) + expect(outOfLimitEvent.length).to.be.equal(1) + expect(outOfLimitEvent[0].returnValues.recipient).to.be.equal(user) + expect(outOfLimitEvent[0].returnValues.value).to.be.equal(twoEthers.toString()) + expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) + } + it( + 'should emit AmountLimitExceeded and not transfer tokens when out of execution limits', + shouldEmitAmountLimitExceededAndNotTransferTokens(false) + ) + it( + 'should emit AmountLimitExceeded and not transfer tokens when out of execution limits (relative limit)', + shouldEmitAmountLimitExceededAndNotTransferTokens(true) + ) }) -} - -contract.only('ForeignAMBErc677ToErc677', async accounts => { - test(accounts, false) -}) - -contract.only('ForeignAMBErc677ToErc677RelativeDailyLimit', async accounts => { - test(accounts, true) }) diff --git a/test/amb_erc677_to_erc677/home_bridge.test.js b/test/amb_erc677_to_erc677/home_bridge.test.js index c88a2fc21..11af3aabc 100644 --- a/test/amb_erc677_to_erc677/home_bridge.test.js +++ b/test/amb_erc677_to_erc677/home_bridge.test.js @@ -30,7 +30,7 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { +contract('HomeAMBErc677ToErc677', async accounts => { const owner = accounts[0] const user = accounts[1] let ambBridgeContract @@ -39,11 +39,7 @@ function test(accounts, isRelativeDailyLimit) { let homeBridge let limitsContract - let limitsArray = [dailyLimit, maxPerTx, minPerTx] - if (isRelativeDailyLimit) { - limitsArray = [targetLimit, threshold, maxPerTx, minPerTx] - } - const LimitsContract = isRelativeDailyLimit ? RelativeDailyLimit : AbsoluteDailyLimit + const limitsArray = [dailyLimit, maxPerTx, minPerTx] beforeEach(async function() { this.bridge = await HomeAMBErc677ToErc677.new() @@ -51,7 +47,7 @@ function test(accounts, isRelativeDailyLimit) { await storageProxy.upgradeTo('1', this.bridge.address).should.be.fulfilled this.proxyContract = await HomeAMBErc677ToErc677.at(storageProxy.address) }) - shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, isRelativeDailyLimit, true) + shouldBehaveLikeBasicAMBErc677ToErc677(HomeAMBErc677ToErc677, accounts, true) describe('onTokenTransfer', () => { beforeEach(async () => { const validatorContract = await BridgeValidators.new() @@ -62,7 +58,7 @@ function test(accounts, isRelativeDailyLimit) { mediatorContract = await ForeignAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) await erc677Token.mint(user, twoEthers, { from: owner }).should.be.fulfilled - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( @@ -143,7 +139,7 @@ function test(accounts, isRelativeDailyLimit) { await ambBridgeContract.setMaxGasPerTx(maxGasPerTx) mediatorContract = await ForeignAMBErc677ToErc677.new() erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( @@ -205,7 +201,7 @@ function test(accounts, isRelativeDailyLimit) { // Given const decimalShiftTwo = 2 erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) - limitsContract = await LimitsContract.new() + limitsContract = await AbsoluteDailyLimit.new() homeBridge = await HomeAMBErc677ToErc677.new() await homeBridge.initialize( @@ -261,50 +257,68 @@ function test(accounts, isRelativeDailyLimit) { expect(await erc677Token.totalSupply()).to.be.bignumber.equal(valueOnHome) expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(valueOnHome) }) - it('should emit AmountLimitExceeded and not mint tokens when out of execution limits', async () => { - // Given - const currentDay = await homeBridge.getCurrentDay() - expect(await homeBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const initialEvents = await getEvents(erc677Token, { event: 'Mint' }) - expect(initialEvents.length).to.be.equal(0) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(ZERO) - - const outOfLimitValueData = await homeBridge.contract.methods - .handleBridgedTokens(user, twoEthers.toString(), nonce) - .encodeABI() - - // when - await ambBridgeContract.executeMessageCall( - homeBridge.address, - mediatorContract.address, - outOfLimitValueData, - exampleTxHash, - 1000000 - ).should.be.fulfilled - - expect(await ambBridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) - - // Then - expect(await homeBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) - const events = await getEvents(erc677Token, { event: 'Mint' }) - expect(events.length).to.be.equal(0) - expect(await erc677Token.totalSupply()).to.be.bignumber.equal(ZERO) - expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) - - expect(await homeBridge.outOfLimitAmount()).to.be.bignumber.equal(twoEthers) - const outOfLimitEvent = await getEvents(homeBridge, { event: 'AmountLimitExceeded' }) - expect(outOfLimitEvent.length).to.be.equal(1) - expect(outOfLimitEvent[0].returnValues.recipient).to.be.equal(user) - expect(outOfLimitEvent[0].returnValues.value).to.be.equal(twoEthers.toString()) - expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) - }) + const shouldEmitAmountLimitExceededAndNotMintTokens = isRelativeDailyLimit => + async function() { + erc677Token = await ERC677BridgeToken.new('test', 'TST', 18) + const LimitsContract = isRelativeDailyLimit ? RelativeDailyLimit : AbsoluteDailyLimit + limitsContract = await LimitsContract.new() + + homeBridge = await HomeAMBErc677ToErc677.new() + await homeBridge.initialize( + ambBridgeContract.address, + mediatorContract.address, + erc677Token.address, + isRelativeDailyLimit ? [targetLimit, threshold, maxPerTx, minPerTx] : [dailyLimit, maxPerTx, minPerTx], + [executionDailyLimit, executionMaxPerTx, executionMinPerTx], + maxGasPerTx, + decimalShiftZero, + owner, + limitsContract.address + ).should.be.fulfilled + await erc677Token.transferOwnership(homeBridge.address) + // Given + const currentDay = await homeBridge.getCurrentDay() + expect(await homeBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const initialEvents = await getEvents(erc677Token, { event: 'Mint' }) + expect(initialEvents.length).to.be.equal(0) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(ZERO) + + const outOfLimitValueData = await homeBridge.contract.methods + .handleBridgedTokens(user, twoEthers.toString(), nonce) + .encodeABI() + + // when + await ambBridgeContract.executeMessageCall( + homeBridge.address, + mediatorContract.address, + outOfLimitValueData, + exampleTxHash, + 1000000 + ).should.be.fulfilled + + expect(await ambBridgeContract.messageCallStatus(exampleTxHash)).to.be.equal(true) + + // Then + expect(await homeBridge.totalExecutedPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const events = await getEvents(erc677Token, { event: 'Mint' }) + expect(events.length).to.be.equal(0) + expect(await erc677Token.totalSupply()).to.be.bignumber.equal(ZERO) + expect(await erc677Token.balanceOf(user)).to.be.bignumber.equal(ZERO) + + expect(await homeBridge.outOfLimitAmount()).to.be.bignumber.equal(twoEthers) + const outOfLimitEvent = await getEvents(homeBridge, { event: 'AmountLimitExceeded' }) + expect(outOfLimitEvent.length).to.be.equal(1) + expect(outOfLimitEvent[0].returnValues.recipient).to.be.equal(user) + expect(outOfLimitEvent[0].returnValues.value).to.be.equal(twoEthers.toString()) + expect(outOfLimitEvent[0].returnValues.transactionHash).to.be.equal(exampleTxHash) + } + it( + 'should emit AmountLimitExceeded and not mint tokens when out of execution limits', + shouldEmitAmountLimitExceededAndNotMintTokens(false) + ) + it( + 'should emit AmountLimitExceeded and not mint tokens when out of execution limits (relative limit)', + shouldEmitAmountLimitExceededAndNotMintTokens(true) + ) }) -} - -contract.only('HomeAMBErc677ToErc677', async accounts => { - test(accounts, false) -}) - -contract.only('HomeAMBErc677ToErc677RelativeDailyLimit', async accounts => { - test(accounts, true) }) From 1ece9a183c7c0f77a379c87ea9de42982f744cd0 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 13 Dec 2019 13:59:56 +0300 Subject: [PATCH 60/80] fix conttracts --- contracts/upgradeable_contracts/AbsoluteDailyLimit.sol | 6 +++--- contracts/upgradeable_contracts/BasicHomeBridge.sol | 2 +- contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol | 2 +- contracts/upgradeable_contracts/BasicTokenBridge.sol | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index 44208feed..18026af72 100644 --- a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -81,12 +81,12 @@ contract AbsoluteDailyLimit is EternalStorage { return uintStorage[EXECUTION_MIN_PER_TX]; } - function withinLimit(uint256 _amount, uint256 _tokenBalance) public view returns (bool) { + function withinLimit(uint256 _amount, uint256 _tokenBalance) external view returns (bool) { uint256 nextLimit = totalSpentPerDay(getCurrentDay()).add(_amount); return dailyLimit(_tokenBalance) >= nextLimit && _amount <= maxPerTx() && _amount >= minPerTx(); } - function withinExecutionLimit(uint256 _amount, uint256 _tokenBalance) public view returns (bool) { + function withinExecutionLimit(uint256 _amount, uint256 _tokenBalance) external view returns (bool) { uint256 nextLimit = totalExecutedPerDay(getCurrentDay()).add(_amount); return executionDailyLimit(_tokenBalance) >= nextLimit && _amount <= executionMaxPerTx(); } @@ -138,5 +138,5 @@ contract AbsoluteDailyLimit is EternalStorage { uintStorage[MIN_PER_TX] = _minPerTx; } - function updateTodayLimit(uint256) public {} + function updateTodayLimit(uint256) external {} } diff --git a/contracts/upgradeable_contracts/BasicHomeBridge.sol b/contracts/upgradeable_contracts/BasicHomeBridge.sol index f1cba55e9..9687930d7 100644 --- a/contracts/upgradeable_contracts/BasicHomeBridge.sol +++ b/contracts/upgradeable_contracts/BasicHomeBridge.sol @@ -22,7 +22,7 @@ contract BasicHomeBridge is EternalStorage, Validatable, BasicBridge, BasicToken uint256 NumberOfCollectedSignatures ); - function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) public onlyValidator { + function executeAffirmation(address recipient, uint256 value, bytes32 transactionHash) external onlyValidator { _updateTodayLimit(); if (withinExecutionLimit(value)) { bytes32 hashMsg = keccak256(abi.encodePacked(recipient, value, transactionHash)); diff --git a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol index 2be812f01..d07135770 100644 --- a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol @@ -54,7 +54,7 @@ contract BasicRelativeDailyLimit is AbsoluteDailyLimit { emit ThresholdChanged(_threshold); } - function updateTodayLimit(uint256 _balance) public { + function updateTodayLimit(uint256 _balance) external { if (_todayLimit() == 0) { uint256 limit = _calculateLimit(_balance); _setTodayLimit(limit); diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index f71705c9e..b26cd34c1 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -154,7 +154,7 @@ contract BasicTokenBridge is EternalStorage, Ownable { require(limitsContract().delegatecall(abi.encodeWithSelector(_method, _value))); } - function _getTokenBalance() internal view returns (uint256) {} + function _getTokenBalance() internal view returns (uint256); function _getUint(bytes4 _method) internal view returns (uint256) { return _getUint(abi.encodeWithSelector(_method)); From 5c3041ce9673f505efde3433131bd3499774eff2 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Sun, 15 Dec 2019 20:01:25 +0300 Subject: [PATCH 61/80] add internal setLimits method --- contracts/upgradeable_contracts/BasicTokenBridge.sol | 8 ++++++-- .../amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol | 2 +- .../erc20_to_erc20/BasicForeignBridgeErcToErc.sol | 2 +- .../erc20_to_erc20/HomeBridgeErcToErc.sol | 2 +- .../erc20_to_native/ForeignBridgeErcToNative.sol | 2 +- .../erc20_to_native/HomeBridgeErcToNative.sol | 2 +- .../native_to_erc20/ForeignBridgeNativeToErc.sol | 2 +- .../native_to_erc20/HomeBridgeNativeToErc.sol | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index b26cd34c1..1e1daa5f1 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -42,8 +42,8 @@ contract BasicTokenBridge is EternalStorage, Ownable { addressStorage[LIMITS_CONTRACT] = _limitsContract; } - function setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) public onlyOwner { - require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); + function setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) external onlyOwner { + _setLimits(_requestLimitsArray, _executionLimitsArray); } function setMaxPerTx(uint256 _maxPerTx) external onlyOwner { @@ -138,6 +138,10 @@ contract BasicTokenBridge is EternalStorage, Ownable { return _getUint(GET_CURRENT_DAY); } + function _setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) internal { + require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); + } + function _increaseTotalSpentPerDay(uint256 _amount) internal { _execute(INCREASE_TOTAL_SPENT_PER_DAY, _amount); } diff --git a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol index e6c172cea..d105ec898 100644 --- a/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol +++ b/contracts/upgradeable_contracts/amb_erc677_to_erc677/BasicAMBErc677ToErc677.sol @@ -55,7 +55,7 @@ contract BasicAMBErc677ToErc677 is setOwner(_owner); setNonce(keccak256(abi.encodePacked(address(this)))); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); setInitialize(); return isInitialized(); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 12031c51f..3f849aede 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -33,7 +33,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol index 32a8b77ca..df5c7df70 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErc.sol @@ -42,7 +42,7 @@ contract HomeBridgeErcToErc is setOwner(_owner); setErc677token(_erc677token); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 8510b2d02..a7a74b62a 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -40,7 +40,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_gasPrice); diff --git a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol index 50fed2db1..bbcc49e55 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/HomeBridgeErcToNative.sol @@ -76,7 +76,7 @@ contract HomeBridgeErcToNative is uintStorage[DECIMAL_SHIFT] = _decimalShift; setOwner(_owner); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_homeGasPrice); diff --git a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol index 3778769f5..9c2ccbda3 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol @@ -41,7 +41,7 @@ contract ForeignBridgeNativeToErc is setOwner(_owner); _setBridgeContractOnOtherSide(_bridgeOnOtherSide); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); emit RequiredBlockConfirmationChanged(_requiredBlockConfirmations); emit GasPriceChanged(_foreignGasPrice); diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 4c0a9091b..72767853f 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -43,7 +43,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom ) public returns (bool) { require(AddressUtils.isContract(_limitsContract)); addressStorage[LIMITS_CONTRACT] = _limitsContract; - setLimits(_requestLimitsArray, _executionLimitsArray); + _setLimits(_requestLimitsArray, _executionLimitsArray); _initialize(_validatorContract, _homeGasPrice, _requiredBlockConfirmations, _owner, _decimalShift); setInitialize(); return isInitialized(); From bdc4aa0f8e93bde88bd773899ec437f5daf22ea2 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Sun, 15 Dec 2019 20:02:01 +0300 Subject: [PATCH 62/80] ffix foreign erc-to-erc tests --- test/erc_to_erc/foreign_bridge.test.js | 1185 +++++++++++++----------- 1 file changed, 651 insertions(+), 534 deletions(-) diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index 29031907c..6f4ee309a 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -1,15 +1,14 @@ const ForeignBridge = artifacts.require('ForeignBridgeErcToErc.sol') -const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeErcToErcRelativeDailyLimit.sol') const ForeignBridgeErc677ToErc677 = artifacts.require('ForeignBridgeErc677ToErc677.sol') -const ForeignBridgeErc677ToErc677RelativeDailyLimit = artifacts.require( - 'ForeignBridgeErc677ToErc677RelativeDailyLimit.sol' -) const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, @@ -36,16 +35,10 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge - const ForeignBridgeErc677ToErc677Contract = isRelativeDailyLimit - ? ForeignBridgeErc677ToErc677RelativeDailyLimit - : ForeignBridgeErc677ToErc677 - +contract('ForeignBridge_ERC20_to_ERC20', async accounts => { + const isRelativeDailyLimit = false const requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] - const executionLimitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const executionLimitsArray = [homeDailyLimit, homeMaxPerTx, homeMinPerTx] let validatorContract let authorities @@ -58,254 +51,295 @@ function test(accounts, isRelativeDailyLimit) { await validatorContract.initialize(1, authorities, owner) }) describe('#initialize', async () => { - it('should initialize', async () => { - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridge = await ForeignBridgeContract.new() - - expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) - expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.isInitialized()).to.be.equal(false) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - - await foreignBridge - .initialize( - ZERO_ADDRESS, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - ZERO_ADDRESS, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - owner, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( + const shouldInitialize = isRelativeDailyLimit => + async function() { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const foreignBridge = await ForeignBridge.new() + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await LimitsContract.new() + const executionLimitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + + expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) + expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.isInitialized()).to.be.equal(false) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.limitsContract()).to.be.equal(ZERO_ADDRESS) + + await foreignBridge + .initialize( + ZERO_ADDRESS, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + ZERO_ADDRESS, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + ZERO_ADDRESS + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + owner, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + 0, // requireBlockConfirmations + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + 0, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + owner, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + + const { logs, tx } = await foreignBridge.initialize( validatorContract.address, token.address, - 0, // requireBlockConfirmations + requireBlockConfirmations, gasPrice, requestLimitsArray, executionLimitsArray, owner, - decimalShiftZero + '9', + limitsContract.address + ).should.be.fulfilled + + expect(await foreignBridge.erc20token()).to.be.equal(token.address) + expect(await foreignBridge.limitsContract()).to.be.equal(limitsContract.address) + expect(await foreignBridge.isInitialized()).to.be.equal(true) + expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( + requireBlockConfirmations.toString() ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(dailyLimit) + expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(maxPerTx) + expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') + expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) + const bridgeMode = '0xba4690f5' // 4 bytes of keccak256('erc-to-erc-core') + expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: homeDailyLimit.toString() + }) + } + } + it('should initialize', shouldInitialize(false)) + it('should initialize (relative limit)', shouldInitialize(true)) + }) + const executeSignatures = isRelativeDailyLimit => + function() { + const value = ether('0.25') + let foreignBridge + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + beforeEach(async () => { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const limitsContract = await LimitsContract.new() + await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, - 0, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - owner, - token.address, - requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) - .should.be.rejectedWith(ERROR_MSG) - - const { logs } = await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - '9' - ) - - expect(await foreignBridge.erc20token()).to.be.equal(token.address) - expect(await foreignBridge.isInitialized()).to.be.equal(true) - expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( - requireBlockConfirmations.toString() - ) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(dailyLimit) - expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(maxPerTx) - expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') - expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - const bridgeMode = '0xba4690f5' // 4 bytes of keccak256('erc-to-erc-core') - expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) - - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) + await token.mint(foreignBridge.address, oneEther) + }) + it('should allow to executeSignatures', async () => { + const recipientAccount = accounts[3] + const balanceBefore = await token.balanceOf(recipientAccount) + const balanceBridgeBefore = await token.balanceOf(foreignBridge.address) + + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + + const balanceAfter = await token.balanceOf(recipientAccount) + const balanceBridgeAfter = await token.balanceOf(foreignBridge.address) + balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) + balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(value)) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + }) + it('should allow second withdrawal with different transactionHash but same recipient and value', async () => { + const recipientAccount = accounts[3] + const balanceBefore = await token.balanceOf(recipientAccount) + // tx 1 + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + // tx 2 + await token.mint(foreignBridge.address, value) + const transactionHash2 = '0x77a496628a776a03d58d7e6059a5937f04bebd8ba4ff89f76dd4bb8ba7e291ee' + const message2 = createMessage(recipientAccount, value, transactionHash2, foreignBridge.address) + const signature2 = await sign(authorities[0], message2) + const vrs2 = signatureToVRS(signature2) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash2)) + const { logs } = await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be + .fulfilled + + logs[0].event.should.be.equal('RelayedMessage') + logs[0].args.recipient.should.be.equal(recipientAccount) + logs[0].args.value.should.be.bignumber.equal(value) + const balanceAfter = await token.balanceOf(recipientAccount) + balanceAfter.should.be.bignumber.equal(balanceBefore.add(value.mul(toBN(2)))) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash2)) }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) - } - }) - }) - describe('#executeSignatures', async () => { - const value = ether('0.25') - let foreignBridge - beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - await token.mint(foreignBridge.address, oneEther) - }) - it('should allow to executeSignatures', async () => { - const recipientAccount = accounts[3] - const balanceBefore = await token.balanceOf(recipientAccount) - const balanceBridgeBefore = await token.balanceOf(foreignBridge.address) - - const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' - const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - const event = logs.find(item => item.event === 'RelayedMessage') - event.args.recipient.should.be.equal(recipientAccount) - event.args.value.should.be.bignumber.equal(value) - - const balanceAfter = await token.balanceOf(recipientAccount) - const balanceBridgeAfter = await token.balanceOf(foreignBridge.address) - balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - balanceBridgeAfter.should.be.bignumber.equal(balanceBridgeBefore.sub(value)) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - }) - it('should allow second withdrawal with different transactionHash but same recipient and value', async () => { - const recipientAccount = accounts[3] - const balanceBefore = await token.balanceOf(recipientAccount) - // tx 1 - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - // tx 2 - await token.mint(foreignBridge.address, value) - const transactionHash2 = '0x77a496628a776a03d58d7e6059a5937f04bebd8ba4ff89f76dd4bb8ba7e291ee' - const message2 = createMessage(recipientAccount, value, transactionHash2, foreignBridge.address) - const signature2 = await sign(authorities[0], message2) - const vrs2 = signatureToVRS(signature2) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash2)) - const { logs } = await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled - - logs[0].event.should.be.equal('RelayedMessage') - logs[0].args.recipient.should.be.equal(recipientAccount) - logs[0].args.value.should.be.bignumber.equal(value) - const balanceAfter = await token.balanceOf(recipientAccount) - balanceAfter.should.be.bignumber.equal(balanceBefore.add(value.mul(toBN(2)))) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash2)) - }) - it('should not allow second withdraw (replay attack) with same transactionHash but different recipient', async () => { - const recipientAccount = accounts[3] - // tx 1 - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - // tx 2 - await token.mint(foreignBridge.address, value) - const message2 = createMessage(accounts[4], value, transactionHash, foreignBridge.address) - const signature2 = await sign(authorities[0], message2) - const vrs2 = signatureToVRS(signature2) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.rejectedWith(ERROR_MSG) - }) + it('should not allow second withdraw (replay attack) with same transactionHash but different recipient', async () => { + const recipientAccount = accounts[3] + // tx 1 + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + // tx 2 + await token.mint(foreignBridge.address, value) + const message2 = createMessage(accounts[4], value, transactionHash, foreignBridge.address) + const signature2 = await sign(authorities[0], message2) + const vrs2 = signatureToVRS(signature2) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.rejectedWith(ERROR_MSG) + }) - it('should not allow withdraw over home max tx limit', async () => { - const recipientAccount = accounts[3] - const invalidValue = ether('0.75') - await token.mint(foreignBridge.address, ether('5')) + it('should not allow withdraw over home max tx limit', async () => { + const recipientAccount = accounts[3] + const invalidValue = ether('0.75') + await token.mint(foreignBridge.address, ether('5')) - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) - }) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) + }) - it('should not allow withdraw over daily home limit', async () => { - const recipientAccount = accounts[3] - await token.mint(foreignBridge.address, halfEther) + it('should not allow withdraw over daily home limit', async () => { + const recipientAccount = accounts[3] + await token.mint(foreignBridge.address, halfEther) - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' - const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) - const signature2 = await sign(authorities[0], message2) - const vrs2 = signatureToVRS(signature2) + const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' + const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) + const signature2 = await sign(authorities[0], message2) + const vrs2 = signatureToVRS(signature2) - await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled + await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled - const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' - const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) - const signature3 = await sign(authorities[0], message3) - const vrs3 = signatureToVRS(signature3) + const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' + const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) + const signature3 = await sign(authorities[0], message3) + const vrs3 = signatureToVRS(signature3) - await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) - }) - }) + await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) + }) + } + describe('#executeSignatures', executeSignatures(false)) + describe('#executeSignatures (relative limit)', executeSignatures(true)) describe('#withdraw with 2 minimum signatures', async () => { let multisigValidatorContract let twoAuthorities @@ -320,7 +354,8 @@ function test(accounts, isRelativeDailyLimit) { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() + const limitsContract = await AbsoluteDailyLimit.new() + foreignBridgeWithMultiSignatures = await ForeignBridge.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -330,7 +365,7 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - { from: ownerOfValidatorContract } + limitsContract.address ) await token.mint(foreignBridgeWithMultiSignatures.address, oneEther) }) @@ -380,7 +415,8 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const limitsContract = await AbsoluteDailyLimit.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -390,7 +426,8 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) await erc20Token.mint(foreignBridgeWithThreeSigs.address, oneEther) @@ -439,10 +476,11 @@ function test(accounts, isRelativeDailyLimit) { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) + const limitsContract = await AbsoluteDailyLimit.new() + foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, @@ -451,7 +489,8 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) // Deploy V2 @@ -471,7 +510,8 @@ function test(accounts, isRelativeDailyLimit) { const validatorsAddress = validatorContract.address const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.new() + const limitsContract = await AbsoluteDailyLimit.new() + const foreignBridge = await ForeignBridge.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, @@ -479,259 +519,298 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, gasPrice, ['3', '2', '1'], - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridgeContract.at(storageProxy.address) + const finalContract = await ForeignBridge.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) }) }) describe('#claimTokens', async () => { - it('can send erc20', async () => { - const owner = accounts[0] - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridgeImpl = await ForeignBridgeContract.new() - const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) + const claim = isRelativeDailyLimit => + async function() { + const owner = accounts[0] + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await LimitsContract.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const foreignBridgeImpl = await ForeignBridge.new() + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled + const foreignBridge = await ForeignBridge.at(storageProxy.address) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) - const tokenSecond = await ERC677BridgeToken.new('Roman Token', 'RST', 18) + const tokenSecond = await ERC677BridgeToken.new('Roman Token', 'RST', 18) - await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - await tokenSecond.transfer(foreignBridge.address, halfEther) - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + await tokenSecond.transfer(foreignBridge.address, halfEther) + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - await foreignBridge - .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) + await foreignBridge + .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + } + it('can send erc20', claim(false)) + it('can send erc20 (relative limit)', claim(true)) }) - describe('#ForeignBridgeErc677ToErc677_onTokenTransfer', async () => { - it('should emit correct events on initialize', async () => { - const owner = accounts[3] - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - const { logs } = await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) + const onTokenTransferTests = isRelativeDailyLimit => + function() { + const executionLimitsArray = isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + + it('should emit correct events on initialize', async () => { + const owner = accounts[3] + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + const limitsContract = await LimitsContract.new() + const { logs, tx } = await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: homeDailyLimit.toString() + }) + } }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) - } - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) - }) - it('can only be called from token contract', async () => { - const owner = accounts[3] - const user = accounts[4] - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - - await token.mint(user, halfEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) - await foreignBridge.onTokenTransfer(user, halfEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) + it('can only be called from token contract', async () => { + const owner = accounts[3] + const user = accounts[4] + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const limitsContract = await LimitsContract.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) - expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) + await foreignBridge.onTokenTransfer(user, halfEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - }) - it('should not allow to transfer more than maxPerTx limit', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueMoreThanLimit = halfEther.add(toBN(1)) - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + }) + it('should not allow to transfer more than maxPerTx limit', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueMoreThanLimit = halfEther.add(toBN(1)) + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const limitsContract = await LimitsContract.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) - await token - .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + await token + .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + valueMoreThanLimit.should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - expect(await token.totalSupply()).to.be.bignumber.equal(valueMoreThanLimit) - expect(await token.balanceOf(user)).to.be.bignumber.equal('1') - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - }) - it('should only let to transfer within daily limit', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueMoreThanLimit = halfEther.add(toBN(1)) - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - await token.mint(user, oneEther.add(toBN(1)), { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) + expect(await token.totalSupply()).to.be.bignumber.equal(valueMoreThanLimit) + expect(await token.balanceOf(user)).to.be.bignumber.equal('1') + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + }) + it('should only let to transfer within daily limit', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueMoreThanLimit = halfEther.add(toBN(1)) + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const limitsContract = await LimitsContract.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) - await token - .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - oneEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) - oneEther.add(toBN(1)).should.be.bignumber.equal(await token.balanceOf(user)) + await token.mint(user, oneEther.add(toBN(1)), { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - oneEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + await token + .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + oneEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) + oneEther.add(toBN(1)).should.be.bignumber.equal(await token.balanceOf(user)) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + oneEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) - expect(await token.balanceOf(user)).to.be.bignumber.equal('1') - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - await token.transferAndCall(foreignBridge.address, '1', '0x', { from: user }).should.be.rejectedWith(ERROR_MSG) - }) - it('should not let to transfer less than minPerTx', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) + expect(await token.balanceOf(user)).to.be.bignumber.equal('1') + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) - await token.mint(user, oneEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) + await token.transferAndCall(foreignBridge.address, '1', '0x', { from: user }).should.be.rejectedWith(ERROR_MSG) + }) + it('should not let to transfer less than minPerTx', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const limitsContract = await LimitsContract.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) - await token - .transferAndCall(foreignBridge.address, valueLessThanMinPerTx, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - expect(await token.balanceOf(user)).to.be.bignumber.equal(oneEther) + await token.mint(user, oneEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) - await token.transferAndCall(foreignBridge.address, minPerTx, '0x', { from: user }).should.be.fulfilled + await token + .transferAndCall(foreignBridge.address, valueLessThanMinPerTx, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + expect(await token.balanceOf(user)).to.be.bignumber.equal(oneEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - expect(await token.balanceOf(user)).to.be.bignumber.equal(oneEther.sub(minPerTx)) - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(minPerTx) + await token.transferAndCall(foreignBridge.address, minPerTx, '0x', { from: user }).should.be.fulfilled - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(minPerTx) - }) - it('should be able to specify a different receiver', async () => { - const owner = accounts[3] - const user = accounts[4] - const user2 = accounts[5] - token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero - ) - await token.mint(user, halfEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) - await token - .transferAndCall(foreignBridge.address, halfEther, ZERO_ADDRESS, { from: user }) - .should.be.rejectedWith(ERROR_MSG) - await token - .transferAndCall(foreignBridge.address, halfEther, '0x0000', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - await token.transferAndCall(foreignBridge.address, halfEther, user2, { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + expect(await token.balanceOf(user)).to.be.bignumber.equal(oneEther.sub(minPerTx)) + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(minPerTx) - expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user2) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - }) - }) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(minPerTx) + }) + it('should be able to specify a different receiver', async () => { + const owner = accounts[3] + const user = accounts[4] + const user2 = accounts[5] + token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) + const limitsContract = await LimitsContract.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address, + { from: owner } + ) + await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) + await token + .transferAndCall(foreignBridge.address, halfEther, ZERO_ADDRESS, { from: user }) + .should.be.rejectedWith(ERROR_MSG) + await token + .transferAndCall(foreignBridge.address, halfEther, '0x0000', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + await token.transferAndCall(foreignBridge.address, halfEther, user2, { from: user }).should.be.fulfilled + + expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user2) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + }) + } + describe('#ForeignBridgeErc677ToErc677_onTokenTransfer', onTokenTransferTests(false)) + describe('#ForeignBridgeErc677ToErc677_onTokenTransfer (relative limit)', onTokenTransferTests(true)) describe('#decimalShift', async () => { const decimalShiftTwo = 2 it('Home to Foreign: withdraw with 1 signature with a decimalShift of 2', async () => { const valueOnForeign = toBN('1000') // Value is decimals shifted from foreign to home: Native on home = 16+2 shift = 18 decimals const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) - const foreignBridge = await ForeignBridgeContract.new() + const foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) + const limitsContract = await AbsoluteDailyLimit.new() await foreignBridge.initialize( validatorContract.address, token.address, @@ -740,7 +819,8 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftTwo + decimalShiftTwo, + limitsContract.address ) await token.mint(foreignBridge.address, valueOnHome.mul(toBN('2'))) @@ -774,8 +854,9 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) + const limitsContract = await AbsoluteDailyLimit.new() - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -785,7 +866,8 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftTwo + decimalShiftTwo, + limitsContract.address ) await erc20Token.mint(foreignBridgeWithThreeSigs.address, valueOnHome.mul(toBN('2'))) @@ -827,7 +909,8 @@ function test(accounts, isRelativeDailyLimit) { const owner = accounts[3] const user = accounts[4] token = await ERC677BridgeToken.new('TEST', 'TST', 16, { from: owner }) - const foreignBridge = await ForeignBridgeErc677ToErc677Contract.new() + const limitsContract = await AbsoluteDailyLimit.new() + const foreignBridge = await ForeignBridgeErc677ToErc677.new({ from: owner }) await foreignBridge.initialize( validatorContract.address, token.address, @@ -836,7 +919,9 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftTwo + decimalShiftTwo, + limitsContract.address, + { from: owner } ) await token.mint(user, value, { from: owner }).should.be.fulfilled @@ -859,8 +944,9 @@ function test(accounts, isRelativeDailyLimit) { const recipient = accounts[8] let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const limitsContract = await AbsoluteDailyLimit.new() await foreignBridge.initialize( validatorContract.address, token.address, @@ -869,41 +955,61 @@ function test(accounts, isRelativeDailyLimit) { requestLimitsArray, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) await token.mint(user, ether('2')) }) - it('should allow to bridge tokens using approve tranferFrom', async () => { - // Given - const currentDay = await foreignBridge.getCurrentDay() - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - await token.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled - - // When - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, ZERO_ADDRESS, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, foreignBridge.address, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, 0, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - const { logs } = await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { - from: user - }).should.be.fulfilled - - // Then - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - expectEventInLogs(logs, 'UserRequestForAffirmation', { - recipient, - value - }) - }) + const shouldAllowToBridgeTokens = isRelativeDailyLimit => + async function() { + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await LimitsContract.new() + foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + // Given + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + await token.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + // When + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, ZERO_ADDRESS, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, foreignBridge.address, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, 0, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + const { logs } = await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { + from: user + }).should.be.fulfilled + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient, + value + }) + } + it('should allow to bridge tokens using approve tranferFrom', shouldAllowToBridgeTokens(false)) + it('should allow to bridge tokens using approve tranferFrom (relative limit)', shouldAllowToBridgeTokens(true)) it('should allow to call relayTokens without specifying the sender', async () => { // Given await foreignBridge.methods['relayTokens(address,uint256)'](recipient, value, { @@ -931,38 +1037,57 @@ function test(accounts, isRelativeDailyLimit) { value }) }) - it('should not be able to transfer more than limit', async () => { - // Given - const userSupply = ether('2') - const bigValue = oneEther - const smallValue = ether('0.001') - const currentDay = await foreignBridge.getCurrentDay() - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - - await token.approve(foreignBridge.address, userSupply, { from: user }).should.be.fulfilled - - // When - // value < minPerTx - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, smallValue, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - // value > maxPerTx - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, bigValue, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) - .should.be.fulfilled - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) - .should.be.fulfilled - // totalSpentPerDay > dailyLimit - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - // Then - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) - }) + const shouldNotBeAbleToTransferMoreThanLimit = isRelativeDailyLimit => + async function() { + const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await LimitsContract.new() + foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + // Given + const userSupply = ether('2') + const bigValue = oneEther + const smallValue = ether('0.001') + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await token.approve(foreignBridge.address, userSupply, { from: user }).should.be.fulfilled + + // When + // value < minPerTx + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, smallValue, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + // value > maxPerTx + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, bigValue, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) + .should.be.fulfilled + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) + .should.be.fulfilled + // totalSpentPerDay > dailyLimit + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + } + it('should not be able to transfer more than limit', shouldNotBeAbleToTransferMoreThanLimit(false)) + it('should not be able to transfer more than limit (relative limit)', shouldNotBeAbleToTransferMoreThanLimit(true)) it('should allow only sender to specify a different receiver', async () => { // Given const currentDay = await foreignBridge.getCurrentDay() @@ -1030,7 +1155,7 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() }) it('should be calculated correctly - 1', async () => { await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) @@ -1089,12 +1214,4 @@ function test(accounts, isRelativeDailyLimit) { }) }) } -} - -contract('ForeignBridge_ERC20_to_ERC20', async accounts => { - test(accounts, false) -}) - -contract('ForeignBridge_ERC20_to_ERC20_RelativeDailyLimit', async accounts => { - test(accounts, true) }) From abcd4a75c1516f6de878f5626a95bb2419c367a3 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Sun, 15 Dec 2019 20:06:53 +0300 Subject: [PATCH 63/80] fix tests --- test/erc_to_erc/foreign_bridge.test.js | 132 ++++++++++++------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index 6f4ee309a..0b65ca24a 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -36,7 +36,6 @@ const targetLimit = ether('0.05') const threshold = ether('10000') contract('ForeignBridge_ERC20_to_ERC20', async accounts => { - const isRelativeDailyLimit = false const requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] const executionLimitsArray = [homeDailyLimit, homeMaxPerTx, homeMinPerTx] @@ -1135,83 +1134,84 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { }) }) }) - if (isRelativeDailyLimit) { - describe('#executionDailyLimit (relative)', () => { - let token - let foreignBridge + describe('#executionDailyLimit (relative)', () => { + let token + let foreignBridge + let limitsContract - function initialize(customExecutionLimitsArray) { - return foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - customExecutionLimitsArray, - owner, - decimalShiftZero - ).should.be.fulfilled - } + function initialize(customExecutionLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + customExecutionLimitsArray, + owner, + decimalShiftZero, + limitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - foreignBridge = await ForeignBridge.new() - }) - it('should be calculated correctly - 1', async () => { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + foreignBridge = await ForeignBridge.new() + limitsContract = await RelativeExecutionDailyLimit.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - await token.mint(foreignBridge.address, halfEther).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await foreignBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) - expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(ZERO) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(homeMinPerTx) - }) - it('should be calculated correctly - 4', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, threshold).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 5', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const homeMinPerTx = ether('0.1') + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) - const limit = await foreignBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } + }) }) From 07d1850da6e2713fea8a3074dfeee91fd639915b Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 16 Dec 2019 13:10:00 +0300 Subject: [PATCH 64/80] return the old order of parameters --- .../erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 1654924c2..2319cd177 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -18,8 +18,8 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { address _owner, address _feeManager, uint256[] _homeFeeForeignFeeArray, // [ 0 = _homeFee, 1 = _foreignFee ] - uint256 _decimalShift, address _blockReward, + uint256 _decimalShift, address _limitsContract ) public returns (bool) { _setBlockRewardContract(_feeManager, _blockReward); From eefae4d6169646ce48eb22fda8da9a3acb45ac1e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 16 Dec 2019 13:10:35 +0300 Subject: [PATCH 65/80] fix home erc-to-erc tests --- test/erc_to_erc/home_bridge.test.js | 606 +++++++++++++++------------- 1 file changed, 330 insertions(+), 276 deletions(-) diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index c17ba0bfd..c055b6452 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -1,7 +1,5 @@ const HomeBridge = artifacts.require('HomeBridgeErcToErc.sol') -const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToErcRelativeDailyLimit.sol') const POSDAOHomeBridge = artifacts.require('HomeBridgeErcToErcPOSDAO.sol') -const POSDAOHomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') @@ -10,8 +8,11 @@ const FeeManagerErcToErcPOSDAO = artifacts.require('FeeManagerErcToErcPOSDAO.sol const RewardableValidators = artifacts.require('RewardableValidators.sol') const BlockReward = artifacts.require('BlockReward') const OldBlockReward = artifacts.require('OldBlockReward') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, sign, getEvents, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') @@ -33,143 +34,157 @@ const markedAsProcessed = toBN(2) const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge - const POSDAOHomeBridgeContract = isRelativeDailyLimit ? POSDAOHomeBridgeRelativeDailyLimit : POSDAOHomeBridge - - const limitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, halfEther, minPerTx] - : [oneEther, halfEther, minPerTx] +contract('HomeBridge_ERC20_to_ERC20', async accounts => { + const limitsArray = [oneEther, halfEther, minPerTx] let homeContract let validatorContract let authorities let owner let token + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() authorities = [accounts[1]] owner = accounts[0] await validatorContract.initialize(1, authorities, owner) + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeDailyLimit.new() }) describe('#initialize', async () => { - const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + const limitsArray = ['3', '2', '1'] beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) }) - it('sets variables', async () => { - expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) - expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) - expect(await homeContract.isInitialized()).to.be.equal(false) - - if (!isRelativeDailyLimit) { - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) - } - - const { logs } = await homeContract.initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - '9' - ).should.be.fulfilled - - expect(await homeContract.isInitialized()).to.be.equal(true) - expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') - expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') - expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') - const bridgeMode = '0xba4690f5' // 4 bytes of keccak256('erc-to-erc-core') - expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) - if (!isRelativeDailyLimit) { - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') - } + const setVariables = isRelativeDailyLimit => + async function() { + const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) - }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) - } - }) - it('cant set wrong values', async () => { - expect(await homeContract.isInitialized()).to.be.equal(false) + expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) + expect(await homeContract.isInitialized()).to.be.equal(false) - if (!isRelativeDailyLimit) { - // dailyLimit > maxPerTx - await homeContract - .initialize( - validatorContract.address, - ['1', '2', '1'], - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - } - // maxPerTx > minPerTx - await homeContract - .initialize( + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract + const { logs, tx } = await homeContract.initialize( validatorContract.address, - isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], + limitsArray, gasPrice, requireBlockConfirmations, token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) + '9', + limitsContract.address + ).should.be.fulfilled - if (isRelativeDailyLimit) { - // threshold >= minPerTx - await homeContract - .initialize( - validatorContract.address, - ['1', '1', '3', '2'], - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) + expect(await homeContract.isInitialized()).to.be.equal(true) + expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) + expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') + expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') + expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') + const bridgeMode = '0xba4690f5' // 4 bytes of keccak256('erc-to-erc-core') + expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + } + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - // targetLimit <= 1 ether + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: foreignDailyLimit.toString() + }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: '3' }) + } + } + it('sets variables', setVariables(false)) + it('sets variables (relative limit)', setVariables(true)) + const cantSetWrongValues = isRelativeDailyLimit => + async function() { + expect(await homeContract.isInitialized()).to.be.equal(false) + + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract + + if (!isRelativeDailyLimit) { + // dailyLimit > maxPerTx + await homeContract + .initialize( + validatorContract.address, + ['1', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + } + // maxPerTx > minPerTx await homeContract .initialize( validatorContract.address, - [ether('2'), '3', '2', '1'], + isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], gasPrice, requireBlockConfirmations, token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) - } - expect(await homeContract.isInitialized()).to.be.equal(false) - }) + if (isRelativeDailyLimit) { + // threshold >= minPerTx + await homeContract + .initialize( + validatorContract.address, + ['1', '1', '3', '2'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + + // targetLimit <= 1 ether + await homeContract + .initialize( + validatorContract.address, + [ether('2'), '3', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + } + + expect(await homeContract.isInitialized()).to.be.equal(false) + } + it('cant set wrong values', cantSetWrongValues(false)) + it('cant set wrong values (relative limit)', cantSetWrongValues(true)) it('can be deployed via upgradeToAndCall', async () => { const storageProxy = await EternalStorageProxy.new().should.be.fulfilled @@ -182,19 +197,18 @@ function test(accounts, isRelativeDailyLimit) { token.address, ['3', '2', '1'], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridgeContract.at(storageProxy.address) + const finalContract = await HomeBridge.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') - if (!isRelativeDailyLimit) { - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') - } + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') }) it('cant initialize with invalid arguments', async () => { @@ -209,7 +223,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -221,7 +236,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -233,7 +249,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -245,7 +262,21 @@ function test(accounts, isRelativeDailyLimit) { ZERO_ADDRESS, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + ZERO_ADDRESS ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -257,7 +288,8 @@ function test(accounts, isRelativeDailyLimit) { owner, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -269,7 +301,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [halfEther, oneEther, quarterEther], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -281,7 +314,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [oneEther, halfEther, halfEther], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract.initialize( @@ -292,7 +326,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeContract.isInitialized()).to.be.equal(true) @@ -310,7 +345,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Then @@ -320,17 +356,18 @@ function test(accounts, isRelativeDailyLimit) { describe('#fallback', async () => { beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await homeContract.initialize( validatorContract.address, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], gasPrice, requireBlockConfirmations, token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) }) it('reverts', async () => { @@ -343,44 +380,50 @@ function test(accounts, isRelativeDailyLimit) { }) }) - describe('#setting limits', async () => { - let homeContract - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - }) - it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled + const settingLimits = isRelativeDailyLimit => + async function() { + let homeContract + beforeEach(async () => { + homeContract = await HomeBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + }) + it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled + + // in implementation with relative daily limit, maxPerTx can be more than current dailyLimit + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } + }) - // in implementation with relative daily limit, maxPerTx can be more than current dailyLimit - if (!isRelativeDailyLimit) { - await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) - } - }) + it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { + await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled - it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { - await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled + await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + } - await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - }) + describe('#setting limits', settingLimits(false)) + describe('#setting limits (relative limit)', settingLimits(true)) describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await homeBridge.initialize( validatorContract.address, @@ -390,7 +433,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await token.transferOwnership(homeBridge.address) }) @@ -466,7 +510,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, limitsArray, @@ -475,7 +519,8 @@ function test(accounts, isRelativeDailyLimit) { token2sig.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await token2sig.transferOwnership(homeBridgeWithTwoSigs.address) const recipient = accounts[5] @@ -551,7 +596,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, limitsArray, @@ -560,7 +605,8 @@ function test(accounts, isRelativeDailyLimit) { token2sig.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await token2sig.transferOwnership(homeBridgeWithTwoSigs.address) const recipient = accounts[5] @@ -593,7 +639,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, limitsArray, @@ -602,7 +648,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await token.transferOwnership(homeBridgeWithThreeSigs.address) @@ -729,7 +776,7 @@ function test(accounts, isRelativeDailyLimit) { }) describe('#isAlreadyProcessed', async () => { it('returns ', async () => { - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const bn = toBN(2).pow(toBN(255)) const processedNumbers = [bn.add(toBN(1)).toString(10), bn.add(toBN(100)).toString(10)] true.should.be.equal(await homeBridge.isAlreadyProcessed(processedNumbers[0])) @@ -749,7 +796,7 @@ function test(accounts, isRelativeDailyLimit) { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridgeContract.new() + homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, limitsArray, @@ -758,7 +805,8 @@ function test(accounts, isRelativeDailyLimit) { token2sig.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await token2sig.transferOwnership(homeBridgeWithTwoSigs.address) }) @@ -819,7 +867,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, limitsArray, @@ -828,7 +876,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const value = ether('0.5') @@ -911,7 +960,7 @@ function test(accounts, isRelativeDailyLimit) { describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() }) it('should return the required message length', async () => { @@ -923,10 +972,10 @@ function test(accounts, isRelativeDailyLimit) { describe('#fixAssetsAboveLimits', async () => { let homeBridge beforeEach(async () => { - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, limitsArray, @@ -935,7 +984,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled }) it('Should revert if value to unlock is bigger than max per transaction', async () => { @@ -1195,10 +1245,10 @@ function test(accounts, isRelativeDailyLimit) { it('should be able to call claimTokens on tokenAddress', async () => { const token = await ERC677BridgeToken.new('Bridge Token', 'BT20', 18) - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, limitsArray, @@ -1207,7 +1257,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await token.transferOwnership(homeBridge.address).should.be.fulfilled @@ -1242,7 +1293,7 @@ function test(accounts, isRelativeDailyLimit) { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - homeBridge = await POSDAOHomeBridgeContract.new() + homeBridge = await POSDAOHomeBridge.new() homeFee = ether('0.002') foreignFee = ether('0.002') blockRewardContract = await BlockReward.new() @@ -1251,11 +1302,7 @@ function test(accounts, isRelativeDailyLimit) { const feeManager = await FeeManagerErcToErcPOSDAO.new() expect(await homeBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeBridge.isInitialized()).to.be.equal(false) - if (!isRelativeDailyLimit) { - expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(ZERO) - } await homeBridge.rewardableInitialize( ZERO_ADDRESS, @@ -1268,7 +1315,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.rejected await homeBridge.rewardableInitialize( rewardableValidators.address, @@ -1281,7 +1329,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.rejected await homeBridge.rewardableInitialize( rewardableValidators.address, @@ -1294,9 +1343,10 @@ function test(accounts, isRelativeDailyLimit) { ZERO_ADDRESS, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.rejected - const { logs } = await homeBridge.rewardableInitialize( + const { logs, tx } = await homeBridge.rewardableInitialize( rewardableValidators.address, limitsArray, gasPrice, @@ -1307,7 +1357,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - '9' + '9', + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeBridge.isInitialized()).to.be.equal(true) @@ -1322,9 +1373,7 @@ function test(accounts, isRelativeDailyLimit) { expect(major).to.be.bignumber.gte(ZERO) expect(minor).to.be.bignumber.gte(ZERO) expect(patch).to.be.bignumber.gte(ZERO) - if (!isRelativeDailyLimit) { - expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(oneEther) - } + expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(oneEther) const feeManagerContract = await homeBridge.feeManagerContract() feeManagerContract.should.be.equals(feeManager.address) @@ -1339,10 +1388,12 @@ function test(accounts, isRelativeDailyLimit) { requiredBlockConfirmations: toBN(requireBlockConfirmations) }) expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) - } + await expectEvent.inTransaction(tx, absoluteLimitsContract, 'ExecutionDailyLimitChanged', { + newLimit: foreignDailyLimit.toString() + }) + await expectEvent.inTransaction(tx, absoluteLimitsContract, 'DailyLimitChanged', { + newLimit: oneEther.toString() + }) }) it('can update fee contract', async () => { const feeManager = await FeeManagerErcToErcPOSDAO.new() @@ -1357,7 +1408,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1383,7 +1435,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1413,7 +1466,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1453,7 +1507,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Then @@ -1475,7 +1530,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled const blockReward = await homeBridge.blockRewardContract() @@ -1497,7 +1553,7 @@ function test(accounts, isRelativeDailyLimit) { describe('#onTokenTransfer', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'TEST', 18) }) it('should trigger UserRequestForSignature with transfer value', async () => { @@ -1512,7 +1568,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled const value = halfEther await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled @@ -1539,7 +1596,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled const value = halfEther await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled @@ -1558,7 +1616,7 @@ function test(accounts, isRelativeDailyLimit) { }) it('should trigger UserRequestForSignature with fee subtracted', async () => { // Given - const homeBridge = await POSDAOHomeBridgeContract.new() + const homeBridge = await POSDAOHomeBridge.new() const owner = accounts[0] const user = accounts[4] const validators = [accounts[1]] @@ -1583,7 +1641,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled const value = halfEther const finalValueCalc = 0.5 * (1 - fee) @@ -1612,7 +1671,7 @@ function test(accounts, isRelativeDailyLimit) { token = await ERC677BridgeTokenRewardable.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() feeManager = await FeeManagerErcToErcPOSDAO.new() - homeBridge = await POSDAOHomeBridgeContract.new() + homeBridge = await POSDAOHomeBridge.new() fee = 0.001 homeFee = ether(fee.toString()) foreignFee = ether(fee.toString()) @@ -1628,7 +1687,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled }) it('should distribute fee to one validator', async () => { @@ -1806,7 +1866,7 @@ function test(accounts, isRelativeDailyLimit) { token = await ERC677BridgeTokenRewardable.new('Some ERC20', 'RSZT', 18) rewardableValidators = await RewardableValidators.new() feeManager = await FeeManagerErcToErcPOSDAO.new() - homeBridge = await POSDAOHomeBridgeContract.new() + homeBridge = await POSDAOHomeBridge.new() fee = 0.001 homeFee = ether(fee.toString()) foreignFee = ether(fee.toString()) @@ -1822,7 +1882,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, [homeFee, foreignFee], blockRewardContract.address, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled }) it('should distribute fee to one validator', async () => { @@ -2015,7 +2076,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, limitsArray, @@ -2024,7 +2085,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ) await token.transferOwnership(homeBridgeWithThreeSigs.address) @@ -2062,7 +2124,7 @@ function test(accounts, isRelativeDailyLimit) { }) it('Foreign to Home: test decimal shift 2, no impact on UserRequestForSignature value', async () => { // Given - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'TEST', 16) const owner = accounts[0] const user = accounts[4] @@ -2074,7 +2136,8 @@ function test(accounts, isRelativeDailyLimit) { token.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ).should.be.fulfilled const value = halfEther await token.mint(homeBridge.address, oneEther, { from: owner }).should.be.fulfilled @@ -2089,91 +2152,82 @@ function test(accounts, isRelativeDailyLimit) { expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(value) }) }) - if (isRelativeDailyLimit) { - describe('#dailyLimit (relative)', () => { - let token - let homeBridge + describe('#dailyLimit (relative)', () => { + let token + let homeBridge - function initialize(customLimitsArray) { - return homeBridge.initialize( - validatorContract.address, - customLimitsArray, - gasPrice, - requireBlockConfirmations, - token.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ).should.be.fulfilled - } + function initialize(customLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + token.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + relativeLimitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - homeBridge = await HomeBridgeContract.new() - }) - it('should be calculated correctly - 1', async () => { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + homeBridge = await HomeBridge.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - await token.mint(homeBridge.address, halfEther).should.be.fulfilled - expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(homeBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await homeBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) - const limit = await homeBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await token.mint(homeBridge.address, minPerTx).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(minPerTx) + await token.mint(homeBridge.address, minPerTx).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(minPerTx) - const limit = await homeBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(minPerTx) - }) - it('should be calculated correctly - 4', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await token.mint(homeBridge.address, threshold).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(threshold) + await token.mint(homeBridge.address, threshold).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(threshold) - const limit = await homeBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 5', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const minPerTx = ether('0.1') + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await token.mint(accounts[0], amountToMint).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) + await token.mint(accounts[0], amountToMint).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) - const limit = await homeBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } -} - -contract('HomeBridge_ERC20_to_ERC20', async accounts => { - test(accounts, false) -}) - -contract('HomeBridge_ERC20_to_ERC20_RelativeDailyLimit', async accounts => { - test(accounts, true) + }) }) From 853e101aa42b25d6a51bd1529ac95c6d79ec1f60 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 16 Dec 2019 14:16:45 +0300 Subject: [PATCH 66/80] fix foreign erc-to-native tests --- test/erc_to_native/foreign_bridge.test.js | 912 +++++++++++++--------- 1 file changed, 526 insertions(+), 386 deletions(-) diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index 7ceb782e7..ecd00effb 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -1,5 +1,4 @@ const ForeignBridge = artifacts.require('ForeignBridgeErcToNative.sol') -const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeErcToNativeRelativeDailyLimit.sol') const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') @@ -7,8 +6,11 @@ const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const ERC20Mock = artifacts.require('ERC20Mock.sol') const ScdMcdMigrationMock = artifacts.require('ScdMcdMigrationMock.sol') const DaiAdapterMock = artifacts.require('DaiAdapterMock.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, @@ -36,180 +38,211 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge - +contract('ForeignBridge_ERC20_to_Native', async accounts => { const requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] - const executionLimitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const executionLimitsArray = [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const relativeExecutionLimitsArray = [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] let validatorContract let authorities let owner let token let otherSideBridge + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() authorities = [accounts[1], accounts[2]] owner = accounts[0] await validatorContract.initialize(1, authorities, owner) otherSideBridge = await ForeignBridge.new() + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeExecutionDailyLimit.new() }) describe('#initialize', async () => { - it('should initialize', async () => { - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridge = await ForeignBridgeContract.new() - - expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) - expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.isInitialized()).to.be.equal(false) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + const shouldInitialize = isRelativeDailyLimit => + async function() { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const foreignBridge = await ForeignBridge.new() + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract + const executionLimits = isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray + + expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) + expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.isInitialized()).to.be.equal(false) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + + await foreignBridge.initialize( + ZERO_ADDRESS, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + ZERO_ADDRESS, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + token.address, + 0, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + 0, + requestLimitsArray, + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + owner, + requireBlockConfirmations, + gasPrice, + [maxPerTx, maxPerTx, minPerTx], + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + owner, + token.address, + requireBlockConfirmations, + gasPrice, + [dailyLimit, minPerTx, minPerTx], + executionLimits, + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit + ? [targetLimit, threshold, homeMaxPerTx, homeMaxPerTx] + : [homeDailyLimit, homeMaxPerTx, homeMaxPerTx], + owner, + decimalShiftZero, + otherSideBridge.address, + limitsContract.address + ).should.be.rejected - await foreignBridge.initialize( - ZERO_ADDRESS, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - ZERO_ADDRESS, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - token.address, - 0, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - 0, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - owner, - requireBlockConfirmations, - gasPrice, - [maxPerTx, maxPerTx, minPerTx], - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - owner, - token.address, - requireBlockConfirmations, - gasPrice, - [dailyLimit, minPerTx, minPerTx], - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMaxPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMaxPerTx], - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + '9', + ZERO_ADDRESS, + limitsContract.address + ).should.be.rejected - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - '9', - ZERO_ADDRESS - ).should.be.rejected + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + '9', + otherSideBridge.address, + ZERO_ADDRESS + ).should.be.rejected - const { logs } = await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - '9', - otherSideBridge.address - ) + const { logs, tx } = await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimits, + owner, + '9', + otherSideBridge.address, + limitsContract.address + ) - expect(await foreignBridge.erc20token()).to.be.equal(token.address) - expect(await foreignBridge.isInitialized()).to.be.equal(true) - expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( - requireBlockConfirmations.toString() - ) - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(dailyLimit) - expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(maxPerTx) - expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) - if (!isRelativeDailyLimit) { - expect(await foreignBridge.executionDailyLimit()).to.be.bignumber.equal(homeDailyLimit) - } - expect(await foreignBridge.executionMaxPerTx()).to.be.bignumber.equal(homeMaxPerTx) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') - expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - const bridgeMode = '0x18762d46' // 4 bytes of keccak256('erc-to-native-core') - expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) - - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) - }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: dailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) + expect(await foreignBridge.erc20token()).to.be.equal(token.address) + expect(await foreignBridge.isInitialized()).to.be.equal(true) + expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( + requireBlockConfirmations.toString() + ) + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(dailyLimit) + expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(maxPerTx) + expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.executionDailyLimit()).to.be.bignumber.equal(homeDailyLimit) + } + expect(await foreignBridge.executionMaxPerTx()).to.be.bignumber.equal(homeMaxPerTx) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') + expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) + const bridgeMode = '0x18762d46' // 4 bytes of keccak256('erc-to-native-core') + expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: dailyLimit.toString() }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: homeDailyLimit.toString() + }) + } } - }) + it('should initialize', shouldInitialize(false)) + it('should initialize (relative limit)', shouldInitialize(true)) }) describe('#executeSignatures', async () => { const value = ether('0.25') let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -220,31 +253,52 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) await token.mint(foreignBridge.address, value) }) - it('should allow to executeSignatures', async () => { - const recipientAccount = accounts[3] - const balanceBefore = await token.balanceOf(recipientAccount) - - const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' - const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + const shouldAllowToExecuteSignatures = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(foreignBridge.address, value) + + const recipientAccount = accounts[3] + const balanceBefore = await token.balanceOf(recipientAccount) + + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + + const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + const balanceAfter = await token.balanceOf(recipientAccount) + const balanceAfterBridge = await token.balanceOf(foreignBridge.address) + balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) + balanceAfterBridge.should.be.bignumber.equal(ZERO) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + } - const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - const event = logs.find(item => item.event === 'RelayedMessage') - event.args.recipient.should.be.equal(recipientAccount) - event.args.value.should.be.bignumber.equal(value) - const balanceAfter = await token.balanceOf(recipientAccount) - const balanceAfterBridge = await token.balanceOf(foreignBridge.address) - balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - balanceAfterBridge.should.be.bignumber.equal(ZERO) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - }) + it('should allow to executeSignatures', shouldAllowToExecuteSignatures(false)) + it('should allow to executeSignatures (relative limit)', shouldAllowToExecuteSignatures(true)) it('should allow second withdrawal with different transactionHash but same recipient and value', async () => { const recipientAccount = accounts[3] @@ -301,44 +355,90 @@ function test(accounts, isRelativeDailyLimit) { await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.rejectedWith(ERROR_MSG) }) - it('should not allow withdraw over home max tx limit', async () => { - const recipientAccount = accounts[3] - const invalidValue = ether('0.75') - await token.mint(foreignBridge.address, ether('5')) + const shouldNotAllowWithdrawOverHomeMaxTxLimit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(foreignBridge.address, value) - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + const recipientAccount = accounts[3] + const invalidValue = ether('0.75') + await token.mint(foreignBridge.address, ether('5')) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) - }) + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - it('should not allow withdraw over daily home limit', async () => { - const recipientAccount = accounts[3] - await token.mint(foreignBridge.address, ether('1.25')) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) + } - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + it('should not allow withdraw over home max tx limit', shouldNotAllowWithdrawOverHomeMaxTxLimit(false)) + it( + 'should not allow withdraw over home max tx limit (relative limit)', + shouldNotAllowWithdrawOverHomeMaxTxLimit(true) + ) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + const shouldNotAllowWithdrawOverDailyHomeLimit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(foreignBridge.address, value) - const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' - const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) - const signature2 = await sign(authorities[0], message2) - const vrs2 = signatureToVRS(signature2) + const recipientAccount = accounts[3] + await token.mint(foreignBridge.address, ether('1.25')) - await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' - const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) - const signature3 = await sign(authorities[0], message3) - const vrs3 = signatureToVRS(signature3) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) - }) + const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' + const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) + const signature2 = await sign(authorities[0], message2) + const vrs2 = signatureToVRS(signature2) + + await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled + + const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' + const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) + const signature3 = await sign(authorities[0], message3) + const vrs3 = signatureToVRS(signature3) + + await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) + } + + it('should not allow withdraw over daily home limit', shouldNotAllowWithdrawOverDailyHomeLimit(false)) + it( + 'should not allow withdraw over daily home limit (relative limit)', + shouldNotAllowWithdrawOverDailyHomeLimit(true) + ) }) describe('#withdraw with 2 minimum signatures', async () => { let multisigValidatorContract @@ -354,7 +454,7 @@ function test(accounts, isRelativeDailyLimit) { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() + foreignBridgeWithMultiSignatures = await ForeignBridge.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -365,6 +465,7 @@ function test(accounts, isRelativeDailyLimit) { owner, decimalShiftZero, otherSideBridge.address, + absoluteLimitsContract.address, { from: ownerOfValidatorContract } ) await token.mint(foreignBridgeWithMultiSignatures.address, oneEther) @@ -420,7 +521,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -431,7 +532,8 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) await erc20Token.mint(foreignBridgeWithThreeSigs.address, oneEther) @@ -480,10 +582,10 @@ function test(accounts, isRelativeDailyLimit) { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) + foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, @@ -493,7 +595,8 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) // Deploy V2 @@ -508,7 +611,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorsAddress = validatorContract.address const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.new() + const foreignBridge = await ForeignBridge.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, @@ -516,56 +619,61 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, gasPrice, ['3', '2', '1'], - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridgeContract.at(storageProxy.address) + const finalContract = await ForeignBridge.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) }) }) describe('#claimTokens', async () => { - it('can send erc20', async () => { - const owner = accounts[0] - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const foreignBridgeImpl = await ForeignBridgeContract.new() - const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) + const canSendErc20 = isRelativeDailyLimit => + async function() { + const owner = accounts[0] + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + const foreignBridgeImpl = await ForeignBridge.new() + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled + const foreignBridge = await ForeignBridge.at(storageProxy.address) - await foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - executionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ) - const tokenSecond = await ERC677BridgeToken.new('Roman Token', 'RST', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + const tokenSecond = await ERC677BridgeToken.new('Roman Token', 'RST', 18) - await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - await tokenSecond.transfer(foreignBridge.address, halfEther) - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + await tokenSecond.transfer(foreignBridge.address, halfEther) + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - await foreignBridge - .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) + await foreignBridge + .claimTokens(tokenSecond.address, accounts[3], { from: accounts[3] }) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + } + it('can send erc20', canSendErc20(false)) + it('can send erc20 (relative limit)', canSendErc20(true)) }) describe('#decimalShift', async () => { const decimalShiftTwo = 2 @@ -577,10 +685,10 @@ function test(accounts, isRelativeDailyLimit) { const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) const owner = accounts[0] - const foreignBridgeImpl = await ForeignBridgeContract.new() + const foreignBridgeImpl = await ForeignBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) + const foreignBridge = await ForeignBridge.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, @@ -591,7 +699,8 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftTwo, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) await token.mint(foreignBridge.address, valueOnHome.mul(toBN('2'))) @@ -628,7 +737,7 @@ function test(accounts, isRelativeDailyLimit) { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - const foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() + const foreignBridgeWithMultiSignatures = await ForeignBridge.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -639,6 +748,7 @@ function test(accounts, isRelativeDailyLimit) { owner, decimalShiftTwo, otherSideBridge.address, + absoluteLimitsContract.address, { from: ownerOfValidatorContract } ) await token.mint(foreignBridgeWithMultiSignatures.address, valueOnHome.mul(toBN('2'))) @@ -680,7 +790,7 @@ function test(accounts, isRelativeDailyLimit) { const recipient = accounts[8] let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -691,42 +801,61 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) await token.mint(user, ether('2')) }) - it('should allow to bridge tokens using approve and relayTokens', async () => { - // Given - const currentDay = await foreignBridge.getCurrentDay() - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - await token.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled - - // When - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, ZERO_ADDRESS, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, foreignBridge.address, value, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, user, 0, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - const { logs } = await foreignBridge.methods['relayTokens(address,address,uint256)'](user, user, value, { - from: user - }).should.be.fulfilled - - // Then - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) - expectEventInLogs(logs, 'UserRequestForAffirmation', { - recipient: user, - value - }) - }) + const shouldAllowToBridgeTokens = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, ether('2')) + // Given + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + await token.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + // When + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, ZERO_ADDRESS, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, foreignBridge.address, value, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, user, 0, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + const { logs } = await foreignBridge.methods['relayTokens(address,address,uint256)'](user, user, value, { + from: user + }).should.be.fulfilled + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient: user, + value + }) + } + it('should allow to bridge tokens using approve and relayTokens', shouldAllowToBridgeTokens(false)) + it('should allow to bridge tokens using approve and relayTokens (relative limit)', shouldAllowToBridgeTokens(true)) it('should allow to bridge tokens using approve and relayTokens with different recipient', async () => { // Given const currentDay = await foreignBridge.getCurrentDay() @@ -803,38 +932,57 @@ function test(accounts, isRelativeDailyLimit) { value }) }) - it('should not be able to transfer more than limit', async () => { - // Given - const userSupply = ether('2') - const bigValue = oneEther - const smallValue = ether('0.001') - const currentDay = await foreignBridge.getCurrentDay() - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - - await token.approve(foreignBridge.address, userSupply, { from: user }).should.be.fulfilled - - // When - // value < minPerTx - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, smallValue, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - // value > maxPerTx - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, bigValue, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) - .should.be.fulfilled - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) - .should.be.fulfilled - // totalSpentPerDay > dailyLimit - await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { - from: user - }).should.be.rejectedWith(ERROR_MSG) - - // Then - expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) - }) + const shouldNotBeAbleToTransferMoreThanLimit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, ether('2')) + + // Given + const userSupply = ether('2') + const bigValue = oneEther + const smallValue = ether('0.001') + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await token.approve(foreignBridge.address, userSupply, { from: user }).should.be.fulfilled + + // When + // value < minPerTx + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, smallValue, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + // value > maxPerTx + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, bigValue, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) + .should.be.fulfilled + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { from: user }) + .should.be.fulfilled + // totalSpentPerDay > dailyLimit + await foreignBridge.methods['relayTokens(address,address,uint256)'](user, recipient, halfEther, { + from: user + }).should.be.rejectedWith(ERROR_MSG) + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + } + it('should not be able to transfer more than limit', shouldNotBeAbleToTransferMoreThanLimit(false)) + it('should not be able to transfer more than limit (relative limit)', shouldNotBeAbleToTransferMoreThanLimit(true)) it('should allow to call relayTokens without specifying the sender', async () => { // Given await foreignBridge.methods['relayTokens(address,uint256)'](recipient, value, { @@ -869,7 +1017,7 @@ function test(accounts, isRelativeDailyLimit) { let dai let migrationContract beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() sai = await ERC20Mock.new('sai', 'SAI', 18) dai = await ERC20Mock.new('dai', 'DAI', 18) const daiAdapterMock = await DaiAdapterMock.new(dai.address) @@ -884,7 +1032,8 @@ function test(accounts, isRelativeDailyLimit) { executionLimitsArray, owner, decimalShiftZero, - otherSideBridge.address + otherSideBridge.address, + absoluteLimitsContract.address ) // Mint the bridge some sai tokens @@ -930,92 +1079,83 @@ function test(accounts, isRelativeDailyLimit) { expect(transferEvent[0].returnValues.value).to.be.equal(oneEther.toString()) }) }) - if (isRelativeDailyLimit) { - describe('#executionDailyLimit (relative)', () => { - let token - let foreignBridge + describe('#executionDailyLimit (relative)', () => { + let token + let foreignBridge - function initialize(customExecutionLimitsArray) { - return foreignBridge.initialize( - validatorContract.address, - token.address, - requireBlockConfirmations, - gasPrice, - requestLimitsArray, - customExecutionLimitsArray, - owner, - decimalShiftZero, - otherSideBridge.address - ).should.be.fulfilled - } + function initialize(customExecutionLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + customExecutionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + relativeLimitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - foreignBridge = await ForeignBridgeContract.new() - }) - it('should be calculated correctly - 1', async () => { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + beforeEach(async () => { + token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) + foreignBridge = await ForeignBridge.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - await token.mint(foreignBridge.address, halfEther).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await foreignBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) - expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await token.totalSupply()).to.be.bignumber.equal(halfEther) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(ZERO) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(ZERO) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(homeMinPerTx) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(homeMinPerTx) - }) - it('should be calculated correctly - 4', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 4', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, threshold).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(threshold) - const limit = await foreignBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 5', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const homeMinPerTx = ether('0.1') + const limit = await foreignBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 5', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(amountToMint) - const limit = await foreignBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await foreignBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } -} - -contract('ForeignBridge_ERC20_to_Native', async accounts => { - test(accounts, false) -}) - -contract('ForeignBridge_ERC20_to_Native_RelativeDailyLimit', async accounts => { - test(accounts, true) + }) }) From 1001737293aebb702bd1e25c44234441b4bc4858 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 17 Dec 2019 14:39:16 +0300 Subject: [PATCH 67/80] add payable modifier for methods of limits contract --- contracts/upgradeable_contracts/AbsoluteDailyLimit.sol | 6 +++--- contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index 18026af72..1c4fb806f 100644 --- a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -96,12 +96,12 @@ contract AbsoluteDailyLimit is EternalStorage { return now / 1 days; } - function increaseTotalSpentPerDay(uint256 _value) external { + function increaseTotalSpentPerDay(uint256 _value) external payable { uint256 totalSpent = totalSpentPerDay(getCurrentDay()).add(_value); uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", getCurrentDay()))] = totalSpent; } - function increaseTotalExecutedPerDay(uint256 _value) external { + function increaseTotalExecutedPerDay(uint256 _value) external payable { uint256 totalExecuted = totalExecutedPerDay(getCurrentDay()).add(_value); uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", getCurrentDay()))] = totalExecuted; } @@ -138,5 +138,5 @@ contract AbsoluteDailyLimit is EternalStorage { uintStorage[MIN_PER_TX] = _minPerTx; } - function updateTodayLimit(uint256) external {} + function updateTodayLimit(uint256) external payable {} } diff --git a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol index d07135770..0bfb0b2e0 100644 --- a/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/BasicRelativeDailyLimit.sol @@ -54,7 +54,7 @@ contract BasicRelativeDailyLimit is AbsoluteDailyLimit { emit ThresholdChanged(_threshold); } - function updateTodayLimit(uint256 _balance) external { + function updateTodayLimit(uint256 _balance) external payable { if (_todayLimit() == 0) { uint256 limit = _calculateLimit(_balance); _setTodayLimit(limit); From 0178a79d21e8800559dcdead1557230508e18086 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 17 Dec 2019 14:40:58 +0300 Subject: [PATCH 68/80] fix home erc-to-native tests --- test/erc_to_native/home_bridge.test.js | 1798 +++++++++++++----------- 1 file changed, 971 insertions(+), 827 deletions(-) diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index 98783ec36..0c04f7368 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -1,5 +1,4 @@ const HomeBridge = artifacts.require('HomeBridgeErcToNative.sol') -const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeErcToNativeRelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const BlockReward = artifacts.require('BlockReward') @@ -8,8 +7,11 @@ const RewardableValidators = artifacts.require('RewardableValidators.sol') const FeeManagerErcToNative = artifacts.require('FeeManagerErcToNative.sol') const FeeManagerErcToNativePOSDAO = artifacts.require('FeeManagerErcToNativePOSDAO') const FeeManagerMock = artifacts.require('FeeManagerMock') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') @@ -28,353 +30,384 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge +contract('HomeBridge_ERC20_to_Native', async accounts => { + const isRelativeDailyLimit = false - const limitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, halfEther, minPerTx] - : [oneEther, halfEther, minPerTx] + const limitsArray = [oneEther, halfEther, minPerTx] + const relativeLimitsArray = [targetLimit, threshold, halfEther, minPerTx] let homeContract let validatorContract let blockRewardContract let authorities let owner + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() blockRewardContract = await BlockReward.new() authorities = [accounts[1]] owner = accounts[0] await validatorContract.initialize(1, authorities, owner) + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeDailyLimit.new() }) - describe('#initialize', async () => { - const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + const initialize = isRelativeDailyLimit => + async function() { + const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + let limitsContract - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - }) - it('sets variables', async () => { - expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) - expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) - expect(await homeContract.isInitialized()).to.be.equal(false) - expect(await homeContract.blockRewardContract()).to.be.equal(ZERO_ADDRESS) - if (!isRelativeDailyLimit) { - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) - } - - const { logs } = await homeContract.initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - '9' - ).should.be.fulfilled - - expect(await homeContract.isInitialized()).to.be.equal(true) - expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - if (!isRelativeDailyLimit) { - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') - } - expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') - expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') - expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') - expect(await homeContract.blockRewardContract()).to.be.equal(blockRewardContract.address) - expect(await homeContract.gasPrice()).to.be.bignumber.equal(gasPrice) - const bridgeMode = '0x18762d46' // 4 bytes of keccak256('erc-to-native-core') - expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) - - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) + beforeEach(async () => { + homeContract = await HomeBridge.new() + limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) - } - }) - - it('can update block reward contract', async () => { - ZERO_ADDRESS.should.be.equal(await homeContract.blockRewardContract()) + it('sets variables', async () => { + expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) + expect(await homeContract.isInitialized()).to.be.equal(false) + expect(await homeContract.blockRewardContract()).to.be.equal(ZERO_ADDRESS) - await homeContract.initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ).should.be.fulfilled + const { logs, tx } = await homeContract.initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + '9', + limitsContract.address + ).should.be.fulfilled - blockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + expect(await homeContract.isInitialized()).to.be.equal(true) + expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) + if (!isRelativeDailyLimit) { + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + } + expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') + expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') + expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') + expect(await homeContract.blockRewardContract()).to.be.equal(blockRewardContract.address) + expect(await homeContract.gasPrice()).to.be.bignumber.equal(gasPrice) + const bridgeMode = '0x18762d46' // 4 bytes of keccak256('erc-to-native-core') + expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: foreignDailyLimit.toString() + }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: '3' }) + } + }) - const secondBlockRewardContract = await BlockReward.new() - await homeContract.setBlockRewardContract(secondBlockRewardContract.address) - secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + it('can update block reward contract', async () => { + ZERO_ADDRESS.should.be.equal(await homeContract.blockRewardContract()) - const thirdBlockRewardContract = await BlockReward.new() - await homeContract - .setBlockRewardContract(thirdBlockRewardContract.address, { from: accounts[4] }) - .should.be.rejectedWith(ERROR_MSG) - secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + await homeContract.initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ).should.be.fulfilled - const notAContract = accounts[5] - await homeContract.setBlockRewardContract(notAContract).should.be.rejectedWith(ERROR_MSG) - secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + blockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) - await homeContract.setBlockRewardContract(validatorContract.address).should.be.rejectedWith(ERROR_MSG) - secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + const secondBlockRewardContract = await BlockReward.new() + await homeContract.setBlockRewardContract(secondBlockRewardContract.address) + secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) - const oldBlockRewardContract = await OldBlockReward.new() - await homeContract.setBlockRewardContract(oldBlockRewardContract.address).should.be.fulfilled - oldBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) - }) + const thirdBlockRewardContract = await BlockReward.new() + await homeContract + .setBlockRewardContract(thirdBlockRewardContract.address, { from: accounts[4] }) + .should.be.rejectedWith(ERROR_MSG) + secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + + const notAContract = accounts[5] + await homeContract.setBlockRewardContract(notAContract).should.be.rejectedWith(ERROR_MSG) + secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + + await homeContract.setBlockRewardContract(validatorContract.address).should.be.rejectedWith(ERROR_MSG) + secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + + const oldBlockRewardContract = await OldBlockReward.new() + await homeContract.setBlockRewardContract(oldBlockRewardContract.address).should.be.fulfilled + oldBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract()) + }) + + it('cant set maxPerTx > dailyLimit', async () => { + false.should.be.equal(await homeContract.isInitialized()) + + if (isRelativeDailyLimit) { + await homeContract + .initialize( + validatorContract.address, + [ether('2'), '3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + ['1', '1', '3', '2'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + } else { + await homeContract + .initialize( + validatorContract.address, + ['1', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + } + await homeContract + .initialize( + validatorContract.address, + isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) - it('cant set maxPerTx > dailyLimit', async () => { - false.should.be.equal(await homeContract.isInitialized()) + false.should.be.equal(await homeContract.isInitialized()) + }) - if (isRelativeDailyLimit) { + it('can be deployed via upgradeToAndCall', async () => { + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + const data = homeContract.contract.methods + .initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + ['3', '2', '1'], + owner, + decimalShiftZero, + limitsContract.address + ) + .encodeABI() + + await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled + const finalContract = await HomeBridge.at(storageProxy.address) + + expect(await finalContract.isInitialized()).to.be.equal(true) + expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + } + expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') + expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') + expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) + }) + it('can be upgraded keeping the state', async () => { + const homeOwner = accounts[8] + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + const data = homeContract.contract.methods + .initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + ['3', '2', '1'], + homeOwner, + decimalShiftZero, + limitsContract.address + ) + .encodeABI() + + await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled + const finalContract = await HomeBridge.at(storageProxy.address) + + expect(await finalContract.isInitialized()).to.be.equal(true) + expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) + if (!isRelativeDailyLimit) { + expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') + } + expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') + expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') + expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) + + const homeContractV2 = await HomeBridge.new() + await storageProxy.upgradeTo('2', homeContractV2.address).should.be.fulfilled + const finalContractV2 = await HomeBridge.at(storageProxy.address) + + expect(await finalContractV2.isInitialized()).to.be.equal(true) + expect(await finalContractV2.validatorContract()).to.be.equal(validatorContract.address) + if (!isRelativeDailyLimit) { + expect(await finalContractV2.dailyLimit()).to.be.bignumber.equal('3') + } + expect(await finalContractV2.maxPerTx()).to.be.bignumber.equal('2') + expect(await finalContractV2.minPerTx()).to.be.bignumber.equal('1') + expect(await finalContractV2.blockRewardContract()).to.be.equal(blockRewardContract.address) + }) + it('cant initialize with invalid arguments', async () => { + false.should.be.equal(await homeContract.isInitialized()) await homeContract .initialize( validatorContract.address, - [ether('2'), '3', '2', '1'], + limitsArray, + gasPrice, + 0, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + owner, + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract .initialize( - validatorContract.address, - ['1', '1', '3', '2'], + ZERO_ADDRESS, + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + owner, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + limitsContract.address ) .should.be.rejectedWith(ERROR_MSG) - } else { await homeContract .initialize( validatorContract.address, - ['1', '2', '1'], + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [halfEther, oneEther, quarterEther], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [oneEther, halfEther, halfEther], + owner, + decimalShiftZero, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await homeContract + .initialize( + validatorContract.address, + limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + ZERO_ADDRESS ) .should.be.rejectedWith(ERROR_MSG) - } - await homeContract - .initialize( - validatorContract.address, - isRelativeDailyLimit ? ['1', '3', '2', '2'] : ['3', '2', '2'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - - false.should.be.equal(await homeContract.isInitialized()) - }) - - it('can be deployed via upgradeToAndCall', async () => { - const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const data = homeContract.contract.methods - .initialize( + await homeContract.initialize( validatorContract.address, limitsArray, gasPrice, requireBlockConfirmations, blockRewardContract.address, - ['3', '2', '1'], - owner, - decimalShiftZero - ) - .encodeABI() - - await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridgeContract.at(storageProxy.address) - - expect(await finalContract.isInitialized()).to.be.equal(true) - expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) - if (!isRelativeDailyLimit) { - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') - } - expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') - expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') - expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) - }) - it('can be upgraded keeping the state', async () => { - const homeOwner = accounts[8] - const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const data = homeContract.contract.methods - .initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - ['3', '2', '1'], - homeOwner, - decimalShiftZero - ) - .encodeABI() - - await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridgeContract.at(storageProxy.address) - - expect(await finalContract.isInitialized()).to.be.equal(true) - expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) - if (!isRelativeDailyLimit) { - expect(await finalContract.dailyLimit()).to.be.bignumber.equal('3') - } - expect(await finalContract.maxPerTx()).to.be.bignumber.equal('2') - expect(await finalContract.minPerTx()).to.be.bignumber.equal('1') - expect(await finalContract.blockRewardContract()).to.be.equal(blockRewardContract.address) - - const homeContractV2 = await HomeBridgeContract.new() - await storageProxy.upgradeTo('2', homeContractV2.address).should.be.fulfilled - const finalContractV2 = await HomeBridgeContract.at(storageProxy.address) - - expect(await finalContractV2.isInitialized()).to.be.equal(true) - expect(await finalContractV2.validatorContract()).to.be.equal(validatorContract.address) - if (!isRelativeDailyLimit) { - expect(await finalContractV2.dailyLimit()).to.be.bignumber.equal('3') - } - expect(await finalContractV2.maxPerTx()).to.be.bignumber.equal('2') - expect(await finalContractV2.minPerTx()).to.be.bignumber.equal('1') - expect(await finalContractV2.blockRewardContract()).to.be.equal(blockRewardContract.address) - }) - it('cant initialize with invalid arguments', async () => { - false.should.be.equal(await homeContract.isInitialized()) - await homeContract - .initialize( - validatorContract.address, - limitsArray, - gasPrice, - 0, - blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - owner, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - ZERO_ADDRESS, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - owner, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [halfEther, oneEther, quarterEther], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract - .initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [oneEther, halfEther, halfEther], - owner, - decimalShiftZero - ) - .should.be.rejectedWith(ERROR_MSG) - await homeContract.initialize( - validatorContract.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ).should.be.fulfilled - true.should.be.equal(await homeContract.isInitialized()) - }) - }) + decimalShiftZero, + limitsContract.address + ).should.be.fulfilled + true.should.be.equal(await homeContract.isInitialized()) + }) + } + describe('#initialize', initialize(false)) + describe('#initialize (relative limit)', initialize(true)) describe('#rewardableInitialize', async () => { - const limitsArray = isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'] + const limitsArray = ['3', '2', '1'] let feeManager let homeFee let foreignFee beforeEach(async () => { feeManager = await FeeManagerErcToNative.new() - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() homeFee = ether('0.001') foreignFee = ether('0.002') }) it('sets variables', async () => { expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) expect(await homeContract.isInitialized()).to.be.equal(false) expect(await homeContract.blockRewardContract()).to.be.equal(ZERO_ADDRESS) - if (!isRelativeDailyLimit) { - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) - } await homeContract.rewardableInitialize( validatorContract.address, @@ -386,7 +419,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - '9' + '9', + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeContract.isInitialized()).to.be.equal(true) @@ -428,7 +462,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -442,7 +477,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -456,7 +492,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -470,7 +507,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -484,7 +522,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -498,7 +537,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -512,7 +552,8 @@ function test(accounts, isRelativeDailyLimit) { owner, ZERO_ADDRESS, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract.rewardableInitialize( @@ -525,7 +566,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled true.should.be.equal(await homeContract.isInitialized()) }) @@ -541,7 +583,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -566,7 +609,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -594,7 +638,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled const invalidFee = ether('1') @@ -616,404 +661,418 @@ function test(accounts, isRelativeDailyLimit) { expect(await homeContract.getForeignFee()).to.be.bignumber.equals(newForeignFee) }) }) - describe('#fallback', async () => { - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - }) + const fallback = isRelativeDailyLimit => + function() { + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) - it('should accept native coins', async () => { - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + it('should accept native coins', async () => { + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - minted.should.be.bignumber.equal('10') + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + minted.should.be.bignumber.equal('10') - const { logs } = await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + const { logs } = await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expectEventInLogs(logs, 'UserRequestForSignature', { recipient: accounts[1], value: toBN(1) }) - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + expectEventInLogs(logs, 'UserRequestForSignature', { recipient: accounts[1], value: toBN(1) }) + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) - homeContractBalance.should.be.bignumber.equal(ZERO) - }) + const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) + homeContractBalance.should.be.bignumber.equal(ZERO) + }) - it('should accumulate burnt coins', async () => { - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + it('should accumulate burnt coins', async () => { + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('2') + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('2') - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('3') + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('3') - const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) - homeContractBalance.should.be.bignumber.equal(ZERO) - }) + const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) + homeContractBalance.should.be.bignumber.equal(ZERO) + }) - it('doesnt let you send more than daily limit', async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) + it('doesnt let you send more than daily limit', async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') - await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) - if (!isRelativeDailyLimit) { - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') - } - }) + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 2 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + } + }) - it('doesnt let you send more than max amount per tx', async () => { - await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) + it('doesnt let you send more than max amount per tx', async () => { + await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) - await homeContract.sendTransaction({ - from: accounts[1], - value: 1 - }).should.be.fulfilled - await homeContract - .sendTransaction({ - from: accounts[1], - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) - if (!isRelativeDailyLimit) { - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled - } - await homeContract.setMaxPerTx(99).should.be.fulfilled - // meets max per tx and daily limit - await homeContract.sendTransaction({ - from: accounts[1], - value: 99 - }).should.be.fulfilled - // above daily limit - await homeContract - .sendTransaction({ + await homeContract.sendTransaction({ from: accounts[1], value: 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) + }).should.be.fulfilled + await homeContract + .sendTransaction({ + from: accounts[1], + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + } + await homeContract.setMaxPerTx(99).should.be.fulfilled + // meets max per tx and daily limit + await homeContract.sendTransaction({ + from: accounts[1], + value: 99 + }).should.be.fulfilled + // // above daily limit + await homeContract + .sendTransaction({ + from: accounts[1], + value: 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) - it('should not let to deposit less than minPerTx', async () => { - const newDailyLimit = 100 - const newMaxPerTx = 50 - const newMinPerTx = 20 + it('should not let to deposit less than minPerTx', async () => { + const newDailyLimit = 100 + const newMaxPerTx = 50 + const newMinPerTx = 20 - await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) - await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled - await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled - await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled + await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled + await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled - await homeContract.sendTransaction({ from: accounts[1], value: newMinPerTx }).should.be.fulfilled - await homeContract - .sendTransaction({ from: accounts[1], value: newMinPerTx - 1 }) - .should.be.rejectedWith(ERROR_MSG) - }) + await homeContract.sendTransaction({ from: accounts[1], value: newMinPerTx }).should.be.fulfilled + await homeContract + .sendTransaction({ from: accounts[1], value: newMinPerTx - 1 }) + .should.be.rejectedWith(ERROR_MSG) + }) - it('should fail if not enough bridged tokens', async () => { - const initiallyMinted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - initiallyMinted.should.be.bignumber.equal(ZERO) + it('should fail if not enough bridged tokens', async () => { + const initiallyMinted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + initiallyMinted.should.be.bignumber.equal(ZERO) - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - const amountToMint = isRelativeDailyLimit ? '3' : '2' - await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) + const amountToMint = isRelativeDailyLimit ? '3' : '2' + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.fulfilled - await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.sendTransaction({ from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - const burnt = await homeContract.totalBurntCoins() + const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + const burnt = await homeContract.totalBurntCoins() - minted.should.be.bignumber.equal(amountToMint) - burnt.should.be.bignumber.equal('2') - }) - }) - describe('#relayTokens', () => { - const recipient = accounts[7] - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - }) - it('should accept native coins and alternative receiver', async () => { - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + minted.should.be.bignumber.equal(amountToMint) + burnt.should.be.bignumber.equal('2') + }) + } + describe('#fallback', fallback(false)) + describe('#fallback (relative limit)', fallback(true)) + const relayTokens = isRelativeDailyLimit => + function() { + const recipient = accounts[7] + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '10000', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) + it('should accept native coins and alternative receiver', async () => { + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - minted.should.be.bignumber.equal('10') + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + minted.should.be.bignumber.equal('10') - const { logs } = await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + const { logs } = await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expectEventInLogs(logs, 'UserRequestForSignature', { recipient, value: toBN(1) }) - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + expectEventInLogs(logs, 'UserRequestForSignature', { recipient, value: toBN(1) }) + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) - homeContractBalance.should.be.bignumber.equal(ZERO) - }) - it('should accumulate burnt coins', async () => { - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) + homeContractBalance.should.be.bignumber.equal(ZERO) + }) + it('should accumulate burnt coins', async () => { + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('2') + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('2') - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('3') + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('3') - const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) - homeContractBalance.should.be.bignumber.equal(ZERO) - }) - it('doesnt let you send more than daily limit', async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) + const homeContractBalance = toBN(await web3.eth.getBalance(homeContract.address)) + homeContractBalance.should.be.bignumber.equal(ZERO) + }) + it('doesnt let you send more than daily limit', async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? [targetLimit, '20', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await blockRewardContract.addMintedTotallyByBridge(10, homeContract.address) - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('1') - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') - await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.rejectedWith(ERROR_MSG) - if (!isRelativeDailyLimit) { - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') - expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') - } - }) - it('doesnt let you send more than max amount per tx', async () => { - await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.relayTokens(recipient, { from: accounts[1], value: 2 }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('4') + expect(await homeContract.totalBurntCoins()).to.be.bignumber.equal('4') + } + }) + it('doesnt let you send more than max amount per tx', async () => { + await blockRewardContract.addMintedTotallyByBridge(102, homeContract.address) - await homeContract.relayTokens(recipient, { - from: accounts[1], - value: 1 - }).should.be.fulfilled - await homeContract - .relayTokens(recipient, { - from: accounts[1], - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) - if (!isRelativeDailyLimit) { - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled - } - await homeContract.setMaxPerTx(99).should.be.fulfilled - // meets max per tx and daily limit - await homeContract.relayTokens(recipient, { - from: accounts[1], - value: 99 - }).should.be.fulfilled - // above daily limit - await homeContract - .relayTokens(recipient, { + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) - it('should not let to deposit less than minPerTx', async () => { - const newDailyLimit = 100 - const newMaxPerTx = 50 - const newMinPerTx = 20 + }).should.be.fulfilled + await homeContract + .relayTokens(recipient, { + from: accounts[1], + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + } + await homeContract.setMaxPerTx(99).should.be.fulfilled + // meets max per tx and daily limit + await homeContract.relayTokens(recipient, { + from: accounts[1], + value: 99 + }).should.be.fulfilled + // above daily limit + await homeContract + .relayTokens(recipient, { + from: accounts[1], + value: 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) + it('should not let to deposit less than minPerTx', async () => { + const newDailyLimit = 100 + const newMaxPerTx = 50 + const newMinPerTx = 20 - await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) + await blockRewardContract.addMintedTotallyByBridge(200, homeContract.address) - if (!isRelativeDailyLimit) { - await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled - } - await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled - await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled + if (!isRelativeDailyLimit) { + await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + } + await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled + await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled - await homeContract.relayTokens(recipient, { from: accounts[1], value: newMinPerTx }).should.be.fulfilled - await homeContract - .relayTokens(recipient, { from: accounts[1], value: newMinPerTx - 1 }) - .should.be.rejectedWith(ERROR_MSG) - }) - it('should fail if not enough bridged tokens', async () => { - const initiallyMinted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - initiallyMinted.should.be.bignumber.equal(ZERO) + await homeContract.relayTokens(recipient, { from: accounts[1], value: newMinPerTx }).should.be.fulfilled + await homeContract + .relayTokens(recipient, { from: accounts[1], value: newMinPerTx - 1 }) + .should.be.rejectedWith(ERROR_MSG) + }) + it('should fail if not enough bridged tokens', async () => { + const initiallyMinted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + initiallyMinted.should.be.bignumber.equal(ZERO) - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - const amountToMint = isRelativeDailyLimit ? '3' : '2' - await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) + const amountToMint = isRelativeDailyLimit ? '3' : '2' + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeContract.address) - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.fulfilled - await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) + await homeContract.relayTokens(recipient, { from: accounts[1], value: 1 }).should.be.rejectedWith(ERROR_MSG) - const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) - const burnt = await homeContract.totalBurntCoins() + const minted = await blockRewardContract.mintedTotallyByBridge(homeContract.address) + const burnt = await homeContract.totalBurntCoins() - minted.should.be.bignumber.equal(amountToMint) - burnt.should.be.bignumber.equal('2') - }) - }) - describe('#setting limits', async () => { - let homeContract - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ) - }) - it('setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled + minted.should.be.bignumber.equal(amountToMint) + burnt.should.be.bignumber.equal('2') + }) + } + describe('#relayTokens', relayTokens(false)) + describe('#relayTokens (relative limit)', relayTokens(true)) + const settingLimits = isRelativeDailyLimit => + function() { + let homeContract + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) + it('setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled - if (!isRelativeDailyLimit) { - await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) - } - const maxPerTx = await homeContract.maxPerTx() - maxPerTx.should.be.bignumber.equal(toBN(2)) - }) + if (!isRelativeDailyLimit) { + await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } + const maxPerTx = await homeContract.maxPerTx() + maxPerTx.should.be.bignumber.equal(toBN(2)) + }) - it('setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { - await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled + it('setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { + await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled - await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - const minPerTx = await homeContract.minPerTx() - minPerTx.should.be.bignumber.equal(toBN(1)) - }) + await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + const minPerTx = await homeContract.minPerTx() + minPerTx.should.be.bignumber.equal(toBN(1)) + }) - it('setExecutionMaxPerTx allows to set only to owner and cannot be more than execution daily limit', async () => { - const newValue = ether('0.3') + it('setExecutionMaxPerTx allows to set only to owner and cannot be more than execution daily limit', async () => { + const newValue = ether('0.3') - const initialExecutionMaxPerTx = await homeContract.executionMaxPerTx() + const initialExecutionMaxPerTx = await homeContract.executionMaxPerTx() - initialExecutionMaxPerTx.should.be.bignumber.not.equal(newValue) + initialExecutionMaxPerTx.should.be.bignumber.not.equal(newValue) - await homeContract.setExecutionMaxPerTx(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setExecutionMaxPerTx(newValue, { from: owner }).should.be.fulfilled + await homeContract.setExecutionMaxPerTx(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setExecutionMaxPerTx(newValue, { from: owner }).should.be.fulfilled - await homeContract.setExecutionMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) - const executionMaxPerTx = await homeContract.executionMaxPerTx() - executionMaxPerTx.should.be.bignumber.equal(newValue) - }) + await homeContract.setExecutionMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) + const executionMaxPerTx = await homeContract.executionMaxPerTx() + executionMaxPerTx.should.be.bignumber.equal(newValue) + }) - it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { - const newValue = ether('0.1') - await homeContract.setExecutionMinPerTx(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setExecutionMinPerTx(newValue, { from: owner }).should.be.fulfilled + it('setExecutionMinPerTx allows to set only to owner and cannot be more than execution daily limit and should be less than executionMaxPerTx', async () => { + const newValue = ether('0.1') + await homeContract.setExecutionMinPerTx(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setExecutionMinPerTx(newValue, { from: owner }).should.be.fulfilled - await homeContract.setExecutionMinPerTx(ether('0.6'), { from: owner }).should.be.rejectedWith(ERROR_MSG) - const minPerTx = await homeContract.executionMinPerTx() - minPerTx.should.be.bignumber.equal(newValue) - }) + await homeContract.setExecutionMinPerTx(ether('0.6'), { from: owner }).should.be.rejectedWith(ERROR_MSG) + const minPerTx = await homeContract.executionMinPerTx() + minPerTx.should.be.bignumber.equal(newValue) + }) - it('executionDailyLimit allows to set only to owner', async () => { - const newValue = ether('1.5') + it('executionDailyLimit allows to set only to owner', async () => { + const newValue = ether('1.5') - const initialExecutionDailyLimit = await homeContract.executionDailyLimit() + const initialExecutionDailyLimit = await homeContract.executionDailyLimit() - initialExecutionDailyLimit.should.be.bignumber.not.equal(newValue) + initialExecutionDailyLimit.should.be.bignumber.not.equal(newValue) - await homeContract.setExecutionDailyLimit(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setExecutionDailyLimit('2', { from: owner }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setExecutionDailyLimit(newValue, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setExecutionDailyLimit('2', { from: owner }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setExecutionDailyLimit(newValue, { from: owner }).should.be.fulfilled - expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(newValue) + await homeContract.setExecutionDailyLimit(newValue, { from: owner }).should.be.fulfilled + expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(newValue) - await homeContract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(ZERO) + await homeContract.setExecutionDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(ZERO) - await homeContract.setExecutionDailyLimit(newValue, { from: owner }).should.be.fulfilled - expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(newValue) - }) - }) + await homeContract.setExecutionDailyLimit(newValue, { from: owner }).should.be.fulfilled + expect(await homeContract.executionDailyLimit()).to.be.bignumber.equal(newValue) + }) + } + describe('#setting limits', settingLimits(false)) + describe('#setting limits (relative limit)', settingLimits(true)) describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, limitsArray, @@ -1022,39 +1081,59 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await blockRewardContract.sendTransaction({ from: accounts[2], value: oneEther }).should.be.fulfilled }) + const shouldAllowValidatorToExecuteAffirmation = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await blockRewardContract.sendTransaction({ + from: accounts[2], + value: oneEther + }).should.be.fulfilled + + const recipient = accounts[5] + const value = halfEther + const balanceBefore = await web3.eth.getBalance(recipient) + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: authorities[0] + }) - it('should allow validator to executeAffirmation', async () => { - const recipient = accounts[5] - const value = halfEther - const balanceBefore = await web3.eth.getBalance(recipient) - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { - from: authorities[0] - }) - - expectEventInLogs(logs, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash - }) - expectEventInLogs(logs, 'AffirmationCompleted', { - recipient, - value, - transactionHash - }) - const balanceAfter = toBN(await web3.eth.getBalance(recipient)) - balanceAfter.should.be.bignumber.equal(toBN(balanceBefore).add(value)) + expectEventInLogs(logs, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash + }) + expectEventInLogs(logs, 'AffirmationCompleted', { + recipient, + value, + transactionHash + }) + const balanceAfter = toBN(await web3.eth.getBalance(recipient)) + balanceAfter.should.be.bignumber.equal(toBN(balanceBefore).add(value)) - const msgHash = web3.utils.soliditySha3(recipient, value, transactionHash) - const senderHash = web3.utils.soliditySha3(authorities[0], msgHash) - true.should.be.equal(await homeBridge.affirmationsSigned(senderHash)) - }) + const msgHash = web3.utils.soliditySha3(recipient, value, transactionHash) + const senderHash = web3.utils.soliditySha3(authorities[0], msgHash) + true.should.be.equal(await homeBridge.affirmationsSigned(senderHash)) + } + it('should allow validator to executeAffirmation', shouldAllowValidatorToExecuteAffirmation(false)) + it('should allow validator to executeAffirmation (relative limit)', shouldAllowValidatorToExecuteAffirmation(true)) it('should allow validator to executeAffirmation with zero value', async () => { const recipient = accounts[5] @@ -1088,7 +1167,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, limitsArray, @@ -1097,7 +1176,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const recipient = accounts[5] const value = halfEther @@ -1152,7 +1232,7 @@ function test(accounts, isRelativeDailyLimit) { }) it('should fail if the block reward contract is not set', async () => { - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, limitsArray, @@ -1161,7 +1241,8 @@ function test(accounts, isRelativeDailyLimit) { ZERO_ADDRESS, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const recipient = accounts[5] @@ -1178,7 +1259,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, limitsArray, @@ -1187,7 +1268,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const value = halfEther @@ -1215,20 +1297,46 @@ function test(accounts, isRelativeDailyLimit) { transactionHash }) }) - it('should not allow execute affirmation over foreign max tx limit', async () => { - const recipient = accounts[5] - const value = oneEther - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { - from: authorities[0] - }).should.be.fulfilled - - expectEventInLogs(logs, 'AmountLimitExceeded', { - recipient, - value, - transactionHash - }) - }) + const shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await blockRewardContract.sendTransaction({ + from: accounts[2], + value: oneEther + }).should.be.fulfilled + + const recipient = accounts[5] + const value = oneEther + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: authorities[0] + }).should.be.fulfilled + + expectEventInLogs(logs, 'AmountLimitExceeded', { + recipient, + value, + transactionHash + }) + } + it( + 'should not allow execute affirmation over foreign max tx limit', + shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit(false) + ) + it( + 'should not allow execute affirmation over foreign max tx limit (relative limit)', + shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit(true) + ) it('should fail if txHash already set as above of limits', async () => { const recipient = accounts[5] const value = oneEther @@ -1250,73 +1358,94 @@ function test(accounts, isRelativeDailyLimit) { .executeAffirmation(accounts[6], value, transactionHash, { from: authorities[0] }) .should.be.rejectedWith(ERROR_MSG) }) - it('should not allow execute affirmation over daily foreign limit', async () => { - await blockRewardContract.sendTransaction({ - from: accounts[2], - value: oneEther - }).should.be.fulfilled - - const recipient = accounts[5] - const value = halfEther - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { - from: authorities[0] - }).should.be.fulfilled - - expectEventInLogs(logs, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash - }) - expectEventInLogs(logs, 'AffirmationCompleted', { - recipient, - value, - transactionHash - }) + const shouldNotAllowExecuteAffirmationOverDailyForeignLimit = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await blockRewardContract.sendTransaction({ + from: accounts[2], + value: oneEther.mul(toBN('2')) + }).should.be.fulfilled + + const recipient = accounts[5] + const value = halfEther + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: authorities[0] + }).should.be.fulfilled + + expectEventInLogs(logs, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash + }) + expectEventInLogs(logs, 'AffirmationCompleted', { + recipient, + value, + transactionHash + }) - const transactionHash2 = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const { logs: logs2 } = await homeBridge.executeAffirmation(recipient, value, transactionHash2, { - from: authorities[0] - }).should.be.fulfilled + const transactionHash2 = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const { logs: logs2 } = await homeBridge.executeAffirmation(recipient, value, transactionHash2, { + from: authorities[0] + }).should.be.fulfilled - expectEventInLogs(logs2, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash: transactionHash2 - }) - expectEventInLogs(logs2, 'AffirmationCompleted', { - recipient, - value, - transactionHash: transactionHash2 - }) + expectEventInLogs(logs2, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash: transactionHash2 + }) + expectEventInLogs(logs2, 'AffirmationCompleted', { + recipient, + value, + transactionHash: transactionHash2 + }) - const transactionHash3 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' - const { logs: logs3 } = await homeBridge.executeAffirmation(recipient, value, transactionHash3, { - from: authorities[0] - }).should.be.fulfilled + const transactionHash3 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' + const { logs: logs3 } = await homeBridge.executeAffirmation(recipient, value, transactionHash3, { + from: authorities[0] + }).should.be.fulfilled - expectEventInLogs(logs3, 'AmountLimitExceeded', { - recipient, - value, - transactionHash: transactionHash3 - }) + expectEventInLogs(logs3, 'AmountLimitExceeded', { + recipient, + value, + transactionHash: transactionHash3 + }) - const outOfLimitAmount = await homeBridge.outOfLimitAmount() + const outOfLimitAmount = await homeBridge.outOfLimitAmount() - outOfLimitAmount.should.be.bignumber.equal(halfEther) + outOfLimitAmount.should.be.bignumber.equal(halfEther) - const transactionHash4 = '0xc9ffe298d85ec5c515153608924b7bdcf1835539813dcc82cdbcc071170c3196' - const { logs: logs4 } = await homeBridge.executeAffirmation(recipient, value, transactionHash4, { - from: authorities[0] - }).should.be.fulfilled + const transactionHash4 = '0xc9ffe298d85ec5c515153608924b7bdcf1835539813dcc82cdbcc071170c3196' + const { logs: logs4 } = await homeBridge.executeAffirmation(recipient, value, transactionHash4, { + from: authorities[0] + }).should.be.fulfilled - expectEventInLogs(logs4, 'AmountLimitExceeded', { - recipient, - value, - transactionHash: transactionHash4 - }) + expectEventInLogs(logs4, 'AmountLimitExceeded', { + recipient, + value, + transactionHash: transactionHash4 + }) - const newOutOfLimitAmount = await homeBridge.outOfLimitAmount() - newOutOfLimitAmount.should.be.bignumber.equal(oneEther) - }) + const newOutOfLimitAmount = await homeBridge.outOfLimitAmount() + newOutOfLimitAmount.should.be.bignumber.equal(oneEther) + } + it( + 'should not allow execute affirmation over daily foreign limit', + shouldNotAllowExecuteAffirmationOverDailyForeignLimit(false) + ) + it( + 'should not allow execute affirmation over daily foreign limit (relative limit)', + shouldNotAllowExecuteAffirmationOverDailyForeignLimit(true) + ) }) describe('#submitSignature', async () => { let validatorContractWith2Signatures @@ -1328,7 +1457,7 @@ function test(accounts, isRelativeDailyLimit) { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridgeContract.new() + homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, limitsArray, @@ -1337,7 +1466,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) }) @@ -1396,7 +1526,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, limitsArray, @@ -1405,7 +1535,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const value = halfEther @@ -1488,7 +1619,7 @@ function test(accounts, isRelativeDailyLimit) { }) describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() }) it('should return the required message length', async () => { @@ -1498,10 +1629,10 @@ function test(accounts, isRelativeDailyLimit) { describe('#fixAssetsAboveLimits', async () => { let homeBridge beforeEach(async () => { - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( validatorContract.address, limitsArray, @@ -1510,7 +1641,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) }) it('Should revert if value to unlock is bigger than max per transaction', async () => { @@ -1733,10 +1865,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1748,7 +1880,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[2], @@ -1805,10 +1938,10 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, limitsArray, @@ -1817,7 +1950,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[2], @@ -1886,10 +2020,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1901,7 +2035,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[2], @@ -1959,11 +2094,11 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 2 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const blockRewardContract = await BlockReward.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1975,7 +2110,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[0], @@ -2065,10 +2201,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2080,7 +2216,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[0], @@ -2170,10 +2307,10 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, limitsArray, @@ -2182,7 +2319,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) }) @@ -2225,10 +2363,10 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, limitsArray, @@ -2237,7 +2375,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) }) @@ -2279,10 +2418,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2294,7 +2433,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -2348,10 +2488,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2363,7 +2503,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -2442,10 +2583,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2457,7 +2598,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -2553,10 +2695,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2570,7 +2712,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[2], @@ -2630,11 +2773,11 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 2 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const blockRewardContract = await BlockReward.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2647,7 +2790,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[0], @@ -2740,10 +2884,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2756,7 +2900,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.sendTransaction({ from: accounts[0], @@ -2859,10 +3004,10 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, limitsArray, @@ -2871,7 +3016,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) }) @@ -2914,10 +3060,10 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - homeBridge = await HomeBridgeContract.at(storageProxy.address) + homeBridge = await HomeBridge.at(storageProxy.address) await homeBridge.initialize( rewardableValidators.address, limitsArray, @@ -2926,7 +3072,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) }) @@ -2968,10 +3115,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2984,7 +3131,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -3044,10 +3192,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -3060,7 +3208,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -3145,10 +3294,10 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridgeImpl = await HomeBridgeContract.new() + const homeBridgeImpl = await HomeBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', homeBridgeImpl.address).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) + const homeBridge = await HomeBridge.at(storageProxy.address) await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -3161,7 +3310,8 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) @@ -3263,8 +3413,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() - const currentDay = await homeBridgeWithTwoSigs.getCurrentDay() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, @@ -3274,8 +3423,11 @@ function test(accounts, isRelativeDailyLimit) { blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ) + + const currentDay = await homeBridgeWithTwoSigs.getCurrentDay() const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' const balanceBefore = toBN(await web3.eth.getBalance(recipient)) const totalExecutedPerDayBefore = await homeBridgeWithTwoSigs.totalExecutedPerDay(currentDay) @@ -3326,16 +3478,17 @@ function test(accounts, isRelativeDailyLimit) { }) it('Home to Foreign: test decimal shift 2, no impact on UserRequestForSignature value', async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() await homeContract.initialize( validatorContract.address, - isRelativeDailyLimit ? [ether('0.05'), '10000', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], gasPrice, requireBlockConfirmations, blockRewardContract.address, [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ) const currentDay = await homeContract.getCurrentDay() @@ -3371,73 +3524,64 @@ function test(accounts, isRelativeDailyLimit) { logsSubmitSignature[1].event.should.be.equal('CollectedSignatures') }) }) - if (isRelativeDailyLimit) { - describe('#dailyLimit (relative)', () => { - let homeBridge + describe('#dailyLimit (relative)', () => { + let homeBridge - function initialize(customLimitsArray) { - return homeBridge.initialize( - validatorContract.address, - customLimitsArray, - gasPrice, - requireBlockConfirmations, - blockRewardContract.address, - [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], - owner, - decimalShiftZero - ).should.be.fulfilled - } + function initialize(customLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + relativeLimitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() - }) - it('should be calculated correctly - 1', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + beforeEach(async () => { + homeBridge = await HomeBridge.new() + }) + it('should be calculated correctly - 1', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await blockRewardContract.addMintedTotallyByBridge(halfEther, homeBridge.address) + await blockRewardContract.addMintedTotallyByBridge(halfEther, homeBridge.address) - const limit = await homeBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await blockRewardContract.addMintedTotallyByBridge(minPerTx, homeBridge.address) + await blockRewardContract.addMintedTotallyByBridge(minPerTx, homeBridge.address) - const limit = await homeBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(minPerTx) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(minPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await blockRewardContract.addMintedTotallyByBridge(threshold, homeBridge.address) + await blockRewardContract.addMintedTotallyByBridge(threshold, homeBridge.address) - const limit = await homeBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 4', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const minPerTx = ether('0.1') + const limit = await homeBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const minPerTx = ether('0.1') - await initialize([targetLimit, threshold, maxPerTx, minPerTx]) + await initialize([targetLimit, threshold, maxPerTx, minPerTx]) - await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeBridge.address) + await blockRewardContract.addMintedTotallyByBridge(amountToMint, homeBridge.address) - const limit = await homeBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await homeBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, minPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } -} - -contract('HomeBridge_ERC20_to_Native', async accounts => { - test(accounts, false) -}) - -contract('HomeBridge_ERC20_to_Native_RelativeDailyLimit', async accounts => { - test(accounts, true) + }) }) From 9f924cf4dfa2a51e770eae565b27b72e1fce0623 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 17 Dec 2019 18:36:02 +0300 Subject: [PATCH 69/80] fix foreign native-to-erc tests --- test/native_to_erc/foreign_bridge_test.js | 1157 +++++++++++---------- 1 file changed, 634 insertions(+), 523 deletions(-) diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index 1eed6aeb1..41cef859e 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -1,5 +1,4 @@ const ForeignBridge = artifacts.require('ForeignBridgeNativeToErc.sol') -const ForeignBridgeRelativeDailyLimit = artifacts.require('ForeignBridgeNativeToErcRelativeDailyLimit.sol') const ForeignBridgeV2 = artifacts.require('ForeignBridgeV2.sol') const HomeBridge = artifacts.require('HomeBridgeNativeToErc.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') @@ -8,8 +7,11 @@ const FeeManagerNativeToErc = artifacts.require('FeeManagerNativeToErc.sol') const RewardableValidators = artifacts.require('RewardableValidators.sol') const POA20 = artifacts.require('ERC677BridgeToken.sol') const NoReturnTransferTokenMock = artifacts.require('NoReturnTransferTokenMock.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, @@ -34,18 +36,18 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const ForeignBridgeContract = isRelativeDailyLimit ? ForeignBridgeRelativeDailyLimit : ForeignBridge - - const limitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, halfEther, minPerTx] - : [oneEther, halfEther, minPerTx] +contract('ForeignBridge_Native_to_ERC', async accounts => { + const limitsArray = [oneEther, halfEther, minPerTx] + const relativeLimitsArray = [targetLimit, threshold, halfEther, minPerTx] let validatorContract let authorities let owner let token let otherSideBridgeAddress + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() authorities = [accounts[1], accounts[2]] @@ -53,148 +55,174 @@ function test(accounts, isRelativeDailyLimit) { await validatorContract.initialize(1, authorities, owner) const otherSideBridge = await HomeBridge.new() otherSideBridgeAddress = otherSideBridge.address + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeDailyLimit.new() }) describe('#initialize', async () => { - it('should initialize', async () => { - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridge = await ForeignBridgeContract.new() - - expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.isInitialized()).to.be.equal(false) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) - if (!isRelativeDailyLimit) { - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) - } - - await foreignBridge - .initialize( - ZERO_ADDRESS, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - ZERO_ADDRESS, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( + const shouldInitialize = isRelativeDailyLimit => + async function() { + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + const foreignBridge = await ForeignBridge.new() + const requestLimits = isRelativeDailyLimit ? relativeLimitsArray : limitsArray + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract + + expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.isInitialized()).to.be.equal(false) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) + + await foreignBridge + .initialize( + ZERO_ADDRESS, + token.address, + requestLimits, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + ZERO_ADDRESS, + requestLimits, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requestLimits, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + ZERO_ADDRESS + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requestLimits, + 0, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + owner, + token.address, + requestLimits, + requireBlockConfirmations, + gasPrice, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + owner, + requestLimits, + requireBlockConfirmations, + gasPrice, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge + .initialize( + validatorContract.address, + token.address, + requestLimits, + gasPrice, + 0, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + limitsContract.address + ) + .should.be.rejectedWith(ERROR_MSG) + const { logs, tx } = await foreignBridge.initialize( validatorContract.address, token.address, - limitsArray, - 0, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - owner, - token.address, - limitsArray, - requireBlockConfirmations, + requestLimits, gasPrice, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - owner, - limitsArray, requireBlockConfirmations, - gasPrice, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, - decimalShiftZero, - otherSideBridgeAddress + '9', + otherSideBridgeAddress, + limitsContract.address ) - .should.be.rejectedWith(ERROR_MSG) - await foreignBridge - .initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - 0, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - .should.be.rejectedWith(ERROR_MSG) - const { logs } = await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - '9', - otherSideBridgeAddress - ) - - expect(await foreignBridge.isInitialized()).to.be.equal(true) - expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) - expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( - requireBlockConfirmations.toString() - ) - expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(halfEther) - expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) - expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') - const bridgeMode = '0x92a8d7fe' // 4 bytes of keccak256('native-to-erc-core') - expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) - if (!isRelativeDailyLimit) { - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) - } - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) - }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: homeDailyLimit }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: oneEther }) + expect(await foreignBridge.isInitialized()).to.be.equal(true) + expect(await foreignBridge.validatorContract()).to.be.equal(validatorContract.address) + expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.above(ZERO) + expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal( + requireBlockConfirmations.toString() + ) + expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) + expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(halfEther) + expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) + expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') + const bridgeMode = '0x92a8d7fe' // 4 bytes of keccak256('native-to-erc-core') + expect(await foreignBridge.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await foreignBridge.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + if (!isRelativeDailyLimit) { + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) + } + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: homeDailyLimit.toString() + }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: oneEther.toString() }) + } } - }) + it('should initialize', shouldInitialize(false)) + it('should initialize (relative limit)', shouldInitialize(true)) }) describe('#executeSignatures', async () => { let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) await foreignBridge.initialize( validatorContract.address, @@ -205,32 +233,52 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await token.transferOwnership(foreignBridge.address) }) - it('should allow to deposit', async () => { - const recipientAccount = accounts[3] - const balanceBefore = await token.balanceOf(recipientAccount) - const totalSupplyBefore = await token.totalSupply() - const value = ether('0.25') - const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' - const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) - false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - const event = logs.find(item => item.event === 'RelayedMessage') - event.args.recipient.should.be.equal(recipientAccount) - event.args.value.should.be.bignumber.equal(value) - event.args.transactionHash.should.be.equal(transactionHash) - - const balanceAfter = await token.balanceOf(recipientAccount) - const totalSupplyAfter = await token.totalSupply() - balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - totalSupplyAfter.should.be.bignumber.equal(totalSupplyBefore.add(value)) - true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) - }) + const shouldAllowToDeposit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.transferOwnership(foreignBridge.address) + + const recipientAccount = accounts[3] + const balanceBefore = await token.balanceOf(recipientAccount) + const totalSupplyBefore = await token.totalSupply() + const value = ether('0.25') + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + false.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + const event = logs.find(item => item.event === 'RelayedMessage') + event.args.recipient.should.be.equal(recipientAccount) + event.args.value.should.be.bignumber.equal(value) + event.args.transactionHash.should.be.equal(transactionHash) + + const balanceAfter = await token.balanceOf(recipientAccount) + const totalSupplyAfter = await token.totalSupply() + balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) + totalSupplyAfter.should.be.bignumber.equal(totalSupplyBefore.add(value)) + true.should.be.equal(await foreignBridge.relayedMessages(transactionHash)) + } + it('should allow to deposit', shouldAllowToDeposit(false)) + it('should allow to deposit (relative limit)', shouldAllowToDeposit(true)) it('should reject if address is not foreign address', async () => { const recipientAccount = accounts[3] const value = ether('0.25') @@ -289,42 +337,88 @@ function test(accounts, isRelativeDailyLimit) { await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.rejectedWith(ERROR_MSG) }) - it('should not allow withdraw over home max tx limit', async () => { - const recipientAccount = accounts[3] - const invalidValue = ether('0.75') + const shouldNotAllowWithdrawOverHomeMaxTxLimit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.transferOwnership(foreignBridge.address) - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + const recipientAccount = accounts[3] + const invalidValue = ether('0.75') - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) - }) + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, invalidValue, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - it('should not allow withdraw over daily home limit', async () => { - const recipientAccount = accounts[3] + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.rejectedWith(ERROR_MSG) + } - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) - const signature = await sign(authorities[0], message) - const vrs = signatureToVRS(signature) + it('should not allow withdraw over home max tx limit', shouldNotAllowWithdrawOverHomeMaxTxLimit(false)) + it( + 'should not allow withdraw over home max tx limit (relative limit)', + shouldNotAllowWithdrawOverHomeMaxTxLimit(true) + ) - await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + const shouldNotAllowWithdrawOverDailyHomeLimit = isRelativeDailyLimit => + async function() { + foreignBridge = await ForeignBridge.new() + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.transferOwnership(foreignBridge.address) - const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' - const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) - const signature2 = await sign(authorities[0], message2) - const vrs2 = signatureToVRS(signature2) + const recipientAccount = accounts[3] - await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) - const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' - const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) - const signature3 = await sign(authorities[0], message3) - const vrs3 = signatureToVRS(signature3) + await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled - await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) - }) + const transactionHash2 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' + const message2 = createMessage(recipientAccount, halfEther, transactionHash2, foreignBridge.address) + const signature2 = await sign(authorities[0], message2) + const vrs2 = signatureToVRS(signature2) + + await foreignBridge.executeSignatures([vrs2.v], [vrs2.r], [vrs2.s], message2).should.be.fulfilled + + const transactionHash3 = '0x022695428093bb292db8e48bd1417c5e1b84c0bf673bd0fff23ed0fb6495b872' + const message3 = createMessage(recipientAccount, halfEther, transactionHash3, foreignBridge.address) + const signature3 = await sign(authorities[0], message3) + const vrs3 = signatureToVRS(signature3) + + await foreignBridge.executeSignatures([vrs3.v], [vrs3.r], [vrs3.s], message3).should.be.rejectedWith(ERROR_MSG) + } + + it('should not allow withdraw over daily home limit', shouldNotAllowWithdrawOverDailyHomeLimit(false)) + it( + 'should not allow withdraw over daily home limit (relative limit)', + shouldNotAllowWithdrawOverDailyHomeLimit(true) + ) }) describe('#executeSignatures with 2 minimum signatures', async () => { @@ -340,7 +434,7 @@ function test(accounts, isRelativeDailyLimit) { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridgeContract.new() + foreignBridgeWithMultiSignatures = await ForeignBridge.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -351,6 +445,7 @@ function test(accounts, isRelativeDailyLimit) { owner, decimalShiftZero, otherSideBridgeAddress, + absoluteLimitsContract.address, { from: ownerOfValidatorContract } ) await token.transferOwnership(foreignBridgeWithMultiSignatures.address) @@ -403,7 +498,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await POA20.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -414,7 +509,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await erc20Token.transferOwnership(foreignBridgeWithThreeSigs.address) @@ -452,7 +548,7 @@ function test(accounts, isRelativeDailyLimit) { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await POA20.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -463,7 +559,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await erc20Token.transferOwnership(foreignBridgeWithThreeSigs.address) @@ -497,215 +594,229 @@ function test(accounts, isRelativeDailyLimit) { }) }) - describe('#onTokenTransfer', async () => { - it('can only be called from token contract', async () => { - const owner = accounts[3] - const user = accounts[4] - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.mint(user, halfEther, { from: owner }).should.be.fulfilled - await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) - await foreignBridge.onTokenTransfer(user, halfEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) - }) - it('should not allow to burn more than the limit', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueMoreThanLimit = halfEther.add(toBN(1)) - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() + const onTokenTransfer = isRelativeDailyLimit => + function() { + it('can only be called from token contract', async () => { + const owner = accounts[3] + const user = accounts[4] + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) + const foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) + await foreignBridge.onTokenTransfer(user, halfEther, '0x', { from: owner }).should.be.rejectedWith(ERROR_MSG) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) + }) + it('should not allow to burn more than the limit', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueMoreThanLimit = halfEther.add(toBN(1)) + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) + const foreignBridge = await ForeignBridge.new() + + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.mint(user, valueMoreThanLimit, { from: owner }).should.be.fulfilled - await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferOwnership(foreignBridge.address, { from: owner }) - await token.transferOwnership(foreignBridge.address, { from: owner }) + await token + .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) - await token - .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) + expect(await token.balanceOf(user)).to.be.bignumber.equal('1') - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) - expect(await token.balanceOf(user)).to.be.bignumber.equal('1') + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + }) + it('should only let to send within maxPerTx limit', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueMoreThanLimit = halfEther.add(toBN(1)) + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) + const foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, oneEther.add(toBN(1)), { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - }) - it('should only let to send within maxPerTx limit', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueMoreThanLimit = halfEther.add(toBN(1)) - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.mint(user, oneEther.add(toBN(1)), { from: owner }).should.be.fulfilled - await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) - await token.transferOwnership(foreignBridge.address, { from: owner }) + await token + .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) - await token - .transferAndCall(foreignBridge.address, valueMoreThanLimit, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) + const twoEther = oneEther.mul(toBN(2)) + twoEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) + oneEther.add(toBN(1)).should.be.bignumber.equal(await token.balanceOf(user)) - const twoEther = oneEther.mul(toBN(2)) - twoEther.add(toBN(1)).should.be.bignumber.equal(await token.totalSupply()) - oneEther.add(toBN(1)).should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) + valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) - valueMoreThanLimit.add(oneEther).should.be.bignumber.equal(await token.totalSupply()) - valueMoreThanLimit.should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled - await token.transferAndCall(foreignBridge.address, halfEther, '0x', { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) + expect(await token.balanceOf(user)).to.be.bignumber.equal('1') + await token.transferAndCall(foreignBridge.address, '1', '0x', { from: user }).should.be.rejectedWith(ERROR_MSG) + }) + it('should not let to withdraw less than minPerTx', async () => { + const owner = accounts[3] + const user = accounts[4] + const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) + const foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, oneEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther.add(toBN(1))) - expect(await token.balanceOf(user)).to.be.bignumber.equal('1') - await token.transferAndCall(foreignBridge.address, '1', '0x', { from: user }).should.be.rejectedWith(ERROR_MSG) - }) - it('should not let to withdraw less than minPerTx', async () => { - const owner = accounts[3] - const user = accounts[4] - const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.mint(user, oneEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) + await token + .transferAndCall(foreignBridge.address, valueLessThanMinPerTx, '0x', { from: user }) + .should.be.rejectedWith(ERROR_MSG) - await token - .transferAndCall(foreignBridge.address, valueLessThanMinPerTx, '0x', { from: user }) - .should.be.rejectedWith(ERROR_MSG) + oneEther.should.be.bignumber.equal(await token.totalSupply()) + oneEther.should.be.bignumber.equal(await token.balanceOf(user)) - oneEther.should.be.bignumber.equal(await token.totalSupply()) - oneEther.should.be.bignumber.equal(await token.balanceOf(user)) + await token.transferAndCall(foreignBridge.address, minPerTx, '0x', { from: user }).should.be.fulfilled - await token.transferAndCall(foreignBridge.address, minPerTx, '0x', { from: user }).should.be.fulfilled + oneEther.sub(minPerTx).should.be.bignumber.equal(await token.totalSupply()) + oneEther.sub(minPerTx).should.be.bignumber.equal(await token.balanceOf(user)) + }) + it('should be able to specify a different receiver', async () => { + const owner = accounts[3] + const user = accounts[4] + const user2 = accounts[5] + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) + const foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.mint(user, halfEther, { from: owner }).should.be.fulfilled + await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled + await token.transferOwnership(foreignBridge.address, { from: owner }) + await token + .transferAndCall(foreignBridge.address, halfEther, otherSideBridgeAddress, { from: user }) + .should.be.rejectedWith(ERROR_MSG) + await token + .transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }) + .should.be.rejectedWith(ERROR_MSG) + await token.transferAndCall(foreignBridge.address, halfEther, user2, { from: user }).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) + const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) + expect(events[0].returnValues.recipient).to.be.equal(user2) + expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) + }) + } - oneEther.sub(minPerTx).should.be.bignumber.equal(await token.totalSupply()) - oneEther.sub(minPerTx).should.be.bignumber.equal(await token.balanceOf(user)) - }) - it('should be able to specify a different receiver', async () => { - const owner = accounts[3] - const user = accounts[4] - const user2 = accounts[5] - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.mint(user, halfEther, { from: owner }).should.be.fulfilled - await token.mint(foreignBridge.address, oneEther, { from: owner }).should.be.fulfilled - await token.transferOwnership(foreignBridge.address, { from: owner }) - await token - .transferAndCall(foreignBridge.address, halfEther, otherSideBridgeAddress, { from: user }) - .should.be.rejectedWith(ERROR_MSG) - await token - .transferAndCall(foreignBridge.address, halfEther, '0x00', { from: user }) - .should.be.rejectedWith(ERROR_MSG) - await token.transferAndCall(foreignBridge.address, halfEther, user2, { from: user }).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) - const events = await getEvents(foreignBridge, { event: 'UserRequestForAffirmation' }) - expect(events[0].returnValues.recipient).to.be.equal(user2) - expect(toBN(events[0].returnValues.value)).to.be.bignumber.equal(halfEther) - }) - }) + describe('#onTokenTransfer', onTokenTransfer(false)) + describe('#onTokenTransfer (relative limit)', onTokenTransfer(true)) - describe('#setting limits', async () => { - let foreignBridge - beforeEach(async () => { - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - foreignBridge = await ForeignBridgeContract.new() - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.transferOwnership(foreignBridge.address) - }) - it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await foreignBridge.setMaxPerTx(halfEther, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.setMaxPerTx(halfEther, { from: owner }).should.be.fulfilled + const settingLimits = isRelativeDailyLimit => + function() { + let foreignBridge + beforeEach(async () => { + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + foreignBridge = await ForeignBridge.new() + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.transferOwnership(foreignBridge.address) + }) + it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await foreignBridge.setMaxPerTx(halfEther, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.setMaxPerTx(halfEther, { from: owner }).should.be.fulfilled - if (!isRelativeDailyLimit) { - await foreignBridge.setMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) - } - }) + if (!isRelativeDailyLimit) { + await foreignBridge.setMaxPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) + } + }) - it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { - await foreignBridge.setMinPerTx(minPerTx, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await foreignBridge.setMinPerTx(minPerTx, { from: owner }).should.be.fulfilled + it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { + await foreignBridge.setMinPerTx(minPerTx, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.setMinPerTx(minPerTx, { from: owner }).should.be.fulfilled - await foreignBridge.setMinPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - }) + await foreignBridge.setMinPerTx(oneEther, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + } + + describe('#setting limits', settingLimits(false)) + describe('#setting limits (relative limit)', settingLimits(true)) describe('#upgradeable', async () => { it('can be upgraded', async () => { @@ -715,8 +826,6 @@ function test(accounts, isRelativeDailyLimit) { const FOREIGN_DAILY_LIMIT = oneEther const FOREIGN_MAX_AMOUNT_PER_TX = halfEther const FOREIGN_MIN_AMOUNT_PER_TX = minPerTx - const TARGET_LIMIT = targetLimit - const THRESHOLD = threshold // Validators Contract let validatorsProxy = await EternalStorageProxy.new().should.be.fulfilled const validatorsContractImpl = await BridgeValidators.new().should.be.fulfilled @@ -731,22 +840,21 @@ function test(accounts, isRelativeDailyLimit) { // ForeignBridge V1 Contract let foreignBridgeProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridgeImpl = await ForeignBridgeContract.new().should.be.fulfilled + const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - foreignBridgeProxy = await ForeignBridgeContract.at(foreignBridgeProxy.address) + foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, token.address, - isRelativeDailyLimit - ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] - : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await token.transferOwnership(foreignBridgeProxy.address).should.be.fulfilled @@ -764,52 +872,48 @@ function test(accounts, isRelativeDailyLimit) { const FOREIGN_DAILY_LIMIT = '3' const FOREIGN_MAX_AMOUNT_PER_TX = '2' const FOREIGN_MIN_AMOUNT_PER_TX = '1' - const TARGET_LIMIT = '1' - const THRESHOLD = '2' const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.new() + const foreignBridge = await ForeignBridge.new() const data = foreignBridge.contract.methods .initialize( validatorsAddress, tokenAddress, - isRelativeDailyLimit - ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] - : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], + [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], gasPrice, requireBlockConfirmations, ['3', '2', '1'], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled - const finalContract = await ForeignBridgeContract.at(storageProxy.address) + const finalContract = await ForeignBridge.at(storageProxy.address) true.should.be.equal(await finalContract.isInitialized()) validatorsAddress.should.be.equal(await finalContract.validatorContract()) - if (!isRelativeDailyLimit) { - expect(await finalContract.dailyLimit()).to.be.bignumber.equal(FOREIGN_DAILY_LIMIT) - } + expect(await finalContract.dailyLimit()).to.be.bignumber.equal(FOREIGN_DAILY_LIMIT) expect(await finalContract.maxPerTx()).to.be.bignumber.equal(FOREIGN_MAX_AMOUNT_PER_TX) expect(await finalContract.minPerTx()).to.be.bignumber.equal(FOREIGN_MIN_AMOUNT_PER_TX) }) it('can transfer ownership', async () => { const token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridge = await ForeignBridgeContract.new() + const foreignBridge = await ForeignBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled const data = foreignBridge.contract.methods .initialize( validatorContract.address, token.address, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], gasPrice, requireBlockConfirmations, ['3', '2', '1'], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled @@ -818,46 +922,50 @@ function test(accounts, isRelativeDailyLimit) { }) describe('#claimTokens', async () => { - it('can send erc20', async () => { - const owner = accounts[0] - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridgeContract.new() - const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) - await foreignBridge.initialize( - validatorContract.address, - token.address, - limitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ) - await token.transferOwnership(foreignBridge.address) + const canSendErc20 = isRelativeDailyLimit => + async function() { + const owner = accounts[0] + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + const foreignBridgeImpl = await ForeignBridge.new() + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled + const foreignBridge = await ForeignBridge.at(storageProxy.address) + await foreignBridge.initialize( + validatorContract.address, + token.address, + isRelativeDailyLimit ? relativeLimitsArray : limitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await token.transferOwnership(foreignBridge.address) - const tokenSecond = await POA20.new('Roman Token', 'RST', 18) + const tokenSecond = await POA20.new('Roman Token', 'RST', 18) - await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - await tokenSecond.transfer(foreignBridge.address, halfEther) - expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + await tokenSecond.transfer(foreignBridge.address, halfEther) + expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) - expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) - expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) + await foreignBridge.claimTokens(tokenSecond.address, accounts[3], { from: owner }) + expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + } + it('can send erc20', canSendErc20(false)) + it('can send erc20 (relative limit)', canSendErc20(true)) it('also calls claimTokens on tokenAddress', async () => { const owner = accounts[0] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridgeContract.new() + const foreignBridgeImpl = await ForeignBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) + const foreignBridge = await ForeignBridge.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, @@ -867,7 +975,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await token.transferOwnership(foreignBridge.address) @@ -887,10 +996,10 @@ function test(accounts, isRelativeDailyLimit) { it('works with token that not return on transfer', async () => { const owner = accounts[0] token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - const foreignBridgeImpl = await ForeignBridgeContract.new() + const foreignBridgeImpl = await ForeignBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const foreignBridge = await ForeignBridgeContract.at(storageProxy.address) + const foreignBridge = await ForeignBridge.at(storageProxy.address) await foreignBridge.initialize( validatorContract.address, token.address, @@ -900,7 +1009,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) const tokenMock = await NoReturnTransferTokenMock.new() @@ -930,7 +1040,7 @@ function test(accounts, isRelativeDailyLimit) { token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() homeFee = ether('0.001') }) it('sets variables', async () => { @@ -939,11 +1049,7 @@ function test(accounts, isRelativeDailyLimit) { expect(await foreignBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.isInitialized()).to.be.equal(false) expect(await foreignBridge.requiredBlockConfirmations()).to.be.bignumber.equal(ZERO) - expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal(ZERO) - if (!isRelativeDailyLimit) { - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(ZERO) - } await foreignBridge .rewardableInitialize( @@ -957,7 +1063,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge @@ -972,7 +1079,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge @@ -987,7 +1095,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge @@ -1002,7 +1111,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge @@ -1017,7 +1127,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge @@ -1032,7 +1143,8 @@ function test(accounts, isRelativeDailyLimit) { ZERO_ADDRESS, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await foreignBridge.rewardableInitialize( @@ -1046,7 +1158,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, '9', - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled expect(await foreignBridge.isInitialized()).to.be.equal(true) @@ -1056,9 +1169,7 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations.toString() ) expect(await foreignBridge.gasPrice()).to.be.bignumber.equal(gasPrice) - if (!isRelativeDailyLimit) { - expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) - } + expect(await foreignBridge.dailyLimit()).to.be.bignumber.equal(oneEther) expect(await foreignBridge.maxPerTx()).to.be.bignumber.equal(halfEther) expect(await foreignBridge.minPerTx()).to.be.bignumber.equal(minPerTx) expect(await foreignBridge.decimalShift()).to.be.bignumber.equal('9') @@ -1086,7 +1197,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1112,7 +1224,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1137,7 +1250,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1171,7 +1285,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, homeFee, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled // Then @@ -1188,7 +1303,7 @@ function test(accounts, isRelativeDailyLimit) { feeManager = await FeeManagerNativeToErc.new() token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) rewardableValidators = await RewardableValidators.new() - foreignBridge = await ForeignBridgeContract.new() + foreignBridge = await ForeignBridge.new() }) it('should distribute fee to validator', async () => { const fee = 0.001 @@ -1214,7 +1329,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, feeInWei, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled await token.transferOwnership(foreignBridge.address) @@ -1273,7 +1389,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, feeInWei, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled await token.transferOwnership(foreignBridge.address) @@ -1360,7 +1477,8 @@ function test(accounts, isRelativeDailyLimit) { feeManager.address, feeInWei, decimalShiftZero, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ).should.be.fulfilled await token.transferOwnership(foreignBridge.address) @@ -1430,7 +1548,7 @@ function test(accounts, isRelativeDailyLimit) { const erc20Token = await POA20.new('Some ERC20', 'RSZT', 16) const valueOnForeign = toBN('1000') const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) - const foreignBridgeWithThreeSigs = await ForeignBridgeContract.new() + const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -1441,7 +1559,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await erc20Token.transferOwnership(foreignBridgeWithThreeSigs.address) @@ -1481,7 +1600,7 @@ function test(accounts, isRelativeDailyLimit) { const user = accounts[4] const value = halfEther token = await POA20.new('POA ERC20 Foundation', 'POA20', 16, { from: owner }) - const foreignBridge = await ForeignBridgeContract.new() + const foreignBridge = await ForeignBridge.new() await foreignBridge.initialize( validatorContract.address, token.address, @@ -1491,7 +1610,8 @@ function test(accounts, isRelativeDailyLimit) { [homeDailyLimit, homeMaxPerTx, homeMinPerTx], owner, decimalShiftTwo, - otherSideBridgeAddress + otherSideBridgeAddress, + absoluteLimitsContract.address ) await token.mint(user, value, { from: owner }).should.be.fulfilled await token.mint(foreignBridge.address, value, { from: owner }).should.be.fulfilled @@ -1503,82 +1623,73 @@ function test(accounts, isRelativeDailyLimit) { expect(await token.balanceOf(user)).to.be.bignumber.equal(ZERO) }) }) - if (isRelativeDailyLimit) { - describe('#dailyLimit (relative)', () => { - let token - let foreignBridge + describe('#dailyLimit (relative)', () => { + let token + let foreignBridge - function initialize(customLimitsArray) { - return foreignBridge.initialize( - validatorContract.address, - token.address, - customLimitsArray, - gasPrice, - requireBlockConfirmations, - [homeDailyLimit, homeMaxPerTx, homeMinPerTx], - owner, - decimalShiftZero, - otherSideBridgeAddress - ).should.be.fulfilled - } + function initialize(customLimitsArray) { + return foreignBridge.initialize( + validatorContract.address, + token.address, + customLimitsArray, + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + decimalShiftZero, + otherSideBridgeAddress, + relativeLimitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) - foreignBridge = await ForeignBridgeContract.new() - }) - it('should be calculated correctly - 1', async () => { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + beforeEach(async () => { + token = await POA20.new('POA ERC20 Foundation', 'POA20', 18) + foreignBridge = await ForeignBridge.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(accounts[0], halfEther).should.be.fulfilled - await token.mint(foreignBridge.address, halfEther).should.be.fulfilled - expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) - expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) + await token.mint(accounts[0], halfEther).should.be.fulfilled + await token.mint(foreignBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await token.totalSupply()).to.be.bignumber.equal(oneEther) - const limit = await foreignBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(oneEther, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(homeMinPerTx) + await token.mint(foreignBridge.address, homeMinPerTx).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(homeMinPerTx) - const limit = await foreignBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(homeMinPerTx) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + const limit = await foreignBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(homeMinPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, threshold).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(threshold) + await token.mint(foreignBridge.address, threshold).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(threshold) - const limit = await foreignBridge.dailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 4', async function() { - const amountToMint = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const homeMinPerTx = ether('0.1') + const limit = await foreignBridge.dailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToMint = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const homeMinPerTx = ether('0.1') - await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) + await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) - await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled - expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) + await token.mint(foreignBridge.address, amountToMint).should.be.fulfilled + expect(await token.totalSupply()).to.be.bignumber.equal(amountToMint) - const limit = await foreignBridge.dailyLimit() - const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await foreignBridge.dailyLimit() + const expectedLimit = calculateDailyLimit(amountToMint, targetLimit, threshold, homeMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } -} - -contract('ForeignBridge_Native_to_ERC', async accounts => { - test(accounts, false) -}) - -contract('ForeignBridge_Native_to_ERC_RelativeDailyLimit', async accounts => { - test(accounts, true) + }) }) From 18040de9dc4f0ec8b1ebda22edcb2bf1a2813a67 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 17 Dec 2019 19:59:34 +0300 Subject: [PATCH 70/80] fix home native-to-erc tests --- test/native_to_erc/home_bridge_test.js | 1223 +++++++++++++----------- 1 file changed, 670 insertions(+), 553 deletions(-) diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index 51cefbefe..1c5db8c1b 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -1,5 +1,4 @@ const HomeBridge = artifacts.require('HomeBridgeNativeToErc.sol') -const HomeBridgeRelativeDailyLimit = artifacts.require('HomeBridgeNativeToErcRelativeDailyLimit.sol') const EternalStorageProxy = artifacts.require('EternalStorageProxy.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') const RevertFallback = artifacts.require('RevertFallback.sol') @@ -8,8 +7,11 @@ const FeeManagerNativeToErcBothDirections = artifacts.require('FeeManagerNativeT const RewardableValidators = artifacts.require('RewardableValidators.sol') const ERC677BridgeToken = artifacts.require('ERC677BridgeToken.sol') const NoReturnTransferTokenMock = artifacts.require('NoReturnTransferTokenMock.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') +const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') const { expect } = require('chai') +const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') @@ -27,70 +29,80 @@ const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') -function test(accounts, isRelativeDailyLimit) { - const HomeBridgeContract = isRelativeDailyLimit ? HomeBridgeRelativeDailyLimit : HomeBridge - - const executionLimitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx] - : [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx] +contract('HomeBridge_Native_to_ERC', async accounts => { + const executionLimitsArray = [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx] + const relativeExecutionLimitsArray = [targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx] let homeContract let validatorContract let authorities let owner + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() authorities = [accounts[1]] owner = accounts[0] await validatorContract.initialize(1, authorities, owner) + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeExecutionDailyLimit.new() }) describe('#initialize', async () => { beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() }) - it('sets variables', async () => { - expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) - expect(await homeContract.maxPerTx()).to.be.bignumber.equal(ZERO) - expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) - expect(await homeContract.isInitialized()).to.be.equal(false) - - const { logs } = await homeContract.initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - executionLimitsArray, - owner, - '9' - ).should.be.fulfilled + const setsVariables = isRelativeDailyLimit => + async function() { + expect(await homeContract.validatorContract()).to.be.equal(ZERO_ADDRESS) + expect(await homeContract.limitsContract()).to.be.equal(ZERO_ADDRESS) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.equal(ZERO) + expect(await homeContract.decimalShift()).to.be.bignumber.equal(ZERO) + expect(await homeContract.isInitialized()).to.be.equal(false) - expect(await homeContract.isInitialized()).to.be.equal(true) - expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) - expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') - expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') - expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') - expect(await homeContract.gasPrice()).to.be.bignumber.equal(gasPrice) - expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') - const bridgeMode = '0x92a8d7fe' // 4 bytes of keccak256('native-to-erc-core') - expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) - const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() - expect(major).to.be.bignumber.gte(ZERO) - expect(minor).to.be.bignumber.gte(ZERO) - expect(patch).to.be.bignumber.gte(ZERO) + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract - expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { - requiredBlockConfirmations: toBN(requireBlockConfirmations) - }) - expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) - if (!isRelativeDailyLimit) { - expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: foreignDailyLimit }) + const { logs, tx } = await homeContract.initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + '9', + limitsContract.address + ).should.be.fulfilled + + expect(await homeContract.isInitialized()).to.be.equal(true) + expect(await homeContract.validatorContract()).to.be.equal(validatorContract.address) + expect(await homeContract.limitsContract()).to.be.equal(limitsContract.address) + expect(await homeContract.deployedAtBlock()).to.be.bignumber.above(ZERO) + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('3') + expect(await homeContract.maxPerTx()).to.be.bignumber.equal('2') + expect(await homeContract.minPerTx()).to.be.bignumber.equal('1') + expect(await homeContract.gasPrice()).to.be.bignumber.equal(gasPrice) + expect(await homeContract.decimalShift()).to.be.bignumber.equal('9') + const bridgeMode = '0x92a8d7fe' // 4 bytes of keccak256('native-to-erc-core') + expect(await homeContract.getBridgeMode()).to.be.equal(bridgeMode) + const { major, minor, patch } = await homeContract.getBridgeInterfacesVersion() + expect(major).to.be.bignumber.gte(ZERO) + expect(minor).to.be.bignumber.gte(ZERO) + expect(patch).to.be.bignumber.gte(ZERO) + + expectEventInLogs(logs, 'RequiredBlockConfirmationChanged', { + requiredBlockConfirmations: toBN(requireBlockConfirmations) + }) + expectEventInLogs(logs, 'GasPriceChanged', { gasPrice }) + await expectEvent.inTransaction(tx, limitsContract, 'DailyLimitChanged', { newLimit: '3' }) + if (!isRelativeDailyLimit) { + await expectEvent.inTransaction(tx, limitsContract, 'ExecutionDailyLimitChanged', { + newLimit: foreignDailyLimit.toString() + }) + } } - expectEventInLogs(logs, 'DailyLimitChanged', { newLimit: '3' }) - }) + it('sets variables', setsVariables(false)) + it('sets variables (relative limit)', setsVariables(true)) it('cant set maxPerTx > dailyLimit', async () => { false.should.be.equal(await homeContract.isInitialized()) await homeContract @@ -101,7 +113,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -112,7 +125,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) false.should.be.equal(await homeContract.isInitialized()) @@ -126,7 +140,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeContract.gasPrice()).to.be.bignumber.equal(gasPrice) @@ -151,7 +166,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeContract.requiredBlockConfirmations()).to.be.bignumber.equal(toBN(requireBlockConfirmations)) @@ -179,15 +195,16 @@ function test(accounts, isRelativeDailyLimit) { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeTo('1', accounts[5]).should.be.rejectedWith(ERROR_MSG) await storageProxy.upgradeToAndCall('1', accounts[5], data).should.be.rejectedWith(ERROR_MSG) await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const finalContract = await HomeBridgeContract.at(storageProxy.address) + const finalContract = await HomeBridge.at(storageProxy.address) expect(await finalContract.isInitialized()).to.be.equal(true) expect(await finalContract.validatorContract()).to.be.equal(validatorContract.address) @@ -205,7 +222,8 @@ function test(accounts, isRelativeDailyLimit) { 0, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -216,7 +234,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract @@ -227,7 +246,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeContract.initialize( @@ -237,7 +257,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled true.should.be.equal(await homeContract.isInitialized()) }) @@ -250,7 +271,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeContract.owner()).to.be.equal(owner) @@ -274,9 +296,10 @@ function test(accounts, isRelativeDailyLimit) { ['3', '2', '1'], gasPrice, requireBlockConfirmations, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + ['3', '2', '1'], owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled @@ -286,233 +309,247 @@ function test(accounts, isRelativeDailyLimit) { }) }) - describe('#fallback', async () => { - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - executionLimitsArray, - owner, - decimalShiftZero - ) - }) - it('should accept native coins', async () => { - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - - const { logs } = await homeContract.sendTransaction({ - from: accounts[1], - value: 1 - }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - - expectEventInLogs(logs, 'UserRequestForSignature', { recipient: accounts[1], value: toBN(1) }) + const fallback = isRelativeDailyLimit => + function() { + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) + it('should accept native coins', async () => { + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) - await homeContract - .sendTransaction({ + const { logs } = await homeContract.sendTransaction({ from: accounts[1], - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) + value: 1 + }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.sendTransaction({ - from: accounts[1], - value: 1 - }).should.be.fulfilled + expectEventInLogs(logs, 'UserRequestForSignature', { recipient: accounts[1], value: toBN(1) }) - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') - }) + await homeContract + .sendTransaction({ + from: accounts[1], + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) - it('doesnt let you send more than max amount per tx', async () => { - await homeContract.sendTransaction({ - from: accounts[1], - value: 1 - }).should.be.fulfilled - await homeContract - .sendTransaction({ - from: accounts[1], - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled - await homeContract.setMaxPerTx(99).should.be.fulfilled - // meets max per tx and daily limit - await homeContract.sendTransaction({ - from: accounts[1], - value: 99 - }).should.be.fulfilled - // above daily limit - await homeContract - .sendTransaction({ + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.sendTransaction({ from: accounts[1], value: 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) + }).should.be.fulfilled - it('should not let to deposit less than minPerTx', async () => { - const newDailyLimit = 100 - const newMaxPerTx = 50 - const newMinPerTx = 20 - await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled - await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled - await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') + }) - await homeContract.sendTransaction({ - from: accounts[1], - value: newMinPerTx - }).should.be.fulfilled - await homeContract - .sendTransaction({ + it('doesnt let you send more than max amount per tx', async () => { + await homeContract.sendTransaction({ from: accounts[1], - value: newMinPerTx - 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) - }) + value: 1 + }).should.be.fulfilled + await homeContract + .sendTransaction({ + from: accounts[1], + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + await homeContract.setMaxPerTx(99).should.be.fulfilled + // meets max per tx and daily limit + await homeContract.sendTransaction({ + from: accounts[1], + value: 99 + }).should.be.fulfilled + // above daily limit + await homeContract + .sendTransaction({ + from: accounts[1], + value: 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) - describe('#relayTokens', async () => { - const user = accounts[1] - const user2 = accounts[2] - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - executionLimitsArray, - owner, - decimalShiftZero - ) - }) - it('should accept native coins and alternative receiver', async () => { - const currentDay = await homeContract.getCurrentDay() - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + it('should not let to deposit less than minPerTx', async () => { + const newDailyLimit = 100 + const newMaxPerTx = 50 + const newMinPerTx = 20 + await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled + await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled - const { logs } = await homeContract.relayTokens(user2, { - from: user, - value: 1 - }).should.be.fulfilled - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') + await homeContract.sendTransaction({ + from: accounts[1], + value: newMinPerTx + }).should.be.fulfilled + await homeContract + .sendTransaction({ + from: accounts[1], + value: newMinPerTx - 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) + } - expectEventInLogs(logs, 'UserRequestForSignature', { recipient: user2, value: toBN(1) }) + describe('#fallback', fallback(false)) + describe('#fallback (relative limit)', fallback(true)) - await homeContract - .relayTokens(user2, { + const relayTokens = isRelativeDailyLimit => + function() { + const user = accounts[1] + const user2 = accounts[2] + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) + it('should accept native coins and alternative receiver', async () => { + const currentDay = await homeContract.getCurrentDay() + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + const { logs } = await homeContract.relayTokens(user2, { from: user, - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) + value: 1 + }).should.be.fulfilled + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('1') - await homeContract.setDailyLimit(4).should.be.fulfilled - await homeContract.relayTokens(user2, { - from: user, - value: 1 - }).should.be.fulfilled + expectEventInLogs(logs, 'UserRequestForSignature', { recipient: user2, value: toBN(1) }) - expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') - }) + await homeContract + .relayTokens(user2, { + from: user, + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) - it('doesnt let you send more than max amount per tx', async () => { - await homeContract.relayTokens(user2, { - from: user, - value: 1 - }).should.be.fulfilled - await homeContract - .relayTokens(user2, { + await homeContract.setDailyLimit(4).should.be.fulfilled + await homeContract.relayTokens(user2, { from: user, - value: 3 - }) - .should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(100).should.be.fulfilled - await homeContract.setMaxPerTx(99).should.be.fulfilled - // meets max per tx and daily limit - await homeContract.relayTokens(user2, { - from: user, - value: 99 - }).should.be.fulfilled - // above daily limit - await homeContract - .relayTokens(user2, { + value: 1 + }).should.be.fulfilled + + expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') + }) + + it('doesnt let you send more than max amount per tx', async () => { + await homeContract.relayTokens(user2, { from: user, value: 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) + }).should.be.fulfilled + await homeContract + .relayTokens(user2, { + from: user, + value: 3 + }) + .should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(100).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(100).should.be.fulfilled + await homeContract.setMaxPerTx(99).should.be.fulfilled + // meets max per tx and daily limit + await homeContract.relayTokens(user2, { + from: user, + value: 99 + }).should.be.fulfilled + // above daily limit + await homeContract + .relayTokens(user2, { + from: user, + value: 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) - it('should not let to deposit less than minPerTx', async () => { - const newDailyLimit = 100 - const newMaxPerTx = 50 - const newMinPerTx = 20 - await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled - await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled - await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled + it('should not let to deposit less than minPerTx', async () => { + const newDailyLimit = 100 + const newMaxPerTx = 50 + const newMinPerTx = 20 + await homeContract.setDailyLimit(newDailyLimit).should.be.fulfilled + await homeContract.setMaxPerTx(newMaxPerTx).should.be.fulfilled + await homeContract.setMinPerTx(newMinPerTx).should.be.fulfilled - await homeContract.relayTokens(user2, { - from: user, - value: newMinPerTx - }).should.be.fulfilled - await homeContract - .relayTokens(user2, { + await homeContract.relayTokens(user2, { from: user, - value: newMinPerTx - 1 - }) - .should.be.rejectedWith(ERROR_MSG) - }) - }) + value: newMinPerTx + }).should.be.fulfilled + await homeContract + .relayTokens(user2, { + from: user, + value: newMinPerTx - 1 + }) + .should.be.rejectedWith(ERROR_MSG) + }) + } - describe('#setting limits', async () => { - let homeContract - beforeEach(async () => { - homeContract = await HomeBridgeContract.new() - await homeContract.initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - executionLimitsArray, - owner, - decimalShiftZero - ) - }) - it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { - await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled + describe('#relayTokens', relayTokens(false)) + describe('#relayTokens (relative limit)', relayTokens(true)) - await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { - await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled + const settingLimits = isRelativeDailyLimit => + function() { + let homeContract + beforeEach(async () => { + homeContract = await HomeBridge.new() + await homeContract.initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + }) + it('#setMaxPerTx allows to set only to owner and cannot be more than daily limit', async () => { + await homeContract.setMaxPerTx(2, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(2, { from: owner }).should.be.fulfilled - await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - }) - it('#setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { - await homeContract.setDailyLimit(4, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMaxPerTx(3, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('#setMinPerTx allows to set only to owner and cannot be more than daily limit and should be less than maxPerTx', async () => { + await homeContract.setMinPerTx(1, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setMinPerTx(1, { from: owner }).should.be.fulfilled - await homeContract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('4') + await homeContract.setMinPerTx(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) + }) + it('#setDailyLimit allow to set by owner and should be greater than maxPerTx or zero', async () => { + await homeContract.setDailyLimit(4, { from: authorities[0] }).should.be.rejectedWith(ERROR_MSG) + await homeContract.setDailyLimit(2, { from: owner }).should.be.rejectedWith(ERROR_MSG) - await homeContract.setDailyLimit(0, { from: owner }).should.be.fulfilled - expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) + await homeContract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('4') - await homeContract.setDailyLimit(4, { from: owner }).should.be.fulfilled - expect(await homeContract.dailyLimit()).to.be.bignumber.equal('4') - }) - }) + await homeContract.setDailyLimit(0, { from: owner }).should.be.fulfilled + expect(await homeContract.dailyLimit()).to.be.bignumber.equal(ZERO) + + await homeContract.setDailyLimit(4, { from: owner }).should.be.fulfilled + expect(await homeContract.dailyLimit()).to.be.bignumber.equal('4') + }) + } + describe('#setting limits', settingLimits(false)) + describe('#setting limits (relative limit)', settingLimits(true)) describe('#executeAffirmation', async () => { let homeBridge beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, [twoEther, halfEther, minPerTx], @@ -520,42 +557,62 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled }) - it('should allow validator to executeAffirmation', async () => { - const recipient = accounts[5] - const value = halfEther - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }) - - const balanceBefore = toBN(await web3.eth.getBalance(recipient)) - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { - from: authorities[0] - }) - - expectEventInLogs(logs, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash - }) - expectEventInLogs(logs, 'AffirmationCompleted', { - recipient, - value, - transactionHash - }) - const homeBalanceAfter = toBN(await web3.eth.getBalance(homeBridge.address)) - const balanceAfter = toBN(await web3.eth.getBalance(recipient)) - balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) - homeBalanceAfter.should.be.bignumber.equal(halfEther) + const shouldAllowValidatorToExecuteAffirmation = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + [twoEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await homeBridge.sendTransaction({ + from: accounts[2], + value: halfEther + }).should.be.fulfilled + + const recipient = accounts[5] + const value = halfEther + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }) + + const balanceBefore = toBN(await web3.eth.getBalance(recipient)) + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: authorities[0] + }) - const msgHash = web3.utils.soliditySha3(recipient, value, transactionHash) - const senderHash = web3.utils.soliditySha3(authorities[0], msgHash) - true.should.be.equal(await homeBridge.affirmationsSigned(senderHash)) - }) + expectEventInLogs(logs, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash + }) + expectEventInLogs(logs, 'AffirmationCompleted', { + recipient, + value, + transactionHash + }) + const homeBalanceAfter = toBN(await web3.eth.getBalance(homeBridge.address)) + const balanceAfter = toBN(await web3.eth.getBalance(recipient)) + balanceAfter.should.be.bignumber.equal(balanceBefore.add(value)) + homeBalanceAfter.should.be.bignumber.equal(halfEther) + + const msgHash = web3.utils.soliditySha3(recipient, value, transactionHash) + const senderHash = web3.utils.soliditySha3(authorities[0], msgHash) + true.should.be.equal(await homeBridge.affirmationsSigned(senderHash)) + } + it('should allow validator to executeAffirmation', shouldAllowValidatorToExecuteAffirmation(false)) + it('should allow validator to executeAffirmation (relative limit)', shouldAllowValidatorToExecuteAffirmation(true)) it('should allow validator to executeAffirmation with zero value', async () => { const recipient = accounts[5] @@ -589,7 +646,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, [twoEther, ether('1.5'), minPerTx], @@ -597,7 +654,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await homeBridgeWithTwoSigs.sendTransaction({ @@ -677,7 +735,7 @@ function test(accounts, isRelativeDailyLimit) { const authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] const ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - const homeBridgeWithTwoSigs = await HomeBridgeContract.new() + const homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, [oneEther, halfEther, minPerTx], @@ -685,7 +743,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) await homeBridgeWithTwoSigs.sendTransaction({ @@ -753,7 +812,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], @@ -761,7 +820,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const value = halfEther @@ -797,61 +857,111 @@ function test(accounts, isRelativeDailyLimit) { transactionHash }) }) - it('should not allow execute affirmation over foreign max tx limit', async () => { - const recipient = accounts[5] - const value = oneEther - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - - await homeBridge - .executeAffirmation(recipient, value, transactionHash, { from: authorities[0] }) - .should.be.rejectedWith(ERROR_MSG) - }) - it('should not allow execute affirmation over daily foreign limit', async () => { - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled - - const recipient = accounts[5] - const value = halfEther - const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' - const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { - from: authorities[0] - }).should.be.fulfilled - - expectEventInLogs(logs, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash - }) - expectEventInLogs(logs, 'AffirmationCompleted', { - recipient, - value, - transactionHash - }) + const shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + [twoEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await homeBridge.sendTransaction({ + from: accounts[2], + value: halfEther + }).should.be.fulfilled + + const recipient = accounts[5] + const value = oneEther + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + await homeBridge + .executeAffirmation(recipient, value, transactionHash, { from: authorities[0] }) + .should.be.rejectedWith(ERROR_MSG) + } + it( + 'should not allow execute affirmation over foreign max tx limit', + shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit(false) + ) + it( + 'should not allow execute affirmation over foreign max tx limit (relative limit)', + shouldNotAllowExecuteAffirmationOverForeignMaxTxLimit(true) + ) + const shouldNotAllowExecuteAffirmationOverDailyForeignLimit = isRelativeDailyLimit => + async function() { + homeBridge = await HomeBridge.new() + await homeBridge.initialize( + validatorContract.address, + [twoEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + await homeBridge.sendTransaction({ + from: accounts[2], + value: halfEther + }).should.be.fulfilled + + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled + + const recipient = accounts[5] + const value = halfEther + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: authorities[0] + }).should.be.fulfilled + + expectEventInLogs(logs, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash + }) + expectEventInLogs(logs, 'AffirmationCompleted', { + recipient, + value, + transactionHash + }) - const transactionHash2 = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' - const { logs: logs2 } = await homeBridge.executeAffirmation(recipient, value, transactionHash2, { - from: authorities[0] - }).should.be.fulfilled + const transactionHash2 = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' + const { logs: logs2 } = await homeBridge.executeAffirmation(recipient, value, transactionHash2, { + from: authorities[0] + }).should.be.fulfilled - expectEventInLogs(logs2, 'SignedForAffirmation', { - signer: authorities[0], - transactionHash: transactionHash2 - }) - expectEventInLogs(logs2, 'AffirmationCompleted', { - recipient, - value, - transactionHash: transactionHash2 - }) + expectEventInLogs(logs2, 'SignedForAffirmation', { + signer: authorities[0], + transactionHash: transactionHash2 + }) + expectEventInLogs(logs2, 'AffirmationCompleted', { + recipient, + value, + transactionHash: transactionHash2 + }) - const transactionHash3 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' - await homeBridge - .executeAffirmation(recipient, value, transactionHash3, { from: authorities[0] }) - .should.be.rejectedWith(ERROR_MSG) - }) + const transactionHash3 = '0x69debd8fd1923c9cb3cd8ef6461e2740b2d037943b941729d5a47671a2bb8712' + await homeBridge + .executeAffirmation(recipient, value, transactionHash3, { from: authorities[0] }) + .should.be.rejectedWith(ERROR_MSG) + } + it( + 'should not allow execute affirmation over daily foreign limit', + shouldNotAllowExecuteAffirmationOverDailyForeignLimit(false) + ) + it( + 'should not allow execute affirmation over daily foreign limit (relative limit)', + shouldNotAllowExecuteAffirmationOverDailyForeignLimit(true) + ) }) describe('#isAlreadyProcessed', async () => { it('returns ', async () => { - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const bn = toBN(2).pow(toBN(255)) const processedNumbers = [bn.add(toBN(1)).toString(10), bn.add(toBN(100)).toString(10)] true.should.be.equal(await homeBridge.isAlreadyProcessed(processedNumbers[0])) @@ -870,7 +980,7 @@ function test(accounts, isRelativeDailyLimit) { authoritiesThreeAccs = [accounts[1], accounts[2], accounts[3]] ownerOfValidators = accounts[0] await validatorContractWith2Signatures.initialize(2, authoritiesThreeAccs, ownerOfValidators) - homeBridgeWithTwoSigs = await HomeBridgeContract.new() + homeBridgeWithTwoSigs = await HomeBridge.new() await homeBridgeWithTwoSigs.initialize( validatorContractWith2Signatures.address, [oneEther, halfEther, minPerTx], @@ -878,7 +988,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) }) it('allows a validator to submit a signature', async () => { @@ -930,7 +1041,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], @@ -938,7 +1049,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) const value = halfEther @@ -1022,7 +1134,7 @@ function test(accounts, isRelativeDailyLimit) { describe('#requiredMessageLength', async () => { beforeEach(async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() }) it('should return the required message length', async () => { @@ -1030,93 +1142,99 @@ function test(accounts, isRelativeDailyLimit) { }) }) - describe('#claimTokens', () => { - it('should work with token that return bool on transfer', async () => { - const storageProxy = await EternalStorageProxy.new() - const data = homeContract.contract.methods - .initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], - owner, - decimalShiftZero - ) - .encodeABI() - await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) - - const token = await ERC677BridgeToken.new('Test', 'TST', 18) - - await token.mint(accounts[0], halfEther).should.be.fulfilled - expect(await token.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - - await token.transfer(homeBridge.address, halfEther).should.be.fulfilled - expect(await token.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) - - await homeBridge.claimTokens(token.address, accounts[3], { from: owner }).should.be.fulfilled - expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(ZERO) - expect(await token.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) - it('should works with token that not return on transfer', async () => { - const storageProxy = await EternalStorageProxy.new() - const data = homeContract.contract.methods - .initialize( - validatorContract.address, - ['3', '2', '1'], - gasPrice, - requireBlockConfirmations, - isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], - owner, - decimalShiftZero - ) - .encodeABI() - await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) - - const tokenMock = await NoReturnTransferTokenMock.new() - - await tokenMock.mint(accounts[0], halfEther).should.be.fulfilled - expect(await tokenMock.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) - - await tokenMock.transfer(homeBridge.address, halfEther).should.be.fulfilled - expect(await tokenMock.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) - expect(await tokenMock.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) - - await homeBridge.claimTokens(tokenMock.address, accounts[3], { from: owner }).should.be.fulfilled - expect(await tokenMock.balanceOf(homeBridge.address)).to.be.bignumber.equal(ZERO) - expect(await tokenMock.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) - }) - it('should work for native coins', async () => { - const storageProxy = await EternalStorageProxy.new() - const data = homeContract.contract.methods - .initialize( - validatorContract.address, - [oneEther.toString(), halfEther.toString(), '1'], - gasPrice, - requireBlockConfirmations, - isRelativeDailyLimit - ? [targetLimit.toString(), threshold.toString(), halfEther.toString(), '1'] - : [oneEther.toString(), halfEther.toString(), '1'], - owner, - decimalShiftZero - ) - .encodeABI() - await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled - const homeBridge = await HomeBridgeContract.at(storageProxy.address) - - const balanceBefore = toBN(await web3.eth.getBalance(accounts[3])) - - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(halfEther) + const claimTokens = isRelativeDailyLimit => + function() { + it('should work with token that return bool on transfer', async () => { + const storageProxy = await EternalStorageProxy.new() + const data = homeContract.contract.methods + .initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + .encodeABI() + await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled + const homeBridge = await HomeBridge.at(storageProxy.address) + + const token = await ERC677BridgeToken.new('Test', 'TST', 18) + + await token.mint(accounts[0], halfEther).should.be.fulfilled + expect(await token.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + + await token.transfer(homeBridge.address, halfEther).should.be.fulfilled + expect(await token.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) + + await homeBridge.claimTokens(token.address, accounts[3], { from: owner }).should.be.fulfilled + expect(await token.balanceOf(homeBridge.address)).to.be.bignumber.equal(ZERO) + expect(await token.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + }) + it('should works with token that not return on transfer', async () => { + const storageProxy = await EternalStorageProxy.new() + const data = homeContract.contract.methods + .initialize( + validatorContract.address, + ['3', '2', '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit ? ['1', '3', '2', '1'] : ['3', '2', '1'], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + .encodeABI() + await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled + const homeBridge = await HomeBridge.at(storageProxy.address) + + const tokenMock = await NoReturnTransferTokenMock.new() + + await tokenMock.mint(accounts[0], halfEther).should.be.fulfilled + expect(await tokenMock.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther) + + await tokenMock.transfer(homeBridge.address, halfEther).should.be.fulfilled + expect(await tokenMock.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO) + expect(await tokenMock.balanceOf(homeBridge.address)).to.be.bignumber.equal(halfEther) + + await homeBridge.claimTokens(tokenMock.address, accounts[3], { from: owner }).should.be.fulfilled + expect(await tokenMock.balanceOf(homeBridge.address)).to.be.bignumber.equal(ZERO) + expect(await tokenMock.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + }) + it('should work for native coins', async () => { + const storageProxy = await EternalStorageProxy.new() + const data = homeContract.contract.methods + .initialize( + validatorContract.address, + [oneEther.toString(), halfEther.toString(), '1'], + gasPrice, + requireBlockConfirmations, + isRelativeDailyLimit + ? [targetLimit.toString(), threshold.toString(), halfEther.toString(), '1'] + : [oneEther.toString(), halfEther.toString(), '1'], + owner, + decimalShiftZero, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address + ) + .encodeABI() + await storageProxy.upgradeToAndCall('1', homeContract.address, data).should.be.fulfilled + const homeBridge = await HomeBridge.at(storageProxy.address) + + const balanceBefore = toBN(await web3.eth.getBalance(accounts[3])) + + await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(halfEther) - await homeBridge.claimTokens(ZERO_ADDRESS, accounts[3], { from: owner }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(ZERO) - expect(toBN(await web3.eth.getBalance(accounts[3]))).to.be.bignumber.equal(balanceBefore.add(halfEther)) - }) - }) + await homeBridge.claimTokens(ZERO_ADDRESS, accounts[3], { from: owner }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(ZERO) + expect(toBN(await web3.eth.getBalance(accounts[3]))).to.be.bignumber.equal(balanceBefore.add(halfEther)) + }) + } + describe('#claimTokens', claimTokens(false)) + describe('#claimTokens (relative limit)', claimTokens(true)) describe('#rewardableInitialize', async () => { let homeFee @@ -1129,7 +1247,7 @@ function test(accounts, isRelativeDailyLimit) { beforeEach(async () => { rewardableValidators = await RewardableValidators.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled - homeBridge = await HomeBridgeContract.new() + homeBridge = await HomeBridge.new() homeFee = ZERO foreignFee = ether('0.002') }) @@ -1137,8 +1255,6 @@ function test(accounts, isRelativeDailyLimit) { const feeManager = await FeeManagerNativeToErc.new() expect(await homeBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) expect(await homeBridge.deployedAtBlock()).to.be.bignumber.equal(ZERO) - expect(await homeBridge.dailyLimit()).to.be.bignumber.equal(ZERO) - expect(await homeBridge.maxPerTx()).to.be.bignumber.equal(ZERO) expect(await homeBridge.isInitialized()).to.be.equal(false) await homeBridge @@ -1151,7 +1267,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeBridge @@ -1164,7 +1281,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeBridge @@ -1177,7 +1295,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeBridge @@ -1190,7 +1309,8 @@ function test(accounts, isRelativeDailyLimit) { owner, ZERO_ADDRESS, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ) .should.be.rejectedWith(ERROR_MSG) await homeBridge.rewardableInitialize( @@ -1202,7 +1322,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled expect(await homeBridge.isInitialized()).to.be.equal(true) @@ -1236,7 +1357,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1261,7 +1383,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1285,7 +1408,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Given @@ -1316,7 +1440,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Then @@ -1338,7 +1463,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [homeFee, foreignFee], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // Then @@ -1356,7 +1482,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1378,7 +1504,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // When @@ -1405,7 +1532,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1427,7 +1554,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // When @@ -1453,7 +1581,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1477,7 +1605,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ @@ -1511,7 +1640,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1537,7 +1666,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -1599,7 +1729,7 @@ function test(accounts, isRelativeDailyLimit) { const feeAmountCalc = 0.5 * fee const feeAmount = ether(feeAmountCalc.toString()) - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const feeManager = await FeeManagerNativeToErc.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -1613,7 +1743,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -1642,11 +1773,7 @@ function test(accounts, isRelativeDailyLimit) { }).should.be.fulfilled // Then - if (isRelativeDailyLimit) { - logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet - } else { - logsValidator1.length.should.be.equals(1) - } + logsValidator1.length.should.be.equals(1) expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[1], @@ -1702,7 +1829,7 @@ function test(accounts, isRelativeDailyLimit) { const feePerValidator = feeAmount.div(toBN(5)) const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const feeManager = await FeeManagerNativeToErc.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -1716,7 +1843,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [notUsedFee, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -1756,11 +1884,7 @@ function test(accounts, isRelativeDailyLimit) { }).should.be.fulfilled // Then - if (isRelativeDailyLimit) { - logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet - } else { - logsValidator1.length.should.be.equals(1) - } + logsValidator1.length.should.be.equals(1) expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[4], @@ -1802,7 +1926,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1823,7 +1947,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // When @@ -1852,7 +1977,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1873,7 +1998,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled // When @@ -1901,7 +2027,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1928,7 +2054,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ @@ -1964,7 +2091,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[4], accounts[5], accounts[6]] const requiredSignatures = 3 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -1990,7 +2117,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ @@ -2052,7 +2180,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[5], accounts[6], accounts[7], accounts[8], accounts[9]] const requiredSignatures = 5 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2077,7 +2205,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ @@ -2142,7 +2271,7 @@ function test(accounts, isRelativeDailyLimit) { const rewards = [accounts[2]] const requiredSignatures = 1 const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner }).should.be.fulfilled @@ -2167,7 +2296,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -2228,7 +2358,7 @@ function test(accounts, isRelativeDailyLimit) { const feeAmountCalc = 0.5 * fee const feeAmount = ether(feeAmountCalc.toString()) - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const feeManager = await FeeManagerNativeToErcBothDirections.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -2242,7 +2372,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -2271,11 +2402,7 @@ function test(accounts, isRelativeDailyLimit) { }).should.be.fulfilled // Then - if (isRelativeDailyLimit) { - logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet - } else { - logsValidator1.length.should.be.equals(1) - } + logsValidator1.length.should.be.equals(1) expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[1], @@ -2330,7 +2457,7 @@ function test(accounts, isRelativeDailyLimit) { const feePerValidator = feeAmount.div(toBN(5)) const rewardableValidators = await RewardableValidators.new() - const homeBridge = await HomeBridgeContract.new() + const homeBridge = await HomeBridge.new() const feeManager = await FeeManagerNativeToErcBothDirections.new() await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { from: owner @@ -2344,7 +2471,8 @@ function test(accounts, isRelativeDailyLimit) { owner, feeManager.address, [feeInWei, feeInWei], - decimalShiftZero + decimalShiftZero, + absoluteLimitsContract.address ).should.be.fulfilled await homeBridge.sendTransaction({ from: accounts[0], @@ -2384,11 +2512,7 @@ function test(accounts, isRelativeDailyLimit) { }).should.be.fulfilled // Then - if (isRelativeDailyLimit) { - logsValidator1.length.should.be.equals(2) // SignedForAffirmation and TodayLimitSet - } else { - logsValidator1.length.should.be.equals(1) - } + logsValidator1.length.should.be.equals(1) expectEventInLogs(logs, 'SignedForAffirmation', { signer: validators[4], @@ -2429,7 +2553,7 @@ function test(accounts, isRelativeDailyLimit) { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) - const homeBridgeWithThreeSigs = await HomeBridgeContract.new() + const homeBridgeWithThreeSigs = await HomeBridge.new() await homeBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, [oneEther, halfEther, minPerTx], @@ -2437,7 +2561,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ) const valueOnForeign = toBN('1000') @@ -2479,7 +2604,7 @@ function test(accounts, isRelativeDailyLimit) { balanceAfterRecipient.should.be.bignumber.equal(balanceBeforeRecipient.add(valueOnHome)) }) it('Foreign to Home: test decimal shift 2, no impact on UserRequestForSignature value', async () => { - homeContract = await HomeBridgeContract.new() + homeContract = await HomeBridge.new() await homeContract.initialize( validatorContract.address, ['3', '2', '1'], @@ -2487,7 +2612,8 @@ function test(accounts, isRelativeDailyLimit) { requireBlockConfirmations, executionLimitsArray, owner, - decimalShiftTwo + decimalShiftTwo, + absoluteLimitsContract.address ) const currentDay = await homeContract.getCurrentDay() expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) @@ -2516,76 +2642,67 @@ function test(accounts, isRelativeDailyLimit) { expect(await homeContract.totalSpentPerDay(currentDay)).to.be.bignumber.equal('2') }) }) - if (isRelativeDailyLimit) { - describe('#executionDailyLimit (relative)', () => { - let homeBridge + describe('#executionDailyLimit (relative)', () => { + let homeBridge - function initialize(customExecutionLimitsArray) { - return homeBridge.initialize( - validatorContract.address, - [threshold.add(toBN(1)), threshold, minPerTx], - gasPrice, - requireBlockConfirmations, - customExecutionLimitsArray, - owner, - decimalShiftZero - ).should.be.fulfilled - } + function initialize(customExecutionLimitsArray) { + return homeBridge.initialize( + validatorContract.address, + [threshold.add(toBN(1)), threshold, minPerTx], + gasPrice, + requireBlockConfirmations, + customExecutionLimitsArray, + owner, + decimalShiftZero, + relativeLimitsContract.address + ).should.be.fulfilled + } - beforeEach(async () => { - homeBridge = await HomeBridgeContract.new() - }) - it('should be calculated correctly - 1', async () => { - await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + beforeEach(async () => { + homeBridge = await HomeBridge.new() + }) + it('should be calculated correctly - 1', async () => { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) - await homeBridge.sendTransaction({ from: accounts[4], value: halfEther }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(halfEther) + await homeBridge.sendTransaction({ from: accounts[4], value: halfEther }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(halfEther) - const limit = await homeBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, foreignMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) - it('should be calculated correctly - 2', async function() { - await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + const limit = await homeBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(halfEther, targetLimit, threshold, foreignMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) + }) + it('should be calculated correctly - 2', async function() { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) - await homeBridge.sendTransaction({ from: accounts[4], value: foreignMinPerTx }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(foreignMinPerTx) + await homeBridge.sendTransaction({ from: accounts[4], value: foreignMinPerTx }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(foreignMinPerTx) - const limit = await homeBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(foreignMinPerTx) - }) - it('should be calculated correctly - 3', async function() { - await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + const limit = await homeBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(foreignMinPerTx) + }) + it('should be calculated correctly - 3', async function() { + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) - await homeBridge.sendTransaction({ from: accounts[4], value: threshold }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(threshold) + await homeBridge.sendTransaction({ from: accounts[4], value: threshold }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(threshold) - const limit = await homeBridge.executionDailyLimit() - expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) - }) - it('should be calculated correctly - 4', async function() { - const amountToSend = ether('5') - const targetLimit = ether('0.06') - const threshold = ether('100') - const foreignMinPerTx = ether('0.1') + const limit = await homeBridge.executionDailyLimit() + expect(limit).to.be.bignumber.equal(threshold.mul(targetLimit).div(oneEther)) + }) + it('should be calculated correctly - 4', async function() { + const amountToSend = ether('5') + const targetLimit = ether('0.06') + const threshold = ether('100') + const foreignMinPerTx = ether('0.1') - await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) + await initialize([targetLimit, threshold, foreignMaxPerTx, foreignMinPerTx]) - await homeBridge.sendTransaction({ from: accounts[4], value: amountToSend }).should.be.fulfilled - expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(amountToSend) + await homeBridge.sendTransaction({ from: accounts[4], value: amountToSend }).should.be.fulfilled + expect(toBN(await web3.eth.getBalance(homeBridge.address))).to.be.bignumber.equal(amountToSend) - const limit = await homeBridge.executionDailyLimit() - const expectedLimit = calculateDailyLimit(amountToSend, targetLimit, threshold, foreignMinPerTx) - expect(limit).to.be.bignumber.equal(expectedLimit) - }) + const limit = await homeBridge.executionDailyLimit() + const expectedLimit = calculateDailyLimit(amountToSend, targetLimit, threshold, foreignMinPerTx) + expect(limit).to.be.bignumber.equal(expectedLimit) }) - } -} - -contract('HomeBridge_Native_to_ERC', async accounts => { - test(accounts, false) -}) - -contract('HomeBridge_Native_to_ERC_RelativeDailyLimit', async accounts => { - test(accounts, true) + }) }) From d8a049ec9b642162b13a2c2faa9255e9ea667548 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 17 Dec 2019 20:18:36 +0300 Subject: [PATCH 71/80] fix erc677 bridge token tests --- test/poa20_test.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/poa20_test.js b/test/poa20_test.js index d8ebfb2d1..d913e1e65 100644 --- a/test/poa20_test.js +++ b/test/poa20_test.js @@ -7,6 +7,7 @@ const StakingTest = artifacts.require('Staking.sol') const HomeErcToErcBridge = artifacts.require('HomeBridgeErcToErc.sol') const ForeignNativeToErcBridge = artifacts.require('ForeignBridgeNativeToErc.sol') const BridgeValidators = artifacts.require('BridgeValidators.sol') +const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') const { expect } = require('chai') const { ERROR_MSG, ERROR_MSG_OPCODE, ZERO_ADDRESS, BN } = require('./setup') @@ -25,9 +26,13 @@ const decimalShiftZero = 0 async function testERC677BridgeToken(accounts, rewardable) { let token + let limitsContract const owner = accounts[0] const user = accounts[1] const tokenContract = rewardable ? POA20RewardableMock : POA20 + before(async () => { + limitsContract = await AbsoluteDailyLimit.new() + }) beforeEach(async () => { token = await tokenContract.new('POA ERC20 Foundation', 'POA20', 18) }) @@ -237,7 +242,8 @@ async function testERC677BridgeToken(accounts, rewardable) { token.address, [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) foreignNativeToErcBridge = await ForeignNativeToErcBridge.new() await foreignNativeToErcBridge.initialize( @@ -249,7 +255,8 @@ async function testERC677BridgeToken(accounts, rewardable) { [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero, - homeErcToErcContract.address + homeErcToErcContract.address, + limitsContract.address ) }) it('sends tokens to recipient', async () => { @@ -415,7 +422,8 @@ async function testERC677BridgeToken(accounts, rewardable) { token.address, [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, - decimalShiftZero + decimalShiftZero, + limitsContract.address ) foreignNativeToErcBridge = await ForeignNativeToErcBridge.new() await foreignNativeToErcBridge.initialize( @@ -427,7 +435,8 @@ async function testERC677BridgeToken(accounts, rewardable) { [executionDailyLimit, executionMaxPerTx, executionMinPerTx], owner, decimalShiftZero, - homeErcToErcContract.address + homeErcToErcContract.address, + limitsContract.address ) }) it('calls contractFallback', async () => { From d41a9d2860ec492b0a07c984d04b256d1b18fbd8 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 18 Dec 2019 12:15:52 +0300 Subject: [PATCH 72/80] update flatten script --- flatten.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/flatten.sh b/flatten.sh index 7e115a940..6321033b4 100755 --- a/flatten.sh +++ b/flatten.sh @@ -20,6 +20,9 @@ ${FLATTENER} contracts/upgradeability/EternalStorageProxy.sol > flats/EternalSto ${FLATTENER} contracts/upgradeability/ClassicEternalStorageProxy.sol > flats/ClassicEternalStorageProxy_flat.sol ${FLATTENER} contracts/ERC677BridgeToken.sol > flats/ERC677BridgeToken_flat.sol ${FLATTENER} contracts/ERC677BridgeTokenRewardable.sol > flats/ERC677BridgeTokenRewardable_flat.sol +${FLATTENER} contracts/upgradeable_contracts/AbsoluteDailyLimit.sol > flats/AbsoluteDailyLimit_flat.sol +${FLATTENER} contracts/upgradeable_contracts/RelativeDailyLimit.sol > flats/RelativeDailyLimit_flat.sol +${FLATTENER} contracts/upgradeable_contracts/RelativeExecutionDailyLimit.sol > flats/RelativeExecutionDailyLimit_flat.sol echo "Flattening bridge validators contracts" ${FLATTENER} ${VALIDATOR_CONTRACTS_DIR}/BridgeValidators.sol > flats/validators/BridgeValidators_flat.sol @@ -27,30 +30,21 @@ ${FLATTENER} ${VALIDATOR_CONTRACTS_DIR}/RewardableValidators.sol > flats/validat echo "Flattening contracts related to native-to-erc bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ForeignBridgeNativeToErc.sol > flats/native_to_erc20/ForeignBridgeNativeToErc_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/ForeignBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/HomeBridgeNativeToErc.sol > flats/native_to_erc20/HomeBridgeNativeToErc_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/HomeBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ClassicHomeBridgeNativeToErc.sol > flats/native_to_erc20/ClassicHomeBridgeNativeToErc_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit.sol > flats/native_to_erc20/ClassicHomeBridgeNativeToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErc.sol > flats/native_to_erc20/FeeManagerNativeToErc_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErcBothDirections.sol > flats/native_to_erc20/FeeManagerNativeToErcBothDirections_flat.sol echo "Flattening contracts related to erc-to-erc bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErc.sol > flats/erc20_to_erc20/HomeBridgeErcToErc_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit.sol > flats/erc20_to_erc20/HomeBridgeErcToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol > flats/erc20_to_erc20/HomeBridgeErcToErcPOSDAO_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit.sol > flats/erc20_to_erc20/HomeBridgeErcToErcPOSDAORelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErcToErc.sol > flats/erc20_to_erc20/ForeignBridgeErcToErc_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit.sol > flats/erc20_to_erc20/ForeignBridgeErcToErcRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErc677ToErc677.sol > flats/erc20_to_erc20/ForeignBridgeErc677ToErc677_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit.sol > flats/erc20_to_erc20/ForeignBridgeErc677ToErc677RelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol > flats/erc20_to_erc20/FeeManagerErcToErcPOSDAO_flat.sol echo "Flattening contracts related to erc-to-native bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/HomeBridgeErcToNative.sol > flats/erc20_to_native/HomeBridgeErcToNative_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit.sol > flats/erc20_to_native/HomeBridgeErcToNativeRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/ForeignBridgeErcToNative.sol > flats/erc20_to_native/ForeignBridgeErcToNative_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit.sol > flats/erc20_to_native/ForeignBridgeErcToNativeRelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/FeeManagerErcToNative.sol > flats/erc20_to_native/FeeManagerErcToNative_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/erc20_to_native/FeeManagerErcToNativePOSDAO.sol > flats/erc20_to_native/FeeManagerErcToNativePOSDAO_flat.sol @@ -60,6 +54,4 @@ ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/arbitrary_message/ForeignAMB.sol > flats/ar echo "Flattening contracts related to erc677 to erc677 on top of AMB bridge" ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/HomeAMBErc677ToErc677.sol > flats/amb_erc677_to_erc677/HomeAMBErc677ToErc677_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit.sol > flats/amb_erc677_to_erc677/HomeAMBErc677ToErc677RelativeDailyLimit_flat.sol ${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/ForeignAMBErc677ToErc677.sol > flats/amb_erc677_to_erc677/ForeignAMBErc677ToErc677_flat.sol -${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit.sol > flats/amb_erc677_to_erc677/ForeignAMBErc677ToErc677RelativeDailyLimit_flat.sol From f878a3da5b019a4a77e6a655320b4535a89c4423 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 18 Dec 2019 15:49:39 +0300 Subject: [PATCH 73/80] update deployment scripts --- deploy/deploy.js | 13 ++++-- deploy/src/amb_erc677_to_erc677/foreign.js | 24 ++++++++--- deploy/src/amb_erc677_to_erc677/home.js | 25 +++++++---- deploy/src/amb_erc677_to_erc677/initialize.js | 33 +++++++++------ deploy/src/erc_to_erc/foreign.js | 35 +++++++++------- deploy/src/erc_to_erc/home.js | 40 +++++++++++------- deploy/src/erc_to_native/foreign.js | 27 ++++++++---- deploy/src/erc_to_native/home.js | 34 ++++++++++----- deploy/src/loadContracts.js | 15 ++----- deploy/src/native_to_erc/foreign.js | 42 ++++++++++++++----- deploy/src/native_to_erc/home.js | 34 ++++++++++----- 11 files changed, 215 insertions(+), 107 deletions(-) diff --git a/deploy/deploy.js b/deploy/deploy.js index 1a413dc56..0ddcb4fec 100644 --- a/deploy/deploy.js +++ b/deploy/deploy.js @@ -128,9 +128,16 @@ async function deployAMBErcToErc() { const deployForeign = require('./src/amb_erc677_to_erc677/foreign') const initialize = require('./src/amb_erc677_to_erc677/initialize') await preDeploy() - const { homeBridgeMediator, bridgeableErc677 } = await deployHome() - const { foreignBridgeMediator } = await deployForeign() - await initialize({ homeBridge: homeBridgeMediator.address, foreignBridge: foreignBridgeMediator.address, homeErc677: bridgeableErc677.address }) + const { homeBridgeMediator, bridgeableErc677, homeLimitsContract } = await deployHome() + const { foreignBridgeMediator, foreignLimitsContract } = await deployForeign() + await initialize({ + homeBridge: homeBridgeMediator.address, + foreignBridge: + foreignBridgeMediator.address, + homeErc677: bridgeableErc677.address, + homeLimitsContract: homeLimitsContract.address, + foreignLimitsContract: foreignLimitsContract.address + }) console.log('\nDeployment has been completed.\n\n') console.log(`[ Home ] Bridge Mediator: ${homeBridgeMediator.address}`) console.log(`[ Home ] ERC677 Bridgeable Token: ${bridgeableErc677.address}`) diff --git a/deploy/src/amb_erc677_to_erc677/foreign.js b/deploy/src/amb_erc677_to_erc677/foreign.js index 6a7eb8478..556b05139 100644 --- a/deploy/src/amb_erc677_to_erc677/foreign.js +++ b/deploy/src/amb_erc677_to_erc677/foreign.js @@ -4,13 +4,14 @@ const { deployContract, privateKeyToAddress, upgradeProxy } = require('../deploy const { foreignContracts: { EternalStorageProxy, - ForeignAMBErc677ToErc677: ForeignBridgeAbsoluteDailyLimit, - ForeignAMBErc677ToErc677RelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + ForeignAMBErc677ToErc677, + AbsoluteDailyLimit, + RelativeExecutionDailyLimit } } = require('../loadContracts') const { DEPLOYMENT_ACCOUNT_PRIVATE_KEY, - RELATIVE_DAILY_LIMIT, + RELATIVE_DAILY_LIMIT } = require('../loadEnv') const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) @@ -28,8 +29,7 @@ async function deployForeign() { console.log('[Foreign] Bridge Mediator Storage: ', foreignBridgeStorage.options.address) console.log('\n[Foreign] Deploying Bridge Mediator implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit - const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { + const foreignBridgeImplementation = await deployContract(ForeignAMBErc677ToErc677, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce @@ -45,10 +45,22 @@ async function deployForeign() { nonce, url: FOREIGN_RPC_URL }) + nonce++ + console.log('\n[Foreign] Hooking up Mediator storage to Mediator implementation - Done') + + console.log('\n[Foreign] Deploying Limits Contracts') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + network: 'foreign', + nonce + }) + console.log('[Foreign] Limits Contract: ', limitsContract.options.address) console.log('\nForeign part of ERC677-to-ERC677 bridge deployed\n') return { - foreignBridgeMediator: { address: foreignBridgeStorage.options.address } + foreignBridgeMediator: { address: foreignBridgeStorage.options.address }, + foreignLimitsContract: { address: limitsContract.options.address } } } diff --git a/deploy/src/amb_erc677_to_erc677/home.js b/deploy/src/amb_erc677_to_erc677/home.js index dbf35430a..aa37e14c7 100644 --- a/deploy/src/amb_erc677_to_erc677/home.js +++ b/deploy/src/amb_erc677_to_erc677/home.js @@ -18,16 +18,17 @@ const { DEPLOY_REWARDABLE_TOKEN, BLOCK_REWARD_ADDRESS, DPOS_STAKING_ADDRESS, - RELATIVE_DAILY_LIMIT, + RELATIVE_DAILY_LIMIT } = require('../loadEnv') const { homeContracts: { EternalStorageProxy, - HomeAMBErc677ToErc677: HomeBridgeAbsoluteDailyLimit, - HomeAMBErc677ToErc677RelativeDailyLimit: HomeBridgeRelativeDailyLimit, + HomeAMBErc677ToErc677, ERC677BridgeToken, - ERC677BridgeTokenRewardable + ERC677BridgeTokenRewardable, + AbsoluteDailyLimit, + RelativeDailyLimit } } = require('../loadContracts') @@ -45,8 +46,7 @@ async function deployHome() { console.log('[Home] Bridge Mediator Storage: ', homeBridgeStorage.options.address) console.log('\n[Home] Deploying Bridge Mediator implementation\n') - const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridgeAbsoluteDailyLimit - const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { + const homeBridgeImplementation = await deployContract(HomeAMBErc677ToErc677, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) @@ -125,11 +125,22 @@ async function deployHome() { nonce, url: HOME_RPC_URL }) + nonce++ + console.log('[Home] Transferring ownership of Bridgeable token to Bridge Mediator contract - Done') + + console.log('\n[Home] Deploying Limits Contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + nonce + }) + console.log('[Home] Limits Contract: ', limitsContract.options.address) console.log('\nHome part of ERC677-to-ERC677 bridge deployed\n') return { homeBridgeMediator: { address: homeBridgeStorage.options.address }, - bridgeableErc677: { address: erc677token.options.address } + bridgeableErc677: { address: erc677token.options.address }, + homeLimitsContract: { address: limitsContract.options.address } } } diff --git a/deploy/src/amb_erc677_to_erc677/initialize.js b/deploy/src/amb_erc677_to_erc677/initialize.js index fe0e11853..12276de8a 100644 --- a/deploy/src/amb_erc677_to_erc677/initialize.js +++ b/deploy/src/amb_erc677_to_erc677/initialize.js @@ -4,13 +4,11 @@ const { web3Home, HOME_RPC_URL, web3Foreign, FOREIGN_RPC_URL, deploymentPrivateK const { homeContracts: { EternalStorageProxy, - HomeAMBErc677ToErc677, - HomeAMBErc677ToErc677RelativeDailyLimit + HomeAMBErc677ToErc677 }, foreignContracts: { EternalStorageProxy: ForeignEternalStorageProxy, - ForeignAMBErc677ToErc677, - ForeignAMBErc677ToErc677RelativeDailyLimit + ForeignAMBErc677ToErc677 } } = require('../loadContracts') const { @@ -64,7 +62,8 @@ async function initialize({ executionMinPerTx, requestGasLimit, foreignToHomeDecimalShift, - owner + owner, + limitsContract }, upgradeableAdmin, sendRawTx, @@ -98,7 +97,8 @@ async function initialize({ EXECUTION_MIN_AMOUNT_PER_TX: ${executionMinPerTx} which is ${Web3Utils.fromWei(executionMinPerTx)} in eth, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, MEDIATOR_REQUEST_GAS_LIMIT : ${requestGasLimit}, - OWNER: ${owner} + OWNER: ${owner}, + LIMITS_CONTRACT: ${limitsContract} `) let requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] @@ -121,7 +121,8 @@ async function initialize({ executionLimitsArray, requestGasLimit, foreignToHomeDecimalShift, - owner + owner, + limitsContract ) .encodeABI() const txInitialize = await sendRawTx({ @@ -149,7 +150,13 @@ async function initialize({ }) } -async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { +async function initializeBridges({ + homeBridge, + foreignBridge, + homeErc677, + homeLimitsContract, + foreignLimitsContract +}) { const foreignToHomeDecimalShift = FOREIGN_TO_HOME_DECIMAL_SHIFT || 0 console.log('\n[Home] Initializing Bridge Mediator with following parameters:\n') @@ -157,7 +164,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { web3: web3Home, url: HOME_RPC_URL, address: homeBridge, - abi: RELATIVE_DAILY_LIMIT ? HomeAMBErc677ToErc677RelativeDailyLimit.abi : HomeAMBErc677ToErc677.abi, + abi: HomeAMBErc677ToErc677.abi, proxyAbi: EternalStorageProxy.abi, params: { bridgeContract: HOME_AMB_BRIDGE, @@ -171,7 +178,8 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { executionMinPerTx: FOREIGN_MIN_AMOUNT_PER_TX, requestGasLimit: HOME_MEDIATOR_REQUEST_GAS_LIMIT, foreignToHomeDecimalShift, - owner: HOME_BRIDGE_OWNER + owner: HOME_BRIDGE_OWNER, + limitsContract: homeLimitsContract }, upgradeableAdmin: HOME_UPGRADEABLE_ADMIN, sendRawTx: sendRawTxHome, @@ -183,7 +191,7 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { web3: web3Foreign, url: FOREIGN_RPC_URL, address: foreignBridge, - abi: RELATIVE_DAILY_LIMIT ? ForeignAMBErc677ToErc677RelativeDailyLimit.abi : ForeignAMBErc677ToErc677.abi, + abi: ForeignAMBErc677ToErc677.abi, proxyAbi: ForeignEternalStorageProxy.abi, params: { bridgeContract: FOREIGN_AMB_BRIDGE, @@ -197,7 +205,8 @@ async function initializeBridges({ homeBridge, foreignBridge, homeErc677 }) { executionMinPerTx: HOME_MIN_AMOUNT_PER_TX, requestGasLimit: FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT, foreignToHomeDecimalShift, - owner: FOREIGN_BRIDGE_OWNER + owner: FOREIGN_BRIDGE_OWNER, + limitsContract: foreignLimitsContract }, upgradeableAdmin: FOREIGN_UPGRADEABLE_ADMIN, sendRawTx: sendRawTxForeign, diff --git a/deploy/src/erc_to_erc/foreign.js b/deploy/src/erc_to_erc/foreign.js index b5f5d9f60..fdb5a0f1b 100644 --- a/deploy/src/erc_to_erc/foreign.js +++ b/deploy/src/erc_to_erc/foreign.js @@ -16,10 +16,10 @@ const { foreignContracts: { EternalStorageProxy, BridgeValidators, - ForeignBridgeErcToErc: ForeignBridgeAbsoluteDailyLimit, - ForeignBridgeErcToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, - ForeignBridgeErc677ToErc677: ForeignBridgeErc677ToErc677AbsoluteDailyLimit, - ForeignBridgeErc677ToErc677RelativeDailyLimit: ForeignBridgeErc677ToErc677RelativeDailyLimit, + ForeignBridgeErcToErc, + ForeignBridgeErc677ToErc677, + AbsoluteDailyLimit, + RelativeExecutionDailyLimit } } = require('../loadContracts') @@ -51,7 +51,7 @@ const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVAT const foreignToHomeDecimalShift = FOREIGN_TO_HOME_DECIMAL_SHIFT || 0 -async function initializeBridge({ validatorsBridge, bridge, nonce }) { +async function initializeBridge({ validatorsBridge, bridge, limitsContract, nonce }) { console.log(`Foreign Validators: ${validatorsBridge.options.address}, ERC20_TOKEN_ADDRESS: ${ERC20_TOKEN_ADDRESS}, FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei( @@ -67,7 +67,8 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address} `) const executionLimitsArray = RELATIVE_DAILY_LIMIT @@ -83,7 +84,8 @@ async function initializeBridge({ validatorsBridge, bridge, nonce }) { [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], executionLimitsArray, FOREIGN_BRIDGE_OWNER, - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() @@ -161,6 +163,16 @@ async function deployForeign() { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + network: 'foreign', + nonce + }) + nonce++ + console.log('[Foreign] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying foreignBridge storage\n') const foreignBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -171,13 +183,7 @@ async function deployForeign() { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - let ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677AbsoluteDailyLimit - let ForeignBridgeContract = ForeignBridgeAbsoluteDailyLimit - if (RELATIVE_DAILY_LIMIT) { - ForeignBridgeErc677ToErc677Contract = ForeignBridgeErc677ToErc677RelativeDailyLimit - ForeignBridgeContract = ForeignBridgeRelativeDailyLimit - } - const bridgeContract = ERC20_EXTENDED_BY_ERC677 ? ForeignBridgeErc677ToErc677Contract : ForeignBridgeContract + const bridgeContract = ERC20_EXTENDED_BY_ERC677 ? ForeignBridgeErc677ToErc677 : ForeignBridgeErcToErc const foreignBridgeImplementation = await deployContract(bridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', @@ -201,6 +207,7 @@ async function deployForeign() { await initializeBridge({ validatorsBridge: storageValidatorsForeign, bridge: foreignBridgeImplementation, + limitsContract, nonce }) nonce++ diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index cc3ac6431..b2f0f0b22 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -22,12 +22,12 @@ const { BridgeValidators, RewardableValidators, FeeManagerErcToErcPOSDAO, - HomeBridgeErcToErc: HomeBridgeAbsoluteDailyLimit, - HomeBridgeErcToErcRelativeDailyLimit: HomeBridgeRelativeDailyLimit, - HomeBridgeErcToErcPOSDAO: HomeBridgePOSDAOAbsoluteDailyLimit, - HomeBridgeErcToErcPOSDAORelativeDailyLimit: HomeBridgePOSDAORelativeDailyLimit, + HomeBridgeErcToErc, + HomeBridgeErcToErcPOSDAO, ERC677BridgeToken, - ERC677BridgeTokenRewardable + ERC677BridgeTokenRewardable, + AbsoluteDailyLimit, + RelativeDailyLimit } } = require('../loadContracts') @@ -74,7 +74,7 @@ if (isRewardableBridge && BLOCK_REWARD_ADDRESS === ZERO_ADDRESS) { VALIDATORS_REWARD_ACCOUNTS = env.VALIDATORS_REWARD_ACCOUNTS.split(' ') } -async function initializeBridge({ validatorsBridge, bridge, erc677token, initialNonce }) { +async function initializeBridge({ validatorsBridge, bridge, erc677token, limitsContract, initialNonce }) { let nonce = initialNonce let initializeHomeBridgeData @@ -108,6 +108,7 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, + LIMITS_CONTRACT: ${limitsContract.options.address}, Block Reward: ${BLOCK_REWARD_ADDRESS}, Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}% @@ -124,7 +125,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial feeManager.options.address, [homeFeeInWei, foreignFeeInWei], BLOCK_REWARD_ADDRESS, - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } else { @@ -137,7 +139,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS}, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address} `) initializeHomeBridgeData = await bridge.methods .initialize( @@ -148,7 +151,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, initial erc677token.options.address, [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } @@ -223,6 +227,15 @@ async function deployHome() { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + nonce + }) + nonce++ + console.log('[Home] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying homeBridge storage\n') const homeBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -232,14 +245,8 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - let HomeBridgePOSDAOContract = HomeBridgePOSDAOAbsoluteDailyLimit - let HomeBridgeContract = HomeBridgeAbsoluteDailyLimit - if (RELATIVE_DAILY_LIMIT) { - HomeBridgePOSDAOContract = HomeBridgePOSDAORelativeDailyLimit - HomeBridgeContract = HomeBridgeRelativeDailyLimit - } const bridgeContract = - isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgePOSDAOContract : HomeBridgeContract + isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS ? HomeBridgeErcToErcPOSDAO : HomeBridgeErcToErc const homeBridgeImplementation = await deployContract(bridgeContract, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce @@ -327,6 +334,7 @@ async function deployHome() { validatorsBridge: storageValidatorsHome, bridge: homeBridgeImplementation, erc677token, + limitsContract, initialNonce: nonce }) diff --git a/deploy/src/erc_to_native/foreign.js b/deploy/src/erc_to_native/foreign.js index dd93b5f05..3dd34d147 100644 --- a/deploy/src/erc_to_native/foreign.js +++ b/deploy/src/erc_to_native/foreign.js @@ -16,8 +16,9 @@ const { foreignContracts: { EternalStorageProxy, BridgeValidators, - ForeignBridgeErcToNative: ForeignBridgeAbsoluteDailyLimit, - ForeignBridgeErcToNativeRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + ForeignBridgeErcToNative, + AbsoluteDailyLimit, + RelativeExecutionDailyLimit } } = require('../loadContracts') @@ -48,7 +49,7 @@ const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVAT const foreignToHomeDecimalShift = FOREIGN_TO_HOME_DECIMAL_SHIFT || 0 -async function initializeBridge({ validatorsBridge, bridge, nonce, homeBridgeAddress }) { +async function initializeBridge({ validatorsBridge, bridge, limitsContract, nonce, homeBridgeAddress }) { console.log(`Foreign Validators: ${validatorsBridge.options.address}, ERC20_TOKEN_ADDRESS: ${ERC20_TOKEN_ADDRESS}, FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth, @@ -69,6 +70,7 @@ async function initializeBridge({ validatorsBridge, bridge, nonce, homeBridgeAdd HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address}, Home bridge Address: ${homeBridgeAddress} `) @@ -86,7 +88,8 @@ async function initializeBridge({ validatorsBridge, bridge, nonce, homeBridgeAdd executionLimitsArray, FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift, - homeBridgeAddress + homeBridgeAddress, + limitsContract.options.address ) .encodeABI() const txInitializeBridge = await sendRawTxForeign({ @@ -163,6 +166,16 @@ async function deployForeign(homeBridgeAddress) { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + network: 'foreign', + nonce + }) + nonce++ + console.log('[Foreign] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying foreignBridge storage\n') const foreignBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -173,8 +186,7 @@ async function deployForeign(homeBridgeAddress) { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit - const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { + const foreignBridgeImplementation = await deployContract(ForeignBridgeErcToNative, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce @@ -197,8 +209,9 @@ async function deployForeign(homeBridgeAddress) { await initializeBridge({ validatorsBridge: storageValidatorsForeign, bridge: foreignBridgeImplementation, + limitsContract, nonce, - homeBridgeAddress + homeBridgeAddress, }) nonce++ diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index dbd7f24a7..85087e03e 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -18,9 +18,10 @@ const { BridgeValidators, RewardableValidators, FeeManagerErcToNative, - HomeBridgeErcToNative: HomeBridgeAbsoluteDailyLimit, - HomeBridgeErcToNativeRelativeDailyLimit: HomeBridgeRelativeDailyLimit, - FeeManagerErcToNativePOSDAO + HomeBridgeErcToNative, + FeeManagerErcToNativePOSDAO, + AbsoluteDailyLimit, + RelativeDailyLimit } } = require('../loadContracts') @@ -64,7 +65,7 @@ if (isRewardableBridge && !isFeeManagerPOSDAO) { VALIDATORS_REWARD_ACCOUNTS = env.VALIDATORS_REWARD_ACCOUNTS.split(' ') } -async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { +async function initializeBridge({ validatorsBridge, bridge, limitsContract, initialNonce }) { let nonce = initialNonce let initializeHomeBridgeData @@ -111,7 +112,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}% Foreign Fee: ${foreignFeeInWei} which is ${FOREIGN_TRANSACTIONS_FEE * 100}%, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}`) + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address}`) initializeHomeBridgeData = await bridge.methods .rewardableInitialize( validatorsBridge.options.address, @@ -123,7 +125,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } else { @@ -146,7 +149,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MIN_AMOUNT_PER_TX )} in eth, HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address} `) initializeHomeBridgeData = await bridge.methods .initialize( @@ -157,7 +161,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { BLOCK_REWARD_ADDRESS, [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX], HOME_BRIDGE_OWNER, - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } @@ -231,6 +236,15 @@ async function deployHome() { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + nonce + }) + nonce++ + console.log('[Home] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying homeBridge storage\n') const homeBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -239,8 +253,7 @@ async function deployHome() { nonce++ console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridgeAbsoluteDailyLimit - const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { + const homeBridgeImplementation = await deployContract(HomeBridgeErcToNative, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) @@ -261,6 +274,7 @@ async function deployHome() { nonce = await initializeBridge({ validatorsBridge: storageValidatorsHome, bridge: homeBridgeImplementation, + limitsContract, initialNonce: nonce }) diff --git a/deploy/src/loadContracts.js b/deploy/src/loadContracts.js index 69720c79e..229367041 100644 --- a/deploy/src/loadContracts.js +++ b/deploy/src/loadContracts.js @@ -16,38 +16,29 @@ function getContracts(evmVersion) { RewardableValidators: require(`../../build/${buildPath}/RewardableValidators.json`), FeeManagerErcToErcPOSDAO: require(`../../build/${buildPath}/FeeManagerErcToErcPOSDAO.json`), HomeBridgeErcToErc: require(`../../build/${buildPath}/HomeBridgeErcToErc.json`), - HomeBridgeErcToErcRelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToErcRelativeDailyLimit.json`), ForeignBridgeErcToErc: require(`../../build/${buildPath}/ForeignBridgeErcToErc.json`), - ForeignBridgeErcToErcRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErcToErcRelativeDailyLimit.json`), ForeignBridgeErc677ToErc677: require(`../../build/${buildPath}/ForeignBridgeErc677ToErc677.json`), - ForeignBridgeErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErc677ToErc677RelativeDailyLimit.json`), HomeBridgeErcToErcPOSDAO: require(`../../build/${buildPath}/HomeBridgeErcToErcPOSDAO.json`), - HomeBridgeErcToErcPOSDAORelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToErcPOSDAORelativeDailyLimit.json`), ERC677BridgeToken: require(`../../build/${buildPath}/ERC677BridgeToken.json`), ERC677BridgeTokenRewardable: require(`../../build/${buildPath}/ERC677BridgeTokenRewardable.json`), ForeignBridgeErcToNative: require(`../../build/${buildPath}/ForeignBridgeErcToNative.json`), - ForeignBridgeErcToNativeRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeErcToNativeRelativeDailyLimit.json`), FeeManagerErcToNative: require(`../../build/${buildPath}/FeeManagerErcToNative.json`), FeeManagerErcToNativePOSDAO: require(`../../build/${buildPath}/FeeManagerErcToNativePOSDAO.json`), HomeBridgeErcToNative: require(`../../build/${buildPath}/HomeBridgeErcToNative.json`), - HomeBridgeErcToNativeRelativeDailyLimit: require(`../../build/${buildPath}/HomeBridgeErcToNativeRelativeDailyLimit.json`), FeeManagerNativeToErc: require(`../../build/${buildPath}/FeeManagerNativeToErc.json`), ForeignBridgeNativeToErc: require(`../../build/${buildPath}/ForeignBridgeNativeToErc.json`), - ForeignBridgeNativeToErcRelativeDailyLimit: require(`../../build/${buildPath}/ForeignBridgeNativeToErcRelativeDailyLimit.json`), FeeManagerNativeToErcBothDirections: require(`../../build/${buildPath}/FeeManagerNativeToErcBothDirections.json`), HomeBridgeNativeToErc: useClassicProxy ? require(`../../build/${buildPath}/ClassicHomeBridgeNativeToErc.json`) : require(`../../build/${buildPath}/HomeBridgeNativeToErc.json`), - HomeBridgeNativeToErcRelativeDailyLimit: useClassicProxy - ? require(`../../build/${buildPath}/ClassicHomeBridgeNativeToErcRelativeDailyLimit.json`) - : require(`../../build/${buildPath}/HomeBridgeNativeToErcRelativeDailyLimit.json`), BlockReward: require(`../../build/${buildPath}/BlockReward.json`), HomeAMB: require(`../../build/${buildPath}/HomeAMB.json`), ForeignAMB: require(`../../build/${buildPath}/ForeignAMB`), HomeAMBErc677ToErc677: require(`../../build/${buildPath}/HomeAMBErc677ToErc677.json`), - HomeAMBErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/HomeAMBErc677ToErc677RelativeDailyLimit.json`), ForeignAMBErc677ToErc677: require(`../../build/${buildPath}/ForeignAMBErc677ToErc677.json`), - ForeignAMBErc677ToErc677RelativeDailyLimit: require(`../../build/${buildPath}/ForeignAMBErc677ToErc677RelativeDailyLimit.json`) + AbsoluteDailyLimit: require(`../../build/${buildPath}/AbsoluteDailyLimit.json`), + RelativeDailyLimit: require(`../../build/${buildPath}/RelativeDailyLimit.json`), + RelativeExecutionDailyLimit: require(`../../build/${buildPath}/RelativeExecutionDailyLimit.json`) } } diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index f76ceac49..13acbc928 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -19,11 +19,12 @@ const { EternalStorageProxy, BridgeValidators, RewardableValidators, - ForeignBridgeNativeToErc: ForeignBridgeAbsoluteDailyLimit, - ForeignBridgeNativeToErcRelativeDailyLimit: ForeignBridgeRelativeDailyLimit, + ForeignBridgeNativeToErc, ERC677BridgeToken, ERC677BridgeTokenRewardable, - FeeManagerNativeToErc + FeeManagerNativeToErc, + AbsoluteDailyLimit, + RelativeDailyLimit } } = require('../loadContracts') @@ -69,7 +70,14 @@ if (isRewardableBridge) { VALIDATORS_REWARD_ACCOUNTS = env.VALIDATORS_REWARD_ACCOUNTS.split(' ') } -async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, initialNonce, homeBridgeAddress }) { +async function initializeBridge({ + validatorsBridge, + bridge, + erc677bridgeToken, + limitsContract, + initialNonce, + homeBridgeAddress +}) { let nonce = initialNonce let initializeFBridgeData @@ -114,7 +122,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}%, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address}, Home bridge Address: ${homeBridgeAddress}`) initializeFBridgeData = await bridge.methods @@ -129,7 +138,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i feeManager.options.address, homeFeeInWei, foreignToHomeDecimalShift, - homeBridgeAddress + homeBridgeAddress, + limitsContract.options.address ) .encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS }) } else { @@ -151,7 +161,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth, HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth, FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER}, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address}, Home bridge Address: ${homeBridgeAddress} `) @@ -165,7 +176,8 @@ async function initializeBridge({ validatorsBridge, bridge, erc677bridgeToken, i [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX], FOREIGN_BRIDGE_OWNER, foreignToHomeDecimalShift, - homeBridgeAddress + homeBridgeAddress, + limitsContract.options.address ) .encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS }) } @@ -254,6 +266,16 @@ async function deployForeign(homeBridgeAddress) { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + network: 'foreign', + nonce + }) + nonce++ + console.log('[Foreign] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying foreignBridge storage\n') const foreignBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -264,8 +286,7 @@ async function deployForeign(homeBridgeAddress) { console.log('[Foreign] ForeignBridge Storage: ', foreignBridgeStorage.options.address) console.log('\ndeploying foreignBridge implementation\n') - const ForeignBridgeContract = RELATIVE_DAILY_LIMIT ? ForeignBridgeRelativeDailyLimit : ForeignBridgeAbsoluteDailyLimit - const foreignBridgeImplementation = await deployContract(ForeignBridgeContract, [], { + const foreignBridgeImplementation = await deployContract(ForeignBridgeNativeToErc, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce @@ -288,6 +309,7 @@ async function deployForeign(homeBridgeAddress) { validatorsBridge: storageValidatorsForeign, bridge: foreignBridgeImplementation, erc677bridgeToken, + limitsContract, initialNonce: nonce, homeBridgeAddress }) diff --git a/deploy/src/native_to_erc/home.js b/deploy/src/native_to_erc/home.js index 964ac7b19..acadca194 100644 --- a/deploy/src/native_to_erc/home.js +++ b/deploy/src/native_to_erc/home.js @@ -18,9 +18,10 @@ const { BridgeValidators, RewardableValidators, FeeManagerNativeToErc, - HomeBridgeNativeToErc: HomeBridge, - HomeBridgeNativeToErcRelativeDailyLimit: HomeBridgeRelativeDailyLimit, - FeeManagerNativeToErcBothDirections + HomeBridgeNativeToErc, + FeeManagerNativeToErcBothDirections, + AbsoluteDailyLimit, + RelativeExecutionDailyLimit } } = require('../loadContracts') @@ -62,7 +63,7 @@ if (isRewardableBridge) { VALIDATORS_REWARD_ACCOUNTS = env.VALIDATORS_REWARD_ACCOUNTS.split(' ') } -async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { +async function initializeBridge({ validatorsBridge, bridge, limitsContract, initialNonce }) { let nonce = initialNonce let initializeHomeBridgeData @@ -110,7 +111,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { Fee Manager: ${feeManager.options.address}, Home Fee: ${homeFeeInWei} which is ${homeFee * 100}% Foreign Fee: ${foreignFeeInWei} which is ${FOREIGN_TRANSACTIONS_FEE * 100}%, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}`) + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address}`) initializeHomeBridgeData = await bridge.methods .rewardableInitialize( @@ -122,7 +124,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_BRIDGE_OWNER, feeManager.options.address, [homeFeeInWei, foreignFeeInWei], - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } else { @@ -144,7 +147,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { FOREIGN_MIN_AMOUNT_PER_TX )} in eth, HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER}, - FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift} + FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}, + LIMITS_CONTRACT: ${limitsContract.options.address} `) initializeHomeBridgeData = await bridge.methods .initialize( @@ -154,7 +158,8 @@ async function initializeBridge({ validatorsBridge, bridge, initialNonce }) { HOME_REQUIRED_BLOCK_CONFIRMATIONS, executionLimitsArray, HOME_BRIDGE_OWNER, - foreignToHomeDecimalShift + foreignToHomeDecimalShift, + limitsContract.options.address ) .encodeABI() } @@ -229,6 +234,15 @@ async function deployHome() { }) nonce++ + console.log('\ndeploying limits contract') + const LimitsContract = RELATIVE_DAILY_LIMIT ? RelativeExecutionDailyLimit : AbsoluteDailyLimit + const limitsContract = await deployContract(LimitsContract, [], { + from: DEPLOYMENT_ACCOUNT_ADDRESS, + nonce + }) + nonce++ + console.log('[Home] Limits Contract: ', limitsContract.options.address) + console.log('\ndeploying homeBridge storage\n') const homeBridgeStorage = await deployContract(EternalStorageProxy, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, @@ -238,8 +252,7 @@ async function deployHome() { console.log('[Home] HomeBridge Storage: ', homeBridgeStorage.options.address) console.log('\ndeploying homeBridge implementation\n') - const HomeBridgeContract = RELATIVE_DAILY_LIMIT ? HomeBridgeRelativeDailyLimit : HomeBridge - const homeBridgeImplementation = await deployContract(HomeBridgeContract, [], { + const homeBridgeImplementation = await deployContract(HomeBridgeNativeToErc, [], { from: DEPLOYMENT_ACCOUNT_ADDRESS, nonce }) @@ -260,6 +273,7 @@ async function deployHome() { nonce = await initializeBridge({ validatorsBridge: storageValidatorsHome, bridge: homeBridgeImplementation, + limitsContract, initialNonce: nonce }) From 94484a447fe361cce8fcf9814a6624ea172435a4 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 18 Dec 2019 16:26:03 +0300 Subject: [PATCH 74/80] update tests --- test/erc_to_erc/foreign_bridge.test.js | 123 +++++++++---------------- 1 file changed, 45 insertions(+), 78 deletions(-) diff --git a/test/erc_to_erc/foreign_bridge.test.js b/test/erc_to_erc/foreign_bridge.test.js index 0b65ca24a..8cb0d87f7 100644 --- a/test/erc_to_erc/foreign_bridge.test.js +++ b/test/erc_to_erc/foreign_bridge.test.js @@ -38,27 +38,30 @@ const threshold = ether('10000') contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const requestLimitsArray = [dailyLimit, maxPerTx, minPerTx] const executionLimitsArray = [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const relativeExecutionLimitsArray = [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] let validatorContract let authorities let owner let token + let absoluteLimitsContract + let relativeLimitsContract + before(async () => { validatorContract = await BridgeValidators.new() authorities = [accounts[1], accounts[2]] owner = accounts[0] await validatorContract.initialize(1, authorities, owner) + absoluteLimitsContract = await AbsoluteDailyLimit.new() + relativeLimitsContract = await RelativeExecutionDailyLimit.new() }) describe('#initialize', async () => { const shouldInitialize = isRelativeDailyLimit => async function() { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const foreignBridge = await ForeignBridge.new() - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit - const limitsContract = await LimitsContract.new() - const executionLimitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] + const executionLimits = isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract expect(await foreignBridge.erc20token()).to.be.equal(ZERO_ADDRESS) expect(await foreignBridge.validatorContract()).to.be.equal(ZERO_ADDRESS) @@ -75,7 +78,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -88,7 +91,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -101,7 +104,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, ZERO_ADDRESS @@ -114,7 +117,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -127,7 +130,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { 0, // requireBlockConfirmations gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -140,7 +143,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, 0, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -153,7 +156,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, decimalShiftZero, limitsContract.address @@ -166,7 +169,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + executionLimits, owner, '9', limitsContract.address @@ -210,23 +213,19 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { function() { const value = ether('0.25') let foreignBridge - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit beforeEach(async () => { foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const limitsContract = await LimitsContract.new() await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, requestLimitsArray, - isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address ) await token.mint(foreignBridge.address, oneEther) }) @@ -353,7 +352,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - const limitsContract = await AbsoluteDailyLimit.new() foreignBridgeWithMultiSignatures = await ForeignBridge.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, @@ -364,7 +362,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + absoluteLimitsContract.address ) await token.mint(foreignBridgeWithMultiSignatures.address, oneEther) }) @@ -414,7 +412,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const limitsContract = await AbsoluteDailyLimit.new() const foreignBridgeWithThreeSigs = await ForeignBridge.new() await foreignBridgeWithThreeSigs.initialize( @@ -426,7 +423,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + absoluteLimitsContract.address ) await erc20Token.mint(foreignBridgeWithThreeSigs.address, oneEther) @@ -478,7 +475,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const foreignBridgeImpl = await ForeignBridge.new().should.be.fulfilled await foreignBridgeProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled - const limitsContract = await AbsoluteDailyLimit.new() foreignBridgeProxy = await ForeignBridge.at(foreignBridgeProxy.address) await foreignBridgeProxy.initialize( validatorsProxy.address, @@ -489,7 +485,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + absoluteLimitsContract.address ) // Deploy V2 @@ -509,7 +505,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const validatorsAddress = validatorContract.address const storageProxy = await EternalStorageProxy.new().should.be.fulfilled - const limitsContract = await AbsoluteDailyLimit.new() const foreignBridge = await ForeignBridge.new() const data = foreignBridge.contract.methods .initialize( @@ -521,7 +516,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { ['3', '2', '1'], owner, decimalShiftZero, - limitsContract.address + absoluteLimitsContract.address ) .encodeABI() await storageProxy.upgradeToAndCall('1', foreignBridge.address, data).should.be.fulfilled @@ -534,8 +529,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const claim = isRelativeDailyLimit => async function() { const owner = accounts[0] - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit - const limitsContract = await LimitsContract.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const foreignBridgeImpl = await ForeignBridge.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled @@ -547,12 +540,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address ) const tokenSecond = await ERC677BridgeToken.new('Roman Token', 'RST', 18) @@ -576,23 +567,18 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { }) const onTokenTransferTests = isRelativeDailyLimit => function() { - const executionLimitsArray = isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx] - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit - it('should emit correct events on initialize', async () => { const owner = accounts[3] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) const foreignBridge = await ForeignBridgeErc677ToErc677.new() - const limitsContract = await LimitsContract.new() + const limitsContract = isRelativeDailyLimit ? relativeLimitsContract : absoluteLimitsContract const { logs, tx } = await foreignBridge.initialize( validatorContract.address, token.address, requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, limitsContract.address, @@ -615,7 +601,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const owner = accounts[3] const user = accounts[4] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const limitsContract = await LimitsContract.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new() await foreignBridge.initialize( validatorContract.address, @@ -623,10 +608,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address, { from: owner } ) @@ -648,7 +633,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const limitsContract = await LimitsContract.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new() await foreignBridge.initialize( validatorContract.address, @@ -656,10 +640,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address, { from: owner } ) @@ -686,7 +670,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueMoreThanLimit = halfEther.add(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const limitsContract = await LimitsContract.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new() await foreignBridge.initialize( validatorContract.address, @@ -694,10 +677,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address, { from: owner } ) @@ -730,7 +713,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const valueLessThanMinPerTx = minPerTx.sub(toBN(1)) token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const limitsContract = await LimitsContract.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new() await foreignBridge.initialize( validatorContract.address, @@ -738,10 +720,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address, { from: owner } ) @@ -769,7 +751,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const user = accounts[4] const user2 = accounts[5] token = await ERC677BridgeToken.new('TEST', 'TST', 18, { from: owner }) - const limitsContract = await LimitsContract.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new() await foreignBridge.initialize( validatorContract.address, @@ -777,10 +758,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - executionLimitsArray, + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address, + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address, { from: owner } ) await token.mint(user, halfEther, { from: owner }).should.be.fulfilled @@ -809,7 +790,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) const foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) - const limitsContract = await AbsoluteDailyLimit.new() await foreignBridge.initialize( validatorContract.address, token.address, @@ -819,7 +799,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftTwo, - limitsContract.address + absoluteLimitsContract.address ) await token.mint(foreignBridge.address, valueOnHome.mul(toBN('2'))) @@ -853,7 +833,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const validatorContractWith3Signatures = await BridgeValidators.new() await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 16) - const limitsContract = await AbsoluteDailyLimit.new() const foreignBridgeWithThreeSigs = await ForeignBridge.new() @@ -866,7 +845,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftTwo, - limitsContract.address + absoluteLimitsContract.address ) await erc20Token.mint(foreignBridgeWithThreeSigs.address, valueOnHome.mul(toBN('2'))) @@ -908,7 +887,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { const owner = accounts[3] const user = accounts[4] token = await ERC677BridgeToken.new('TEST', 'TST', 16, { from: owner }) - const limitsContract = await AbsoluteDailyLimit.new() const foreignBridge = await ForeignBridgeErc677ToErc677.new({ from: owner }) await foreignBridge.initialize( validatorContract.address, @@ -919,7 +897,7 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftTwo, - limitsContract.address, + absoluteLimitsContract.address, { from: owner } ) @@ -945,7 +923,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { beforeEach(async () => { foreignBridge = await ForeignBridge.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) - const limitsContract = await AbsoluteDailyLimit.new() await foreignBridge.initialize( validatorContract.address, token.address, @@ -955,14 +932,12 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + absoluteLimitsContract.address ) await token.mint(user, ether('2')) }) const shouldAllowToBridgeTokens = isRelativeDailyLimit => async function() { - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit - const limitsContract = await LimitsContract.new() foreignBridge = await ForeignBridge.new() await foreignBridge.initialize( validatorContract.address, @@ -970,12 +945,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address ) // Given const currentDay = await foreignBridge.getCurrentDay() @@ -1038,8 +1011,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { }) const shouldNotBeAbleToTransferMoreThanLimit = isRelativeDailyLimit => async function() { - const LimitsContract = isRelativeDailyLimit ? RelativeExecutionDailyLimit : AbsoluteDailyLimit - const limitsContract = await LimitsContract.new() foreignBridge = await ForeignBridge.new() await foreignBridge.initialize( validatorContract.address, @@ -1047,12 +1018,10 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { requireBlockConfirmations, gasPrice, requestLimitsArray, - isRelativeDailyLimit - ? [targetLimit, threshold, homeMaxPerTx, homeMinPerTx] - : [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, owner, decimalShiftZero, - limitsContract.address + isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address ) // Given const userSupply = ether('2') @@ -1137,7 +1106,6 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { describe('#executionDailyLimit (relative)', () => { let token let foreignBridge - let limitsContract function initialize(customExecutionLimitsArray) { return foreignBridge.initialize( @@ -1149,14 +1117,13 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => { customExecutionLimitsArray, owner, decimalShiftZero, - limitsContract.address + relativeLimitsContract.address ).should.be.fulfilled } beforeEach(async () => { token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) foreignBridge = await ForeignBridge.new() - limitsContract = await RelativeExecutionDailyLimit.new() }) it('should be calculated correctly - 1', async () => { await initialize([targetLimit, threshold, homeMaxPerTx, homeMinPerTx]) From 79752d6d80c67a6118e7ddababfa20b4a7162cc7 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 19 Dec 2019 01:52:45 +0300 Subject: [PATCH 75/80] Merge branch 'develop' into relative-daily-limit --- .eslintignore | 1 + contracts/ERC677BridgeToken.sol | 8 + contracts/interfaces/ERC677.sol | 2 + contracts/interfaces/IScdMcdMigration.sol | 4 + .../mocks/ForeignBridgeErcToNativeMock.sol | 20 + contracts/mocks/SaiTopMock.sol | 9 + .../AbsoluteDailyLimit.sol | 4 +- .../BaseBridgeValidators.sol | 24 +- .../BridgeValidators.sol | 1 - .../upgradeable_contracts/ERC20Bridge.sol | 1 + .../RelativeDailyLimit.sol | 4 +- .../RewardableValidators.sol | 1 - .../VersionableBridge.sol | 2 +- .../ForeignBridgeErcToNative.sol | 138 +- .../native_to_erc20/HomeBridgeNativeToErc.sol | 1 + scripts/test.sh | 1 + test/erc_to_erc/home_bridge.test.js | 67 +- test/erc_to_native/foreign_bridge.test.js | 427 +- test/erc_to_native/home_bridge.test.js | 217 +- test/native_to_erc/foreign_bridge_test.js | 43 +- test/native_to_erc/home_bridge_test.js | 172 +- test/poa20_test.js | 26 + test/rewardable_validators_test.js | 32 +- test/validators_test.js | 41 +- truffle-config.js | 57 +- upgrade/.env.example | 18 + upgrade/.eslintrc | 12 + upgrade/.gitignore | 2 + upgrade/.nvmrc | 1 + upgrade/.prettierrc | 6 + upgrade/README.md | 27 + upgrade/abi/multiSigwallet.json | 265 ++ upgrade/package-lock.json | 3879 +++++++++++++++++ upgrade/package.json | 24 + upgrade/src/confirmTransaction.js | 49 + upgrade/src/migrateToMCD.js | 56 + upgrade/src/upgradeBridgeOnForeign.js | 68 + upgrade/src/upgradeBridgeOnHome.js | 55 + upgrade/src/upgradeValidatorsOnForeign.js | 75 + upgrade/src/validatorState.js | 17 + 40 files changed, 5761 insertions(+), 96 deletions(-) create mode 100644 contracts/mocks/ForeignBridgeErcToNativeMock.sol create mode 100644 contracts/mocks/SaiTopMock.sol create mode 100644 upgrade/.env.example create mode 100644 upgrade/.eslintrc create mode 100644 upgrade/.gitignore create mode 100644 upgrade/.nvmrc create mode 100644 upgrade/.prettierrc create mode 100644 upgrade/README.md create mode 100644 upgrade/abi/multiSigwallet.json create mode 100644 upgrade/package-lock.json create mode 100644 upgrade/package.json create mode 100644 upgrade/src/confirmTransaction.js create mode 100644 upgrade/src/migrateToMCD.js create mode 100644 upgrade/src/upgradeBridgeOnForeign.js create mode 100644 upgrade/src/upgradeBridgeOnHome.js create mode 100644 upgrade/src/upgradeValidatorsOnForeign.js create mode 100644 upgrade/src/validatorState.js diff --git a/.eslintignore b/.eslintignore index 4b4280a4c..3504d10ba 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ node_modules deploy +upgrade diff --git a/contracts/ERC677BridgeToken.sol b/contracts/ERC677BridgeToken.sol index 19ed9d7e2..4a045da58 100644 --- a/contracts/ERC677BridgeToken.sol +++ b/contracts/ERC677BridgeToken.sol @@ -79,4 +79,12 @@ contract ERC677BridgeToken is IBurnableMintableERC677Token, DetailedERC20, Burna function claimTokens(address _token, address _to) public onlyOwner validAddress(_to) { claimValues(_token, _to); } + + function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { + return super.increaseApproval(spender, addedValue); + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { + return super.decreaseApproval(spender, subtractedValue); + } } diff --git a/contracts/interfaces/ERC677.sol b/contracts/interfaces/ERC677.sol index 9a2c9919b..06f2ef3a9 100644 --- a/contracts/interfaces/ERC677.sol +++ b/contracts/interfaces/ERC677.sol @@ -6,4 +6,6 @@ contract ERC677 is ERC20 { function transferAndCall(address, uint256, bytes) external returns (bool); + function increaseAllowance(address spender, uint256 addedValue) public returns (bool); + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool); } diff --git a/contracts/interfaces/IScdMcdMigration.sol b/contracts/interfaces/IScdMcdMigration.sol index 215bed94b..e52a217fe 100644 --- a/contracts/interfaces/IScdMcdMigration.sol +++ b/contracts/interfaces/IScdMcdMigration.sol @@ -8,3 +8,7 @@ interface IScdMcdMigration { interface IDaiAdapter { function dai() public returns (address); } + +interface ISaiTop { + function caged() public returns (uint256); +} diff --git a/contracts/mocks/ForeignBridgeErcToNativeMock.sol b/contracts/mocks/ForeignBridgeErcToNativeMock.sol new file mode 100644 index 000000000..4e6572808 --- /dev/null +++ b/contracts/mocks/ForeignBridgeErcToNativeMock.sol @@ -0,0 +1,20 @@ +pragma solidity 0.4.24; + +import "../upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol"; + +contract ForeignBridgeErcToNativeMock is ForeignBridgeErcToNative { + function migrationContract() internal pure returns (IScdMcdMigration) { + // Address generated in unit test + return IScdMcdMigration(0x44Bf5539DAAc4259f7F11A24280255ED2Fa3F7BF); + } + + function halfDuplexErc20token() public pure returns (ERC20) { + // Address generated in unit test + return ERC20(0x872D709De609c391741c7595F0053F6060e59e0D); + } + + function saiTopContract() internal pure returns (ISaiTop) { + // Address generated in unit test + return ISaiTop(0x96bc48adACdB60E6536E55a6727919a397F14540); + } +} diff --git a/contracts/mocks/SaiTopMock.sol b/contracts/mocks/SaiTopMock.sol new file mode 100644 index 000000000..5e3d5008d --- /dev/null +++ b/contracts/mocks/SaiTopMock.sol @@ -0,0 +1,9 @@ +pragma solidity 0.4.24; + +contract SaiTopMock { + uint256 public caged; + + function setCaged(uint256 _value) public { + caged = _value; + } +} diff --git a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index 1c4fb806f..a4e356f67 100644 --- a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -129,12 +129,12 @@ contract AbsoluteDailyLimit is EternalStorage { } function setMaxPerTx(uint256 _maxPerTx) external { - require(_maxPerTx < dailyLimit(0)); + require(_maxPerTx == 0 || (_maxPerTx > minPerTx() && _maxPerTx < dailyLimit(0))); uintStorage[MAX_PER_TX] = _maxPerTx; } function setMinPerTx(uint256 _minPerTx) external { - require(_minPerTx < dailyLimit(0) && _minPerTx < maxPerTx()); + require(_minPerTx > 0 && _minPerTx < dailyLimit(0) && _minPerTx < maxPerTx()); uintStorage[MIN_PER_TX] = _minPerTx; } diff --git a/contracts/upgradeable_contracts/BaseBridgeValidators.sol b/contracts/upgradeable_contracts/BaseBridgeValidators.sol index a55710d62..70d75ad68 100644 --- a/contracts/upgradeable_contracts/BaseBridgeValidators.sol +++ b/contracts/upgradeable_contracts/BaseBridgeValidators.sol @@ -8,7 +8,7 @@ contract BaseBridgeValidators is InitializableBridge, Ownable { using SafeMath for uint256; address public constant F_ADDR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF; - uint256 internal constant MAX_VALIDATORS = 100; + uint256 internal constant MAX_VALIDATORS = 50; bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // keccak256(abi.encodePacked("requiredSignatures")) bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // keccak256(abi.encodePacked("validatorCount")) @@ -24,7 +24,7 @@ contract BaseBridgeValidators is InitializableBridge, Ownable { } function getBridgeValidatorsInterfacesVersion() external pure returns (uint64 major, uint64 minor, uint64 patch) { - return (2, 2, 0); + return (2, 3, 0); } function validatorList() external view returns (address[]) { @@ -96,10 +96,30 @@ contract BaseBridgeValidators is InitializableBridge, Ownable { } function setValidatorCount(uint256 _validatorCount) internal { + require(_validatorCount <= MAX_VALIDATORS); uintStorage[VALIDATOR_COUNT] = _validatorCount; } function setNextValidator(address _prevValidator, address _validator) internal { addressStorage[keccak256(abi.encodePacked("validatorsList", _prevValidator))] = _validator; } + + function isValidatorDuty(address _validator) external view returns (bool) { + uint256 counter = 0; + address next = getNextValidator(F_ADDR); + require(next != address(0)); + + while (next != F_ADDR) { + if (next == _validator) { + return (block.number % validatorCount() == counter); + } + + next = getNextValidator(next); + counter++; + + require(next != address(0)); + } + + return false; + } } diff --git a/contracts/upgradeable_contracts/BridgeValidators.sol b/contracts/upgradeable_contracts/BridgeValidators.sol index 887baf835..8db5a1266 100644 --- a/contracts/upgradeable_contracts/BridgeValidators.sol +++ b/contracts/upgradeable_contracts/BridgeValidators.sol @@ -12,7 +12,6 @@ contract BridgeValidators is BaseBridgeValidators { setOwner(_owner); require(_requiredSignatures != 0); require(_initialValidators.length >= _requiredSignatures); - require(_initialValidators.length <= MAX_VALIDATORS); for (uint256 i = 0; i < _initialValidators.length; i++) { require(_initialValidators[i] != address(0) && _initialValidators[i] != F_ADDR); diff --git a/contracts/upgradeable_contracts/ERC20Bridge.sol b/contracts/upgradeable_contracts/ERC20Bridge.sol index 84519871c..7a1511206 100644 --- a/contracts/upgradeable_contracts/ERC20Bridge.sol +++ b/contracts/upgradeable_contracts/ERC20Bridge.sol @@ -20,6 +20,7 @@ contract ERC20Bridge is BasicForeignBridge { require(_receiver != address(0)); require(_receiver != address(this)); require(_amount > 0); + _updateTodayLimit(); require(withinLimit(_amount)); _increaseTotalSpentPerDay(_amount); diff --git a/contracts/upgradeable_contracts/RelativeDailyLimit.sol b/contracts/upgradeable_contracts/RelativeDailyLimit.sol index a6a4adb8c..6cbdde364 100644 --- a/contracts/upgradeable_contracts/RelativeDailyLimit.sol +++ b/contracts/upgradeable_contracts/RelativeDailyLimit.sol @@ -27,12 +27,12 @@ contract RelativeDailyLimit is BasicRelativeDailyLimit { } function setMinPerTx(uint256 _minPerTx) external { - require(_minPerTx < maxPerTx()); + require(_minPerTx > 0 && _minPerTx < maxPerTx()); uintStorage[MIN_PER_TX] = _minPerTx; } function setMaxPerTx(uint256 _maxPerTx) external { - require(_maxPerTx > minPerTx() || _maxPerTx == 0); + require(_maxPerTx == 0 || _maxPerTx > minPerTx()); uintStorage[MAX_PER_TX] = _maxPerTx; } } diff --git a/contracts/upgradeable_contracts/RewardableValidators.sol b/contracts/upgradeable_contracts/RewardableValidators.sol index f1a11545f..c71ebf4c5 100644 --- a/contracts/upgradeable_contracts/RewardableValidators.sol +++ b/contracts/upgradeable_contracts/RewardableValidators.sol @@ -14,7 +14,6 @@ contract RewardableValidators is BaseBridgeValidators { setOwner(_owner); require(_requiredSignatures != 0); require(_initialValidators.length >= _requiredSignatures); - require(_initialValidators.length <= MAX_VALIDATORS); require(_initialValidators.length == _initialRewards.length); for (uint256 i = 0; i < _initialValidators.length; i++) { diff --git a/contracts/upgradeable_contracts/VersionableBridge.sol b/contracts/upgradeable_contracts/VersionableBridge.sol index 615ac71e9..765b28209 100644 --- a/contracts/upgradeable_contracts/VersionableBridge.sol +++ b/contracts/upgradeable_contracts/VersionableBridge.sol @@ -2,7 +2,7 @@ pragma solidity 0.4.24; contract VersionableBridge { function getBridgeInterfacesVersion() external pure returns (uint64 major, uint64 minor, uint64 patch) { - return (2, 4, 0); + return (2, 5, 0); } /* solcov ignore next */ diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index a7a74b62a..224de17c2 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -8,6 +8,9 @@ import "../../interfaces/IScdMcdMigration.sol"; contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideBridgeStorage { event TokensSwapped(address indexed from, address indexed to, uint256 value); + bytes32 internal constant MIN_HDTOKEN_BALANCE = 0x48649cf195feb695632309f41e61252b09f537943654bde13eb7bb1bca06964e; // keccak256(abi.encodePacked("minHDTokenBalance")) + bytes4 internal constant SWAP_TOKENS = 0x73d00224; // swapTokens() + function initialize( address _validatorContract, address _erc20token, @@ -55,6 +58,11 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB function claimTokens(address _token, address _to) public { require(_token != address(erc20token())); + if (_token == address(halfDuplexErc20token())) { + // SCD is not claimable if the bridge accepts deposits of this token + // solhint-disable-next-line not-rely-on-time + require(!isTokenSwapAllowed(now)); + } super.claimTokens(_token, _to); } @@ -65,38 +73,130 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB ) internal returns (bool) { _increaseTotalExecutedPerDay(_amount); uint256 amount = _amount.div(10**decimalShift()); - return erc20token().transfer(_recipient, amount); + bool res = erc20token().transfer(_recipient, amount); + + if (tokenBalance(halfDuplexErc20token()) > 0) { + address(this).call(abi.encodeWithSelector(SWAP_TOKENS)); + } + + return res; } function onFailedMessage(address, uint256, bytes32) internal { revert(); } - function _relayTokens(address _sender, address _receiver, uint256 _amount) internal { - require(_receiver != bridgeContractOnOtherSide()); - super._relayTokens(_sender, _receiver, _amount); - } - - function migrateToMCD(address _migrationContract) external onlyOwner { + function migrateToMCD() external { bytes32 storageAddress = 0x3378953eb16363e06fd9ea9701d36ed7285d206d9de7df55b778462d74596a89; // keccak256(abi.encodePacked("migrationToMcdCompleted")) - require(!boolStorage[storageAddress]); - require(AddressUtils.isContract(_migrationContract)); - - uint256 curBalance = erc20token().balanceOf(address(this)); - require(erc20token().approve(_migrationContract, curBalance)); - //It is important to note that this action will cause appearing of `Transfer` - //event as part of the tokens minting - IScdMcdMigration(_migrationContract).swapSaiToDai(curBalance); - address saiContract = erc20token(); - address mcdContract = IDaiAdapter(IScdMcdMigration(_migrationContract).daiJoin()).dai(); + + address mcdContract = IDaiAdapter(migrationContract().daiJoin()).dai(); setErc20token(mcdContract); - require(erc20token().balanceOf(address(this)) == curBalance); - emit TokensSwapped(saiContract, erc20token(), curBalance); + uintStorage[MIN_HDTOKEN_BALANCE] = 10 ether; + + swapTokens(); + boolStorage[storageAddress] = true; } + function saiTopContract() internal pure returns (ISaiTop) { + return ISaiTop(0x9b0ccf7C8994E19F39b2B4CF708e0A7DF65fA8a3); + } + + function isTokenSwapAllowed(uint256 _ts) public view returns (bool) { + uint256 esTs = saiTopContract().caged(); + if (esTs > 0 && _ts > esTs) { + return false; + } + return true; + } + + function halfDuplexErc20token() public pure returns (ERC20) { + return ERC20(0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359); + } + + function setMinHDTokenBalance(uint256 _minBalance) external onlyOwner { + uintStorage[MIN_HDTOKEN_BALANCE] = _minBalance; + } + + function minHDTokenBalance() public view returns (uint256) { + return uintStorage[MIN_HDTOKEN_BALANCE]; + } + + function isHDTokenBalanceAboveMinBalance() public view returns (bool) { + if (tokenBalance(halfDuplexErc20token()) > minHDTokenBalance()) { + return true; + } + return false; + } + + function tokenBalance(ERC20 _token) internal view returns (uint256) { + return _token.balanceOf(address(this)); + } + + function migrationContract() internal pure returns (IScdMcdMigration) { + return IScdMcdMigration(0xc73e0383F3Aff3215E6f04B0331D58CeCf0Ab849); + } + + function swapTokens() public { + // solhint-disable-next-line not-rely-on-time + require(isTokenSwapAllowed(now)); + + IScdMcdMigration mcdMigrationContract = migrationContract(); + ERC20 hdToken = halfDuplexErc20token(); + ERC20 fdToken = erc20token(); + + uint256 curHDTokenBalance = tokenBalance(hdToken); + require(curHDTokenBalance > 0); + + uint256 curFDTokenBalance = tokenBalance(fdToken); + + require(hdToken.approve(mcdMigrationContract, curHDTokenBalance)); + mcdMigrationContract.swapSaiToDai(curHDTokenBalance); + + require(tokenBalance(fdToken).sub(curFDTokenBalance) == curHDTokenBalance); + + emit TokensSwapped(hdToken, fdToken, curHDTokenBalance); + } + + function relayTokens(address _from, address _receiver, uint256 _amount, address _token) external { + require(_from == msg.sender || _from == _receiver); + _relayTokens(_from, _receiver, _amount, _token); + } + + function relayTokens(address _receiver, uint256 _amount, address _token) external { + _relayTokens(msg.sender, _receiver, _amount, _token); + } + + function _relayTokens(address _sender, address _receiver, uint256 _amount, address _token) internal { + require(_receiver != bridgeContractOnOtherSide()); + require(_receiver != address(0)); + require(_receiver != address(this)); + require(_amount > 0); + _updateTodayLimit(); + require(withinLimit(_amount)); + + ERC20 tokenToOperate = ERC20(_token); + ERC20 hdToken = halfDuplexErc20token(); + ERC20 fdToken = erc20token(); + + if (tokenToOperate == ERC20(0x0)) { + tokenToOperate = fdToken; + } + + require(tokenToOperate == fdToken || tokenToOperate == hdToken); + + _increaseTotalSpentPerDay(_amount); + + tokenToOperate.transferFrom(_sender, address(this), _amount); + emit UserRequestForAffirmation(_receiver, _amount); + + if (tokenToOperate == hdToken) { + swapTokens(); + } + } + function _getTokenBalance() internal view returns (uint256) { return erc20token().balanceOf(address(this)); } diff --git a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol index 72767853f..d027951cd 100644 --- a/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol +++ b/contracts/upgradeable_contracts/native_to_erc20/HomeBridgeNativeToErc.sol @@ -14,6 +14,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom function nativeTransfer(address _receiver) internal { require(msg.value > 0); + _updateTodayLimit(); require(withinLimit(msg.value)); _increaseTotalSpentPerDay(msg.value); uint256 valueToTransfer = msg.value; diff --git a/scripts/test.sh b/scripts/test.sh index 758f3f1b6..287eb19f8 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -36,6 +36,7 @@ start_ganache() { --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" + --account="0x19fba401d77e4113b15095e9aa7117bcd25adcfac7f6111f8298894eef443600,1000000000000000000000000" ) if [ "$SOLIDITY_COVERAGE" != true ]; then diff --git a/test/erc_to_erc/home_bridge.test.js b/test/erc_to_erc/home_bridge.test.js index c055b6452..e9c48b2c9 100644 --- a/test/erc_to_erc/home_bridge.test.js +++ b/test/erc_to_erc/home_bridge.test.js @@ -14,7 +14,15 @@ const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, getEvents, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') +const { + createMessage, + sign, + getEvents, + ether, + expectEventInLogs, + calculateDailyLimit, + createAccounts +} = require('../helpers/helpers') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') @@ -27,6 +35,8 @@ const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther const foreignMinPerTx = minPerTx const ZERO = toBN(0) +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const decimalShiftZero = 0 const markedAsProcessed = toBN(2) .pow(toBN(255)) @@ -1853,6 +1863,35 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { balanceRewardAddress4.should.be.bignumber.equal(feePerValidator) balanceRewardAddress5.should.be.bignumber.equal(feePerValidator) }) + it('should distribute fee to max allowed number of validator', async () => { + // Given + const recipient = accounts[9] + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled + await blockRewardContract.setValidatorsRewards(rewards) + await blockRewardContract.setToken(token.address) + await token.setBlockRewardContract(blockRewardContract.address, { from: owner }) + await token.transferOwnership(homeBridge.address, { from: owner }) + + const valueCalc = 0.5 * (1 - fee) + const value = ether(valueCalc.toString()) + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipient, value, transactionHash, homeBridge.address) + const signature = await sign(validators[0], message) + + const blockRewardBalanceBefore = await token.balanceOf(blockRewardContract.address) + blockRewardBalanceBefore.should.be.bignumber.equal('0') + + // When + const { receipt } = await homeBridge.submitSignature(signature, message, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#rewardable_executeAffirmation', () => { let fee @@ -2065,6 +2104,32 @@ contract('HomeBridge_ERC20_to_ERC20', async accounts => { balanceRewardAddress4.should.be.bignumber.equal(feePerValidator) balanceRewardAddress5.should.be.bignumber.equal(feePerValidator) }) + + it('should distribute fee to max allowed number of validators', async () => { + // Given + const recipient = accounts[0] + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await blockRewardContract.setValidatorsRewards(rewards) + await blockRewardContract.setToken(token.address) + await token.setBlockRewardContract(blockRewardContract.address) + await token.transferOwnership(homeBridge.address) + + const initialValue = halfEther + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + + // When + const { receipt } = await homeBridge.executeAffirmation(recipient, initialValue, transactionHash, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#decimals Shift', async () => { const decimalShiftTwo = 2 diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index ecd00effb..d0fd5ee32 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -8,6 +8,8 @@ const ScdMcdMigrationMock = artifacts.require('ScdMcdMigrationMock.sol') const DaiAdapterMock = artifacts.require('DaiAdapterMock.sol') const AbsoluteDailyLimit = artifacts.require('AbsoluteDailyLimit.sol') const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLimit.sol') +const SaiTopMock = artifacts.require('SaiTopMock.sol') +const ForeignBridgeErcToNativeMock = artifacts.require('ForeignBridgeErcToNativeMock.sol') const { expect } = require('chai') const { expectEvent } = require('@openzeppelin/test-helpers') @@ -27,6 +29,7 @@ const halfEther = ether('0.5') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') const oneEther = ether('1') +const twoEthers = ether('2') const homeDailyLimit = oneEther const homeMaxPerTx = halfEther const homeMinPerTx = quarterEther @@ -50,6 +53,11 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { let otherSideBridge let absoluteLimitsContract let relativeLimitsContract + let sai + let dai + let migrationContract + let saiTop + const user = accounts[7] before(async () => { validatorContract = await BridgeValidators.new() @@ -59,6 +67,20 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { otherSideBridge = await ForeignBridge.new() absoluteLimitsContract = await AbsoluteDailyLimit.new() relativeLimitsContract = await RelativeExecutionDailyLimit.new() + + // Used account 11 to deploy contracts. The contract addresses will be hardcoded in ForeignBridgeErcToNativeMock + const deployAccount = accounts[10] + sai = await ERC20Mock.new('sai', 'SAI', 18, { from: deployAccount }) + saiTop = await SaiTopMock.new({ from: deployAccount }) + dai = await ERC20Mock.new('dai', 'DAI', 18) + const daiAdapterMock = await DaiAdapterMock.new(dai.address) + migrationContract = await ScdMcdMigrationMock.new(sai.address, daiAdapterMock.address, { from: deployAccount }) + await sai.transferOwnership(accounts[0], { from: deployAccount }) + + await dai.mint(user, ether('100000')) + + // migration contract can mint dai + await dai.transferOwnership(migrationContract.address) }) describe('#initialize', async () => { const shouldInitialize = isRelativeDailyLimit => @@ -242,7 +264,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const value = ether('0.25') let foreignBridge beforeEach(async () => { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeErcToNativeMock.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -261,7 +283,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const shouldAllowToExecuteSignatures = isRelativeDailyLimit => async function() { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeErcToNativeMock.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -357,7 +379,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const shouldNotAllowWithdrawOverHomeMaxTxLimit = isRelativeDailyLimit => async function() { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeErcToNativeMock.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -393,7 +415,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const shouldNotAllowWithdrawOverDailyHomeLimit = isRelativeDailyLimit => async function() { - foreignBridge = await ForeignBridge.new() + foreignBridge = await ForeignBridgeErcToNativeMock.new() token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) await foreignBridge.initialize( validatorContract.address, @@ -407,11 +429,12 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { otherSideBridge.address, isRelativeDailyLimit ? relativeLimitsContract.address : absoluteLimitsContract.address ) - await token.mint(foreignBridge.address, value) const recipientAccount = accounts[3] await token.mint(foreignBridge.address, ether('1.25')) + console.log((await foreignBridge.executionDailyLimit()).toString()) + const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) const signature = await sign(authorities[0], message) @@ -454,7 +477,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - foreignBridgeWithMultiSignatures = await ForeignBridge.new() + foreignBridgeWithMultiSignatures = await ForeignBridgeErcToNativeMock.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -521,7 +544,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await validatorContractWith3Signatures.initialize(3, authoritiesFiveAccs, ownerOfValidators) const erc20Token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18) const value = halfEther - const foreignBridgeWithThreeSigs = await ForeignBridge.new() + const foreignBridgeWithThreeSigs = await ForeignBridgeErcToNativeMock.new() await foreignBridgeWithThreeSigs.initialize( validatorContractWith3Signatures.address, @@ -685,7 +708,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const valueOnHome = toBN(valueOnForeign * 10 ** decimalShiftTwo) const owner = accounts[0] - const foreignBridgeImpl = await ForeignBridge.new() + const foreignBridgeImpl = await ForeignBridgeErcToNativeMock.new() const storageProxy = await EternalStorageProxy.new().should.be.fulfilled await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled const foreignBridge = await ForeignBridge.at(storageProxy.address) @@ -737,7 +760,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { await multisigValidatorContract.initialize(2, twoAuthorities, ownerOfValidatorContract, { from: ownerOfValidatorContract }) - const foreignBridgeWithMultiSignatures = await ForeignBridge.new() + const foreignBridgeWithMultiSignatures = await ForeignBridgeErcToNativeMock.new() await foreignBridgeWithMultiSignatures.initialize( multisigValidatorContract.address, token.address, @@ -1013,15 +1036,8 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) describe('migrateToMCD', () => { let foreignBridge - let sai - let dai - let migrationContract beforeEach(async () => { - foreignBridge = await ForeignBridge.new() - sai = await ERC20Mock.new('sai', 'SAI', 18) - dai = await ERC20Mock.new('dai', 'DAI', 18) - const daiAdapterMock = await DaiAdapterMock.new(dai.address) - migrationContract = await ScdMcdMigrationMock.new(sai.address, daiAdapterMock.address) + foreignBridge = await ForeignBridgeErcToNativeMock.new() await foreignBridge.initialize( validatorContract.address, @@ -1038,9 +1054,6 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { // Mint the bridge some sai tokens await sai.mint(foreignBridge.address, oneEther) - - // migration contract can mint dai - await dai.transferOwnership(migrationContract.address) }) it('should be able to swap tokens', async () => { // Given @@ -1050,33 +1063,379 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { // When - // migration address should be a contract - await foreignBridge.migrateToMCD(accounts[3], { from: owner }).should.be.rejectedWith(ERROR_MSG) - - // should be called by owner - await foreignBridge - .migrateToMCD(migrationContract.address, { from: accounts[5] }) - .should.be.rejectedWith(ERROR_MSG) - - const { logs } = await foreignBridge.migrateToMCD(migrationContract.address, { from: owner }).should.be.fulfilled + const { logs } = await foreignBridge.migrateToMCD({ from: owner }).should.be.fulfilled // can't migrate token again - await foreignBridge.migrateToMCD(migrationContract.address, { from: owner }).should.be.rejectedWith(ERROR_MSG) + await foreignBridge.migrateToMCD({ from: owner }).should.be.rejectedWith(ERROR_MSG) // Then expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) expect(await foreignBridge.erc20token()).to.be.equal(dai.address) + expect(await foreignBridge.minHDTokenBalance()).to.be.bignumber.equal(ether('10')) expectEventInLogs(logs, 'TokensSwapped', { from: sai.address, to: dai.address, value: oneEther }) const transferEvent = await getEvents(dai, { event: 'Transfer' }) - expect(transferEvent.length).to.be.equal(1) - expect(transferEvent[0].returnValues.from).to.be.equal(ZERO_ADDRESS) - expect(transferEvent[0].returnValues.to).to.be.equal(foreignBridge.address) - expect(transferEvent[0].returnValues.value).to.be.equal(oneEther.toString()) + + // first transfer event was for minting to user in the top Before section + expect(transferEvent.length).to.be.equal(2) + expect(transferEvent[1].returnValues.from).to.be.equal(ZERO_ADDRESS) + expect(transferEvent[1].returnValues.to).to.be.equal(foreignBridge.address) + expect(transferEvent[1].returnValues.value).to.be.equal(oneEther.toString()) + }) + }) + describe('support two tokens', () => { + let foreignBridge + const recipient = accounts[8] + beforeEach(async () => { + foreignBridge = await ForeignBridgeErcToNativeMock.new() + + await foreignBridge.initialize( + validatorContract.address, + dai.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + absoluteLimitsContract.address + ) + + // Mint sai tokens to a user + await sai.mint(user, twoEthers) + }) + describe('isTokenSwapAllowed', () => { + it('isTokenSwapAllowed should return true if SCD ES was executed', async () => { + // Given + expect(await foreignBridge.isTokenSwapAllowed(100)).to.be.equal(true) + + // When + await saiTop.setCaged(150) + + // Then + expect(await foreignBridge.isTokenSwapAllowed(100)).to.be.equal(true) + expect(await foreignBridge.isTokenSwapAllowed(150)).to.be.equal(true) + expect(await foreignBridge.isTokenSwapAllowed(200)).to.be.equal(false) + + // reset the caged value + await saiTop.setCaged(0) + }) + }) + describe('isHDTokenBalanceAboveMinBalance', () => { + it('isHDTokenBalanceAboveMinBalance should return true if balance above the threshold ', async () => { + const threshold = halfEther + // Given + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + + await foreignBridge.setMinHDTokenBalance(threshold) + + expect(await foreignBridge.minHDTokenBalance()).to.be.bignumber.equal(threshold) + + expect(await foreignBridge.isHDTokenBalanceAboveMinBalance()).to.be.equal(false) + + // When + await sai.mint(foreignBridge.address, oneEther) + + // Then + expect(await foreignBridge.isHDTokenBalanceAboveMinBalance()).to.be.equal(true) + }) + }) + describe('halfDuplexErc20token', () => { + it('should be able to get half duplex erc20 token', async () => { + expect(await foreignBridge.halfDuplexErc20token()).to.be.equal(sai.address) + }) + }) + describe('swapTokens', () => { + it('should be able to swap tokens calling swapTokens', async () => { + expect(await saiTop.caged()).to.be.bignumber.equal(ZERO) + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + + // should have sai balance + await foreignBridge.swapTokens().should.be.rejectedWith(ERROR_MSG) + + // mint sai tokens to bridge + await sai.mint(foreignBridge.address, oneEther) + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + + const { logs } = await foreignBridge.swapTokens() + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + expect(await foreignBridge.erc20token()).to.be.equal(dai.address) + expectEventInLogs(logs, 'TokensSwapped', { + from: sai.address, + to: dai.address, + value: oneEther + }) + + // mint more sai tokens to bridge + await sai.mint(foreignBridge.address, oneEther) + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + + await foreignBridge.swapTokens().should.be.fulfilled + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) + + const block = await web3.eth.getBlock('latest') + // Trigger Emergency Shutdown + await saiTop.setCaged(block.number) + + // mint sai tokens to bridge + await sai.mint(foreignBridge.address, oneEther) + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(oneEther) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(twoEthers) + + // should not be able to swap tokens after Emergency Shutdown + await foreignBridge.swapTokens().should.be.rejectedWith(ERROR_MSG) + + // reset the caged value + await saiTop.setCaged(0) + }) + }) + describe('relayTokens', () => { + const value = ether('0.25') + it('should allow to bridge tokens specifying the token address', async () => { + // Given + const balance = await dai.balanceOf(user) + const relayTokens = foreignBridge.methods['relayTokens(address,uint256,address)'] + + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await relayTokens(recipient, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + + await dai.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + // When + await relayTokens(ZERO_ADDRESS, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + await relayTokens(foreignBridge.address, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + await relayTokens(otherSideBridge.address, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + await relayTokens(recipient, 0, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + const { logs } = await relayTokens(recipient, value, dai.address, { from: user }).should.be.fulfilled + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient, + value + }) + expect(await dai.balanceOf(user)).to.be.bignumber.equal(balance.sub(value)) + }) + it('should use erc20Token if token address is zero', async () => { + // Given + const balance = await dai.balanceOf(user) + const relayTokens = foreignBridge.methods['relayTokens(address,uint256,address)'] + + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await dai.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + // When + const { logs } = await relayTokens(recipient, value, ZERO_ADDRESS, { from: user }).should.be.fulfilled + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient, + value + }) + expect(await dai.balanceOf(user)).to.be.bignumber.equal(balance.sub(value)) + }) + it('should swap token if half duplex token is used', async () => { + // Given + const relayTokens = foreignBridge.methods['relayTokens(address,uint256,address)'] + + const userBalance = await sai.balanceOf(user) + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + await sai.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + // When + const { logs } = await relayTokens(recipient, value, sai.address, { from: user }).should.be.fulfilled + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(value) + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient, + value + }) + expectEventInLogs(logs, 'TokensSwapped', { + from: sai.address, + to: dai.address, + value + }) + expect(await sai.balanceOf(user)).to.be.bignumber.equal(userBalance.sub(value)) + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(value) + }) + it('should fail if token address is unknown', async () => { + const otherToken = await ERC20Mock.new('token', 'TOK', 18) + await otherToken.mint(user, twoEthers) + + const relayTokens = foreignBridge.methods['relayTokens(address,uint256,address)'] + + await otherToken.approve(foreignBridge.address, value, { from: user }).should.be.fulfilled + + await relayTokens(recipient, value, otherToken.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + }) + it('should allow specify the sender and a different receiver', async () => { + // Given + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + const userBalance = await dai.balanceOf(user) + + const relayTokens = foreignBridge.methods['relayTokens(address,address,uint256,address)'] + + await relayTokens(user, recipient, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + + await dai.approve(foreignBridge.address, halfEther, { from: user }).should.be.fulfilled + + // When + await relayTokens(user, ZERO_ADDRESS, value, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + await relayTokens(user, foreignBridge.address, value, dai.address, { from: user }).should.be.rejectedWith( + ERROR_MSG + ) + await relayTokens(user, recipient, 0, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + await relayTokens(user, recipient, value, dai.address, { from: recipient }).should.be.rejectedWith(ERROR_MSG) + const { logs } = await relayTokens(user, recipient, value, dai.address, { from: user }).should.be.fulfilled + const { logs: logsSecondTx } = await relayTokens(user, user, value, dai.address, { from: recipient }).should.be + .fulfilled + + // Then + expectEventInLogs(logs, 'UserRequestForAffirmation', { + recipient, + value + }) + expectEventInLogs(logsSecondTx, 'UserRequestForAffirmation', { + recipient: user, + value + }) + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(halfEther) + expect(await dai.balanceOf(user)).to.be.bignumber.equal(userBalance.sub(halfEther)) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + }) + it('should not be able to transfer more than limit', async () => { + // Given + const userSupply = ether('2') + const bigValue = oneEther + const smallValue = ether('0.001') + const currentDay = await foreignBridge.getCurrentDay() + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(ZERO) + + const relayTokens = foreignBridge.methods['relayTokens(address,uint256,address)'] + + await dai.approve(foreignBridge.address, userSupply, { from: user }).should.be.fulfilled + + // When + // value < minPerTx + await relayTokens(recipient, smallValue, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + // value > maxPerTx + await relayTokens(recipient, bigValue, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + + await relayTokens(recipient, halfEther, dai.address, { from: user }).should.be.fulfilled + await relayTokens(recipient, halfEther, dai.address, { from: user }).should.be.fulfilled + // totalSpentPerDay > dailyLimit + await relayTokens(recipient, halfEther, dai.address, { from: user }).should.be.rejectedWith(ERROR_MSG) + + // Then + expect(await foreignBridge.totalSpentPerDay(currentDay)).to.be.bignumber.equal(oneEther) + }) + }) + describe('onExecuteMessage', () => { + it('should swapTokens in executeSignatures', async () => { + const value = ether('0.25') + const recipientAccount = accounts[3] + const balanceBefore = await dai.balanceOf(recipientAccount) + + // fund dai tokens + await dai.transfer(foreignBridge.address, value, { from: user }) + + // mint sai tokens to bridge + await sai.mint(foreignBridge.address, halfEther) + + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(authorities[0], message) + const vrs = signatureToVRS(signature) + expect(await foreignBridge.relayedMessages(transactionHash)).to.be.equal(false) + + const { logs } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + + expectEventInLogs(logs, 'RelayedMessage', { + recipient: recipientAccount, + value + }) + expectEventInLogs(logs, 'TokensSwapped', { + from: sai.address, + to: dai.address, + value: halfEther + }) + expect(await dai.balanceOf(recipientAccount)).to.be.bignumber.equal(balanceBefore.add(value)) + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await dai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await foreignBridge.relayedMessages(transactionHash)).to.be.equal(true) + }) + }) + describe('claimTokens', async () => { + it('can send erc20', async () => { + const foreignBridgeImpl = await ForeignBridgeErcToNativeMock.new() + const storageProxy = await EternalStorageProxy.new().should.be.fulfilled + await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled + const foreignBridge = await ForeignBridgeErcToNativeMock.at(storageProxy.address) + + await foreignBridge.initialize( + validatorContract.address, + dai.address, + requireBlockConfirmations, + gasPrice, + requestLimitsArray, + executionLimitsArray, + owner, + decimalShiftZero, + otherSideBridge.address, + absoluteLimitsContract.address + ) + + expect(await saiTop.caged()).to.be.bignumber.equal(ZERO) + + // Mint sai tokens to the bridge + await sai.mint(foreignBridge.address, halfEther) + + await foreignBridge.claimTokens(sai.address, accounts[3], { from: owner }).should.be.rejectedWith(ERROR_MSG) + + const block = await web3.eth.getBlock('latest') + // Trigger Emergency Shutdown + await saiTop.setCaged(block.number) + + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(halfEther) + expect(await sai.balanceOf(accounts[3])).to.be.bignumber.equal(ZERO) + + await foreignBridge + .claimTokens(sai.address, accounts[3], { from: accounts[3] }) + .should.be.rejectedWith(ERROR_MSG) + await foreignBridge.claimTokens(sai.address, accounts[3], { from: owner }) + expect(await sai.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) + expect(await sai.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther) + + // reset the caged value + await saiTop.setCaged(0) + }) }) }) describe('#executionDailyLimit (relative)', () => { diff --git a/test/erc_to_native/home_bridge.test.js b/test/erc_to_native/home_bridge.test.js index 0c04f7368..d84068147 100644 --- a/test/erc_to_native/home_bridge.test.js +++ b/test/erc_to_native/home_bridge.test.js @@ -13,7 +13,14 @@ const RelativeDailyLimit = artifacts.require('RelativeDailyLimit.sol') const { expect } = require('chai') const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') +const { + createMessage, + sign, + ether, + expectEventInLogs, + calculateDailyLimit, + createAccounts +} = require('../helpers/helpers') const requireBlockConfirmations = 8 const gasPrice = web3.utils.toWei('1', 'gwei') @@ -26,6 +33,8 @@ const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther const foreignMinPerTx = quarterEther const ZERO = toBN(0) +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') @@ -1022,6 +1031,13 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { minPerTx.should.be.bignumber.equal(toBN(1)) }) + it('setMaxPerTx allows to set limit to zero', async () => { + await homeContract.setMaxPerTx(0, { from: owner }).should.be.fulfilled + + const maxPerTx = await homeContract.maxPerTx() + maxPerTx.should.be.bignumber.equal(ZERO) + }) + it('setExecutionMaxPerTx allows to set only to owner and cannot be more than execution daily limit', async () => { const newValue = ether('0.3') @@ -2296,6 +2312,54 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + + it('should distribute fee to max allowed number of validators', async () => { + // Initialize + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await homeBridge.initialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await blockRewardContract.sendTransaction({ + from: owner, + value: oneEther + }).should.be.fulfilled + + // Given + const value = halfEther + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const feeManager = await FeeManagerErcToNative.new() + await homeBridge.setFeeManagerContract(feeManager.address, { from: owner }).should.be.fulfilled + await homeBridge.setForeignFee(feeInWei, { from: owner }).should.be.fulfilled + + const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' + + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + // When + const { receipt } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: validators[0] + }) + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#feeManager_fallback', async () => { let homeBridge @@ -2668,6 +2732,57 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + it('should distribute fee to max allowed number of validators', async () => { + // Initialize + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await homeBridge.initialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) + + // Given + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const feeManager = await FeeManagerErcToNative.new() + await homeBridge.setFeeManagerContract(feeManager.address, { from: owner }).should.be.fulfilled + await homeBridge.setHomeFee(feeInWei, { from: owner }).should.be.fulfilled + + const recipient = accounts[0] + const initialValue = halfEther + const valueCalc = 0.5 * (1 - fee) + const value = ether(valueCalc.toString()) + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + // When + await homeBridge.sendTransaction({ from: recipient, value: initialValue }).should.be.fulfilled + + const message = createMessage(recipient, value, transactionHash, homeBridge.address) + + const signature = await sign(validators[0], message) + + const { receipt } = await homeBridge.submitSignature(signature, message, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#FeeManager_random', async () => { it('should return value between 0 and 3', async () => { @@ -2993,6 +3108,54 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const feeAmountBlockReward = await blockRewardContract.feeAmount() expect(toBN(feeAmountBlockReward)).to.be.bignumber.equal(feeAmount) }) + it('should distribute fee to max allowed number of validators', async () => { + // Initialize + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await blockRewardContract.setValidatorsRewards(rewards) + await homeBridge.initialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await blockRewardContract.sendTransaction({ + from: accounts[0], + value: oneEther + }).should.be.fulfilled + + // Given + const value = halfEther + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const feeManager = await FeeManagerErcToNativePOSDAO.new() + await homeBridge.setFeeManagerContract(feeManager.address, { from: owner }).should.be.fulfilled + await homeBridge.setForeignFee(feeInWei, { from: owner }).should.be.fulfilled + + const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' + + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + // When + const { receipt } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#feeManager_fallback_POSDAO', async () => { let homeBridge @@ -3396,6 +3559,58 @@ contract('HomeBridge_ERC20_to_Native', async accounts => { const feeAmountBlockReward = await blockRewardContract.feeAmount() feeAmountBlockReward.should.be.bignumber.equal(feeAmount) }) + it('should distribute fee to max allowed number of validators', async () => { + // Initialize + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await blockRewardContract.setValidatorsRewards(rewards) + await homeBridge.initialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + blockRewardContract.address, + [foreignDailyLimit, foreignMaxPerTx, foreignMinPerTx], + owner, + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await blockRewardContract.addMintedTotallyByBridge(oneEther, homeBridge.address) + + // Given + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const feeManager = await FeeManagerErcToNativePOSDAO.new() + await homeBridge.setFeeManagerContract(feeManager.address, { from: owner }).should.be.fulfilled + await homeBridge.setHomeFee(feeInWei, { from: owner }).should.be.fulfilled + + const recipient = accounts[0] + const initialValue = halfEther + const valueCalc = 0.5 * (1 - fee) + const value = ether(valueCalc.toString()) + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + // When + await homeBridge.sendTransaction({ from: recipient, value: initialValue }).should.be.fulfilled + + const message = createMessage(recipient, value, transactionHash, homeBridge.address) + + const signature = await sign(validators[0], message) + + const { receipt } = await homeBridge.submitSignature(signature, message, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#decimals Shift', async () => { const decimalShiftTwo = 2 diff --git a/test/native_to_erc/foreign_bridge_test.js b/test/native_to_erc/foreign_bridge_test.js index 41cef859e..2cd766e24 100644 --- a/test/native_to_erc/foreign_bridge_test.js +++ b/test/native_to_erc/foreign_bridge_test.js @@ -20,7 +20,8 @@ const { getEvents, ether, expectEventInLogs, - calculateDailyLimit + calculateDailyLimit, + createAccounts } = require('../helpers/helpers') const oneEther = ether('1') @@ -32,6 +33,8 @@ const homeDailyLimit = oneEther const homeMaxPerTx = halfEther const homeMinPerTx = minPerTx const ZERO = toBN(0) +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') @@ -1536,6 +1539,44 @@ contract('ForeignBridge_Native_to_ERC', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + it('should distribute fee to max allowed number of validators', async () => { + // Given + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const value = halfEther + + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner).should.be.fulfilled + await foreignBridge.rewardableInitialize( + rewardableValidators.address, + token.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + [homeDailyLimit, homeMaxPerTx, homeMinPerTx], + owner, + feeManager.address, + feeInWei, + decimalShiftZero, + otherSideBridgeAddress, + absoluteLimitsContract.address + ).should.be.fulfilled + await token.transferOwnership(foreignBridge.address) + + const recipientAccount = accounts[0] + + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(recipientAccount, value, transactionHash, foreignBridge.address) + const signature = await sign(validators[0], message) + const vrs = signatureToVRS(signature) + + // When + const { receipt } = await foreignBridge.executeSignatures([vrs.v], [vrs.r], [vrs.s], message).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#decimalShift', async () => { const decimalShiftTwo = 2 diff --git a/test/native_to_erc/home_bridge_test.js b/test/native_to_erc/home_bridge_test.js index 1c5db8c1b..95145501d 100644 --- a/test/native_to_erc/home_bridge_test.js +++ b/test/native_to_erc/home_bridge_test.js @@ -13,7 +13,14 @@ const RelativeExecutionDailyLimit = artifacts.require('RelativeExecutionDailyLim const { expect } = require('chai') const { expectEvent } = require('@openzeppelin/test-helpers') const { ERROR_MSG, ZERO_ADDRESS, toBN } = require('../setup') -const { createMessage, sign, ether, expectEventInLogs, calculateDailyLimit } = require('../helpers/helpers') +const { + createMessage, + sign, + ether, + expectEventInLogs, + calculateDailyLimit, + createAccounts +} = require('../helpers/helpers') const minPerTx = ether('0.01') const requireBlockConfirmations = 8 @@ -25,6 +32,8 @@ const foreignDailyLimit = oneEther const foreignMaxPerTx = halfEther const foreignMinPerTx = minPerTx const ZERO = toBN(0) +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const decimalShiftZero = 0 const targetLimit = ether('0.05') const threshold = ether('10000') @@ -570,7 +579,7 @@ contract('HomeBridge_Native_to_ERC', async accounts => { homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, - [twoEther, halfEther, minPerTx], + [twoEther, oneEther, minPerTx], gasPrice, requireBlockConfirmations, isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, @@ -580,18 +589,17 @@ contract('HomeBridge_Native_to_ERC', async accounts => { ) await homeBridge.sendTransaction({ from: accounts[2], - value: halfEther + value: oneEther }).should.be.fulfilled const recipient = accounts[5] const value = halfEther - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }) const balanceBefore = toBN(await web3.eth.getBalance(recipient)) const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' const { logs } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { from: authorities[0] - }) + }).should.be.fulfilled expectEventInLogs(logs, 'SignedForAffirmation', { signer: authorities[0], @@ -862,7 +870,7 @@ contract('HomeBridge_Native_to_ERC', async accounts => { homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, - [twoEther, halfEther, minPerTx], + [twoEther, oneEther, minPerTx], gasPrice, requireBlockConfirmations, isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, @@ -872,7 +880,7 @@ contract('HomeBridge_Native_to_ERC', async accounts => { ) await homeBridge.sendTransaction({ from: accounts[2], - value: halfEther + value: oneEther }).should.be.fulfilled const recipient = accounts[5] @@ -896,7 +904,7 @@ contract('HomeBridge_Native_to_ERC', async accounts => { homeBridge = await HomeBridge.new() await homeBridge.initialize( validatorContract.address, - [twoEther, halfEther, minPerTx], + [twoEther, oneEther.add(halfEther), minPerTx], gasPrice, requireBlockConfirmations, isRelativeDailyLimit ? relativeExecutionLimitsArray : executionLimitsArray, @@ -906,12 +914,9 @@ contract('HomeBridge_Native_to_ERC', async accounts => { ) await homeBridge.sendTransaction({ from: accounts[2], - value: halfEther + value: oneEther.add(halfEther) }).should.be.fulfilled - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled - await homeBridge.sendTransaction({ from: accounts[2], value: halfEther }).should.be.fulfilled - const recipient = accounts[5] const value = halfEther const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' @@ -1915,6 +1920,53 @@ contract('HomeBridge_Native_to_ERC', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + it('should distribute fee to max allowed number of validators', async () => { + // Given + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + + const value = halfEther + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const notUsedFee = ZERO + + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + const feeManager = await FeeManagerNativeToErc.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await homeBridge.rewardableInitialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + executionLimitsArray, + owner, + feeManager.address, + [notUsedFee, feeInWei], + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled + + const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' + + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + // When + const { receipt } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#feeManager_BothDirections_fallback', () => { @@ -2261,6 +2313,57 @@ contract('HomeBridge_Native_to_ERC', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + it('should distribute fee to max allowed number of validators', async () => { + // Initialize + const user = accounts[0] + const owner = accounts[9] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + const feeManager = await FeeManagerNativeToErcBothDirections.new() + + // Given + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + const initialValue = halfEther + const valueCalc = 0.5 * (1 - fee) + const value = ether(valueCalc.toString()) + + await homeBridge.rewardableInitialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + executionLimitsArray, + owner, + feeManager.address, + [feeInWei, feeInWei], + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + + await homeBridge.sendTransaction({ + from: user, + value: initialValue + }).should.be.fulfilled + + // When + const transactionHash = '0x1045bfe274b88120a6b1e5d01b5ec00ab5d01098346e90e7c7a3c9b8f0181c80' + const message = createMessage(user, value, transactionHash, homeBridge.address) + const signature = await sign(validators[0], message) + + const { receipt } = await homeBridge.submitSignature(signature, message, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#feeManager_BothDirections_ExecuteAffirmation', async () => { @@ -2543,6 +2646,51 @@ contract('HomeBridge_Native_to_ERC', async accounts => { updatedBalanceRewardAddress4.should.be.bignumber.equal(initialBalanceRewardAddress4.add(feePerValidator)) updatedBalanceRewardAddress5.should.be.bignumber.equal(initialBalanceRewardAddress5.add(feePerValidator)) }) + it('should distribute fee to max allowed number of validators', async () => { + // Given + const owner = accounts[0] + const validators = createAccounts(web3, MAX_VALIDATORS) + validators[0] = accounts[2] + const rewards = createAccounts(web3, MAX_VALIDATORS) + const requiredSignatures = 1 + + const value = halfEther + // 0.1% fee + const fee = 0.001 + const feeInWei = ether(fee.toString()) + + const rewardableValidators = await RewardableValidators.new() + const homeBridge = await HomeBridge.new() + const feeManager = await FeeManagerNativeToErcBothDirections.new() + await rewardableValidators.initialize(requiredSignatures, validators, rewards, owner, { + from: owner + }).should.be.fulfilled + await homeBridge.rewardableInitialize( + rewardableValidators.address, + [oneEther, halfEther, minPerTx], + gasPrice, + requireBlockConfirmations, + executionLimitsArray, + owner, + feeManager.address, + [feeInWei, feeInWei], + decimalShiftZero, + absoluteLimitsContract.address + ).should.be.fulfilled + await homeBridge.sendTransaction({ + from: accounts[0], + value: halfEther + }).should.be.fulfilled + + const recipient = '0xf4BEF13F9f4f2B203FAF0C3cBbaAbe1afE056955' + + const transactionHash = '0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415' + + const { receipt } = await homeBridge.executeAffirmation(recipient, value, transactionHash, { + from: validators[0] + }).should.be.fulfilled + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + }) }) describe('#decimalShift', async () => { const decimalShiftTwo = 2 diff --git a/test/poa20_test.js b/test/poa20_test.js index d913e1e65..cce410294 100644 --- a/test/poa20_test.js +++ b/test/poa20_test.js @@ -395,6 +395,32 @@ async function testERC677BridgeToken(accounts, rewardable) { } }) + describe('#increaseAllowance', async () => { + it('can increase allowance', async () => { + const twoEther = ether('2') + const user2 = accounts[2] + + await token.mint(user, oneEther, { from: owner }).should.be.fulfilled + await token.approve(user2, oneEther, { from: user }).should.be.fulfilled + await token.increaseAllowance(user2, oneEther, { from: user }).should.be.fulfilled + + expect(await token.allowance(user, user2)).to.be.bignumber.equal(twoEther) + }) + }) + + describe('#decreaseAllowance', async () => { + it('can decrease allowance', async () => { + const twoEther = ether('2') + const user2 = accounts[2] + + await token.mint(user, twoEther, { from: owner }).should.be.fulfilled + await token.approve(user2, twoEther, { from: user }).should.be.fulfilled + await token.decreaseAllowance(user2, oneEther, { from: user }).should.be.fulfilled + + expect(await token.allowance(user, user2)).to.be.bignumber.equal(oneEther) + }) + }) + describe('#burn', async () => { it('can burn', async () => { await token.burn(100, { from: owner }).should.be.rejectedWith(ERROR_MSG) diff --git a/test/rewardable_validators_test.js b/test/rewardable_validators_test.js index d36b850cb..62989e7e9 100644 --- a/test/rewardable_validators_test.js +++ b/test/rewardable_validators_test.js @@ -5,6 +5,8 @@ const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, F_ADDRESS, BN } = require('./setup') const { expectEventInLogs, createAccounts } = require('./helpers/helpers') +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const ZERO = new BN(0) contract('RewardableValidators', async accounts => { @@ -62,18 +64,32 @@ contract('RewardableValidators', async accounts => { }) it('should fail if exceed amount of validators', async () => { // Given - const validators = createAccounts(web3, 101) + const validators = createAccounts(web3, MAX_VALIDATORS + 1) // When await bridgeValidators - .initialize(99, validators, validators, accounts[2], { from: accounts[2] }) + .initialize(MAX_VALIDATORS - 1, validators, validators, accounts[2], { from: accounts[2] }) .should.be.rejectedWith(ERROR_MSG) - await bridgeValidators.initialize(99, validators.slice(0, 100), validators.slice(0, 100), accounts[2], { + }) + + it('should be able to operate with max allowed number of validators', async () => { + // Given + const validators = createAccounts(web3, MAX_VALIDATORS) + + // When + const { receipt } = await bridgeValidators.initialize(MAX_VALIDATORS - 1, validators, validators, accounts[2], { from: accounts[2] }).should.be.fulfilled - // Then - expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal('100') + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal(`${MAX_VALIDATORS}`) + + // removing last validator from list (the highest gas consumption) + await bridgeValidators.removeValidator(validators[MAX_VALIDATORS - 1], { + from: accounts[2] + }).should.be.fulfilled + + expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal(`${MAX_VALIDATORS - 1}`) }) }) @@ -267,7 +283,7 @@ contract('RewardableValidators', async accounts => { await proxy.upgradeTo('1', bridgeValidatorsImpl.address) bridgeValidators = await BridgeValidators.at(proxy.address) const { initialize, isInitialized, removeValidator } = bridgeValidators - await initialize(1, accounts.slice(0, 5), accounts.slice(5), owner, { from: owner }).should.be.fulfilled + await initialize(1, accounts.slice(0, 5), accounts.slice(5, 10), owner, { from: owner }).should.be.fulfilled true.should.be.equal(await isInitialized()) // When @@ -283,7 +299,7 @@ contract('RewardableValidators', async accounts => { it(`reward address is properly assigned`, async () => { // Given const { initialize, isInitialized, getValidatorRewardAddress } = bridgeValidators - await initialize(1, accounts.slice(0, 5), accounts.slice(5), owner, { from: owner }).should.be.fulfilled + await initialize(1, accounts.slice(0, 5), accounts.slice(5, 10), owner, { from: owner }).should.be.fulfilled // When expect(await isInitialized()).to.be.equal(true) @@ -302,7 +318,7 @@ contract('RewardableValidators', async accounts => { const { initialize, validatorList } = bridgeValidators // When - await initialize(1, validators, accounts.slice(5), owner, { from: owner }).should.be.fulfilled + await initialize(1, validators, accounts.slice(5, 10), owner, { from: owner }).should.be.fulfilled // Then expect(await validatorList()).to.be.eql(validators) diff --git a/test/validators_test.js b/test/validators_test.js index a5969f7d3..f2c2c7caa 100644 --- a/test/validators_test.js +++ b/test/validators_test.js @@ -5,6 +5,8 @@ const { expect } = require('chai') const { ERROR_MSG, ZERO_ADDRESS, F_ADDRESS, BN } = require('./setup') const { expectEventInLogs, createAccounts } = require('./helpers/helpers') +const MAX_GAS = 8000000 +const MAX_VALIDATORS = 50 const ZERO = new BN(0) contract('BridgeValidators', async accounts => { @@ -50,17 +52,30 @@ contract('BridgeValidators', async accounts => { }) it('should fail if exceed amount of validators', async () => { // Given - const validators = createAccounts(web3, 101) + const validators = createAccounts(web3, MAX_VALIDATORS + 1) // When await bridgeValidators - .initialize(99, validators, accounts[2], { from: accounts[2] }) + .initialize(MAX_VALIDATORS - 1, validators, accounts[2], { from: accounts[2] }) .should.be.rejectedWith(ERROR_MSG) - await bridgeValidators.initialize(99, validators.slice(0, 100), accounts[2], { from: accounts[2] }).should.be - .fulfilled + }) - // Then - expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal('100') + it('should be able to operate with max allowed number of validators', async () => { + // Given + const validators = createAccounts(web3, MAX_VALIDATORS) + + // When + const { receipt } = await bridgeValidators.initialize(MAX_VALIDATORS - 1, validators, accounts[2], { + from: accounts[2] + }).should.be.fulfilled + + expect(receipt.gasUsed).to.be.lte(MAX_GAS) + expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal(`${MAX_VALIDATORS}`) + + // removing last validator from list (the highest gas consumption) + await bridgeValidators.removeValidator(validators[MAX_VALIDATORS - 1], { from: accounts[2] }).should.be.fulfilled + + expect(await bridgeValidators.validatorCount()).to.be.bignumber.equal(`${MAX_VALIDATORS - 1}`) }) }) @@ -248,4 +263,18 @@ contract('BridgeValidators', async accounts => { returnedList.should.be.eql(validators) }) }) + describe('#isValidatorDuty', () => { + it('should return if provided valdidator is on duty', async () => { + // Given + const validators = accounts.slice(0, 5) + const { initialize, isValidatorDuty } = bridgeValidators + await initialize(1, validators, owner, { from: owner }).should.be.fulfilled + + // When + const results = await Promise.all(validators.map(v => isValidatorDuty(v))) + + // Then + expect(results.filter(r => r === true).length).to.be.equal(1) + }) + }) }) diff --git a/truffle-config.js b/truffle-config.js index dec355d8c..0c83d6ef4 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -29,9 +29,54 @@ if (process.env.SOLIDITY_COVERAGE === 'true') { }) provider.addProvider(global.coverageSubprovider) const ganacheSubprovider = new GanacheSubprovider({ - default_balance_ether: '1000000000000000000000000', - total_accounts: 10, - port: 8545 + accounts: [ + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209', + balance: '1000000000000000000000000' + }, + { + secretKey: '0x19fba401d77e4113b15095e9aa7117bcd25adcfac7f6111f8298894eef443600', + balance: '1000000000000000000000000' + } + ], + port: 8545, + gasLimit: 10000000 }) provider.addProvider(ganacheSubprovider) provider.start(err => { @@ -47,13 +92,15 @@ module.exports = { networks: { development: { provider, - network_id: '*' + network_id: '*', + gas: 10000000 }, ganache: { host: '127.0.0.1', port: 8545, network_id: '*', // eslint-disable-line camelcase - gasPrice: 100000000000 + gasPrice: 100000000000, + gas: 10000000 } }, compilers: { diff --git a/upgrade/.env.example b/upgrade/.env.example new file mode 100644 index 000000000..ce973f966 --- /dev/null +++ b/upgrade/.env.example @@ -0,0 +1,18 @@ +HOME_RPC_URL=https://dai.poa.network +HOME_PRIVKEY=0x... +HOME_BRIDGE_ADDRESS=0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6 +HOME_START_BLOCK=7384314 +HOME_GAS_PRICE=1000000000 + +FOREIGN_RPC_URL=https://mainnet.infura.io/v3/API_KEY +FOREIGN_PRIVKEY=0x... +FOREING_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016 +FOREIGN_START_BLOCK=9122083 +FOREIGN_GAS_PRICE=1000000000 + +# leader or confirm +ROLE=confirm + +NEW_IMPLEMENTATION_XDAI_BRIDGE= +NEW_IMPLEMENTATION_ETH_VALIDATORS= +NEW_IMPLEMENTATION_ETH_BRIDGE= diff --git a/upgrade/.eslintrc b/upgrade/.eslintrc new file mode 100644 index 000000000..9b35f4dee --- /dev/null +++ b/upgrade/.eslintrc @@ -0,0 +1,12 @@ +{ + "extends": ["plugin:node/recommended", "airbnb-base", "plugin:prettier/recommended"], + "plugins": ["node"], + "env": { + "node": true + }, + "rules": { + "no-use-before-define": ["error", { "functions": false }], + "node/no-unpublished-require": "off", + "no-console": "off" + } +} diff --git a/upgrade/.gitignore b/upgrade/.gitignore new file mode 100644 index 000000000..6ed48a986 --- /dev/null +++ b/upgrade/.gitignore @@ -0,0 +1,2 @@ +.env +node_modules diff --git a/upgrade/.nvmrc b/upgrade/.nvmrc new file mode 100644 index 000000000..ec3053c8d --- /dev/null +++ b/upgrade/.nvmrc @@ -0,0 +1 @@ +10.15 diff --git a/upgrade/.prettierrc b/upgrade/.prettierrc new file mode 100644 index 000000000..29c575606 --- /dev/null +++ b/upgrade/.prettierrc @@ -0,0 +1,6 @@ +{ + "semi": false, + "singleQuote": true, + "printWidth": 120, + "bracketSpacing": true +} diff --git a/upgrade/README.md b/upgrade/README.md new file mode 100644 index 000000000..4e8f1d068 --- /dev/null +++ b/upgrade/README.md @@ -0,0 +1,27 @@ +### How to run upgrade scripts + +Install dependencies in root project and compile the contracts +```bash +cd .. +npm i +npm run compile +``` + +Install dependencies from `upgrade` folder +```bash +cd upgrade +npm i +``` + +Create `.env` file +```bash +cp .env.example .env +``` + +Complete the variables in `.env` file. The `ROLE` variable indicates if the validator will send the creation transaction on the multisig wallet or if it will send the confirmation. + +Run the script. The following are available: +* `npm run upgradeBridgeOnHome` +* `npm run upgradeValidatorsOnForeign` +* `npm run upgradeBridgeOnForeign` +* `npm run migrateToMCD` diff --git a/upgrade/abi/multiSigwallet.json b/upgrade/abi/multiSigwallet.json new file mode 100644 index 000000000..4dedfcffd --- /dev/null +++ b/upgrade/abi/multiSigwallet.json @@ -0,0 +1,265 @@ +[ + { + "constant": true, + "inputs": [{ "name": "", "type": "uint256" }], + "name": "owners", + "outputs": [{ "name": "", "type": "address" }], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "owner", "type": "address" }], + "name": "removeOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "revokeConfirmation", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "", "type": "address" }], + "name": "isOwner", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "name": "", "type": "uint256" }, + { "name": "", "type": "address" } + ], + "name": "confirmations", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "name": "pending", "type": "bool" }, + { "name": "executed", "type": "bool" } + ], + "name": "getTransactionCount", + "outputs": [{ "name": "count", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "owner", "type": "address" }], + "name": "addOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "isConfirmed", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "getConfirmationCount", + "outputs": [{ "name": "count", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "", "type": "uint256" }], + "name": "transactions", + "outputs": [ + { "name": "destination", "type": "address" }, + { "name": "value", "type": "uint256" }, + { "name": "data", "type": "bytes" }, + { "name": "executed", "type": "bool" } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getOwners", + "outputs": [{ "name": "", "type": "address[]" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "name": "from", "type": "uint256" }, + { "name": "to", "type": "uint256" }, + { "name": "pending", "type": "bool" }, + { "name": "executed", "type": "bool" } + ], + "name": "getTransactionIds", + "outputs": [{ "name": "_transactionIds", "type": "uint256[]" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "getConfirmations", + "outputs": [{ "name": "_confirmations", "type": "address[]" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "transactionCount", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_required", "type": "uint256" }], + "name": "changeRequirement", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "confirmTransaction", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "destination", "type": "address" }, + { "name": "value", "type": "uint256" }, + { "name": "data", "type": "bytes" } + ], + "name": "submitTransaction", + "outputs": [{ "name": "transactionId", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OWNER_COUNT", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "required", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "owner", "type": "address" }, + { "name": "newOwner", "type": "address" } + ], + "name": "replaceOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "transactionId", "type": "uint256" }], + "name": "executeTransaction", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "inputs": [ + { "name": "_owners", "type": "address[]" }, + { "name": "_required", "type": "uint256" } + ], + "payable": false, + "type": "constructor" + }, + { "payable": true, "type": "fallback" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "sender", "type": "address" }, + { "indexed": true, "name": "transactionId", "type": "uint256" } + ], + "name": "Confirmation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "sender", "type": "address" }, + { "indexed": true, "name": "transactionId", "type": "uint256" } + ], + "name": "Revocation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }], + "name": "Submission", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }], + "name": "Execution", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }], + "name": "ExecutionFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "sender", "type": "address" }, + { "indexed": false, "name": "value", "type": "uint256" } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "name": "owner", "type": "address" }], + "name": "OwnerAddition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "name": "owner", "type": "address" }], + "name": "OwnerRemoval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "name": "required", "type": "uint256" }], + "name": "RequirementChange", + "type": "event" + } +] diff --git a/upgrade/package-lock.json b/upgrade/package-lock.json new file mode 100644 index 000000000..ff3a248de --- /dev/null +++ b/upgrade/package-lock.json @@ -0,0 +1,3879 @@ +{ + "name": "upgrade-xdai", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@sindresorhus/is": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", + "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==" + }, + "@szmarczak/http-timer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", + "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", + "requires": { + "defer-to-connect": "^1.0.1" + } + }, + "@types/bignumber.js": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/bignumber.js/-/bignumber.js-5.0.0.tgz", + "integrity": "sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA==", + "requires": { + "bignumber.js": "*" + } + }, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "12.12.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.20.tgz", + "integrity": "sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ==" + }, + "@web3-js/scrypt-shim": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@web3-js/scrypt-shim/-/scrypt-shim-0.1.0.tgz", + "integrity": "sha512-ZtZeWCc/s0nMcdx/+rZwY1EcuRdemOK9ag21ty9UsHkFxsNb/AaoucUz0iPuyGe0Ku+PFuRmWZG7Z7462p9xPw==", + "requires": { + "scryptsy": "^2.1.0", + "semver": "^6.3.0" + } + }, + "@web3-js/websocket": { + "version": "1.0.30", + "resolved": "https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.30.tgz", + "integrity": "sha512-fDwrD47MiDrzcJdSeTLF75aCcxVVt8B1N74rA+vh2XCAvFy4tEWJjtnUtj2QG7/zlQ6g9cQ88bZFBxwd9/FmtA==", + "requires": { + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "nan": "^2.14.0", + "typedarray-to-buffer": "^3.1.5", + "yaeti": "^0.0.6" + } + }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "acorn": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + }, + "acorn-jsx": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", + "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "dev": true + }, + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-escapes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", + "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", + "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "bignumber.js": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", + "integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==" + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "bl": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, + "browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "requires": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "buffer": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", + "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" + }, + "buffer-to-arraybuffer": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", + "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=" + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "cacheable-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", + "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^3.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^1.0.2" + }, + "dependencies": { + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "requires": { + "pump": "^3.0.0" + } + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" + } + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "chownr": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "requires": { + "mimic-response": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "confusing-browser-globals": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", + "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==", + "dev": true + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "create-ecdh": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, + "create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "requires": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "requires": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" + }, + "decompress": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.0.tgz", + "integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=", + "requires": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + } + }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "requires": { + "mimic-response": "^1.0.0" + } + }, + "decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "requires": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + } + }, + "decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "requires": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "dependencies": { + "file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==" + } + } + }, + "decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "requires": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + } + }, + "decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=", + "requires": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "dependencies": { + "file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" + }, + "get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", + "requires": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + } + } + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defer-to-connect": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.1.tgz", + "integrity": "sha512-J7thop4u3mRTkYRQ+Vpfwy2G5Ehoy82I14+14W4YMDLKdWloI9gSzRbV30s/NckQGVJtPkWNcW4oMAUigTdqiQ==" + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "dom-walk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", + "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" + }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, + "drbg.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", + "integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", + "requires": { + "browserify-aes": "^1.0.6", + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4" + } + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "elliptic": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", + "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "es-abstract": { + "version": "1.17.0-next.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz", + "integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.0", + "string.prototype.trimright": "^2.1.0" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es5-ext": { + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", + "requires": { + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "6.7.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.2.tgz", + "integrity": "sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.3", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "eslint-config-airbnb-base": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.0.0.tgz", + "integrity": "sha512-2IDHobw97upExLmsebhtfoD3NAKhV4H0CJWP3Uprd/uk+cHuWYOczPVxQ8PxLFUAw7o3Th1RAU8u1DoUpr+cMA==", + "dev": true, + "requires": { + "confusing-browser-globals": "^1.0.7", + "object.assign": "^4.1.0", + "object.entries": "^1.1.0" + } + }, + "eslint-config-prettier": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.7.0.tgz", + "integrity": "sha512-FamQVKM3jjUVwhG4hEMnbtsq7xOIDm+SY5iBPfR8gKsJoAB2IQnNF+bk1+8Fy44Nq7PPJaLvkRxILYdJWoguKQ==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, + "eslint-plugin-es": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-2.0.0.tgz", + "integrity": "sha512-f6fceVtg27BR02EYnBhgWLFQfK6bN4Ll0nQFrBHOlCsAyxeZkn0NHns5O0YZOPrV1B3ramd6cgFwaoFLcSkwEQ==", + "dev": true, + "requires": { + "eslint-utils": "^1.4.2", + "regexpp": "^3.0.0" + }, + "dependencies": { + "regexpp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz", + "integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==", + "dev": true + } + } + }, + "eslint-plugin-node": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-10.0.0.tgz", + "integrity": "sha512-1CSyM/QCjs6PXaT18+zuAXsjXGIGo5Rw630rSKwokSs2jrYURQc4R5JZpoanNCqwNmepg+0eZ9L7YiRUJb8jiQ==", + "dev": true, + "requires": { + "eslint-plugin-es": "^2.0.0", + "eslint-utils": "^1.4.2", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", + "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", + "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "espree": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", + "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "dev": true, + "requires": { + "acorn": "^7.1.0", + "acorn-jsx": "^5.1.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "eth-ens-namehash": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", + "integrity": "sha1-IprEbsqG1S4MmR58sq74P/D2i88=", + "requires": { + "idna-uts46-hx": "^2.3.1", + "js-sha3": "^0.5.7" + }, + "dependencies": { + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + } + } + }, + "eth-lib": { + "version": "0.1.29", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.1.29.tgz", + "integrity": "sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ==", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "nano-json-stream-parser": "^0.1.2", + "servify": "^0.1.12", + "ws": "^3.0.0", + "xhr-request-promise": "^0.1.2" + } + }, + "ethereum-bloom-filters": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.6.tgz", + "integrity": "sha512-dE9CGNzgOOsdh7msZirvv8qjHtnHpvBlKe2647kM8v+yeF71IRso55jpojemvHV+jMjr48irPWxMRaHuOWzAFA==", + "requires": { + "js-sha3": "^0.8.0" + } + }, + "ethereumjs-common": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.5.0.tgz", + "integrity": "sha512-SZOjgK1356hIY7MRj3/ma5qtfr/4B5BL+G4rP/XSMYr2z1H5el4RX5GReYCKmQmYI/nSBmRnwrZ17IfHuG0viQ==" + }, + "ethereumjs-tx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.1.tgz", + "integrity": "sha512-QtVriNqowCFA19X9BCRPMgdVNJ0/gMBS91TQb1DfrhsbR748g4STwxZptFAwfqehMyrF8rDwB23w87PQwru0wA==", + "requires": { + "ethereumjs-common": "^1.3.1", + "ethereumjs-util": "^6.0.0" + } + }, + "ethereumjs-util": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.0.tgz", + "integrity": "sha512-vb0XN9J2QGdZGIEKG2vXM+kUdEivUfU6Wmi5y0cg+LRhDYKnXIZ/Lz7XjFbHRR9VIKq2lVGLzGBkA++y2nOdOQ==", + "requires": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "ethjs-util": "0.1.6", + "keccak": "^2.0.0", + "rlp": "^2.2.3", + "secp256k1": "^3.0.1" + } + }, + "ethers": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", + "integrity": "sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog==", + "requires": { + "@types/node": "^10.3.2", + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.3.3", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.3", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + }, + "dependencies": { + "@types/node": { + "version": "10.17.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.11.tgz", + "integrity": "sha512-dNd2pp8qTzzNLAs3O8nH3iU9DG9866KHq9L3ISPB7DOGERZN81nW/5/g/KzMJpCU8jrbCiMRBzV9/sCEdRosig==" + }, + "elliptic": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", + "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + }, + "setimmediate": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", + "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" + } + } + }, + "ethjs-unit": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", + "integrity": "sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk=", + "requires": { + "bn.js": "4.11.6", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + } + } + }, + "ethjs-util": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz", + "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==", + "requires": { + "is-hex-prefixed": "1.0.0", + "strip-hex-prefix": "1.0.0" + } + }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" + }, + "evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "requires": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "ext": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", + "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", + "requires": { + "type": "^2.0.0" + }, + "dependencies": { + "type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", + "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "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=" + }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "requires": { + "pend": "~1.2.0" + } + }, + "figures": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", + "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=" + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "requires": { + "minipass": "^2.6.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "requires": { + "pump": "^3.0.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "global": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", + "integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=", + "requires": { + "min-document": "^2.19.0", + "process": "~0.5.1" + } + }, + "globals": { + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", + "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "requires": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + } + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==" + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbol-support-x": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz", + "integrity": "sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw==" + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "has-to-string-tag-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", + "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "requires": { + "has-symbol-support-x": "^1.4.1" + } + }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "http-cache-semantics": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", + "integrity": "sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew==" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, + "http-https": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz", + "integrity": "sha1-L5CN1fHbQGjAWM1ubUzjkskTOJs=" + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "idna-uts46-hx": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz", + "integrity": "sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA==", + "requires": { + "punycode": "2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", + "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=" + } + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "inquirer": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz", + "integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", + "run-async": "^2.2.0", + "rxjs": "^6.5.3", + "string-width": "^4.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + } + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-function": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", + "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-hex-prefixed": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", + "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=" + }, + "is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=" + }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=" + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-retry-allowed": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz", + "integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "isurl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", + "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", + "requires": { + "has-to-string-tag-x": "^1.2.0", + "is-object": "^1.0.1" + } + }, + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "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==" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "keccak": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-2.1.0.tgz", + "integrity": "sha512-m1wbJRTo+gWbctZWay9i26v5fFnYkOn7D5PCxJ3fZUGUEb49dE1Pm4BREUYCt/aoO6di7jeoGmhvqN9Nzylm3Q==", + "requires": { + "bindings": "^1.5.0", + "inherits": "^2.0.4", + "nan": "^2.14.0", + "safe-buffer": "^5.2.0" + } + }, + "keyv": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", + "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", + "requires": { + "json-buffer": "3.0.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "requires": { + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + } + } + }, + "md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" + }, + "mime-types": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "requires": { + "mime-db": "1.42.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" + }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "requires": { + "dom-walk": "^0.1.0" + } + }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mkdirp-promise": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz", + "integrity": "sha1-6bj2jlUsaKnBcTuEiD96HdA5uKE=", + "requires": { + "mkdirp": "*" + } + }, + "mock-fs": { + "version": "4.10.4", + "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.10.4.tgz", + "integrity": "sha512-gDfZDLaPIvtOusbusLinfx6YSe2YpQsDT8qdP41P47dQ/NQggtkHukz7hwqgt8QvMBmAv+Z6DGmXPyb5BWX2nQ==" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + }, + "nano-json-stream-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", + "integrity": "sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18=" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "normalize-url": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", + "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" + }, + "number-to-bn": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", + "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", + "requires": { + "bn.js": "4.11.6", + "strip-hex-prefix": "1.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + } + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.1.tgz", + "integrity": "sha512-ilqR7BgdyZetJutmDPfXCDffGa0/Yzl2ivVNpbx/g4UeWrCdRnFDUBrKJGLhGieRHDATnyZXWBeCb29k9CJysQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "oboe": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.4.tgz", + "integrity": "sha1-IMiM2wwVNxuwQRklfU/dNLCqSfY=", + "requires": { + "http-https": "^1.0.0" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==" + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-timeout": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-1.2.1.tgz", + "integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=", + "requires": { + "p-finally": "^1.0.0" + } + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-asn1": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", + "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, + "parse-headers": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.3.tgz", + "integrity": "sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA==" + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "pbkdf2": { + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "requires": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" + }, + "prettier": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, + "process": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", + "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "psl": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", + "integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==" + }, + "public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "requires": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "requires": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + } + } + }, + "resolve": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", + "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "requires": { + "lowercase-keys": "^1.0.0" + } + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "rlp": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.4.tgz", + "integrity": "sha512-fdq2yYCWpAQBhwkZv+Z8o/Z4sPmYm1CUq6P7n6lVTOdb949CnqA0sndXal5C1NleSVSZm6q5F3iEbauyVln/iw==", + "requires": { + "bn.js": "^4.11.1" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", + "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "scrypt-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", + "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=" + }, + "scryptsy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-2.1.0.tgz", + "integrity": "sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w==" + }, + "secp256k1": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "requires": { + "bindings": "^1.5.0", + "bip66": "^1.1.5", + "bn.js": "^4.11.8", + "create-hash": "^1.2.0", + "drbg.js": "^1.0.1", + "elliptic": "^6.4.1", + "nan": "^2.14.0", + "safe-buffer": "^5.1.2" + } + }, + "seek-bzip": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz", + "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", + "requires": { + "commander": "~2.8.1" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "servify": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/servify/-/servify-0.1.12.tgz", + "integrity": "sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw==", + "requires": { + "body-parser": "^1.16.0", + "cors": "^2.8.1", + "express": "^4.14.0", + "request": "^2.79.0", + "xhr": "^2.3.3" + } + }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" + }, + "simple-get": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", + "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", + "requires": { + "decompress-response": "^3.3.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=" + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + }, + "strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "requires": { + "is-natural-number": "^4.0.1" + } + }, + "strip-hex-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", + "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", + "requires": { + "is-hex-prefixed": "1.0.0" + } + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "swarm-js": { + "version": "0.1.39", + "resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.39.tgz", + "integrity": "sha512-QLMqL2rzF6n5s50BptyD6Oi0R1aWlJC5Y17SRIVXRj6OR1DRIPM7nepvrxxkjA1zNzFz6mUOMjfeqeDaWB7OOg==", + "requires": { + "bluebird": "^3.5.0", + "buffer": "^5.0.5", + "decompress": "^4.0.0", + "eth-lib": "^0.1.26", + "fs-extra": "^4.0.2", + "got": "^7.1.0", + "mime-types": "^2.1.16", + "mkdirp-promise": "^5.0.1", + "mock-fs": "^4.1.0", + "setimmediate": "^1.0.5", + "tar": "^4.0.2", + "xhr-request-promise": "^0.1.2" + }, + "dependencies": { + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, + "got": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/got/-/got-7.1.0.tgz", + "integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==", + "requires": { + "decompress-response": "^3.2.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-plain-obj": "^1.1.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "isurl": "^1.0.0-alpha5", + "lowercase-keys": "^1.0.0", + "p-cancelable": "^0.3.0", + "p-timeout": "^1.1.1", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "url-parse-lax": "^1.0.0", + "url-to-options": "^1.0.1" + } + }, + "p-cancelable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", + "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==" + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "requires": { + "prepend-http": "^1.0.1" + } + } + } + }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "tar": { + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" + }, + "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", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, + "to-readable-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", + "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==" + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "ultron": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" + }, + "unbzip2-stream": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", + "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "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==", + "requires": { + "punycode": "^2.1.0" + } + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "requires": { + "prepend-http": "^2.0.0" + } + }, + "url-set-query": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", + "integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk=" + }, + "url-to-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", + "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=" + }, + "utf8": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", + "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" + }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "web3": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.4.tgz", + "integrity": "sha512-xPXGe+w0x0t88Wj+s/dmAdASr3O9wmA9mpZRtixGZxmBexAF0MjfqYM+MS4tVl5s11hMTN3AZb8cDD4VLfC57A==", + "requires": { + "@types/node": "^12.6.1", + "web3-bzz": "1.2.4", + "web3-core": "1.2.4", + "web3-eth": "1.2.4", + "web3-eth-personal": "1.2.4", + "web3-net": "1.2.4", + "web3-shh": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-bzz": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.2.4.tgz", + "integrity": "sha512-MqhAo/+0iQSMBtt3/QI1rU83uvF08sYq8r25+OUZ+4VtihnYsmkkca+rdU0QbRyrXY2/yGIpI46PFdh0khD53A==", + "requires": { + "@types/node": "^10.12.18", + "got": "9.6.0", + "swarm-js": "0.1.39", + "underscore": "1.9.1" + }, + "dependencies": { + "@types/node": { + "version": "10.17.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.11.tgz", + "integrity": "sha512-dNd2pp8qTzzNLAs3O8nH3iU9DG9866KHq9L3ISPB7DOGERZN81nW/5/g/KzMJpCU8jrbCiMRBzV9/sCEdRosig==" + } + } + }, + "web3-core": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.2.4.tgz", + "integrity": "sha512-CHc27sMuET2cs1IKrkz7xzmTdMfZpYswe7f0HcuyneTwS1yTlTnHyqjAaTy0ZygAb/x4iaVox+Gvr4oSAqSI+A==", + "requires": { + "@types/bignumber.js": "^5.0.0", + "@types/bn.js": "^4.11.4", + "@types/node": "^12.6.1", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-requestmanager": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-core-helpers": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.2.4.tgz", + "integrity": "sha512-U7wbsK8IbZvF3B7S+QMSNP0tni/6VipnJkB0tZVEpHEIV2WWeBHYmZDnULWcsS/x/jn9yKhJlXIxWGsEAMkjiw==", + "requires": { + "underscore": "1.9.1", + "web3-eth-iban": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-core-method": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.2.4.tgz", + "integrity": "sha512-8p9kpL7di2qOVPWgcM08kb+yKom0rxRCMv6m/K+H+yLSxev9TgMbCgMSbPWAHlyiF3SJHw7APFKahK5Z+8XT5A==", + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-core-promievent": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.2.4.tgz", + "integrity": "sha512-gEUlm27DewUsfUgC3T8AxkKi8Ecx+e+ZCaunB7X4Qk3i9F4C+5PSMGguolrShZ7Zb6717k79Y86f3A00O0VAZw==", + "requires": { + "any-promise": "1.3.0", + "eventemitter3": "3.1.2" + } + }, + "web3-core-requestmanager": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.2.4.tgz", + "integrity": "sha512-eZJDjyNTDtmSmzd3S488nR/SMJtNnn/GuwxnMh3AzYCqG3ZMfOylqTad2eYJPvc2PM5/Gj1wAMQcRpwOjjLuPg==", + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4", + "web3-providers-http": "1.2.4", + "web3-providers-ipc": "1.2.4", + "web3-providers-ws": "1.2.4" + } + }, + "web3-core-subscriptions": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.2.4.tgz", + "integrity": "sha512-3D607J2M8ymY9V+/WZq4MLlBulwCkwEjjC2U+cXqgVO1rCyVqbxZNCmHyNYHjDDCxSEbks9Ju5xqJxDSxnyXEw==", + "requires": { + "eventemitter3": "3.1.2", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-eth": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.2.4.tgz", + "integrity": "sha512-+j+kbfmZsbc3+KJpvHM16j1xRFHe2jBAniMo1BHKc3lho6A8Sn9Buyut6odubguX2AxoRArCdIDCkT9hjUERpA==", + "requires": { + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-eth-accounts": "1.2.4", + "web3-eth-contract": "1.2.4", + "web3-eth-ens": "1.2.4", + "web3-eth-iban": "1.2.4", + "web3-eth-personal": "1.2.4", + "web3-net": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-abi": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.4.tgz", + "integrity": "sha512-8eLIY4xZKoU3DSVu1pORluAw9Ru0/v4CGdw5so31nn+7fR8zgHMgwbFe0aOqWQ5VU42PzMMXeIJwt4AEi2buFg==", + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.4" + } + }, + "web3-eth-accounts": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.2.4.tgz", + "integrity": "sha512-04LzT/UtWmRFmi4hHRewP5Zz43fWhuHiK5XimP86sUQodk/ByOkXQ3RoXyGXFMNoRxdcAeRNxSfA2DpIBc9xUw==", + "requires": { + "@web3-js/scrypt-shim": "^0.1.0", + "any-promise": "1.3.0", + "crypto-browserify": "3.12.0", + "eth-lib": "0.2.7", + "ethereumjs-common": "^1.3.2", + "ethereumjs-tx": "^2.1.1", + "underscore": "1.9.1", + "uuid": "3.3.2", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-utils": "1.2.4" + }, + "dependencies": { + "eth-lib": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", + "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } + } + }, + "web3-eth-contract": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.2.4.tgz", + "integrity": "sha512-b/9zC0qjVetEYnzRA1oZ8gF1OSSUkwSYi5LGr4GeckLkzXP7osEnp9lkO/AQcE4GpG+l+STnKPnASXJGZPgBRQ==", + "requires": { + "@types/bn.js": "^4.11.4", + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-ens": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.2.4.tgz", + "integrity": "sha512-g8+JxnZlhdsCzCS38Zm6R/ngXhXzvc3h7bXlxgKU4coTzLLoMpgOAEz71GxyIJinWTFbLXk/WjNY0dazi9NwVw==", + "requires": { + "eth-ens-namehash": "2.0.8", + "underscore": "1.9.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-promievent": "1.2.4", + "web3-eth-abi": "1.2.4", + "web3-eth-contract": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-eth-iban": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.2.4.tgz", + "integrity": "sha512-D9HIyctru/FLRpXakRwmwdjb5bWU2O6UE/3AXvRm6DCOf2e+7Ve11qQrPtaubHfpdW3KWjDKvlxV9iaFv/oTMQ==", + "requires": { + "bn.js": "4.11.8", + "web3-utils": "1.2.4" + } + }, + "web3-eth-personal": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.2.4.tgz", + "integrity": "sha512-5Russ7ZECwHaZXcN3DLuLS7390Vzgrzepl4D87SD6Sn1DHsCZtvfdPIYwoTmKNp69LG3mORl7U23Ga5YxqkICw==", + "requires": { + "@types/node": "^12.6.1", + "web3-core": "1.2.4", + "web3-core-helpers": "1.2.4", + "web3-core-method": "1.2.4", + "web3-net": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-net": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.2.4.tgz", + "integrity": "sha512-wKOsqhyXWPSYTGbp7ofVvni17yfRptpqoUdp3SC8RAhDmGkX6irsiT9pON79m6b3HUHfLoBilFQyt/fTUZOf7A==", + "requires": { + "web3-core": "1.2.4", + "web3-core-method": "1.2.4", + "web3-utils": "1.2.4" + } + }, + "web3-providers-http": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.2.4.tgz", + "integrity": "sha512-dzVCkRrR/cqlIrcrWNiPt9gyt0AZTE0J+MfAu9rR6CyIgtnm1wFUVVGaxYRxuTGQRO4Dlo49gtoGwaGcyxqiTw==", + "requires": { + "web3-core-helpers": "1.2.4", + "xhr2-cookies": "1.1.0" + } + }, + "web3-providers-ipc": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.2.4.tgz", + "integrity": "sha512-8J3Dguffin51gckTaNrO3oMBo7g+j0UNk6hXmdmQMMNEtrYqw4ctT6t06YOf9GgtOMjSAc1YEh3LPrvgIsR7og==", + "requires": { + "oboe": "2.1.4", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-providers-ws": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.2.4.tgz", + "integrity": "sha512-F/vQpDzeK+++oeeNROl1IVTufFCwCR2hpWe5yRXN0ApLwHqXrMI7UwQNdJ9iyibcWjJf/ECbauEEQ8CHgE+MYQ==", + "requires": { + "@web3-js/websocket": "^1.0.29", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.4" + } + }, + "web3-shh": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.2.4.tgz", + "integrity": "sha512-z+9SCw0dE+69Z/Hv8809XDbLj7lTfEv9Sgu8eKEIdGntZf4v7ewj5rzN5bZZSz8aCvfK7Y6ovz1PBAu4QzS4IQ==", + "requires": { + "web3-core": "1.2.4", + "web3-core-method": "1.2.4", + "web3-core-subscriptions": "1.2.4", + "web3-net": "1.2.4" + } + }, + "web3-utils": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.4.tgz", + "integrity": "sha512-+S86Ip+jqfIPQWvw2N/xBQq5JNqCO0dyvukGdJm8fEWHZbckT4WxSpHbx+9KLEWY4H4x9pUwnoRkK87pYyHfgQ==", + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + }, + "dependencies": { + "eth-lib": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", + "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + } + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "xhr": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.5.0.tgz", + "integrity": "sha512-4nlO/14t3BNUZRXIXfXe+3N6w3s1KoxcJUUURctd64BLRe67E4gRwp4PjywtDY72fXpZ1y6Ch0VZQRY/gMPzzQ==", + "requires": { + "global": "~4.3.0", + "is-function": "^1.0.1", + "parse-headers": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "xhr-request": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xhr-request/-/xhr-request-1.1.0.tgz", + "integrity": "sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA==", + "requires": { + "buffer-to-arraybuffer": "^0.0.5", + "object-assign": "^4.1.1", + "query-string": "^5.0.1", + "simple-get": "^2.7.0", + "timed-out": "^4.0.1", + "url-set-query": "^1.0.0", + "xhr": "^2.0.4" + } + }, + "xhr-request-promise": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/xhr-request-promise/-/xhr-request-promise-0.1.2.tgz", + "integrity": "sha1-NDxE0e53JrhkgGloLQ+EDIO0Jh0=", + "requires": { + "xhr-request": "^1.0.1" + } + }, + "xhr2-cookies": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz", + "integrity": "sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg=", + "requires": { + "cookiejar": "^2.1.1" + } + }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, + "yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/upgrade/package.json b/upgrade/package.json new file mode 100644 index 000000000..3ed1e461f --- /dev/null +++ b/upgrade/package.json @@ -0,0 +1,24 @@ +{ + "name": "upgrade-xdai", + "version": "1.0.0", + "main": "index.js", + "license": "GPLv3", + "scripts": { + "upgradeBridgeOnHome": "node src/upgradeBridgeOnHome.js", + "upgradeValidatorsOnForeign": "node src/upgradeValidatorsOnForeign.js", + "upgradeBridgeOnForeign": "node src/upgradeBridgeOnForeign.js", + "migrateToMCD": "node src/migrateToMCD.js" + }, + "dependencies": { + "dotenv": "^8.2.0", + "web3": "^1.2.4" + }, + "devDependencies": { + "eslint": "^6.7.2", + "eslint-config-airbnb-base": "^14.0.0", + "eslint-config-prettier": "^6.7.0", + "eslint-plugin-node": "^10.0.0", + "eslint-plugin-prettier": "^3.1.2", + "prettier": "^1.19.1" + } +} diff --git a/upgrade/src/confirmTransaction.js b/upgrade/src/confirmTransaction.js new file mode 100644 index 000000000..7a6a3ff81 --- /dev/null +++ b/upgrade/src/confirmTransaction.js @@ -0,0 +1,49 @@ +const { toBN } = require('web3').utils + +const confirmTransaction = async ({ contract, fromBlock = 0, destination, data, address, gasPrice }) => { + const submissions = await contract.getPastEvents('Submission', { fromBlock, toBlock: 'latest' }) + + if (!submissions.length) { + throw new Error('No submissions found.') + } + const filteredSubmission = [] + await Promise.all( + submissions.map(async s => { + const { transactionId } = s.returnValues + const transaction = await contract.methods.transactions(transactionId).call() + if (transaction.destination === destination && transaction.data === data) { + if (!transaction.executed) { + console.log( + `Found a transaction to confirm. Id: ${transactionId}, Block: ${s.blockNumber}, Data: ${transaction.data}` + ) + filteredSubmission.push(s) + return + } + console.log( + `Found a transaction that was already executed. Id: ${transactionId}, Block: ${s.blockNumber}, Data: ${transaction.data}` + ) + } + }) + ) + + if (filteredSubmission.length > 1) { + throw new Error('More than one transaction found.') + } else if (filteredSubmission.length === 0) { + throw new Error('No transaction to confirm.') + } + const { transactionId } = filteredSubmission[0].returnValues + const estimatedGas = await contract.methods.confirmTransaction(transactionId).estimateGas({ from: address }) + const gas = addExtraGas(estimatedGas) + + const receipt = await contract.methods.confirmTransaction(transactionId).send({ from: address, gas, gasPrice }) + console.log(`Confirmation status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`) +} + +function addExtraGas(gas) { + gas = toBN(gas) + const extraPercentage = toBN(4) + + return gas.mul(extraPercentage) +} + +module.exports = confirmTransaction diff --git a/upgrade/src/migrateToMCD.js b/upgrade/src/migrateToMCD.js new file mode 100644 index 000000000..2dd04519c --- /dev/null +++ b/upgrade/src/migrateToMCD.js @@ -0,0 +1,56 @@ +require('dotenv').config() +const Web3 = require('web3') +const multiSigWalletAbi = require('../abi/multiSigwallet') +const proxyAbi = require('../../build/contracts/EternalStorageProxy').abi +const foreignBridgeAbi = require('../../build/contracts/ForeignBridgeErcToNative').abi +const confirmTransaction = require('./confirmTransaction') +const validatorState = require('./validatorState') + +const { + FOREIGN_PRIVKEY, + FOREIGN_RPC_URL, + FOREING_BRIDGE_ADDRESS, + ROLE, + FOREIGN_START_BLOCK, + FOREIGN_GAS_PRICE +} = process.env + +const web3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) +const { address } = web3.eth.accounts.wallet.add(FOREIGN_PRIVKEY) + +const migrateToMCD = async () => { + try { + const proxy = new web3.eth.Contract(proxyAbi, FOREING_BRIDGE_ADDRESS) + const bridge = new web3.eth.Contract(foreignBridgeAbi, FOREING_BRIDGE_ADDRESS) + + const ownerAddress = await proxy.methods.upgradeabilityOwner().call() + const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, ownerAddress) + + await validatorState(web3, address, multiSigWallet) + + const data = bridge.methods.migrateToMCD().encodeABI() + + if (ROLE === 'leader') { + const gas = await multiSigWallet.methods + .submitTransaction(FOREING_BRIDGE_ADDRESS, 0, data) + .estimateGas({ from: address }) + const receipt = await multiSigWallet.methods + .submitTransaction(FOREING_BRIDGE_ADDRESS, 0, data) + .send({ from: address, gas, gasPrice: FOREIGN_GAS_PRICE }) + console.log(`Submission status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`) + } else { + await confirmTransaction({ + fromBlock: FOREIGN_START_BLOCK, + contract: multiSigWallet, + destination: FOREING_BRIDGE_ADDRESS, + data, + address, + gasPrice: FOREIGN_GAS_PRICE + }) + } + } catch (e) { + console.log(e.message) + } +} + +migrateToMCD() diff --git a/upgrade/src/upgradeBridgeOnForeign.js b/upgrade/src/upgradeBridgeOnForeign.js new file mode 100644 index 000000000..1ba660d0a --- /dev/null +++ b/upgrade/src/upgradeBridgeOnForeign.js @@ -0,0 +1,68 @@ +require('dotenv').config() +const Web3 = require('web3') +const multiSigWalletAbi = require('../abi/multiSigwallet') +const proxyAbi = require('../../build/contracts/EternalStorageProxy').abi +const confirmTransaction = require('./confirmTransaction') +const validatorState = require('./validatorState') + +const { + FOREIGN_PRIVKEY, + FOREIGN_RPC_URL, + FOREING_BRIDGE_ADDRESS, + ROLE, + FOREIGN_START_BLOCK, + FOREIGN_GAS_PRICE, + NEW_IMPLEMENTATION_ETH_BRIDGE +} = process.env + +const migrationMethodAbi = [ + { + constant: false, + inputs: [], + name: 'upgradeToV250', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + } +] + +const web3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) +const { address } = web3.eth.accounts.wallet.add(FOREIGN_PRIVKEY) + +const upgradeBridgeOnForeign = async () => { + try { + const proxy = new web3.eth.Contract(proxyAbi, FOREING_BRIDGE_ADDRESS) + const ownerAddress = await proxy.methods.upgradeabilityOwner().call() + const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, ownerAddress) + + await validatorState(web3, address, multiSigWallet) + + const bridge = new web3.eth.Contract(migrationMethodAbi, FOREING_BRIDGE_ADDRESS) + const upgradeData = bridge.methods.upgradeToV250().encodeABI() + const data = proxy.methods.upgradeToAndCall('3', NEW_IMPLEMENTATION_ETH_BRIDGE, upgradeData).encodeABI() + + if (ROLE === 'leader') { + const gas = await multiSigWallet.methods.submitTransaction(FOREING_BRIDGE_ADDRESS, 0, data).estimateGas({ + from: address + }) + const receipt = await multiSigWallet.methods + .submitTransaction(FOREING_BRIDGE_ADDRESS, 0, data) + .send({ from: address, gas, gasPrice: FOREIGN_GAS_PRICE }) + console.log(`Submission status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`) + } else { + await confirmTransaction({ + fromBlock: FOREIGN_START_BLOCK, + contract: multiSigWallet, + destination: FOREING_BRIDGE_ADDRESS, + data, + address, + gasPrice: FOREIGN_GAS_PRICE + }) + } + } catch (e) { + console.log(e.message) + } +} + +upgradeBridgeOnForeign() diff --git a/upgrade/src/upgradeBridgeOnHome.js b/upgrade/src/upgradeBridgeOnHome.js new file mode 100644 index 000000000..acd2eb3bb --- /dev/null +++ b/upgrade/src/upgradeBridgeOnHome.js @@ -0,0 +1,55 @@ +require('dotenv').config() +const Web3 = require('web3') +const multiSigWalletAbi = require('../abi/multiSigwallet') +const proxyAbi = require('../../build/contracts/EternalStorageProxy').abi +const confirmTransaction = require('./confirmTransaction') +const validatorState = require('./validatorState') + +const { + HOME_PRIVKEY, + HOME_RPC_URL, + HOME_BRIDGE_ADDRESS, + ROLE, + HOME_START_BLOCK, + HOME_GAS_PRICE, + NEW_IMPLEMENTATION_XDAI_BRIDGE +} = process.env + +const web3 = new Web3(new Web3.providers.HttpProvider(HOME_RPC_URL)) +const { address } = web3.eth.accounts.wallet.add(HOME_PRIVKEY) + +const proxy = new web3.eth.Contract(proxyAbi, HOME_BRIDGE_ADDRESS) + +const upgradeBridgeOnHome = async () => { + try { + const ownerAddress = await proxy.methods.upgradeabilityOwner().call() + const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, ownerAddress) + + await validatorState(web3, address, multiSigWallet) + + const data = proxy.methods.upgradeTo('3', NEW_IMPLEMENTATION_XDAI_BRIDGE).encodeABI() + + if (ROLE === 'leader') { + const gas = await multiSigWallet.methods + .submitTransaction(HOME_BRIDGE_ADDRESS, 0, data) + .estimateGas({ from: address }) + const receipt = await multiSigWallet.methods + .submitTransaction(HOME_BRIDGE_ADDRESS, 0, data) + .send({ from: address, gas, gasPrice: HOME_GAS_PRICE }) + console.log(`Submission status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`) + } else { + await confirmTransaction({ + fromBlock: HOME_START_BLOCK, + contract: multiSigWallet, + destination: HOME_BRIDGE_ADDRESS, + data, + address, + gasPrice: HOME_GAS_PRICE + }) + } + } catch (e) { + console.log(e.message) + } +} + +upgradeBridgeOnHome() diff --git a/upgrade/src/upgradeValidatorsOnForeign.js b/upgrade/src/upgradeValidatorsOnForeign.js new file mode 100644 index 000000000..76eea31b0 --- /dev/null +++ b/upgrade/src/upgradeValidatorsOnForeign.js @@ -0,0 +1,75 @@ +require('dotenv').config() +const Web3 = require('web3') +const multiSigWalletAbi = require('../abi/multiSigwallet') +const proxyAbi = require('../../build/contracts/EternalStorageProxy').abi +const foreignBridgeAbi = require('../../build/contracts/ForeignBridgeErcToNative').abi +const confirmTransaction = require('./confirmTransaction') +const validatorState = require('./validatorState') + +const migrationMethodAbi = [ + { + constant: false, + inputs: [], + name: 'upgradeToV230', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function' + } +] + +const { + FOREIGN_PRIVKEY, + FOREIGN_RPC_URL, + FOREING_BRIDGE_ADDRESS, + ROLE, + FOREIGN_START_BLOCK, + FOREIGN_GAS_PRICE, + NEW_IMPLEMENTATION_ETH_VALIDATORS +} = process.env + +const web3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) +const { address } = web3.eth.accounts.wallet.add(FOREIGN_PRIVKEY) + +const bridge = new web3.eth.Contract(foreignBridgeAbi, FOREING_BRIDGE_ADDRESS) + +const upgradeValidatorsOnForeign = async () => { + try { + const validatorsAddress = await bridge.methods.validatorContract().call() + + const proxy = new web3.eth.Contract(proxyAbi, validatorsAddress) + const ownerAddress = await proxy.methods.upgradeabilityOwner().call() + + const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, ownerAddress) + + await validatorState(web3, address, multiSigWallet) + + const validatorContract = new web3.eth.Contract(migrationMethodAbi, validatorsAddress) + const upgradeData = validatorContract.methods.upgradeToV230().encodeABI() + + const data = proxy.methods.upgradeToAndCall('2', NEW_IMPLEMENTATION_ETH_VALIDATORS, upgradeData).encodeABI() + + if (ROLE === 'leader') { + const gas = await multiSigWallet.methods + .submitTransaction(validatorsAddress, 0, data) + .estimateGas({ from: address }) + const receipt = await multiSigWallet.methods + .submitTransaction(validatorsAddress, 0, data) + .send({ from: address, gas, gasPrice: FOREIGN_GAS_PRICE }) + console.log(`Submission status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`) + } else { + await confirmTransaction({ + fromBlock: FOREIGN_START_BLOCK, + contract: multiSigWallet, + destination: validatorsAddress, + data, + address, + gasPrice: FOREIGN_GAS_PRICE + }) + } + } catch (e) { + console.log(e.message) + } +} + +upgradeValidatorsOnForeign() diff --git a/upgrade/src/validatorState.js b/upgrade/src/validatorState.js new file mode 100644 index 000000000..664cc8981 --- /dev/null +++ b/upgrade/src/validatorState.js @@ -0,0 +1,17 @@ +const { toBN } = require('web3').utils + +const validatorState = async (web3, address, multiSigWallet) => { + const balance = await web3.eth.getBalance(address) + console.log(`Validator ${address} balance is ${balance}`) + if (toBN(balance).isZero()) { + throw new Error(`Balance is zero.`) + } + + const isOwner = await multiSigWallet.methods.isOwner(address).call() + + if (!isOwner) { + throw new Error(`The validator is not part of the multisig wallet.`) + } +} + +module.exports = validatorState From ec03614c6a14c12539cdb54605fca75a6782c7d5 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 19 Dec 2019 12:10:08 +0300 Subject: [PATCH 76/80] fix linter errors --- .../AbsoluteDailyLimit.sol | 1 + .../BasicTokenBridge.sol | 6 ++++- .../HomeBridgeErcToErcPOSDAO.sol | 27 ++++++++++--------- test/erc_to_native/foreign_bridge.test.js | 2 -- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol index a4e356f67..2dd22e24c 100644 --- a/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol +++ b/contracts/upgradeable_contracts/AbsoluteDailyLimit.sol @@ -138,5 +138,6 @@ contract AbsoluteDailyLimit is EternalStorage { uintStorage[MIN_PER_TX] = _minPerTx; } + // solhint-disable-next-line no-empty-blocks function updateTodayLimit(uint256) external payable {} } diff --git a/contracts/upgradeable_contracts/BasicTokenBridge.sol b/contracts/upgradeable_contracts/BasicTokenBridge.sol index 1e1daa5f1..284c7b201 100644 --- a/contracts/upgradeable_contracts/BasicTokenBridge.sol +++ b/contracts/upgradeable_contracts/BasicTokenBridge.sol @@ -139,7 +139,11 @@ contract BasicTokenBridge is EternalStorage, Ownable { } function _setLimits(uint256[] _requestLimitsArray, uint256[] _executionLimitsArray) internal { - require(limitsContract().delegatecall(abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray))); + require( + limitsContract().delegatecall( + abi.encodeWithSelector(SET_LIMITS, _requestLimitsArray, _executionLimitsArray) + ) + ); } function _increaseTotalSpentPerDay(uint256 _amount) internal { diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol index 2319cd177..ae7b4d9f9 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/HomeBridgeErcToErcPOSDAO.sol @@ -23,19 +23,20 @@ contract HomeBridgeErcToErcPOSDAO is HomeBridgeErcToErc { address _limitsContract ) public returns (bool) { _setBlockRewardContract(_feeManager, _blockReward); - return super.rewardableInitialize( - _validatorContract, - _requestLimitsArray, - _homeGasPrice, - _requiredBlockConfirmations, - _erc677token, - _executionLimitsArray, - _owner, - _feeManager, - _homeFeeForeignFeeArray, - _decimalShift, - _limitsContract - ); + return + super.rewardableInitialize( + _validatorContract, + _requestLimitsArray, + _homeGasPrice, + _requiredBlockConfirmations, + _erc677token, + _executionLimitsArray, + _owner, + _feeManager, + _homeFeeForeignFeeArray, + _decimalShift, + _limitsContract + ); } function blockRewardContract() public view returns (address) { diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index 41d5d0fec..efdecaee2 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -436,8 +436,6 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { const recipientAccount = accounts[3] await token.mint(foreignBridge.address, ether('1.25')) - console.log((await foreignBridge.executionDailyLimit()).toString()) - const transactionHash = '0x35d3818e50234655f6aebb2a1cfbf30f59568d8a4ec72066fac5a25dbe7b8121' const message = createMessage(recipientAccount, halfEther, transactionHash, foreignBridge.address) const signature = await sign(authorities[0], message) From d171071373e19a3a53906645e5a03b875bb2b5d4 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 27 Dec 2019 12:10:40 +0300 Subject: [PATCH 77/80] fix merge --- .../erc20_to_erc20/BasicForeignBridgeErcToErc.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol index 3f849aede..48098a16c 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/BasicForeignBridgeErcToErc.sol @@ -17,7 +17,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge { address _owner, uint256 _decimalShift, address _limitsContract - ) external returns (bool) { + ) external onlyRelevantSender returns (bool) { require(!isInitialized()); require(AddressUtils.isContract(_validatorContract)); require(_requiredBlockConfirmations != 0); From 4aa2b668254f0e3b837210e6250bf5ba8c262f25 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 27 Dec 2019 14:57:33 -0300 Subject: [PATCH 78/80] Update explorer verifier script to include limit contracts --- deploy/src/utils/verifier.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deploy/src/utils/verifier.js b/deploy/src/utils/verifier.js index 22d6a59a3..dbe08d261 100644 --- a/deploy/src/utils/verifier.js +++ b/deploy/src/utils/verifier.js @@ -7,15 +7,17 @@ const promiseRetry = require('promise-retry') const basePath = path.join(__dirname, '..', '..', '..', 'flats') -const isBridgeToken = (name) => name === 'ERC677BridgeToken.sol' || name === 'ERC677BridgeTokenRewardable.sol' -const isValidators = (name) => name === 'BridgeValidators.sol' || name === 'RewardableValidators.sol' +const isBridgeToken = name => name === 'ERC677BridgeToken.sol' || name === 'ERC677BridgeTokenRewardable.sol' +const isValidators = name => name === 'BridgeValidators.sol' || name === 'RewardableValidators.sol' +const isLimitContract = name => + name === 'AbsoluteDailyLimit.sol' || name === 'RelativeDailyLimit.sol' || name === 'RelativeExecutionDailyLimit.sol' const flat = async contractPath => { const pathArray = contractPath.split('/') const name = pathArray[pathArray.length - 1] let module = pathArray[pathArray.length - 2] - if (isBridgeToken(name)) { + if (isBridgeToken(name) || isLimitContract(name)) { module = '' } else if (isValidators(name)) { module = 'validators' From d929f43b7165a93cd737a896069b9dfac3c7ccec Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Fri, 27 Dec 2019 23:33:18 +0300 Subject: [PATCH 79/80] fix params in deploymentt scripts --- deploy/src/amb_erc677_to_erc677/initialize.js | 12 ++++++++---- deploy/src/erc_to_erc/home.js | 11 +++++++---- deploy/src/erc_to_native/home.js | 11 +++++++---- deploy/src/native_to_erc/foreign.js | 11 +++++++---- deploy/src/native_to_erc/home.js | 11 +++++++---- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/deploy/src/amb_erc677_to_erc677/initialize.js b/deploy/src/amb_erc677_to_erc677/initialize.js index 12276de8a..22baf8f91 100644 --- a/deploy/src/amb_erc677_to_erc677/initialize.js +++ b/deploy/src/amb_erc677_to_erc677/initialize.js @@ -72,10 +72,14 @@ async function initialize({ let nonce = await web3.eth.getTransactionCount(DEPLOYMENT_ACCOUNT_ADDRESS) const contract = new web3.eth.Contract(abi, address) - const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ - Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) - }%, - THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + + let RELATIVE_DAILY_LIMIT_PARAMS + if (RELATIVE_DAILY_LIMIT) { + RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + } console.log(` AMB contract: ${bridgeContract}, diff --git a/deploy/src/erc_to_erc/home.js b/deploy/src/erc_to_erc/home.js index b2f0f0b22..985274498 100644 --- a/deploy/src/erc_to_erc/home.js +++ b/deploy/src/erc_to_erc/home.js @@ -82,10 +82,13 @@ async function initializeBridge({ validatorsBridge, bridge, erc677token, limitsC ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] - const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ - Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) - }%, - THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + let RELATIVE_DAILY_LIMIT_PARAMS + if (RELATIVE_DAILY_LIMIT) { + RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + } if (isRewardableBridge && BLOCK_REWARD_ADDRESS !== ZERO_ADDRESS) { console.log('\ndeploying implementation for fee manager') diff --git a/deploy/src/erc_to_native/home.js b/deploy/src/erc_to_native/home.js index 85087e03e..63fac024e 100644 --- a/deploy/src/erc_to_native/home.js +++ b/deploy/src/erc_to_native/home.js @@ -73,10 +73,13 @@ async function initializeBridge({ validatorsBridge, bridge, limitsContract, init ? [TARGET_LIMIT, THRESHOLD, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] : [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX] - const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ - Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) - }%, - THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + let RELATIVE_DAILY_LIMIT_PARAMS + if (RELATIVE_DAILY_LIMIT) { + RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + } if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') diff --git a/deploy/src/native_to_erc/foreign.js b/deploy/src/native_to_erc/foreign.js index dd95942c0..9a37a8f0e 100644 --- a/deploy/src/native_to_erc/foreign.js +++ b/deploy/src/native_to_erc/foreign.js @@ -85,10 +85,13 @@ async function initializeBridge({ ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] - const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ - Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) - }%, - THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + let RELATIVE_DAILY_LIMIT_PARAMS + if (RELATIVE_DAILY_LIMIT) { + RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + } if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') diff --git a/deploy/src/native_to_erc/home.js b/deploy/src/native_to_erc/home.js index acadca194..f9fe1ec5a 100644 --- a/deploy/src/native_to_erc/home.js +++ b/deploy/src/native_to_erc/home.js @@ -71,10 +71,13 @@ async function initializeBridge({ validatorsBridge, bridge, limitsContract, init ? [TARGET_LIMIT, THRESHOLD, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] : [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX] - const RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ - Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) - }%, - THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + let RELATIVE_DAILY_LIMIT_PARAMS + if (RELATIVE_DAILY_LIMIT) { + RELATIVE_DAILY_LIMIT_PARAMS = `TARGET_LIMIT: ${TARGET_LIMIT} which is ${ + Web3Utils.fromWei(Web3Utils.toBN(TARGET_LIMIT).mul(Web3Utils.toBN(100))) + }%, + THRESHOLD: ${THRESHOLD} which is ${Web3Utils.fromWei(THRESHOLD)} in eth,` + } if (isRewardableBridge) { console.log('\ndeploying implementation for fee manager') From a5f2403f89efb0d76f3cab2724a56c0a70cbf33e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Wed, 8 Jan 2020 16:35:49 +0300 Subject: [PATCH 80/80] return mistakenly deleted method --- .../erc20_to_native/ForeignBridgeErcToNative.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 8fded1387..99e7faec0 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -86,6 +86,11 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB revert(); } + function _relayTokens(address _sender, address _receiver, uint256 _amount) internal { + require(_receiver != bridgeContractOnOtherSide()); + super._relayTokens(_sender, _receiver, _amount); + } + function migrateToMCD() external { bytes32 storageAddress = 0x3378953eb16363e06fd9ea9701d36ed7285d206d9de7df55b778462d74596a89; // keccak256(abi.encodePacked("migrationToMcdCompleted")) require(!boolStorage[storageAddress]);