Skip to content

Commit

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

Issue: Cantina #21
  • Loading branch information
marktoda authored Apr 9, 2024
1 parent 4e87927 commit 2bc445d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions src/reactors/BaseReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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 @@ -44,7 +44,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 @@ -58,7 +58,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 @@ -78,7 +78,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 @@ -96,7 +96,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 @@ -136,10 +136,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
6 changes: 3 additions & 3 deletions test/util/mock/MockDutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ contract MockDutchOrderReactor is DutchOrderReactor {
constructor(IPermit2 _permit2, address _protocolFeeOwner) DutchOrderReactor(_permit2, _protocolFeeOwner) {}

function resolveOrder(SignedOrder calldata order) external view returns (ResolvedOrder memory resolvedOrder) {
return resolve(order);
return _resolve(order);
}

function resolve(SignedOrder calldata order) internal view override returns (ResolvedOrder memory resolvedOrder) {
return DutchOrderReactor.resolve(order);
function _resolve(SignedOrder calldata order) internal view override returns (ResolvedOrder memory resolvedOrder) {
return DutchOrderReactor._resolve(order);
}
}

0 comments on commit 2bc445d

Please sign in to comment.