Skip to content

Commit 00fbe2c

Browse files
committed
renamed to onInFlowDeleted and onOutFlowDeleted
1 parent ee71ae0 commit 00fbe2c

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ subtask(TASK_COMPILE_GET_REMAPPINGS).setAction(
7272
- `SuperTokenV1Library.distribute`: return `actualAmount` instead of a bool
7373

7474
# Breaking
75-
- CFASuperAppBase: `onFlowDeleted` from now on only handles events related to incoming flows, while for events triggered by outgoing flows `onOutFlowDeleted` is invoked.
76-
This is safer because the latter case is in many cases unexpected and may thus not be handled correctly, potentially leading to state corruption or SuperApp jailing.
77-
The change is breaking because of a signature change in `onFlowDeleted`. The removal of the now unnecessary `receiver` argument also makes sure
78-
that this change can't without notice break implementations which correctly handled the corner case of an outgoing flow with the previous implementation of CFASuperAppBase.
79-
Many applications may not want/need to handle the case of outgoing flows being deleted, thus don't need to override the newly added `onOutFlowDeleted`.
75+
- CFASuperAppBase: `onFlowDeleted` is replaced by `onInFlowDeleted` and `onOutFlowDeleted`.
76+
This is safer because the latter hook handles a case (outgoing flow being deleted by its receiver) which is often not expected.
77+
In the past, apps creating outflows had to explicitly distinguish between the 2 possible triggers in order to avoid potentially invalid state changes or even jailing.
78+
Most apps will want to implement just `onInFlowDeleted`.
8079

8180
## [v1.12.0]
8281

packages/ethereum-contracts/contracts/apps/CFASuperAppBase.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ abstract contract CFASuperAppBase is ISuperApp {
153153

154154
/// @dev override if the SuperApp shall have custom logic invoked when an existing flow
155155
/// to it is deleted (flowrate set to 0).
156-
/// Unlike the other callbacks, this method is NOT allowed to revert.
156+
/// Unlike the other callbacks, the delete callbacks are NOT allowed to revert.
157157
/// Failing to satisfy that requirement leads to jailing (defunct SuperApp).
158-
function onFlowDeleted(
158+
function onInFlowDeleted(
159159
ISuperToken /*superToken*/,
160160
address /*sender*/,
161161
int96 /*previousFlowRate*/,
@@ -168,13 +168,13 @@ abstract contract CFASuperAppBase is ISuperApp {
168168
/// @dev override if the SuperApp shall have custom logic invoked when an outgoing flow
169169
/// is deleted by the receiver (it's not triggered when deleted by the SuperApp itself).
170170
/// A possible implementation is to make outflows "sticky" by simply reopening it.
171-
/// Like onFlowDeleted, this method is NOT allowed to revert.
171+
/// Like onInFlowDeleted, this method is NOT allowed to revert.
172172
/// It's safe to not override this method if the SuperApp doesn't have outgoing flows,
173173
/// or if it doesn't want/need to know if an outgoing flow is deleted by its receiver.
174174
/// Note: In theory this hook could also be triggered by a liquidation, but this would imply
175175
/// that the SuperApp is insolvent, and would thus be jailed already.
176176
/// Thus in practice this is triggered only when a receiver of an outgoing flow deletes that flow.
177-
function onOutflowDeleted(
177+
function onOutFlowDeleted(
178178
ISuperToken /*superToken*/,
179179
address /*receiver*/,
180180
int96 /*previousFlowRate*/,
@@ -324,7 +324,7 @@ abstract contract CFASuperAppBase is ISuperApp {
324324

325325
if (receiver == address(this)) {
326326
return
327-
onFlowDeleted(
327+
onInFlowDeleted(
328328
superToken,
329329
sender,
330330
previousFlowRate,
@@ -333,7 +333,7 @@ abstract contract CFASuperAppBase is ISuperApp {
333333
);
334334
} else {
335335
return
336-
onOutflowDeleted(
336+
onOutFlowDeleted(
337337
superToken,
338338
receiver,
339339
previousFlowRate,

packages/ethereum-contracts/test/foundry/apps/CFASuperAppBaseTester.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ contract CFASuperAppBaseTester is CFASuperAppBase {
7272

7373
// DELETE
7474

75-
function onFlowDeleted(
75+
function onInFlowDeleted(
7676
ISuperToken, /*superToken*/
7777
address sender,
7878
int96 previousFlowRate,
@@ -85,7 +85,7 @@ contract CFASuperAppBaseTester is CFASuperAppBase {
8585
return ctx;
8686
}
8787

88-
function onOutflowDeleted(
88+
function onOutFlowDeleted(
8989
ISuperToken, /*superToken*/
9090
address receiver,
9191
int96 previousFlowRate,

packages/ethereum-contracts/test/foundry/apps/SuperAppTester/FlowSplitter.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ contract FlowSplitter is CFASuperAppBase {
129129
);
130130
}
131131

132-
function onFlowDeleted(
132+
function onInFlowDeleted(
133133
ISuperToken superToken,
134134
address, /*sender*/
135135
int96 previousFlowRate,
@@ -160,7 +160,7 @@ contract FlowSplitter is CFASuperAppBase {
160160
}
161161
}
162162

163-
function onOutflowDeleted(
163+
function onOutFlowDeleted(
164164
ISuperToken superToken,
165165
address receiver,
166166
int96 previousFlowRate,

packages/ethereum-contracts/test/foundry/apps/SuperTokenV1Library.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,18 @@ contract SuperAppMock is CFASuperAppBase {
553553
return _mirrorOrMatchIncomingFlow(superToken, sender, ctx);
554554
}
555555

556-
function onFlowDeleted(
556+
function onInFlowDeleted(
557557
ISuperToken superToken,
558558
address sender,
559-
int96 previousFlowRate,
559+
int96 /*previousFlowRate*/,
560560
uint256 /*lastUpdated*/,
561561
bytes calldata ctx
562562
) internal virtual override returns (bytes memory /*newCtx*/) {
563563
return _mirrorOrMatchIncomingFlow(superToken, sender, ctx);
564564
}
565565

566566
// outflow was deleted by the sender we mirror to, we make it "sticky" by simply restoring it.
567-
function onOutflowDeleted(
567+
function onOutFlowDeleted(
568568
ISuperToken superToken,
569569
address receiver,
570570
int96 previousFlowRate,

0 commit comments

Comments
 (0)