From 07c1b10d62e1cd322938fd0e75745ceba2d50094 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 2 Jan 2025 11:21:02 -0600 Subject: [PATCH 1/4] fix permit hash --- .../token/src/erc20/snip12_utils/permit.cairo | 19 +++++++++++-------- .../src/tests/erc20/test_erc20_permit.cairo | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) 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); } From fdcfbca916e1a1f338a237b1ad84130614254267 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 2 Jan 2025 11:21:17 -0600 Subject: [PATCH 2/4] fix message hash --- packages/utils/src/tests/test_snip12.cairo | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 { From bb3493d0fac891f5925be55613e612539201be45 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 2 Jan 2025 11:24:17 -0600 Subject: [PATCH 3/4] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c441bebe..0eb590ba2 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 (#) ## 0.20.0 (2024-12-06) From c668b03b3a289f78d26b6415c6c4dd11dcb5b821 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 2 Jan 2025 15:04:05 -0600 Subject: [PATCH 4/4] update changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb590ba2..0390606f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +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 (#) +- Permit and Message SNIP12 hashes (#1283) ## 0.20.0 (2024-12-06)