Skip to content

Commit

Permalink
wallet-core: reorder imports to align with convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Neotamandua committed Nov 25, 2024
1 parent c047e87 commit 4ba25ae
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 71 deletions.
29 changes: 13 additions & 16 deletions wallet-core/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,35 @@ pub mod error;
pub mod mem;
pub mod panic;

use crate::keys::{
derive_bls_pk, derive_bls_sk, derive_phoenix_pk, derive_phoenix_sk,
derive_phoenix_vk,
};
use crate::notes::{self, balance, owned, pick};
use crate::Seed;
use error::ErrorCode;

use alloc::string::String;
use alloc::vec::Vec;
use core::{ptr, slice};

use dusk_bytes::{DeserializableSlice, Serializable};
use execution_core::signatures::bls::PublicKey as BlsPublicKey;
use execution_core::stake::{Stake, Withdraw as StakeWithdraw, STAKE_CONTRACT};
use execution_core::transfer::data::{ContractCall, TransactionData};
use execution_core::transfer::moonlight::Transaction as MoonlightTransaction;
use execution_core::transfer::phoenix;
use execution_core::transfer::phoenix::{
ArchivedNoteLeaf, Note, NoteLeaf, NoteOpening, Prove,
PublicKey as PhoenixPublicKey,
};

use execution_core::stake::{Stake, Withdraw as StakeWithdraw, STAKE_CONTRACT};
use execution_core::transfer::withdraw::WithdrawReplayToken;
use execution_core::transfer::Transaction;
use execution_core::BlsScalar;

use zeroize::Zeroize;

use rand_chacha::rand_core::SeedableRng;
use rand_chacha::ChaCha12Rng;
use rkyv::to_bytes;
use zeroize::Zeroize;

use rand_chacha::{rand_core::SeedableRng, ChaCha12Rng};
use error::ErrorCode;

use alloc::string::String;
use crate::keys::{
derive_bls_pk, derive_bls_sk, derive_phoenix_pk, derive_phoenix_sk,
derive_phoenix_vk,
};
use crate::notes::{self, balance, owned, pick};
use crate::Seed;

#[no_mangle]
static KEY_SIZE: usize = BlsScalar::SIZE;
Expand Down
13 changes: 6 additions & 7 deletions wallet-core/src/ffi/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::ffi::error::ErrorCode;

use alloc::alloc::{alloc, dealloc, Layout};
use core::slice;

use alloc::alloc::{alloc, dealloc, Layout};
use bytecheck::CheckBytes;
use rkyv::{
check_archived_root, de::deserializers::SharedDeserializeMap,
validation::validators::DefaultValidator, Archive, Deserialize,
};
use rkyv::de::deserializers::SharedDeserializeMap;
use rkyv::validation::validators::DefaultValidator;
use rkyv::{check_archived_root, Archive, Deserialize};

use crate::ffi::error::ErrorCode;

/// The alignment of the memory allocated by the FFI.
///
Expand Down
18 changes: 9 additions & 9 deletions wallet-core/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
use alloc::vec::Vec;
use core::ops::Range;

use rand_chacha::{rand_core::SeedableRng, ChaCha12Rng};
use execution_core::signatures::bls::{
PublicKey as BlsPublicKey, SecretKey as BlsSecretKey,
};
use execution_core::transfer::phoenix::{
PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey,
ViewKey as PhoenixViewKey,
};
use rand_chacha::rand_core::SeedableRng;
use rand_chacha::ChaCha12Rng;
use sha2::{Digest, Sha256};
use zeroize::Zeroize;

use execution_core::{
signatures::bls::{PublicKey as BlsPublicKey, SecretKey as BlsSecretKey},
transfer::phoenix::{
PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey,
ViewKey as PhoenixViewKey,
},
};

use crate::Seed;

/// Generates a [`BlsSecretKey`] from a seed and index.
Expand Down
10 changes: 5 additions & 5 deletions wallet-core/src/notes/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

use alloc::vec;
use alloc::vec::Vec;

