Skip to content

Commit

Permalink
Merge pull request #423 from Concordium/fix-nonce-event-serialization
Browse files Browse the repository at this point in the history
[CIS-3 NFT] Fix nonce event serialization
  • Loading branch information
lassemoldrup authored May 14, 2024
2 parents 39a0dd1 + 8b93d7e commit 8fb01c5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions examples/cis2-multi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()),
]),
),
);
Expand Down Expand Up @@ -1424,8 +1424,8 @@ fn contract_permit(

// Log the nonce event.
logger.log(&Event::Nonce(NonceEvent {
account: param.signer,
nonce,
account: param.signer,
}))?;

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions examples/cis2-multi/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ fn test_permit_mint() {
},
})),
Event::Nonce(NonceEvent {
account: ALICE,
nonce: 0,
account: ALICE,
})
]);

Expand Down Expand Up @@ -391,8 +391,8 @@ fn test_permit_burn() {
owner: ALICE_ADDR,
})),
Event::Nonce(NonceEvent {
account: ALICE,
nonce: 0,
account: ALICE,
})
]);

Expand Down Expand Up @@ -442,8 +442,8 @@ fn test_permit_update_operator() {
operator: BOB_ADDR,
})),
Event::Nonce(NonceEvent {
account: ALICE,
nonce: 0,
account: ALICE,
})
]);

Expand Down Expand Up @@ -492,8 +492,8 @@ fn test_permit_transfer() {
to: BOB_ADDR,
})),
Event::Nonce(NonceEvent {
account: ALICE,
nonce: 0,
account: ALICE,
})
]);

Expand Down
8 changes: 4 additions & 4 deletions examples/cis3-nft-sponsored-txs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()),
]),
),
);
Expand Down Expand Up @@ -871,8 +871,8 @@ fn contract_permit(

// Log the nonce event.
logger.log(&Event::Nonce(NonceEvent {
account: param.signer,
nonce,
account: param.signer,
}))?;

Ok(())
Expand Down
12 changes: 6 additions & 6 deletions examples/cis5-smart-contract-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -811,8 +811,8 @@ fn withdraw_ccd(
}

logger.log(&Event::Nonce(NonceEvent {
public_key: signer,
nonce,
public_key: signer,
}))?;
}

Expand Down Expand Up @@ -947,8 +947,8 @@ fn withdraw_cis2_tokens(
}

logger.log(&Event::Nonce(NonceEvent {
public_key: signer,
nonce,
public_key: signer,
}))?;
}

Expand Down Expand Up @@ -1133,8 +1133,8 @@ fn transfer_ccd(
}

logger.log(&Event::Nonce(NonceEvent {
public_key: signer,
nonce,
public_key: signer,
}))?;
}

Expand Down Expand Up @@ -1230,8 +1230,8 @@ fn transfer_cis2_tokens(
}

logger.log(&Event::Nonce(NonceEvent {
public_key: signer,
nonce,
public_key: signer,
}))?;
}

Expand Down
8 changes: 4 additions & 4 deletions examples/cis5-smart-contract-wallet/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
]);
}
Expand Down Expand Up @@ -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,
})
]);
}
Expand Down Expand Up @@ -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,
})
]);
}
Expand Down Expand Up @@ -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,
})
]);
}
Expand Down

0 comments on commit 8fb01c5

Please sign in to comment.