From ee5000da1b25c623fe14c482731fc789b077c722 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 21 Aug 2020 03:54:01 +0530 Subject: [PATCH] Added constructor in mapping gauge --- contracts/mapping/curve_gauge_mapping.sol | 37 +++++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/contracts/mapping/curve_gauge_mapping.sol b/contracts/mapping/curve_gauge_mapping.sol index 69b0210..f9c78cf 100644 --- a/contracts/mapping/curve_gauge_mapping.sol +++ b/contracts/mapping/curve_gauge_mapping.sol @@ -52,22 +52,11 @@ contract Helpers is BytesHelper { _; } - function addGaugeMappings( - string[] memory gaugeNames, - address[] memory gaugeAddresses, - bool[] memory rewardTokens - ) public isChief { - require(gaugeNames.length == gaugeAddresses.length && gaugeAddresses.length == rewardTokens.length, "length-not-match"); - for (uint32 i; i < gaugeNames.length; i++) { - addGaugeMapping(gaugeNames[i], gaugeAddresses[i], rewardTokens[i]); - } - } - - function addGaugeMapping( + function _addGaugeMapping( string memory gaugeName, address gaugeAddress, bool rewardToken - ) public isChief { + ) internal { require(gaugeAddress != address(0), "gaugeAddress-not-vaild"); require(bytes(gaugeName).length <= 32, "Length-exceeds"); bytes32 gaugeType = stringToBytes32(gaugeName); @@ -79,6 +68,17 @@ contract Helpers is BytesHelper { emit LogAddGaugeMapping(gaugeName, gaugeAddress, rewardToken); } + function addGaugeMappings( + string[] memory gaugeNames, + address[] memory gaugeAddresses, + bool[] memory rewardTokens + ) public isChief { + require(gaugeNames.length == gaugeAddresses.length && gaugeAddresses.length == rewardTokens.length, "length-not-match"); + for (uint32 i; i < gaugeNames.length; i++) { + _addGaugeMapping(gaugeNames[i], gaugeAddresses[i], rewardTokens[i]); + } + } + function removeGaugeMapping(string memory gaugeName, address gaugeAddress) public isChief { require(gaugeAddress != address(0), "gaugeAddress-not-vaild"); bytes32 gaugeType = stringToBytes32(gaugeName); @@ -95,4 +95,15 @@ contract Helpers is BytesHelper { contract CurveGaugeMapping is Helpers { string constant public name = "Curve-Gauge-Mapping-v1"; + + constructor ( + string[] memory gaugeNames, + address[] memory gaugeAddresses, + bool[] memory rewardTokens + ) public { + require(gaugeNames.length == gaugeAddresses.length && gaugeAddresses.length == rewardTokens.length, "length-not-match"); + for (uint32 i; i < gaugeNames.length; i++) { + _addGaugeMapping(gaugeNames[i], gaugeAddresses[i], rewardTokens[i]); + } + } }