Skip to content

Commit

Permalink
change typehashes to be EIP712 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdomrom committed Nov 16, 2023
1 parent 444b035 commit b243008
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/lyra-utils
18 changes: 9 additions & 9 deletions src/libraries/PermitAllowanceLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {IAllowances} from "../interfaces/IAllowances.sol";
* @notice hash function for PermitAllowance object
*/
library PermitAllowanceLib {
bytes32 public constant _PERMIT_ALLOWANCE_TYPEHASH = keccak256(
"PermitAllowance(address delegate,uint256 nonce,uint256 accountId,uint256 deadline,AssetAllowance[] assetAllowances,SubIdAllowance[] subIdAllowances)"
bytes32 public constant PERMIT_ALLOWANCE_TYPEHASH = keccak256(
"PermitAllowance(address delegate,uint256 nonce,uint256 accountId,uint256 deadline,(address asset,uint256 positive,uint256 negative)[] assetAllowances,(address asset,uint256 subId,uint256 positive,uint256 negative)[] subIdAllowances)"
);

bytes32 public constant _ASSET_ALLOWANCE_TYPEHASH =
keccak256("AssetAllowance(address delegate,uint256 positive,uint256 negative)");
bytes32 public constant ASSET_ALLOWANCE_TYPEHASH =
keccak256("AssetAllowance(address asset,uint256 positive,uint256 negative)");

bytes32 public constant _SUBID_ALLOWANCE_TYPEHASH =
keccak256("SubIdAllowance(address delegate,uint256 subId,uint256 positive,uint256 negative)");
bytes32 public constant SUBID_ALLOWANCE_TYPEHASH =
keccak256("SubIdAllowance(address asset,uint256 subId,uint256 positive,uint256 negative)");

/**
* @dev hash the permit struct
Expand All @@ -41,7 +41,7 @@ library PermitAllowanceLib {

return keccak256(
abi.encode(
_PERMIT_ALLOWANCE_TYPEHASH,
PERMIT_ALLOWANCE_TYPEHASH,
permit.delegate,
permit.nonce,
permit.accountId,
Expand All @@ -53,10 +53,10 @@ library PermitAllowanceLib {
}

function _hashAssetAllowance(IAllowances.AssetAllowance memory allowance) private pure returns (bytes32) {
return keccak256(abi.encode(_ASSET_ALLOWANCE_TYPEHASH, allowance));
return keccak256(abi.encode(ASSET_ALLOWANCE_TYPEHASH, allowance));
}

function _hashSubIdAllowance(IAllowances.SubIdAllowance memory allowance) private pure returns (bytes32) {
return keccak256(abi.encode(_SUBID_ALLOWANCE_TYPEHASH, allowance));
return keccak256(abi.encode(SUBID_ALLOWANCE_TYPEHASH, allowance));
}
}
2 changes: 1 addition & 1 deletion test/feed/unit-tests/LyraForwardFeed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ contract UNIT_LyraForwardFeed is LyraFeedTestUtils {
feed.acceptData(data);
}

function testEncodeFwdFeedData() public {
function testEncodeFwdFeedData() public view {
uint64 expiry_ = 1698998400;
uint settlementStartAggregate_ = 1;
uint currentSpotAggregate_ = 3211595747743195673395200;
Expand Down

0 comments on commit b243008

Please sign in to comment.