Skip to content

Commit

Permalink
ref: crypto into diff pack
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyF0uR committed Nov 6, 2024
1 parent 274852c commit 4165f98
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 52 deletions.
21 changes: 13 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
resolver = "2"
members = [
# Inner libs
"crates/cesium-crypto",
"crates/cesium-storage",
"crates/cesium-material",
"crates/cesium-mempool",
"crates/cesium-state",
"crates/cesium-econ",
"crates/cesium-proc",
"crates/selenide-sdk",
"crates/selenide-sdk-macros",
Expand Down Expand Up @@ -59,11 +59,11 @@ wasmer-middlewares = "5.0.0"
clap = { version = "4.5.20", features = ["derive"]}
dashmap = "6.1.0"
# Inner libs
cesium-crypto = { path = "crates/cesium-crypto" }
cesium-storage = { path = "crates/cesium-storage" }
cesium-material = { path = "crates/cesium-material" }
cesium-mempool = { path = "crates/cesium-mempool" }
cesium-state = { path = "crates/cesium-state" }
cesium-econ = { path = "crates/cesium-econ" }
cesium-runtime = { path = "crates/cesium-runtime" }
cesium-proc = { path = "crates/cesium-proc" }
selenide-sdk = { path = "crates/selenide-sdk" }
Expand Down
16 changes: 16 additions & 0 deletions crates/cesium-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "cesium-crypto"
edition = "2021"
version.workspace = true
license = "GPL-3.0"
publish = false


[dependencies]
pqcrypto-sphincsplus.workspace = true
pqcrypto-traits.workspace = true
hex.workspace = true
rand.workspace = true
bs58.workspace = true
serde.workspace = true
sha3.workspace = true
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub const DEFAULT_DECIMALS: u8 = 12;
pub const MAX_BLOCK_TRANSACTIONS: usize = 2250;
pub const NATIVE_TOKEN: &str = "cesium111111111111111111111111111111111111111111111111111111111111";
// [99, 101, 115, 105, 117, 109, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49]
pub const NATIVE_DECIMALS: u8 = 12;
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions crates/cesium-crypto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod constants;
pub mod id;
pub mod keys;
pub mod serializer;
File renamed without changes.
8 changes: 0 additions & 8 deletions crates/cesium-econ/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion crates/cesium-econ/src/lib.rs

This file was deleted.

7 changes: 1 addition & 6 deletions crates/cesium-material/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ publish = false


[dependencies]
pqcrypto-sphincsplus.workspace = true
pqcrypto-traits.workspace = true
hex.workspace = true
rand.workspace = true
bs58.workspace = true
serde.workspace = true
sha3.workspace = true
cesium-crypto.workspace = true
19 changes: 10 additions & 9 deletions crates/cesium-material/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use cesium_crypto::keys::{KeyPair, PublicKeyBytes};
use rand::Rng;

use crate::{
constants::MAX_BLOCK_TRANSACTIONS,
keys::{KeyPair, PublicKeyBytes},
transaction::Transaction,
};
use crate::transaction::Transaction;

const MAX_BLOCK_TRANSACTIONS: usize = 2250;

pub struct Block {
pub index: u64,
Expand Down Expand Up @@ -97,13 +96,15 @@ impl Block {

#[cfg(test)]
mod tests {
use super::*;
use crate::{
use cesium_crypto::{
constants::{NATIVE_DECIMALS, NATIVE_TOKEN},
instruction::Instruction,
keys::{self, KeyPair, SIG_BYTE_LEN},
keys::{self, SIG_BYTE_LEN},
};

use crate::instruction::Instruction;

use super::*;

#[test]
fn test_block() {
let sender_kp = KeyPair::create();
Expand Down
7 changes: 4 additions & 3 deletions crates/cesium-material/src/instruction.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::constants::NATIVE_TOKEN;
use crate::keys;
use crate::keys::PublicKeyBytes;
use cesium_crypto::{
constants::NATIVE_TOKEN,
keys::{self, PublicKeyBytes},
};

pub struct DataParameter {
pub d: Vec<u8>, // the data
Expand Down
4 changes: 0 additions & 4 deletions crates/cesium-material/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
pub mod block;
pub mod constants;
pub mod id;
pub mod instruction;
pub mod keys;
pub mod serializer;
pub mod transaction;
4 changes: 3 additions & 1 deletion crates/cesium-material/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{instruction::Instruction, keys::KeyPair};
use cesium_crypto::keys::KeyPair;

use crate::instruction::Instruction;

pub struct Transaction {
pub instructions: Vec<Instruction>,
Expand Down
2 changes: 1 addition & 1 deletion crates/cesium-proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ publish = false

[dependencies]
tokio.workspace = true
cesium-material.workspace = true
cesium-crypto.workspace = true
dashmap.workspace = true
2 changes: 1 addition & 1 deletion crates/cesium-proc/src/graph/dag.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cesium_material::{
use cesium_crypto::{
id::generate_id,
keys::{slice_to_array_48, SIG_BYTE_LEN},
};
Expand Down
1 change: 1 addition & 0 deletions crates/cesium-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ license = "GPL-3.0"
publish = false

[dependencies]
cesium-crypto.workspace = true
cesium-material.workspace = true
tokio.workspace = true
3 changes: 2 additions & 1 deletion crates/cesium-state/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cesium_material::{block::Block, keys::KeyPair};
use cesium_crypto::keys::KeyPair;
use cesium_material::block::Block;
use std::sync::Arc;
use tokio::sync::OnceCell;

Expand Down
2 changes: 1 addition & 1 deletion crates/cesium-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false


[dependencies]
cesium-material.workspace = true
cesium-crypto.workspace = true
rocksdb.workspace = true
# tokio.workspace = true
bincode.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/cesium-storage/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use cesium_material::id::{generate_id, to_readable_id};
use cesium_crypto::id::{generate_id, to_readable_id};
use rocksdb::{Options, WriteBatch, DB};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -85,7 +85,7 @@ impl DataAccountManager {
#[cfg(test)]
mod tests {
use super::*;
use cesium_material::keys::KeyPair;
use cesium_crypto::keys::KeyPair;
use tempfile::TempDir;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/cesium-storage/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use cesium_material::serializer::Array48;
use cesium_crypto::serializer::Array48;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DataObject {
Expand Down
2 changes: 1 addition & 1 deletion crates/selenide-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ publish = false
[dependencies]
wasmer.workspace = true
wasmer-middlewares.workspace = true
cesium-material.workspace = true
cesium-crypto.workspace = true
2 changes: 1 addition & 1 deletion crates/selenide-wasm/src/functions/generate_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cesium_material::id::generate_id;
use cesium_crypto::id::generate_id;
use wasmer::FunctionEnvMut;

use crate::{env::ContractEnv, memory};
Expand Down

0 comments on commit 4165f98

Please sign in to comment.