-
Notifications
You must be signed in to change notification settings - Fork 9
fix : modify GSM signature encoding #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+293
−117
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1554c7f
fix : modify GSM signature encoding
Kogaroshi 86dc0ee
chore : lint Bindings
Kogaroshi d6b4afd
fix : fixes and changes for review
Kogaroshi be73dce
chore: lint
Kogaroshi bd81a40
fix : verify EIP712 digests in GSM tests
Kogaroshi ea0a8b8
fix : add modifier to test & better fail assert msg
Kogaroshi 1ecea74
fix : revert back to simpler tests for EIP712 digests
Kogaroshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| [submodule "lib/aave-v3-origin"] | ||
| path = lib/aave-v3-origin | ||
| url = https://github.com/aave-dao/aave-v3-origin | ||
| [submodule "lib/forge-std"] | ||
| path = lib/forge-std | ||
| url = https://github.com/foundry-rs/forge-std |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| forge-std/=lib/aave-v3-origin/lib/forge-std/src/ | ||
| forge-std/=lib/forge-std/src/ | ||
| aave-v3-origin/=lib/aave-v3-origin/src/ | ||
| aave-v3-origin-tests/=lib/aave-v3-origin/tests/ | ||
| solidity-utils/=lib/aave-v3-origin/lib/solidity-utils/src/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| library EIP712Types { | ||
| //BuyAssetWithSig(address originator,uint256 minAmount,address receiver,uint256 nonce,uint256 deadline) | ||
| struct BuyAssetWithSig { | ||
| address originator; | ||
| uint256 minAmount; | ||
| address receiver; | ||
| uint256 nonce; | ||
| uint256 deadline; | ||
| } | ||
|
|
||
| //SellAssetWithSig(address originator,uint256 maxAmount,address receiver,uint256 nonce,uint256 deadline) | ||
| struct SellAssetWithSig { | ||
| address originator; | ||
| uint256 maxAmount; | ||
| address receiver; | ||
| uint256 nonce; | ||
| uint256 deadline; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| // Automatically generated by forge bind-json. | ||
| pragma solidity >=0.6.2 <0.9.0; | ||
| pragma experimental ABIEncoderV2; | ||
|
|
||
| import {EIP712Types} from 'tests/helpers/EIP712Types.sol'; | ||
|
|
||
| interface Vm { | ||
| function parseJsonTypeArray( | ||
| string calldata json, | ||
| string calldata key, | ||
| string calldata typeDescription | ||
| ) external pure returns (bytes memory); | ||
|
|
||
| function parseJsonType( | ||
| string calldata json, | ||
| string calldata typeDescription | ||
| ) external pure returns (bytes memory); | ||
|
|
||
| function parseJsonType( | ||
| string calldata json, | ||
| string calldata key, | ||
| string calldata typeDescription | ||
| ) external pure returns (bytes memory); | ||
|
|
||
| function serializeJsonType( | ||
| string calldata typeDescription, | ||
| bytes memory value | ||
| ) external pure returns (string memory json); | ||
|
|
||
| function serializeJsonType( | ||
| string calldata objectKey, | ||
| string calldata valueKey, | ||
| string calldata typeDescription, | ||
| bytes memory value | ||
| ) external returns (string memory json); | ||
| } | ||
|
|
||
| library JsonBindings { | ||
| Vm constant vm = Vm(address(uint160(uint256(keccak256('hevm cheat code'))))); | ||
|
|
||
| // prettier-ignore | ||
| string constant schema_BuyAssetWithSig = "BuyAssetWithSig(address originator,uint256 minAmount,address receiver,uint256 nonce,uint256 deadline)"; | ||
| // prettier-ignore | ||
| string constant schema_SellAssetWithSig = "SellAssetWithSig(address originator,uint256 maxAmount,address receiver,uint256 nonce,uint256 deadline)"; | ||
|
|
||
| function serialize( | ||
| EIP712Types.BuyAssetWithSig memory value | ||
| ) internal pure returns (string memory) { | ||
| return vm.serializeJsonType(schema_BuyAssetWithSig, abi.encode(value)); | ||
| } | ||
|
|
||
| function serialize( | ||
| EIP712Types.BuyAssetWithSig memory value, | ||
| string memory objectKey, | ||
| string memory valueKey | ||
| ) internal returns (string memory) { | ||
| return vm.serializeJsonType(objectKey, valueKey, schema_BuyAssetWithSig, abi.encode(value)); | ||
| } | ||
|
|
||
| function deserializeBuyAssetWithSig( | ||
| string memory json | ||
| ) public pure returns (EIP712Types.BuyAssetWithSig memory) { | ||
| return | ||
| abi.decode(vm.parseJsonType(json, schema_BuyAssetWithSig), (EIP712Types.BuyAssetWithSig)); | ||
| } | ||
|
|
||
| function deserializeBuyAssetWithSig( | ||
| string memory json, | ||
| string memory path | ||
| ) public pure returns (EIP712Types.BuyAssetWithSig memory) { | ||
| return | ||
| abi.decode( | ||
| vm.parseJsonType(json, path, schema_BuyAssetWithSig), | ||
| (EIP712Types.BuyAssetWithSig) | ||
| ); | ||
| } | ||
|
|
||
| function deserializeBuyAssetWithSigArray( | ||
| string memory json, | ||
| string memory path | ||
| ) public pure returns (EIP712Types.BuyAssetWithSig[] memory) { | ||
| return | ||
| abi.decode( | ||
| vm.parseJsonTypeArray(json, path, schema_BuyAssetWithSig), | ||
| (EIP712Types.BuyAssetWithSig[]) | ||
| ); | ||
| } | ||
|
|
||
| function serialize( | ||
| EIP712Types.SellAssetWithSig memory value | ||
| ) internal pure returns (string memory) { | ||
| return vm.serializeJsonType(schema_SellAssetWithSig, abi.encode(value)); | ||
| } | ||
|
|
||
| function serialize( | ||
| EIP712Types.SellAssetWithSig memory value, | ||
| string memory objectKey, | ||
| string memory valueKey | ||
| ) internal returns (string memory) { | ||
| return vm.serializeJsonType(objectKey, valueKey, schema_SellAssetWithSig, abi.encode(value)); | ||
| } | ||
|
|
||
| function deserializeSellAssetWithSig( | ||
| string memory json | ||
| ) public pure returns (EIP712Types.SellAssetWithSig memory) { | ||
| return | ||
| abi.decode(vm.parseJsonType(json, schema_SellAssetWithSig), (EIP712Types.SellAssetWithSig)); | ||
| } | ||
|
|
||
| function deserializeSellAssetWithSig( | ||
| string memory json, | ||
| string memory path | ||
| ) public pure returns (EIP712Types.SellAssetWithSig memory) { | ||
| return | ||
| abi.decode( | ||
| vm.parseJsonType(json, path, schema_SellAssetWithSig), | ||
| (EIP712Types.SellAssetWithSig) | ||
| ); | ||
| } | ||
|
|
||
| function deserializeSellAssetWithSigArray( | ||
| string memory json, | ||
| string memory path | ||
| ) public pure returns (EIP712Types.SellAssetWithSig[] memory) { | ||
| return | ||
| abi.decode( | ||
| vm.parseJsonTypeArray(json, path, schema_SellAssetWithSig), | ||
| (EIP712Types.SellAssetWithSig[]) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.