Skip to content

Commit

Permalink
feat: add set pl & usd refund
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Dec 1, 2023
1 parent 6586a88 commit 8fadfa6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/dev/src/bridge/GalxeBadgeReceiverV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ contract GalxeBadgeReceiverV2 is IBadgeReceiverV2, Ownable, IERC721Receiver {
emit DstValidSet(dstChainId, valid);
}

function updateUsdRefund(uint256[] calldata cids, uint256[] calldata usdAmounts) external onlyOwner {
for (uint256 i = 0; i < cids.length; i++) {
uint256 cid = cids[i];
uint256 usdAmount = usdAmounts[i];
usdRefund[cid] = usdAmount;
}

emit UsdRefundSet(cids, usdAmounts);
}

function updatePlUsdRefund(uint256[] calldata cids, uint256[] calldata pls) external onlyOwner {
for (uint256 i = 0; i < cids.length; i++) {
uint256 cid = cids[i];
uint256 pl = pls[i];
plRefund[cid] = pl;
}

emit PlRefundSet(cids, pls);
}

function onERC721Received(address, address, uint256, bytes calldata) public pure override returns (bytes4) {
return this.onERC721Received.selector;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/dev/src/bridge/interfaces/IBadgeReceiverV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ interface IBadgeReceiverV2Def {
event ValidNftAddrSet(address nftAddr, bool valid);

event DstValidSet(uint256 chainId, bool valid);

event PlRefundSet(uint256[] cids, uint256[] amounts);

event UsdRefundSet(uint256[] cids, uint256[] amounts);
}

interface IBadgeReceiverV2 is IBadgeReceiverV2Def {}
8 changes: 8 additions & 0 deletions packages/dev/test/uint/fuzz/GBROnlyOwnerTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ contract GBR_OnlyOwner_Test is GalxeBadgeReceiverV2Test {
function testFuzz_onlyOwner_UpdateDstValidity(address eve) public onlyOwnerCanCall(eve) {
galxeBadgeReceiverV2.updateDstValidity(1, true);
}

function testFuzz_onlyOwner_UpdateUsdRefund(address eve) public onlyOwnerCanCall(eve) {
galxeBadgeReceiverV2.updateUsdRefund(new uint256[](1), new uint256[](1));
}

function testFuzz_onlyOwner_UpdatePlRefund(address eve) public onlyOwnerCanCall(eve) {
galxeBadgeReceiverV2.updatePlUsdRefund(new uint256[](1), new uint256[](1));
}
}

0 comments on commit 8fadfa6

Please sign in to comment.