mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-03-03 18:53:40 +00:00
add serialize/deserialize impls
This commit is contained in:
parent
d863b763d1
commit
84abe02573
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -9006,7 +9006,6 @@ dependencies = [
|
||||
"nssa",
|
||||
"nssa_core",
|
||||
"optfield",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,4 @@
|
||||
use nssa::AccountId;
|
||||
use nssa_core::account::Nonce;
|
||||
|
||||
use crate::{
|
||||
HashType,
|
||||
@ -65,7 +64,7 @@ pub fn create_transaction_native_token_transfer(
|
||||
signing_key: nssa::PrivateKey,
|
||||
) -> NSSATransaction {
|
||||
let account_ids = vec![from, to];
|
||||
let nonces = vec![Nonce(nonce)];
|
||||
let nonces = vec![nonce.into()];
|
||||
let program_id = nssa::program::Program::authenticated_transfer_program().id();
|
||||
let message = nssa::public_transaction::Message::try_new(
|
||||
program_id,
|
||||
|
||||
@ -168,7 +168,7 @@ impl InitialData {
|
||||
balance: 10_000,
|
||||
data: Data::default(),
|
||||
program_owner: DEFAULT_PROGRAM_ID,
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
),
|
||||
(
|
||||
@ -177,7 +177,7 @@ impl InitialData {
|
||||
balance: 20_000,
|
||||
data: Data::default(),
|
||||
program_owner: DEFAULT_PROGRAM_ID,
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -136,7 +136,7 @@ impl TpsTestManager {
|
||||
let message = putx::Message::try_new(
|
||||
program.id(),
|
||||
[pair[0].1, pair[1].1].to_vec(),
|
||||
[Nonce(0u128)].to_vec(),
|
||||
[0u128.into()].to_vec(),
|
||||
amount,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -10,7 +10,7 @@ use anyhow::Result;
|
||||
use integration_tests::{BlockingTestContext, TIME_TO_WAIT_FOR_BLOCK_SECONDS};
|
||||
use log::info;
|
||||
use nssa::{Account, AccountId, PrivateKey, PublicKey, program::Program};
|
||||
use nssa_core::{account::Nonce, program::DEFAULT_PROGRAM_ID};
|
||||
use nssa_core::program::DEFAULT_PROGRAM_ID;
|
||||
use tempfile::tempdir;
|
||||
use wallet::WalletCore;
|
||||
use wallet_ffi::{
|
||||
@ -523,7 +523,7 @@ fn test_wallet_ffi_get_account_private() -> Result<()> {
|
||||
);
|
||||
assert_eq!(account.balance, 10000);
|
||||
assert!(account.data.is_empty());
|
||||
assert_eq!(account.nonce, Nonce(0));
|
||||
assert_eq!(account.nonce, 0u128.into());
|
||||
|
||||
unsafe {
|
||||
wallet_ffi_free_account_data((&mut out_account) as *mut FfiAccount);
|
||||
|
||||
@ -11,18 +11,7 @@ use crate::{NullifierPublicKey, NullifierSecretKey, program::ProgramId};
|
||||
|
||||
pub mod data;
|
||||
|
||||
#[derive(
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Clone,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
BorshDeserialize,
|
||||
BorshSerialize,
|
||||
)]
|
||||
#[derive(Copy, Debug, Default, Clone, Eq, PartialEq)]
|
||||
pub struct Nonce(pub u128);
|
||||
|
||||
impl Nonce {
|
||||
@ -50,6 +39,48 @@ impl Nonce {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u128> for Nonce {
|
||||
fn from(value: u128) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Nonce> for u128 {
|
||||
fn from(value: Nonce) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Nonce {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
Serialize::serialize(&self.0, serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Nonce {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
Ok(<u128 as Deserialize>::deserialize(deserializer)?.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl BorshSerialize for Nonce {
|
||||
fn serialize<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
|
||||
BorshSerialize::serialize(&self.0, writer)
|
||||
}
|
||||
}
|
||||
|
||||
impl BorshDeserialize for Nonce {
|
||||
fn deserialize_reader<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
|
||||
Ok(<u128 as BorshDeserialize>::deserialize_reader(reader)?.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// Account to be used both in public and private contexts
|
||||
#[derive(
|
||||
Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize, BorshSerialize, BorshDeserialize,
|
||||
@ -252,4 +283,26 @@ mod tests {
|
||||
let expected_nonce = Nonce(327300903218789900388409116014290259894);
|
||||
assert_eq!(nonce, expected_nonce);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serde_roundtrip_for_nonce() {
|
||||
let nonce: Nonce = 7u128.into();
|
||||
|
||||
let serde_serialized_nonce = serde_json::to_vec(&nonce).unwrap();
|
||||
|
||||
let nonce_restored = serde_json::from_slice(&serde_serialized_nonce).unwrap();
|
||||
|
||||
assert_eq!(nonce, nonce_restored);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_borsh_roundtrip_for_nonce() {
|
||||
let nonce: Nonce = 7u128.into();
|
||||
|
||||
let borsh_serialized_nonce = borsh::to_vec(&nonce).unwrap();
|
||||
|
||||
let nonce_restored = borsh::from_slice(&borsh_serialized_nonce).unwrap();
|
||||
|
||||
assert_eq!(nonce, nonce_restored);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,14 +161,13 @@ impl AccountId {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::account::Nonce;
|
||||
|
||||
#[test]
|
||||
fn test_enconding() {
|
||||
let account = Account {
|
||||
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
balance: 123456789012345678901234567890123456,
|
||||
nonce: Nonce(42),
|
||||
nonce: 42u128.into(),
|
||||
data: b"hola mundo".to_vec().try_into().unwrap(),
|
||||
};
|
||||
|
||||
@ -226,12 +225,10 @@ mod tests {
|
||||
#[cfg(feature = "host")]
|
||||
#[test]
|
||||
fn test_account_to_bytes_roundtrip() {
|
||||
use crate::account::Nonce;
|
||||
|
||||
let account = Account {
|
||||
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
balance: 123456789012345678901234567890123456,
|
||||
nonce: Nonce(42),
|
||||
nonce: 42u128.into(),
|
||||
data: b"hola mundo".to_vec().try_into().unwrap(),
|
||||
};
|
||||
let bytes = account.to_bytes();
|
||||
|
||||
@ -328,7 +328,6 @@ impl WrappedBalanceSum {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::account::Nonce;
|
||||
|
||||
#[test]
|
||||
fn test_post_state_new_with_claim_constructor() {
|
||||
@ -336,7 +335,7 @@ mod tests {
|
||||
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
balance: 1337,
|
||||
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
|
||||
nonce: Nonce(10),
|
||||
nonce: 10u128.into(),
|
||||
};
|
||||
|
||||
let account_post_state = AccountPostState::new_claimed(account.clone());
|
||||
@ -351,7 +350,7 @@ mod tests {
|
||||
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
balance: 1337,
|
||||
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
|
||||
nonce: Nonce(10),
|
||||
nonce: 10u128.into(),
|
||||
};
|
||||
|
||||
let account_post_state = AccountPostState::new(account.clone());
|
||||
@ -366,7 +365,7 @@ mod tests {
|
||||
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
balance: 1337,
|
||||
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
|
||||
nonce: Nonce(10),
|
||||
nonce: 10u128.into(),
|
||||
};
|
||||
|
||||
let mut account_post_state = AccountPostState::new(account.clone());
|
||||
|
||||
@ -208,7 +208,7 @@ mod tests {
|
||||
let expected_sender_post = Account {
|
||||
program_owner: program.id(),
|
||||
balance: 100 - balance_to_move,
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
data: Data::default(),
|
||||
};
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ impl Message {
|
||||
pub mod tests {
|
||||
use nssa_core::{
|
||||
Commitment, EncryptionScheme, Nullifier, NullifierPublicKey, SharedSecretKey,
|
||||
account::{Account, Nonce},
|
||||
account::Account,
|
||||
encryption::{EphemeralPublicKey, ViewingPublicKey},
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
@ -111,7 +111,7 @@ pub mod tests {
|
||||
|
||||
let public_account_ids = vec![AccountId::new([1; 32])];
|
||||
|
||||
let nonces = vec![Nonce(1), Nonce(2), Nonce(3)];
|
||||
let nonces = vec![1u128.into(), 2u128.into(), 3u128.into()];
|
||||
|
||||
let public_post_states = vec![Account::default()];
|
||||
|
||||
|
||||
@ -232,7 +232,6 @@ impl PublicTransaction {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use nssa_core::account::Nonce;
|
||||
use sha2::{Digest, digest::FixedOutput};
|
||||
|
||||
use crate::{
|
||||
@ -258,7 +257,7 @@ pub mod tests {
|
||||
|
||||
fn transaction_for_tests() -> PublicTransaction {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let nonces = vec![Nonce(0), Nonce(0)];
|
||||
let nonces = vec![0u128.into(), 0u128.into()];
|
||||
let instruction = 1337;
|
||||
let message = Message::try_new(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
@ -336,7 +335,7 @@ pub mod tests {
|
||||
fn test_account_id_list_cant_have_duplicates() {
|
||||
let (key1, _, addr1, _) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![Nonce(0), Nonce(0)];
|
||||
let nonces = vec![0u128.into(), 0u128.into()];
|
||||
let instruction = 1337;
|
||||
let message = Message::try_new(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
@ -356,7 +355,7 @@ pub mod tests {
|
||||
fn test_number_of_nonces_must_match_number_of_signatures() {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![Nonce(0)];
|
||||
let nonces = vec![0u128.into()];
|
||||
let instruction = 1337;
|
||||
let message = Message::try_new(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
@ -376,7 +375,7 @@ pub mod tests {
|
||||
fn test_all_signatures_must_be_valid() {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![Nonce(0), Nonce(0)];
|
||||
let nonces = vec![0u128.into(), 0u128.into()];
|
||||
let instruction = 1337;
|
||||
let message = Message::try_new(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
@ -397,7 +396,7 @@ pub mod tests {
|
||||
fn test_nonces_must_match_the_state_current_nonces() {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![Nonce(0), Nonce(1)];
|
||||
let nonces = vec![0u128.into(), 1u128.into()];
|
||||
let instruction = 1337;
|
||||
let message = Message::try_new(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
@ -417,7 +416,7 @@ pub mod tests {
|
||||
fn test_program_id_must_belong_to_bulitin_program_ids() {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![Nonce(0), Nonce(0)];
|
||||
let nonces = vec![0u128.into(), 0u128.into()];
|
||||
let instruction = 1337;
|
||||
let unknown_program_id = [0xdeadbeef; 8];
|
||||
let message =
|
||||
|
||||
@ -51,8 +51,6 @@ impl WitnessSet {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use nssa_core::account::Nonce;
|
||||
|
||||
use super::*;
|
||||
use crate::AccountId;
|
||||
|
||||
@ -64,7 +62,7 @@ mod tests {
|
||||
let pubkey2 = PublicKey::new_from_private_key(&key2);
|
||||
let addr1 = AccountId::from(&pubkey1);
|
||||
let addr2 = AccountId::from(&pubkey2);
|
||||
let nonces = vec![Nonce(1), Nonce(2)];
|
||||
let nonces = vec![1u128.into(), 2u128.into()];
|
||||
let instruction = vec![1, 2, 3, 4];
|
||||
let message = Message::try_new([0; 8], vec![addr1, addr2], nonces, instruction).unwrap();
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ use std::collections::{BTreeSet, HashMap, HashSet};
|
||||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use nssa_core::{
|
||||
Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, MembershipProof, Nullifier,
|
||||
account::{Account, AccountId, Nonce},
|
||||
account::{Account, AccountId},
|
||||
program::ProgramId,
|
||||
};
|
||||
|
||||
@ -167,7 +167,7 @@ impl V02State {
|
||||
|
||||
for account_id in tx.signer_account_ids() {
|
||||
let current_account = self.get_account_by_id_mut(account_id);
|
||||
current_account.nonce.0 += 1;
|
||||
current_account.nonce.public_account_nonce_increment();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -203,7 +203,7 @@ impl V02State {
|
||||
// 5. Increment nonces for public signers
|
||||
for account_id in tx.signer_account_ids() {
|
||||
let current_account = self.get_account_by_id_mut(account_id);
|
||||
current_account.nonce.0 += 1;
|
||||
current_account.nonce.public_account_nonce_increment();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -287,7 +287,7 @@ impl V02State {
|
||||
balance: 1500,
|
||||
// Difficulty: 3
|
||||
data: vec![3; 33].try_into().expect("should fit"),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -345,7 +345,7 @@ pub mod tests {
|
||||
balance: u128,
|
||||
) -> PublicTransaction {
|
||||
let account_ids = vec![from, to];
|
||||
let nonces = vec![Nonce(nonce)];
|
||||
let nonces = vec![nonce.into()];
|
||||
let program_id = Program::authenticated_transfer_program().id();
|
||||
let message =
|
||||
public_transaction::Message::try_new(program_id, account_ids, nonces, balance).unwrap();
|
||||
@ -561,7 +561,7 @@ pub mod tests {
|
||||
..Account::default()
|
||||
};
|
||||
let account_with_default_values_except_nonce = Account {
|
||||
nonce: Nonce(37),
|
||||
nonce: 37u128.into(),
|
||||
..Account::default()
|
||||
};
|
||||
let account_with_default_values_except_data = Account {
|
||||
@ -1052,7 +1052,7 @@ pub mod tests {
|
||||
let expected_sender_post = {
|
||||
let mut this = state.get_account_by_id(sender_keys.account_id());
|
||||
this.balance -= balance_to_move;
|
||||
this.nonce.0 += 1;
|
||||
this.nonce.public_account_nonce_increment();
|
||||
this
|
||||
};
|
||||
|
||||
@ -2206,7 +2206,7 @@ pub mod tests {
|
||||
let message = public_transaction::Message::try_new(
|
||||
program.id(),
|
||||
vec![from, to],
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
amount,
|
||||
)
|
||||
.unwrap();
|
||||
@ -2249,7 +2249,7 @@ pub mod tests {
|
||||
program.id(),
|
||||
vec![to, from], // The chain_caller program permutes the account order in the chain
|
||||
// call
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -2288,7 +2288,7 @@ pub mod tests {
|
||||
program.id(),
|
||||
vec![to, from], // The chain_caller program permutes the account order in the chain
|
||||
// call
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -2556,7 +2556,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2568,7 +2568,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2588,7 +2588,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2601,7 +2601,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::token_a_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2614,7 +2614,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::token_b_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2627,7 +2627,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::token_lp_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2639,7 +2639,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_balance_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2651,7 +2651,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_balance_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2663,7 +2663,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: BalanceForTests::user_token_lp_holding_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2675,7 +2675,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_balance_swap_1(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2687,7 +2687,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_balance_swap_1(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2707,7 +2707,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2719,7 +2719,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_swap_1(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2731,7 +2731,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_swap_1(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2743,7 +2743,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_balance_swap_2(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2755,7 +2755,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_balance_swap_2(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2775,7 +2775,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2787,7 +2787,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_swap_2(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2799,7 +2799,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_swap_2(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2811,7 +2811,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_balance_add(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2823,7 +2823,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_balance_add(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2843,7 +2843,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2855,7 +2855,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_add(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2867,7 +2867,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_add(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2879,7 +2879,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: BalanceForTests::user_token_lp_holding_add(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2892,7 +2892,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::token_lp_supply_add(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2904,7 +2904,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_balance_remove(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2916,7 +2916,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_balance_remove(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2936,7 +2936,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2948,7 +2948,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_remove(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2960,7 +2960,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_remove(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2972,7 +2972,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: BalanceForTests::user_token_lp_holding_remove(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2985,7 +2985,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::token_lp_supply_remove(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2998,7 +2998,7 @@ pub mod tests {
|
||||
total_supply: 0,
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3010,7 +3010,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3022,7 +3022,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3042,7 +3042,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: false,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3054,7 +3054,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_holding_new_definition(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3066,7 +3066,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_holding_new_definition(),
|
||||
}),
|
||||
nonce: Nonce(1),
|
||||
nonce: 1u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3078,7 +3078,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: BalanceForTests::lp_supply_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3091,7 +3091,7 @@ pub mod tests {
|
||||
total_supply: BalanceForTests::lp_supply_init(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3111,7 +3111,7 @@ pub mod tests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3123,7 +3123,7 @@ pub mod tests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3210,7 +3210,7 @@ pub mod tests {
|
||||
IdForTests::user_token_b_id(),
|
||||
IdForTests::user_token_lp_id(),
|
||||
],
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3287,7 +3287,7 @@ pub mod tests {
|
||||
IdForTests::user_token_b_id(),
|
||||
IdForTests::user_token_lp_id(),
|
||||
],
|
||||
vec![Nonce(0), Nonce(0)],
|
||||
vec![0u128.into(), 0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3371,7 +3371,7 @@ pub mod tests {
|
||||
IdForTests::user_token_b_id(),
|
||||
IdForTests::user_token_lp_id(),
|
||||
],
|
||||
vec![Nonce(0), Nonce(0)],
|
||||
vec![0u128.into(), 0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3443,7 +3443,7 @@ pub mod tests {
|
||||
IdForTests::user_token_b_id(),
|
||||
IdForTests::user_token_lp_id(),
|
||||
],
|
||||
vec![Nonce(0), Nonce(0)],
|
||||
vec![0u128.into(), 0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3506,7 +3506,7 @@ pub mod tests {
|
||||
IdForTests::user_token_b_id(),
|
||||
IdForTests::user_token_lp_id(),
|
||||
],
|
||||
vec![Nonce(0), Nonce(0)],
|
||||
vec![0u128.into(), 0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3566,7 +3566,7 @@ pub mod tests {
|
||||
IdForTests::user_token_a_id(),
|
||||
IdForTests::user_token_b_id(),
|
||||
],
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3616,7 +3616,7 @@ pub mod tests {
|
||||
IdForTests::user_token_a_id(),
|
||||
IdForTests::user_token_b_id(),
|
||||
],
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -3731,7 +3731,7 @@ pub mod tests {
|
||||
chain_caller.id(),
|
||||
vec![to, from], // The chain_caller program permutes the account order in the chain
|
||||
// call
|
||||
vec![Nonce(0)],
|
||||
vec![0u128.into()],
|
||||
instruction,
|
||||
)
|
||||
.unwrap();
|
||||
@ -4018,14 +4018,14 @@ pub mod tests {
|
||||
let expected_sender_post = {
|
||||
let mut this = state.get_account_by_id(sender_id);
|
||||
this.balance = sender_init_balance;
|
||||
this.nonce = Nonce(0);
|
||||
this.nonce = 0u128.into();
|
||||
this
|
||||
};
|
||||
|
||||
let expected_recipient_post = {
|
||||
let mut this = state.get_account_by_id(sender_id);
|
||||
this.balance = recipient_init_balance;
|
||||
this.nonce = Nonce(0);
|
||||
this.nonce = 0u128.into();
|
||||
this
|
||||
};
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ use amm_core::{
|
||||
compute_pool_pda, compute_vault_pda, compute_vault_pda_seed,
|
||||
};
|
||||
use nssa_core::{
|
||||
account::{Account, AccountId, AccountWithMetadata, Data, Nonce},
|
||||
account::{Account, AccountId, AccountWithMetadata, Data},
|
||||
program::{ChainedCall, ProgramId},
|
||||
};
|
||||
use token_core::{TokenDefinition, TokenHolding};
|
||||
@ -415,7 +415,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::user_token_a_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::user_token_a_id(),
|
||||
@ -431,7 +431,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::user_token_b_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::user_token_b_id(),
|
||||
@ -447,7 +447,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_reserve_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_a_id(),
|
||||
@ -463,7 +463,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_reserve_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_b_id(),
|
||||
@ -479,7 +479,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_reserve_high(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_a_id(),
|
||||
@ -495,7 +495,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_reserve_high(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_b_id(),
|
||||
@ -511,7 +511,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_reserve_low(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_a_id(),
|
||||
@ -527,7 +527,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_reserve_low(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_b_id(),
|
||||
@ -543,7 +543,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_a_id(),
|
||||
@ -559,7 +559,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_b_id(),
|
||||
@ -576,7 +576,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::lp_supply_init(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::token_lp_definition_id(),
|
||||
@ -593,7 +593,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::lp_supply_init(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::vault_a_id(),
|
||||
@ -609,7 +609,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::user_token_lp_id(),
|
||||
@ -625,7 +625,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_lp_definition_id(),
|
||||
balance: BalanceForTests::user_token_lp_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::user_token_lp_id(),
|
||||
@ -649,7 +649,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -673,7 +673,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -697,7 +697,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -721,7 +721,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -745,7 +745,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -769,7 +769,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -793,7 +793,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -817,7 +817,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -841,7 +841,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -865,7 +865,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -889,7 +889,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: false,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -913,7 +913,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: false,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: AccountId::new([4; 32]),
|
||||
@ -929,7 +929,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_a_definition_id(),
|
||||
balance: BalanceForTests::vault_a_reserve_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: AccountId::new([4; 32]),
|
||||
@ -945,7 +945,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::token_b_definition_id(),
|
||||
balance: BalanceForTests::vault_b_reserve_init(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: AccountId::new([4; 32]),
|
||||
@ -969,7 +969,7 @@ impl AccountForTests {
|
||||
fees: 0u128,
|
||||
active: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use nssa_core::account::{Account, AccountId, AccountWithMetadata, Data, Nonce};
|
||||
use nssa_core::account::{Account, AccountId, AccountWithMetadata, Data};
|
||||
use token_core::{
|
||||
MetadataStandard, NewTokenDefinition, NewTokenMetadata, TokenDefinition, TokenHolding,
|
||||
};
|
||||
@ -32,7 +32,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::init_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -49,7 +49,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::init_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -65,7 +65,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id_diff(),
|
||||
balance: BalanceForTests::holding_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -81,7 +81,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::holding_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -97,7 +97,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::holding_balance(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -113,7 +113,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::init_supply(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -130,7 +130,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::init_supply_burned(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -146,7 +146,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::holding_balance_burned(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -170,7 +170,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::mint_success(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -186,7 +186,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::holding_balance_mint(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -203,7 +203,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::init_supply_mint(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -219,7 +219,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::mint_overflow(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -236,7 +236,7 @@ impl AccountForTests {
|
||||
printable_supply: BalanceForTests::printable_copies(),
|
||||
metadata_id: AccountId::new([0; 32]),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -260,7 +260,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::init_supply(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -277,7 +277,7 @@ impl AccountForTests {
|
||||
total_supply: BalanceForTests::init_supply(),
|
||||
metadata_id: None,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::pool_definition_id(),
|
||||
@ -293,7 +293,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::init_supply(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -309,7 +309,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::init_supply(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id_2(),
|
||||
@ -325,7 +325,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::recipient_post_transfer(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id_2(),
|
||||
@ -341,7 +341,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
balance: BalanceForTests::sender_post_transfer(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -357,7 +357,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
print_balance: BalanceForTests::printable_copies(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -373,7 +373,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
print_balance: 1,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -389,7 +389,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
print_balance: BalanceForTests::printable_copies() - 1,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -405,7 +405,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
owned: true,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: false,
|
||||
account_id: IdForTests::holding_id(),
|
||||
@ -421,7 +421,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
print_balance: BalanceForTests::printable_copies(),
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id_2(),
|
||||
@ -437,7 +437,7 @@ impl AccountForTests {
|
||||
definition_id: IdForTests::pool_definition_id(),
|
||||
print_balance: 0,
|
||||
}),
|
||||
nonce: Nonce(0),
|
||||
nonce: 0u128.into(),
|
||||
},
|
||||
is_authorized: true,
|
||||
account_id: IdForTests::holding_id(),
|
||||
|
||||
@ -11,8 +11,8 @@ fn main() {
|
||||
};
|
||||
|
||||
let account_pre = &pre.account;
|
||||
let mut account_post = account_pre.clone();
|
||||
account_post.nonce.0 += 1;
|
||||
let account_post = account_pre.clone();
|
||||
account_post.nonce.public_account_nonce_increment();
|
||||
|
||||
write_nssa_outputs(
|
||||
instruction_words,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user