-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed edge case where distributeRewards could revert but the submit w…
…as considered successful
- Loading branch information
Showing
3 changed files
with
29 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
pragma solidity 0.8.25; | ||
|
||
import {console2} from "forge-std/console2.sol"; | ||
import {MerkleProof} from "openzeppelin/utils/cryptography/MerkleProof.sol"; | ||
import {Ownable} from "openzeppelin/access/Ownable.sol"; | ||
import {Verification} from "./Verification.sol"; | ||
|
@@ -107,6 +108,24 @@ contract Gateway is IOGateway, IInitializable, IUpgradable { | |
error CantSetMiddlewareToZeroAddress(); | ||
error CantSetMiddlewareToSameAddress(); | ||
error MiddlewareNotSet(); | ||
error EUnableToProcessRewardsB( | ||
uint256 epoch, | ||
uint256 eraIndex, | ||
address tokenAddress, | ||
uint256 totalPointsToken, | ||
uint256 totalTokensInflated, | ||
bytes32 rewardsRoot, | ||
bytes errorBytes | ||
); | ||
error EUnableToProcessRewardsS( | ||
uint256 epoch, | ||
uint256 eraIndex, | ||
address tokenAddress, | ||
uint256 totalPointsToken, | ||
uint256 totalTokensInflated, | ||
bytes32 rewardsRoot, | ||
string errorString | ||
); | ||
|
||
// Message handlers can only be dispatched by the gateway itself | ||
modifier onlySelf() { | ||
|
@@ -509,7 +528,6 @@ contract Gateway is IOGateway, IInitializable, IUpgradable { | |
revert MiddlewareNotSet(); | ||
} | ||
|
||
// Probably need to send me the token to be minted? | ||
( | ||
uint256 epoch, | ||
uint256 eraIndex, | ||
|
@@ -525,11 +543,11 @@ contract Gateway is IOGateway, IInitializable, IUpgradable { | |
try IMiddlewareBasic(middlewareAddress).distributeRewards( | ||
epoch, eraIndex, totalPointsToken, totalTokensInflated, rewardsRoot, tokenAddress | ||
) {} catch Error(string memory err) { | ||
emit UnableToProcessRewardsS( | ||
revert EUnableToProcessRewardsS( | ||
epoch, eraIndex, tokenAddress, totalPointsToken, totalTokensInflated, rewardsRoot, err | ||
); | ||
} catch (bytes memory err) { | ||
emit UnableToProcessRewardsB( | ||
revert EUnableToProcessRewardsB( | ||
epoch, eraIndex, tokenAddress, totalPointsToken, totalTokensInflated, rewardsRoot, err | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters