Skip to content

Commit 6e32b93

Browse files
committed
fix: external withdraw permission check
1 parent 9cca418 commit 6e32b93

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/facets/TokenizedVaultIOFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ contract TokenizedVaultIOFacet is Modifiers, ReentrancyGuard {
5353
address _receiver,
5454
address _externalTokenAddress,
5555
uint256 _amount
56-
) external notLocked nonReentrant assertPrivilege(LibObject._getParentFromAddress(msg.sender), LC.GROUP_EXTERNAL_WITHDRAW_FROM_ENTITY) {
56+
) external notLocked nonReentrant assertPrivilege(_entityId, LC.GROUP_EXTERNAL_WITHDRAW_FROM_ENTITY) {
5757
if (!LibACL._hasGroupPrivilege(LibHelpers._getIdForAddress(_receiver), _entityId, LibHelpers._stringToBytes32(LC.GROUP_EXTERNAL_WITHDRAW_FROM_ENTITY)))
5858
revert ExternalWithdrawInvalidReceiver(_receiver);
5959
LibTokenizedVaultIO._externalWithdraw(_entityId, _receiver, _externalTokenAddress, _amount);

test/T02Access.t.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,19 @@ contract T02Access is D03ProtocolDefaults {
149149
changePrank(ea);
150150
writeTokenBalance(ea.addr, naymsAddress, wethAddress, 1 ether);
151151
nayms.externalDeposit(wethAddress, 1 ether); // deposit 100 weth into ea's parent (sm.entityId)
152-
// Withdrawing from the entity sm.entityId
153152
nayms.externalWithdrawFromEntity(sm.entityId, ea.addr, wethAddress, 100);
154153

155154
changePrank(cc);
156155
writeTokenBalance(cc.addr, naymsAddress, wethAddress, 1 ether);
157-
vm.expectRevert(); // Invalid group privilege
158156
nayms.externalWithdrawFromEntity(sm.entityId, cc.addr, wethAddress, 100);
159157

160158
changePrank(sm);
161-
nayms.setEntity(cc.id, sm.entityId); // User's parent must be set to the entity to deposit and withdraw from it
162-
changePrank(cc);
163-
nayms.externalWithdrawFromEntity(sm.entityId, cc.addr, wethAddress, 100);
159+
hCreateEntity(ts.entityId, ts.id, entity, "entity test hash");
160+
changePrank(sa);
161+
hAssignRole(ts.id, ts.entityId, LC.ROLE_ENTITY_ADMIN);
164162

165-
vm.expectRevert(abi.encodeWithSelector(ExternalWithdrawInvalidReceiver.selector, sm.addr));
163+
changePrank(ts);
164+
vm.expectRevert(abi.encodeWithSelector(InvalidGroupPrivilege.selector, ts.id, sm.entityId, "", LC.GROUP_EXTERNAL_WITHDRAW_FROM_ENTITY));
166165
nayms.externalWithdrawFromEntity(sm.entityId, sm.addr, wethAddress, 100); // Invalid receiver sm.addr
167166
}
168167

0 commit comments

Comments
 (0)