diff --git a/contracts/mapping/curve_gauge_mapping.sol b/contracts/mapping/curve_gauge_mapping.sol index cd6b14f..6a10759 100644 --- a/contracts/mapping/curve_gauge_mapping.sol +++ b/contracts/mapping/curve_gauge_mapping.sol @@ -68,6 +68,17 @@ 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( string memory gaugeName, address gaugeAddress, diff --git a/contracts/tests/MockCurveGaugeMapping.sol b/contracts/tests/MockCurveGaugeMapping.sol index 0996e6b..c80852c 100644 --- a/contracts/tests/MockCurveGaugeMapping.sol +++ b/contracts/tests/MockCurveGaugeMapping.sol @@ -1,4 +1,5 @@ pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; import { CurveGaugeMapping } from "../mapping/curve_gauge_mapping.sol"; diff --git a/test/CurveGauge.js b/test/CurveGauge.js index 1677caf..96c2d26 100644 --- a/test/CurveGauge.js +++ b/test/CurveGauge.js @@ -32,8 +32,8 @@ contract("ConnectCurveGauge", async accounts => { let rewarded_token = await curveGauge.methods.rewarded_token().encodeABI(); await mock.givenMethodReturnAddress(rewarded_token, mock.address); - mockCurveGaugeMapping.addGaugeMapping('compound', mock.address, false); - mockCurveGaugeMapping.addGaugeMapping('susd', mock.address, true); + await mockCurveGaugeMapping.addGaugeMapping('compound', mock.address, false); + await mockCurveGaugeMapping.addGaugeMapping('susd', mock.address, true); }) it('can deposit into compound gauge', async function() { @@ -146,4 +146,9 @@ contract("ConnectCurveGauge", async accounts => { ) await expectRevert(tx, "wrong-gauge-pool-name") }); + + it('can add multiple gauge mappings', async function() { + const tx = await mockCurveGaugeMapping.addGaugeMappings(['sbtc'], [mock.address], [true]); + expectEvent(tx, "LogAddGaugeMapping"); + }); })