From 8afe7df92730b06886f83f89d5974219bc4c39c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20M=C3=B8ldrup?= Date: Tue, 23 Apr 2024 15:20:51 +0200 Subject: [PATCH 1/2] Fix nonce event serialization --- examples/cis3-nft-sponsored-txs/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/cis3-nft-sponsored-txs/src/lib.rs b/examples/cis3-nft-sponsored-txs/src/lib.rs index e702e3d5..2fff7a1f 100644 --- a/examples/cis3-nft-sponsored-txs/src/lib.rs +++ b/examples/cis3-nft-sponsored-txs/src/lib.rs @@ -94,10 +94,10 @@ pub enum Event { /// tracks the nonce used by the signer of the `PermitMessage`. #[derive(Debug, Serialize, SchemaType, PartialEq, Eq)] pub struct NonceEvent { - /// Account that signed the `PermitMessage`. - pub account: AccountAddress, /// The nonce that was used in the `PermitMessage`. pub nonce: u64, + /// Account that signed the `PermitMessage`. + pub account: AccountAddress, } // Implementing a custom schemaType to the `Event` combining all CIS2/CIS3 @@ -110,8 +110,8 @@ impl schema::SchemaType for Event { ( "Nonce".to_string(), schema::Fields::Named(vec![ - (String::from("account"), AccountAddress::get_type()), (String::from("nonce"), u64::get_type()), + (String::from("account"), AccountAddress::get_type()), ]), ), ); @@ -871,8 +871,8 @@ fn contract_permit( // Log the nonce event. logger.log(&Event::Nonce(NonceEvent { - account: param.signer, nonce, + account: param.signer, }))?; Ok(()) From 8b93d7ea0633c49af36d96b4acf971b2f12eb84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20M=C3=B8ldrup?= Date: Tue, 14 May 2024 13:24:38 +0200 Subject: [PATCH 2/2] Reorder NonceEvent struct to match CIS-3 standard --- examples/cis2-multi/src/lib.rs | 8 ++++---- examples/cis2-multi/tests/tests.rs | 8 ++++---- examples/cis5-smart-contract-wallet/src/lib.rs | 12 ++++++------ examples/cis5-smart-contract-wallet/tests/tests.rs | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/cis2-multi/src/lib.rs b/examples/cis2-multi/src/lib.rs index ba58d1f7..50fbbcbd 100644 --- a/examples/cis2-multi/src/lib.rs +++ b/examples/cis2-multi/src/lib.rs @@ -171,10 +171,10 @@ pub enum Event { /// tracks the nonce used by the signer of the `PermitMessage`. #[derive(Debug, Serialize, SchemaType, PartialEq, Eq)] pub struct NonceEvent { - /// Account that signed the `PermitMessage`. - pub account: AccountAddress, /// The nonce that was used in the `PermitMessage`. pub nonce: u64, + /// Account that signed the `PermitMessage`. + pub account: AccountAddress, } /// The UpdateBlacklistEvent is logged when an address is added to or removed @@ -218,8 +218,8 @@ impl schema::SchemaType for Event { ( "Nonce".to_string(), schema::Fields::Named(vec![ - (String::from("account"), AccountAddress::get_type()), (String::from("nonce"), u64::get_type()), + (String::from("account"), AccountAddress::get_type()), ]), ), ); @@ -1424,8 +1424,8 @@ fn contract_permit( // Log the nonce event. logger.log(&Event::Nonce(NonceEvent { - account: param.signer, nonce, + account: param.signer, }))?; Ok(()) diff --git a/examples/cis2-multi/tests/tests.rs b/examples/cis2-multi/tests/tests.rs index 90d1c43d..ea3d6384 100644 --- a/examples/cis2-multi/tests/tests.rs +++ b/examples/cis2-multi/tests/tests.rs @@ -345,8 +345,8 @@ fn test_permit_mint() { }, })), Event::Nonce(NonceEvent { - account: ALICE, nonce: 0, + account: ALICE, }) ]); @@ -391,8 +391,8 @@ fn test_permit_burn() { owner: ALICE_ADDR, })), Event::Nonce(NonceEvent { - account: ALICE, nonce: 0, + account: ALICE, }) ]); @@ -442,8 +442,8 @@ fn test_permit_update_operator() { operator: BOB_ADDR, })), Event::Nonce(NonceEvent { - account: ALICE, nonce: 0, + account: ALICE, }) ]); @@ -492,8 +492,8 @@ fn test_permit_transfer() { to: BOB_ADDR, })), Event::Nonce(NonceEvent { - account: ALICE, nonce: 0, + account: ALICE, }) ]); diff --git a/examples/cis5-smart-contract-wallet/src/lib.rs b/examples/cis5-smart-contract-wallet/src/lib.rs index c99940c3..c2cea5a6 100644 --- a/examples/cis5-smart-contract-wallet/src/lib.rs +++ b/examples/cis5-smart-contract-wallet/src/lib.rs @@ -104,10 +104,10 @@ pub enum Event { /// tracks the nonce used by the signer of the message. #[derive(Debug, Serialize, SchemaType, PartialEq, Eq)] pub struct NonceEvent { - /// Account that signed the message. - pub public_key: PublicKeyEd25519, /// The nonce that was used in the message. pub nonce: u64, + /// Account that signed the message. + pub public_key: PublicKeyEd25519, } /// The `DepositCcdEvent` is logged whenever a CCD amount received by @@ -811,8 +811,8 @@ fn withdraw_ccd( } logger.log(&Event::Nonce(NonceEvent { - public_key: signer, nonce, + public_key: signer, }))?; } @@ -947,8 +947,8 @@ fn withdraw_cis2_tokens( } logger.log(&Event::Nonce(NonceEvent { - public_key: signer, nonce, + public_key: signer, }))?; } @@ -1133,8 +1133,8 @@ fn transfer_ccd( } logger.log(&Event::Nonce(NonceEvent { - public_key: signer, nonce, + public_key: signer, }))?; } @@ -1230,8 +1230,8 @@ fn transfer_cis2_tokens( } logger.log(&Event::Nonce(NonceEvent { - public_key: signer, nonce, + public_key: signer, }))?; } diff --git a/examples/cis5-smart-contract-wallet/tests/tests.rs b/examples/cis5-smart-contract-wallet/tests/tests.rs index 09ba1e89..70beea0b 100644 --- a/examples/cis5-smart-contract-wallet/tests/tests.rs +++ b/examples/cis5-smart-contract-wallet/tests/tests.rs @@ -172,8 +172,8 @@ fn test_withdraw_ccd() { to: BOB_ADDR, }), Event::Nonce(NonceEvent { - public_key: alice_public_key, nonce: 0, + public_key: alice_public_key, }) ]); } @@ -312,8 +312,8 @@ fn test_withdraw_cis2_tokens() { to: BOB_ADDR }), Event::Nonce(NonceEvent { - public_key: alice_public_key, nonce: 0, + public_key: alice_public_key, }) ]); } @@ -423,8 +423,8 @@ fn test_transfer_ccd() { to: BOB_PUBLIC_KEY, }), Event::Nonce(NonceEvent { - public_key: alice_public_key, nonce: 0, + public_key: alice_public_key, }) ]); } @@ -554,8 +554,8 @@ fn test_transfer_cis2_tokens() { to: BOB_PUBLIC_KEY }), Event::Nonce(NonceEvent { - public_key: alice_public_key, nonce: 0, + public_key: alice_public_key, }) ]); }