Skip to content

Commit

Permalink
Fix 712 hashing and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongeric committed Feb 12, 2024
1 parent 7f462fb commit b537664
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141167
141162
Original file line number Diff line number Diff line change
@@ -1 +1 @@
237967
237972
Original file line number Diff line number Diff line change
@@ -1 +1 @@
139163
139167
Original file line number Diff line number Diff line change
@@ -1 +1 @@
187174
187172
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141162
141167
Original file line number Diff line number Diff line change
@@ -1 +1 @@
180198
180193
Original file line number Diff line number Diff line change
@@ -1 +1 @@
160343
160342
Original file line number Diff line number Diff line change
@@ -1 +1 @@
267169
267168
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158661
158666
Original file line number Diff line number Diff line change
@@ -1 +1 @@
154377
154371
4 changes: 2 additions & 2 deletions src/lib/FeeEscalatorLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ library FeeEscalatorLib {
bytes32 internal constant FEE_ESCALATOR_TYPEHASH =
keccak256("FeeEscalator(address token,uint256 startAmount,uint256 maxAmount,uint256 startTime,uint256 endTime)");

/// @notice Transforms the input data into the TokenPermissions struct needed for the permit call.
/// @notice Transforms the fee data into a TokenPermissions struct needed for the permit call.
function toPermit(FeeEscalator memory fee)
internal
pure
returns (ISignatureTransfer.TokenPermissions memory permission)
{
permission = ISignatureTransfer.TokenPermissions({token: fee.token, amount: fee.maxAmount});
}
/// @notice Handles transforming the input data into the the decayed amounts and respective recipients.

/// @notice Handles transforming the fee data into the the resolved amounts and respective recipients.
function toTransferDetails(FeeEscalator memory fee, address feeRecipient)
internal
view
Expand Down
12 changes: 6 additions & 6 deletions src/lib/RelayOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library RelayOrderLib {
"RelayOrder(",
"address reactor,",
"address swapper,",
"uint256[] startAmounts,",
"uint256[] amounts,",
"address[] recipients,",
"FeeEscalator fee,",
"bytes[] actions)"
Expand Down Expand Up @@ -108,17 +108,17 @@ library RelayOrderLib {

/// @notice hash the given order
/// @param order the order to hash
/// @dev We do not hash the entire Input struct as only some of the input information is required in the witness (recipients, and startAmounts). The token and maxAmount are already hashed in the TokenPermissions struct of the permit.
/// @dev We do not hash the entire Input struct as only some of the input information is required in the witness (recipients, and amounts). The token and maxAmount are already hashed in the TokenPermissions struct of the permit.
/// @return the eip-712 order hash
function hash(RelayOrder memory order) internal pure returns (bytes32) {
uint256 inputsLength = order.inputs.length;
// Build an array for the startAmounts and recipients.
uint256[] memory startAmounts = new uint256[](inputsLength);
// Build an array for the input amounts and recipients.
uint256[] memory amounts = new uint256[](inputsLength);
address[] memory recipients = new address[](inputsLength);

for (uint256 i = 0; i < inputsLength; i++) {
Input memory input = order.inputs[i];
startAmounts[i] = input.amount;
amounts[i] = input.amount;
recipients[i] = input.recipient;
}

Expand All @@ -134,7 +134,7 @@ library RelayOrderLib {
RELAY_ORDER_TYPEHASH,
order.info.reactor,
order.info.swapper,
keccak256(abi.encodePacked(startAmounts)),
keccak256(abi.encodePacked(amounts)),
keccak256(abi.encodePacked(recipients)),
order.fee.hash(),
keccak256(abi.encodePacked(hashedActions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,6 @@ contract RelayOrderReactorIntegrationTest is GasSnapshot, Test, Interop, PermitS
MethodParameters memory methodParameters = readFixture(json, "._UNISWAP_V3_DAI_USDC");
actions[0] = methodParameters.data;

OrderInfo memory info = OrderInfo({
reactor: IRelayOrderReactor(address(reactor)),
swapper: swapper,
nonce: 1,
deadline: block.timestamp + 100
});

OrderInfo memory orderInfo = OrderInfoBuilder.init(address(reactor)).withSwapper(swapper).withDeadline(
block.timestamp + 100
).withNonce(1);
Expand Down
2 changes: 1 addition & 1 deletion test/foundry-tests/util/RelayOrderBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ library RelayOrderBuilder {

function init(OrderInfo memory info, Input[] memory inputs, FeeEscalator memory fee)
internal
view
pure
returns (RelayOrder memory)
{
return RelayOrder({info: info, inputs: inputs, fee: fee, actions: new bytes[](0)});
Expand Down

0 comments on commit b537664

Please sign in to comment.