Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crates refactors #3670

Merged
merged 38 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f244da8
core: rm unused dep
tzemanovic Aug 19, 2024
98306d6
mv crates/core/src/sign.rs crates/tx/src/
tzemanovic Aug 19, 2024
ebafe2e
post mv fixes
tzemanovic Aug 19, 2024
f93d23a
mv crates/core/src/account.rs crates/account/src/auth.rs
tzemanovic Aug 19, 2024
8b777dc
post mv fixes
tzemanovic Aug 19, 2024
b892193
core: mv ProposalBytes into parameters mod
tzemanovic Aug 19, 2024
6b07f76
core: mv BlockHeight, BlockHash, Epoch, Epochs, Header into chain mod
tzemanovic Aug 19, 2024
cac41c4
core: rename s/Header/BlockHeader
tzemanovic Aug 19, 2024
de9eac8
core: update crate description
tzemanovic Aug 19, 2024
23af704
replay_protection: re-export storage Key
tzemanovic Aug 19, 2024
7756c4a
merkle_tree: re-export types in pub api
tzemanovic Aug 19, 2024
d68a5bf
storage: re-export types in pub api
tzemanovic Aug 19, 2024
3139dd3
storage: update rustdocs
tzemanovic Aug 19, 2024
c6b309e
gas: re-export types in pub api
tzemanovic Aug 19, 2024
39784a3
tx_env: re-export types in pub api
tzemanovic Aug 19, 2024
8d440c3
tx: remove unnecessary "salt" feature
tzemanovic Aug 20, 2024
496e10e
vp_env: re-export types in pub api
tzemanovic Aug 20, 2024
c72d752
account: re-export types in pub api
tzemanovic Aug 20, 2024
4c7363c
controller: re-export types in pub api
tzemanovic Aug 20, 2024
d5e5baa
vp: re-export types in pub api
tzemanovic Aug 20, 2024
af68c80
proof_of_stake: remove direct `namada_storage` dep
tzemanovic Aug 20, 2024
e74c963
shielded_token: remove direct `namada_storage` dep
tzemanovic Aug 20, 2024
8e025ad
trans_token: remove direct `namada_storage` dep
tzemanovic Aug 20, 2024
720efff
vm_env: remove unused deps and re-export public api
tzemanovic Aug 20, 2024
72f5d87
ibc: remove direct `namada_storage` dep
tzemanovic Aug 21, 2024
821e518
token: refactor imports
tzemanovic Aug 21, 2024
f85ebde
parameters: remove direct `namada_storage` dep
tzemanovic Aug 21, 2024
bcb0721
tx_prelude: refactors
tzemanovic Aug 21, 2024
afdcc24
refactor errors wrapping with namada_storage::Error/Result
tzemanovic Aug 22, 2024
494b533
tx_prelude: update crate doc
tzemanovic Aug 22, 2024
18e71d6
state: propagate migrations feature
tzemanovic Aug 23, 2024
67c586a
sdk: remove unused dep
tzemanovic Aug 23, 2024
2e0c7a5
tests: rm unused dep
tzemanovic Aug 23, 2024
323da6a
apps_lib: rm unused deps
tzemanovic Aug 23, 2024
e39b356
apps: rm unused deps
tzemanovic Aug 23, 2024
9a9b7da
changelog: add #3670
tzemanovic Aug 23, 2024
130f149
Apply suggestions from code review
tzemanovic Aug 27, 2024
c71daae
fixup! Apply suggestions from code review
tzemanovic Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/unreleased/improvements/3670-crate-refactors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Reorganized some types and modules and refactored crates re-
exports, error handling features and removed unused depdendencies.
([\#3670](https://github.com/anoma/namada/pull/3670))
45 changes: 15 additions & 30 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions crates/core/src/account.rs → crates/account/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//! Account types
//! Public keys associated with an account for n-signature authorization.

use std::collections::BTreeMap;

use borsh::{BorshDeserialize, BorshSerialize};
use namada_core::collections::HashMap;
use namada_core::hints;
use namada_core::key::common;
use namada_macros::BorshDeserializer;
#[cfg(feature = "migrations")]
use namada_migrations::*;
use serde::{Deserialize, Serialize};

use super::key::{common, RefTo};
use crate::collections::HashMap;
use crate::hints;

#[derive(
Debug,
Clone,
Expand Down Expand Up @@ -86,7 +85,7 @@ impl AccountPublicKeysMap {
secret_keys
.into_iter()
.filter_map(|secret_key: common::SecretKey| {
self.get_index_from_public_key(&secret_key.ref_to())
self.get_index_from_public_key(&secret_key.to_public())
.map(|index| (index, secret_key))
})
.collect()
Expand Down
9 changes: 6 additions & 3 deletions crates/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
clippy::print_stderr
)]

mod auth;
mod storage;
mod storage_key;
mod types;

pub use auth::AccountPublicKeysMap;
use borsh::{BorshDeserialize, BorshSerialize};
pub use namada_core::account::AccountPublicKeysMap;
use namada_core::address::Address;
use namada_core::key::common;
pub use namada_core::address::Address;
pub use namada_core::hash::Hash;
pub use namada_core::key::common;
pub use namada_core::storage::Key;
use namada_macros::BorshDeserializer;
#[cfg(feature = "migrations")]
use namada_migrations::*;
Expand Down
7 changes: 0 additions & 7 deletions crates/apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ tracing.workspace = true
winapi.workspace = true

[dev-dependencies]
namada_test_utils = {path = "../test_utils"}

assert_matches.workspace = true
bit-set.workspace = true
proptest.workspace = true
test-log.workspace = true
tokio-test.workspace = true

[build-dependencies]
git2.workspace = true
9 changes: 2 additions & 7 deletions crates/apps_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mainnet = [
"namada_sdk/mainnet",
]
# for integration tests and test utilities
testing = ["namada_test_utils", "lazy_static", "namada_sdk/testing"]
benches = ["namada_test_utils", "lazy_static", "namada_sdk/benches"]
testing = ["lazy_static", "namada_sdk/testing"]
benches = ["lazy_static", "namada_sdk/benches"]
integration = []
migrations = [
"namada_migrations",
Expand All @@ -35,7 +35,6 @@ namada_core = {path = "../core"}
namada_macros = {path = "../macros"}
namada_migrations = {path = "../migrations", optional = true}
namada_sdk = {path = "../sdk", features = ["download-params", "multicore"]}
namada_test_utils = {path = "../test_utils", optional = true}
namada_vm = {path = "../vm"}

async-trait.workspace = true
Expand Down Expand Up @@ -86,13 +85,9 @@ zeroize.workspace = true

[dev-dependencies]
namada_sdk = {path = "../sdk", features = ["testing"]}
namada_test_utils = {path = "../test_utils"}

assert_matches.workspace = true
bit-set.workspace = true
proptest.workspace = true
test-log.workspace = true
tokio-test.workspace = true
lazy_static.workspace= true
pretty_assertions.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/cli/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use borsh_ext::BorshSerializeExt;
use color_eyre::eyre::Result;
use itertools::sorted;
use ledger_namada_rs::{BIP44Path, NamadaApp};
use namada_core::storage::BlockHeight;
use namada_core::chain::BlockHeight;
use namada_sdk::address::{Address, DecodeError};
use namada_sdk::io::Io;
use namada_sdk::key::*;
Expand Down
3 changes: 2 additions & 1 deletion crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use masp_primitives::sapling::Node;
use masp_primitives::transaction::components::I128Sum;
use masp_primitives::zip32::ExtendedFullViewingKey;
use namada_sdk::address::{Address, InternalAddress, MASP};
use namada_sdk::chain::{BlockHeight, Epoch};
use namada_sdk::collections::{HashMap, HashSet};
use namada_sdk::control_flow::time::{Duration, Instant};
use namada_sdk::events::Event;
Expand All @@ -37,7 +38,7 @@ use namada_sdk::queries::{Client, RPC};
use namada_sdk::rpc::{
self, enriched_bonds_and_unbonds, query_epoch, TxResponse,
};
use namada_sdk::storage::{BlockHeight, BlockResults, Epoch};
use namada_sdk::storage::BlockResults;
use namada_sdk::tendermint_rpc::endpoint::status;
use namada_sdk::token::MaspDigitPos;
use namada_sdk::tx::display_batch_resp;
Expand Down
3 changes: 1 addition & 2 deletions crates/apps_lib/src/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ use namada_macros::BorshDeserializer;
#[cfg(feature = "migrations")]
use namada_migrations::*;
use namada_sdk::address::{Address, EstablishedAddress};
use namada_sdk::chain::ProposalBytes;
use namada_sdk::collections::HashMap;
use namada_sdk::eth_bridge::EthereumBridgeParams;
use namada_sdk::governance::parameters::GovernanceParameters;
use namada_sdk::governance::pgf::parameters::PgfParameters;
use namada_sdk::key::*;
use namada_sdk::parameters::EpochDuration;
use namada_sdk::parameters::{EpochDuration, ProposalBytes};
use namada_sdk::proof_of_stake::{Dec, GenesisValidator, OwnedPosParams};
use namada_sdk::string_encoding::StringEncoded;
use namada_sdk::time::DateTimeUtc;
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/config/genesis/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use namada_macros::BorshDeserializer;
#[cfg(feature = "migrations")]
use namada_migrations::*;
use namada_sdk::address::Address;
use namada_sdk::chain::ProposalBytes;
use namada_sdk::dec::Dec;
use namada_sdk::eth_bridge::storage::parameters::{
Contracts, Erc20WhitelistEntry, MinimumConfirmations,
};
use namada_sdk::parameters::ProposalBytes;
use namada_sdk::token::{
Amount, DenominatedAmount, Denomination, NATIVE_MAX_DECIMAL_PLACES,
};
Expand Down
3 changes: 1 addition & 2 deletions crates/apps_lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use std::num::NonZeroU64;
use std::path::{Path, PathBuf};

use directories::ProjectDirs;
use namada_sdk::chain::ChainId;
use namada_sdk::chain::{BlockHeight, ChainId};
use namada_sdk::collections::HashMap;
use namada_sdk::storage::BlockHeight;
use namada_sdk::time::Rfc3339String;
use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down
Loading
Loading