Skip to content

Commit

Permalink
make msgSender public (#253)
Browse files Browse the repository at this point in the history
Co-authored-by: Sara Reynolds <snreynolds2506@gmail.com>
  • Loading branch information
hensha256 and snreynolds authored Aug 2, 2024
1 parent e764aec commit 912536c
Show file tree
Hide file tree
Showing 64 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/BaseActionsRouter_mock10commands.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
61778
61756
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134509
134555
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134647
134693
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127656
127702
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127794
127840
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_empty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47186
47168
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_empty_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47004
46986
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_nonEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
130136
130119
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_nonEmpty_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123058
123040
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150257
150235
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141409
141387
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150257
150235
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decreaseLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
115800
115778
Original file line number Diff line number Diff line change
@@ -1 +1 @@
108602
108584
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134196
134178
Original file line number Diff line number Diff line change
@@ -1 +1 @@
126935
126917
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128516
128494
Original file line number Diff line number Diff line change
@@ -1 +1 @@
152363
152341
Original file line number Diff line number Diff line change
@@ -1 +1 @@
151604
151582
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134163
134141
Original file line number Diff line number Diff line change
@@ -1 +1 @@
130328
130306
Original file line number Diff line number Diff line change
@@ -1 +1 @@
171022
171000
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140866
140844
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
336841
336819
Original file line number Diff line number Diff line change
@@ -1 +1 @@
345347
345325
Original file line number Diff line number Diff line change
@@ -1 +1 @@
344888
344866
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_onSameTickLower.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
314823
314801
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_onSameTickUpper.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
315465
315443
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
241047
241025
Original file line number Diff line number Diff line change
@@ -1 +1 @@
371147
371125
Original file line number Diff line number Diff line change
@@ -1 +1 @@
320841
320819
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
372141
372119
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_withSettlePair.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
371520
371498
Original file line number Diff line number Diff line change
@@ -1 +1 @@
416538
416560
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_Bytecode.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7995
8068
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn1Hop_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
120558
120604
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn1Hop_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119753
119799
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn1Hop_oneForZero.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128625
128671
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn1Hop_zeroForOne.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135455
135501
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186962
187008
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn2Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
178897
178943
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
238494
238540
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
230453
230499
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactInputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134509
134555
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactInputSingle_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119612
119658
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactInputSingle_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
118790
118836
Original file line number Diff line number Diff line change
@@ -1 +1 @@
126261
126262
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut1Hop_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
120494
120540
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut1Hop_oneForZero.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129366
129412
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut1Hop_zeroForOne.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134167
134213
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186277
186323
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut2Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
183172
183173
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
238427
238473
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
235346
235347
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
229579
229625
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOutputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
132930
132976
Original file line number Diff line number Diff line change
@@ -1 +1 @@
125024
125025
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOutputSingle_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119315
119316
10 changes: 5 additions & 5 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ contract PositionManager is
}
}

function _msgSender() internal view override returns (address) {
function msgSender() public view override returns (address) {
return _getLocker();
}

Expand All @@ -208,7 +208,7 @@ contract PositionManager is
uint128 amount0Min,
uint128 amount1Min,
bytes calldata hookData
) internal onlyIfApproved(_msgSender(), tokenId) onlyValidConfig(tokenId, config) {
) internal onlyIfApproved(msgSender(), tokenId) onlyValidConfig(tokenId, config) {
// Note: the tokenId is used as the salt.
BalanceDelta liquidityDelta = _modifyLiquidity(config, -(liquidity.toInt256()), bytes32(tokenId), hookData);
liquidityDelta.validateMinOut(amount0Min, amount1Min);
Expand Down Expand Up @@ -242,7 +242,7 @@ contract PositionManager is
int256 currencyDelta = poolManager.currencyDelta(address(this), currency);

// the locker is the payer or receiver
address caller = _msgSender();
address caller = msgSender();
if (currencyDelta < 0) {
_settle(currency, caller, uint256(-currencyDelta));
} else if (currencyDelta > 0) {
Expand All @@ -260,7 +260,7 @@ contract PositionManager is

function _settlePair(Currency currency0, Currency currency1) internal {
// the locker is the payer when settling
address caller = _msgSender();
address caller = msgSender();
_settle(currency0, caller, _getFullSettleAmount(currency0));
_settle(currency1, caller, _getFullSettleAmount(currency1));
}
Expand All @@ -272,7 +272,7 @@ contract PositionManager is
uint128 amount0Min,
uint128 amount1Min,
bytes calldata hookData
) internal onlyIfApproved(_msgSender(), tokenId) onlyValidConfig(tokenId, config) {
) internal onlyIfApproved(msgSender(), tokenId) onlyValidConfig(tokenId, config) {
uint256 liquidity = uint256(_getPositionLiquidity(config, tokenId));

BalanceDelta liquidityDelta;
Expand Down
2 changes: 1 addition & 1 deletion src/V4Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract contract V4Router is IV4Router, BaseActionsRouter, DeltaResolver {
if (action == Actions.SETTLE_ALL) {
Currency currency = params.decodeCurrency();
// TODO should it have a maxAmountOut added slippage protection?
_settle(currency, _msgSender(), _getFullSettleAmount(currency));
_settle(currency, msgSender(), _getFullSettleAmount(currency));
} else if (action == Actions.SETTLE) {
(Currency currency, uint256 amount, bool payerIsUser) = params.decodeCurrencyUint256AndBool();
_settle(currency, _mapPayer(payerIsUser), _mapSettleAmount(amount, currency));
Expand Down
6 changes: 3 additions & 3 deletions src/base/BaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ abstract contract BaseActionsRouter is SafeCallback {
/// In many contracts this will be the address that calls the initial entry point that calls `_executeActions`
/// `msg.sender` shouldnt be used, as this will be the v4 pool manager contract that calls `unlockCallback`
/// If using ReentrancyLock.sol, this function can return _getLocker()
function _msgSender() internal view virtual returns (address);
function msgSender() public view virtual returns (address);

/// @notice Calculates the address for a action
function _mapRecipient(address recipient) internal view returns (address) {
if (recipient == Constants.MSG_SENDER) {
return _msgSender();
return msgSender();
} else if (recipient == Constants.ADDRESS_THIS) {
return address(this);
} else {
Expand All @@ -68,6 +68,6 @@ abstract contract BaseActionsRouter is SafeCallback {

/// @notice Calculates the payer for an action
function _mapPayer(bool payerIsUser) internal view returns (address) {
return payerIsUser ? _msgSender() : address(this);
return payerIsUser ? msgSender() : address(this);
}
}
2 changes: 1 addition & 1 deletion src/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ library Constants {
uint128 internal constant CONTRACT_BALANCE = 0;
uint128 internal constant OPEN_DELTA = 1;

/// @notice used to signal that the recipient of an action should be the _msgSender of address(this)
/// @notice used to signal that the recipient of an action should be the msgSender of address(this)
address internal constant MSG_SENDER = address(1);
address internal constant ADDRESS_THIS = address(2);
}
2 changes: 1 addition & 1 deletion test/mocks/MockBaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract MockBaseActionsRouter is BaseActionsRouter, ReentrancyLock {
}
}

function _msgSender() internal pure override returns (address) {
function msgSender() public pure override returns (address) {
return address(0xdeadbeef);
}

Expand Down
2 changes: 1 addition & 1 deletion test/mocks/MockV4Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract MockV4Router is V4Router, ReentrancyLock {
}
}

function _msgSender() internal view override returns (address) {
function msgSender() public view override returns (address) {
return _getLocker();
}

Expand Down

0 comments on commit 912536c

Please sign in to comment.