Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS] host should be immutable (#1542)
Browse files Browse the repository at this point in the history
* host should be immutable

* follow convention of capitalized immutable vars
  • Loading branch information
0xdavinchee authored Jul 21, 2023
1 parent fb7bed2 commit 85afdd0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/ethereum-contracts/contracts/apps/SuperAppBaseFlow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {

bytes32 public constant CFAV1_TYPE = keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1");

ISuperfluid public host;
ISuperfluid public immutable HOST;

/// @dev Thrown when the callback caller is not the host.
error UnauthorizedHost();
Expand All @@ -30,7 +30,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bool activateOnUpdated,
bool activateOnDeleted
) {
host = host_;
HOST = host_;

uint256 callBackDefinitions = SuperAppDefinitions.APP_LEVEL_FINAL
| SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP;
Expand Down Expand Up @@ -131,7 +131,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bytes calldata /*cbdata*/,
bytes calldata ctx
) external override returns (bytes memory newCtx) {
if (msg.sender != address(host)) revert UnauthorizedHost();
if (msg.sender != address(HOST)) revert UnauthorizedHost();
if (!isAcceptedAgreement(agreementClass)) return ctx;
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();

Expand All @@ -154,7 +154,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bytes calldata agreementData,
bytes calldata /*ctx*/
) external view override returns (bytes memory /*beforeData*/) {
if (msg.sender != address(host)) revert UnauthorizedHost();
if (msg.sender != address(HOST)) revert UnauthorizedHost();
if (!isAcceptedAgreement(agreementClass)) return "0x";
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();

Expand All @@ -175,7 +175,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bytes calldata cbdata,
bytes calldata ctx
) external override returns (bytes memory newCtx) {
if (msg.sender != address(host)) revert UnauthorizedHost();
if (msg.sender != address(HOST)) revert UnauthorizedHost();
if (!isAcceptedAgreement(agreementClass)) return ctx;
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();

Expand All @@ -202,7 +202,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bytes calldata /*ctx*/
) external view override returns (bytes memory /*beforeData*/) {
// we're not allowed to revert in this callback, thus just return empty beforeData on failing checks
if (msg.sender != address(host)
if (msg.sender != address(HOST)
|| !isAcceptedAgreement(agreementClass)
|| !isAcceptedSuperToken(superToken))
{
Expand All @@ -227,7 +227,7 @@ abstract contract SuperAppBaseFlow is ISuperApp {
bytes calldata ctx
) external override returns (bytes memory newCtx) {
// we're not allowed to revert in this callback, thus just return ctx on failing checks
if (msg.sender != address(host)
if (msg.sender != address(HOST)
|| !isAcceptedAgreement(agreementClass)
|| !isAcceptedSuperToken(superToken))
{
Expand Down Expand Up @@ -258,6 +258,6 @@ abstract contract SuperAppBaseFlow is ISuperApp {
* Current implementation expects ConstantFlowAgreement
*/
function isAcceptedAgreement(address agreementClass) internal view virtual returns (bool) {
return agreementClass == address(host.getAgreementClass(CFAV1_TYPE));
return agreementClass == address(HOST.getAgreementClass(CFAV1_TYPE));
}
}

0 comments on commit 85afdd0

Please sign in to comment.