Skip to content

Commit f1d3270

Browse files
committed
added overloaded version of
1 parent 3699c23 commit f1d3270

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to the ethereum-contracts will be documented in this file.
33

44
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [UNRELEASED]
7+
8+
### Added
9+
10+
- `SuperTokenV1Library`: overloaded `claimAll` for the msg.sender to claim for themselves.
11+
612
## [v1.12.0]
713

814
### Added

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,16 @@ library SuperTokenV1Library {
12211221
return createPool(token, address(this));
12221222
}
12231223

1224+
/**
1225+
* @dev Claims all tokens from the pool for the msg.sender
1226+
* @param token The Super Token address.
1227+
* @param pool The Superfluid Pool to claim from.
1228+
* @return A boolean value indicating whether the claim was successful.
1229+
*/
1230+
function claimAll(ISuperToken token, ISuperfluidPool pool) internal returns (bool) {
1231+
return claimAll(token, pool, address(this), new bytes(0));
1232+
}
1233+
12241234
/**
12251235
* @dev Claims all tokens from the pool.
12261236
* @param token The Super Token address.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,26 @@ contract SuperTokenV1LibraryTest is FoundrySuperfluidTester {
119119
assertEq(superToken.balanceOf(bob) - bobBalBefore, DEFAULT_AMOUNT, "distribute unexpected result");
120120
}
121121

122+
function testClaimAllToMsgSender() external {
123+
superToken.transfer(alice, DEFAULT_AMOUNT);
124+
125+
uint256 balBefore = superToken.balanceOf(address(this));
126+
ISuperfluidPool pool = superToken.createPool();
127+
pool.updateMemberUnits(address(this), 1);
128+
129+
vm.startPrank(alice);
130+
// using callAgreement here because prank won't work as expected with the lib function
131+
sf.host.callAgreement(
132+
sf.gda,
133+
abi.encodeCall(sf.gda.distribute, (superToken, alice, pool, DEFAULT_AMOUNT, new bytes(0))),
134+
new bytes(0) // userData
135+
);
136+
vm.stopPrank();
137+
138+
superToken.claimAll(pool);
139+
assertEq(superToken.balanceOf(address(this)) - balBefore, DEFAULT_AMOUNT, "distribute unexpected result");
140+
}
141+
122142
function testCreatePool() external {
123143
ISuperfluidPool pool = superToken.createPool();
124144
assertEq(pool.admin(), address(this));

0 commit comments

Comments
 (0)