Skip to content

Commit

Permalink
feat: use consistent naming for internals
Browse files Browse the repository at this point in the history
internal functions should be prefixed by _

Issue: Cantina #21
  • Loading branch information
marktoda committed Apr 5, 2024
1 parent a23f3a3 commit 116070f
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 52 deletions.
14 changes: 7 additions & 7 deletions src/reactors/BaseReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
/// @inheritdoc IReactor
function execute(SignedOrder calldata order) external payable override nonReentrant {
ResolvedOrder[] memory resolvedOrders = new ResolvedOrder[](1);
resolvedOrders[0] = resolve(order);
resolvedOrders[0] = _resolve(order);

_prepare(resolvedOrders);
_fill(resolvedOrders);
Expand All @@ -48,7 +48,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
nonReentrant
{
ResolvedOrder[] memory resolvedOrders = new ResolvedOrder[](1);
resolvedOrders[0] = resolve(order);
resolvedOrders[0] = _resolve(order);

_prepare(resolvedOrders);
IReactorCallback(msg.sender).reactorCallback(resolvedOrders, callbackData);
Expand All @@ -62,7 +62,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran

unchecked {
for (uint256 i = 0; i < ordersLength; i++) {
resolvedOrders[i] = resolve(orders[i]);
resolvedOrders[i] = _resolve(orders[i]);
}
}

Expand All @@ -82,7 +82,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran

unchecked {
for (uint256 i = 0; i < ordersLength; i++) {
resolvedOrders[i] = resolve(orders[i]);
resolvedOrders[i] = _resolve(orders[i]);
}
}

Expand All @@ -100,7 +100,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
ResolvedOrder memory order = orders[i];
_injectFees(order);
order.validate(msg.sender);
transferInputTokens(order, msg.sender);
_transferInputTokens(order, msg.sender);
}
}
}
Expand Down Expand Up @@ -140,10 +140,10 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
/// @param order The encoded order to resolve
/// @return resolvedOrder generic resolved order of inputs and outputs
/// @dev should revert on any order-type-specific validation errors
function resolve(SignedOrder calldata order) internal view virtual returns (ResolvedOrder memory resolvedOrder);
function _resolve(SignedOrder calldata order) internal view virtual returns (ResolvedOrder memory resolvedOrder);

