-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix encoding & hardhat test #18
Conversation
🚀 Add hardhat test to ci
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## fix-encoding #18 +/- ##
=============================================
Coverage 74.10% 74.10%
=============================================
Files 5 5
Lines 139 139
Branches 28 28
=============================================
Hits 103 103
Misses 30 30
Partials 6 6 ☔ View full report in Codecov by Sentry. |
expect(await engine.getAddress()).to.exist; | ||
}); | ||
|
||
it("Signature is verified", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nicely done ☑️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a single question, but otherwise, everything LGTM ✨
Description
Add a hardhat test for conditional order signatures, and fix a tiny bug in the SC
ConditionalOrderHashLib.hash
function.Related PR
Fix/addition to PR
Motivation and Context
Front-end was struggling to get signatures to match, reached out for help, I got pulled down the rabbit hole and decided to try and debug.
I found these two stack-overflow posts with the same issue:
And also another example that uses the new approach:
In both of those posts, the solution used
encodePacked
for the array of hashes before hashing that array instead ofencode
. Honestly I couldn't tell this myself from reading the EIP, so I wrote a hardhat test to verify, and it fails without this change, and passes with it.This thread questions the reasoning behind this.
bb_terk
says:That's the closest I could come to a reason for using
encodePacked
other than the fact it works and others use it in this scenario. The actual EIP itself says the following:This phraseology is pretty opaque to me, if anything it makes me think to use
encode
overencodePacked
. Hence it is possible that Viem and ethers have incorrectly interpreted the EIP. It is either that, or I am not reading it correctly or am missing some details in it.Note the following change was due to a
reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)
error when testing an array of conditions with hardhat:Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge fmt
?forge snapshot
?forge test
?