docs: fix message type hash in snip12 guide #1273#1274
Merged
andrew-fleming merged 2 commits intoOpenZeppelin:mainfrom Jan 2, 2025
Merged
docs: fix message type hash in snip12 guide #1273#1274andrew-fleming merged 2 commits intoOpenZeppelin:mainfrom
andrew-fleming merged 2 commits intoOpenZeppelin:mainfrom
Conversation
trishtzy
commented
Dec 28, 2024
c6d0a8b to
a901bb9
Compare
| [,cairo] | ||
| ---- | ||
| let message_type_hash = 0x120ae1bdaf7c1e48349da94bb8dad27351ca115d6605ce345aee02d68d99ec1; | ||
| let message_type_hash = 0xa2a7036c1f406af7c47722b209f23bd2f2d6ac21423c8c73bd92cf28409ee2; |
Collaborator
There was a problem hiding this comment.
Suggested change
| let message_type_hash = 0xa2a7036c1f406af7c47722b209f23bd2f2d6ac21423c8c73bd92cf28409ee2; | |
| let message_type_hash = 0x1bd8318a34d524539867e6c110cb97d385c745575910b6c2afec623432ee55; |
This is the hash I'm getting^
Can you confirm?
use core::to_byte_array::FormatAsByteArray;
let res = selector!("\"Message\"(\"recipient\":\"ContractAddress\",\"amount\":\"u256\",\"nonce\":\"felt\",\"expiry\":\"u128\")\"u256\"(\"low\":\"felt\",\"high\":\"felt\")");
println!("res: {}", res); // 49196983552140144393093620210836098680955957904181459224647480219440180821
let hex = res.format_as_byte_array(16);
println!("hex: 0x{}", hex); // 0x1bd8318a34d524539867e6c110cb97d385c745575910b6c2afec623432ee55
Contributor
Author
There was a problem hiding this comment.
Sorry! I was using timestamp for expiry and forgot to re-generate the hash.
The expected hash should be 0x28bf13f11bba405c77ce010d2781c5903cbed100f01f72fcff1664f98343eb6, where u256 is broken down to u128 low, high values instead of felt (ref).
(Updated PR description too)
use core::to_byte_array::FormatAsByteArray;
let res = selector!("\"Message\"(\"recipient\":\"ContractAddress\",\"amount\":\"u256\",\"nonce\":\"felt\",\"expiry\":\"u128\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")");
println!("res: {}", res); // 1151882460384444625458237696336527865031165261341111302013491262776159780534
let hex = res.format_as_byte_array(16);
println!("hex: 0x{}", hex); // 0x28bf13f11bba405c77ce010d2781c5903cbed100f01f72fcff1664f98343eb6
a901bb9 to
0e5ad17
Compare
andrew-fleming
approved these changes
Jan 2, 2025
Collaborator
andrew-fleming
left a comment
There was a problem hiding this comment.
LGTM! Thanks, @trishtzy!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1273
This PR updates the SNIP-12 documentation guide with a corrected message type hash value. Here are the key changes:
Typed Message Update:
"expiry\":\"u64\"to"expiry\":\"u128\"and,"u256"("low":"felt","high":"felt")to"u256"("low":"u128","high":"u128")Hash Value Update:
0x120ae1bdaf7c1e48349da94bb8dad27351ca115d6605ce345aee02d68d99ec1to:0x28bf13f11bba405c77ce010d2781c5903cbed100f01f72fcff1664f98343eb6PR Checklist