/// @notice Transfers tokens to the fillContract
/// @param order The encoded order to transfer tokens for
/// @param to The address to transfer tokens to
function transferInputTokens(ResolvedOrder memory order, address to) internal virtual;
function _transferInputTokens(ResolvedOrder memory order, address to) internal virtual;
}
4 changes: 2 additions & 2 deletions src/reactors/DutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract DutchOrderReactor is BaseReactor {
constructor(IPermit2 _permit2, address _protocolFeeOwner) BaseReactor(_permit2, _protocolFeeOwner) {}

/// @inheritdoc BaseReactor
function resolve(SignedOrder calldata signedOrder)
function _resolve(SignedOrder calldata signedOrder)
internal
view
virtual
Expand All @@ -44,7 +44,7 @@ contract DutchOrderReactor is BaseReactor {
}

/// @inheritdoc BaseReactor
function transferInputTokens(ResolvedOrder memory order, address to) internal override {
function _transferInputTokens(ResolvedOrder memory order, address to) internal override {
permit2.permitWitnessTransferFrom(
order.toPermit(),
order.transferDetails(to),
Expand Down
4 changes: 2 additions & 2 deletions src/reactors/ExclusiveDutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract ExclusiveDutchOrderReactor is BaseReactor {
constructor(IPermit2 _permit2, address _protocolFeeOwner) BaseReactor(_permit2, _protocolFeeOwner) {}

/// @inheritdoc BaseReactor
function resolve(SignedOrder calldata signedOrder)
function _resolve(SignedOrder calldata signedOrder)
internal
view
virtual
Expand All @@ -47,7 +47,7 @@ contract ExclusiveDutchOrderReactor is BaseReactor {
}

/// @inheritdoc BaseReactor
function transferInputTokens(ResolvedOrder memory order, address to) internal override {
function _transferInputTokens(ResolvedOrder memory order, address to) internal override {
permit2.permitWitnessTransferFrom(
order.toPermit(),
order.transferDetails(to),
Expand Down
4 changes: 2 additions & 2 deletions src/reactors/LimitOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract LimitOrderReactor is BaseReactor {
constructor(IPermit2 _permit2, address _protocolFeeOwner) BaseReactor(_permit2, _protocolFeeOwner) {}

/// @inheritdoc BaseReactor
function resolve(SignedOrder calldata signedOrder)
function _resolve(SignedOrder calldata signedOrder)
internal
pure
override
Expand All @@ -32,7 +32,7 @@ contract LimitOrderReactor is BaseReactor {
}

/// @inheritdoc BaseReactor
function transferInputTokens(ResolvedOrder memory order, address to) internal override {
function _transferInputTokens(ResolvedOrder memory order, address to) internal override {
permit2.permitWitnessTransferFrom(
order.toPermit(),
order.transferDetails(to),
Expand Down
4 changes: 2 additions & 2 deletions src/reactors/V2DutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract V2DutchOrderReactor is BaseReactor {
constructor(IPermit2 _permit2, address _protocolFeeOwner) BaseReactor(_permit2, _protocolFeeOwner) {}

/// @inheritdoc BaseReactor
function resolve(SignedOrder calldata signedOrder)
function _resolve(SignedOrder calldata signedOrder)
internal
view
virtual
Expand Down Expand Up @@ -72,7 +72,7 @@ contract V2DutchOrderReactor is BaseReactor {
}

/// @inheritdoc BaseReactor
function transferInputTokens(ResolvedOrder memory order, address to) internal override {
function _transferInputTokens(ResolvedOrder memory order, address to) internal override {
permit2.permitWitnessTransferFrom(
order.toPermit(),
order.transferDetails(to),
Expand Down
28 changes: 14 additions & 14 deletions test/base/BaseReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(deadline).withValidationContract(
additionalValidationContract
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -274,7 +274,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[0] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
0
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand All @@ -284,7 +284,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[1] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
input: InputToken(tokenIn, 2 * inputAmount, 2 * inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), 2 * outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -322,7 +322,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[0] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
0
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(NATIVE, outputAmount, swapper),
sig: hex"00",
Expand All @@ -332,7 +332,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[1] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
input: InputToken(tokenIn, 2 * inputAmount, 2 * inputAmount),
outputs: OutputsBuilder.single(NATIVE, 2 * outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -374,7 +374,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[0] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
0
),
),
input: InputToken(tokenIn, ONE, ONE),
outputs: OutputsBuilder.multiple(address(tokenOut), output1, swapper),
sig: hex"00",
Expand All @@ -384,7 +384,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[1] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
input: InputToken(tokenIn, ONE * 2, ONE * 2),
outputs: OutputsBuilder.multiple(address(tokenOut), output2, swapper),
sig: hex"00",
Expand Down Expand Up @@ -431,7 +431,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[0] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
0
),
),
input: InputToken(tokenIn, ONE, ONE),
outputs: outputs1,
sig: hex"00",
Expand All @@ -441,7 +441,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
orders[1] = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
input: InputToken(tokenIn, ONE * 2, ONE * 2),
outputs: outputs2,
sig: hex"00",
Expand Down Expand Up @@ -523,7 +523,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
123
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -691,7 +691,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(deadline).withValidationContract(
additionalValidationContract
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -733,7 +733,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(deadline).withValidationContract(
additionalValidationContract
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand Down Expand Up @@ -763,7 +763,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(orderReactor).withSwapper(swapper).withDeadline(deadline).withValidationContract(
additionalValidationContract
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand All @@ -787,7 +787,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
ResolvedOrder memory order = ResolvedOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(deadline).withValidationContract(
additionalValidationContract
),
),
input: InputToken(tokenIn, inputAmount, inputAmount),
outputs: OutputsBuilder.single(address(tokenOut), outputAmount, swapper),
sig: hex"00",
Expand Down
4 changes: 2 additions & 2 deletions test/executors/SwapRouter02Executor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contract SwapRouter02ExecutorTest is Test, PermitSignature, GasSnapshot, DeployP
DutchOrder memory order2 = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1234
),
),
decayStartTime: block.timestamp - 100,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, ONE, ONE),
Expand Down Expand Up @@ -270,7 +270,7 @@ contract SwapRouter02ExecutorTest is Test, PermitSignature, GasSnapshot, DeployP
DutchOrder memory order2 = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, inputAmount * 3, inputAmount * 3),
Expand Down
4 changes: 2 additions & 2 deletions test/reactors/BaseDutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ abstract contract BaseDutchOrderReactorTest is PermitSignature, DeployPermit2, B
input: DutchInput(tokenIn, 0, 0),
outputs: OutputsBuilder.multipleDutch(
tokenOut, Solarray.uint256s(1000, 10000, 2000), Solarray.uint256s(900, 9000, 1000), address(0)
)
)
})
);
ResolvedOrder memory resolvedOrder = quoter.quote(order.order, order.sig);
Expand Down Expand Up @@ -363,7 +363,7 @@ abstract contract BaseDutchOrderReactorTest is PermitSignature, DeployPermit2, B
input: DutchInput(tokenIn, 100, 110),
outputs: OutputsBuilder.multipleDutch(
tokenOut, Solarray.uint256s(1000, 1000), Solarray.uint256s(1000, 900), address(0)
)
)
})
);
vm.expectRevert(DutchOrderReactor.InputAndOutputDecay.selector);
Expand Down
8 changes: 4 additions & 4 deletions test/reactors/DutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ contract DutchOrderReactorTest is PermitSignature, DeployPermit2, BaseDutchOrder
orders[1] = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, 2 ether, 2 ether),
Expand Down Expand Up @@ -166,7 +166,7 @@ contract DutchOrderReactorTest is PermitSignature, DeployPermit2, BaseDutchOrder
orders[1] = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, inputAmount * 2, inputAmount * 2),
Expand Down Expand Up @@ -199,7 +199,7 @@ contract DutchOrderReactorTest is PermitSignature, DeployPermit2, BaseDutchOrder
orders[1] = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, inputAmount * 2, inputAmount * 2),
Expand Down Expand Up @@ -233,7 +233,7 @@ contract DutchOrderReactorTest is PermitSignature, DeployPermit2, BaseDutchOrder
orders[1] = DutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
input: DutchInput(tokenIn, inputAmount, inputAmount),
Expand Down
8 changes: 4 additions & 4 deletions test/reactors/ExclusiveDutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ contract ExclusiveDutchOrderReactorTest is PermitSignature, DeployPermit2, BaseD
orders[1] = ExclusiveDutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
exclusiveFiller: address(0),
Expand Down Expand Up @@ -279,7 +279,7 @@ contract ExclusiveDutchOrderReactorTest is PermitSignature, DeployPermit2, BaseD
orders[1] = ExclusiveDutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
exclusiveFiller: address(0),
Expand Down Expand Up @@ -316,7 +316,7 @@ contract ExclusiveDutchOrderReactorTest is PermitSignature, DeployPermit2, BaseD
orders[1] = ExclusiveDutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
exclusiveFiller: address(0),
Expand Down Expand Up @@ -354,7 +354,7 @@ contract ExclusiveDutchOrderReactorTest is PermitSignature, DeployPermit2, BaseD
orders[1] = ExclusiveDutchOrder({
info: OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(block.timestamp + 100).withNonce(
1
),
),
decayStartTime: block.timestamp,
decayEndTime: block.timestamp + 100,
exclusiveFiller: address(0),
Expand Down
Loading

0 comments on commit 116070f

Please sign in to comment.