use bytecheck::CheckBytes;
use core::ops::Index;
use core::slice::Iter;
use execution_core::{
transfer::phoenix::{NoteLeaf, SecretKey as PhoenixSecretKey},
BlsScalar,

use bytecheck::CheckBytes;
use execution_core::transfer::phoenix::{
NoteLeaf, SecretKey as PhoenixSecretKey,
};
use execution_core::BlsScalar;
use rkyv::{Archive, Deserialize, Serialize};

/// A collection of notes stored as key-value pairs.
Expand Down
5 changes: 3 additions & 2 deletions wallet-core/src/notes/pick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

use alloc::vec::Vec;

use crate::notes::owned::NoteList;
use crate::notes::MAX_INPUT_NOTES;
use execution_core::transfer::phoenix::{NoteLeaf, ViewKey as PhoenixViewKey};
use execution_core::BlsScalar;

use crate::notes::owned::NoteList;
use crate::notes::MAX_INPUT_NOTES;

/// Pick up to [`MAX_INPUT_NOTES`] notes to be used as input-notes in a
/// transaction from a list of owned notes.
///
Expand Down
35 changes: 17 additions & 18 deletions wallet-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,27 @@
use alloc::vec::Vec;

use dusk_bytes::Serializable;
use execution_core::signatures::bls::{
PublicKey as BlsPublicKey, SecretKey as BlsSecretKey,
};
use execution_core::stake::{Stake, Withdraw as StakeWithdraw, STAKE_CONTRACT};
use execution_core::transfer::data::{
ContractBytecode, ContractCall, ContractDeploy, TransactionData,
};
use execution_core::transfer::moonlight::Transaction as MoonlightTransaction;
use execution_core::transfer::phoenix::{
Note, NoteOpening, Prove, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, Transaction as PhoenixTransaction,
};
use execution_core::transfer::withdraw::{
Withdraw, WithdrawReceiver, WithdrawReplayToken,
};
use execution_core::transfer::{Transaction, TRANSFER_CONTRACT};
use execution_core::{BlsScalar, ContractId, Error, JubJubScalar};
use ff::Field;
use rand::{CryptoRng, RngCore};
use zeroize::Zeroize;

use execution_core::{
signatures::bls::{PublicKey as BlsPublicKey, SecretKey as BlsSecretKey},
stake::{Stake, Withdraw as StakeWithdraw, STAKE_CONTRACT},
transfer::{
data::{
ContractBytecode, ContractCall, ContractDeploy, TransactionData,
},
moonlight::Transaction as MoonlightTransaction,
phoenix::{
Note, NoteOpening, Prove, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, Transaction as PhoenixTransaction,
},
withdraw::{Withdraw, WithdrawReceiver, WithdrawReplayToken},
Transaction, TRANSFER_CONTRACT,
},
BlsScalar, ContractId, Error, JubJubScalar,
};

/// An unproven-transaction is nearly identical to a [`PhoenixTransaction`] with
/// the only difference being that it carries a serialized [`TxCircuitVec`]
/// instead of the proof bytes.
Expand Down
1 change: 0 additions & 1 deletion wallet-core/tests/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_bytes::Serializable;

use wallet_core::keys::{
derive_bls_sk, derive_multiple_phoenix_sk, derive_phoenix_pk,
derive_phoenix_sk, derive_phoenix_vk,
Expand Down
23 changes: 10 additions & 13 deletions wallet-core/tests/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use ff::Field;
use rand::{rngs::StdRng, CryptoRng, RngCore, SeedableRng};

use execution_core::{
transfer::phoenix::{
Note, NoteLeaf, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
},
JubJubScalar,
use execution_core::transfer::phoenix::{
Note, NoteLeaf, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
};
use execution_core::JubJubScalar;
use ff::Field;
use rand::rngs::StdRng;
use rand::{CryptoRng, RngCore, SeedableRng};

use wallet_core::{
keys::derive_multiple_phoenix_sk, keys::derive_phoenix_sk, map_owned,
notes::owned::NoteList, phoenix_balance, pick_notes, BalanceInfo, Seed,
};
use wallet_core::keys::{derive_multiple_phoenix_sk, derive_phoenix_sk};
use wallet_core::notes::owned::NoteList;
use wallet_core::{map_owned, phoenix_balance, pick_notes, BalanceInfo, Seed};

/// Generate a note, useful for testing purposes
fn gen_note<T: RngCore + CryptoRng>(
Expand Down

0 comments on commit 4ba25ae

Please sign in to comment.