diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c441bebe..0390606f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed message type hash in SNIP12 doc (#1274) +- Permit and Message SNIP12 hashes (#1283) ## 0.20.0 (2024-12-06) diff --git a/packages/token/src/erc20/snip12_utils/permit.cairo b/packages/token/src/erc20/snip12_utils/permit.cairo index 3be1be100..20b5cf328 100644 --- a/packages/token/src/erc20/snip12_utils/permit.cairo +++ b/packages/token/src/erc20/snip12_utils/permit.cairo @@ -17,16 +17,19 @@ pub struct Permit { // Since there's no u64 type in SNIP-12, the type used for `deadline` parameter is u128 // selector!( -// "\"Permit\"( -// \"token\":\"ContractAddress\", -// \"spender\":\"ContractAddress\", -// \"amount\":\"u256\", -// \"nonce\":\"felt\", -// \"deadline\":\"u128\" -// )" +// "\"Permit\"( +// \"token\":\"ContractAddress\", +// \"spender\":\"ContractAddress\", +// \"amount\":\"u256\", +// \"nonce\":\"felt\", +// \"deadline\":\"u128\" +// )\"u256\"( +// \"low\":\"u128\", +// \"high\":\"u128\" +// )" // ); pub const PERMIT_TYPE_HASH: felt252 = - 0x2a8eb238e7cde741a544afcc79fe945d4292b089875fd068633854927fd5a96; + 0x3210d4fa611411fccef9213585061fbd533f82d1ea2bd3c1b3b6b589448d5cf; impl StructHashImpl of StructHash { fn hash_struct(self: @Permit) -> felt252 { diff --git a/packages/token/src/tests/erc20/test_erc20_permit.cairo b/packages/token/src/tests/erc20/test_erc20_permit.cairo index d07417bcc..42ea0d7c4 100644 --- a/packages/token/src/tests/erc20/test_erc20_permit.cairo +++ b/packages/token/src/tests/erc20/test_erc20_permit.cairo @@ -239,7 +239,7 @@ fn test_domain_separator() { #[test] fn test_permit_type_hash() { let expected_type_hash = selector!( - "\"Permit\"(\"token\":\"ContractAddress\",\"spender\":\"ContractAddress\",\"amount\":\"u256\",\"nonce\":\"felt\",\"deadline\":\"u128\")", + "\"Permit\"(\"token\":\"ContractAddress\",\"spender\":\"ContractAddress\",\"amount\":\"u256\",\"nonce\":\"felt\",\"deadline\":\"u128\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", ); assert_eq!(PERMIT_TYPE_HASH, expected_type_hash); } diff --git a/packages/utils/src/tests/test_snip12.cairo b/packages/utils/src/tests/test_snip12.cairo index 2ed399e1b..5b630ce72 100644 --- a/packages/utils/src/tests/test_snip12.cairo +++ b/packages/utils/src/tests/test_snip12.cairo @@ -7,8 +7,20 @@ use openzeppelin_testing::constants::{OWNER, RECIPIENT}; use snforge_std::{start_cheat_chain_id, test_address}; use starknet::ContractAddress; +// Since there's no u64 type in SNIP-12, the type used for `expiry` parameter is u128 +// selector!( +// "\"Message\"( +// \"recipient\":\"ContractAddress\", +// \"amount\":\"u256\", +// \"nonce\":\"felt\", +// \"expiry\":\"u128\" +// )\"u256\"( +// \"low\":\"u128\", +// \"high\":\"u128\" +// )" +// ); const MESSAGE_TYPE_HASH: felt252 = - 0x120ae1bdaf7c1e48349da94bb8dad27351ca115d6605ce345aee02d68d99ec1; + 0x28bf13f11bba405c77ce010d2781c5903cbed100f01f72fcff1664f98343eb6; #[derive(Copy, Drop, Hash)] struct Message {