From 8e8ebf2013c24e5b2b2f07ad6b9a103f2840385b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 1 Feb 2024 15:57:57 +0000 Subject: [PATCH] update all core types usages --- Cargo.lock | 2 - crates/account/src/lib.rs | 6 +- crates/account/src/storage.rs | 6 +- crates/account/src/storage_key.rs | 6 +- crates/account/src/types.rs | 12 +- crates/apps/src/bin/namada-node/cli.rs | 2 +- crates/apps/src/lib/bench_utils.rs | 24 ++-- crates/apps/src/lib/cli.rs | 24 ++-- crates/apps/src/lib/cli/api.rs | 2 +- crates/apps/src/lib/cli/client.rs | 2 +- crates/apps/src/lib/cli/context.rs | 14 +- crates/apps/src/lib/cli/relayer.rs | 2 +- crates/apps/src/lib/cli/wallet.rs | 8 +- crates/apps/src/lib/client/rpc.rs | 22 +-- crates/apps/src/lib/client/tx.rs | 8 +- crates/apps/src/lib/client/utils.rs | 12 +- .../src/lib/config/ethereum_bridge/ledger.rs | 2 +- crates/apps/src/lib/config/genesis.rs | 26 ++-- crates/apps/src/lib/config/genesis/chain.rs | 20 +-- .../apps/src/lib/config/genesis/templates.rs | 20 +-- .../src/lib/config/genesis/transactions.rs | 20 +-- crates/apps/src/lib/config/genesis/utils.rs | 2 +- crates/apps/src/lib/config/global.rs | 2 +- crates/apps/src/lib/config/mod.rs | 8 +- crates/apps/src/lib/node/ledger/abortable.rs | 2 +- .../apps/src/lib/node/ledger/broadcaster.rs | 2 +- .../lib/node/ledger/ethereum_oracle/events.rs | 14 +- .../lib/node/ledger/ethereum_oracle/mod.rs | 15 +- .../test_tools/events_endpoint.rs | 2 +- .../ledger/ethereum_oracle/test_tools/mod.rs | 4 +- crates/apps/src/lib/node/ledger/mod.rs | 6 +- .../lib/node/ledger/shell/finalize_block.rs | 26 ++-- .../src/lib/node/ledger/shell/governance.rs | 6 +- .../src/lib/node/ledger/shell/init_chain.rs | 12 +- crates/apps/src/lib/node/ledger/shell/mod.rs | 47 +++--- .../lib/node/ledger/shell/prepare_proposal.rs | 18 +-- .../lib/node/ledger/shell/process_proposal.rs | 10 +- .../apps/src/lib/node/ledger/shell/queries.rs | 4 +- .../lib/node/ledger/shell/testing/client.rs | 2 +- .../src/lib/node/ledger/shell/testing/node.rs | 14 +- .../lib/node/ledger/shell/testing/utils.rs | 2 +- .../apps/src/lib/node/ledger/shell/utils.rs | 2 +- .../shell/vote_extensions/bridge_pool_vext.rs | 10 +- .../shell/vote_extensions/eth_events.rs | 16 +-- .../shell/vote_extensions/val_set_update.rs | 2 +- .../src/lib/node/ledger/shims/abcipp_shim.rs | 6 +- .../node/ledger/shims/abcipp_shim_types.rs | 6 +- .../apps/src/lib/node/ledger/storage/mod.rs | 59 ++++---- .../src/lib/node/ledger/storage/rocksdb.rs | 134 +++++++----------- .../src/lib/node/ledger/tendermint_node.rs | 8 +- crates/apps/src/lib/wallet/defaults.rs | 8 +- crates/apps/src/lib/wallet/mod.rs | 2 +- crates/apps/src/lib/wallet/pre_genesis.rs | 2 +- crates/apps/src/lib/wallet/store.rs | 4 +- crates/benches/README.md | 2 +- crates/benches/host_env.rs | 12 +- crates/benches/native_vps.rs | 102 ++++++------- crates/benches/process_wrapper.rs | 8 +- crates/benches/txs.rs | 36 ++--- crates/benches/vps.rs | 13 +- crates/core/Cargo.toml | 2 - crates/core/src/address.rs | 22 ++- crates/core/src/dec.rs | 8 +- crates/core/src/eth_abi.rs | 6 +- crates/core/src/eth_bridge_pool.rs | 22 +-- crates/core/src/ethereum_events.rs | 22 +-- crates/core/src/ethereum_structs.rs | 2 +- crates/core/src/event.rs | 4 +- crates/core/src/ibc.rs | 7 +- crates/core/src/keccak.rs | 4 +- crates/core/src/key/common.rs | 11 +- crates/core/src/key/ed25519.rs | 2 +- crates/core/src/key/mod.rs | 16 +-- crates/core/src/key/secp256k1.rs | 6 +- crates/core/src/lib.rs | 2 +- crates/core/src/masp.rs | 8 +- crates/core/src/storage.rs | 21 ++- crates/core/src/string_encoding.rs | 10 +- crates/core/src/token.rs | 14 +- crates/core/src/uint.rs | 4 +- crates/core/src/voting_power.rs | 4 +- crates/encoding_spec/src/main.rs | 8 +- crates/ethereum_bridge/src/lib.rs | 2 +- crates/ethereum_bridge/src/oracle/config.rs | 4 +- .../transactions/bridge_pool_roots.rs | 20 +-- .../transactions/ethereum_events/eth_msgs.rs | 8 +- .../transactions/ethereum_events/events.rs | 28 ++-- .../transactions/ethereum_events/mod.rs | 22 ++- .../src/protocol/transactions/mod.rs | 2 +- .../src/protocol/transactions/read.rs | 8 +- .../src/protocol/transactions/update.rs | 8 +- .../src/protocol/transactions/utils.rs | 12 +- .../transactions/validator_set_update/mod.rs | 12 +- .../src/protocol/transactions/votes.rs | 12 +- .../protocol/transactions/votes/storage.rs | 6 +- .../src/protocol/transactions/votes/update.rs | 12 +- .../protocol/validation/bridge_pool_roots.rs | 4 +- .../protocol/validation/ethereum_events.rs | 2 +- .../validation/validator_set_update.rs | 2 +- .../src/storage/bridge_pool.rs | 6 +- .../src/storage/eth_bridge_queries.rs | 19 ++- crates/ethereum_bridge/src/storage/mod.rs | 10 +- .../ethereum_bridge/src/storage/parameters.rs | 10 +- crates/ethereum_bridge/src/storage/proof.rs | 16 +-- .../src/storage/vote_tallies.rs | 10 +- .../src/storage/vp/bridge_pool.rs | 2 +- .../src/storage/vp/ethereum_bridge.rs | 2 +- .../ethereum_bridge/src/storage/whitelist.rs | 12 +- .../src/storage/wrapped_erc20s.rs | 14 +- crates/ethereum_bridge/src/test_utils.rs | 14 +- crates/governance/src/cli/offline.rs | 12 +- crates/governance/src/cli/onchain.rs | 6 +- crates/governance/src/cli/validation.rs | 6 +- crates/governance/src/lib.rs | 2 +- crates/governance/src/parameters.rs | 2 +- crates/governance/src/pgf/cli/steward.rs | 4 +- crates/governance/src/pgf/inflation.rs | 4 +- crates/governance/src/pgf/mod.rs | 2 +- crates/governance/src/pgf/parameters.rs | 4 +- crates/governance/src/pgf/storage/keys.rs | 4 +- crates/governance/src/pgf/storage/mod.rs | 4 +- crates/governance/src/pgf/storage/steward.rs | 4 +- crates/governance/src/storage/keys.rs | 4 +- crates/governance/src/storage/mod.rs | 4 +- crates/governance/src/storage/proposal.rs | 14 +- crates/governance/src/utils.rs | 10 +- crates/ibc/src/actions.rs | 12 +- crates/ibc/src/context/common.rs | 4 +- crates/ibc/src/context/storage.rs | 6 +- crates/ibc/src/context/token_transfer.rs | 6 +- crates/ibc/src/lib.rs | 8 +- crates/ibc/src/storage.rs | 10 +- .../src/reading/asynchronous/account.rs | 2 +- .../light_sdk/src/reading/asynchronous/mod.rs | 6 +- .../light_sdk/src/reading/asynchronous/pos.rs | 6 +- .../light_sdk/src/reading/blocking/account.rs | 2 +- crates/light_sdk/src/reading/blocking/mod.rs | 6 +- crates/light_sdk/src/reading/blocking/pos.rs | 6 +- crates/light_sdk/src/transaction/account.rs | 10 +- crates/light_sdk/src/transaction/bridge.rs | 17 +-- .../light_sdk/src/transaction/governance.rs | 10 +- crates/light_sdk/src/transaction/ibc.rs | 12 +- crates/light_sdk/src/transaction/mod.rs | 14 +- crates/light_sdk/src/transaction/pgf.rs | 12 +- crates/light_sdk/src/transaction/pos.rs | 14 +- crates/light_sdk/src/transaction/transfer.rs | 12 +- crates/light_sdk/src/transaction/wrapper.rs | 6 +- crates/macros/src/lib.rs | 98 ++++++------- crates/merkle_tree/src/eth_bridge_pool.rs | 20 +-- crates/merkle_tree/src/ics23_specs.rs | 2 +- crates/merkle_tree/src/lib.rs | 28 ++-- crates/namada/src/ledger/governance/mod.rs | 4 +- crates/namada/src/ledger/mod.rs | 13 +- .../ethereum_bridge/bridge_pool_vp.rs | 24 ++-- .../ledger/native_vp/ethereum_bridge/nut.rs | 10 +- .../ledger/native_vp/ethereum_bridge/vp.rs | 16 +-- .../src/ledger/native_vp/ibc/context.rs | 13 +- crates/namada/src/ledger/native_vp/ibc/mod.rs | 34 ++--- crates/namada/src/ledger/native_vp/masp.rs | 17 ++- crates/namada/src/ledger/native_vp/mod.rs | 16 +-- .../namada/src/ledger/native_vp/multitoken.rs | 14 +- .../namada/src/ledger/native_vp/parameters.rs | 4 +- crates/namada/src/ledger/pgf/mod.rs | 4 +- crates/namada/src/ledger/pgf/utils.rs | 2 +- crates/namada/src/ledger/pos/mod.rs | 8 +- crates/namada/src/ledger/pos/vp.rs | 4 +- crates/namada/src/ledger/protocol/mod.rs | 26 ++-- crates/namada/src/ledger/vp_host_fns.rs | 12 +- crates/namada/src/lib.rs | 11 +- crates/namada/src/types/ibc/mod.rs | 3 - crates/namada/src/types/key/mod.rs | 3 - crates/namada/src/types/mod.rs | 12 -- crates/namada/src/vm/host_env.rs | 28 ++-- crates/namada/src/vm/types.rs | 4 +- .../src/vm/wasm/compilation_cache/common.rs | 4 +- crates/namada/src/vm/wasm/host_env.rs | 2 +- crates/namada/src/vm/wasm/run.rs | 12 +- crates/parameters/src/lib.rs | 18 +-- crates/parameters/src/storage.rs | 4 +- crates/parameters/src/wasm_allowlist.rs | 4 +- crates/proof_of_stake/src/epoched.rs | 8 +- crates/proof_of_stake/src/error.rs | 6 +- crates/proof_of_stake/src/lib.rs | 16 +-- crates/proof_of_stake/src/parameters.rs | 10 +- crates/proof_of_stake/src/pos_queries.rs | 8 +- crates/proof_of_stake/src/queries.rs | 8 +- crates/proof_of_stake/src/rewards.rs | 10 +- crates/proof_of_stake/src/slashing.rs | 8 +- crates/proof_of_stake/src/storage.rs | 34 ++--- crates/proof_of_stake/src/storage_key.rs | 4 +- crates/proof_of_stake/src/tests/helpers.rs | 14 +- .../proof_of_stake/src/tests/state_machine.rs | 12 +- .../src/tests/state_machine_v2.rs | 12 +- .../src/tests/test_helper_fns.rs | 10 +- crates/proof_of_stake/src/tests/test_pos.rs | 14 +- .../src/tests/test_slash_and_redel.rs | 8 +- .../src/tests/test_validator.rs | 14 +- crates/proof_of_stake/src/types/mod.rs | 16 +-- crates/proof_of_stake/src/types/rev_order.rs | 8 +- .../src/validator_set_update.rs | 8 +- crates/replay_protection/src/lib.rs | 4 +- crates/sdk/Cargo.toml | 2 + crates/sdk/src/args.rs | 32 ++--- crates/sdk/src/error.rs | 10 +- crates/sdk/src/eth_bridge/bridge_pool.rs | 36 +++-- crates/sdk/src/eth_bridge/mod.rs | 2 +- crates/sdk/src/eth_bridge/validator_set.rs | 8 +- crates/sdk/src/events/log.rs | 2 +- crates/sdk/src/events/log/dumb_queries.rs | 4 +- crates/sdk/src/lib.rs | 37 +++-- crates/sdk/src/masp.rs | 34 ++--- crates/sdk/src/queries/mod.rs | 9 +- crates/sdk/src/queries/router.rs | 18 +-- crates/sdk/src/queries/shell.rs | 14 +- crates/sdk/src/queries/shell/eth_bridge.rs | 41 +++--- crates/sdk/src/queries/types.rs | 2 +- crates/sdk/src/queries/vp/pgf.rs | 2 +- crates/sdk/src/queries/vp/pos.rs | 8 +- crates/sdk/src/queries/vp/token.rs | 8 +- crates/sdk/src/rpc.rs | 12 +- crates/sdk/src/signing.rs | 26 ++-- crates/sdk/src/tx.rs | 18 +-- crates/sdk/src/wallet/alias.rs | 2 +- crates/sdk/src/wallet/derivation_path.rs | 4 +- crates/sdk/src/wallet/mod.rs | 6 +- crates/sdk/src/wallet/pre_genesis.rs | 2 +- crates/sdk/src/wallet/store.rs | 6 +- crates/shielded_token/src/conversion.rs | 20 +-- crates/shielded_token/src/lib.rs | 2 +- crates/shielded_token/src/storage.rs | 8 +- crates/shielded_token/src/storage_key.rs | 6 +- crates/shielded_token/src/utils.rs | 2 +- crates/state/src/lib.rs | 34 +++-- crates/state/src/wl_storage.rs | 12 +- crates/state/src/write_log.rs | 20 ++- crates/storage/src/collections/lazy_map.rs | 4 +- crates/storage/src/collections/lazy_set.rs | 4 +- crates/storage/src/collections/lazy_vec.rs | 4 +- crates/storage/src/collections/mod.rs | 2 +- crates/storage/src/conversion_state.rs | 6 +- crates/storage/src/db.rs | 14 +- crates/storage/src/lib.rs | 92 +++++------- crates/storage/src/mockdb.rs | 116 ++++++--------- crates/storage/src/tx_queue.rs | 2 +- crates/test_utils/src/tx_data.rs | 6 +- crates/tests/src/e2e/eth_bridge_tests.rs | 18 +-- .../tests/src/e2e/eth_bridge_tests/helpers.rs | 8 +- crates/tests/src/e2e/helpers.rs | 8 +- crates/tests/src/e2e/ibc_tests.rs | 10 +- crates/tests/src/e2e/ledger_tests.rs | 10 +- .../tests/src/e2e/multitoken_tests/helpers.rs | 6 +- crates/tests/src/e2e/setup.rs | 10 +- crates/tests/src/integration/masp.rs | 2 +- crates/tests/src/integration/setup.rs | 4 +- crates/tests/src/native_vp/eth_bridge_pool.rs | 18 +-- crates/tests/src/native_vp/mod.rs | 4 +- crates/tests/src/native_vp/pos.rs | 18 +-- crates/tests/src/storage.rs | 2 +- .../src/storage_api/collections/lazy_map.rs | 4 +- .../src/storage_api/collections/lazy_set.rs | 4 +- .../src/storage_api/collections/lazy_vec.rs | 4 +- .../collections/nested_lazy_map.rs | 4 +- crates/tests/src/vm_host_env/ibc.rs | 14 +- crates/tests/src/vm_host_env/mod.rs | 10 +- crates/tests/src/vm_host_env/tx.rs | 12 +- crates/tests/src/vm_host_env/vp.rs | 6 +- crates/token/src/lib.rs | 2 +- crates/trans_token/src/inflation.rs | 4 +- crates/trans_token/src/lib.rs | 2 +- crates/trans_token/src/storage.rs | 6 +- crates/trans_token/src/storage_key.rs | 6 +- crates/tx/src/data/eval_vp.rs | 2 +- crates/tx/src/data/mod.rs | 22 +-- crates/tx/src/data/pgf.rs | 8 +- crates/tx/src/data/pos.rs | 16 +-- crates/tx/src/data/protocol.rs | 2 +- crates/tx/src/data/wrapper.rs | 12 +- crates/tx/src/lib.rs | 4 +- crates/tx/src/types.rs | 92 ++++++------ crates/tx_env/src/lib.rs | 6 +- crates/tx_prelude/src/ibc.rs | 6 +- crates/tx_prelude/src/key.rs | 2 +- crates/tx_prelude/src/lib.rs | 33 ++--- crates/tx_prelude/src/proof_of_stake.rs | 6 +- crates/tx_prelude/src/token.rs | 2 +- crates/vm_env/src/lib.rs | 2 +- crates/vote_ext/src/bridge_pool_roots.rs | 8 +- crates/vote_ext/src/ethereum_events.rs | 16 +-- crates/vote_ext/src/lib.rs | 4 +- crates/vote_ext/src/validator_set_update.rs | 28 ++-- .../src/collection_validation/lazy_map.rs | 2 +- .../src/collection_validation/lazy_set.rs | 2 +- .../src/collection_validation/lazy_vec.rs | 2 +- .../vp_env/src/collection_validation/mod.rs | 2 +- crates/vp_env/src/lib.rs | 10 +- crates/vp_prelude/src/lib.rs | 16 +-- wasm/Cargo.lock | 2 - wasm/wasm_source/src/tx_bond.rs | 4 +- .../src/tx_change_validator_commission.rs | 4 +- wasm/wasm_source/src/tx_redelegate.rs | 4 +- wasm/wasm_source/src/tx_unbond.rs | 4 +- wasm/wasm_source/src/tx_withdraw.rs | 4 +- wasm/wasm_source/src/vp_implicit.rs | 4 +- wasm/wasm_source/src/vp_user.rs | 4 +- wasm_for_tests/wasm_source/Cargo.lock | 2 - 305 files changed, 1694 insertions(+), 1865 deletions(-) delete mode 100644 crates/namada/src/types/ibc/mod.rs delete mode 100644 crates/namada/src/types/key/mod.rs delete mode 100644 crates/namada/src/types/mod.rs diff --git a/Cargo.lock b/Cargo.lock index f4d3fc3034..830e13fdc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4342,7 +4342,6 @@ dependencies = [ "k256", "masp_primitives", "namada_macros", - "num-derive", "num-integer", "num-rational 0.4.1", "num-traits 0.2.17", @@ -4351,7 +4350,6 @@ dependencies = [ "pretty_assertions", "primitive-types", "proptest", - "prost 0.12.3", "prost-types 0.12.3", "rand 0.8.5", "rand_core 0.6.4", diff --git a/crates/account/src/lib.rs b/crates/account/src/lib.rs index e7f79a3e55..890cf942a0 100644 --- a/crates/account/src/lib.rs +++ b/crates/account/src/lib.rs @@ -7,9 +7,9 @@ mod storage_key; mod types; use borsh::{BorshDeserialize, BorshSerialize}; -pub use namada_core::types::account::AccountPublicKeysMap; -use namada_core::types::address::Address; -use namada_core::types::key::common; +pub use namada_core::account::AccountPublicKeysMap; +use namada_core::address::Address; +use namada_core::key::common; use serde::{Deserialize, Serialize}; pub use storage::*; pub use storage_key::*; diff --git a/crates/account/src/storage.rs b/crates/account/src/storage.rs index 50b56e7808..357922b6ea 100644 --- a/crates/account/src/storage.rs +++ b/crates/account/src/storage.rs @@ -1,8 +1,8 @@ //! Cryptographic signature keys storage API -use namada_core::types::address::Address; -use namada_core::types::key::common; -use namada_core::types::storage; +use namada_core::address::Address; +use namada_core::key::common; +use namada_core::storage; use namada_storage::{Result, StorageRead, StorageWrite}; use super::*; diff --git a/crates/account/src/storage_key.rs b/crates/account/src/storage_key.rs index 20e02906b8..baec1fba86 100644 --- a/crates/account/src/storage_key.rs +++ b/crates/account/src/storage_key.rs @@ -1,6 +1,6 @@ -use namada_core::types::address::Address; -use namada_core::types::key::common; -use namada_core::types::storage::{self, DbKeySeg}; +use namada_core::address::Address; +use namada_core::key::common; +use namada_core::storage::{self, DbKeySeg}; use namada_macros::StorageKeys; use namada_storage::collections::lazy_map::LazyMap; use namada_storage::collections::{lazy_map, LazyCollection}; diff --git a/crates/account/src/types.rs b/crates/account/src/types.rs index 606cf4c63c..332c3e8764 100644 --- a/crates/account/src/types.rs +++ b/crates/account/src/types.rs @@ -1,7 +1,7 @@ +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::hash::Hash; -use namada_core::types::key::common; +use namada_core::hash::Hash; +use namada_core::key::common; use serde::{Deserialize, Serialize}; /// A tx data type to initialize a new established account @@ -53,9 +53,9 @@ pub struct UpdateAccount { #[cfg(any(test, feature = "testing"))] /// Tests and strategies for accounts pub mod tests { - use namada_core::types::address::testing::arb_non_internal_address; - use namada_core::types::hash::testing::arb_hash; - use namada_core::types::key::testing::arb_common_pk; + use namada_core::address::testing::arb_non_internal_address; + use namada_core::hash::testing::arb_hash; + use namada_core::key::testing::arb_common_pk; use proptest::prelude::Just; use proptest::{collection, option, prop_compose}; diff --git a/crates/apps/src/bin/namada-node/cli.rs b/crates/apps/src/bin/namada-node/cli.rs index 7477d3d6af..a0d00d48dc 100644 --- a/crates/apps/src/bin/namada-node/cli.rs +++ b/crates/apps/src/bin/namada-node/cli.rs @@ -1,7 +1,7 @@ //! Namada node CLI. use eyre::{Context, Result}; -use namada::types::time::{DateTimeUtc, Utc}; +use namada::core::time::{DateTimeUtc, Utc}; use namada_apps::cli::{self, cmds}; use namada_apps::config::ValidatorLocalConfig; use namada_apps::node::ledger; diff --git a/crates/apps/src/lib/bench_utils.rs b/crates/apps/src/lib/bench_utils.rs index 40e3c6d393..1db7a07411 100644 --- a/crates/apps/src/lib/bench_utils.rs +++ b/crates/apps/src/lib/bench_utils.rs @@ -14,6 +14,16 @@ use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::Transaction; use masp_primitives::zip32::ExtendedFullViewingKey; use masp_proofs::prover::LocalTxProver; +use namada::core::address::{self, Address, InternalAddress}; +use namada::core::chain::ChainId; +use namada::core::hash::Hash; +use namada::core::key::common::SecretKey; +use namada::core::masp::{ + ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget, +}; +use namada::core::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex}; +use namada::core::time::DateTimeUtc; +use namada::core::token::{Amount, DenominatedAmount, Transfer}; use namada::governance::storage::proposal::ProposalType; use namada::governance::InitProposalData; use namada::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; @@ -50,6 +60,7 @@ use namada::ibc::core::host::types::path::{ use namada::ibc::primitives::proto::{Any, Protobuf}; use namada::ibc::primitives::{Msg, Timestamp as IbcTimestamp}; use namada::ibc::storage::port_key; +use namada::io::StdIo; use namada::ledger::dry_run_tx; use namada::ledger::gas::TxGasMeter; use namada::ledger::ibc::storage::{channel_key, connection_key}; @@ -62,17 +73,6 @@ use namada::tendermint_rpc::{self}; use namada::tx::data::pos::Bond; use namada::tx::data::{TxResult, VpsResult}; use namada::tx::{Code, Data, Section, Signature, Tx}; -use namada::types::address::{self, Address, InternalAddress}; -use namada::types::chain::ChainId; -use namada::types::hash::Hash; -use namada::types::io::StdIo; -use namada::types::key::common::SecretKey; -use namada::types::masp::{ - ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget, -}; -use namada::types::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex}; -use namada::types::time::DateTimeUtc; -use namada::types::token::{Amount, DenominatedAmount, Transfer}; use namada::vm::wasm::run; use namada::{proof_of_stake, tendermint}; use namada_sdk::masp::{ @@ -1021,7 +1021,7 @@ impl BenchShieldedCtx { let mut hasher = Sha256::new(); let shielded_section_hash = shielded.clone().map(|transaction| { - namada::types::hash::Hash( + namada::core::hash::Hash( Section::MaspTx(transaction) .hash(&mut hasher) .finalize_reset() diff --git a/crates/apps/src/lib/cli.rs b/crates/apps/src/lib/cli.rs index 8cb65ebcd5..70e29a49c4 100644 --- a/crates/apps/src/lib/cli.rs +++ b/crates/apps/src/lib/cli.rs @@ -15,7 +15,7 @@ pub mod wallet; use clap::{ArgGroup, ArgMatches, ColorChoice}; use color_eyre::eyre::Result; -use namada::types::io::StdIo; +use namada::io::StdIo; use utils::*; pub use utils::{safe_exit, Cmd}; @@ -2826,19 +2826,19 @@ pub mod args { use std::path::PathBuf; use std::str::FromStr; + use namada::core::address::{Address, EstablishedAddress}; + use namada::core::chain::{ChainId, ChainIdPrefix}; + use namada::core::dec::Dec; + use namada::core::ethereum_events::EthAddress; + use namada::core::keccak::KeccakHash; + use namada::core::key::*; + use namada::core::masp::PaymentAddress; + use namada::core::storage::{self, BlockHeight, Epoch}; + use namada::core::time::DateTimeUtc; + use namada::core::token; + use namada::core::token::NATIVE_MAX_DECIMAL_PLACES; use namada::ibc::core::host::types::identifiers::{ChannelId, PortId}; use namada::tx::data::GasLimit; - use namada::types::address::{Address, EstablishedAddress}; - use namada::types::chain::{ChainId, ChainIdPrefix}; - use namada::types::dec::Dec; - use namada::types::ethereum_events::EthAddress; - use namada::types::keccak::KeccakHash; - use namada::types::key::*; - use namada::types::masp::PaymentAddress; - use namada::types::storage::{self, BlockHeight, Epoch}; - use namada::types::time::DateTimeUtc; - use namada::types::token; - use namada::types::token::NATIVE_MAX_DECIMAL_PLACES; pub use namada_sdk::args::*; pub use namada_sdk::tx::{ TX_BECOME_VALIDATOR_WASM, TX_BOND_WASM, TX_BRIDGE_POOL_WASM, diff --git a/crates/apps/src/lib/cli/api.rs b/crates/apps/src/lib/cli/api.rs index 3a5db7d33e..0d83273598 100644 --- a/crates/apps/src/lib/cli/api.rs +++ b/crates/apps/src/lib/cli/api.rs @@ -1,5 +1,5 @@ +use namada::io::Io; use namada::tendermint_rpc::HttpClient; -use namada::types::io::Io; use namada_sdk::error::Error; use namada_sdk::queries::Client; use namada_sdk::rpc::wait_until_node_is_synched; diff --git a/crates/apps/src/lib/cli/client.rs b/crates/apps/src/lib/cli/client.rs index b7f41dc6a2..866913a323 100644 --- a/crates/apps/src/lib/cli/client.rs +++ b/crates/apps/src/lib/cli/client.rs @@ -1,5 +1,5 @@ use color_eyre::eyre::Result; -use namada::types::io::Io; +use namada::io::Io; use namada_sdk::{Namada, NamadaImpl}; use crate::cli; diff --git a/crates/apps/src/lib/cli/context.rs b/crates/apps/src/lib/cli/context.rs index b9653e9fb2..aafe04d069 100644 --- a/crates/apps/src/lib/cli/context.rs +++ b/crates/apps/src/lib/cli/context.rs @@ -6,14 +6,14 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use color_eyre::eyre::Result; +use namada::core::address::{Address, InternalAddress}; +use namada::core::chain::ChainId; +use namada::core::ethereum_events::EthAddress; +use namada::core::ibc::is_ibc_denom; +use namada::core::key::*; +use namada::core::masp::*; +use namada::io::Io; use namada::ledger::ibc::storage::ibc_token; -use namada::types::address::{Address, InternalAddress}; -use namada::types::chain::ChainId; -use namada::types::ethereum_events::EthAddress; -use namada::types::ibc::is_ibc_denom; -use namada::types::io::Io; -use namada::types::key::*; -use namada::types::masp::*; use namada_sdk::masp::fs::FsShieldedUtils; use namada_sdk::masp::ShieldedContext; use namada_sdk::wallet::Wallet; diff --git a/crates/apps/src/lib/cli/relayer.rs b/crates/apps/src/lib/cli/relayer.rs index e46f568023..37f0cada62 100644 --- a/crates/apps/src/lib/cli/relayer.rs +++ b/crates/apps/src/lib/cli/relayer.rs @@ -1,5 +1,5 @@ use color_eyre::eyre::Result; -use namada::types::io::Io; +use namada::io::Io; use namada_sdk::eth_bridge::{bridge_pool, validator_set}; use crate::cli; diff --git a/crates/apps/src/lib/cli/wallet.rs b/crates/apps/src/lib/cli/wallet.rs index 3ce69521e4..d133e725a9 100644 --- a/crates/apps/src/lib/cli/wallet.rs +++ b/crates/apps/src/lib/cli/wallet.rs @@ -12,10 +12,10 @@ use ledger_namada_rs::{BIP44Path, NamadaApp}; use ledger_transport_hid::hidapi::HidApi; use ledger_transport_hid::TransportNativeHID; use masp_primitives::zip32::ExtendedFullViewingKey; -use namada::types::address::{Address, DecodeError}; -use namada::types::io::Io; -use namada::types::key::*; -use namada::types::masp::{ExtendedSpendingKey, MaspValue, PaymentAddress}; +use namada::core::address::{Address, DecodeError}; +use namada::core::key::*; +use namada::core::masp::{ExtendedSpendingKey, MaspValue, PaymentAddress}; +use namada::io::Io; use namada_sdk::masp::find_valid_diversifier; use namada_sdk::wallet::{ DecryptionError, DerivationPath, DerivationPathError, FindKeyError, Wallet, diff --git a/crates/apps/src/lib/client/rpc.rs b/crates/apps/src/lib/client/rpc.rs index cedc239b3f..67143de68e 100644 --- a/crates/apps/src/lib/client/rpc.rs +++ b/crates/apps/src/lib/client/rpc.rs @@ -15,6 +15,15 @@ use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::{Node, ViewingKey}; use masp_primitives::transaction::components::I128Sum; use masp_primitives::zip32::ExtendedFullViewingKey; +use namada::core::address::{Address, InternalAddress, MASP}; +use namada::core::hash::Hash; +use namada::core::ibc::{is_ibc_denom, IbcTokenHash}; +use namada::core::key::*; +use namada::core::masp::{BalanceOwner, ExtendedViewingKey, PaymentAddress}; +use namada::core::storage::{ + BlockHeight, BlockResults, Epoch, IndexedTx, Key, KeySeg, +}; +use namada::core::token::{Change, MaspDigitPos}; use namada::governance::cli::offline::{ find_offline_proposal, find_offline_votes, read_offline_files, OfflineSignedProposal, OfflineVote, @@ -29,6 +38,7 @@ use namada::governance::storage::proposal::{ use namada::governance::utils::{ compute_proposal_result, ProposalVotes, TallyType, TallyVote, VotePower, }; +use namada::io::Io; use namada::ledger::events::Event; use namada::ledger::ibc::storage::{ ibc_denom_key, ibc_denom_key_prefix, is_ibc_denom_key, @@ -38,16 +48,6 @@ use namada::ledger::pos::types::{CommissionPair, Slash}; use namada::ledger::pos::PosParams; use namada::ledger::queries::RPC; use namada::proof_of_stake::types::{ValidatorState, WeightedValidator}; -use namada::types::address::{Address, InternalAddress, MASP}; -use namada::types::hash::Hash; -use namada::types::ibc::{is_ibc_denom, IbcTokenHash}; -use namada::types::io::Io; -use namada::types::key::*; -use namada::types::masp::{BalanceOwner, ExtendedViewingKey, PaymentAddress}; -use namada::types::storage::{ - BlockHeight, BlockResults, Epoch, IndexedTx, Key, KeySeg, -}; -use namada::types::token::{Change, MaspDigitPos}; use namada::{state as storage, token}; use namada_sdk::error::{ is_pinned_error, Error, PinnedBalanceError, QueryError, @@ -329,7 +329,7 @@ pub async fn query_transparent_balance( args: args::QueryBalance, ) { let prefix = Key::from( - Address::Internal(namada::types::address::InternalAddress::Multitoken) + Address::Internal(namada::core::address::InternalAddress::Multitoken) .to_db_key(), ); match (args.token, args.owner) { diff --git a/crates/apps/src/lib/client/tx.rs b/crates/apps/src/lib/client/tx.rs index 911e1b475a..1e0e864a52 100644 --- a/crates/apps/src/lib/client/tx.rs +++ b/crates/apps/src/lib/client/tx.rs @@ -7,6 +7,9 @@ use borsh_ext::BorshSerializeExt; use ledger_namada_rs::{BIP44Path, NamadaApp}; use ledger_transport_hid::hidapi::HidApi; use ledger_transport_hid::TransportNativeHID; +use namada::core::address::{Address, ImplicitAddress}; +use namada::core::dec::Dec; +use namada::core::key::{self, *}; use namada::governance::cli::offline::{ OfflineProposal, OfflineSignedProposal, OfflineVote, }; @@ -15,13 +18,10 @@ use namada::governance::cli::onchain::{ }; use namada::governance::ProposalVote; use namada::ibc::apps::transfer::types::Memo; +use namada::io::Io; use namada::state::EPOCH_SWITCH_BLOCKS_DELAY; use namada::tx::data::pos::{BecomeValidator, ConsensusKeyChange}; use namada::tx::{CompressedSignature, Section, Signer, Tx}; -use namada::types::address::{Address, ImplicitAddress}; -use namada::types::dec::Dec; -use namada::types::io::Io; -use namada::types::key::{self, *}; use namada_sdk::rpc::{InnerTxResult, TxBroadcastData, TxResponse}; use namada_sdk::wallet::alias::validator_consensus_key; use namada_sdk::wallet::{Wallet, WalletIo}; diff --git a/crates/apps/src/lib/client/utils.rs b/crates/apps/src/lib/client/utils.rs index a2d5115654..07643104f1 100644 --- a/crates/apps/src/lib/client/utils.rs +++ b/crates/apps/src/lib/client/utils.rs @@ -10,12 +10,12 @@ use flate2::read::GzDecoder; use flate2::write::GzEncoder; use flate2::Compression; use itertools::Either; -use namada::types::chain::ChainId; -use namada::types::dec::Dec; -use namada::types::key::*; -use namada::types::string_encoding::StringEncoded; -use namada::types::token; -use namada::types::uint::Uint; +use namada::core::chain::ChainId; +use namada::core::dec::Dec; +use namada::core::key::*; +use namada::core::string_encoding::StringEncoded; +use namada::core::token; +use namada::core::uint::Uint; use namada::vm::validate_untrusted_wasm; use namada_sdk::wallet::{alias, Wallet}; use prost::bytes::Bytes; diff --git a/crates/apps/src/lib/config/ethereum_bridge/ledger.rs b/crates/apps/src/lib/config/ethereum_bridge/ledger.rs index 55694439b5..c1117c44b5 100644 --- a/crates/apps/src/lib/config/ethereum_bridge/ledger.rs +++ b/crates/apps/src/lib/config/ethereum_bridge/ledger.rs @@ -1,6 +1,6 @@ //! Runtime configuration for a validator node. #[allow(unused_imports)] -use namada::types::ethereum_events::EthereumEvent; +use namada::core::ethereum_events::EthereumEvent; use serde::{Deserialize, Serialize}; /// Default [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) endpoint used by the oracle diff --git a/crates/apps/src/lib/config/genesis.rs b/crates/apps/src/lib/config/genesis.rs index 2a4377a877..074d17966a 100644 --- a/crates/apps/src/lib/config/genesis.rs +++ b/crates/apps/src/lib/config/genesis.rs @@ -11,19 +11,19 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; use derivative::Derivative; +use namada::core::address::{Address, EstablishedAddress}; +use namada::core::chain::ProposalBytes; +use namada::core::key::*; +use namada::core::storage; +use namada::core::string_encoding::StringEncoded; +use namada::core::time::{DateTimeUtc, DurationSecs}; +use namada::core::token::Denomination; use namada::governance::parameters::GovernanceParameters; use namada::governance::pgf::parameters::PgfParameters; use namada::ledger::eth_bridge::EthereumBridgeParams; use namada::ledger::parameters::EpochDuration; use namada::ledger::pos::{Dec, GenesisValidator, OwnedPosParams}; use namada::token; -use namada::types::address::{Address, EstablishedAddress}; -use namada::types::chain::ProposalBytes; -use namada::types::key::*; -use namada::types::storage; -use namada::types::string_encoding::StringEncoded; -use namada::types::time::{DateTimeUtc, DurationSecs}; -use namada::types::token::Denomination; use serde::{Deserialize, Serialize}; #[cfg(all(any(test, feature = "benches"), not(feature = "integration")))] @@ -313,13 +313,13 @@ pub fn make_dev_genesis( use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::time::Duration; + use namada::core::address::wnam; + use namada::core::chain::ChainIdPrefix; + use namada::core::ethereum_events::EthAddress; + use namada::core::key::*; use namada::ledger::eth_bridge::{Contracts, UpgradeableContract}; use namada::ledger::pos::types::ValidatorMetaData; use namada::tx::standalone_signature; - use namada::types::address::wnam; - use namada::types::chain::ChainIdPrefix; - use namada::types::ethereum_events::EthAddress; - use namada::types::key::*; use namada_sdk::wallet::alias::Alias; use crate::config::genesis::chain::{finalize, DeriveEstablishedAddress}; @@ -554,8 +554,8 @@ pub fn make_dev_genesis( #[cfg(test)] pub mod tests { use borsh_ext::BorshSerializeExt; - use namada::types::address::testing::gen_established_address; - use namada::types::key::*; + use namada::core::address::testing::gen_established_address; + use namada::core::key::*; use rand::prelude::ThreadRng; use rand::thread_rng; diff --git a/crates/apps/src/lib/config/genesis/chain.rs b/crates/apps/src/lib/config/genesis/chain.rs index 563802e68b..3203e3fa90 100644 --- a/crates/apps/src/lib/config/genesis/chain.rs +++ b/crates/apps/src/lib/config/genesis/chain.rs @@ -4,16 +4,16 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; use borsh_ext::BorshSerializeExt; -use namada::ledger::parameters::EpochDuration; -use namada::types::address::{ +use namada::core::address::{ Address, EstablishedAddress, EstablishedAddressGen, }; -use namada::types::chain::{ChainId, ChainIdPrefix}; -use namada::types::dec::Dec; -use namada::types::hash::Hash; -use namada::types::key::{common, RefTo}; -use namada::types::time::{DateTimeUtc, DurationNanos, Rfc3339String}; -use namada::types::token::Amount; +use namada::core::chain::{ChainId, ChainIdPrefix}; +use namada::core::dec::Dec; +use namada::core::hash::Hash; +use namada::core::key::{common, RefTo}; +use namada::core::time::{DateTimeUtc, DurationNanos, Rfc3339String}; +use namada::core::token::Amount; +use namada::ledger::parameters::EpochDuration; use namada_sdk::wallet::store::AddressVpType; use namada_sdk::wallet::{pre_genesis, Wallet}; use serde::{Deserialize, Serialize}; @@ -291,11 +291,11 @@ impl Finalized { let min_duration: i64 = 60 * 60 * 24 * 365 / (epochs_per_year as i64); let epoch_duration = EpochDuration { min_num_of_blocks, - min_duration: namada::types::time::Duration::seconds(min_duration) + min_duration: namada::core::time::Duration::seconds(min_duration) .into(), }; let max_expected_time_per_block = - namada::types::time::Duration::seconds(max_expected_time_per_block) + namada::core::time::Duration::seconds(max_expected_time_per_block) .into(); let vp_allowlist = vp_allowlist.unwrap_or_default(); let tx_allowlist = tx_allowlist.unwrap_or_default(); diff --git a/crates/apps/src/lib/config/genesis/templates.rs b/crates/apps/src/lib/config/genesis/templates.rs index 7ac2d588ff..696880552a 100644 --- a/crates/apps/src/lib/config/genesis/templates.rs +++ b/crates/apps/src/lib/config/genesis/templates.rs @@ -5,17 +5,17 @@ use std::marker::PhantomData; use std::path::Path; use borsh::{BorshDeserialize, BorshSerialize}; +use namada::core::address::Address; +use namada::core::chain::ProposalBytes; +use namada::core::dec::Dec; +use namada::core::ethereum_structs; +use namada::core::token::{ + Amount, DenominatedAmount, Denomination, NATIVE_MAX_DECIMAL_PLACES, +}; use namada::eth_bridge::storage::parameters::{ Contracts, Erc20WhitelistEntry, MinimumConfirmations, }; use namada::token; -use namada::types::address::Address; -use namada::types::chain::ProposalBytes; -use namada::types::dec::Dec; -use namada::types::ethereum_structs; -use namada::types::token::{ - Amount, DenominatedAmount, Denomination, NATIVE_MAX_DECIMAL_PLACES, -}; use serde::{Deserialize, Serialize}; use super::transactions::{self, Transactions}; @@ -948,9 +948,9 @@ mod tests { use std::fs; use std::path::PathBuf; - use namada::types::key; - use namada::types::key::RefTo; - use namada::types::string_encoding::StringEncoded; + use namada::core::key; + use namada::core::key::RefTo; + use namada::core::string_encoding::StringEncoded; use tempfile::tempdir; use super::*; diff --git a/crates/apps/src/lib/config/genesis/transactions.rs b/crates/apps/src/lib/config/genesis/transactions.rs index 68a3040eb8..8d3e6facfc 100644 --- a/crates/apps/src/lib/config/genesis/transactions.rs +++ b/crates/apps/src/lib/config/genesis/transactions.rs @@ -11,22 +11,22 @@ use ledger_namada_rs::NamadaApp; use ledger_transport_hid::hidapi::HidApi; use ledger_transport_hid::TransportNativeHID; use namada::account::AccountPublicKeysMap; +use namada::core::address::{nam, Address, EstablishedAddress}; +use namada::core::chain::ChainId; +use namada::core::dec::Dec; +use namada::core::key::{ + common, ed25519, RefTo, SerializeWithBorsh, SigScheme, +}; +use namada::core::string_encoding::StringEncoded; +use namada::core::time::DateTimeUtc; +use namada::core::token; +use namada::core::token::{DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; use namada::ledger::pos::common::PublicKey; use namada::ledger::pos::types::ValidatorMetaData; use namada::tx::data::{pos, Fee, TxType}; use namada::tx::{ verify_standalone_sig, Code, Commitment, Data, Section, SignatureIndex, Tx, }; -use namada::types::address::{nam, Address, EstablishedAddress}; -use namada::types::chain::ChainId; -use namada::types::dec::Dec; -use namada::types::key::{ - common, ed25519, RefTo, SerializeWithBorsh, SigScheme, -}; -use namada::types::string_encoding::StringEncoded; -use namada::types::time::DateTimeUtc; -use namada::types::token; -use namada::types::token::{DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; use namada_sdk::args::Tx as TxArgs; use namada_sdk::signing::{sign_tx, SigningTxData}; use namada_sdk::tx::{TX_BECOME_VALIDATOR_WASM, TX_BOND_WASM}; diff --git a/crates/apps/src/lib/config/genesis/utils.rs b/crates/apps/src/lib/config/genesis/utils.rs index a17f09843d..a67f259db0 100644 --- a/crates/apps/src/lib/config/genesis/utils.rs +++ b/crates/apps/src/lib/config/genesis/utils.rs @@ -4,8 +4,8 @@ use std::path::Path; use eyre::Context; use ledger_namada_rs::NamadaApp; use ledger_transport_hid::TransportNativeHID; +use namada::core::key::common; use namada::tx::Tx; -use namada::types::key::common; use namada_sdk::wallet::Wallet; use namada_sdk::{error, signing}; use serde::de::DeserializeOwned; diff --git a/crates/apps/src/lib/config/global.rs b/crates/apps/src/lib/config/global.rs index 1dc1380635..f6d917c770 100644 --- a/crates/apps/src/lib/config/global.rs +++ b/crates/apps/src/lib/config/global.rs @@ -4,7 +4,7 @@ use std::fs::{create_dir_all, File}; use std::io::Write; use std::path::{Path, PathBuf}; -use namada::types::chain::ChainId; +use namada::core::chain::ChainId; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/apps/src/lib/config/mod.rs b/crates/apps/src/lib/config/mod.rs index 6d18586408..782ffee77d 100644 --- a/crates/apps/src/lib/config/mod.rs +++ b/crates/apps/src/lib/config/mod.rs @@ -11,9 +11,9 @@ use std::io::Write; use std::path::{Path, PathBuf}; use directories::ProjectDirs; -use namada::types::chain::ChainId; -use namada::types::storage::BlockHeight; -use namada::types::time::Rfc3339String; +use namada::core::chain::ChainId; +use namada::core::storage::BlockHeight; +use namada::core::time::Rfc3339String; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -45,7 +45,7 @@ pub struct Config { #[derive(Debug, Serialize, Deserialize)] pub struct ValidatorLocalConfig { pub accepted_gas_tokens: - HashMap, + HashMap, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] diff --git a/crates/apps/src/lib/node/ledger/abortable.rs b/crates/apps/src/lib/node/ledger/abortable.rs index ceb4a4c892..5a5bf11e58 100644 --- a/crates/apps/src/lib/node/ledger/abortable.rs +++ b/crates/apps/src/lib/node/ledger/abortable.rs @@ -1,7 +1,7 @@ use std::future::Future; use std::pin::Pin; -use namada::types::control_flow::{install_shutdown_signal, ShutdownSignal}; +use namada::control_flow::{install_shutdown_signal, ShutdownSignal}; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use tokio::task::JoinHandle; diff --git a/crates/apps/src/lib/node/ledger/broadcaster.rs b/crates/apps/src/lib/node/ledger/broadcaster.rs index 62c4083a11..bd0b74ae36 100644 --- a/crates/apps/src/lib/node/ledger/broadcaster.rs +++ b/crates/apps/src/lib/node/ledger/broadcaster.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use std::ops::ControlFlow; -use namada::types::control_flow::time; +use namada::control_flow::time; use tokio::sync::mpsc::UnboundedReceiver; use crate::facade::tendermint_rpc::{Client, HttpClient}; diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs b/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs index a750ffbc15..d804e85d91 100644 --- a/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs +++ b/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs @@ -7,14 +7,14 @@ pub mod eth_events { ValidatorSetUpdateFilter, }; use ethbridge_events::{DynEventCodec, Events as RawEvents}; - use namada::types::address::Address; - use namada::types::ethereum_events::{ + use namada::core::address::Address; + use namada::core::ethereum_events::{ EthAddress, EthereumEvent, TransferToEthereum, TransferToNamada, Uint, }; - use namada::types::ethereum_structs; - use namada::types::hash::Hash; - use namada::types::keccak::KeccakHash; - use namada::types::token::Amount; + use namada::core::ethereum_structs; + use namada::core::hash::Hash; + use namada::core::keccak::KeccakHash; + use namada::core::token::Amount; use num256::Uint256; use thiserror::Error; @@ -176,7 +176,7 @@ pub mod eth_events { impl Parse for ethabi::Uint { fn parse_amount(self) -> Result { let uint = { - use namada::types::uint::Uint as NamadaUint; + use namada::core::uint::Uint as NamadaUint; let mut num_buf = [0; 32]; self.to_little_endian(&mut num_buf); NamadaUint::from_little_endian(&num_buf) diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs b/crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs index b0488226f3..777d133769 100644 --- a/crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs +++ b/crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs @@ -8,13 +8,12 @@ use async_trait::async_trait; use ethabi::Address; use ethbridge_events::{event_codecs, EventKind}; use itertools::Either; -use namada::core::hints; +use namada::control_flow::time::{Constant, Duration, Instant, Sleep}; +use namada::core::ethereum_events::EthereumEvent; +use namada::core::{ethereum_structs, hints}; use namada::eth_bridge::ethers; use namada::eth_bridge::ethers::providers::{Http, Middleware, Provider}; use namada::eth_bridge::oracle::config::Config; -use namada::types::control_flow::time::{Constant, Duration, Instant, Sleep}; -use namada::types::ethereum_events::EthereumEvent; -use namada::types::ethereum_structs; use namada_sdk::eth_bridge::{eth_syncing_status_timeout, SyncStatus}; use num256::Uint256; use thiserror::Error; @@ -602,7 +601,7 @@ fn process_queue( pub mod last_processed_block { //! Functionality to do with publishing which blocks we have processed. - use namada::types::ethereum_structs; + use namada::core::ethereum_structs; use tokio::sync::watch; pub type Sender = watch::Sender>; @@ -621,11 +620,11 @@ mod test_oracle { use std::num::NonZeroU64; use ethbridge_bridge_events::{TransferToChainFilter, TransferToErcFilter}; + use namada::core::address::testing::gen_established_address; + use namada::core::ethereum_events::{EthAddress, TransferToEthereum}; + use namada::core::hash::Hash; use namada::eth_bridge::ethers::types::H160; use namada::eth_bridge::structs::Erc20Transfer; - use namada::types::address::testing::gen_established_address; - use namada::types::ethereum_events::{EthAddress, TransferToEthereum}; - use namada::types::hash::Hash; use tokio::sync::oneshot::channel; use tokio::time::timeout; diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs b/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs index 650a0ad279..2826bc8dbd 100644 --- a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs +++ b/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use borsh::BorshDeserialize; -use namada::types::ethereum_events::EthereumEvent; +use namada::core::ethereum_events::EthereumEvent; use tokio::sync::mpsc::Sender as BoundedSender; use tokio::sync::oneshot::{Receiver, Sender}; use warp::reply::WithStatus; diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs b/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs index 460e651df5..4d853a9515 100644 --- a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs +++ b/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs @@ -67,8 +67,8 @@ pub mod mock_web3_client { use async_trait::async_trait; use ethabi::Address; use ethbridge_events::EventCodec; - use namada::types::control_flow::time::{Duration, Instant}; - use namada::types::ethereum_structs::BlockHeight; + use namada::control_flow::time::{Duration, Instant}; + use namada::core::ethereum_structs::BlockHeight; use num256::Uint256; use tokio::sync::mpsc::{ unbounded_channel, UnboundedReceiver, UnboundedSender, diff --git a/crates/apps/src/lib/node/ledger/mod.rs b/crates/apps/src/lib/node/ledger/mod.rs index 7ed221f260..5b897cb10c 100644 --- a/crates/apps/src/lib/node/ledger/mod.rs +++ b/crates/apps/src/lib/node/ledger/mod.rs @@ -14,10 +14,10 @@ use std::thread; use byte_unit::Byte; use futures::future::TryFutureExt; +use namada::core::storage::Key; +use namada::core::time::{DateTimeUtc, Utc}; use namada::eth_bridge::ethers::providers::{Http, Provider}; use namada::governance::storage::keys as governance_storage; -use namada::types::storage::Key; -use namada::types::time::{DateTimeUtc, Utc}; use namada_sdk::tendermint::abci::request::CheckTxKind; use once_cell::unsync::Lazy; use sysinfo::{RefreshKind, System, SystemExt}; @@ -758,8 +758,8 @@ pub fn test_genesis_files( genesis: config::genesis::chain::Finalized, wasm_dir: PathBuf, ) { + use namada::core::hash::Sha256Hasher; use namada::state::mockdb::MockDB; - use namada::types::hash::Sha256Hasher; // Channels for validators to send protocol txs to be broadcast to the // broadcaster service diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs index 885c531557..8fc12578ea 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -3,6 +3,8 @@ use data_encoding::HEXUPPER; use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; +use namada::core::key::tm_raw_hash_to_string; +use namada::core::storage::{BlockHash, BlockResults, Epoch, Header}; use namada::governance::pgf::inflation as pgf_inflation; use namada::ledger::events::EventType; use namada::ledger::gas::{GasMetering, TxGasMeter}; @@ -18,8 +20,6 @@ use namada::state::{ ResultExt, StorageRead, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY, }; use namada::tx::data::protocol::ProtocolTxType; -use namada::types::key::tm_raw_hash_to_string; -use namada::types::storage::{BlockHash, BlockResults, Epoch, Header}; use namada::vote_ext::ethereum_events::MultiSignedEthEvent; use namada::vote_ext::ethereum_tx_data_variants; use namada_sdk::tx::new_tx_event; @@ -742,6 +742,15 @@ mod test_finalize_block { use std::str::FromStr; use data_encoding::HEXUPPER; + use namada::core::dec::{Dec, POS_DECIMAL_PRECISION}; + use namada::core::ethereum_events::{EthAddress, Uint as ethUint}; + use namada::core::hash::Hash; + use namada::core::keccak::KeccakHash; + use namada::core::key::testing::common_sk_from_simple_seed; + use namada::core::key::tm_consensus_key_raw_hash; + use namada::core::storage::{Epoch, KeySeg}; + use namada::core::time::{DateTimeUtc, DurationSecs}; + use namada::core::uint::Uint; use namada::eth_bridge::storage::bridge_pool::{ self, get_key_from_hash, get_nonce_key, get_signed_root_key, }; @@ -773,15 +782,6 @@ mod test_finalize_block { use namada::token::{Amount, DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::{Code, Data, Section, Signature}; - use namada::types::dec::{Dec, POS_DECIMAL_PRECISION}; - use namada::types::ethereum_events::{EthAddress, Uint as ethUint}; - use namada::types::hash::Hash; - use namada::types::keccak::KeccakHash; - use namada::types::key::testing::common_sk_from_simple_seed; - use namada::types::key::tm_consensus_key_raw_hash; - use namada::types::storage::{Epoch, KeySeg}; - use namada::types::time::{DateTimeUtc, DurationSecs}; - use namada::types::uint::Uint; use namada::vote_ext::{ethereum_events, EthereumTxData}; use namada_sdk::eth_bridge::MinimumConfirmations; use namada_sdk::governance::ProposalVote; @@ -1431,7 +1431,7 @@ mod test_finalize_block { } // write transfer to storage let transfer = { - use namada::types::eth_bridge_pool::{ + use namada::core::eth_bridge_pool::{ GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, }; @@ -5008,7 +5008,7 @@ mod test_finalize_block { // we advance forward to the next epoch let mut req = FinalizeBlock::default(); - req.header.time = namada::types::time::DateTimeUtc::now(); + req.header.time = namada::core::time::DateTimeUtc::now(); let current_decision_height = shell.get_current_decision_height(); if let Some(b) = shell.wl_storage.storage.last_block.as_mut() { b.height = current_decision_height + 11; diff --git a/crates/apps/src/lib/node/ledger/shell/governance.rs b/crates/apps/src/lib/node/ledger/shell/governance.rs index 4865f714f5..36ff6e7cf4 100644 --- a/crates/apps/src/lib/node/ledger/shell/governance.rs +++ b/crates/apps/src/lib/node/ledger/shell/governance.rs @@ -1,6 +1,9 @@ use std::collections::HashMap; +use namada::core::address::Address; +use namada::core::encode; use namada::core::event::EmitEvents; +use namada::core::storage::Epoch; use namada::governance::pgf::storage::keys as pgf_storage; use namada::governance::pgf::storage::steward::StewardDetail; use namada::governance::pgf::{storage as pgf, ADDRESS}; @@ -21,9 +24,6 @@ use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::storage::read_total_stake; use namada::state::{DBIter, StorageHasher, StorageWrite, DB}; use namada::tx::{Code, Data}; -use namada::types::address::Address; -use namada::types::encode; -use namada::types::storage::Epoch; use namada::{ibc, token}; use namada_sdk::proof_of_stake::storage::read_validator_stake; diff --git a/crates/apps/src/lib/node/ledger/shell/init_chain.rs b/crates/apps/src/lib/node/ledger/shell/init_chain.rs index a881171b51..6da33496db 100644 --- a/crates/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/crates/apps/src/lib/node/ledger/shell/init_chain.rs @@ -6,14 +6,14 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_proofs::bls12_381; use namada::account::protocol_pk_key; +use namada::core::address::Address; +use namada::core::hash::Hash as CodeHash; +use namada::core::time::{DateTimeUtc, TimeZone, Utc}; use namada::ledger::parameters::Parameters; use namada::ledger::{ibc, pos}; use namada::proof_of_stake::BecomeValidator; use namada::state::{DBIter, StorageHasher, StorageWrite, DB}; use namada::token::{credit_tokens, write_denom}; -use namada::types::address::Address; -use namada::types::hash::Hash as CodeHash; -use namada::types::time::{DateTimeUtc, TimeZone, Utc}; use namada::vm::validate_untrusted_wasm; use namada_sdk::eth_bridge::EthBridgeStatus; use namada_sdk::proof_of_stake::PosParams; @@ -153,7 +153,7 @@ where let convert_anchor_key = token::storage_key::masp_convert_anchor_key(); self.wl_storage.write( &convert_anchor_key, - namada::types::hash::Hash( + namada::core::hash::Hash( bls12_381::Scalar::from( self.wl_storage.storage.conversion_state.tree.root(), ) @@ -554,7 +554,7 @@ where genesis: &genesis::chain::Finalized, vp_cache: &mut HashMap>, params: &PosParams, - current_epoch: namada::types::storage::Epoch, + current_epoch: namada::core::storage::Epoch, ) -> ControlFlow<()> { if let Some(txs) = genesis.transactions.validator_account.as_ref() { for FinalizedValidatorAccountTx { @@ -939,8 +939,8 @@ mod test { use std::collections::BTreeMap; use std::str::FromStr; + use namada::core::string_encoding::StringEncoded; use namada::state::DBIter; - use namada::types::string_encoding::StringEncoded; use namada_sdk::wallet::alias::Alias; use super::*; diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps/src/lib/node/ledger/shell/mod.rs index 93faa419d6..28c06cdb5b 100644 --- a/crates/apps/src/lib/node/ledger/shell/mod.rs +++ b/crates/apps/src/lib/node/ledger/shell/mod.rs @@ -30,7 +30,13 @@ use std::rc::Rc; use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::Transaction; -use namada::core::hints; +use namada::core::address::Address; +use namada::core::chain::ChainId; +use namada::core::ethereum_events::EthereumEvent; +use namada::core::key::*; +use namada::core::storage::{BlockHeight, Key, TxIndex}; +use namada::core::time::DateTimeUtc; +use namada::core::{address, hints}; use namada::ethereum_bridge::protocol::validation::bridge_pool_roots::validate_bp_roots_vext; use namada::ethereum_bridge::protocol::validation::ethereum_events::validate_eth_events_vext; use namada::ethereum_bridge::protocol::validation::validator_set_update::validate_valset_upd_vext; @@ -59,13 +65,6 @@ use namada::token; pub use namada::tx::data::ResultCode; use namada::tx::data::{DecryptedTx, TxType, WrapperTx, WrapperTxErr}; use namada::tx::{Section, Tx}; -use namada::types::address; -use namada::types::address::Address; -use namada::types::chain::ChainId; -use namada::types::ethereum_events::EthereumEvent; -use namada::types::key::*; -use namada::types::storage::{BlockHeight, Key, TxIndex}; -use namada::types::time::DateTimeUtc; use namada::vm::wasm::{TxCache, VpCache}; use namada::vm::{WasmCacheAccess, WasmCacheRwAccess}; use namada::vote_ext::EthereumTxData; @@ -358,7 +357,7 @@ where /// Merkle tree storage key filter. Return `false` for keys that shouldn't be /// merklized. -pub fn is_merklized_storage_key(key: &namada_sdk::types::storage::Key) -> bool { +pub fn is_merklized_storage_key(key: &namada_sdk::storage::Key) -> bool { !token::storage_key::is_masp_key(key) && !namada::ibc::storage::is_ibc_counter_key(key) } @@ -616,8 +615,8 @@ where /// Get the next epoch for which we can request validator set changed pub fn get_validator_set_update_epoch( &self, - current_epoch: namada_sdk::types::storage::Epoch, - ) -> namada_sdk::types::storage::Epoch { + current_epoch: namada_sdk::storage::Epoch, + ) -> namada_sdk::storage::Epoch { if let Some(delay) = self.wl_storage.storage.update_epoch_blocks_delay { if delay == EPOCH_SWITCH_BLOCKS_DELAY { // If we're about to update validator sets for the @@ -1423,6 +1422,14 @@ mod test_utils { use std::path::PathBuf; use data_encoding::HEXUPPER; + use namada::core::address; + use namada::core::chain::ChainId; + use namada::core::ethereum_events::Uint; + use namada::core::hash::Hash; + use namada::core::keccak::KeccakHash; + use namada::core::key::*; + use namada::core::storage::{BlockHash, Epoch, Header}; + use namada::core::time::{DateTimeUtc, DurationSecs}; use namada::ledger::parameters::{EpochDuration, Parameters}; use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::storage::validator_consensus_key_handle; @@ -1434,14 +1441,6 @@ mod test_utils { use namada::token::conversion::update_allowed_conversions; use namada::tx::data::{Fee, TxType, WrapperTx}; use namada::tx::{Code, Data}; - use namada::types::address; - use namada::types::chain::ChainId; - use namada::types::ethereum_events::Uint; - use namada::types::hash::Hash; - use namada::types::keccak::KeccakHash; - use namada::types::key::*; - use namada::types::storage::{BlockHash, Epoch, Header}; - use namada::types::time::{DateTimeUtc, DurationSecs}; use tempfile::tempdir; use tokio::sync::mpsc::{Sender, UnboundedReceiver}; @@ -1537,7 +1536,7 @@ mod test_utils { /// Get the default bridge pool vext bytes to be signed. pub fn get_bp_bytes_to_sign() -> KeccakHash { - use namada::types::keccak::{Hasher, Keccak}; + use namada::core::keccak::{Hasher, Keccak}; let root = [0; 32]; let nonce = Uint::from(0).to_bytes(); @@ -2095,15 +2094,15 @@ mod test_utils { #[cfg(test)] mod shell_tests { + use namada::core::ethereum_events::EthereumEvent; + use namada::core::key::RefTo; + use namada::core::storage::{BlockHeight, Epoch}; use namada::token::read_denom; use namada::tx::data::protocol::{ProtocolTx, ProtocolTxType}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::{ Code, Data, Section, SignableEthMessage, Signature, Signed, Tx, }; - use namada::types::ethereum_events::EthereumEvent; - use namada::types::key::RefTo; - use namada::types::storage::{BlockHeight, Epoch}; use namada::vote_ext::{ bridge_pool_roots, ethereum_events, ethereum_tx_data_variants, }; @@ -2202,7 +2201,7 @@ mod shell_tests { /// not validated by `CheckTx`. #[test] fn test_outdated_nonce_mempool_validate() { - use namada::types::storage::InnerEthEventsQueue; + use namada::core::storage::InnerEthEventsQueue; const LAST_HEIGHT: BlockHeight = BlockHeight(3); diff --git a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs index 7255789052..9b56878f16 100644 --- a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -1,7 +1,10 @@ //! Implementation of the [`RequestPrepareProposal`] ABCI++ method for the Shell use masp_primitives::transaction::Transaction; +use namada::core::address::Address; use namada::core::hints; +use namada::core::key::tm_raw_hash_to_string; +use namada::core::time::DateTimeUtc; use namada::gas::TxGasMeter; use namada::ledger::protocol; use namada::ledger::storage::tx_queue::TxInQueue; @@ -9,9 +12,6 @@ use namada::proof_of_stake::storage::find_validator_by_raw_hash; use namada::state::{DBIter, StorageHasher, TempWlStorage, DB}; use namada::tx::data::{DecryptedTx, TxType, WrapperTx}; use namada::tx::Tx; -use namada::types::address::Address; -use namada::types::key::tm_raw_hash_to_string; -use namada::types::time::DateTimeUtc; use namada::vm::wasm::{TxCache, VpCache}; use namada::vm::WasmCacheAccess; @@ -431,6 +431,10 @@ mod test_prepare_proposal { use std::collections::BTreeSet; use borsh_ext::BorshSerializeExt; + use namada::core::address::{self, Address}; + use namada::core::ethereum_events::EthereumEvent; + use namada::core::key::RefTo; + use namada::core::storage::{BlockHeight, InnerEthEventsQueue}; use namada::ledger::gas::Gas; use namada::ledger::pos::PosQueries; use namada::proof_of_stake::storage::{ @@ -443,10 +447,6 @@ mod test_prepare_proposal { use namada::token::{read_denom, Amount, DenominatedAmount}; use namada::tx::data::{Fee, TxType, WrapperTx}; use namada::tx::{Code, Data, Header, Section, Signature, Signed}; - use namada::types::address::{self, Address}; - use namada::types::ethereum_events::EthereumEvent; - use namada::types::key::RefTo; - use namada::types::storage::{BlockHeight, InnerEthEventsQueue}; use namada::vote_ext::{ethereum_events, ethereum_tx_data_variants}; use namada::{replay_protection, token}; @@ -1183,7 +1183,7 @@ mod test_prepare_proposal { // Remove the allowed btc *local_config = Some(ValidatorLocalConfig { accepted_gas_tokens: std::collections::HashMap::from([( - namada::types::address::nam(), + namada::core::address::nam(), Amount::from(1), )]), }); @@ -1289,7 +1289,7 @@ mod test_prepare_proposal { // Remove btc and increase minimum for nam *local_config = Some(ValidatorLocalConfig { accepted_gas_tokens: std::collections::HashMap::from([( - namada::types::address::nam(), + namada::core::address::nam(), Amount::from(100), )]), }); diff --git a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs b/crates/apps/src/lib/node/ledger/shell/process_proposal.rs index 7146726382..4f4e3eb132 100644 --- a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -667,16 +667,16 @@ where /// are covered by the e2e tests. #[cfg(test)] mod test_process_proposal { + use namada::core::ethereum_events::EthereumEvent; + use namada::core::key::*; + use namada::core::storage::Epoch; + use namada::core::time::DateTimeUtc; use namada::state::StorageWrite; use namada::token::{read_denom, Amount, DenominatedAmount}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::{ Code, Data, Section, SignableEthMessage, Signature, Signed, }; - use namada::types::ethereum_events::EthereumEvent; - use namada::types::key::*; - use namada::types::storage::Epoch; - use namada::types::time::DateTimeUtc; use namada::vote_ext::{ bridge_pool_roots, ethereum_events, EthereumTxData, }; @@ -2176,7 +2176,7 @@ mod test_process_proposal { /// not validated by `ProcessProposal`. #[test] fn test_outdated_nonce_process_proposal() { - use namada::types::storage::InnerEthEventsQueue; + use namada::core::storage::InnerEthEventsQueue; const LAST_HEIGHT: BlockHeight = BlockHeight(3); diff --git a/crates/apps/src/lib/node/ledger/shell/queries.rs b/crates/apps/src/lib/node/ledger/shell/queries.rs index 721fd14621..b4cc45b069 100644 --- a/crates/apps/src/lib/node/ledger/shell/queries.rs +++ b/crates/apps/src/lib/node/ledger/shell/queries.rs @@ -1,9 +1,9 @@ //! Shell methods for querying state +use namada::core::address::Address; use namada::ledger::dry_run_tx; use namada::ledger::queries::{RequestCtx, ResponseQuery}; use namada::token; -use namada::types::address::Address; use super::*; use crate::node::ledger::response; @@ -66,12 +66,12 @@ where // access to the `Shell` there #[cfg(test)] mod test_queries { + use namada::core::storage::{BlockHash, Epoch}; use namada::ledger::pos::PosQueries; use namada::proof_of_stake::storage::read_consensus_validator_set_addresses_with_stake; use namada::proof_of_stake::types::WeightedValidator; use namada::state::EPOCH_SWITCH_BLOCKS_DELAY; use namada::tendermint::abci::types::VoteInfo; - use namada::types::storage::{BlockHash, Epoch}; use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use super::*; diff --git a/crates/apps/src/lib/node/ledger/shell/testing/client.rs b/crates/apps/src/lib/node/ledger/shell/testing/client.rs index 6f34737f22..310a4ce860 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/client.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/client.rs @@ -1,6 +1,6 @@ use clap::Command as App; use eyre::Report; -use namada::types::io::Io; +use namada::io::Io; use namada_sdk::error::Error as SdkError; use tendermint_config::net::Address as TendermintAddress; diff --git a/crates/apps/src/lib/node/ledger/shell/testing/node.rs b/crates/apps/src/lib/node/ledger/shell/testing/node.rs index a3ab32dcb6..18f61463e1 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/node.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/node.rs @@ -10,6 +10,13 @@ use color_eyre::eyre::{Report, Result}; use data_encoding::HEXUPPER; use itertools::Either; use lazy_static::lazy_static; +use namada::control_flow::time::Duration; +use namada::core::ethereum_events::EthereumEvent; +use namada::core::ethereum_structs; +use namada::core::hash::Hash; +use namada::core::key::tm_consensus_key_raw_hash; +use namada::core::storage::{BlockHash, BlockHeight, Epoch, Header}; +use namada::core::time::DateTimeUtc; use namada::eth_bridge::oracle::config::Config as OracleConfig; use namada::ledger::dry_run_tx; use namada::ledger::events::log::dumb_queries; @@ -26,13 +33,6 @@ use namada::state::{LastBlock, Sha256Hasher, EPOCH_SWITCH_BLOCKS_DELAY}; use namada::tendermint::abci::response::Info; use namada::tendermint::abci::types::VoteInfo; use namada::tendermint_rpc::SimpleRequest; -use namada::types::control_flow::time::Duration; -use namada::types::ethereum_events::EthereumEvent; -use namada::types::ethereum_structs; -use namada::types::hash::Hash; -use namada::types::key::tm_consensus_key_raw_hash; -use namada::types::storage::{BlockHash, BlockHeight, Epoch, Header}; -use namada::types::time::DateTimeUtc; use namada_sdk::queries::Client; use namada_sdk::tendermint_proto::google::protobuf::Timestamp; use namada_sdk::tx::data::ResultCode; diff --git a/crates/apps/src/lib/node/ledger/shell/testing/utils.rs b/crates/apps/src/lib/node/ledger/shell/testing/utils.rs index 451e20c2df..c742559b84 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/utils.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/utils.rs @@ -4,7 +4,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use lazy_static::lazy_static; -use namada::types::io::{prompt_aux, read_aux, Io}; +use namada::io::{prompt_aux, read_aux, Io}; use tempfile::tempdir; use tokio::io::{AsyncRead, ReadBuf}; diff --git a/crates/apps/src/lib/node/ledger/shell/utils.rs b/crates/apps/src/lib/node/ledger/shell/utils.rs index 3a9142cdb8..e34009956d 100644 --- a/crates/apps/src/lib/node/ledger/shell/utils.rs +++ b/crates/apps/src/lib/node/ledger/shell/utils.rs @@ -1,6 +1,6 @@ use borsh::BorshDeserialize; +use namada::core::storage::Key; use namada::state::{self, StorageRead}; -use namada::types::storage::Key; pub(super) fn force_read( storage: &S, diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs index f6f9f10308..6e2b6db25a 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs @@ -56,6 +56,11 @@ where #[cfg(test)] mod test_bp_vote_extensions { + use namada::core::ethereum_events::Uint; + use namada::core::keccak::{keccak_hash, KeccakHash}; + use namada::core::key::*; + use namada::core::storage::BlockHeight; + use namada::core::token; use namada::ethereum_bridge::protocol::validation::bridge_pool_roots::validate_bp_roots_vext; use namada::ethereum_bridge::storage::bridge_pool::get_key_from_hash; use namada::ethereum_bridge::storage::eth_bridge_queries::EthBridgeQueries; @@ -71,11 +76,6 @@ mod test_bp_vote_extensions { use namada::state::StorageWrite; use namada::tendermint::abci::types::VoteInfo; use namada::tx::{SignableEthMessage, Signed}; - use namada::types::ethereum_events::Uint; - use namada::types::keccak::{keccak_hash, KeccakHash}; - use namada::types::key::*; - use namada::types::storage::BlockHeight; - use namada::types::token; use namada::vote_ext::bridge_pool_roots; use crate::node::ledger::shell::test_utils::*; diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs index 8ef538bbcb..3954404203 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs @@ -2,9 +2,9 @@ use std::collections::{BTreeMap, HashMap}; +use namada::core::ethereum_events::EthereumEvent; use namada::state::{DBIter, StorageHasher, DB}; use namada::tx::Signed; -use namada::types::ethereum_events::EthereumEvent; use namada::vote_ext::ethereum_events::{self, MultiSignedEthEvent}; use namada_sdk::eth_bridge::EthBridgeQueries; @@ -143,6 +143,13 @@ mod test_vote_extensions { use std::convert::TryInto; use borsh_ext::BorshSerializeExt; + use namada::core::address::testing::gen_established_address; + use namada::core::ethereum_events::{ + EthAddress, EthereumEvent, TransferToEthereum, Uint, + }; + use namada::core::hash::Hash; + use namada::core::key::*; + use namada::core::storage::{Epoch, InnerEthEventsQueue}; use namada::eth_bridge::storage::bridge_pool; use namada::ledger::eth_bridge::EthBridgeQueries; use namada::ledger::pos::PosQueries; @@ -153,13 +160,6 @@ mod test_vote_extensions { use namada::proof_of_stake::types::WeightedValidator; use namada::state::collections::lazy_map::{NestedSubKey, SubKey}; use namada::tendermint::abci::types::VoteInfo; - use namada::types::address::testing::gen_established_address; - use namada::types::ethereum_events::{ - EthAddress, EthereumEvent, TransferToEthereum, Uint, - }; - use namada::types::hash::Hash; - use namada::types::key::*; - use namada::types::storage::{Epoch, InnerEthEventsQueue}; use namada::vote_ext::ethereum_events; use super::validate_eth_events_vext; diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs index 2c3be6e78a..56ef810414 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs @@ -113,6 +113,7 @@ where #[cfg(test)] mod test_vote_extensions { + use namada::core::key::RefTo; use namada::ledger::pos::PosQueries; use namada::proof_of_stake::storage::{ consensus_validator_set_handle, @@ -122,7 +123,6 @@ mod test_vote_extensions { use namada::proof_of_stake::Epoch; use namada::state::collections::lazy_map::{NestedSubKey, SubKey}; use namada::tendermint::abci::types::VoteInfo; - use namada::types::key::RefTo; use namada::vote_ext::validator_set_update; use namada_sdk::eth_bridge::EthBridgeQueries; diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 12848d86e0..e62d1fdb13 100644 --- a/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -5,12 +5,12 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::future::FutureExt; +use namada::core::hash::Hash; +use namada::core::key::tm_raw_hash_to_string; +use namada::core::storage::{BlockHash, BlockHeight}; use namada::proof_of_stake::storage::find_validator_by_raw_hash; use namada::tx::data::hash_tx; use namada::tx::Tx; -use namada::types::hash::Hash; -use namada::types::key::tm_raw_hash_to_string; -use namada::types::storage::{BlockHash, BlockHeight}; use tokio::sync::broadcast; use tokio::sync::mpsc::UnboundedSender; use tower::Service; diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index 5b0a553f55..81151f45ef 100644 --- a/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -153,9 +153,9 @@ pub mod shim { pub mod request { use std::convert::TryFrom; - use namada::types::hash::Hash; - use namada::types::storage::{BlockHash, Header}; - use namada::types::time::DateTimeUtc; + use namada::core::hash::Hash; + use namada::core::storage::{BlockHash, Header}; + use namada::core::time::DateTimeUtc; use super::VoteInfo; use crate::facade::tendermint::abci::types::Misbehavior; diff --git a/crates/apps/src/lib/node/ledger/storage/mod.rs b/crates/apps/src/lib/node/ledger/storage/mod.rs index 385405fed1..8f9aef8476 100644 --- a/crates/apps/src/lib/node/ledger/storage/mod.rs +++ b/crates/apps/src/lib/node/ledger/storage/mod.rs @@ -54,6 +54,13 @@ mod tests { use borsh::BorshDeserialize; use itertools::Itertools; + use namada::core::chain::ChainId; + use namada::core::ethereum_events::Uint; + use namada::core::hash::Hash; + use namada::core::keccak::KeccakHash; + use namada::core::storage::{BlockHash, BlockHeight, Key}; + use namada::core::time::DurationSecs; + use namada::core::{address, storage}; use namada::eth_bridge::storage::proof::BridgePoolRootProof; use namada::ledger::eth_bridge::storage::bridge_pool; use namada::ledger::gas::STORAGE_ACCESS_GAS_PER_BYTE; @@ -64,14 +71,7 @@ mod tests { self, StorageRead, StorageWrite, StoreType, WlStorage, DB, }; use namada::token::conversion::update_allowed_conversions; - use namada::types::chain::ChainId; - use namada::types::ethereum_events::Uint; - use namada::types::hash::Hash; - use namada::types::keccak::KeccakHash; - use namada::types::storage::{BlockHash, BlockHeight, Key}; - use namada::types::time::DurationSecs; - use namada::types::{address, storage}; - use namada::{parameters, types}; + use namada::{decode, encode, parameters}; use proptest::collection::vec; use proptest::prelude::*; use proptest::test_runner::Config; @@ -94,7 +94,7 @@ mod tests { ); let key = Key::parse("key").expect("cannot parse the key string"); let value: u64 = 1; - let value_bytes = types::encode(&value); + let value_bytes = encode(&value); let value_bytes_len = value_bytes.len(); // before insertion @@ -113,9 +113,8 @@ mod tests { assert!(result); assert_eq!(gas, key.len() as u64 * STORAGE_ACCESS_GAS_PER_BYTE); let (result, gas) = storage.read(&key).expect("read failed"); - let read_value: u64 = - types::decode(result.expect("value doesn't exist")) - .expect("decoding failed"); + let read_value: u64 = decode(result.expect("value doesn't exist")) + .expect("decoding failed"); assert_eq!(read_value, value); assert_eq!( gas, @@ -150,7 +149,7 @@ mod tests { .expect("begin_block failed"); let key = Key::parse("key").expect("cannot parse the key string"); let value: u64 = 1; - let value_bytes = types::encode(&value); + let value_bytes = encode(&value); let mut wl_storage = WlStorage::new(WriteLog::default(), storage); // initialize parameter storage let params = Parameters { @@ -242,7 +241,7 @@ mod tests { let key = prefix .push(&format!("{}", i)) .expect("cannot push the key segment"); - let value_bytes = types::encode(&(i as u64)); + let value_bytes = encode(&(i as u64)); // insert storage .write(&key, value_bytes.clone()) @@ -373,7 +372,7 @@ mod tests { ); if write_value { - let value_bytes = types::encode(&storage.block.height); + let value_bytes = encode(&storage.block.height); storage.write(&key, value_bytes)?; } else { storage.delete(&key)?; @@ -391,11 +390,10 @@ mod tests { let value_bytes = value_bytes.unwrap_or_else(|| { panic!("Couldn't read from height {height}") }); - let value: BlockHeight = types::decode(value_bytes).unwrap(); + let value: BlockHeight = decode(value_bytes).unwrap(); assert_eq!(value, height); } else if value_bytes.is_some() { - let value: BlockHeight = - types::decode(value_bytes.unwrap()).unwrap(); + let value: BlockHeight = decode(value_bytes.unwrap()).unwrap(); panic!("Expected no value at height {height}, got {}", value,); } } @@ -415,11 +413,10 @@ mod tests { if is_last_write { let value_bytes = value_bytes.expect("Should have been written"); - let value: BlockHeight = types::decode(value_bytes).unwrap(); + let value: BlockHeight = decode(value_bytes).unwrap(); assert_eq!(value, storage.get_last_block_height()); } else if value_bytes.is_some() { - let value: BlockHeight = - types::decode(value_bytes.unwrap()).unwrap(); + let value: BlockHeight = decode(value_bytes.unwrap()).unwrap(); panic!("Expected no value at height {height}, got {}", value,); } } @@ -458,13 +455,13 @@ mod tests { // write values at Height 0 like init_storage for i in 0..num_keys { let key = ibc_key(format!("key{}", i)).unwrap(); - let value_bytes = types::encode(&storage.block.height); + let value_bytes = encode(&storage.block.height); storage.write(&key, value_bytes)?; } let key = bridge_pool::get_signed_root_key(); let root_proof = BridgePoolRootProof::new((KeccakHash::default(), Uint::default())); - let bytes = types::encode(&root_proof); + let bytes = encode(&root_proof); storage.write(&key, bytes)?; // Update and commit @@ -497,14 +494,14 @@ mod tests { storage.delete(&key)?; } 2 => { - let value_bytes = types::encode(&storage.block.height); + let value_bytes = encode(&storage.block.height); storage.write(&key, value_bytes)?; } 3 => { storage.batch_delete_subspace_val(&mut batch, &key)?; } _ => { - let value_bytes = types::encode(&storage.block.height); + let value_bytes = encode(&storage.block.height); storage.batch_write_subspace_val( &mut batch, &key, @@ -571,9 +568,7 @@ mod tests { let key = ibc_key("key").unwrap(); let value: u64 = 1; - storage - .write(&key, types::encode(&value)) - .expect("write failed"); + storage.write(&key, encode(&value)).expect("write failed"); storage.block.pred_epochs.new_epoch(new_epoch_start); let batch = PersistentStorage::batch(); @@ -586,9 +581,7 @@ mod tests { let key = ibc_key("key2").unwrap(); let value: u64 = 2; - storage - .write(&key, types::encode(&value)) - .expect("write failed"); + storage.write(&key, encode(&value)).expect("write failed"); // the second nonce isn't written for a test skipping pruning let nonce = nonce + 1; @@ -609,7 +602,7 @@ mod tests { let nonce = nonce + 1; let root_proof = BridgePoolRootProof::new((KeccakHash::default(), nonce)); - let bytes = types::encode(&root_proof); + let bytes = encode(&root_proof); storage.write(&signed_root_key, bytes).unwrap(); storage.block.epoch = storage.block.epoch.next(); @@ -637,7 +630,7 @@ mod tests { let nonce = nonce + 1; let root_proof = BridgePoolRootProof::new((KeccakHash::default(), nonce)); - let bytes = types::encode(&root_proof); + let bytes = encode(&root_proof); storage.write(&signed_root_key, bytes).unwrap(); storage.block.epoch = storage.block.epoch.next(); storage.block.pred_epochs.new_epoch(BlockHeight(12)); diff --git a/crates/apps/src/lib/node/ledger/storage/rocksdb.rs b/crates/apps/src/lib/node/ledger/storage/rocksdb.rs index 97bbb37b3c..dca0c44cad 100644 --- a/crates/apps/src/lib/node/ledger/storage/rocksdb.rs +++ b/crates/apps/src/lib/node/ledger/storage/rocksdb.rs @@ -48,9 +48,16 @@ use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; use itertools::Either; +use namada::core::storage::{ + BlockHeight, BlockResults, Epoch, EthEventsQueue, Header, Key, KeySeg, + KEY_SEGMENT_SEPARATOR, +}; +use namada::core::time::DateTimeUtc; +use namada::core::{decode, encode, ethereum_events, ethereum_structs}; use namada::eth_bridge::storage::proof::BridgePoolRootProof; use namada::ledger::eth_bridge::storage::bridge_pool; use namada::ledger::storage::tx_queue::TxQueue; +use namada::replay_protection; use namada::state::merkle_tree::{base_tree_key_prefix, subtree_key_prefix}; use namada::state::types::PrefixIterator; use namada::state::{ @@ -58,13 +65,6 @@ use namada::state::{ DbResult as Result, MerkleTreeStoresRead, StoreType, DB, }; use namada::token::ConversionState; -use namada::types::storage::{ - BlockHeight, BlockResults, Epoch, EthEventsQueue, Header, Key, KeySeg, - KEY_SEGMENT_SEPARATOR, -}; -use namada::types::time::DateTimeUtc; -use namada::types::{ethereum_events, ethereum_structs}; -use namada::{replay_protection, types}; use rayon::prelude::*; use rocksdb::{ BlockBasedOptions, ColumnFamily, ColumnFamilyDescriptor, DBCompactionStyle, @@ -338,7 +338,7 @@ impl RocksDB { .get_column_family(STATE_CF) .expect("State column family should exist"); - let last_height: BlockHeight = types::decode( + let last_height: BlockHeight = decode( self.0 .get_cf(state_cf, "height") .expect("Unable to read DB") @@ -512,7 +512,7 @@ impl RocksDB { // three keys in storage we can only perform one rollback before // restarting the chain tracing::info!("Reverting non-height-prepended metadata keys"); - batch.put_cf(state_cf, "height", types::encode(&previous_height)); + batch.put_cf(state_cf, "height", encode(&previous_height)); for metadata_key in [ "next_epoch_min_start_height", "next_epoch_min_start_time", @@ -664,7 +664,7 @@ impl DB for RocksDB { Some(bytes) => { // TODO if there's an issue decoding this height, should we try // load its predecessor instead? - types::decode(bytes).map_err(Error::CodingError)? + decode(bytes).map_err(Error::CodingError)? } None => return Ok(None), }; @@ -677,7 +677,7 @@ impl DB for RocksDB { .get_cf(block_cf, results_path) .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; @@ -687,7 +687,7 @@ impl DB for RocksDB { .get_cf(state_cf, "next_epoch_min_start_height") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!( "Couldn't load next epoch start height from the DB" @@ -700,7 +700,7 @@ impl DB for RocksDB { .get_cf(state_cf, "next_epoch_min_start_time") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!( "Couldn't load next epoch start time from the DB" @@ -713,7 +713,7 @@ impl DB for RocksDB { .get_cf(state_cf, "update_epoch_blocks_delay") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!( "Couldn't load epoch update block delay from the DB" @@ -726,7 +726,7 @@ impl DB for RocksDB { .get_cf(state_cf, "conversion_state") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!("Couldn't load conversion state from the DB"); return Ok(None); @@ -737,7 +737,7 @@ impl DB for RocksDB { .get_cf(state_cf, "tx_queue") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!("Couldn't load tx queue from the DB"); return Ok(None); @@ -749,7 +749,7 @@ impl DB for RocksDB { .get_cf(state_cf, "ethereum_height") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!("Couldn't load ethereum height from the DB"); return Ok(None); @@ -761,7 +761,7 @@ impl DB for RocksDB { .get_cf(state_cf, "eth_events_queue") .map_err(|e| Error::DBError(e.into_string()))? { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => { tracing::error!( "Couldn't load the eth events queue from the DB" @@ -810,7 +810,7 @@ impl DB for RocksDB { match segments.get(3) { Some(&"root") => merkle_tree_stores.set_root( &st, - types::decode(bytes) + decode(bytes) .map_err(Error::CodingError)?, ), Some(&"store") => merkle_tree_stores @@ -824,29 +824,21 @@ impl DB for RocksDB { // the block header doesn't have to be restored } "hash" => { - hash = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + hash = Some(decode(bytes).map_err(Error::CodingError)?) } "time" => { - time = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + time = Some(decode(bytes).map_err(Error::CodingError)?) } "epoch" => { - epoch = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + epoch = Some(decode(bytes).map_err(Error::CodingError)?) } "pred_epochs" => { - pred_epochs = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + pred_epochs = + Some(decode(bytes).map_err(Error::CodingError)?) } "address_gen" => { - address_gen = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ); + address_gen = + Some(decode(bytes).map_err(Error::CodingError)?); } _ => unknown_key_error(path)?, }, @@ -866,7 +858,7 @@ impl DB for RocksDB { { merkle_tree_stores.set_root( st, - types::decode(bytes).map_err(Error::CodingError)?, + decode(bytes).map_err(Error::CodingError)?, ); } let store_key = key_prefix.with_segment("store".to_owned()); @@ -952,7 +944,7 @@ impl DB for RocksDB { batch.0.put_cf( state_cf, "next_epoch_min_start_height", - types::encode(&next_epoch_min_start_height), + encode(&next_epoch_min_start_height), ); if let Some(current_value) = self @@ -970,7 +962,7 @@ impl DB for RocksDB { batch.0.put_cf( state_cf, "next_epoch_min_start_time", - types::encode(&next_epoch_min_start_time), + encode(&next_epoch_min_start_time), ); if let Some(current_value) = self .0 @@ -987,7 +979,7 @@ impl DB for RocksDB { batch.0.put_cf( state_cf, "update_epoch_blocks_delay", - types::encode(&update_epoch_blocks_delay), + encode(&update_epoch_blocks_delay), ); // Save the conversion state when the epoch is updated @@ -1007,7 +999,7 @@ impl DB for RocksDB { batch.0.put_cf( state_cf, "conversion_state", - types::encode(conversion_state), + encode(conversion_state), ); } @@ -1020,19 +1012,13 @@ impl DB for RocksDB { // Write the predecessor value for rollback batch.0.put_cf(state_cf, "pred/tx_queue", pred_tx_queue); } + batch.0.put_cf(state_cf, "tx_queue", encode(&tx_queue)); batch .0 - .put_cf(state_cf, "tx_queue", types::encode(&tx_queue)); - batch.0.put_cf( - state_cf, - "ethereum_height", - types::encode(ðereum_height), - ); - batch.0.put_cf( - state_cf, - "eth_events_queue", - types::encode(ð_events_queue), - ); + .put_cf(state_cf, "ethereum_height", encode(ðereum_height)); + batch + .0 + .put_cf(state_cf, "eth_events_queue", encode(ð_events_queue)); let block_cf = self.get_column_family(BLOCK_CF)?; let prefix_key = Key::from(height.to_db_key()); @@ -1050,7 +1036,7 @@ impl DB for RocksDB { batch.0.put_cf( block_cf, root_key.to_string(), - types::encode(merkle_tree_stores.root(st)), + encode(merkle_tree_stores.root(st)), ); let store_key = key_prefix.with_segment("store".to_owned()); batch.0.put_cf( @@ -1077,60 +1063,48 @@ impl DB for RocksDB { let key = prefix_key .push(&"hash".to_owned()) .map_err(Error::KeyError)?; - batch - .0 - .put_cf(block_cf, key.to_string(), types::encode(&hash)); + batch.0.put_cf(block_cf, key.to_string(), encode(&hash)); } // Block time { let key = prefix_key .push(&"time".to_owned()) .map_err(Error::KeyError)?; - batch - .0 - .put_cf(block_cf, key.to_string(), types::encode(&time)); + batch.0.put_cf(block_cf, key.to_string(), encode(&time)); } // Block epoch { let key = prefix_key .push(&"epoch".to_owned()) .map_err(Error::KeyError)?; - batch - .0 - .put_cf(block_cf, key.to_string(), types::encode(&epoch)); + batch.0.put_cf(block_cf, key.to_string(), encode(&epoch)); } // Block results { let results_path = format!("results/{}", height.raw()); - batch - .0 - .put_cf(block_cf, results_path, types::encode(&results)); + batch.0.put_cf(block_cf, results_path, encode(&results)); } // Predecessor block epochs { let key = prefix_key .push(&"pred_epochs".to_owned()) .map_err(Error::KeyError)?; - batch.0.put_cf( - block_cf, - key.to_string(), - types::encode(&pred_epochs), - ); + batch + .0 + .put_cf(block_cf, key.to_string(), encode(&pred_epochs)); } // Address gen { let key = prefix_key .push(&"address_gen".to_owned()) .map_err(Error::KeyError)?; - batch.0.put_cf( - block_cf, - key.to_string(), - types::encode(&address_gen), - ); + batch + .0 + .put_cf(block_cf, key.to_string(), encode(&address_gen)); } // Block height - batch.0.put_cf(state_cf, "height", types::encode(&height)); + batch.0.put_cf(state_cf, "height", encode(&height)); Ok(()) } @@ -1180,7 +1154,7 @@ impl DB for RocksDB { .map_err(|e| Error::DBError(e.into_string()))?; match bytes { Some(b) => { - let root = types::decode(b).map_err(Error::CodingError)?; + let root = decode(b).map_err(Error::CodingError)?; merkle_tree_stores.set_root(st, root); } None => return Ok(None), @@ -1203,7 +1177,7 @@ impl DB for RocksDB { fn has_replay_protection_entry( &self, - hash: &namada::types::hash::Hash, + hash: &namada::core::hash::Hash, ) -> Result { let replay_protection_cf = self.get_column_family(REPLAY_PROTECTION_CF)?; @@ -1813,11 +1787,11 @@ mod imp { #[cfg(test)] mod test { - use namada::state::{MerkleTree, Sha256Hasher}; - use namada::types::address::{ + use namada::core::address::{ gen_established_address, EstablishedAddressGen, }; - use namada::types::storage::{BlockHash, Epoch, Epochs}; + use namada::core::storage::{BlockHash, Epoch, Epochs}; + use namada::state::{MerkleTree, Sha256Hasher}; use tempfile::tempdir; use test_log::test; @@ -2120,7 +2094,7 @@ mod test { db.0.get_cf(state_cf, "conversion_state".as_bytes()) .unwrap() .unwrap(); - assert_eq!(conversion_state, types::encode(&conversion_state_0)); + assert_eq!(conversion_state, encode(&conversion_state_0)); } #[test] diff --git a/crates/apps/src/lib/node/ledger/tendermint_node.rs b/crates/apps/src/lib/node/ledger/tendermint_node.rs index 87616d9df2..5f58df7c2f 100644 --- a/crates/apps/src/lib/node/ledger/tendermint_node.rs +++ b/crates/apps/src/lib/node/ledger/tendermint_node.rs @@ -4,10 +4,10 @@ use std::process::Stdio; use std::str::FromStr; use borsh_ext::BorshSerializeExt; -use namada::types::chain::ChainId; -use namada::types::key::*; -use namada::types::storage::BlockHeight; -use namada::types::time::DateTimeUtc; +use namada::core::chain::ChainId; +use namada::core::key::*; +use namada::core::storage::BlockHeight; +use namada::core::time::DateTimeUtc; use serde_json::json; use sha2::{Digest, Sha256}; use thiserror::Error; diff --git a/crates/apps/src/lib/wallet/defaults.rs b/crates/apps/src/lib/wallet/defaults.rs index 6b53ee5545..3b06bdfb13 100644 --- a/crates/apps/src/lib/wallet/defaults.rs +++ b/crates/apps/src/lib/wallet/defaults.rs @@ -13,11 +13,11 @@ mod dev { use std::collections::HashMap; use lazy_static::lazy_static; - use namada::ledger::{governance, pgf, pos}; - use namada::types::address::{ + use namada::core::address::{ apfel, btc, dot, eth, kartoffel, nam, schnitzel, Address, }; - use namada::types::key::*; + use namada::core::key::*; + use namada::ledger::{governance, pgf, pos}; use namada_sdk::wallet::alias::Alias; use namada_sdk::wallet::pre_genesis::ValidatorWallet; use namada_sdk::wallet::Wallet; @@ -78,7 +78,7 @@ mod dev { ("christel".into(), christel_address()), ("daewon".into(), daewon_address()), ("ester".into(), ester_address()), - ("masp".into(), namada::types::address::MASP), + ("masp".into(), namada::core::address::MASP), ] .into_iter() .collect(); diff --git a/crates/apps/src/lib/wallet/mod.rs b/crates/apps/src/lib/wallet/mod.rs index 3ed2969742..d157afdf83 100644 --- a/crates/apps/src/lib/wallet/mod.rs +++ b/crates/apps/src/lib/wallet/mod.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use std::{env, fs}; use namada::bip39::{Language, Mnemonic}; -use namada::types::key::*; +use namada::core::key::*; pub use namada_sdk::wallet::alias::Alias; use namada_sdk::wallet::fs::FsWalletStorage; use namada_sdk::wallet::store::Store; diff --git a/crates/apps/src/lib/wallet/pre_genesis.rs b/crates/apps/src/lib/wallet/pre_genesis.rs index 12f88ed99a..a39a8358f6 100644 --- a/crates/apps/src/lib/wallet/pre_genesis.rs +++ b/crates/apps/src/lib/wallet/pre_genesis.rs @@ -3,7 +3,7 @@ use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use fd_lock::RwLock; -use namada::types::key::SchemeType; +use namada::core::key::SchemeType; use namada_sdk::wallet::pre_genesis::{ ReadError, ValidatorStore, ValidatorWallet, }; diff --git a/crates/apps/src/lib/wallet/store.rs b/crates/apps/src/lib/wallet/store.rs index c721b02d9c..20021765a5 100644 --- a/crates/apps/src/lib/wallet/store.rs +++ b/crates/apps/src/lib/wallet/store.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use namada::types::key::*; +use namada::core::key::*; use namada_sdk::wallet::{ gen_secret_key, LoadStoreError, Store, ValidatorKeys, }; @@ -59,7 +59,7 @@ pub fn gen_validator_keys( #[cfg(test)] mod test_wallet { - use namada::types::address::Address; + use namada::core::address::Address; use super::*; diff --git a/crates/benches/README.md b/crates/benches/README.md index 9f73d2c15b..62980150ac 100644 --- a/crates/benches/README.md +++ b/crates/benches/README.md @@ -6,7 +6,7 @@ Measurements are taken on the elapsed wall-time. The benchmarks only focus on successful transactions and vps: in case of failure, the bench function shall panic to avoid timing incomplete execution paths. -In addition, this crate also contains benchmarks for `WrapperTx` (`namada::core::types::transaction::wrapper::WrapperTx`) validation and `host_env` (`namada::vm::host_env`) exposed functions that define the gas constants of `gas` (`namada::core::ledger::gas`). +In addition, this crate also contains benchmarks for `WrapperTx` (`namada::core::transaction::wrapper::WrapperTx`) validation and `host_env` (`namada::vm::host_env`) exposed functions that define the gas constants of `gas` (`namada::core::ledger::gas`). For more realistic results these benchmarks should be run on all the combination of supported OS/architecture. diff --git a/crates/benches/host_env.rs b/crates/benches/host_env.rs index 36a79cea05..a659e7aa51 100644 --- a/crates/benches/host_env.rs +++ b/crates/benches/host_env.rs @@ -1,8 +1,8 @@ use std::collections::{HashMap, HashSet}; use criterion::{criterion_group, criterion_main, Criterion}; -use namada::core::types::account::AccountPublicKeysMap; -use namada::core::types::address; +use namada::core::account::AccountPublicKeysMap; +use namada::core::address; use namada::ledger::storage::DB; use namada::token::{Amount, Transfer}; use namada::tx::Signature; @@ -183,7 +183,7 @@ fn write_log_read(c: &mut Criterion) { let mut shell = BenchShell::default(); for (key, value_len) in generate_random_keys_sized() { - let key = namada::core::types::storage::Key::parse(key).unwrap(); + let key = namada::core::storage::Key::parse(key).unwrap(); // Extract the throughput, together with the wall-time, so that we can // than invert it to calculate the desired metric (time/byte) // NOTE: criterion states that the throughput is measured on the @@ -214,7 +214,7 @@ fn storage_read(c: &mut Criterion) { let mut shell = BenchShell::default(); for (key, value_len) in generate_random_keys_sized() { - let key = namada::core::types::storage::Key::parse(key).unwrap(); + let key = namada::core::storage::Key::parse(key).unwrap(); // Extract the throughput, together with the wall-time, so that we can // than invert it to calculate the desired metric (time/byte) // NOTE: criterion states that the throughput is measured on the @@ -254,7 +254,7 @@ fn write_log_write(c: &mut Criterion) { let mut shell = BenchShell::default(); for (key, value_len) in generate_random_keys_sized() { - let key = namada::core::types::storage::Key::parse(key).unwrap(); + let key = namada::core::storage::Key::parse(key).unwrap(); // Extract the throughput, together with the wall-time, so that we can // than invert it to calculate the desired metric (time/byte) // NOTE: criterion states that the throughput is measured on the @@ -289,7 +289,7 @@ fn storage_write(c: &mut Criterion) { let mut shell = BenchShell::default(); for (key, value_len) in generate_random_keys_sized() { - let key = namada::core::types::storage::Key::parse(key).unwrap(); + let key = namada::core::storage::Key::parse(key).unwrap(); // Extract the throughput, together with the wall-time, so that we can // than invert it to calculate the desired metric (time/byte) // NOTE: criterion states that the throughput is measured on the diff --git a/crates/benches/native_vps.rs b/crates/benches/native_vps.rs index 5f0524699b..e4d94d764f 100644 --- a/crates/benches/native_vps.rs +++ b/crates/benches/native_vps.rs @@ -5,7 +5,9 @@ use std::str::FromStr; use criterion::{criterion_group, criterion_main, Criterion}; use masp_primitives::sapling::Node; -use namada::core::types::address::{self, Address}; +use namada::core::address::{self, Address, InternalAddress}; +use namada::core::eth_bridge_pool::{GasFee, PendingTransfer}; +use namada::core::masp::{TransferSource, TransferTarget}; use namada::eth_bridge::storage::whitelist; use namada::governance::pgf::storage::steward::StewardDetail; use namada::governance::storage::proposal::ProposalType; @@ -44,9 +46,6 @@ use namada::sdk::masp_primitives::transaction::Transaction; use namada::state::{Epoch, StorageRead, StorageWrite, TxIndex}; use namada::token::{Amount, Transfer}; use namada::tx::{Code, Section, Tx}; -use namada::types::address::InternalAddress; -use namada::types::eth_bridge_pool::{GasFee, PendingTransfer}; -use namada::types::masp::{TransferSource, TransferTarget}; use namada_apps::bench_utils::{ generate_foreign_key_tx, BenchShell, BenchShieldedCtx, ALBERT_PAYMENT_ADDRESS, ALBERT_SPENDING_KEY, BERTHA_PAYMENT_ADDRESS, @@ -353,7 +352,7 @@ fn ibc(c: &mut Criterion) { match bench_name { "open_connection" => { let _ = shell.init_ibc_client_state( - namada::core::types::storage::Key::from( + namada::core::storage::Key::from( Address::Internal(InternalAddress::Ibc).to_db_key(), ), ); @@ -648,7 +647,7 @@ fn pgf(c: &mut Criterion) { steward: defaults::albert_address(), commission: HashMap::from([( defaults::albert_address(), - namada::types::dec::Dec::zero(), + namada::core::dec::Dec::zero(), )]), }; shell.generate_tx( @@ -709,20 +708,21 @@ fn eth_bridge_nut(c: &mut Criterion) { read_native_erc20_address(&shell.wl_storage).unwrap(); let signed_tx = { - let data = PendingTransfer{ - transfer: namada::types::eth_bridge_pool::TransferToEthereum { - kind: namada::types::eth_bridge_pool::TransferToEthereumKind::Erc20, - asset: native_erc20_addres, - recipient: namada::types::ethereum_events::EthAddress([1u8; 20]), - sender: defaults::albert_address(), - amount: Amount::from(1), - }, - gas_fee: GasFee{ - amount: Amount::from(100), - payer: defaults::albert_address(), - token: shell.wl_storage.storage.native_token.clone(), - }, - }; + let data = PendingTransfer { + transfer: namada::core::eth_bridge_pool::TransferToEthereum { + kind: + namada::core::eth_bridge_pool::TransferToEthereumKind::Erc20, + asset: native_erc20_addres, + recipient: namada::core::ethereum_events::EthAddress([1u8; 20]), + sender: defaults::albert_address(), + amount: Amount::from(1), + }, + gas_fee: GasFee { + amount: Amount::from(100), + payer: defaults::albert_address(), + token: shell.wl_storage.storage.native_token.clone(), + }, + }; shell.generate_tx( TX_BRIDGE_POOL_WASM, data, @@ -778,20 +778,21 @@ fn eth_bridge(c: &mut Criterion) { read_native_erc20_address(&shell.wl_storage).unwrap(); let signed_tx = { - let data = PendingTransfer{ - transfer: namada::types::eth_bridge_pool::TransferToEthereum { - kind: namada::types::eth_bridge_pool::TransferToEthereumKind::Erc20, - asset: native_erc20_addres, - recipient: namada::types::ethereum_events::EthAddress([1u8; 20]), - sender: defaults::albert_address(), - amount: Amount::from(1), - }, - gas_fee: GasFee{ - amount: Amount::from(100), - payer: defaults::albert_address(), - token: shell.wl_storage.storage.native_token.clone(), - }, - }; + let data = PendingTransfer { + transfer: namada::core::eth_bridge_pool::TransferToEthereum { + kind: + namada::core::eth_bridge_pool::TransferToEthereumKind::Erc20, + asset: native_erc20_addres, + recipient: namada::core::ethereum_events::EthAddress([1u8; 20]), + sender: defaults::albert_address(), + amount: Amount::from(1), + }, + gas_fee: GasFee { + amount: Amount::from(100), + payer: defaults::albert_address(), + token: shell.wl_storage.storage.native_token.clone(), + }, + }; shell.generate_tx( TX_BRIDGE_POOL_WASM, data, @@ -875,20 +876,21 @@ fn eth_bridge_pool(c: &mut Criterion) { shell.wl_storage.write(&denom_key, 0).unwrap(); let signed_tx = { - let data = PendingTransfer{ - transfer: namada::types::eth_bridge_pool::TransferToEthereum { - kind: namada::types::eth_bridge_pool::TransferToEthereumKind::Erc20, - asset: native_erc20_addres, - recipient: namada::types::ethereum_events::EthAddress([1u8; 20]), - sender: defaults::albert_address(), - amount: Amount::from(1), - }, - gas_fee: GasFee{ - amount: Amount::from(100), - payer: defaults::albert_address(), - token: shell.wl_storage.storage.native_token.clone(), - }, - }; + let data = PendingTransfer { + transfer: namada::core::eth_bridge_pool::TransferToEthereum { + kind: + namada::core::eth_bridge_pool::TransferToEthereumKind::Erc20, + asset: native_erc20_addres, + recipient: namada::core::ethereum_events::EthAddress([1u8; 20]), + sender: defaults::albert_address(), + amount: Amount::from(1), + }, + gas_fee: GasFee { + amount: Amount::from(100), + payer: defaults::albert_address(), + token: shell.wl_storage.storage.native_token.clone(), + }, + }; shell.generate_tx( TX_BRIDGE_POOL_WASM, data, @@ -1137,7 +1139,7 @@ fn ibc_vp_validate_action(c: &mut Criterion) { match bench_name { "open_connection" => { let _ = shell.init_ibc_client_state( - namada::core::types::storage::Key::from( + namada::core::storage::Key::from( Address::Internal(InternalAddress::Ibc).to_db_key(), ), ); @@ -1235,7 +1237,7 @@ fn ibc_vp_execute_action(c: &mut Criterion) { match bench_name { "open_connection" => { let _ = shell.init_ibc_client_state( - namada::core::types::storage::Key::from( + namada::core::storage::Key::from( Address::Internal(InternalAddress::Ibc).to_db_key(), ), ); diff --git a/crates/benches/process_wrapper.rs b/crates/benches/process_wrapper.rs index 4a12b34836..4264748e53 100644 --- a/crates/benches/process_wrapper.rs +++ b/crates/benches/process_wrapper.rs @@ -1,12 +1,12 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use namada::core::types::address; +use namada::core::address; +use namada::core::key::RefTo; +use namada::core::storage::BlockHeight; +use namada::core::time::DateTimeUtc; use namada::ledger::storage::TempWlStorage; use namada::token::{Amount, DenominatedAmount, Transfer}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::Signature; -use namada::types::key::RefTo; -use namada::types::storage::BlockHeight; -use namada::types::time::DateTimeUtc; use namada_apps::bench_utils::{BenchShell, TX_TRANSFER_WASM}; use namada_apps::node::ledger::shell::process_proposal::ValidationMeta; use namada_apps::wallet::defaults; diff --git a/crates/benches/txs.rs b/crates/benches/txs.rs index 44749908c3..22119c3c5c 100644 --- a/crates/benches/txs.rs +++ b/crates/benches/txs.rs @@ -3,9 +3,15 @@ use std::str::FromStr; use criterion::{criterion_group, criterion_main, Criterion}; use namada::account::{InitAccount, UpdateAccount}; -use namada::core::types::key::{ - common, SecretKey as SecretKeyInterface, SigScheme, +use namada::core::address::{self, Address}; +use namada::core::eth_bridge_pool::{GasFee, PendingTransfer}; +use namada::core::hash::Hash; +use namada::core::key::{ + common, ed25519, secp256k1, PublicKey, RefTo, + SecretKey as SecretKeyInterface, SigScheme, }; +use namada::core::masp::{TransferSource, TransferTarget}; +use namada::core::storage::Key; use namada::governance::pgf::storage::steward::StewardDetail; use namada::governance::storage::proposal::ProposalType; use namada::governance::storage::vote::ProposalVote; @@ -31,12 +37,6 @@ use namada::tx::data::pos::{ MetaDataChange, Redelegation, Withdraw, }; use namada::tx::{Code, Section}; -use namada::types::address::{self, Address}; -use namada::types::eth_bridge_pool::{GasFee, PendingTransfer}; -use namada::types::hash::Hash; -use namada::types::key::{ed25519, secp256k1, PublicKey, RefTo}; -use namada::types::masp::{TransferSource, TransferTarget}; -use namada::types::storage::Key; use namada_apps::bench_utils::{ BenchShell, BenchShieldedCtx, ALBERT_PAYMENT_ADDRESS, ALBERT_SPENDING_KEY, BERTHA_PAYMENT_ADDRESS, TX_BECOME_VALIDATOR_WASM, TX_BOND_WASM, @@ -617,8 +617,8 @@ fn become_validator(c: &mut Criterion) { eth_cold_key, eth_hot_key, protocol_key, - commission_rate: namada::types::dec::Dec::default(), - max_commission_rate_change: namada::types::dec::Dec::default(), + commission_rate: namada::core::dec::Dec::default(), + max_commission_rate_change: namada::core::dec::Dec::default(), email: "null@null.net".to_string(), description: None, website: None, @@ -647,7 +647,7 @@ fn become_validator(c: &mut Criterion) { shell .wl_storage .write_bytes( - &namada::types::storage::Key::validity_predicate( + &namada::core::storage::Key::validity_predicate( &address, ), vec![], @@ -667,7 +667,7 @@ fn change_validator_commission(c: &mut Criterion) { TX_CHANGE_VALIDATOR_COMMISSION_WASM, CommissionChange { validator: defaults::validator_address(), - new_rate: namada::types::dec::Dec::new(6, 2).unwrap(), + new_rate: namada::core::dec::Dec::new(6, 2).unwrap(), }, None, None, @@ -794,8 +794,8 @@ fn ibc(c: &mut Criterion) { match bench_name { "open_connection" => { let _ = shell.init_ibc_client_state( - namada::core::types::storage::Key::from( - Address::Internal(namada::types::address::InternalAddress::Ibc).to_db_key(), + namada::core::storage::Key::from( + Address::Internal(namada::core::address::InternalAddress::Ibc).to_db_key(), ), ); } @@ -866,10 +866,10 @@ fn tx_bridge_pool(c: &mut Criterion) { let shell = BenchShell::default(); let data = PendingTransfer { - transfer: namada::types::eth_bridge_pool::TransferToEthereum { - kind: namada::types::eth_bridge_pool::TransferToEthereumKind::Erc20, + transfer: namada::core::eth_bridge_pool::TransferToEthereum { + kind: namada::core::eth_bridge_pool::TransferToEthereumKind::Erc20, asset: read_native_erc20_address(&shell.wl_storage).unwrap(), - recipient: namada::types::ethereum_events::EthAddress([1u8; 20]), + recipient: namada::core::ethereum_events::EthAddress([1u8; 20]), sender: defaults::albert_address(), amount: Amount::from(1), }, @@ -941,7 +941,7 @@ fn update_steward_commission(c: &mut Criterion) { steward: defaults::albert_address(), commission: HashMap::from([( defaults::albert_address(), - namada::types::dec::Dec::zero(), + namada::core::dec::Dec::zero(), )]), }; let tx = shell.generate_tx( diff --git a/crates/benches/vps.rs b/crates/benches/vps.rs index 35dc7ca219..352fe39f25 100644 --- a/crates/benches/vps.rs +++ b/crates/benches/vps.rs @@ -2,19 +2,18 @@ use std::collections::BTreeSet; use criterion::{criterion_group, criterion_main, Criterion}; use namada::account::UpdateAccount; -use namada::core::types::address::{self, Address}; -use namada::core::types::key::{ - common, SecretKey as SecretKeyInterface, SigScheme, +use namada::core::address::{self, Address}; +use namada::core::hash::Hash; +use namada::core::key::{ + common, ed25519, SecretKey as SecretKeyInterface, SigScheme, }; +use namada::core::storage::{Key, TxIndex}; use namada::governance::storage::vote::ProposalVote; use namada::governance::VoteProposalData; use namada::ledger::gas::{TxGasMeter, VpGasMeter}; use namada::token::{Amount, Transfer}; use namada::tx::data::pos::{Bond, CommissionChange}; use namada::tx::{Code, Section}; -use namada::types::hash::Hash; -use namada::types::key::ed25519; -use namada::types::storage::{Key, TxIndex}; use namada::vm::wasm::run; use namada_apps::bench_utils::{ generate_foreign_key_tx, BenchShell, TX_BOND_WASM, @@ -383,7 +382,7 @@ fn vp_validator(c: &mut Criterion) { TX_CHANGE_VALIDATOR_COMMISSION_WASM, CommissionChange { validator: defaults::validator_address(), - new_rate: namada::types::dec::Dec::new(6, 2).unwrap(), + new_rate: namada::core::dec::Dec::new(6, 2).unwrap(), }, None, None, diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 67271d6728..bb4437f87d 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -46,14 +46,12 @@ index-set.workspace = true k256.workspace = true masp_primitives.workspace = true num256.workspace = true -num-derive.workspace = true num_enum = "0.7.0" num-integer = "0.1.45" num-rational.workspace = true num-traits.workspace = true primitive-types.workspace = true proptest = {workspace = true, optional = true} -prost.workspace = true prost-types.workspace = true rand = {version = "0.8", optional = true} rand_core = {version = "0.6", optional = true} diff --git a/crates/core/src/address.rs b/crates/core/src/address.rs index a0d911e2c3..9cd8f3c64d 100644 --- a/crates/core/src/address.rs +++ b/crates/core/src/address.rs @@ -14,13 +14,12 @@ use data_encoding::HEXUPPER; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; +use crate::ethereum_events::EthAddress; use crate::ibc::primitives::Signer; -use crate::impl_display_and_from_str_via_format; -use crate::types::ethereum_events::EthAddress; -use crate::types::ibc::IbcTokenHash; -use crate::types::key::PublicKeyHash; -use crate::types::token::Denomination; -use crate::types::{key, string_encoding}; +use crate::ibc::IbcTokenHash; +use crate::key::PublicKeyHash; +use crate::token::Denomination; +use crate::{impl_display_and_from_str_via_format, key, string_encoding}; /// The length of an established [`Address`] encoded with Borsh. pub const ESTABLISHED_ADDRESS_BYTES_LEN: usize = 21; @@ -44,7 +43,7 @@ pub const HASH_LEN: usize = 20; /// use sha2::Digest; /// assert_eq!( /// sha2::Sha256::output_size(), -/// namada_core::types::address::SHA_HASH_LEN +/// namada_core::address::SHA_HASH_LEN /// ); /// ``` pub const SHA_HASH_LEN: usize = 32; @@ -366,8 +365,7 @@ impl TryFrom for Address { // sending a token from a spending key, it has been already // replaced with the MASP address. Address::decode(signer.as_ref()).or( - match crate::types::masp::PaymentAddress::from_str(signer.as_ref()) - { + match crate::masp::PaymentAddress::from_str(signer.as_ref()) { Ok(_) => Ok(MASP), Err(_) => Err(DecodeError::InvalidInnerEncoding(format!( "Invalid address for IBC transfer: {signer}" @@ -750,7 +748,7 @@ pub mod testing { use proptest::prelude::*; use super::*; - use crate::types::key::*; + use crate::key::*; /// Generate a new established address. pub fn gen_established_address() -> Address { @@ -899,13 +897,13 @@ pub mod testing { } fn arb_erc20() -> InternalAddress { - use crate::types::ethereum_events::testing::arbitrary_eth_address; + use crate::ethereum_events::testing::arbitrary_eth_address; // TODO: generate random erc20 addr data InternalAddress::Erc20(arbitrary_eth_address()) } fn arb_nut() -> InternalAddress { - use crate::types::ethereum_events::testing::arbitrary_eth_address; + use crate::ethereum_events::testing::arbitrary_eth_address; // TODO: generate random erc20 addr data InternalAddress::Nut(arbitrary_eth_address()) } diff --git a/crates/core/src/dec.rs b/crates/core/src/dec.rs index 5b32b484e5..c8720e4b8e 100644 --- a/crates/core/src/dec.rs +++ b/crates/core/src/dec.rs @@ -14,8 +14,8 @@ use num_traits::CheckedMul; use serde::{Deserialize, Serialize}; use super::token::NATIVE_MAX_DECIMAL_PLACES; -use crate::types::token::{Amount, Change}; -use crate::types::uint::{Uint, I256}; +use crate::token::{Amount, Change}; +use crate::uint::{Uint, I256}; /// The number of Dec places for PoS rational calculations pub const POS_DECIMAL_PRECISION: u8 = 12; @@ -69,7 +69,7 @@ impl Dec { /// /// Example: /// ``` - /// use namada_core::types::dec::Dec; + /// use namada_core::dec::Dec; /// /// let x = Dec::new(3, 1).unwrap(); // Represents 0.3 /// let y = Dec::new(2, 1).unwrap(); // Represents 0.2 @@ -549,7 +549,7 @@ pub mod testing { #[cfg(test)] mod test_dec { use super::*; - use crate::types::token::{Amount, Change}; + use crate::token::{Amount, Change}; #[derive(Debug, Serialize, Deserialize)] struct SerializerTest { diff --git a/crates/core/src/eth_abi.rs b/crates/core/src/eth_abi.rs index 886b5b9c46..62fe0169fe 100644 --- a/crates/core/src/eth_abi.rs +++ b/crates/core/src/eth_abi.rs @@ -7,8 +7,8 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; #[doc(inline)] pub use ethabi::token::Token; -use crate::types::keccak::{keccak_hash, KeccakHash}; -use crate::types::key::{Signable, SignableEthMessage}; +use crate::keccak::{keccak_hash, KeccakHash}; +use crate::key::{Signable, SignableEthMessage}; /// A container for data types that are able to be Ethereum ABI-encoded. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, BorshSchema)] @@ -129,7 +129,7 @@ mod tests { use tiny_keccak::{Hasher, Keccak}; use super::*; - use crate::types::ethereum_events::EthAddress; + use crate::ethereum_events::EthAddress; /// Checks if we get the same result as `abi.encode`, for some given /// input data. diff --git a/crates/core/src/eth_bridge_pool.rs b/crates/core/src/eth_bridge_pool.rs index 83bcef6c6a..b2d9c82986 100644 --- a/crates/core/src/eth_bridge_pool.rs +++ b/crates/core/src/eth_bridge_pool.rs @@ -13,14 +13,14 @@ use super::address::InternalAddress; use super::keccak::KeccakHash; use super::storage::{self, KeySeg}; use crate as namada_core; // This is needed for `StorageKeys` macro -use crate::types::address::Address; -use crate::types::eth_abi::Encode; -use crate::types::ethereum_events::{ +use crate::address::Address; +use crate::eth_abi::Encode; +use crate::ethereum_events::{ EthAddress, TransferToEthereum as TransferToEthereumEvent, }; -use crate::types::hash::Hash as HashDigest; -use crate::types::storage::{DbKeySeg, Key}; -use crate::types::token::Amount; +use crate::hash::Hash as HashDigest; +use crate::storage::{DbKeySeg, Key}; +use crate::token::Amount; /// The main address of the Ethereum bridge pool pub const BRIDGE_POOL_ADDRESS: Address = @@ -364,11 +364,11 @@ pub mod testing { use proptest::strategy::Strategy; use super::*; - use crate::types::address::testing::{ + use crate::address::testing::{ arb_established_address, arb_non_internal_address, }; - use crate::types::ethereum_events::testing::arb_eth_address; - use crate::types::token::testing::arb_amount; + use crate::ethereum_events::testing::arb_eth_address; + use crate::token::testing::arb_amount; prop_compose! { /// Generate an arbitrary pending transfer @@ -434,8 +434,8 @@ pub mod testing { #[cfg(test)] mod test_eth_bridge_pool_types { use super::*; - use crate::types::address::nam; - use crate::types::address::testing::established_address_1; + use crate::address::nam; + use crate::address::testing::established_address_1; /// Test that [`PendingTransfer`] and [`TransferToEthereum`] /// have the same keccak hash, after being ABI encoded. diff --git a/crates/core/src/ethereum_events.rs b/crates/core/src/ethereum_events.rs index 8569b118e4..9e55df2b69 100644 --- a/crates/core/src/ethereum_events.rs +++ b/crates/core/src/ethereum_events.rs @@ -12,13 +12,13 @@ use ethabi::Token; use eyre::{eyre, Context}; use serde::{Deserialize, Serialize}; -use crate::types::address::Address; -use crate::types::eth_abi::Encode; -use crate::types::ethereum_structs::Erc20Transfer; -use crate::types::hash::Hash; -use crate::types::keccak::KeccakHash; -use crate::types::storage::{DbKeySeg, KeySeg}; -use crate::types::token::Amount; +use crate::address::Address; +use crate::eth_abi::Encode; +use crate::ethereum_structs::Erc20Transfer; +use crate::hash::Hash; +use crate::keccak::KeccakHash; +use crate::storage::{DbKeySeg, KeySeg}; +use crate::token::Amount; /// Namada native type to replace the ethabi::Uint type #[derive( @@ -197,9 +197,9 @@ impl From for String { } impl KeySeg for EthAddress { - fn parse(string: String) -> crate::types::storage::Result { + fn parse(string: String) -> crate::storage::Result { Self::from_str(string.as_str()) - .map_err(|_| crate::types::storage::Error::ParseKeySeg(string)) + .map_err(|_| crate::storage::Error::ParseKeySeg(string)) } fn raw(&self) -> String { @@ -373,7 +373,7 @@ impl From for TransferToEthereum { Self { amount: { let uint = { - use crate::types::uint::Uint as NamadaUint; + use crate::uint::Uint as NamadaUint; let mut num_buf = [0; 32]; transfer.amount.to_little_endian(&mut num_buf); NamadaUint::from_little_endian(&num_buf) @@ -450,7 +450,7 @@ pub mod testing { use proptest::prop_compose; use super::*; - use crate::types::token::{self, Amount}; + use crate::token::{self, Amount}; pub const DAI_ERC20_ETH_ADDRESS_CHECKSUMMED: &str = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; diff --git a/crates/core/src/ethereum_structs.rs b/crates/core/src/ethereum_structs.rs index 5b29e0e588..e2bd8a5ce0 100644 --- a/crates/core/src/ethereum_structs.rs +++ b/crates/core/src/ethereum_structs.rs @@ -9,7 +9,7 @@ pub use ethbridge_structs::*; use num256::Uint256; use serde::{Deserialize, Serialize}; -use crate::types::keccak::KeccakHash; +use crate::keccak::KeccakHash; /// Status of some Bridge pool transfer. #[derive( diff --git a/crates/core/src/event.rs b/crates/core/src/event.rs index 5db1de6131..d82121de50 100644 --- a/crates/core/src/event.rs +++ b/crates/core/src/event.rs @@ -8,8 +8,8 @@ use std::str::FromStr; use thiserror::Error; use crate::borsh::{BorshDeserialize, BorshSerialize}; -use crate::types::ethereum_structs::{BpTransferStatus, EthBridgeEvent}; -use crate::types::ibc::IbcEvent; +use crate::ethereum_structs::{BpTransferStatus, EthBridgeEvent}; +use crate::ibc::IbcEvent; /// Used in sub-systems that may emit events. pub trait EmitEvents { diff --git a/crates/core/src/ibc.rs b/crates/core/src/ibc.rs index f517c84363..a60cd1d8ed 100644 --- a/crates/core/src/ibc.rs +++ b/crates/core/src/ibc.rs @@ -7,6 +7,7 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use borsh_ext::BorshSerializeExt; use data_encoding::{DecodePartial, HEXLOWER, HEXLOWER_PERMISSIVE, HEXUPPER}; +pub use ibc::*; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -17,9 +18,9 @@ use crate::ibc::core::handler::types::events::{ Error as IbcEventError, IbcEvent as RawIbcEvent, }; use crate::ibc::primitives::proto::Protobuf; +use crate::masp::PaymentAddress; use crate::tendermint::abci::Event as AbciEvent; -use crate::types::masp::PaymentAddress; -use crate::types::token::Transfer; +use crate::token::Transfer; /// The event type defined in ibc-rs for receiving a token pub const EVENT_TYPE_PACKET: &str = "fungible_token_packet"; @@ -166,7 +167,7 @@ pub enum Error { } /// Conversion functions result -pub type Result = std::result::Result; +type Result = std::result::Result; impl TryFrom for IbcEvent { type Error = Error; diff --git a/crates/core/src/keccak.rs b/crates/core/src/keccak.rs index f6fc15724d..b2e85ebd01 100644 --- a/crates/core/src/keccak.rs +++ b/crates/core/src/keccak.rs @@ -11,8 +11,8 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; pub use tiny_keccak::{Hasher, Keccak}; -use crate::types::eth_abi::Encode; -use crate::types::hash::{Hash, HASH_LENGTH}; +use crate::eth_abi::Encode; +use crate::hash::{Hash, HASH_LENGTH}; /// Errors for converting / parsing Keccak hashes #[allow(missing_docs)] diff --git a/crates/core/src/key/common.rs b/crates/core/src/key/common.rs index 7db4641879..05023548a4 100644 --- a/crates/core/src/key/common.rs +++ b/crates/core/src/key/common.rs @@ -17,10 +17,9 @@ use super::{ ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, VerifySigError, }; -use crate::impl_display_and_from_str_via_format; -use crate::types::ethereum_events::EthAddress; -use crate::types::key::{SignableBytes, StorageHasher}; -use crate::types::string_encoding; +use crate::ethereum_events::EthAddress; +use crate::key::{SignableBytes, StorageHasher}; +use crate::{impl_display_and_from_str_via_format, string_encoding}; /// Public key #[derive( @@ -456,14 +455,14 @@ impl super::SigScheme for SigScheme { #[cfg(test)] mod tests { use super::*; - use crate::types::key::ed25519; + use crate::key::ed25519; /// Run `cargo test gen_ed25519_keypair -- --nocapture` to generate a /// new ed25519 keypair wrapped in `common` key types. #[test] fn gen_ed25519_keypair() { let secret_key = - SecretKey::Ed25519(crate::types::key::testing::gen_keypair::< + SecretKey::Ed25519(crate::key::testing::gen_keypair::< ed25519::SigScheme, >()); let public_key = secret_key.to_public(); diff --git a/crates/core/src/key/ed25519.rs b/crates/core/src/key/ed25519.rs index 2e118fe90e..ea7cc46e6f 100644 --- a/crates/core/src/key/ed25519.rs +++ b/crates/core/src/key/ed25519.rs @@ -19,7 +19,7 @@ use super::{ ParsePublicKeyError, ParseSecretKeyError, ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, SignableBytes, VerifySigError, }; -use crate::types::key::StorageHasher; +use crate::key::StorageHasher; const PUBLIC_KEY_LENGTH: usize = 32; const SECRET_KEY_LENGTH: usize = 32; diff --git a/crates/core/src/key/mod.rs b/crates/core/src/key/mod.rs index b07efc0ba4..0c32560682 100644 --- a/crates/core/src/key/mod.rs +++ b/crates/core/src/key/mod.rs @@ -17,9 +17,9 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use thiserror::Error; -use crate::types::address; -use crate::types::hash::{KeccakHasher, Sha256Hasher, StorageHasher}; -use crate::types::keccak::{keccak_hash, KeccakHash}; +use crate::address; +use crate::hash::{KeccakHasher, Sha256Hasher, StorageHasher}; +use crate::keccak::{keccak_hash, KeccakHash}; /// Represents an error in signature verification #[allow(missing_docs)] @@ -458,25 +458,25 @@ impl SignableBytes for &[u8] {} impl SignableBytes for [u8; N] {} impl SignableBytes for &[u8; N] {} -impl SignableBytes for crate::types::hash::Hash { +impl SignableBytes for crate::hash::Hash { fn signable_hash(&self) -> [u8; 32] { self.0 } } -impl SignableBytes for &crate::types::hash::Hash { +impl SignableBytes for &crate::hash::Hash { fn signable_hash(&self) -> [u8; 32] { self.0 } } -impl SignableBytes for crate::types::keccak::KeccakHash { +impl SignableBytes for crate::keccak::KeccakHash { fn signable_hash(&self) -> [u8; 32] { self.0 } } -impl SignableBytes for &crate::types::keccak::KeccakHash { +impl SignableBytes for &crate::keccak::KeccakHash { fn signable_hash(&self) -> [u8; 32] { self.0 } @@ -491,7 +491,7 @@ pub mod testing { use rand::{thread_rng, SeedableRng}; use super::SigScheme; - use crate::types::key::*; + use crate::key::*; /// Generate an arbitrary public key pub fn arb_pk() diff --git a/crates/core/src/key/secp256k1.rs b/crates/core/src/key/secp256k1.rs index 06ae2c4216..65a569b1a9 100644 --- a/crates/core/src/key/secp256k1.rs +++ b/crates/core/src/key/secp256k1.rs @@ -24,9 +24,9 @@ use super::{ ParsePublicKeyError, ParseSecretKeyError, ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, SignableBytes, VerifySigError, }; -use crate::types::eth_abi::Encode; -use crate::types::ethereum_events::EthAddress; -use crate::types::key::StorageHasher; +use crate::eth_abi::Encode; +use crate::ethereum_events::EthAddress; +use crate::key::StorageHasher; /// The provided constant is for a traditional /// signature on this curve. For Ethereum, an extra byte is included diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index c7580895ea..667aae67aa 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -10,7 +10,7 @@ pub mod bytes; pub mod event; pub mod hints; -pub use {ibc, masp_primitives, tendermint, tendermint_proto}; +pub use {masp_primitives, tendermint, tendermint_proto}; /// Borsh binary encoding (re-exported) from official crate with custom ext. pub mod borsh { pub use borsh::*; diff --git a/crates/core/src/masp.rs b/crates/core/src/masp.rs index 61b63dab60..fcee87ac71 100644 --- a/crates/core/src/masp.rs +++ b/crates/core/src/masp.rs @@ -9,14 +9,14 @@ use masp_primitives::asset_type::AssetType; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; +use crate::address::{Address, DecodeError, HASH_HEX_LEN, MASP}; use crate::impl_display_and_from_str_via_format; -use crate::types::address::{Address, DecodeError, HASH_HEX_LEN, MASP}; -use crate::types::storage::Epoch; -use crate::types::string_encoding::{ +use crate::storage::Epoch; +use crate::string_encoding::{ self, MASP_EXT_FULL_VIEWING_KEY_HRP, MASP_EXT_SPENDING_KEY_HRP, MASP_PAYMENT_ADDRESS_HRP, }; -use crate::types::token::{Denomination, MaspDigitPos}; +use crate::token::{Denomination, MaspDigitPos}; /// The plain representation of a MASP aaset #[derive( diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 1ac99d11b4..8eec976070 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -16,13 +16,13 @@ use serde::{Deserialize, Serialize}; use thiserror::Error; use super::key::common; +use crate::address::{self, Address}; use crate::bytes::ByteBuf; +use crate::ethereum_events::{GetEventNonce, TransfersToNamada, Uint}; +use crate::hash::Hash; use crate::hints; -use crate::types::address::{self, Address}; -use crate::types::ethereum_events::{GetEventNonce, TransfersToNamada, Uint}; -use crate::types::hash::Hash; -use crate::types::keccak::{KeccakHash, TryFromError}; -use crate::types::time::DateTimeUtc; +use crate::keccak::{KeccakHash, TryFromError}; +use crate::time::DateTimeUtc; /// The maximum size of an IBC key (in bytes) allowed in merkle-ized storage pub const IBC_KEY_LIMIT: usize = 240; @@ -900,9 +900,8 @@ impl KeySeg for Address { impl KeySeg for Hash { fn parse(seg: String) -> Result { - seg.try_into().map_err(|e: crate::types::hash::Error| { - Error::ParseKeySeg(e.to_string()) - }) + seg.try_into() + .map_err(|e: crate::hash::Error| Error::ParseKeySeg(e.to_string())) } fn raw(&self) -> String { @@ -1477,7 +1476,7 @@ pub mod tests { use proptest::prelude::*; use super::*; - use crate::types::address::testing::arb_address; + use crate::address::testing::arb_address; proptest! { /// Tests that any key that doesn't contain reserved prefixes is valid. @@ -1906,9 +1905,7 @@ pub mod testing { use proptest::prelude::*; use super::*; - use crate::types::address::testing::{ - arb_address, arb_non_internal_address, - }; + use crate::address::testing::{arb_address, arb_non_internal_address}; prop_compose! { /// Generate an arbitrary epoch diff --git a/crates/core/src/string_encoding.rs b/crates/core/src/string_encoding.rs index 47db158d85..1e0c37806f 100644 --- a/crates/core/src/string_encoding.rs +++ b/crates/core/src/string_encoding.rs @@ -112,19 +112,15 @@ macro_rules! impl_display_and_from_str_via_format { ($t:path) => { impl std::fmt::Display for $t { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - $crate::types::string_encoding::Format::encode(self) - ) + write!(f, "{}", $crate::string_encoding::Format::encode(self)) } } impl std::str::FromStr for $t { - type Err = $crate::types::string_encoding::DecodeError; + type Err = $crate::string_encoding::DecodeError; fn from_str(s: &str) -> std::result::Result { - $crate::types::string_encoding::Format::decode(s) + $crate::string_encoding::Format::decode(s) } } }; diff --git a/crates/core/src/token.rs b/crates/core/src/token.rs index 3d2429c151..fb7d781a88 100644 --- a/crates/core/src/token.rs +++ b/crates/core/src/token.rs @@ -12,13 +12,13 @@ use ethabi::ethereum_types::U256; use serde::{Deserialize, Serialize}; use thiserror::Error; +use crate::address::Address; +use crate::dec::{Dec, POS_DECIMAL_PRECISION}; +use crate::hash::Hash; use crate::ibc::apps::transfer::types::Amount as IbcAmount; -use crate::types::address::Address; -use crate::types::dec::{Dec, POS_DECIMAL_PRECISION}; -use crate::types::hash::Hash; -use crate::types::storage; -use crate::types::storage::{DbKeySeg, KeySeg}; -use crate::types::uint::{self, Uint, I256}; +use crate::storage; +use crate::storage::{DbKeySeg, KeySeg}; +use crate::uint::{self, Uint, I256}; /// Amount in micro units. For different granularity another representation /// might be more appropriate. @@ -1020,7 +1020,7 @@ pub mod testing { use proptest::prelude::*; use super::*; - use crate::types::address::testing::{ + use crate::address::testing::{ arb_established_address, arb_non_internal_address, }; diff --git a/crates/core/src/uint.rs b/crates/core/src/uint.rs index e13cb9ce1b..4633720fea 100644 --- a/crates/core/src/uint.rs +++ b/crates/core/src/uint.rs @@ -12,8 +12,8 @@ use num_traits::{CheckedAdd, CheckedMul, CheckedSub}; use uint::construct_uint; use super::dec::{Dec, POS_DECIMAL_PRECISION}; -use crate::types::token; -use crate::types::token::{Amount, AmountParseError, MaspDigitPos}; +use crate::token; +use crate::token::{Amount, AmountParseError, MaspDigitPos}; /// The value zero. pub const ZERO: Uint = Uint::from_u64(0); diff --git a/crates/core/src/voting_power.rs b/crates/core/src/voting_power.rs index 014e0bade9..b4164b58f0 100644 --- a/crates/core/src/voting_power.rs +++ b/crates/core/src/voting_power.rs @@ -14,8 +14,8 @@ use num_traits::ops::checked::CheckedAdd; use serde::de::Visitor; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; -use crate::types::token::Amount; -use crate::types::uint::Uint; +use crate::token::Amount; +use crate::uint::Uint; /// Namada voting power, normalized to the range `0 - 2^32`. #[derive( diff --git a/crates/encoding_spec/src/main.rs b/crates/encoding_spec/src/main.rs index d6bb9df06c..dcd8c13620 100644 --- a/crates/encoding_spec/src/main.rs +++ b/crates/encoding_spec/src/main.rs @@ -25,12 +25,12 @@ use itertools::Itertools; use lazy_static::lazy_static; use madato::types::TableRow; use namada::account; +use namada::core::address::Address; +use namada::core::key::ed25519::{PublicKey, Signature}; +use namada::core::storage::{self, Epoch}; +use namada::core::token; use namada::ledger::parameters::Parameters; use namada::tx::data::{pos, TxType, WrapperTx}; -use namada::types::address::Address; -use namada::types::key::ed25519::{PublicKey, Signature}; -use namada::types::storage::{self, Epoch}; -use namada::types::token; /// This generator will write output into this `docs` file. const OUTPUT_PATH: &str = diff --git a/crates/ethereum_bridge/src/lib.rs b/crates/ethereum_bridge/src/lib.rs index 955ba19887..eef7126bab 100644 --- a/crates/ethereum_bridge/src/lib.rs +++ b/crates/ethereum_bridge/src/lib.rs @@ -6,5 +6,5 @@ pub mod storage; #[cfg(any(test, feature = "testing"))] pub mod test_utils; -pub use namada_core::types::address::ETH_BRIDGE as ADDRESS; +pub use namada_core::address::ETH_BRIDGE as ADDRESS; pub use namada_trans_token as token; diff --git a/crates/ethereum_bridge/src/oracle/config.rs b/crates/ethereum_bridge/src/oracle/config.rs index 33b66a34d7..37e5a94cf9 100644 --- a/crates/ethereum_bridge/src/oracle/config.rs +++ b/crates/ethereum_bridge/src/oracle/config.rs @@ -1,8 +1,8 @@ //! Configuration for an oracle. use std::num::NonZeroU64; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::ethereum_structs; +use namada_core::ethereum_events::EthAddress; +use namada_core::ethereum_structs; /// Configuration for an oracle. #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] diff --git a/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs b/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs index afd307fb87..47679b74da 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs @@ -1,11 +1,11 @@ use std::collections::{HashMap, HashSet}; use eyre::Result; -use namada_core::types::address::Address; -use namada_core::types::keccak::keccak_hash; -use namada_core::types::key::{common, SignableEthMessage}; -use namada_core::types::storage::BlockHeight; -use namada_core::types::token::Amount; +use namada_core::address::Address; +use namada_core::keccak::keccak_hash; +use namada_core::key::{common, SignableEthMessage}; +use namada_core::storage::BlockHeight; +use namada_core::token::Amount; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::{StorageRead, StorageWrite}; @@ -259,11 +259,11 @@ mod test_apply_bp_roots_to_storage { use assert_matches::assert_matches; use borsh::BorshDeserialize; - use namada_core::types::address; - use namada_core::types::ethereum_events::Uint; - use namada_core::types::keccak::{keccak_hash, KeccakHash}; - use namada_core::types::storage::Key; - use namada_core::types::voting_power::FractionalVotingPower; + use namada_core::address; + use namada_core::ethereum_events::Uint; + use namada_core::keccak::{keccak_hash, KeccakHash}; + use namada_core::storage::Key; + use namada_core::voting_power::FractionalVotingPower; use namada_proof_of_stake::parameters::OwnedPosParams; use namada_proof_of_stake::storage::write_pos_params; use namada_state::testing::TestWlStorage; diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs index 515c793a65..3267912131 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::ethereum_events::EthereumEvent; +use namada_core::ethereum_events::EthereumEvent; use namada_vote_ext::ethereum_events::MultiSignedEthEvent; use crate::protocol::transactions::votes::{dedupe, Tally, Votes}; @@ -51,11 +51,11 @@ pub struct EthMsg { mod tests { use std::collections::BTreeSet; - use namada_core::types::address; - use namada_core::types::ethereum_events::testing::{ + use namada_core::address; + use namada_core::ethereum_events::testing::{ arbitrary_nonce, arbitrary_single_transfer, }; - use namada_core::types::storage::BlockHeight; + use namada_core::storage::BlockHeight; use super::*; diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs index 73a228dcea..09980ad331 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs @@ -5,19 +5,19 @@ use std::str::FromStr; use borsh::BorshDeserialize; use eyre::{Result, WrapErr}; -use namada_core::hints; -use namada_core::types::address::Address; -use namada_core::types::eth_abi::Encode; -use namada_core::types::eth_bridge_pool::{ +use namada_core::address::Address; +use namada_core::eth_abi::Encode; +use namada_core::eth_bridge_pool::{ erc20_nut_address, erc20_token_address, PendingTransfer, TransferToEthereumKind, }; -use namada_core::types::ethereum_events::{ +use namada_core::ethereum_events::{ EthAddress, EthereumEvent, TransferToEthereum, TransferToNamada, TransfersToNamada, }; -use namada_core::types::ethereum_structs::EthBridgeEvent; -use namada_core::types::storage::{BlockHeight, Key, KeySeg}; +use namada_core::ethereum_structs::EthBridgeEvent; +use namada_core::hints; +use namada_core::storage::{BlockHeight, Key, KeySeg}; use namada_parameters::read_epoch_duration_parameter; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::{StorageRead, StorageWrite}; @@ -585,16 +585,16 @@ mod tests { use assert_matches::assert_matches; use eyre::Result; + use namada_core::address::testing::gen_implicit_address; + use namada_core::address::{gen_established_address, nam, wnam}; use namada_core::borsh::BorshSerializeExt; - use namada_core::types::address::testing::gen_implicit_address; - use namada_core::types::address::{gen_established_address, nam, wnam}; - use namada_core::types::eth_bridge_pool::GasFee; - use namada_core::types::ethereum_events::testing::{ + use namada_core::eth_bridge_pool::GasFee; + use namada_core::ethereum_events::testing::{ arbitrary_keccak_hash, arbitrary_nonce, DAI_ERC20_ETH_ADDRESS, }; - use namada_core::types::time::DurationSecs; - use namada_core::types::token::Amount; - use namada_core::types::{address, eth_bridge_pool}; + use namada_core::time::DurationSecs; + use namada_core::token::Amount; + use namada_core::{address, eth_bridge_pool}; use namada_parameters::{update_epoch_parameter, EpochDuration}; use namada_state::testing::TestWlStorage; use namada_storage::mockdb::MockDBWriteBatch; diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs index b9b2fe2731..afd596c8a4 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs @@ -8,12 +8,12 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use borsh::BorshDeserialize; use eth_msgs::EthMsgUpdate; use eyre::Result; -use namada_core::types::address::Address; -use namada_core::types::ethereum_events::EthereumEvent; -use namada_core::types::ethereum_structs::EthBridgeEvent; -use namada_core::types::key::common; -use namada_core::types::storage::{BlockHeight, Epoch, Key}; -use namada_core::types::token::Amount; +use namada_core::address::Address; +use namada_core::ethereum_events::EthereumEvent; +use namada_core::ethereum_structs::EthBridgeEvent; +use namada_core::key::common; +use namada_core::storage::{BlockHeight, Epoch, Key}; +use namada_core::token::Amount; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::tx_queue::ExpiredTx; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; @@ -337,15 +337,13 @@ mod tests { use std::collections::{BTreeSet, HashMap, HashSet}; use borsh::BorshDeserialize; - use namada_core::types::address; - use namada_core::types::ethereum_events::testing::{ + use namada_core::address; + use namada_core::ethereum_events::testing::{ arbitrary_amount, arbitrary_eth_address, arbitrary_nonce, arbitrary_single_transfer, DAI_ERC20_ETH_ADDRESS, }; - use namada_core::types::ethereum_events::{ - EthereumEvent, TransferToNamada, - }; - use namada_core::types::voting_power::FractionalVotingPower; + use namada_core::ethereum_events::{EthereumEvent, TransferToNamada}; + use namada_core::voting_power::FractionalVotingPower; use namada_state::testing::TestWlStorage; use namada_storage::mockdb::MockDBWriteBatch; use namada_storage::StorageRead; diff --git a/crates/ethereum_bridge/src/protocol/transactions/mod.rs b/crates/ethereum_bridge/src/protocol/transactions/mod.rs index 52833e7790..5b249deb7d 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/mod.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/mod.rs @@ -14,7 +14,7 @@ pub mod votes; use std::collections::BTreeSet; -use namada_core::types::storage; +use namada_core::storage; /// The keys changed while applying a protocol transaction. pub type ChangedKeys = BTreeSet; diff --git a/crates/ethereum_bridge/src/protocol/transactions/read.rs b/crates/ethereum_bridge/src/protocol/transactions/read.rs index c618b0335d..63663a4eb0 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/read.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/read.rs @@ -1,8 +1,8 @@ //! Helpers for reading from storage use borsh::BorshDeserialize; use eyre::{eyre, Result}; -use namada_core::types::storage; -use namada_core::types::token::Amount; +use namada_core::storage; +use namada_core::token::Amount; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::StorageRead; @@ -54,8 +54,8 @@ where #[cfg(test)] mod tests { use assert_matches::assert_matches; - use namada_core::types::storage; - use namada_core::types::token::Amount; + use namada_core::storage; + use namada_core::token::Amount; use namada_state::testing::TestWlStorage; use namada_storage::StorageWrite; diff --git a/crates/ethereum_bridge/src/protocol/transactions/update.rs b/crates/ethereum_bridge/src/protocol/transactions/update.rs index ee258774a2..7d3d5d2e8f 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/update.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/update.rs @@ -1,9 +1,9 @@ //! Helpers for writing to storage use eyre::Result; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::hash::StorageHasher; -use namada_core::types::storage; -use namada_core::types::token::{Amount, AmountError}; +use namada_core::hash::StorageHasher; +use namada_core::storage; +use namada_core::token::{Amount, AmountError}; use namada_state::{DBIter, WlStorage, DB}; use namada_storage::StorageWrite; @@ -43,7 +43,7 @@ where #[cfg(test)] mod tests { use eyre::{eyre, Result}; - use namada_core::types::storage; + use namada_core::storage; use namada_state::testing::TestWlStorage; use namada_storage::{StorageRead, StorageWrite}; diff --git a/crates/ethereum_bridge/src/protocol/transactions/utils.rs b/crates/ethereum_bridge/src/protocol/transactions/utils.rs index 63eaf8530e..6694cd6f27 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/utils.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/utils.rs @@ -2,9 +2,9 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use eyre::eyre; use itertools::Itertools; -use namada_core::types::address::Address; -use namada_core::types::storage::BlockHeight; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::storage::BlockHeight; +use namada_core::token; use namada_proof_of_stake::pos_queries::PosQueries; use namada_proof_of_stake::types::WeightedValidator; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; @@ -123,9 +123,9 @@ mod tests { use std::collections::HashSet; use assert_matches::assert_matches; - use namada_core::types::address; - use namada_core::types::ethereum_events::testing::arbitrary_bonded_stake; - use namada_core::types::voting_power::FractionalVotingPower; + use namada_core::address; + use namada_core::ethereum_events::testing::arbitrary_bonded_stake; + use namada_core::voting_power::FractionalVotingPower; use super::*; diff --git a/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs b/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs index 1adcf3d09b..86ecaf0d88 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs @@ -3,10 +3,10 @@ use std::collections::{HashMap, HashSet}; use eyre::Result; -use namada_core::types::address::Address; -use namada_core::types::key::common; -use namada_core::types::storage::{BlockHeight, Epoch}; -use namada_core::types::token::Amount; +use namada_core::address::Address; +use namada_core::key::common; +use namada_core::storage::{BlockHeight, Epoch}; +use namada_core::token::Amount; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_tx::data::TxResult; use namada_vote_ext::validator_set_update; @@ -233,8 +233,8 @@ where #[cfg(test)] mod test_valset_upd_state_changes { - use namada_core::types::address; - use namada_core::types::voting_power::FractionalVotingPower; + use namada_core::address; + use namada_core::voting_power::FractionalVotingPower; use namada_proof_of_stake::pos_queries::PosQueries; use namada_vote_ext::validator_set_update::VotingPowersMap; diff --git a/crates/ethereum_bridge/src/protocol/transactions/votes.rs b/crates/ethereum_bridge/src/protocol/transactions/votes.rs index 7accb41f66..ef361f6a09 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/votes.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/votes.rs @@ -5,10 +5,10 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use eyre::{eyre, Result}; -use namada_core::types::address::Address; -use namada_core::types::storage::{BlockHeight, Epoch}; -use namada_core::types::token; -use namada_core::types::voting_power::FractionalVotingPower; +use namada_core::address::Address; +use namada_core::storage::{BlockHeight, Epoch}; +use namada_core::token; +use namada_core::voting_power::FractionalVotingPower; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; @@ -187,8 +187,8 @@ pub fn dedupe(signers: BTreeSet<(Address, BlockHeight)>) -> Votes { mod tests { use std::collections::BTreeSet; - use namada_core::types::storage::BlockHeight; - use namada_core::types::{address, token}; + use namada_core::storage::BlockHeight; + use namada_core::{address, token}; use namada_proof_of_stake::parameters::OwnedPosParams; use namada_proof_of_stake::storage::write_pos_params; diff --git a/crates/ethereum_bridge/src/protocol/transactions/votes/storage.rs b/crates/ethereum_bridge/src/protocol/transactions/votes/storage.rs index 8830059b63..494d3da5e7 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/votes/storage.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/votes/storage.rs @@ -1,8 +1,8 @@ use eyre::{Result, WrapErr}; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; use namada_core::hints; -use namada_core::types::storage::Key; -use namada_core::types::voting_power::FractionalVotingPower; +use namada_core::storage::Key; +use namada_core::voting_power::FractionalVotingPower; use namada_state::{DBIter, PrefixIter, StorageHasher, WlStorage, DB}; use namada_storage::{StorageRead, StorageWrite}; @@ -135,7 +135,7 @@ mod tests { use assert_matches::assert_matches; use namada_core::borsh::BorshSerializeExt; - use namada_core::types::ethereum_events::EthereumEvent; + use namada_core::ethereum_events::EthereumEvent; use super::*; use crate::test_utils; diff --git a/crates/ethereum_bridge/src/protocol/transactions/votes/update.rs b/crates/ethereum_bridge/src/protocol/transactions/votes/update.rs index 47027cde41..7f8ff356af 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/votes/update.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/votes/update.rs @@ -2,9 +2,9 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use borsh::BorshDeserialize; use eyre::{eyre, Result}; -use namada_core::types::address::Address; -use namada_core::types::storage::BlockHeight; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::storage::BlockHeight; +use namada_core::token; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; @@ -209,9 +209,9 @@ fn keys_changed( mod tests { use std::collections::BTreeMap; - use namada_core::types::address; - use namada_core::types::ethereum_events::EthereumEvent; - use namada_core::types::voting_power::FractionalVotingPower; + use namada_core::address; + use namada_core::ethereum_events::EthereumEvent; + use namada_core::voting_power::FractionalVotingPower; use namada_state::testing::TestWlStorage; use self::helpers::{default_event, default_total_stake, TallyParams}; diff --git a/crates/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs b/crates/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs index e178a1fa98..74adde0a07 100644 --- a/crates/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs +++ b/crates/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs @@ -1,7 +1,7 @@ //! Bridge pool roots validation. -use namada_core::types::keccak::keccak_hash; -use namada_core::types::storage::BlockHeight; +use namada_core::keccak::keccak_hash; +use namada_core::storage::BlockHeight; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_tx::{SignableEthMessage, Signed}; diff --git a/crates/ethereum_bridge/src/protocol/validation/ethereum_events.rs b/crates/ethereum_bridge/src/protocol/validation/ethereum_events.rs index a71d743c35..7c21d4746e 100644 --- a/crates/ethereum_bridge/src/protocol/validation/ethereum_events.rs +++ b/crates/ethereum_bridge/src/protocol/validation/ethereum_events.rs @@ -1,6 +1,6 @@ //! Ethereum events validation. -use namada_core::types::storage::BlockHeight; +use namada_core::storage::BlockHeight; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_tx::Signed; diff --git a/crates/ethereum_bridge/src/protocol/validation/validator_set_update.rs b/crates/ethereum_bridge/src/protocol/validation/validator_set_update.rs index ec22576393..bd720d5603 100644 --- a/crates/ethereum_bridge/src/protocol/validation/validator_set_update.rs +++ b/crates/ethereum_bridge/src/protocol/validation/validator_set_update.rs @@ -1,6 +1,6 @@ //! Validator set update validation. -use namada_core::types::storage::Epoch; +use namada_core::storage::Epoch; use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_vote_ext::validator_set_update; diff --git a/crates/ethereum_bridge/src/storage/bridge_pool.rs b/crates/ethereum_bridge/src/storage/bridge_pool.rs index 9fe34e7611..1ef4870df8 100644 --- a/crates/ethereum_bridge/src/storage/bridge_pool.rs +++ b/crates/ethereum_bridge/src/storage/bridge_pool.rs @@ -1,12 +1,12 @@ //! Tools for accessing the storage subspaces of the Ethereum //! bridge pool -use namada_core::types::eth_bridge_pool::Segments; -pub use namada_core::types::eth_bridge_pool::{ +use namada_core::eth_bridge_pool::Segments; +pub use namada_core::eth_bridge_pool::{ get_key_from_hash, get_pending_key, is_pending_transfer_key, BRIDGE_POOL_ADDRESS, }; -use namada_core::types::storage::{DbKeySeg, Key}; +use namada_core::storage::{DbKeySeg, Key}; pub use namada_state::merkle_tree::eth_bridge_pool::BridgePoolTree; /// Get the storage key for the root of the Merkle tree diff --git a/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs b/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs index 44b38a751a..1d4f56f117 100644 --- a/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs +++ b/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs @@ -1,17 +1,14 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::hints; -use namada_core::types::address::Address; -use namada_core::types::eth_abi::Encode; -use namada_core::types::eth_bridge_pool::PendingTransfer; -use namada_core::types::ethereum_events::{ +use namada_core::address::Address; +use namada_core::eth_abi::Encode; +use namada_core::eth_bridge_pool::PendingTransfer; +use namada_core::ethereum_events::{ EthAddress, EthereumEvent, GetEventNonce, TransferToEthereum, Uint, }; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::storage::{BlockHeight, Epoch, Key as StorageKey}; -use namada_core::types::token; -use namada_core::types::voting_power::{ - EthBridgeVotingPower, FractionalVotingPower, -}; +use namada_core::keccak::KeccakHash; +use namada_core::storage::{BlockHeight, Epoch, Key as StorageKey}; +use namada_core::voting_power::{EthBridgeVotingPower, FractionalVotingPower}; +use namada_core::{hints, token}; use namada_proof_of_stake::pos_queries::{ConsensusValidators, PosQueries}; use namada_proof_of_stake::storage::{ validator_eth_cold_key_handle, validator_eth_hot_key_handle, diff --git a/crates/ethereum_bridge/src/storage/mod.rs b/crates/ethereum_bridge/src/storage/mod.rs index db40a541b0..b4e4470944 100644 --- a/crates/ethereum_bridge/src/storage/mod.rs +++ b/crates/ethereum_bridge/src/storage/mod.rs @@ -9,8 +9,8 @@ pub mod vp; pub mod whitelist; pub mod wrapped_erc20s; -use namada_core::types::address::Address; -use namada_core::types::storage::{DbKeySeg, Key, KeySeg}; +use namada_core::address::Address; +use namada_core::storage::{DbKeySeg, Key, KeySeg}; pub use namada_parameters::native_erc20_key; use namada_parameters::storage::*; use namada_parameters::ADDRESS as PARAM_ADDRESS; @@ -68,9 +68,9 @@ pub fn bridge_contract_key() -> Key { #[cfg(test)] mod test { - use namada_core::types::address; - use namada_core::types::address::nam; - use namada_core::types::ethereum_events::testing::arbitrary_eth_address; + use namada_core::address; + use namada_core::address::nam; + use namada_core::ethereum_events::testing::arbitrary_eth_address; use super::*; diff --git a/crates/ethereum_bridge/src/storage/parameters.rs b/crates/ethereum_bridge/src/storage/parameters.rs index ead8b612f4..f075662313 100644 --- a/crates/ethereum_bridge/src/storage/parameters.rs +++ b/crates/ethereum_bridge/src/storage/parameters.rs @@ -3,10 +3,10 @@ use std::num::NonZeroU64; use eyre::{eyre, Result}; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::ethereum_structs; -use namada_core::types::storage::Key; -use namada_core::types::token::{DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; +use namada_core::ethereum_events::EthAddress; +use namada_core::ethereum_structs; +use namada_core::storage::Key; +use namada_core::token::{DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::{StorageRead, StorageWrite}; use serde::{Deserialize, Serialize}; @@ -364,7 +364,7 @@ where #[cfg(test)] mod tests { use eyre::Result; - use namada_core::types::ethereum_events::EthAddress; + use namada_core::ethereum_events::EthAddress; use namada_state::testing::TestWlStorage; use super::*; diff --git a/crates/ethereum_bridge/src/storage/proof.rs b/crates/ethereum_bridge/src/storage/proof.rs index 92b377f70f..2f5895f363 100644 --- a/crates/ethereum_bridge/src/storage/proof.rs +++ b/crates/ethereum_bridge/src/storage/proof.rs @@ -4,12 +4,12 @@ use std::collections::HashMap; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use ethers::abi::Tokenizable; -use namada_core::types::eth_abi::Encode; -use namada_core::types::ethereum_events::Uint; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::key::{common, secp256k1}; -use namada_core::types::storage::Epoch; -use namada_core::types::{eth_abi, ethereum_structs}; +use namada_core::eth_abi::Encode; +use namada_core::ethereum_events::Uint; +use namada_core::keccak::KeccakHash; +use namada_core::key::{common, secp256k1}; +use namada_core::storage::Epoch; +use namada_core::{eth_abi, ethereum_structs}; use namada_vote_ext::validator_set_update::{ valset_upd_toks_to_hashes, EthAddrBook, VotingPowersMap, VotingPowersMapExt, }; @@ -123,8 +123,8 @@ mod test_ethbridge_proofs { //! Test ethereum bridge proofs. use assert_matches::assert_matches; - use namada_core::types::ethereum_events::EthAddress; - use namada_core::types::key; + use namada_core::ethereum_events::EthAddress; + use namada_core::key; use namada_tx::Signed; use super::*; diff --git a/crates/ethereum_bridge/src/storage/vote_tallies.rs b/crates/ethereum_bridge/src/storage/vote_tallies.rs index b597f15e1f..a6a6770253 100644 --- a/crates/ethereum_bridge/src/storage/vote_tallies.rs +++ b/crates/ethereum_bridge/src/storage/vote_tallies.rs @@ -4,11 +4,11 @@ use std::io::{Read, Write}; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::ethereum_events::{EthereumEvent, Uint}; -use namada_core::types::hash::Hash; -use namada_core::types::keccak::{keccak_hash, KeccakHash}; -use namada_core::types::storage::{BlockHeight, DbKeySeg, Epoch, Key}; +use namada_core::address::Address; +use namada_core::ethereum_events::{EthereumEvent, Uint}; +use namada_core::hash::Hash; +use namada_core::keccak::{keccak_hash, KeccakHash}; +use namada_core::storage::{BlockHeight, DbKeySeg, Epoch, Key}; use namada_macros::StorageKeys; use namada_vote_ext::validator_set_update::VotingPowersMap; diff --git a/crates/ethereum_bridge/src/storage/vp/bridge_pool.rs b/crates/ethereum_bridge/src/storage/vp/bridge_pool.rs index ec52cf37db..572ef84590 100644 --- a/crates/ethereum_bridge/src/storage/vp/bridge_pool.rs +++ b/crates/ethereum_bridge/src/storage/vp/bridge_pool.rs @@ -1,4 +1,4 @@ -use namada_core::types::ethereum_events::Uint; +use namada_core::ethereum_events::Uint; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::StorageWrite; use namada_trans_token::storage_key::balance_key; diff --git a/crates/ethereum_bridge/src/storage/vp/ethereum_bridge.rs b/crates/ethereum_bridge/src/storage/vp/ethereum_bridge.rs index f2ede582a1..9e79024991 100644 --- a/crates/ethereum_bridge/src/storage/vp/ethereum_bridge.rs +++ b/crates/ethereum_bridge/src/storage/vp/ethereum_bridge.rs @@ -1,4 +1,4 @@ -use namada_core::types::hash::StorageHasher; +use namada_core::hash::StorageHasher; use namada_state::{DBIter, WlStorage, DB}; use namada_storage::StorageWrite; use namada_trans_token::storage_key::balance_key; diff --git a/crates/ethereum_bridge/src/storage/whitelist.rs b/crates/ethereum_bridge/src/storage/whitelist.rs index 7792f06484..349469a0d0 100644 --- a/crates/ethereum_bridge/src/storage/whitelist.rs +++ b/crates/ethereum_bridge/src/storage/whitelist.rs @@ -5,10 +5,10 @@ use std::str::FromStr; -use namada_core::types::eth_bridge_pool::erc20_token_address; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::storage; -use namada_core::types::storage::DbKeySeg; +use namada_core::eth_bridge_pool::erc20_token_address; +use namada_core::ethereum_events::EthAddress; +use namada_core::storage; +use namada_core::storage::DbKeySeg; use namada_trans_token::storage_key::{denom_key, minted_balance_key}; use super::prefix as ethbridge_key_prefix; @@ -16,7 +16,7 @@ use crate::ADDRESS as BRIDGE_ADDRESS; mod segments { //! Storage key segments under the token whitelist. - use namada_core::types::address::Address; + use namada_core::address::Address; use namada_macros::StorageKeys; /// The name of the main storage segment. @@ -118,7 +118,7 @@ pub fn is_cap_or_whitelisted_key(key: &storage::Key) -> bool { #[cfg(test)] mod tests { - use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; + use namada_core::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; use super::*; diff --git a/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs b/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs index 4976caea8f..551da0a8ad 100644 --- a/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs +++ b/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs @@ -1,12 +1,12 @@ //! Functionality for accessing the multitoken subspace use eyre::eyre; -use namada_core::types::address::{Address, InternalAddress}; -pub use namada_core::types::eth_bridge_pool::{ +use namada_core::address::{Address, InternalAddress}; +pub use namada_core::eth_bridge_pool::{ erc20_nut_address as nut, erc20_token_address as token, }; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::storage::{self, DbKeySeg}; +use namada_core::ethereum_events::EthAddress; +use namada_core::storage::{self, DbKeySeg}; use namada_trans_token::storage_key::{ balance_key, minted_balance_key, MINTED_STORAGE_KEY, }; @@ -110,9 +110,9 @@ mod test { use std::str::FromStr; use assert_matches::assert_matches; - use namada_core::types::address::{nam, Address}; - use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; - use namada_core::types::storage::DbKeySeg; + use namada_core::address::{nam, Address}; + use namada_core::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; + use namada_core::storage::DbKeySeg; use super::*; use crate::token::storage_key::BALANCE_STORAGE_KEY; diff --git a/crates/ethereum_bridge/src/test_utils.rs b/crates/ethereum_bridge/src/test_utils.rs index bc108be1d0..f823cc7f47 100644 --- a/crates/ethereum_bridge/src/test_utils.rs +++ b/crates/ethereum_bridge/src/test_utils.rs @@ -4,13 +4,13 @@ use std::collections::HashMap; use std::num::NonZeroU64; use namada_account::protocol_pk_key; -use namada_core::types::address::{self, wnam, Address}; -use namada_core::types::dec::Dec; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::key::{self, RefTo}; -use namada_core::types::storage::{BlockHeight, Key}; -use namada_core::types::token; +use namada_core::address::{self, wnam, Address}; +use namada_core::dec::Dec; +use namada_core::ethereum_events::EthAddress; +use namada_core::keccak::KeccakHash; +use namada_core::key::{self, RefTo}; +use namada_core::storage::{BlockHeight, Key}; +use namada_core::token; use namada_proof_of_stake::parameters::OwnedPosParams; use namada_proof_of_stake::pos_queries::PosQueries; use namada_proof_of_stake::types::GenesisValidator; diff --git a/crates/governance/src/cli/offline.rs b/crates/governance/src/cli/offline.rs index b89d9afe10..f55a3e0104 100644 --- a/crates/governance/src/cli/offline.rs +++ b/crates/governance/src/cli/offline.rs @@ -2,13 +2,13 @@ use std::collections::{BTreeMap, BTreeSet}; use std::fs::{File, ReadDir}; use std::path::PathBuf; +use namada_core::account::AccountPublicKeysMap; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; -use namada_core::types::account::AccountPublicKeysMap; -use namada_core::types::address::Address; -use namada_core::types::hash::Hash; -use namada_core::types::key::{common, RefTo, SigScheme}; -use namada_core::types::sign::SignatureIndex; -use namada_core::types::storage::Epoch; +use namada_core::hash::Hash; +use namada_core::key::{common, RefTo, SigScheme}; +use namada_core::sign::SignatureIndex; +use namada_core::storage::Epoch; use serde::{Deserialize, Serialize}; use super::validation::{is_valid_tally_epoch, ProposalValidation}; diff --git a/crates/governance/src/cli/onchain.rs b/crates/governance/src/cli/onchain.rs index db40a16eb1..a366022584 100644 --- a/crates/governance/src/cli/onchain.rs +++ b/crates/governance/src/cli/onchain.rs @@ -1,9 +1,9 @@ use std::collections::BTreeMap; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::storage::Epoch; +use namada_core::token; use serde::{Deserialize, Serialize}; use super::validation::{ diff --git a/crates/governance/src/cli/validation.rs b/crates/governance/src/cli/validation.rs index db3222614d..07efc82e93 100644 --- a/crates/governance/src/cli/validation.rs +++ b/crates/governance/src/cli/validation.rs @@ -1,8 +1,8 @@ use std::collections::BTreeMap; -use namada_core::types::address::Address; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::storage::Epoch; +use namada_core::token; use thiserror::Error; use super::onchain::{PgfFunding, StewardsUpdate}; diff --git a/crates/governance/src/lib.rs b/crates/governance/src/lib.rs index 54d23b623b..49d6695a99 100644 --- a/crates/governance/src/lib.rs +++ b/crates/governance/src/lib.rs @@ -1,6 +1,6 @@ //! Governance library code -use namada_core::types::address::{self, Address}; +use namada_core::address::{self, Address}; /// governance CLI structures pub mod cli; diff --git a/crates/governance/src/parameters.rs b/crates/governance/src/parameters.rs index a93eefad43..b1537bf381 100644 --- a/crates/governance/src/parameters.rs +++ b/crates/governance/src/parameters.rs @@ -1,5 +1,5 @@ use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::token; +use namada_core::token; use namada_state::{StorageRead, StorageResult, StorageWrite}; use super::storage::keys as goverance_storage; diff --git a/crates/governance/src/pgf/cli/steward.rs b/crates/governance/src/pgf/cli/steward.rs index 6cfbf61b26..bac7482603 100644 --- a/crates/governance/src/pgf/cli/steward.rs +++ b/crates/governance/src/pgf/cli/steward.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; +use namada_core::address::Address; +use namada_core::dec::Dec; use serde::{Deserialize, Serialize}; use crate::pgf::REWARD_DISTRIBUTION_LIMIT; diff --git a/crates/governance/src/pgf/inflation.rs b/crates/governance/src/pgf/inflation.rs index 30391a622a..a057c8b479 100644 --- a/crates/governance/src/pgf/inflation.rs +++ b/crates/governance/src/pgf/inflation.rs @@ -1,7 +1,7 @@ //! PGF lib code. -use namada_core::types::address::Address; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::token; use namada_parameters::storage as params_storage; use namada_state::{ DBIter, StorageHasher, StorageRead, StorageResult, WlStorage, DB, diff --git a/crates/governance/src/pgf/mod.rs b/crates/governance/src/pgf/mod.rs index 77302b6ebd..22592625cf 100644 --- a/crates/governance/src/pgf/mod.rs +++ b/crates/governance/src/pgf/mod.rs @@ -1,6 +1,6 @@ //! Pgf library code -use namada_core::types::address::{Address, InternalAddress}; +use namada_core::address::{Address, InternalAddress}; /// Pgf CLI pub mod cli; diff --git a/crates/governance/src/pgf/parameters.rs b/crates/governance/src/pgf/parameters.rs index 416cbcb931..5e9bb34f34 100644 --- a/crates/governance/src/pgf/parameters.rs +++ b/crates/governance/src/pgf/parameters.rs @@ -1,8 +1,8 @@ use std::collections::BTreeSet; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; +use namada_core::dec::Dec; use namada_state::{StorageRead, StorageResult, StorageWrite}; use serde::{Deserialize, Serialize}; diff --git a/crates/governance/src/pgf/storage/keys.rs b/crates/governance/src/pgf/storage/keys.rs index 5d581d27a7..3d856f066b 100644 --- a/crates/governance/src/pgf/storage/keys.rs +++ b/crates/governance/src/pgf/storage/keys.rs @@ -1,5 +1,5 @@ -use namada_core::types::address::Address; -use namada_core::types::storage::{DbKeySeg, Key, KeySeg}; +use namada_core::address::Address; +use namada_core::storage::{DbKeySeg, Key, KeySeg}; use namada_macros::StorageKeys; use namada_state::collections::{lazy_map, LazyCollection, LazyMap}; diff --git a/crates/governance/src/pgf/storage/mod.rs b/crates/governance/src/pgf/storage/mod.rs index f965da157d..fd8190dd51 100644 --- a/crates/governance/src/pgf/storage/mod.rs +++ b/crates/governance/src/pgf/storage/mod.rs @@ -7,8 +7,8 @@ pub mod steward; use std::collections::HashMap; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; +use namada_core::address::Address; +use namada_core::dec::Dec; use namada_state::{StorageRead, StorageResult, StorageWrite}; use crate::pgf::parameters::PgfParameters; diff --git a/crates/governance/src/pgf/storage/steward.rs b/crates/governance/src/pgf/storage/steward.rs index ce6855a130..973c33ed78 100644 --- a/crates/governance/src/pgf/storage/steward.rs +++ b/crates/governance/src/pgf/storage/steward.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; +use namada_core::address::Address; +use namada_core::dec::Dec; use crate::pgf::REWARD_DISTRIBUTION_LIMIT; diff --git a/crates/governance/src/storage/keys.rs b/crates/governance/src/storage/keys.rs index 5eed69cbba..ded546af78 100644 --- a/crates/governance/src/storage/keys.rs +++ b/crates/governance/src/storage/keys.rs @@ -1,5 +1,5 @@ -use namada_core::types::address::Address; -use namada_core::types::storage::{DbKeySeg, Key, KeySeg}; +use namada_core::address::Address; +use namada_core::storage::{DbKeySeg, Key, KeySeg}; use namada_macros::StorageKeys; use crate::ADDRESS; diff --git a/crates/governance/src/storage/mod.rs b/crates/governance/src/storage/mod.rs index 4feaeba578..bc8c36a4ea 100644 --- a/crates/governance/src/storage/mod.rs +++ b/crates/governance/src/storage/mod.rs @@ -9,9 +9,9 @@ pub mod vote; use std::collections::BTreeMap; +use namada_core::address::Address; use namada_core::borsh::BorshDeserialize; -use namada_core::types::address::Address; -use namada_core::types::storage::Epoch; +use namada_core::storage::Epoch; use namada_state::{ iter_prefix, StorageError, StorageRead, StorageResult, StorageWrite, }; diff --git a/crates/governance/src/storage/proposal.rs b/crates/governance/src/storage/proposal.rs index f88bf24919..fcc07140bc 100644 --- a/crates/governance/src/storage/proposal.rs +++ b/crates/governance/src/storage/proposal.rs @@ -2,10 +2,10 @@ use std::collections::{BTreeMap, BTreeSet}; use std::fmt::Display; use borsh::{BorshDeserialize, BorshSerialize}; +use namada_core::address::Address; +use namada_core::hash::Hash; use namada_core::ibc::core::host::types::identifiers::{ChannelId, PortId}; -use namada_core::types::address::Address; -use namada_core::types::hash::Hash; -use namada_core::types::storage::Epoch; +use namada_core::storage::Epoch; use namada_trans_token::Amount; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -565,10 +565,10 @@ impl Display for StorageProposal { #[cfg(any(test, feature = "testing"))] /// Testing helpers and and strategies for governance proposals pub mod testing { - use namada_core::types::address::testing::arb_non_internal_address; - use namada_core::types::hash::testing::arb_hash; - use namada_core::types::storage::testing::arb_epoch; - use namada_core::types::token::testing::arb_amount; + use namada_core::address::testing::arb_non_internal_address; + use namada_core::hash::testing::arb_hash; + use namada_core::storage::testing::arb_epoch; + use namada_core::token::testing::arb_amount; use proptest::prelude::*; use proptest::{collection, option, prop_compose}; diff --git a/crates/governance/src/utils.rs b/crates/governance/src/utils.rs index 55a18e4fed..09d478ee56 100644 --- a/crates/governance/src/utils.rs +++ b/crates/governance/src/utils.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use std::fmt::Display; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; +use namada_core::token; use super::cli::offline::OfflineVote; use super::storage::proposal::ProposalType; @@ -455,7 +455,7 @@ pub fn is_valid_validator_voting_period( mod test { use std::ops::{Add, Sub}; - use namada_core::types::address; + use namada_core::address; use super::*; diff --git a/crates/ibc/src/actions.rs b/crates/ibc/src/actions.rs index eed8f284ae..9a999e6151 100644 --- a/crates/ibc/src/actions.rs +++ b/crates/ibc/src/actions.rs @@ -3,18 +3,18 @@ use std::cell::RefCell; use std::rc::Rc; +use namada_core::address::{Address, InternalAddress}; +use namada_core::hash::Hash; use namada_core::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use namada_core::ibc::apps::transfer::types::packet::PacketData; use namada_core::ibc::apps::transfer::types::PrefixedCoin; use namada_core::ibc::core::channel::types::timeout::TimeoutHeight; use namada_core::ibc::primitives::Msg; +use namada_core::ibc::IbcEvent; +use namada_core::storage::Epochs; use namada_core::tendermint::Time as TmTime; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::hash::Hash; -use namada_core::types::ibc::IbcEvent; -use namada_core::types::storage::Epochs; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::token::DenominatedAmount; +use namada_core::time::DateTimeUtc; +use namada_core::token::DenominatedAmount; use namada_governance::storage::proposal::PGFIbcTarget; use namada_parameters::read_epoch_duration_parameter; use namada_state::wl_storage::{PrefixIter, WriteLogAndStorage}; diff --git a/crates/ibc/src/context/common.rs b/crates/ibc/src/context/common.rs index b5b761bd86..9f335c6318 100644 --- a/crates/ibc/src/context/common.rs +++ b/crates/ibc/src/context/common.rs @@ -24,9 +24,9 @@ use namada_core::ibc::core::host::types::identifiers::{ }; use namada_core::ibc::primitives::proto::{Any, Protobuf}; use namada_core::ibc::primitives::Timestamp; +use namada_core::storage::{BlockHeight, Key}; use namada_core::tendermint::Time as TmTime; -use namada_core::types::storage::{BlockHeight, Key}; -use namada_core::types::time::DurationSecs; +use namada_core::time::DurationSecs; use namada_parameters::storage::get_max_expected_time_per_block_key; use prost::Message; use sha2::Digest; diff --git a/crates/ibc/src/context/storage.rs b/crates/ibc/src/context/storage.rs index 05ab8121ef..c9d8218bd1 100644 --- a/crates/ibc/src/context/storage.rs +++ b/crates/ibc/src/context/storage.rs @@ -1,9 +1,9 @@ //! IBC storage context pub use ics23::ProofSpec; -use namada_core::types::address::Address; -use namada_core::types::ibc::IbcEvent; -use namada_core::types::token::DenominatedAmount; +use namada_core::address::Address; +use namada_core::ibc::IbcEvent; +use namada_core::token::DenominatedAmount; use namada_storage::{Error, StorageRead, StorageWrite}; /// IBC context trait to be implemented in integration that can read and write diff --git a/crates/ibc/src/context/token_transfer.rs b/crates/ibc/src/context/token_transfer.rs index 4b3e333ec4..caaa945015 100644 --- a/crates/ibc/src/context/token_transfer.rs +++ b/crates/ibc/src/context/token_transfer.rs @@ -3,6 +3,7 @@ use std::cell::RefCell; use std::rc::Rc; +use namada_core::address::{Address, InternalAddress}; use namada_core::ibc::apps::transfer::context::{ TokenTransferExecutionContext, TokenTransferValidationContext, }; @@ -11,9 +12,8 @@ use namada_core::ibc::apps::transfer::types::{PrefixedCoin, PrefixedDenom}; use namada_core::ibc::core::channel::types::error::ChannelError; use namada_core::ibc::core::handler::types::error::ContextError; use namada_core::ibc::core::host::types::identifiers::{ChannelId, PortId}; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::token; -use namada_core::types::uint::Uint; +use namada_core::token; +use namada_core::uint::Uint; use namada_trans_token::read_denom; use super::common::IbcCommonContext; diff --git a/crates/ibc/src/lib.rs b/crates/ibc/src/lib.rs index bea1b2ba4a..fe31b7177f 100644 --- a/crates/ibc/src/lib.rs +++ b/crates/ibc/src/lib.rs @@ -18,6 +18,7 @@ pub use context::token_transfer::TokenTransferContext; pub use context::transfer_mod::{ModuleWrapper, TransferModule}; use context::IbcContext; pub use context::ValidationParams; +use namada_core::address::{Address, MASP}; use namada_core::ibc::apps::transfer::handler::{ send_transfer_execute, send_transfer_validate, }; @@ -36,12 +37,7 @@ use namada_core::ibc::core::router::types::error::RouterError; use namada_core::ibc::core::router::types::module::ModuleId; use namada_core::ibc::primitives::proto::Any; pub use namada_core::ibc::*; -use namada_core::types::address::{Address, MASP}; -use namada_core::types::ibc::{ - get_shielded_transfer, is_ibc_denom, MsgShieldedTransfer, - EVENT_TYPE_DENOM_TRACE, EVENT_TYPE_PACKET, -}; -use namada_core::types::masp::PaymentAddress; +use namada_core::masp::PaymentAddress; use prost::Message; use thiserror::Error; diff --git a/crates/ibc/src/storage.rs b/crates/ibc/src/storage.rs index 2137a6e6fa..c4aafc947d 100644 --- a/crates/ibc/src/storage.rs +++ b/crates/ibc/src/storage.rs @@ -2,6 +2,7 @@ use std::str::FromStr; +use namada_core::address::{Address, InternalAddress, HASH_LEN, SHA_HASH_LEN}; use namada_core::ibc::core::client::types::Height; use namada_core::ibc::core::host::types::identifiers::{ ChannelId, ClientId, ConnectionId, PortId, Sequence, @@ -11,11 +12,8 @@ use namada_core::ibc::core::host::types::path::{ ClientStatePath, CommitmentPath, ConnectionPath, Path, PortPath, ReceiptPath, SeqAckPath, SeqRecvPath, SeqSendPath, }; -use namada_core::types::address::{ - Address, InternalAddress, HASH_LEN, SHA_HASH_LEN, -}; -use namada_core::types::ibc::IbcTokenHash; -use namada_core::types::storage::{DbKeySeg, Key, KeySeg}; +use namada_core::ibc::IbcTokenHash; +use namada_core::storage::{DbKeySeg, Key, KeySeg}; use sha2::{Digest, Sha256}; use thiserror::Error; @@ -29,7 +27,7 @@ const DENOM: &str = "ibc_denom"; #[derive(Error, Debug)] pub enum Error { #[error("Storage key error: {0}")] - StorageKey(namada_core::types::storage::Error), + StorageKey(namada_core::storage::Error), #[error("Invalid Key: {0}")] InvalidKey(String), #[error("Port capability error: {0}")] diff --git a/crates/light_sdk/src/reading/asynchronous/account.rs b/crates/light_sdk/src/reading/asynchronous/account.rs index 8648ca7059..24b1c34e13 100644 --- a/crates/light_sdk/src/reading/asynchronous/account.rs +++ b/crates/light_sdk/src/reading/asynchronous/account.rs @@ -1,5 +1,5 @@ use namada_sdk::account::Account; -use namada_sdk::types::key::common; +use namada_sdk::key::common; use super::*; diff --git a/crates/light_sdk/src/reading/asynchronous/mod.rs b/crates/light_sdk/src/reading/asynchronous/mod.rs index 441d88746c..0b40764955 100644 --- a/crates/light_sdk/src/reading/asynchronous/mod.rs +++ b/crates/light_sdk/src/reading/asynchronous/mod.rs @@ -1,13 +1,13 @@ use std::str::FromStr; +use namada_sdk::address::Address; use namada_sdk::error::{EncodingError, Error}; use namada_sdk::io::StdIo; use namada_sdk::queries::RPC; use namada_sdk::rpc; use namada_sdk::state::LastBlock; -use namada_sdk::types::address::Address; -use namada_sdk::types::storage::BlockResults; -use namada_sdk::types::token::{self, DenominatedAmount}; +use namada_sdk::storage::BlockResults; +use namada_sdk::token::{self, DenominatedAmount}; use tendermint_config::net::Address as TendermintAddress; use tendermint_rpc::HttpClient; diff --git a/crates/light_sdk/src/reading/asynchronous/pos.rs b/crates/light_sdk/src/reading/asynchronous/pos.rs index 9c28beb957..0885fdcc39 100644 --- a/crates/light_sdk/src/reading/asynchronous/pos.rs +++ b/crates/light_sdk/src/reading/asynchronous/pos.rs @@ -1,13 +1,13 @@ use std::collections::{BTreeSet, HashMap, HashSet}; +use namada_sdk::address::Address; +use namada_sdk::key::common; use namada_sdk::proof_of_stake::types::{ BondsAndUnbondsDetails, CommissionPair, ValidatorMetaData, ValidatorState, }; use namada_sdk::proof_of_stake::PosParams; use namada_sdk::queries::vp::pos::EnrichedBondsAndUnbondsDetails; -use namada_sdk::types::address::Address; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::{BlockHeight, Epoch}; +use namada_sdk::storage::{BlockHeight, Epoch}; use super::*; diff --git a/crates/light_sdk/src/reading/blocking/account.rs b/crates/light_sdk/src/reading/blocking/account.rs index 321178e62c..eb5bccc21d 100644 --- a/crates/light_sdk/src/reading/blocking/account.rs +++ b/crates/light_sdk/src/reading/blocking/account.rs @@ -1,5 +1,5 @@ use namada_sdk::account::Account; -use namada_sdk::types::key::common; +use namada_sdk::key::common; use super::*; diff --git a/crates/light_sdk/src/reading/blocking/mod.rs b/crates/light_sdk/src/reading/blocking/mod.rs index 5f7e79ca62..a70b4633e4 100644 --- a/crates/light_sdk/src/reading/blocking/mod.rs +++ b/crates/light_sdk/src/reading/blocking/mod.rs @@ -1,13 +1,13 @@ use std::str::FromStr; +use namada_sdk::address::Address; use namada_sdk::error::{EncodingError, Error}; use namada_sdk::io::StdIo; use namada_sdk::queries::RPC; use namada_sdk::rpc; use namada_sdk::state::LastBlock; -use namada_sdk::types::address::Address; -use namada_sdk::types::storage::BlockResults; -use namada_sdk::types::token::{self, DenominatedAmount}; +use namada_sdk::storage::BlockResults; +use namada_sdk::token::{self, DenominatedAmount}; use tendermint_config::net::Address as TendermintAddress; use tendermint_rpc::HttpClient; use tokio::runtime::Runtime; diff --git a/crates/light_sdk/src/reading/blocking/pos.rs b/crates/light_sdk/src/reading/blocking/pos.rs index a03aad078d..4a070d36f8 100644 --- a/crates/light_sdk/src/reading/blocking/pos.rs +++ b/crates/light_sdk/src/reading/blocking/pos.rs @@ -1,13 +1,13 @@ use std::collections::{BTreeSet, HashMap, HashSet}; +use namada_sdk::address::Address; +use namada_sdk::key::common; use namada_sdk::proof_of_stake::types::{ BondsAndUnbondsDetails, CommissionPair, ValidatorMetaData, ValidatorState, }; use namada_sdk::proof_of_stake::PosParams; use namada_sdk::queries::vp::pos::EnrichedBondsAndUnbondsDetails; -use namada_sdk::types::address::Address; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::{BlockHeight, Epoch}; +use namada_sdk::storage::{BlockHeight, Epoch}; use super::*; diff --git a/crates/light_sdk/src/transaction/account.rs b/crates/light_sdk/src/transaction/account.rs index e4d30ece2c..fce8794bb6 100644 --- a/crates/light_sdk/src/transaction/account.rs +++ b/crates/light_sdk/src/transaction/account.rs @@ -1,10 +1,10 @@ +use namada_sdk::address::Address; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; diff --git a/crates/light_sdk/src/transaction/bridge.rs b/crates/light_sdk/src/transaction/bridge.rs index e365a8ad89..c1e01238c5 100644 --- a/crates/light_sdk/src/transaction/bridge.rs +++ b/crates/light_sdk/src/transaction/bridge.rs @@ -1,11 +1,11 @@ +use namada_sdk::address::Address; +pub use namada_sdk::eth_bridge_pool::{GasFee, TransferToEthereum}; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -pub use namada_sdk::types::eth_bridge_pool::{GasFee, TransferToEthereum}; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; @@ -23,10 +23,7 @@ impl BridgeTransfer { args: GlobalArgs, ) -> Self { let pending_transfer = - namada_sdk::types::eth_bridge_pool::PendingTransfer { - transfer, - gas_fee, - }; + namada_sdk::eth_bridge_pool::PendingTransfer { transfer, gas_fee }; Self(transaction::build_tx( args, diff --git a/crates/light_sdk/src/transaction/governance.rs b/crates/light_sdk/src/transaction/governance.rs index 60ef066e24..a0ac5e96cc 100644 --- a/crates/light_sdk/src/transaction/governance.rs +++ b/crates/light_sdk/src/transaction/governance.rs @@ -1,11 +1,11 @@ +use namada_sdk::address::Address; use namada_sdk::governance::{ProposalType, ProposalVote}; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; diff --git a/crates/light_sdk/src/transaction/ibc.rs b/crates/light_sdk/src/transaction/ibc.rs index 016817820b..2ecc9b3825 100644 --- a/crates/light_sdk/src/transaction/ibc.rs +++ b/crates/light_sdk/src/transaction/ibc.rs @@ -1,15 +1,15 @@ use std::str::FromStr; +use namada_sdk::address::Address; +use namada_sdk::hash::Hash; pub use namada_sdk::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use namada_sdk::ibc::primitives::Msg; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::time::DateTimeUtc; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::time::DateTimeUtc; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; diff --git a/crates/light_sdk/src/transaction/mod.rs b/crates/light_sdk/src/transaction/mod.rs index cf44997e37..598a665381 100644 --- a/crates/light_sdk/src/transaction/mod.rs +++ b/crates/light_sdk/src/transaction/mod.rs @@ -2,15 +2,15 @@ use std::collections::BTreeMap; use std::str::FromStr; use borsh::BorshSerialize; +use namada_sdk::address::Address; +use namada_sdk::chain::ChainId; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::time::DateTimeUtc; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::{Fee, GasLimit}; use namada_sdk::tx::{Section, Signature, Signer, Tx}; -use namada_sdk::types::address::Address; -use namada_sdk::types::chain::ChainId; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::time::DateTimeUtc; -use namada_sdk::types::token::DenominatedAmount; pub mod account; pub mod bridge; diff --git a/crates/light_sdk/src/transaction/pgf.rs b/crates/light_sdk/src/transaction/pgf.rs index 572503573d..48afb38a68 100644 --- a/crates/light_sdk/src/transaction/pgf.rs +++ b/crates/light_sdk/src/transaction/pgf.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; +use namada_sdk::address::Address; +use namada_sdk::dec::Dec; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::dec::Dec; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; diff --git a/crates/light_sdk/src/transaction/pos.rs b/crates/light_sdk/src/transaction/pos.rs index 5b9ed197cb..39ae504c7a 100644 --- a/crates/light_sdk/src/transaction/pos.rs +++ b/crates/light_sdk/src/transaction/pos.rs @@ -1,13 +1,13 @@ +use namada_sdk::address::Address; +use namada_sdk::dec::Dec; +use namada_sdk::hash::Hash; +use namada_sdk::key::{common, secp256k1}; +use namada_sdk::storage::Epoch; +use namada_sdk::token; +use namada_sdk::token::{Amount, DenominatedAmount}; use namada_sdk::tx::data::pos::Redelegation; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::dec::Dec; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::{common, secp256k1}; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token; -use namada_sdk::types::token::{Amount, DenominatedAmount}; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; diff --git a/crates/light_sdk/src/transaction/transfer.rs b/crates/light_sdk/src/transaction/transfer.rs index 1c749819e6..b548665086 100644 --- a/crates/light_sdk/src/transaction/transfer.rs +++ b/crates/light_sdk/src/transaction/transfer.rs @@ -1,11 +1,11 @@ use borsh_ext::BorshSerializeExt; +use namada_sdk::address::Address; +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; +use namada_sdk::token::DenominatedAmount; use namada_sdk::tx::data::GasLimit; use namada_sdk::tx::{Signature, Tx, TxError}; -use namada_sdk::types::address::Address; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; -use namada_sdk::types::token::DenominatedAmount; use super::{attach_fee, attach_fee_signature, GlobalArgs}; use crate::transaction; @@ -27,7 +27,7 @@ impl Transfer { shielded: Option, args: GlobalArgs, ) -> Self { - let init_proposal = namada_sdk::types::token::Transfer { + let init_proposal = namada_sdk::token::Transfer { source, target, token, diff --git a/crates/light_sdk/src/transaction/wrapper.rs b/crates/light_sdk/src/transaction/wrapper.rs index 8f396cb144..fbc1ea953e 100644 --- a/crates/light_sdk/src/transaction/wrapper.rs +++ b/crates/light_sdk/src/transaction/wrapper.rs @@ -1,8 +1,8 @@ +use namada_sdk::hash::Hash; +use namada_sdk::key::common; +use namada_sdk::storage::Epoch; use namada_sdk::tx::data::{Fee, GasLimit}; use namada_sdk::tx::{Section, Signature, Signer, Tx, TxError}; -use namada_sdk::types::hash::Hash; -use namada_sdk::types::key::common; -use namada_sdk::types::storage::Epoch; #[allow(missing_docs)] pub struct Wrapper(Tx); diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index c3af2fd82f..bb362a422f 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -269,10 +269,10 @@ fn derive_storage_keys_inner(struct_def: TokenStream2) -> TokenStream2 { let id = syn::Ident::new(&id, ident.span()); quote! { #[allow(missing_docs)] - pub fn #id(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn #id(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(#ident), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(#ident), ] if a == address && #ident == #struct_def_ident::VALUES.#ident) } } @@ -282,11 +282,11 @@ fn derive_storage_keys_inner(struct_def: TokenStream2) -> TokenStream2 { let id = syn::Ident::new(&id, ident.span()); quote! { #[allow(missing_docs)] - pub fn #id(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn #id(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(#struct_def_ident::VALUES.#ident.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(#struct_def_ident::VALUES.#ident.to_string()), ], } } @@ -403,66 +403,66 @@ mod test_proc_macros { }; } #[allow(missing_docs)] - pub fn is_bird_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_bird_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(bird), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(bird), ] if a == address && bird == Keys::VALUES.bird) } #[allow(missing_docs)] - pub fn get_bird_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_bird_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.bird.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.bird.to_string()), ], } } #[allow(missing_docs)] - pub fn is_is_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_is_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(is), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(is), ] if a == address && is == Keys::VALUES.is) } #[allow(missing_docs)] - pub fn get_is_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_is_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.is.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.is.to_string()), ], } } #[allow(missing_docs)] - pub fn is_the_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_the_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(the), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(the), ] if a == address && the == Keys::VALUES.the) } #[allow(missing_docs)] - pub fn get_the_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_the_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.the.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.the.to_string()), ], } } #[allow(missing_docs)] - pub fn is_word_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_word_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(word), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(word), ] if a == address && word == Keys::VALUES.word) } #[allow(missing_docs)] - pub fn get_word_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_word_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.word.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.word.to_string()), ], } } @@ -531,34 +531,34 @@ mod test_proc_macros { }; } #[allow(missing_docs)] - pub fn is_param1_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_param1_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(param1), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(param1), ] if a == address && param1 == Keys::VALUES.param1) } #[allow(missing_docs)] - pub fn get_param1_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_param1_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.param1.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.param1.to_string()), ], } } #[allow(missing_docs)] - pub fn is_param2_key_at_addr(key: &namada_core::types::storage::Key, address: &Address) -> bool { + pub fn is_param2_key_at_addr(key: &namada_core::storage::Key, address: &Address) -> bool { matches!(&key.segments[..], [ - namada_core::types::storage::DbKeySeg::AddressSeg(a), - namada_core::types::storage::DbKeySeg::StringSeg(param2), + namada_core::storage::DbKeySeg::AddressSeg(a), + namada_core::storage::DbKeySeg::StringSeg(param2), ] if a == address && param2 == Keys::VALUES.param2) } #[allow(missing_docs)] - pub fn get_param2_key_at_addr(address: Address) -> namada_core::types::storage::Key { - namada_core::types::storage::Key { + pub fn get_param2_key_at_addr(address: Address) -> namada_core::storage::Key { + namada_core::storage::Key { segments: vec![ - namada_core::types::storage::DbKeySeg::AddressSeg(address), - namada_core::types::storage::DbKeySeg::StringSeg(Keys::VALUES.param2.to_string()), + namada_core::storage::DbKeySeg::AddressSeg(address), + namada_core::storage::DbKeySeg::StringSeg(Keys::VALUES.param2.to_string()), ], } } diff --git a/crates/merkle_tree/src/eth_bridge_pool.rs b/crates/merkle_tree/src/eth_bridge_pool.rs index b8c30a36aa..32d0f0462c 100644 --- a/crates/merkle_tree/src/eth_bridge_pool.rs +++ b/crates/merkle_tree/src/eth_bridge_pool.rs @@ -4,12 +4,12 @@ use std::collections::{BTreeMap, BTreeSet}; use eyre::eyre; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::eth_abi::{Encode, Token}; -use namada_core::types::eth_bridge_pool::PendingTransfer; -use namada_core::types::hash::Hash; -use namada_core::types::keccak::{keccak_hash, KeccakHash}; -use namada_core::types::storage; -use namada_core::types::storage::{BlockHeight, DbKeySeg}; +use namada_core::eth_abi::{Encode, Token}; +use namada_core::eth_bridge_pool::PendingTransfer; +use namada_core::hash::Hash; +use namada_core::keccak::{keccak_hash, KeccakHash}; +use namada_core::storage; +use namada_core::storage::{BlockHeight, DbKeySeg}; #[derive(thiserror::Error, Debug)] #[error(transparent)] @@ -373,12 +373,12 @@ mod test_bridge_pool_tree { use assert_matches::assert_matches; use itertools::Itertools; - use namada_core::types::address::{nam, Address}; - use namada_core::types::eth_bridge_pool::{ + use namada_core::address::{nam, Address}; + use namada_core::eth_bridge_pool::{ GasFee, TransferToEthereum, TransferToEthereumKind, }; - use namada_core::types::ethereum_events::EthAddress; - use namada_core::types::storage::Key; + use namada_core::ethereum_events::EthAddress; + use namada_core::storage::Key; use proptest::prelude::*; use super::*; diff --git a/crates/merkle_tree/src/ics23_specs.rs b/crates/merkle_tree/src/ics23_specs.rs index 130735d33a..c907b6b71b 100644 --- a/crates/merkle_tree/src/ics23_specs.rs +++ b/crates/merkle_tree/src/ics23_specs.rs @@ -2,7 +2,7 @@ use arse_merkle_tree::H256; use ics23::{HashOp, LeafOp, LengthOp, ProofSpec}; -use namada_core::types::hash::StorageHasher; +use namada_core::hash::StorageHasher; /// Get the leaf spec for the base tree. The key is stored after hashing, /// but the stored value is the subtree's root without hashing. diff --git a/crates/merkle_tree/src/lib.rs b/crates/merkle_tree/src/lib.rs index eb55878a82..cd91fe52b1 100644 --- a/crates/merkle_tree/src/lib.rs +++ b/crates/merkle_tree/src/lib.rs @@ -15,19 +15,17 @@ use eth_bridge_pool::{BridgePoolProof, BridgePoolTree}; use ics23::commitment_proof::Proof as Ics23Proof; use ics23::{CommitmentProof, ExistenceProof, NonExistenceProof}; use ics23_specs::ibc_leaf_spec; +use namada_core::address::{Address, InternalAddress}; use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; use namada_core::bytes::ByteBuf; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::eth_bridge_pool::{ - is_pending_transfer_key, PendingTransfer, -}; -use namada_core::types::hash::{Hash, StorageHasher}; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::storage::{ +use namada_core::eth_bridge_pool::{is_pending_transfer_key, PendingTransfer}; +use namada_core::hash::{Hash, StorageHasher}; +use namada_core::keccak::KeccakHash; +use namada_core::storage::{ self, BlockHeight, DbKeySeg, Epoch, Error as StorageError, Key, KeySeg, StringKey, TreeBytes, TreeKeyError, IBC_KEY_LIMIT, }; -use namada_core::types::{self, DecodeError}; +use namada_core::{self, decode, DecodeError}; use thiserror::Error; /// Trait for reading from a merkle tree that is a sub-tree @@ -303,11 +301,11 @@ impl StoreType { bytes: T, ) -> std::result::Result { match self { - Self::Base => Ok(Store::Base(types::decode(bytes)?)), - Self::Account => Ok(Store::Account(types::decode(bytes)?)), - Self::Ibc => Ok(Store::Ibc(types::decode(bytes)?)), - Self::PoS => Ok(Store::PoS(types::decode(bytes)?)), - Self::BridgePool => Ok(Store::BridgePool(types::decode(bytes)?)), + Self::Base => Ok(Store::Base(decode(bytes)?)), + Self::Account => Ok(Store::Account(decode(bytes)?)), + Self::Ibc => Ok(Store::Ibc(decode(bytes)?)), + Self::PoS => Ok(Store::PoS(decode(bytes)?)), + Self::BridgePool => Ok(Store::BridgePool(decode(bytes)?)), } } } @@ -1004,8 +1002,8 @@ impl<'a> SubTreeWrite for &'a mut BridgePoolTree { #[cfg(test)] mod test { use ics23::HostFunctionsManager; - use namada_core::types::hash::Sha256Hasher; - use namada_core::types::storage::KeySeg; + use namada_core::hash::Sha256Hasher; + use namada_core::storage::KeySeg; use super::*; use crate::ics23_specs::{ibc_proof_specs, proof_specs}; diff --git a/crates/namada/src/ledger/governance/mod.rs b/crates/namada/src/ledger/governance/mod.rs index ce5b48cbeb..c694f035d4 100644 --- a/crates/namada/src/ledger/governance/mod.rs +++ b/crates/namada/src/ledger/governance/mod.rs @@ -19,11 +19,11 @@ use namada_vp_env::VpEnv; use thiserror::Error; use self::utils::ReadType; +use crate::address::{Address, InternalAddress}; use crate::ledger::native_vp::{Ctx, NativeVp}; use crate::ledger::{native_vp, pos}; +use crate::storage::{Epoch, Key}; use crate::token; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage::{Epoch, Key}; use crate::vm::WasmCacheAccess; /// for handling Governance NativeVP errors diff --git a/crates/namada/src/ledger/mod.rs b/crates/namada/src/ledger/mod.rs index 8ca87958f0..f73b730945 100644 --- a/crates/namada/src/ledger/mod.rs +++ b/crates/namada/src/ledger/mod.rs @@ -46,7 +46,7 @@ mod dry_run_tx { use namada_tx::Tx; use crate::ledger::protocol::ShellParams; - use crate::types::storage::TxIndex; + use crate::storage::TxIndex; let mut tx = Tx::try_from(&request.data[..]).into_storage_result()?; tx.validate_tx().into_storage_result()?; @@ -134,9 +134,9 @@ mod dry_run_tx { mod test { use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; - use namada_core::types::address; - use namada_core::types::hash::Hash; - use namada_core::types::storage::{BlockHeight, Key}; + use namada_core::address; + use namada_core::hash::Hash; + use namada_core::storage::{BlockHeight, Key}; use namada_sdk::queries::{ EncodedResponseQuery, RequestCtx, RequestQuery, Router, RPC, }; @@ -191,10 +191,7 @@ mod test { namada_parameters::storage::get_max_block_gas_key(); wl_storage .storage - .write( - &max_block_gas_key, - namada_core::types::encode(&20_000_000_u64), - ) + .write(&max_block_gas_key, namada_core::encode(&20_000_000_u64)) .expect( "Max block gas parameter must be initialized in storage", ); diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs index 19e99a7475..09aef4623d 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs @@ -17,8 +17,8 @@ use std::marker::PhantomData; use borsh::BorshDeserialize; use eyre::eyre; +use namada_core::eth_bridge_pool::erc20_token_address; use namada_core::hints; -use namada_core::types::eth_bridge_pool::erc20_token_address; use namada_ethereum_bridge::storage::bridge_pool::{ get_pending_key, is_bridge_pool_key, BRIDGE_POOL_ADDRESS, }; @@ -28,13 +28,13 @@ use namada_ethereum_bridge::ADDRESS as BRIDGE_ADDRESS; use namada_state::{DBIter, StorageHasher, DB}; use namada_tx::Tx; +use crate::address::{Address, InternalAddress}; +use crate::eth_bridge_pool::{PendingTransfer, TransferToEthereumKind}; +use crate::ethereum_events::EthAddress; use crate::ledger::native_vp::{Ctx, NativeVp, StorageReader}; +use crate::storage::Key; use crate::token::storage_key::balance_key; use crate::token::Amount; -use crate::types::address::{Address, InternalAddress}; -use crate::types::eth_bridge_pool::{PendingTransfer, TransferToEthereumKind}; -use crate::types::ethereum_events::EthAddress; -use crate::types::storage::Key; use crate::vm::WasmCacheAccess; #[derive(thiserror::Error, Debug)] @@ -642,8 +642,8 @@ mod test_bridge_pool_vp { use std::env::temp_dir; use borsh::BorshDeserialize; + use namada_core::address; use namada_core::borsh::BorshSerializeExt; - use namada_core::types::address; use namada_ethereum_bridge::storage::bridge_pool::get_signed_root_key; use namada_ethereum_bridge::storage::parameters::{ Contracts, EthereumBridgeParams, UpgradeableContract, @@ -654,15 +654,15 @@ mod test_bridge_pool_vp { use namada_tx::data::TxType; use super::*; + use crate::address::{nam, wnam, InternalAddress}; + use crate::chain::ChainId; + use crate::eth_bridge_pool::{GasFee, TransferToEthereum}; + use crate::hash::Hash; use crate::ledger::gas::VpGasMeter; use crate::state::mockdb::MockDB; use crate::state::write_log::WriteLog; use crate::state::{Sha256Hasher, State, WlStorage}; - use crate::types::address::{nam, wnam, InternalAddress}; - use crate::types::chain::ChainId; - use crate::types::eth_bridge_pool::{GasFee, TransferToEthereum}; - use crate::types::hash::Hash; - use crate::types::storage::TxIndex; + use crate::storage::TxIndex; use crate::vm::wasm::VpCache; use crate::vm::WasmCacheRwAccess; @@ -714,7 +714,7 @@ mod test_bridge_pool_vp { /// An implicit user address for testing & development #[allow(dead_code)] pub fn daewon_address() -> Address { - use crate::types::key::*; + use crate::key::*; pub fn daewon_keypair() -> common::SecretKey { let bytes = [ 235, 250, 15, 1, 145, 250, 172, 218, 247, 27, 63, 212, 60, 47, diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs index 5acd2927f2..545d549bf8 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs @@ -3,8 +3,8 @@ use std::collections::BTreeSet; use eyre::WrapErr; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::storage::Key; +use namada_core::address::{Address, InternalAddress}; +use namada_core::storage::Key; use namada_state::StorageHasher; use namada_tx::Tx; use namada_vp_env::VpEnv; @@ -121,10 +121,10 @@ mod test_nuts { use std::env::temp_dir; use assert_matches::assert_matches; + use namada_core::address::testing::arb_non_internal_address; use namada_core::borsh::BorshSerializeExt; - use namada_core::types::address::testing::arb_non_internal_address; - use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; - use namada_core::types::storage::TxIndex; + use namada_core::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; + use namada_core::storage::TxIndex; use namada_ethereum_bridge::storage::wrapped_erc20s; use namada_state::testing::TestWlStorage; use namada_state::StorageWrite; diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs index b72fe7d13f..289769eb88 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs @@ -2,9 +2,9 @@ use std::collections::{BTreeSet, HashSet}; use eyre::{eyre, Result}; -use namada_core::types::address::Address; -use namada_core::types::hash::StorageHasher; -use namada_core::types::storage::Key; +use namada_core::address::Address; +use namada_core::hash::StorageHasher; +use namada_core::storage::Key; use namada_ethereum_bridge; use namada_ethereum_bridge::storage; use namada_ethereum_bridge::storage::escrow_key; @@ -176,21 +176,21 @@ mod tests { use rand::Rng; use super::*; + use crate::address::testing::established_address_1; + use crate::address::{nam, wnam}; use crate::ethereum_bridge::storage::bridge_pool::BRIDGE_POOL_ADDRESS; use crate::ethereum_bridge::storage::parameters::{ Contracts, EthereumBridgeParams, UpgradeableContract, }; use crate::ethereum_bridge::storage::wrapped_erc20s; + use crate::ethereum_events; + use crate::ethereum_events::EthAddress; use crate::ledger::gas::VpGasMeter; use crate::state::mockdb::MockDB; use crate::state::write_log::WriteLog; use crate::state::{Sha256Hasher, State, WlStorage}; + use crate::storage::TxIndex; use crate::token::storage_key::minted_balance_key; - use crate::types::address::testing::established_address_1; - use crate::types::address::{nam, wnam}; - use crate::types::ethereum_events; - use crate::types::ethereum_events::EthAddress; - use crate::types::storage::TxIndex; use crate::vm::wasm::VpCache; use crate::vm::WasmCacheRwAccess; diff --git a/crates/namada/src/ledger/native_vp/ibc/context.rs b/crates/namada/src/ledger/native_vp/ibc/context.rs index 8581e766ce..3a57ffc126 100644 --- a/crates/namada/src/ledger/native_vp/ibc/context.rs +++ b/crates/namada/src/ledger/native_vp/ibc/context.rs @@ -3,21 +3,18 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use borsh_ext::BorshSerializeExt; -use ledger_storage::ResultExt; -use namada_core::types::storage::Epochs; +use namada_core::storage::Epochs; use namada_ibc::{IbcCommonContext, IbcStorageContext}; use namada_state::{StorageError, StorageRead, StorageWrite}; +use crate::address::{Address, InternalAddress}; +use crate::ibc::IbcEvent; use crate::ledger::ibc::storage::is_ibc_key; use crate::ledger::native_vp::CtxPreStorageRead; use crate::state::write_log::StorageModification; -use crate::state::{self as ledger_storage, StorageHasher}; +use crate::state::{self as ledger_storage, ResultExt, StorageHasher}; +use crate::storage::{BlockHash, BlockHeight, Epoch, Header, Key, TxIndex}; use crate::token::{self as token, Amount, DenominatedAmount}; -use crate::types::address::{Address, InternalAddress}; -use crate::types::ibc::IbcEvent; -use crate::types::storage::{ - BlockHash, BlockHeight, Epoch, Header, Key, TxIndex, -}; use crate::vm::WasmCacheAccess; /// Result of a storage API call. diff --git a/crates/namada/src/ledger/native_vp/ibc/mod.rs b/crates/namada/src/ledger/native_vp/ibc/mod.rs index 7774c41cf1..db0ed077e1 100644 --- a/crates/namada/src/ledger/native_vp/ibc/mod.rs +++ b/crates/namada/src/ledger/native_vp/ibc/mod.rs @@ -8,8 +8,8 @@ use std::rc::Rc; use std::time::Duration; use context::{PseudoExecutionContext, VpValidationContext}; -use namada_core::types::address::Address; -use namada_core::types::storage::Key; +use namada_core::address::Address; +use namada_core::storage::Key; use namada_gas::{IBC_ACTION_EXECUTE_GAS, IBC_ACTION_VALIDATE_GAS}; use namada_ibc::{ Error as ActionError, IbcActions, TransferModule, ValidationParams, @@ -247,12 +247,12 @@ impl From for Error { /// A dummy header used for testing #[cfg(any(test, feature = "testing"))] -pub fn get_dummy_header() -> crate::types::storage::Header { +pub fn get_dummy_header() -> crate::storage::Header { use crate::tendermint::time::Time as TmTime; - crate::types::storage::Header { - hash: crate::types::hash::Hash([0; 32]), + crate::storage::Header { + hash: crate::hash::Hash([0; 32]), time: TmTime::now().try_into().unwrap(), - next_validators_hash: crate::types::hash::Hash([0; 32]), + next_validators_hash: crate::hash::Hash([0; 32]), } } @@ -260,11 +260,11 @@ pub fn get_dummy_header() -> crate::types::storage::Header { #[cfg(any(test, feature = "testing"))] pub fn get_dummy_genesis_validator() -> namada_proof_of_stake::types::GenesisValidator { - use crate::core::types::address::testing::established_address_1; - use crate::core::types::dec::Dec; - use crate::core::types::key::testing::common_sk_from_simple_seed; + use crate::core::address::testing::established_address_1; + use crate::core::dec::Dec; + use crate::core::key::testing::common_sk_from_simple_seed; + use crate::key; use crate::token::Amount; - use crate::types::key; let address = established_address_1(); let tokens = Amount::native_whole(1); @@ -327,11 +327,11 @@ mod tests { use sha2::Digest; use super::*; - use crate::core::types::address::testing::{ + use crate::core::address::testing::{ established_address_1, established_address_2, }; - use crate::core::types::address::{nam, InternalAddress}; - use crate::core::types::storage::Epoch; + use crate::core::address::{nam, InternalAddress}; + use crate::core::storage::Epoch; use crate::ibc::apps::transfer::types::events::{ AckEvent, DenomTraceEvent, RecvEvent, TimeoutEvent, TransferEvent, }; @@ -398,18 +398,18 @@ mod tests { ibc_denom_key, next_sequence_ack_key, next_sequence_recv_key, next_sequence_send_key, receipt_key, }; + use crate::key::testing::keypair_1; use crate::ledger::gas::VpGasMeter; use crate::ledger::parameters::storage::{ get_epoch_duration_storage_key, get_max_expected_time_per_block_key, }; use crate::ledger::parameters::EpochDuration; use crate::ledger::{ibc, pos}; + use crate::storage::{BlockHash, BlockHeight, TxIndex}; use crate::tendermint::time::Time as TmTime; + use crate::time::DurationSecs; use crate::token::storage_key::balance_key; use crate::token::Amount; - use crate::types::key::testing::keypair_1; - use crate::types::storage::{BlockHash, BlockHeight, TxIndex}; - use crate::types::time::DurationSecs; use crate::vm::wasm; const ADDRESS: Address = Address::Internal(InternalAddress::Ibc); @@ -450,7 +450,7 @@ mod tests { let time_key = get_max_expected_time_per_block_key(); wl_storage .write_log - .write(&time_key, namada_core::types::encode(&time)) + .write(&time_key, namada_core::encode(&time)) .expect("write failed"); // set a dummy header wl_storage diff --git a/crates/namada/src/ledger/native_vp/masp.rs b/crates/namada/src/ledger/native_vp/masp.rs index b222aeaf9b..c76b2995b7 100644 --- a/crates/namada/src/ledger/native_vp/masp.rs +++ b/crates/namada/src/ledger/native_vp/masp.rs @@ -9,10 +9,10 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_primitives::transaction::components::I128Sum; use masp_primitives::transaction::Transaction; -use namada_core::types::address::Address; -use namada_core::types::address::InternalAddress::Masp; -use namada_core::types::masp::encode_asset_type; -use namada_core::types::storage::{IndexedTx, Key}; +use namada_core::address::Address; +use namada_core::address::InternalAddress::Masp; +use namada_core::masp::encode_asset_type; +use namada_core::storage::{IndexedTx, Key}; use namada_gas::MASP_VERIFY_SHIELDED_TX_GAS; use namada_sdk::masp::verify_shielded_tx; use namada_state::{OptionExt, ResultExt}; @@ -34,7 +34,7 @@ use token::Amount; use crate::ledger::native_vp; use crate::ledger::native_vp::{Ctx, NativeVp}; use crate::token; -use crate::types::token::MaspDigitPos; +use crate::token::MaspDigitPos; use crate::vm::WasmCacheAccess; #[allow(missing_docs)] @@ -217,7 +217,7 @@ where let anchor_key = masp_convert_anchor_key(); let expected_anchor = self .ctx - .read_pre::(&anchor_key)? + .read_pre::(&anchor_key)? .ok_or(Error::NativeVpError( native_vp::Error::SimpleMessage("Cannot read storage"), ))?; @@ -225,9 +225,8 @@ where for description in &bundle.shielded_converts { // Check if the provided anchor matches the current // conversion tree's one - if namada_core::types::hash::Hash( - description.anchor.to_bytes(), - ) != expected_anchor + if namada_core::hash::Hash(description.anchor.to_bytes()) + != expected_anchor { tracing::debug!( "Convert description refers to an invalid anchor" diff --git a/crates/namada/src/ledger/native_vp/mod.rs b/crates/namada/src/ledger/native_vp/mod.rs index 6692a514b8..cbfe3b225f 100644 --- a/crates/namada/src/ledger/native_vp/mod.rs +++ b/crates/namada/src/ledger/native_vp/mod.rs @@ -12,24 +12,22 @@ use std::collections::BTreeSet; use borsh::BorshDeserialize; use eyre::WrapErr; -use namada_core::types::storage; -use namada_core::types::storage::Epochs; -use namada_core::types::validity_predicate::VpSentinel; +use namada_core::storage; +use namada_core::storage::Epochs; +use namada_core::validity_predicate::VpSentinel; use namada_gas::GasMetering; use namada_tx::Tx; pub use namada_vp_env::VpEnv; use super::vp_host_fns; +use crate::address::Address; +use crate::hash::Hash; +use crate::ibc::IbcEvent; use crate::ledger::gas::VpGasMeter; use crate::state; use crate::state::write_log::WriteLog; use crate::state::{ResultExt, State, StorageHasher, StorageRead}; -use crate::types::address::Address; -use crate::types::hash::Hash; -use crate::types::ibc::IbcEvent; -use crate::types::storage::{ - BlockHash, BlockHeight, Epoch, Header, Key, TxIndex, -}; +use crate::storage::{BlockHash, BlockHeight, Epoch, Header, Key, TxIndex}; use crate::vm::prefix_iter::PrefixIterators; use crate::vm::WasmCacheAccess; diff --git a/crates/namada/src/ledger/native_vp/multitoken.rs b/crates/namada/src/ledger/native_vp/multitoken.rs index 8999855ece..4a4cdeadf8 100644 --- a/crates/namada/src/ledger/native_vp/multitoken.rs +++ b/crates/namada/src/ledger/native_vp/multitoken.rs @@ -8,14 +8,14 @@ use namada_tx::Tx; use namada_vp_env::VpEnv; use thiserror::Error; +use crate::address::{Address, InternalAddress}; use crate::ledger::native_vp::{self, Ctx, NativeVp}; +use crate::storage::{Key, KeySeg}; use crate::token::storage_key::{ is_any_minted_balance_key, is_any_minter_key, is_any_token_balance_key, minter_key, }; use crate::token::Amount; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage::{Key, KeySeg}; use crate::vm::WasmCacheAccess; #[allow(missing_docs)] @@ -223,19 +223,19 @@ mod tests { use namada_tx::{Code, Data, Section, Signature, Tx}; use super::*; - use crate::core::types::address::nam; - use crate::core::types::address::testing::{ + use crate::address::{Address, InternalAddress}; + use crate::core::address::nam; + use crate::core::address::testing::{ established_address_1, established_address_2, }; + use crate::key::testing::keypair_1; use crate::ledger::gas::VpGasMeter; use crate::ledger::ibc::storage::ibc_token; + use crate::storage::TxIndex; use crate::token::storage_key::{ balance_key, minted_balance_key, minter_key, }; use crate::token::Amount; - use crate::types::address::{Address, InternalAddress}; - use crate::types::key::testing::keypair_1; - use crate::types::storage::TxIndex; use crate::vm::wasm::compilation_cache::common::testing::cache as wasm_cache; const ADDRESS: Address = Address::Internal(InternalAddress::Multitoken); diff --git a/crates/namada/src/ledger/native_vp/parameters.rs b/crates/namada/src/ledger/native_vp/parameters.rs index b22f56260e..a64667d9f8 100644 --- a/crates/namada/src/ledger/native_vp/parameters.rs +++ b/crates/namada/src/ledger/native_vp/parameters.rs @@ -2,8 +2,8 @@ use std::collections::BTreeSet; -use namada_core::types::address::Address; -use namada_core::types::storage::Key; +use namada_core::address::Address; +use namada_core::storage::Key; use namada_tx::Tx; use thiserror::Error; diff --git a/crates/namada/src/ledger/pgf/mod.rs b/crates/namada/src/ledger/pgf/mod.rs index eb7ec70a98..23ff47903d 100644 --- a/crates/namada/src/ledger/pgf/mod.rs +++ b/crates/namada/src/ledger/pgf/mod.rs @@ -10,10 +10,10 @@ use namada_governance::{is_proposal_accepted, pgf}; use namada_tx::Tx; use thiserror::Error; +use crate::address::{Address, InternalAddress}; use crate::ledger::native_vp; use crate::ledger::native_vp::{Ctx, NativeVp}; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage::Key; +use crate::storage::Key; use crate::vm::WasmCacheAccess; /// for handling Pgf NativeVP errors diff --git a/crates/namada/src/ledger/pgf/utils.rs b/crates/namada/src/ledger/pgf/utils.rs index 8132de32af..6f6153885e 100644 --- a/crates/namada/src/ledger/pgf/utils.rs +++ b/crates/namada/src/ledger/pgf/utils.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use namada_core::types::address::Address; +use namada_core::address::Address; use crate::ledger::events::EventType; use crate::token; diff --git a/crates/namada/src/ledger/pos/mod.rs b/crates/namada/src/ledger/pos/mod.rs index a7e8fa0d22..c62daccffd 100644 --- a/crates/namada/src/ledger/pos/mod.rs +++ b/crates/namada/src/ledger/pos/mod.rs @@ -4,9 +4,9 @@ pub mod vp; use std::convert::TryFrom; -use namada_core::types::address; -pub use namada_core::types::dec::Dec; -pub use namada_core::types::key::common; +use namada_core::address; +pub use namada_core::dec::Dec; +pub use namada_core::key::common; pub use namada_proof_of_stake::parameters::{OwnedPosParams, PosParams}; pub use namada_proof_of_stake::pos_queries::*; pub use namada_proof_of_stake::storage::*; @@ -16,8 +16,8 @@ pub use namada_proof_of_stake::{staking_token_address, types}; pub use vp::PosVP; pub use {namada_proof_of_stake, namada_state}; +use crate::address::{Address, InternalAddress}; pub use crate::token; -use crate::types::address::{Address, InternalAddress}; /// Address of the PoS account implemented as a native VP pub const ADDRESS: Address = address::POS; diff --git a/crates/namada/src/ledger/pos/vp.rs b/crates/namada/src/ledger/pos/vp.rs index 69ec002654..dfb1c32c25 100644 --- a/crates/namada/src/ledger/pos/vp.rs +++ b/crates/namada/src/ledger/pos/vp.rs @@ -18,9 +18,9 @@ use namada_state::StorageRead; use namada_tx::Tx; use thiserror::Error; +use crate::address::{Address, InternalAddress}; use crate::ledger::native_vp::{self, Ctx, NativeVp}; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage::{Key, KeySeg}; +use crate::storage::{Key, KeySeg}; use crate::vm::WasmCacheAccess; #[allow(missing_docs)] diff --git a/crates/namada/src/ledger/protocol/mod.rs b/crates/namada/src/ledger/protocol/mod.rs index 9ffa91b6c9..33c930a5c6 100644 --- a/crates/namada/src/ledger/protocol/mod.rs +++ b/crates/namada/src/ledger/protocol/mod.rs @@ -4,8 +4,8 @@ use std::collections::BTreeSet; use borsh_ext::BorshSerializeExt; use eyre::{eyre, WrapErr}; use masp_primitives::transaction::Transaction; -use namada_core::types::hash::Hash; -use namada_core::types::storage::Key; +use namada_core::hash::Hash; +use namada_core::storage::Key; use namada_gas::TxGasMeter; use namada_sdk::tx::TX_TRANSFER_WASM; use namada_state::wl_storage::WriteLogAndStorage; @@ -19,6 +19,7 @@ use namada_vote_ext::EthereumTxData; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use thiserror::Error; +use crate::address::{Address, InternalAddress}; use crate::ledger::gas::{GasMetering, VpGasMeter}; use crate::ledger::governance::GovernanceVp; use crate::ledger::native_vp::ethereum_bridge::bridge_pool_vp::BridgePoolVp; @@ -33,10 +34,9 @@ use crate::ledger::pgf::PgfVp; use crate::ledger::pos::{self, PosVP}; use crate::state::write_log::WriteLog; use crate::state::{DBIter, State, StorageHasher, WlStorage, DB}; +use crate::storage; +use crate::storage::TxIndex; use crate::token::Amount; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage; -use crate::types::storage::TxIndex; use crate::vm::wasm::{TxCache, VpCache}; use crate::vm::{self, wasm, WasmCacheAccess}; @@ -1151,15 +1151,13 @@ mod tests { use borsh::BorshDeserialize; use eyre::Result; - use namada_core::types::chain::ChainId; - use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; - use namada_core::types::ethereum_events::{ - EthereumEvent, TransferToNamada, - }; - use namada_core::types::keccak::keccak_hash; - use namada_core::types::storage::BlockHeight; - use namada_core::types::voting_power::FractionalVotingPower; - use namada_core::types::{address, key}; + use namada_core::chain::ChainId; + use namada_core::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; + use namada_core::ethereum_events::{EthereumEvent, TransferToNamada}; + use namada_core::keccak::keccak_hash; + use namada_core::storage::BlockHeight; + use namada_core::voting_power::FractionalVotingPower; + use namada_core::{address, key}; use namada_ethereum_bridge::protocol::transactions::votes::{ EpochedVotingPower, Votes, }; diff --git a/crates/namada/src/ledger/vp_host_fns.rs b/crates/namada/src/ledger/vp_host_fns.rs index 5ebd1a635b..716a49a66a 100644 --- a/crates/namada/src/ledger/vp_host_fns.rs +++ b/crates/namada/src/ledger/vp_host_fns.rs @@ -2,22 +2,22 @@ use std::num::TryFromIntError; -use namada_core::types::address::{Address, ESTABLISHED_ADDRESS_BYTES_LEN}; -use namada_core::types::hash::{Hash, HASH_LENGTH}; -use namada_core::types::storage::{ +use namada_core::address::{Address, ESTABLISHED_ADDRESS_BYTES_LEN}; +use namada_core::hash::{Hash, HASH_LENGTH}; +use namada_core::storage::{ BlockHash, BlockHeight, Epoch, Epochs, Header, Key, TxIndex, TX_INDEX_LENGTH, }; -use namada_core::types::validity_predicate::VpSentinel; +use namada_core::validity_predicate::VpSentinel; use namada_gas::MEMORY_ACCESS_GAS_PER_BYTE; use namada_state::write_log::WriteLog; use namada_state::{write_log, State, StorageHasher}; use namada_tx::{Section, Tx}; use thiserror::Error; +use crate::ibc::IbcEvent; use crate::ledger::gas; use crate::ledger::gas::{GasMetering, VpGasMeter}; -use crate::types::ibc::IbcEvent; /// These runtime errors will abort VP execution immediately #[allow(missing_docs)] @@ -28,7 +28,7 @@ pub enum RuntimeError { #[error("Storage error: {0}")] StorageError(namada_state::Error), #[error("Storage data error: {0}")] - StorageDataError(crate::types::storage::Error), + StorageDataError(crate::storage::Error), #[error("Encoding error: {0}")] EncodingError(std::io::Error), #[error("Numeric conversion error: {0}")] diff --git a/crates/namada/src/lib.rs b/crates/namada/src/lib.rs index 63a0ecb7f6..47f2db3691 100644 --- a/crates/namada/src/lib.rs +++ b/crates/namada/src/lib.rs @@ -6,7 +6,13 @@ #![deny(rustdoc::broken_intra_doc_links)] #![deny(rustdoc::private_intra_doc_links)] -pub use namada_core::{tendermint, tendermint_proto}; +pub use namada_core::{ + address, chain, dec, decode, encode, eth_abi, eth_bridge_pool, + ethereum_events, ethereum_structs, hash, internal, keccak, key, masp, + storage, string_encoding, tendermint, tendermint_proto, time, uint, + validity_predicate, voting_power, +}; +pub use namada_sdk::{control_flow, io}; #[cfg(feature = "tendermint-rpc")] pub use tendermint_rpc; pub use { @@ -21,13 +27,12 @@ pub use { pub mod ledger; pub use namada_tx::proto; -pub mod types; pub mod vm; pub mod eth_bridge { //! Namada Ethereum bridge re-exports. pub use ethers; - pub use namada_core::types::ethereum_structs as structs; + pub use namada_core::ethereum_structs as structs; pub use namada_ethereum_bridge::*; } diff --git a/crates/namada/src/types/ibc/mod.rs b/crates/namada/src/types/ibc/mod.rs deleted file mode 100644 index 3c57da5203..0000000000 --- a/crates/namada/src/types/ibc/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Types that are used in IBC. - -pub use namada_core::types::ibc::*; diff --git a/crates/namada/src/types/key/mod.rs b/crates/namada/src/types/key/mod.rs deleted file mode 100644 index 11a7af5533..0000000000 --- a/crates/namada/src/types/key/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Cryptographic keys - -pub use namada_core::types::key::*; diff --git a/crates/namada/src/types/mod.rs b/crates/namada/src/types/mod.rs deleted file mode 100644 index 3a68fbc779..0000000000 --- a/crates/namada/src/types/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Types definitions. - -pub use namada_sdk::control_flow; -pub mod ibc; -pub use namada_sdk::io; -pub mod key; - -pub use namada_core::types::{ - address, chain, dec, decode, encode, eth_abi, eth_bridge_pool, - ethereum_events, ethereum_structs, hash, internal, keccak, masp, storage, - string_encoding, time, token, uint, validity_predicate, voting_power, -}; diff --git a/crates/namada/src/vm/host_env.rs b/crates/namada/src/vm/host_env.rs index 21cc2885e8..11acd72987 100644 --- a/crates/namada/src/vm/host_env.rs +++ b/crates/namada/src/vm/host_env.rs @@ -7,10 +7,10 @@ use std::num::TryFromIntError; use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::Transaction; -use namada_core::types::address::ESTABLISHED_ADDRESS_BYTES_LEN; -use namada_core::types::internal::KeyVal; -use namada_core::types::storage::{Epochs, TX_INDEX_LENGTH}; -use namada_core::types::validity_predicate::VpSentinel; +use namada_core::address::ESTABLISHED_ADDRESS_BYTES_LEN; +use namada_core::internal::KeyVal; +use namada_core::storage::{Epochs, TX_INDEX_LENGTH}; +use namada_core::validity_predicate::VpSentinel; use namada_gas::{ self as gas, GasMetering, TxGasMeter, VpGasMeter, MEMORY_ACCESS_GAS_PER_BYTE, @@ -27,16 +27,16 @@ use super::wasm::TxCache; #[cfg(feature = "wasm-runtime")] use super::wasm::VpCache; use super::WasmCacheAccess; +use crate::address::{self, Address}; +use crate::hash::Hash; +use crate::ibc::IbcEvent; +use crate::internal::HostEnvResult; use crate::ledger::vp_host_fns; +use crate::storage::{BlockHeight, Epoch, Key, TxIndex}; use crate::token::storage_key::{ balance_key, is_any_minted_balance_key, is_any_minter_key, is_any_token_balance_key, minted_balance_key, minter_key, }; -use crate::types::address::{self, Address}; -use crate::types::hash::Hash; -use crate::types::ibc::IbcEvent; -use crate::types::internal::HostEnvResult; -use crate::types::storage::{BlockHeight, Epoch, Key, TxIndex}; use crate::vm::memory::VmMemory; use crate::vm::prefix_iter::{PrefixIteratorId, PrefixIterators}; use crate::vm::{HostRef, MutHostRef}; @@ -63,7 +63,7 @@ pub enum TxRuntimeError { #[error("Storage error: {0}")] StorageError(#[from] StorageError), #[error("Storage data error: {0}")] - StorageDataError(crate::types::storage::Error), + StorageDataError(crate::storage::Error), #[error("Encoding error: {0}")] EncodingError(std::io::Error), #[error("Address error: {0}")] @@ -1982,7 +1982,7 @@ where .map_err(|e| vp_host_fns::RuntimeError::MemoryError(Box::new(e)))?; vp_host_fns::add_gas(gas_meter, gas, sentinel)?; let public_keys_map = - namada_core::types::account::AccountPublicKeysMap::try_from_slice( + namada_core::account::AccountPublicKeysMap::try_from_slice( &public_keys_map, ) .map_err(vp_host_fns::RuntimeError::EncodingError)?; @@ -2196,7 +2196,7 @@ where .map_err(|e| TxRuntimeError::MemoryError(Box::new(e)))?; tx_charge_gas(env, gas)?; let public_keys_map = - namada_core::types::account::AccountPublicKeysMap::try_from_slice( + namada_core::account::AccountPublicKeysMap::try_from_slice( &public_keys_map, ) .map_err(TxRuntimeError::EncodingError)?; @@ -2367,7 +2367,7 @@ where // Temp. workaround for use namada_state::StorageRead; -use crate::types::storage::BlockHash; +use crate::storage::BlockHash; impl<'a, DB, H, CA> StorageRead for TxCtx<'a, DB, H, CA> where DB: namada_state::DB + for<'iter> namada_state::DBIter<'iter>, @@ -2493,7 +2493,7 @@ where fn get_block_header( &self, height: BlockHeight, - ) -> Result, StorageError> { + ) -> Result, StorageError> { let storage = unsafe { self.storage.get() }; let (header, gas) = storage .get_block_header(Some(height)) diff --git a/crates/namada/src/vm/types.rs b/crates/namada/src/vm/types.rs index 54cc170371..203563ece9 100644 --- a/crates/namada/src/vm/types.rs +++ b/crates/namada/src/vm/types.rs @@ -13,8 +13,8 @@ use std::collections::BTreeSet; use namada_tx::Tx; -use crate::types::address::Address; -use crate::types::storage; +use crate::address::Address; +use crate::storage; /// Input for validity predicate wasm module call pub struct VpInput<'a> { diff --git a/crates/namada/src/vm/wasm/compilation_cache/common.rs b/crates/namada/src/vm/wasm/compilation_cache/common.rs index ce3758678e..cb9291b14a 100644 --- a/crates/namada/src/vm/wasm/compilation_cache/common.rs +++ b/crates/namada/src/vm/wasm/compilation_cache/common.rs @@ -18,8 +18,8 @@ use clru::{CLruCache, CLruCacheConfig, WeightScale}; use wasmer::{Module, Store}; use wasmer_cache::{FileSystemCache, Hash as CacheHash}; -use crate::core::types::hash::Hash; -use crate::types::control_flow::time::{ExponentialBackoff, SleepStrategy}; +use crate::control_flow::time::{ExponentialBackoff, SleepStrategy}; +use crate::core::hash::Hash; use crate::vm::wasm::run::untrusted_wasm_store; use crate::vm::wasm::{self, memory}; use crate::vm::{WasmCacheAccess, WasmCacheRoAccess}; diff --git a/crates/namada/src/vm/wasm/host_env.rs b/crates/namada/src/vm/wasm/host_env.rs index 4ab7ecda35..f6d45e23cb 100644 --- a/crates/namada/src/vm/wasm/host_env.rs +++ b/crates/namada/src/vm/wasm/host_env.rs @@ -3,7 +3,7 @@ //! Here, we expose the host functions into wasm's //! imports, so they can be called from inside the wasm. -use namada_core::types::hash::StorageHasher; +use namada_core::hash::StorageHasher; use wasmer::{ Function, HostEnvInitError, ImportObject, Instance, Memory, Store, WasmerEnv, diff --git a/crates/namada/src/vm/wasm/run.rs b/crates/namada/src/vm/wasm/run.rs index 8d84185135..5c3a3c392d 100644 --- a/crates/namada/src/vm/wasm/run.rs +++ b/crates/namada/src/vm/wasm/run.rs @@ -4,7 +4,7 @@ use std::collections::BTreeSet; use std::marker::PhantomData; use borsh::BorshDeserialize; -use namada_core::types::validity_predicate::VpSentinel; +use namada_core::validity_predicate::VpSentinel; use namada_gas::{GasMetering, TxGasMeter, WASM_MEMORY_PAGE_GAS}; use namada_state::write_log::StorageModification; use namada_state::{State, StorageHasher}; @@ -16,12 +16,12 @@ use wasmer::{BaseTunables, Module, Store}; use super::memory::{Limit, WasmMemory}; use super::TxCache; +use crate::address::Address; +use crate::hash::{Error as TxHashError, Hash}; +use crate::internal::HostEnvResult; use crate::ledger::gas::VpGasMeter; use crate::state::write_log::WriteLog; -use crate::types::address::Address; -use crate::types::hash::{Error as TxHashError, Hash}; -use crate::types::internal::HostEnvResult; -use crate::types::storage::{Key, TxIndex}; +use crate::storage::{Key, TxIndex}; use crate::vm::host_env::{TxVmEnv, VpCtx, VpEvaluator, VpVmEnv}; use crate::vm::prefix_iter::PrefixIterators; use crate::vm::types::VpInput; @@ -641,9 +641,9 @@ mod tests { use wasmer_vm::TrapCode; use super::*; + use crate::hash::Hash; use crate::state::testing::TestStorage; use crate::tx::data::eval_vp::EvalVp; - use crate::types::hash::Hash; use crate::vm::host_env::TxRuntimeError; use crate::vm::wasm; diff --git a/crates/parameters/src/lib.rs b/crates/parameters/src/lib.rs index 8fd77ad58f..e59323e114 100644 --- a/crates/parameters/src/lib.rs +++ b/crates/parameters/src/lib.rs @@ -3,14 +3,14 @@ pub mod storage; mod wasm_allowlist; use std::collections::BTreeMap; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::chain::ProposalBytes; -use namada_core::types::dec::Dec; -use namada_core::types::hash::Hash; -pub use namada_core::types::parameters::*; -use namada_core::types::storage::Key; -use namada_core::types::time::DurationSecs; -use namada_core::types::token; +use namada_core::address::{Address, InternalAddress}; +use namada_core::chain::ProposalBytes; +use namada_core::dec::Dec; +use namada_core::hash::Hash; +pub use namada_core::parameters::*; +use namada_core::storage::Key; +use namada_core::time::DurationSecs; +use namada_core::token; use namada_storage::{self, ResultExt, StorageRead, StorageWrite}; pub use storage::get_max_block_gas; use thiserror::Error; @@ -26,7 +26,7 @@ pub enum ReadError { #[error("Storage error: {0}")] StorageError(namada_storage::Error), #[error("Storage type error: {0}")] - StorageTypeError(namada_core::types::storage::Error), + StorageTypeError(namada_core::storage::Error), #[error("Protocol parameters are missing, they must be always set")] ParametersMissing, } diff --git a/crates/parameters/src/storage.rs b/crates/parameters/src/storage.rs index 7bacb2c6fa..abf3fa743f 100644 --- a/crates/parameters/src/storage.rs +++ b/crates/parameters/src/storage.rs @@ -1,7 +1,7 @@ //! Parameters storage -use namada_core::types::address::Address; -use namada_core::types::storage::{DbKeySeg, Key}; +use namada_core::address::Address; +use namada_core::storage::{DbKeySeg, Key}; use namada_macros::StorageKeys; use namada_storage::StorageRead; diff --git a/crates/parameters/src/wasm_allowlist.rs b/crates/parameters/src/wasm_allowlist.rs index e75b9b292b..c22b4b6fc1 100644 --- a/crates/parameters/src/wasm_allowlist.rs +++ b/crates/parameters/src/wasm_allowlist.rs @@ -1,5 +1,5 @@ -use namada_core::types::hash::Hash; -use namada_core::types::storage; +use namada_core::hash::Hash; +use namada_core::storage; use namada_storage::{Result, StorageRead}; use crate::storage::{ diff --git a/crates/proof_of_stake/src/epoched.rs b/crates/proof_of_stake/src/epoched.rs index 5db83af399..a1767f0318 100644 --- a/crates/proof_of_stake/src/epoched.rs +++ b/crates/proof_of_stake/src/epoched.rs @@ -7,7 +7,7 @@ use std::marker::PhantomData; use std::{cmp, ops}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::storage::{self, Epoch}; +use namada_core::storage::{self, Epoch}; use namada_storage; use namada_storage::collections::lazy_map::{LazyMap, NestedMap}; use namada_storage::collections::{self, LazyCollection}; @@ -1085,9 +1085,9 @@ pub trait EpochOffset: #[cfg(test)] mod test { - use namada_core::types::address::testing::established_address_1; - use namada_core::types::dec::Dec; - use namada_core::types::{key, token}; + use namada_core::address::testing::established_address_1; + use namada_core::dec::Dec; + use namada_core::{key, token}; use namada_state::testing::TestWlStorage; use test_log::test; diff --git a/crates/proof_of_stake/src/error.rs b/crates/proof_of_stake/src/error.rs index 6516809575..c692e0decf 100644 --- a/crates/proof_of_stake/src/error.rs +++ b/crates/proof_of_stake/src/error.rs @@ -1,9 +1,9 @@ /// Custom error types use std::num::TryFromIntError; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; use thiserror::Error; use crate::rewards; diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index 2c55df51b1..16a6307c88 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -27,13 +27,13 @@ use std::cmp::{self}; use std::collections::{BTreeMap, BTreeSet, HashSet}; pub use error::*; +use namada_core::address::{Address, InternalAddress}; +use namada_core::dec::Dec; use namada_core::event::EmitEvents; +use namada_core::key::{common, tm_raw_hash_to_string}; +use namada_core::storage::BlockHeight; +pub use namada_core::storage::{Epoch, Key, KeySeg}; use namada_core::tendermint::abci::types::{Misbehavior, MisbehaviorKind}; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::dec::Dec; -use namada_core::types::key::{common, tm_raw_hash_to_string}; -use namada_core::types::storage::BlockHeight; -pub use namada_core::types::storage::{Epoch, Key, KeySeg}; use namada_storage::collections::lazy_map::{self, Collectable, LazyMap}; use namada_storage::{StorageRead, StorageWrite}; pub use namada_trans_token as token; @@ -163,7 +163,7 @@ where pub fn is_delegator( storage: &S, address: &Address, - epoch: Option, + epoch: Option, ) -> namada_storage::Result where S: StorageRead, @@ -2498,7 +2498,7 @@ pub mod test_utils { storage: &mut S, params: &PosParams, validators: impl Iterator, - current_epoch: namada_core::types::storage::Epoch, + current_epoch: namada_core::storage::Epoch, ) -> namada_storage::Result<()> where S: StorageRead + StorageWrite, @@ -2561,7 +2561,7 @@ pub mod test_utils { storage: &mut S, owned: OwnedPosParams, validators: impl Iterator + Clone, - current_epoch: namada_core::types::storage::Epoch, + current_epoch: namada_core::storage::Epoch, ) -> namada_storage::Result where S: StorageRead + StorageWrite, diff --git a/crates/proof_of_stake/src/parameters.rs b/crates/proof_of_stake/src/parameters.rs index 6062f11a5b..0acafc3d16 100644 --- a/crates/proof_of_stake/src/parameters.rs +++ b/crates/proof_of_stake/src/parameters.rs @@ -3,10 +3,10 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; -use namada_core::types::token; -use namada_core::types::uint::Uint; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; +use namada_core::token; +use namada_core::uint::Uint; use namada_governance::parameters::GovernanceParameters; use thiserror::Error; @@ -297,7 +297,7 @@ mod tests { /// Testing helpers #[cfg(any(test, feature = "testing"))] pub mod testing { - use namada_core::types::dec::Dec; + use namada_core::dec::Dec; use proptest::prelude::*; use super::*; diff --git a/crates/proof_of_stake/src/pos_queries.rs b/crates/proof_of_stake/src/pos_queries.rs index f76d4c6ed8..8b07205f9e 100644 --- a/crates/proof_of_stake/src/pos_queries.rs +++ b/crates/proof_of_stake/src/pos_queries.rs @@ -1,10 +1,10 @@ //! Storage API for querying data about Proof-of-stake related //! data. This includes validator and epoch related data. -use namada_core::types::address::Address; -use namada_core::types::chain::ProposalBytes; -use namada_core::types::storage::{BlockHeight, Epoch}; -use namada_core::types::{key, token}; +use namada_core::address::Address; +use namada_core::chain::ProposalBytes; +use namada_core::storage::{BlockHeight, Epoch}; +use namada_core::{key, token}; use namada_parameters::storage::get_max_proposal_bytes_key; use namada_storage::collections::lazy_map::NestedSubKey; use namada_storage::StorageRead; diff --git a/crates/proof_of_stake/src/queries.rs b/crates/proof_of_stake/src/queries.rs index 0b98810cba..fcd4273ed5 100644 --- a/crates/proof_of_stake/src/queries.rs +++ b/crates/proof_of_stake/src/queries.rs @@ -4,10 +4,10 @@ use std::cmp; use std::collections::{BTreeMap, HashMap, HashSet}; use borsh::BorshDeserialize; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; +use namada_core::token; use namada_storage::collections::lazy_map::{NestedSubKey, SubKey}; use namada_storage::{self, StorageRead}; diff --git a/crates/proof_of_stake/src/rewards.rs b/crates/proof_of_stake/src/rewards.rs index c81a517db4..b6a2edd712 100644 --- a/crates/proof_of_stake/src/rewards.rs +++ b/crates/proof_of_stake/src/rewards.rs @@ -2,11 +2,11 @@ use std::collections::{HashMap, HashSet}; -use namada_core::types::address::{self, Address}; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; -use namada_core::types::token::{self, Amount}; -use namada_core::types::uint::{Uint, I256}; +use namada_core::address::{self, Address}; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; +use namada_core::token::{self, Amount}; +use namada_core::uint::{Uint, I256}; use namada_parameters::storage as params_storage; use namada_storage::collections::lazy_map::NestedSubKey; use namada_storage::{ResultExt, StorageRead, StorageWrite}; diff --git a/crates/proof_of_stake/src/slashing.rs b/crates/proof_of_stake/src/slashing.rs index 3d7361c3cf..acbda17255 100644 --- a/crates/proof_of_stake/src/slashing.rs +++ b/crates/proof_of_stake/src/slashing.rs @@ -4,10 +4,10 @@ use std::cmp::{self, Reverse}; use std::collections::{BTreeMap, BTreeSet, HashMap}; use borsh::BorshDeserialize; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::storage::Epoch; +use namada_core::token; use namada_storage::collections::lazy_map::{ Collectable, NestedMap, NestedSubKey, SubKey, }; diff --git a/crates/proof_of_stake/src/storage.rs b/crates/proof_of_stake/src/storage.rs index 36c0af84ac..9cae1168a9 100644 --- a/crates/proof_of_stake/src/storage.rs +++ b/crates/proof_of_stake/src/storage.rs @@ -4,11 +4,11 @@ use std::collections::{BTreeSet, HashSet}; use namada_account::protocol_pk_key; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::key::{common, tm_consensus_key_raw_hash}; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::key::{common, tm_consensus_key_raw_hash}; +use namada_core::storage::Epoch; +use namada_core::token; use namada_governance::storage::get_max_proposal_period; use namada_storage::collections::lazy_map::NestedSubKey; use namada_storage::collections::{LazyCollection, LazySet}; @@ -391,7 +391,7 @@ where pub fn read_validator_deltas_value( storage: &S, validator: &Address, - epoch: &namada_core::types::storage::Epoch, + epoch: &namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -407,7 +407,7 @@ pub fn read_validator_stake( storage: &S, params: &PosParams, validator: &Address, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result where S: StorageRead, @@ -429,7 +429,7 @@ pub fn update_validator_deltas( params: &OwnedPosParams, validator: &Address, delta: token::Change, - current_epoch: namada_core::types::storage::Epoch, + current_epoch: namada_core::storage::Epoch, offset_opt: Option, ) -> namada_storage::Result<()> where @@ -453,7 +453,7 @@ where pub fn read_total_stake( storage: &S, params: &PosParams, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result where S: StorageRead, @@ -472,7 +472,7 @@ where /// Read all addresses from consensus validator set. pub fn read_consensus_validator_set_addresses( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -487,7 +487,7 @@ where /// Read all addresses from below-capacity validator set. pub fn read_below_capacity_validator_set_addresses( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -502,7 +502,7 @@ where /// Read all addresses from the below-threshold set pub fn read_below_threshold_validator_set_addresses( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -524,7 +524,7 @@ where /// Read all addresses from consensus validator set with their stake. pub fn read_consensus_validator_set_addresses_with_stake( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -554,7 +554,7 @@ where /// Count the number of consensus validators pub fn get_num_consensus_validators( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result where S: StorageRead, @@ -568,7 +568,7 @@ where /// Read all addresses from below-capacity validator set with their stake. pub fn read_below_capacity_validator_set_addresses_with_stake( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -598,7 +598,7 @@ where /// Read all validator addresses. pub fn read_all_validator_addresses( storage: &S, - epoch: namada_core::types::storage::Epoch, + epoch: namada_core::storage::Epoch, ) -> namada_storage::Result> where S: StorageRead, @@ -615,7 +615,7 @@ pub fn update_total_deltas( storage: &mut S, params: &OwnedPosParams, delta: token::Change, - current_epoch: namada_core::types::storage::Epoch, + current_epoch: namada_core::storage::Epoch, offset_opt: Option, ) -> namada_storage::Result<()> where diff --git a/crates/proof_of_stake/src/storage_key.rs b/crates/proof_of_stake/src/storage_key.rs index 6135468a95..c64a677ce6 100644 --- a/crates/proof_of_stake/src/storage_key.rs +++ b/crates/proof_of_stake/src/storage_key.rs @@ -1,7 +1,7 @@ //! Proof-of-Stake storage keys and storage integration. -use namada_core::types::address::Address; -use namada_core::types::storage::{DbKeySeg, Epoch, Key, KeySeg}; +use namada_core::address::Address; +use namada_core::storage::{DbKeySeg, Epoch, Key, KeySeg}; use namada_storage::collections::{lazy_map, lazy_vec}; use super::ADDRESS; diff --git a/crates/proof_of_stake/src/tests/helpers.rs b/crates/proof_of_stake/src/tests/helpers.rs index 8a54eddd2e..a0671f6377 100644 --- a/crates/proof_of_stake/src/tests/helpers.rs +++ b/crates/proof_of_stake/src/tests/helpers.rs @@ -1,13 +1,13 @@ use std::cmp::max; use std::ops::Range; -use namada_core::types::address::testing::address_from_simple_seed; -use namada_core::types::dec::Dec; -use namada_core::types::key::testing::common_sk_from_simple_seed; -use namada_core::types::key::{self, RefTo}; -use namada_core::types::storage::Epoch; -use namada_core::types::token; -use namada_core::types::token::testing::arb_amount_non_zero_ceiled; +use namada_core::address::testing::address_from_simple_seed; +use namada_core::dec::Dec; +use namada_core::key::testing::common_sk_from_simple_seed; +use namada_core::key::{self, RefTo}; +use namada_core::storage::Epoch; +use namada_core::token; +use namada_core::token::testing::arb_amount_non_zero_ceiled; use namada_state::testing::TestWlStorage; use proptest::strategy::{Just, Strategy}; diff --git a/crates/proof_of_stake/src/tests/state_machine.rs b/crates/proof_of_stake/src/tests/state_machine.rs index 3dc34c36fa..e2d1ad0cfe 100644 --- a/crates/proof_of_stake/src/tests/state_machine.rs +++ b/crates/proof_of_stake/src/tests/state_machine.rs @@ -6,12 +6,12 @@ use std::ops::Deref; use assert_matches::assert_matches; use itertools::Itertools; -use namada_core::types::address::{self, Address}; -use namada_core::types::dec::Dec; -use namada_core::types::key; -use namada_core::types::key::common::PublicKey; -use namada_core::types::storage::Epoch; -use namada_core::types::token::Change; +use namada_core::address::{self, Address}; +use namada_core::dec::Dec; +use namada_core::key; +use namada_core::key::common::PublicKey; +use namada_core::storage::Epoch; +use namada_core::token::Change; use namada_governance::parameters::GovernanceParameters; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::{ diff --git a/crates/proof_of_stake/src/tests/state_machine_v2.rs b/crates/proof_of_stake/src/tests/state_machine_v2.rs index 872625f9d5..ee83c08f0d 100644 --- a/crates/proof_of_stake/src/tests/state_machine_v2.rs +++ b/crates/proof_of_stake/src/tests/state_machine_v2.rs @@ -7,12 +7,12 @@ use std::{cmp, mem}; use assert_matches::assert_matches; use derivative::Derivative; use itertools::Itertools; -use namada_core::types::address::{self, Address}; -use namada_core::types::dec::Dec; -use namada_core::types::key; -use namada_core::types::key::common::PublicKey; -use namada_core::types::storage::Epoch; -use namada_core::types::token::Change; +use namada_core::address::{self, Address}; +use namada_core::dec::Dec; +use namada_core::key; +use namada_core::key::common::PublicKey; +use namada_core::storage::Epoch; +use namada_core::token::Change; use namada_governance::parameters::GovernanceParameters; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::{NestedSubKey, SubKey}; diff --git a/crates/proof_of_stake/src/tests/test_helper_fns.rs b/crates/proof_of_stake/src/tests/test_helper_fns.rs index 5148224412..b4e08395fd 100644 --- a/crates/proof_of_stake/src/tests/test_helper_fns.rs +++ b/crates/proof_of_stake/src/tests/test_helper_fns.rs @@ -1,11 +1,11 @@ use std::collections::{BTreeMap, BTreeSet}; -use namada_core::types::address::testing::{ +use namada_core::address::testing::{ established_address_1, established_address_2, established_address_3, }; -use namada_core::types::dec::Dec; -use namada_core::types::storage::{Epoch, Key}; -use namada_core::types::token; +use namada_core::dec::Dec; +use namada_core::storage::{Epoch, Key}; +use namada_core::token; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::NestedMap; use namada_storage::collections::LazyCollection; @@ -1927,7 +1927,7 @@ fn test_compute_amount_after_slashing_withdraw() { /// SM test case 1 from Brent #[test] fn test_from_sm_case_1() { - use namada_core::types::address::testing::established_address_4; + use namada_core::address::testing::established_address_4; let mut storage = TestWlStorage::default(); let gov_params = diff --git a/crates/proof_of_stake/src/tests/test_pos.rs b/crates/proof_of_stake/src/tests/test_pos.rs index 72bc87c3e3..1be4fb90c1 100644 --- a/crates/proof_of_stake/src/tests/test_pos.rs +++ b/crates/proof_of_stake/src/tests/test_pos.rs @@ -2,14 +2,12 @@ use std::collections::{BTreeMap, HashSet}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::key::testing::{ - common_sk_from_simple_seed, gen_keypair, -}; -use namada_core::types::key::RefTo; -use namada_core::types::storage::{BlockHeight, Epoch}; -use namada_core::types::{address, key}; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::key::testing::{common_sk_from_simple_seed, gen_keypair}; +use namada_core::key::RefTo; +use namada_core::storage::{BlockHeight, Epoch}; +use namada_core::{address, key}; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::Collectable; use namada_storage::StorageRead; diff --git a/crates/proof_of_stake/src/tests/test_slash_and_redel.rs b/crates/proof_of_stake/src/tests/test_slash_and_redel.rs index a38912705b..29b51b861f 100644 --- a/crates/proof_of_stake/src/tests/test_slash_and_redel.rs +++ b/crates/proof_of_stake/src/tests/test_slash_and_redel.rs @@ -2,10 +2,10 @@ use std::ops::Deref; use std::str::FromStr; use assert_matches::assert_matches; -use namada_core::types::address; -use namada_core::types::dec::Dec; -use namada_core::types::storage::{BlockHeight, Epoch}; -use namada_core::types::token::NATIVE_MAX_DECIMAL_PLACES; +use namada_core::address; +use namada_core::dec::Dec; +use namada_core::storage::{BlockHeight, Epoch}; +use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::Collectable; use namada_storage::StorageRead; diff --git a/crates/proof_of_stake/src/tests/test_validator.rs b/crates/proof_of_stake/src/tests/test_validator.rs index ebcaec7703..35a6e0cdbb 100644 --- a/crates/proof_of_stake/src/tests/test_validator.rs +++ b/crates/proof_of_stake/src/tests/test_validator.rs @@ -1,14 +1,14 @@ use std::cmp::min; -use namada_core::types::address::testing::arb_established_address; -use namada_core::types::address::{self, Address, EstablishedAddressGen}; -use namada_core::types::dec::Dec; -use namada_core::types::key::testing::{ +use namada_core::address::testing::arb_established_address; +use namada_core::address::{self, Address, EstablishedAddressGen}; +use namada_core::dec::Dec; +use namada_core::key::testing::{ arb_common_keypair, common_sk_from_simple_seed, }; -use namada_core::types::key::{self, common, RefTo}; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::key::{self, common, RefTo}; +use namada_core::storage::Epoch; +use namada_core::token; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map; use proptest::prelude::*; diff --git a/crates/proof_of_stake/src/types/mod.rs b/crates/proof_of_stake/src/types/mod.rs index 282ab6a6d4..bf581566fb 100644 --- a/crates/proof_of_stake/src/types/mod.rs +++ b/crates/proof_of_stake/src/types/mod.rs @@ -10,12 +10,12 @@ use std::hash::Hash; use std::ops::Sub; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::key::common; -use namada_core::types::storage::{Epoch, KeySeg}; -use namada_core::types::token; -use namada_core::types::token::Amount; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::key::common; +use namada_core::storage::{Epoch, KeySeg}; +use namada_core::token; +use namada_core::token::Amount; use namada_storage::collections::lazy_map::NestedMap; use namada_storage::collections::{LazyMap, LazySet, LazyVec}; pub use rev_order::ReverseOrdTokenAmount; @@ -469,7 +469,7 @@ impl Display for WeightedValidator { pub struct Position(pub u64); impl KeySeg for Position { - fn parse(string: String) -> namada_core::types::storage::Result + fn parse(string: String) -> namada_core::storage::Result where Self: Sized, { @@ -481,7 +481,7 @@ impl KeySeg for Position { self.0.raw() } - fn to_db_key(&self) -> namada_core::types::storage::DbKeySeg { + fn to_db_key(&self) -> namada_core::storage::DbKeySeg { self.0.to_db_key() } } diff --git a/crates/proof_of_stake/src/types/rev_order.rs b/crates/proof_of_stake/src/types/rev_order.rs index 57619941d4..ef23fb9e53 100644 --- a/crates/proof_of_stake/src/types/rev_order.rs +++ b/crates/proof_of_stake/src/types/rev_order.rs @@ -1,5 +1,5 @@ -use namada_core::types::storage::KeySeg; -use namada_core::types::token; +use namada_core::storage::KeySeg; +use namada_core::token; /// A wrapper over `token::Amount`, whose `KeySeg` implementation has reverse /// order of the `token::Amount` type. @@ -27,7 +27,7 @@ fn invert(amount: token::Amount) -> token::Amount { } impl KeySeg for ReverseOrdTokenAmount { - fn parse(string: String) -> namada_core::types::storage::Result + fn parse(string: String) -> namada_core::storage::Result where Self: Sized, { @@ -39,7 +39,7 @@ impl KeySeg for ReverseOrdTokenAmount { invert(self.0).raw() } - fn to_db_key(&self) -> namada_core::types::storage::DbKeySeg { + fn to_db_key(&self) -> namada_core::storage::DbKeySeg { invert(self.0).to_db_key() } } diff --git a/crates/proof_of_stake/src/validator_set_update.rs b/crates/proof_of_stake/src/validator_set_update.rs index 3897697a01..1d6244b2b1 100644 --- a/crates/proof_of_stake/src/validator_set_update.rs +++ b/crates/proof_of_stake/src/validator_set_update.rs @@ -2,10 +2,10 @@ use std::collections::{HashMap, HashSet}; -use namada_core::types::address::Address; -use namada_core::types::key::PublicKeyTmRawHash; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::key::PublicKeyTmRawHash; +use namada_core::storage::Epoch; +use namada_core::token; use namada_storage::collections::lazy_map::{NestedSubKey, SubKey}; use namada_storage::{StorageRead, StorageWrite}; use num_traits::ops::checked::CheckedAdd; diff --git a/crates/replay_protection/src/lib.rs b/crates/replay_protection/src/lib.rs index 7f68314fcd..b014f39f02 100644 --- a/crates/replay_protection/src/lib.rs +++ b/crates/replay_protection/src/lib.rs @@ -1,7 +1,7 @@ //! Replay protection storage keys -use namada_core::types::hash::Hash; -use namada_core::types::storage::Key; +use namada_core::hash::Hash; +use namada_core::storage::Key; const ERROR_MSG: &str = "Cannot obtain a valid db key"; diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 707dfa97de..0c620e3d92 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -43,6 +43,7 @@ testing = [ "namada_governance/testing", "namada_ibc/testing", "namada_proof_of_stake/testing", + "namada_storage/testing", "namada_tx/testing", "async-client", "proptest", @@ -131,6 +132,7 @@ namada_proof_of_stake = { path = "../proof_of_stake", default-features = false, "testing", ] } namada_state = { path = "../state", features = ["testing"] } +namada_storage = { path = "../storage", features = ["testing"] } namada_test_utils = { path = "../test_utils" } namada_tx = { path = "../tx", features = ["testing"]} namada_vote_ext = {path = "../vote_ext"} diff --git a/crates/sdk/src/args.rs b/crates/sdk/src/args.rs index e8d2cbcdd2..960095b9a3 100644 --- a/crates/sdk/src/args.rs +++ b/crates/sdk/src/args.rs @@ -4,16 +4,16 @@ use std::collections::HashMap; use std::path::PathBuf; use std::time::Duration as StdDuration; -use namada_core::types::address::Address; -use namada_core::types::chain::ChainId; -use namada_core::types::dec::Dec; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::key::{common, SchemeType}; -use namada_core::types::masp::PaymentAddress; -use namada_core::types::storage::Epoch; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::{storage, token}; +use namada_core::address::Address; +use namada_core::chain::ChainId; +use namada_core::dec::Dec; +use namada_core::ethereum_events::EthAddress; +use namada_core::keccak::KeccakHash; +use namada_core::key::{common, SchemeType}; +use namada_core::masp::PaymentAddress; +use namada_core::storage::Epoch; +use namada_core::time::DateTimeUtc; +use namada_core::{storage, token}; use namada_governance::cli::onchain::{ DefaultProposal, PgfFundingProposal, PgfStewardProposal, }; @@ -93,17 +93,17 @@ pub struct BpConversionTableEntry { impl NamadaTypes for SdkTypes { type AddrOrNativeToken = Address; type Address = Address; - type BalanceOwner = namada_core::types::masp::BalanceOwner; + type BalanceOwner = namada_core::masp::BalanceOwner; type BpConversionTable = HashMap; type ConfigRpcTendermintAddress = tendermint_config::net::Address; type Data = Vec; type EthereumAddress = (); - type Keypair = namada_core::types::key::common::SecretKey; - type PublicKey = namada_core::types::key::common::PublicKey; + type Keypair = namada_core::key::common::SecretKey; + type PublicKey = namada_core::key::common::PublicKey; type TendermintAddress = tendermint_config::net::Address; - type TransferSource = namada_core::types::masp::TransferSource; - type TransferTarget = namada_core::types::masp::TransferTarget; - type ViewingKey = namada_core::types::masp::ExtendedViewingKey; + type TransferSource = namada_core::masp::TransferSource; + type TransferTarget = namada_core::masp::TransferTarget; + type ViewingKey = namada_core::masp::ExtendedViewingKey; } /// Common query arguments diff --git a/crates/sdk/src/error.rs b/crates/sdk/src/error.rs index a8cb147da4..d50e385d41 100644 --- a/crates/sdk/src/error.rs +++ b/crates/sdk/src/error.rs @@ -1,11 +1,11 @@ //! Generic Error Type for all of the Shared Crate +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::ethereum_events::EthAddress; use namada_core::event::EventError; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::storage; -use namada_core::types::storage::Epoch; +use namada_core::storage; +use namada_core::storage::Epoch; use namada_tx::Tx; use prost::EncodeError; use tendermint_rpc::Error as RpcError; diff --git a/crates/sdk/src/eth_bridge/bridge_pool.rs b/crates/sdk/src/eth_bridge/bridge_pool.rs index 6712e463c8..8189953dfb 100644 --- a/crates/sdk/src/eth_bridge/bridge_pool.rs +++ b/crates/sdk/src/eth_bridge/bridge_pool.rs @@ -9,15 +9,15 @@ use borsh_ext::BorshSerializeExt; use ethbridge_bridge_contract::Bridge; use ethers::providers::Middleware; use futures::future::FutureExt; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::eth_abi::Encode; -use namada_core::types::eth_bridge_pool::{ +use namada_core::address::{Address, InternalAddress}; +use namada_core::eth_abi::Encode; +use namada_core::eth_bridge_pool::{ erc20_token_address, GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, }; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::voting_power::FractionalVotingPower; +use namada_core::ethereum_events::EthAddress; +use namada_core::keccak::KeccakHash; +use namada_core::voting_power::FractionalVotingPower; use namada_ethereum_bridge::storage::bridge_pool::get_pending_key; use namada_token::storage_key::balance_key; use namada_token::Amount; @@ -737,9 +737,9 @@ mod recommendations { use std::collections::BTreeSet; use borsh::BorshDeserialize; - use namada_core::types::ethereum_events::Uint as EthUint; - use namada_core::types::storage::BlockHeight; - use namada_core::types::uint::{self, Uint, I256}; + use namada_core::ethereum_events::Uint as EthUint; + use namada_core::storage::BlockHeight; + use namada_core::uint::{self, Uint, I256}; use namada_vote_ext::validator_set_update::{ EthAddrBook, VotingPowersMap, VotingPowersMapExt, }; @@ -1213,7 +1213,7 @@ mod recommendations { #[cfg(test)] mod test_recommendations { - use namada_core::types::address::Address; + use namada_core::address::Address; use super::*; use crate::io::StdIo; @@ -1236,7 +1236,7 @@ mod recommendations { amount: Default::default(), }, gas_fee: GasFee { - token: namada_core::types::address::nam(), + token: namada_core::address::nam(), amount: gas_amount.into(), payer: bertha_address(), }, @@ -1279,7 +1279,7 @@ mod recommendations { /// Add ETH to a conversion table. fn add_eth_to_conversion_table(&mut self) { self.conversion_table.insert( - namada_core::types::address::eth(), + namada_core::address::eth(), args::BpConversionTableEntry { alias: "ETH".into(), conversion_rate: 1e9, // 1 ETH = 1e9 GWEI @@ -1304,7 +1304,7 @@ mod recommendations { amount: Default::default(), }, gas_fee: GasFee { - token: namada_core::types::address::eth(), + token: namada_core::address::eth(), amount: 1_000_000_000_u64.into(), // 1 GWEI payer: bertha_address(), }, @@ -1537,14 +1537,14 @@ mod recommendations { let conversion_table = { let mut t = HashMap::new(); t.insert( - namada_core::types::address::apfel(), + namada_core::address::apfel(), args::BpConversionTableEntry { alias: APFEL.into(), conversion_rate: APF_RATE, }, ); t.insert( - namada_core::types::address::schnitzel(), + namada_core::address::schnitzel(), args::BpConversionTableEntry { alias: SCHNITZEL.into(), conversion_rate: SCH_RATE, @@ -1559,15 +1559,13 @@ mod recommendations { let transfer_paid_in_apfel = { let mut pending = ctx.pending.clone(); pending.transfer.amount = 1.into(); - pending.gas_fee.token = - namada_core::types::address::apfel(); + pending.gas_fee.token = namada_core::address::apfel(); pending }; let transfer_paid_in_schnitzel = { let mut pending = ctx.pending.clone(); pending.transfer.amount = 2.into(); - pending.gas_fee.token = - namada_core::types::address::schnitzel(); + pending.gas_fee.token = namada_core::address::schnitzel(); pending }; // add the transfers to the pool, and expect them to diff --git a/crates/sdk/src/eth_bridge/mod.rs b/crates/sdk/src/eth_bridge/mod.rs index ecebd05c32..98c84fcf6c 100644 --- a/crates/sdk/src/eth_bridge/mod.rs +++ b/crates/sdk/src/eth_bridge/mod.rs @@ -8,7 +8,7 @@ use std::ops::ControlFlow; pub use ethers; use ethers::providers::Middleware; use itertools::Either; -pub use namada_core::types::ethereum_structs as structs; +pub use namada_core::ethereum_structs as structs; pub use namada_ethereum_bridge::storage::eth_bridge_queries::*; pub use namada_ethereum_bridge::storage::parameters::*; pub use namada_ethereum_bridge::storage::wrapped_erc20s; diff --git a/crates/sdk/src/eth_bridge/validator_set.rs b/crates/sdk/src/eth_bridge/validator_set.rs index c11b9b62c6..f532d10825 100644 --- a/crates/sdk/src/eth_bridge/validator_set.rs +++ b/crates/sdk/src/eth_bridge/validator_set.rs @@ -10,10 +10,10 @@ use data_encoding::HEXLOWER; use ethbridge_bridge_contract::Bridge; use ethers::providers::Middleware; use futures::future::{self, FutureExt}; +use namada_core::eth_abi::EncodeCell; +use namada_core::ethereum_events::EthAddress; use namada_core::hints; -use namada_core::types::eth_abi::EncodeCell; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::storage::Epoch; +use namada_core::storage::Epoch; use namada_ethereum_bridge::storage::proof::EthereumProof; use namada_vote_ext::validator_set_update::{ ValidatorSetArgs, VotingPowersMap, @@ -24,7 +24,7 @@ use crate::control_flow::install_shutdown_signal; use crate::control_flow::time::{self, Duration, Instant}; use crate::error::{Error as SdkError, EthereumBridgeError, QueryError}; use crate::eth_bridge::ethers::abi::{AbiDecode, AbiType, Tokenizable}; -use crate::eth_bridge::ethers::core::types::TransactionReceipt; +use crate::eth_bridge::ethers::types::TransactionReceipt; use crate::eth_bridge::structs::Signature; use crate::internal_macros::{echo_error, trace_error}; use crate::io::Io; diff --git a/crates/sdk/src/events/log.rs b/crates/sdk/src/events/log.rs index 596c23bdc9..fa47d0fd3c 100644 --- a/crates/sdk/src/events/log.rs +++ b/crates/sdk/src/events/log.rs @@ -85,7 +85,7 @@ impl EventLog { #[cfg(test)] mod tests { - use namada_core::types::hash::Hash; + use namada_core::hash::Hash; use super::*; use crate::events::{EventLevel, EventType}; diff --git a/crates/sdk/src/events/log/dumb_queries.rs b/crates/sdk/src/events/log/dumb_queries.rs index 8a639b5a1b..1d2b0527a2 100644 --- a/crates/sdk/src/events/log/dumb_queries.rs +++ b/crates/sdk/src/events/log/dumb_queries.rs @@ -8,8 +8,8 @@ use std::collections::HashMap; -use namada_core::types::hash::Hash; -use namada_core::types::storage::BlockHeight; +use namada_core::hash::Hash; +use namada_core::storage::BlockHeight; use crate::events::{Event, EventType}; use crate::ibc::core::client::types::Height as IbcHeight; diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 74b15fbfd3..e495abe216 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -1,6 +1,6 @@ extern crate alloc; -pub use namada_core::{borsh, ibc, tendermint, tendermint_proto, types}; +pub use namada_core::*; #[cfg(feature = "tendermint-rpc")] pub use tendermint_rpc; pub use { @@ -36,13 +36,12 @@ use std::path::PathBuf; use std::str::FromStr; use args::{InputAmount, SdkTypes}; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::ethereum_events::EthAddress; use namada_core::ibc::core::host::types::identifiers::{ChannelId, PortId}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::key::*; -use namada_core::types::masp::{TransferSource, TransferTarget}; -use namada_core::types::token; +use namada_core::key::*; +use namada_core::masp::{TransferSource, TransferTarget}; use namada_tx::data::wrapper::GasLimit; use namada_tx::Tx; use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -767,17 +766,15 @@ pub mod testing { use ibc::primitives::proto::Any; use masp_primitives::transaction::TransparentAddress; use namada_account::{InitAccount, UpdateAccount}; - use namada_core::types::address::testing::{ + use namada_core::address::testing::{ arb_established_address, arb_non_internal_address, }; - use namada_core::types::address::MASP; - use namada_core::types::eth_bridge_pool::PendingTransfer; - use namada_core::types::hash::testing::arb_hash; - use namada_core::types::storage::testing::arb_epoch; - use namada_core::types::token::testing::{ - arb_denominated_amount, arb_transfer, - }; - use namada_core::types::token::Transfer; + use namada_core::address::MASP; + use namada_core::eth_bridge_pool::PendingTransfer; + use namada_core::hash::testing::arb_hash; + use namada_core::storage::testing::arb_epoch; + use namada_core::token::testing::{arb_denominated_amount, arb_transfer}; + use namada_core::token::Transfer; use namada_governance::storage::proposal::testing::{ arb_init_proposal, arb_vote_proposal, }; @@ -797,9 +794,13 @@ pub mod testing { use super::*; use crate::account::tests::{arb_init_account, arb_update_account}; + use crate::chain::ChainId; + use crate::eth_bridge_pool::testing::arb_pending_transfer; + use crate::key::testing::arb_common_pk; use crate::masp::testing::{ arb_deshielding_transfer, arb_shielded_transfer, arb_shielding_transfer, }; + use crate::time::{DateTime, DateTimeUtc, Utc}; use crate::tx::data::pgf::tests::arb_update_steward_commission; use crate::tx::data::pos::tests::{ arb_become_validator, arb_bond, arb_commission_change, @@ -807,10 +808,6 @@ pub mod testing { arb_withdraw, }; use crate::tx::{Code, Commitment, Header, MaspBuilder, Section}; - use crate::types::chain::ChainId; - use crate::types::eth_bridge_pool::testing::arb_pending_transfer; - use crate::types::key::testing::arb_common_pk; - use crate::types::time::{DateTime, DateTimeUtc, Utc}; #[derive(Debug)] #[allow(clippy::large_enum_variant)] diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index c3cf8d1bf3..ae95247866 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -51,15 +51,15 @@ use masp_proofs::bellman::groth16::PreparedVerifyingKey; use masp_proofs::bls12_381::Bls12; use masp_proofs::prover::LocalTxProver; use masp_proofs::sapling::SaplingVerificationContext; -use namada_core::types::address::{Address, MASP}; -use namada_core::types::dec::Dec; -use namada_core::types::masp::{ +use namada_core::address::{Address, MASP}; +use namada_core::dec::Dec; +use namada_core::masp::{ encode_asset_type, AssetData, BalanceOwner, ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget, }; -use namada_core::types::storage::{BlockHeight, Epoch, IndexedTx, TxIndex}; -use namada_core::types::time::{DateTimeUtc, DurationSecs}; -use namada_core::types::uint::Uint; +use namada_core::storage::{BlockHeight, Epoch, IndexedTx, TxIndex}; +use namada_core::time::{DateTimeUtc, DurationSecs}; +use namada_core::uint::Uint; use namada_ibc::IbcMessage; use namada_token::{self as token, Denomination, MaspDigitPos, Transfer}; use namada_tx::data::{TxResult, WrapperTx}; @@ -702,11 +702,7 @@ impl ShieldedContext { ) -> Result< BTreeMap< IndexedTx, - ( - Epoch, - BTreeSet, - Transaction, - ), + (Epoch, BTreeSet, Transaction), >, Error, > { @@ -791,8 +787,7 @@ impl ShieldedContext { tx: &Tx, action_arg: ExtractShieldedActionArg<'args, C>, check_header: bool, - ) -> Result<(BTreeSet, Transaction), Error> - { + ) -> Result<(BTreeSet, Transaction), Error> { let maybe_transaction = if check_header { let tx_header = tx.header(); // NOTE: simply looking for masp sections attached to the tx @@ -943,7 +938,7 @@ impl ShieldedContext { &mut self, indexed_tx: IndexedTx, epoch: Epoch, - tx_changed_keys: &BTreeSet, + tx_changed_keys: &BTreeSet, shielded: &Transaction, native_token: Address, ) -> Result<(), Error> { @@ -2256,8 +2251,7 @@ impl ShieldedContext { #[cfg(feature = "testing")] { - let builder_hash = - namada_core::types::hash::Hash::sha256(&builder_bytes); + let builder_hash = namada_core::hash::Hash::sha256(&builder_bytes); let saved_filepath = env::current_dir() .map_err(|e| Error::Other(e.to_string()))? @@ -2567,7 +2561,7 @@ enum ExtractShieldedActionArg<'args, C: Client + Sync> { async fn extract_payload_from_shielded_action<'args, C: Client + Sync>( tx_data: &[u8], args: ExtractShieldedActionArg<'args, C>, -) -> Result<(BTreeSet, Transaction), Error> { +) -> Result<(BTreeSet, Transaction), Error> { let message = namada_ibc::decode_message(tx_data) .map_err(|e| Error::Other(e.to_string()))?; @@ -2644,7 +2638,7 @@ async fn extract_payload_from_shielded_action<'args, C: Client + Sync>( TxResult::from_str(&attribute.value).unwrap(); for ibc_event in &tx_result.ibc_events { let event = - namada_core::types::ibc::get_shielded_transfer( + namada_core::ibc::get_shielded_transfer( ibc_event, ) .ok() @@ -2814,15 +2808,15 @@ pub mod testing { use proptest::{collection, option, prop_compose}; use super::*; + use crate::address::testing::arb_address; use crate::masp_primitives::consensus::BranchId; use crate::masp_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR; use crate::masp_primitives::merkle_tree::FrozenCommitmentTree; use crate::masp_primitives::sapling::keys::OutgoingViewingKey; use crate::masp_primitives::sapling::redjubjub::PrivateKey; use crate::masp_primitives::transaction::components::transparent::testing::arb_transparent_address; + use crate::storage::testing::arb_epoch; use crate::token::testing::arb_denomination; - use crate::types::address::testing::arb_address; - use crate::types::storage::testing::arb_epoch; #[derive(Debug, Clone)] // Adapts a CSPRNG from a PRNG for proptesting diff --git a/crates/sdk/src/queries/mod.rs b/crates/sdk/src/queries/mod.rs index bf30131170..5753b989c5 100644 --- a/crates/sdk/src/queries/mod.rs +++ b/crates/sdk/src/queries/mod.rs @@ -2,7 +2,7 @@ //! defined via `router!` macro. // Re-export to show in rustdoc! -use namada_core::types::storage::BlockHeight; +use namada_core::storage::BlockHeight; use namada_state::{DBIter, StorageHasher, DB}; pub use shell::Shell; use shell::SHELL; @@ -97,7 +97,7 @@ pub fn require_no_data(request: &RequestQuery) -> namada_storage::Result<()> { #[cfg(any(test, feature = "testing"))] mod testing { - use namada_core::types::storage::BlockHeight; + use namada_core::storage::BlockHeight; use namada_state::testing::TestWlStorage; use tendermint_rpc::Response; @@ -133,10 +133,7 @@ mod testing { namada_parameters::storage::get_max_block_gas_key(); wl_storage .storage - .write( - &max_block_gas_key, - namada_core::types::encode(&20_000_000_u64), - ) + .write(&max_block_gas_key, namada_core::encode(&20_000_000_u64)) .expect( "Max block gas parameter must be initialized in storage", ); diff --git a/crates/sdk/src/queries/router.rs b/crates/sdk/src/queries/router.rs index 31931dc8c6..63e8060250 100644 --- a/crates/sdk/src/queries/router.rs +++ b/crates/sdk/src/queries/router.rs @@ -401,7 +401,7 @@ macro_rules! pattern_and_handler_to_method { `storage_value` and `storage_prefix`) from `storage_value`."] pub async fn storage_value(&self, client: &CLIENT, data: Option>, - height: Option, + height: Option, prove: bool, $( $param: &$param_ty ),* ) @@ -453,7 +453,7 @@ macro_rules! pattern_and_handler_to_method { `storage_value` and `storage_prefix`) from `" $handle "`."] pub async fn $handle(&self, client: &CLIENT, data: Option>, - height: Option, + height: Option, prove: bool, $( $param: &$param_ty ),* ) @@ -835,8 +835,8 @@ macro_rules! router { #[cfg(test)] mod test_rpc_handlers { use borsh_ext::BorshSerializeExt; - use namada_core::types::storage::Epoch; - use namada_core::types::token; + use namada_core::storage::Epoch; + use namada_core::token; use namada_state::{DBIter, StorageHasher, DB}; use crate::queries::{ @@ -962,8 +962,8 @@ mod test_rpc_handlers { /// ``` #[cfg(test)] mod test_rpc { - use namada_core::types::storage::Epoch; - use namada_core::types::token; + use namada_core::storage::Epoch; + use namada_core::token; use super::test_rpc_handlers::*; @@ -1000,10 +1000,10 @@ mod test_rpc { #[cfg(test)] mod test { + use namada_core::storage::Epoch; use namada_core::tendermint::block; - use namada_core::types::storage::Epoch; - use namada_core::types::token; - use namada_core::types::token::NATIVE_MAX_DECIMAL_PLACES; + use namada_core::token; + use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use super::test_rpc::TEST_RPC; use crate::queries::testing::TestClient; diff --git a/crates/sdk/src/queries/shell.rs b/crates/sdk/src/queries/shell.rs index 3450425eff..4c37ade7ce 100644 --- a/crates/sdk/src/queries/shell.rs +++ b/crates/sdk/src/queries/shell.rs @@ -8,15 +8,15 @@ use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; use namada_account::{Account, AccountPublicKeysMap}; +use namada_core::address::Address; +use namada_core::dec::Dec; +use namada_core::hash::Hash; use namada_core::hints; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::hash::Hash; -use namada_core::types::storage::{ +use namada_core::storage::{ self, BlockHeight, BlockResults, Epoch, KeySeg, PrefixValue, }; -use namada_core::types::token::{Denomination, MaspDigitPos}; -use namada_core::types::uint::Uint; +use namada_core::token::{Denomination, MaspDigitPos}; +use namada_core::uint::Uint; use namada_state::{DBIter, LastBlock, StorageHasher, DB}; use namada_storage::{self, ResultExt, StorageRead}; #[cfg(any(test, feature = "async-client"))] @@ -615,7 +615,7 @@ where #[cfg(test)] mod test { - use namada_core::types::address; + use namada_core::address; use namada_token::storage_key::balance_key; use crate::queries::RPC; diff --git a/crates/sdk/src/queries/shell/eth_bridge.rs b/crates/sdk/src/queries/shell/eth_bridge.rs index 92ee5f3ca8..913155d5b2 100644 --- a/crates/sdk/src/queries/shell/eth_bridge.rs +++ b/crates/sdk/src/queries/shell/eth_bridge.rs @@ -6,20 +6,17 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; use borsh_ext::BorshSerializeExt; -use namada_core::hints; -use namada_core::types::address::Address; -use namada_core::types::eth_abi::{Encode, EncodeCell}; -use namada_core::types::eth_bridge_pool::{ - PendingTransfer, PendingTransferAppendix, -}; -use namada_core::types::ethereum_events::{ +use namada_core::address::Address; +use namada_core::eth_abi::{Encode, EncodeCell}; +use namada_core::eth_bridge_pool::{PendingTransfer, PendingTransferAppendix}; +use namada_core::ethereum_events::{ EthAddress, EthereumEvent, TransferToEthereum, }; -use namada_core::types::ethereum_structs; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::storage::{BlockHeight, DbKeySeg, Epoch, Key}; -use namada_core::types::token::Amount; -use namada_core::types::voting_power::FractionalVotingPower; +use namada_core::keccak::KeccakHash; +use namada_core::storage::{BlockHeight, DbKeySeg, Epoch, Key}; +use namada_core::token::Amount; +use namada_core::voting_power::FractionalVotingPower; +use namada_core::{ethereum_structs, hints}; use namada_ethereum_bridge::protocol::transactions::votes::{ EpochedVotingPower, EpochedVotingPowerExt, }; @@ -837,15 +834,15 @@ mod test_ethbridge_router { use std::collections::BTreeMap; use assert_matches::assert_matches; - use namada_core::types::address::nam; - use namada_core::types::address::testing::established_address_1; - use namada_core::types::eth_abi::Encode; - use namada_core::types::eth_bridge_pool::{ + use namada_core::address::nam; + use namada_core::address::testing::established_address_1; + use namada_core::eth_abi::Encode; + use namada_core::eth_bridge_pool::{ GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, }; - use namada_core::types::ethereum_events::EthAddress; - use namada_core::types::storage::BlockHeight; - use namada_core::types::voting_power::{ + use namada_core::ethereum_events::EthAddress; + use namada_core::storage::BlockHeight; + use namada_core::voting_power::{ EthBridgeVotingPower, FractionalVotingPower, }; use namada_ethereum_bridge::protocol::transactions::validator_set_update::aggregate_votes; @@ -1443,8 +1440,8 @@ mod test_ethbridge_router { .write(&get_pending_key(&transfer), &transfer) .expect("Test failed"); - let event_transfer: namada_core::types::ethereum_events::TransferToEthereum - = (&transfer).into(); + let event_transfer: namada_core::ethereum_events::TransferToEthereum = + (&transfer).into(); let eth_event = EthereumEvent::TransfersToEthereum { nonce: Default::default(), transfers: vec![event_transfer.clone()], @@ -1791,7 +1788,7 @@ mod test_ethbridge_router { #[cfg(any(feature = "testing", test))] #[allow(dead_code)] mod test_utils { - use namada_core::types::address::Address; + use namada_core::address::Address; pub use namada_ethereum_bridge::test_utils::*; /// An established user address for testing & development diff --git a/crates/sdk/src/queries/types.rs b/crates/sdk/src/queries/types.rs index 614a717a8e..00b57368cc 100644 --- a/crates/sdk/src/queries/types.rs +++ b/crates/sdk/src/queries/types.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -use namada_core::types::storage::BlockHeight; +use namada_core::storage::BlockHeight; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use thiserror::Error; diff --git a/crates/sdk/src/queries/vp/pgf.rs b/crates/sdk/src/queries/vp/pgf.rs index 4b8431e854..7b767911bb 100644 --- a/crates/sdk/src/queries/vp/pgf.rs +++ b/crates/sdk/src/queries/vp/pgf.rs @@ -1,4 +1,4 @@ -use namada_core::types::address::Address; +use namada_core::address::Address; use namada_governance::pgf::parameters::PgfParameters; use namada_governance::pgf::storage::steward::StewardDetail; use namada_governance::storage::proposal::StoragePgfFunding; diff --git a/crates/sdk/src/queries/vp/pos.rs b/crates/sdk/src/queries/vp/pos.rs index 02b395f269..d6bc889660 100644 --- a/crates/sdk/src/queries/vp/pos.rs +++ b/crates/sdk/src/queries/vp/pos.rs @@ -3,10 +3,10 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::key::common; -use namada_core::types::storage::Epoch; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::key::common; +use namada_core::storage::Epoch; +use namada_core::token; use namada_proof_of_stake::parameters::PosParams; use namada_proof_of_stake::queries::{ find_delegation_validators, find_delegations, diff --git a/crates/sdk/src/queries/vp/token.rs b/crates/sdk/src/queries/vp/token.rs index fb77a396a4..e9696e796d 100644 --- a/crates/sdk/src/queries/vp/token.rs +++ b/crates/sdk/src/queries/vp/token.rs @@ -1,7 +1,7 @@ //! Token validity predicate queries -use namada_core::types::address::Address; -use namada_core::types::token; +use namada_core::address::Address; +use namada_core::token; use namada_state::{DBIter, StorageHasher, DB}; use namada_token::{read_denom, read_total_supply}; @@ -40,8 +40,8 @@ where #[cfg(any(test, feature = "async-client"))] pub mod client_only_methods { use borsh::BorshDeserialize; - use namada_core::types::address::Address; - use namada_core::types::token; + use namada_core::address::Address; + use namada_core::token; use namada_token::storage_key::balance_key; use super::Token; diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index bed1ebe51d..eab9238337 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -10,16 +10,16 @@ use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; use namada_account::Account; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::hash::Hash; -use namada_core::types::key::common; -use namada_core::types::storage::{ +use namada_core::address::{Address, InternalAddress}; +use namada_core::hash::Hash; +use namada_core::key::common; +use namada_core::storage::{ BlockHeight, BlockResults, Epoch, Key, PrefixValue, }; -use namada_core::types::token::{ +use namada_core::token::{ Amount, DenominatedAmount, Denomination, MaspDigitPos, }; -use namada_core::types::{storage, token}; +use namada_core::{storage, token}; use namada_governance::parameters::GovernanceParameters; use namada_governance::pgf::parameters::PgfParameters; use namada_governance::pgf::storage::steward::StewardDetail; diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index 1519b1ae49..961c796c52 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -11,17 +11,15 @@ use masp_primitives::transaction::components::sapling::fees::{ InputView, OutputView, }; use namada_account::{AccountPublicKeysMap, InitAccount, UpdateAccount}; -use namada_core::types::address::{ - Address, ImplicitAddress, InternalAddress, MASP, -}; -use namada_core::types::key::*; -use namada_core::types::masp::{AssetData, ExtendedViewingKey, PaymentAddress}; -use namada_core::types::sign::SignatureIndex; -use namada_core::types::storage::Epoch; -use namada_core::types::token; -use namada_core::types::token::Transfer; -// use namada_core::types::storage::Key; -use namada_core::types::token::{Amount, DenominatedAmount}; +use namada_core::address::{Address, ImplicitAddress, InternalAddress, MASP}; +use namada_core::key::*; +use namada_core::masp::{AssetData, ExtendedViewingKey, PaymentAddress}; +use namada_core::sign::SignatureIndex; +use namada_core::storage::Epoch; +use namada_core::token; +use namada_core::token::Transfer; +// use namada_core::storage::Key; +use namada_core::token::{Amount, DenominatedAmount}; use namada_governance::storage::proposal::{ InitProposalData, ProposalType, VoteProposalData, }; @@ -41,6 +39,7 @@ use tokio::sync::RwLock; use super::masp::{ShieldedContext, ShieldedTransfer}; use crate::args::SdkTypes; use crate::error::{EncodingError, Error, TxSubmitError}; +use crate::eth_bridge_pool::PendingTransfer; use crate::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use crate::ibc::primitives::proto::Any; use crate::io::*; @@ -56,7 +55,6 @@ use crate::tx::{ TX_UPDATE_STEWARD_COMMISSION, TX_VOTE_PROPOSAL, TX_WITHDRAW_WASM, VP_USER_WASM, }; -use crate::types::eth_bridge_pool::PendingTransfer; pub use crate::wallet::store::AddressVpType; use crate::wallet::{Wallet, WalletIo}; use crate::{args, display_line, rpc, MaybeSend, Namada}; @@ -506,7 +504,7 @@ pub async fn wrap_tx( Some(diff) if !diff.is_zero() => { if let Some(spending_key) = args.fee_unshield.clone() { // Unshield funds for fee payment - let target = namada_core::types::masp::TransferTarget::Address( + let target = namada_core::masp::TransferTarget::Address( fee_payer_address.clone(), ); let fee_amount = DenominatedAmount::new( @@ -638,7 +636,7 @@ pub async fn wrap_tx( let mut hasher = sha2::Sha256::new(); section.hash(&mut hasher); tx.add_section(section); - namada_core::types::hash::Hash(hasher.finalize().into()) + namada_core::hash::Hash(hasher.finalize().into()) }); tx.add_wrapper( diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index a5ff9da0da..ee8c1de075 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -19,6 +19,9 @@ use masp_primitives::transaction::components::transparent::fees::{ }; use masp_primitives::transaction::components::I128Sum; use namada_account::{InitAccount, UpdateAccount}; +use namada_core::address::{Address, InternalAddress, MASP}; +use namada_core::dec::Dec; +use namada_core::hash::Hash; use namada_core::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use namada_core::ibc::apps::transfer::types::packet::PacketData; use namada_core::ibc::apps::transfer::types::PrefixedCoin; @@ -26,15 +29,12 @@ use namada_core::ibc::core::channel::types::timeout::TimeoutHeight; use namada_core::ibc::core::client::types::Height as IbcHeight; use namada_core::ibc::core::host::types::identifiers::{ChannelId, PortId}; use namada_core::ibc::primitives::{Msg, Timestamp as IbcTimestamp}; -use namada_core::types::address::{Address, InternalAddress, MASP}; -use namada_core::types::dec::Dec; -use namada_core::types::hash::Hash; -use namada_core::types::ibc::{IbcShieldedTransfer, MsgShieldedTransfer}; -use namada_core::types::key::*; -use namada_core::types::masp::{AssetData, TransferSource, TransferTarget}; -use namada_core::types::storage::Epoch; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::{storage, token}; +use namada_core::ibc::{IbcShieldedTransfer, MsgShieldedTransfer}; +use namada_core::key::*; +use namada_core::masp::{AssetData, TransferSource, TransferTarget}; +use namada_core::storage::Epoch; +use namada_core::time::DateTimeUtc; +use namada_core::{storage, token}; use namada_governance::cli::onchain::{ DefaultProposal, OnChainProposal, PgfFundingProposal, PgfStewardProposal, }; diff --git a/crates/sdk/src/wallet/alias.rs b/crates/sdk/src/wallet/alias.rs index 48ab4a9fa0..1801d5fbad 100644 --- a/crates/sdk/src/wallet/alias.rs +++ b/crates/sdk/src/wallet/alias.rs @@ -7,7 +7,7 @@ use std::io::Read; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::{Address, InternalAddress}; +use namada_core::address::{Address, InternalAddress}; use serde::{Deserialize, Serialize}; /// Aliases created from raw strings are kept in-memory as given, but their diff --git a/crates/sdk/src/wallet/derivation_path.rs b/crates/sdk/src/wallet/derivation_path.rs index 3210450d26..79296038ac 100644 --- a/crates/sdk/src/wallet/derivation_path.rs +++ b/crates/sdk/src/wallet/derivation_path.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use derivation_path::{ChildIndex, DerivationPath as DerivationPathInner}; use masp_primitives::zip32; -use namada_core::types::key::SchemeType; +use namada_core::key::SchemeType; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; use tiny_hderive::bip44::{ @@ -272,7 +272,7 @@ impl From for Vec { #[cfg(test)] mod tests { - use namada_core::types::key::SchemeType; + use namada_core::key::SchemeType; use super::DerivationPath; diff --git a/crates/sdk/src/wallet/mod.rs b/crates/sdk/src/wallet/mod.rs index 5fae3db2ad..2bea2cc8f7 100644 --- a/crates/sdk/src/wallet/mod.rs +++ b/crates/sdk/src/wallet/mod.rs @@ -12,9 +12,9 @@ use std::str::FromStr; use alias::Alias; use bip39::{Language, Mnemonic, MnemonicType, Seed}; use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::key::*; -use namada_core::types::masp::{ +use namada_core::address::Address; +use namada_core::key::*; +use namada_core::masp::{ ExtendedSpendingKey, ExtendedViewingKey, PaymentAddress, }; pub use pre_genesis::gen_key_to_store; diff --git a/crates/sdk/src/wallet/pre_genesis.rs b/crates/sdk/src/wallet/pre_genesis.rs index abbb918470..dbe1a11571 100644 --- a/crates/sdk/src/wallet/pre_genesis.rs +++ b/crates/sdk/src/wallet/pre_genesis.rs @@ -1,5 +1,5 @@ //! Provides functionality for managing validator keys -use namada_core::types::key::{common, SchemeType}; +use namada_core::key::{common, SchemeType}; use rand::{CryptoRng, Rng}; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/sdk/src/wallet/store.rs b/crates/sdk/src/wallet/store.rs index 533d657f8d..c356081074 100644 --- a/crates/sdk/src/wallet/store.rs +++ b/crates/sdk/src/wallet/store.rs @@ -7,9 +7,9 @@ use std::str::FromStr; use bimap::BiBTreeMap; use itertools::Itertools; use masp_primitives::zip32; -use namada_core::types::address::{Address, ImplicitAddress}; -use namada_core::types::key::*; -use namada_core::types::masp::{ +use namada_core::address::{Address, ImplicitAddress}; +use namada_core::key::*; +use namada_core::masp::{ ExtendedSpendingKey, ExtendedViewingKey, PaymentAddress, }; use serde::{Deserialize, Serialize}; diff --git a/crates/shielded_token/src/conversion.rs b/crates/shielded_token/src/conversion.rs index b2a560d3c5..d247b65026 100644 --- a/crates/shielded_token/src/conversion.rs +++ b/crates/shielded_token/src/conversion.rs @@ -1,8 +1,8 @@ //! MASP rewards conversions -use namada_core::types::address::{Address, MASP}; -use namada_core::types::dec::Dec; -use namada_core::types::uint::Uint; +use namada_core::address::{Address, MASP}; +use namada_core::dec::Dec; +use namada_core::uint::Uint; use namada_parameters as parameters; use namada_storage::{StorageRead, StorageWrite}; use namada_trans_token::inflation::{ @@ -208,8 +208,8 @@ where use masp_primitives::merkle_tree::FrozenCommitmentTree; use masp_primitives::sapling::Node; use masp_primitives::transaction::components::I128Sum as MaspAmount; - use namada_core::types::masp::encode_asset_type; - use namada_core::types::storage::Epoch; + use namada_core::masp::encode_asset_type; + use namada_core::storage::Epoch; use namada_storage::ResultExt; use namada_trans_token::{MaspDigitPos, NATIVE_MAX_DECIMAL_PLACES}; use rayon::iter::{ @@ -485,7 +485,7 @@ where // Update the anchor in storage storage.write( &crate::storage_key::masp_convert_anchor_key(), - namada_core::types::hash::Hash( + namada_core::hash::Hash( bls12_381::Scalar::from(storage.conversion_state().tree.root()) .to_bytes(), ), @@ -526,10 +526,10 @@ mod tests { use std::collections::HashMap; use std::str::FromStr; - use namada_core::types::address; - use namada_core::types::dec::testing::arb_non_negative_dec; - use namada_core::types::time::DurationSecs; - use namada_core::types::token::testing::arb_amount; + use namada_core::address; + use namada_core::dec::testing::arb_non_negative_dec; + use namada_core::time::DurationSecs; + use namada_core::token::testing::arb_amount; use namada_parameters::{EpochDuration, Parameters}; use namada_storage::testing::TestStorage; use namada_trans_token::{write_denom, Denomination}; diff --git a/crates/shielded_token/src/lib.rs b/crates/shielded_token/src/lib.rs index b5f0583738..08c70719b8 100644 --- a/crates/shielded_token/src/lib.rs +++ b/crates/shielded_token/src/lib.rs @@ -8,7 +8,7 @@ pub mod utils; use std::str::FromStr; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::dec::Dec; +use namada_core::dec::Dec; pub use namada_storage::conversion_state::{ ConversionState, WithConversionState, }; diff --git a/crates/shielded_token/src/storage.rs b/crates/shielded_token/src/storage.rs index 05b42c7ab7..0c975296ab 100644 --- a/crates/shielded_token/src/storage.rs +++ b/crates/shielded_token/src/storage.rs @@ -1,7 +1,7 @@ -use namada_core::types::address::Address; -use namada_core::types::token; -use namada_core::types::token::Amount; -use namada_core::types::uint::Uint; +use namada_core::address::Address; +use namada_core::token; +use namada_core::token::Amount; +use namada_core::uint::Uint; use namada_storage as storage; use namada_storage::{StorageRead, StorageWrite}; use storage::ResultExt; diff --git a/crates/shielded_token/src/storage_key.rs b/crates/shielded_token/src/storage_key.rs index e58ffe93a0..832a8ac9dc 100644 --- a/crates/shielded_token/src/storage_key.rs +++ b/crates/shielded_token/src/storage_key.rs @@ -2,9 +2,9 @@ use masp_primitives::bls12_381::Scalar; use masp_primitives::sapling::Nullifier; -use namada_core::types::address::{self, Address}; -use namada_core::types::hash::Hash; -use namada_core::types::storage::{self, DbKeySeg, KeySeg}; +use namada_core::address::{self, Address}; +use namada_core::hash::Hash; +use namada_core::storage::{self, DbKeySeg, KeySeg}; use namada_trans_token::storage_key::parameter_prefix; /// Key segment prefix for pinned shielded transactions diff --git a/crates/shielded_token/src/utils.rs b/crates/shielded_token/src/utils.rs index 4dfbaa9e89..42fc6413dd 100644 --- a/crates/shielded_token/src/utils.rs +++ b/crates/shielded_token/src/utils.rs @@ -3,7 +3,7 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_primitives::transaction::Transaction; -use namada_core::types::storage::IndexedTx; +use namada_core::storage::IndexedTx; use namada_storage::{Error, Result, StorageRead, StorageWrite}; use crate::storage_key::{ diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index fa7b0ab116..f111212c5e 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -7,22 +7,20 @@ use core::fmt::Debug; use std::cmp::Ordering; use std::format; +use namada_core::address::{Address, EstablishedAddressGen, InternalAddress}; use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; -use namada_core::tendermint::merkle::proof::ProofOps; -use namada_core::types::address::{ - Address, EstablishedAddressGen, InternalAddress, -}; -use namada_core::types::chain::{ChainId, CHAIN_ID_LENGTH}; -use namada_core::types::eth_bridge_pool::is_pending_transfer_key; -use namada_core::types::hash::{Error as HashError, Hash}; -pub use namada_core::types::hash::{Sha256Hasher, StorageHasher}; -pub use namada_core::types::storage::{ +use namada_core::chain::{ChainId, CHAIN_ID_LENGTH}; +use namada_core::eth_bridge_pool::is_pending_transfer_key; +use namada_core::hash::{Error as HashError, Hash}; +pub use namada_core::hash::{Sha256Hasher, StorageHasher}; +pub use namada_core::storage::{ BlockHash, BlockHeight, BlockResults, Epoch, Epochs, EthEventsQueue, Header, Key, KeySeg, TxIndex, BLOCK_HASH_LENGTH, BLOCK_HEIGHT_LENGTH, EPOCH_TYPE_LENGTH, }; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::{encode, ethereum_structs, storage}; +use namada_core::tendermint::merkle::proof::ProofOps; +use namada_core::time::DateTimeUtc; +use namada_core::{encode, ethereum_structs, storage}; use namada_gas::{ MEMORY_ACCESS_GAS_PER_BYTE, STORAGE_ACCESS_GAS_PER_BYTE, STORAGE_WRITE_GAS_PER_BYTE, @@ -156,9 +154,9 @@ pub enum Error { #[error("Found an unknown key: {key}")] UnknownKey { key: String }, #[error("Storage key error {0}")] - KeyError(namada_core::types::storage::Error), + KeyError(namada_core::storage::Error), #[error("Coding error: {0}")] - CodingError(#[from] namada_core::types::DecodeError), + CodingError(#[from] namada_core::DecodeError), #[error("Merkle tree error: {0}")] MerkleTreeError(MerkleTreeError), #[error("DB error: {0}")] @@ -1102,8 +1100,8 @@ impl From for Error { /// Helpers for testing components that depend on storage #[cfg(any(test, feature = "testing"))] pub mod testing { - use namada_core::types::address; - use namada_core::types::hash::Sha256Hasher; + use namada_core::address; + use namada_core::hash::Sha256Hasher; use super::mockdb::MockDB; use super::*; @@ -1172,9 +1170,9 @@ mod tests { use std::collections::BTreeMap; use chrono::{TimeZone, Utc}; - use namada_core::types::dec::Dec; - use namada_core::types::time::{self, Duration}; - use namada_core::types::token; + use namada_core::dec::Dec; + use namada_core::time::{self, Duration}; + use namada_core::token; use namada_parameters::Parameters; use proptest::prelude::*; use proptest::test_runner::Config; diff --git a/crates/state/src/wl_storage.rs b/crates/state/src/wl_storage.rs index 270a8fc005..4dc2f36fae 100644 --- a/crates/state/src/wl_storage.rs +++ b/crates/state/src/wl_storage.rs @@ -2,10 +2,10 @@ use std::iter::Peekable; -use namada_core::types::address::Address; -use namada_core::types::hash::{Hash, StorageHasher}; -use namada_core::types::storage::{self, BlockHeight, Epochs}; -use namada_core::types::time::DateTimeUtc; +use namada_core::address::Address; +use namada_core::hash::{Hash, StorageHasher}; +use namada_core::storage::{self, BlockHeight, Epochs}; +use namada_core::time::DateTimeUtc; use namada_parameters::EpochDuration; use namada_storage::conversion_state::{ConversionState, WithConversionState}; use namada_storage::{ResultExt, StorageRead, StorageWrite}; @@ -591,9 +591,9 @@ where mod tests { use std::collections::BTreeMap; + use namada_core::address::InternalAddress; use namada_core::borsh::{BorshDeserialize, BorshSerializeExt}; - use namada_core::types::address::InternalAddress; - use namada_core::types::storage::DbKeySeg; + use namada_core::storage::DbKeySeg; use proptest::prelude::*; use proptest::test_runner::Config; // Use `RUST_LOG=info` (or another tracing level) and `--nocapture` to diff --git a/crates/state/src/write_log.rs b/crates/state/src/write_log.rs index 241aa251fa..f776a7fa88 100644 --- a/crates/state/src/write_log.rs +++ b/crates/state/src/write_log.rs @@ -4,12 +4,10 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use itertools::Itertools; -use namada_core::types::address::{ - Address, EstablishedAddressGen, InternalAddress, -}; -use namada_core::types::hash::{Hash, StorageHasher}; -use namada_core::types::ibc::IbcEvent; -use namada_core::types::storage; +use namada_core::address::{Address, EstablishedAddressGen, InternalAddress}; +use namada_core::hash::{Hash, StorageHasher}; +use namada_core::ibc::IbcEvent; +use namada_core::storage; use namada_gas::{MEMORY_ACCESS_GAS_PER_BYTE, STORAGE_WRITE_GAS_PER_BYTE}; use namada_replay_protection as replay_protection; use namada_trans_token::storage_key::{ @@ -731,8 +729,8 @@ impl WriteLog { #[cfg(test)] mod tests { use assert_matches::assert_matches; - use namada_core::types::hash::Hash; - use namada_core::types::{address, storage}; + use namada_core::hash::Hash; + use namada_core::{address, storage}; use pretty_assertions::assert_eq; use proptest::prelude::*; @@ -1108,9 +1106,9 @@ mod tests { /// Helpers for testing with write log. #[cfg(any(test, feature = "testing"))] pub mod testing { - use namada_core::types::address::testing::arb_address; - use namada_core::types::hash::HASH_LENGTH; - use namada_core::types::storage::testing::arb_key; + use namada_core::address::testing::arb_address; + use namada_core::hash::HASH_LENGTH; + use namada_core::storage::testing::arb_key; use proptest::collection; use proptest::prelude::{any, prop_oneof, Just, Strategy}; diff --git a/crates/storage/src/collections/lazy_map.rs b/crates/storage/src/collections/lazy_map.rs index f2d24f7dd1..7c7ea1c2b9 100644 --- a/crates/storage/src/collections/lazy_map.rs +++ b/crates/storage/src/collections/lazy_map.rs @@ -6,7 +6,7 @@ use std::hash::Hash; use std::marker::PhantomData; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::storage::{self, DbKeySeg, KeySeg}; +use namada_core::storage::{self, DbKeySeg, KeySeg}; use thiserror::Error; use super::super::Result; @@ -539,7 +539,7 @@ where #[cfg(test)] mod test { - use namada_core::types::address::{self, Address}; + use namada_core::address::{self, Address}; use super::*; use crate::testing::TestStorage; diff --git a/crates/storage/src/collections/lazy_set.rs b/crates/storage/src/collections/lazy_set.rs index ab4e41705b..bee96d41a5 100644 --- a/crates/storage/src/collections/lazy_set.rs +++ b/crates/storage/src/collections/lazy_set.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use std::marker::PhantomData; -use namada_core::types::storage::{self, DbKeySeg, KeySeg}; +use namada_core::storage::{self, DbKeySeg, KeySeg}; use thiserror::Error; use super::super::Result; @@ -213,7 +213,7 @@ where #[cfg(test)] mod test { - use namada_core::types::address::{self, Address}; + use namada_core::address::{self, Address}; use super::*; use crate::testing::TestStorage; diff --git a/crates/storage/src/collections/lazy_vec.rs b/crates/storage/src/collections/lazy_vec.rs index 12398a3f23..2826620fd7 100644 --- a/crates/storage/src/collections/lazy_vec.rs +++ b/crates/storage/src/collections/lazy_vec.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use std::marker::PhantomData; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::storage::{self, DbKeySeg, KeySeg}; +use namada_core::storage::{self, DbKeySeg, KeySeg}; use thiserror::Error; use super::super::Result; @@ -284,7 +284,7 @@ where #[cfg(test)] mod test { - use namada_core::types::address::{self, Address}; + use namada_core::address::{self, Address}; use super::*; use crate::collections::lazy_map::{self, NestedMap}; diff --git a/crates/storage/src/collections/mod.rs b/crates/storage/src/collections/mod.rs index 8de1f05092..4cc9ca9aea 100644 --- a/crates/storage/src/collections/mod.rs +++ b/crates/storage/src/collections/mod.rs @@ -19,7 +19,7 @@ pub mod lazy_vec; pub use lazy_map::LazyMap; pub use lazy_set::LazySet; pub use lazy_vec::LazyVec; -use namada_core::types::storage; +use namada_core::storage; #[allow(missing_docs)] #[derive(Error, Debug)] diff --git a/crates/storage/src/conversion_state.rs b/crates/storage/src/conversion_state.rs index 5ef405c4db..135b63bab5 100644 --- a/crates/storage/src/conversion_state.rs +++ b/crates/storage/src/conversion_state.rs @@ -2,14 +2,14 @@ use std::collections::BTreeMap; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; use namada_core::masp_primitives::asset_type::AssetType; use namada_core::masp_primitives::convert::AllowedConversion; use namada_core::masp_primitives::merkle_tree::FrozenCommitmentTree; use namada_core::masp_primitives::sapling; -use namada_core::types::address::Address; -use namada_core::types::storage::Epoch; -use namada_core::types::token::{Denomination, MaspDigitPos}; +use namada_core::storage::Epoch; +use namada_core::token::{Denomination, MaspDigitPos}; /// A representation of the conversion state #[derive(Debug, Default, BorshSerialize, BorshDeserialize)] diff --git a/crates/storage/src/db.rs b/crates/storage/src/db.rs index 34f7f90a15..5ce22e85db 100644 --- a/crates/storage/src/db.rs +++ b/crates/storage/src/db.rs @@ -1,13 +1,13 @@ use std::fmt::Debug; -use namada_core::types::address::EstablishedAddressGen; -use namada_core::types::hash::{Error as HashError, Hash}; -use namada_core::types::storage::{ +use namada_core::address::EstablishedAddressGen; +use namada_core::hash::{Error as HashError, Hash}; +use namada_core::storage::{ BlockHash, BlockHeight, BlockResults, Epoch, Epochs, EthEventsQueue, Header, Key, }; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::{ethereum_events, ethereum_structs}; +use namada_core::time::DateTimeUtc; +use namada_core::{ethereum_events, ethereum_structs}; use namada_merkle_tree::{ Error as MerkleTreeError, MerkleTreeStoresRead, MerkleTreeStoresWrite, StoreType, @@ -25,9 +25,9 @@ pub enum Error { #[error("Found an unknown key: {key}")] UnknownKey { key: String }, #[error("Storage key error {0}")] - KeyError(namada_core::types::storage::Error), + KeyError(namada_core::storage::Error), #[error("Coding error: {0}")] - CodingError(#[from] namada_core::types::DecodeError), + CodingError(#[from] namada_core::DecodeError), #[error("Merkle tree error: {0}")] MerkleTreeError(#[from] MerkleTreeError), #[error("DB error: {0}")] diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index a2ebabb6a2..9b8e478d93 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -11,12 +11,10 @@ pub mod types; pub use db::{Error as DbError, Result as DbResult, *}; pub use error::{CustomError, Error, OptionExt, Result, ResultExt}; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; -use namada_core::types::address::Address; -pub use namada_core::types::hash::StorageHasher; -use namada_core::types::storage::{ - self, BlockHash, BlockHeight, Epoch, Epochs, Header, TxIndex, -}; +pub use namada_core::hash::StorageHasher; +pub use namada_core::storage::*; /// Common storage read interface /// @@ -40,10 +38,7 @@ pub trait StorageRead { /// Storage read Borsh encoded value. It will try to read from the storage /// and decode it if found. - fn read( - &self, - key: &storage::Key, - ) -> Result> { + fn read(&self, key: &Key) -> Result> { let bytes = self.read_bytes(key)?; match bytes { Some(bytes) => { @@ -55,10 +50,10 @@ pub trait StorageRead { } /// Storage read raw bytes. It will try to read from the storage. - fn read_bytes(&self, key: &storage::Key) -> Result>>; + fn read_bytes(&self, key: &Key) -> Result>>; /// Storage `has_key` in. It will try to read from the storage. - fn has_key(&self, key: &storage::Key) -> Result; + fn has_key(&self, key: &Key) -> Result; /// Storage prefix iterator ordered by the storage keys. It will try to get /// an iterator from the storage. @@ -67,7 +62,7 @@ pub trait StorageRead { /// [`fn@iter_prefix_bytes`] instead. fn iter_prefix<'iter>( &'iter self, - prefix: &storage::Key, + prefix: &Key, ) -> Result>; /// Storage prefix iterator. It will try to read from the storage. @@ -135,27 +130,19 @@ pub trait StorageRead { /// Common storage write interface pub trait StorageWrite { /// Write a value to be encoded with Borsh at the given key to storage. - fn write( - &mut self, - key: &storage::Key, - val: T, - ) -> Result<()> { + fn write(&mut self, key: &Key, val: T) -> Result<()> { let bytes = val.serialize_to_vec(); self.write_bytes(key, bytes) } /// Write a value as bytes at the given key to storage. - fn write_bytes( - &mut self, - key: &storage::Key, - val: impl AsRef<[u8]>, - ) -> Result<()>; + fn write_bytes(&mut self, key: &Key, val: impl AsRef<[u8]>) -> Result<()>; /// Delete a value at the given key from storage. - fn delete(&mut self, key: &storage::Key) -> Result<()>; + fn delete(&mut self, key: &Key) -> Result<()>; /// Delete all key-vals with a matching prefix. - fn delete_prefix(&mut self, prefix: &storage::Key) -> Result<()> + fn delete_prefix(&mut self, prefix: &Key) -> Result<()> where Self: StorageRead + Sized, { @@ -164,7 +151,7 @@ pub trait StorageWrite { let (key, _val) = res?; Ok(key) }) - .collect::>>(); + .collect::>>(); for key in keys? { // Skip validity predicates as they cannot be deleted if key.is_validity_predicate().is_none() { @@ -178,13 +165,13 @@ pub trait StorageWrite { /// Iterate items matching the given prefix, ordered by the storage keys. pub fn iter_prefix_bytes<'a>( storage: &'a impl StorageRead, - prefix: &storage::Key, -) -> Result)>> + 'a> { + prefix: &Key, +) -> Result)>> + 'a> { let iter = storage.iter_prefix(prefix)?; let iter = itertools::unfold(iter, |iter| { match storage.iter_next(iter) { Ok(Some((key, val))) => { - let key = match storage::Key::parse(key).into_storage_result() { + let key = match Key::parse(key).into_storage_result() { Ok(key) => key, Err(err) => { // Propagate key encoding errors into Iterator's Item @@ -207,8 +194,8 @@ pub fn iter_prefix_bytes<'a>( /// storage keys. pub fn iter_prefix<'a, T>( storage: &'a impl StorageRead, - prefix: &storage::Key, -) -> Result> + 'a> + prefix: &Key, +) -> Result> + 'a> where T: BorshDeserialize, { @@ -216,7 +203,7 @@ where let iter = itertools::unfold(iter, |iter| { match storage.iter_next(iter) { Ok(Some((key, val))) => { - let key = match storage::Key::parse(key).into_storage_result() { + let key = match Key::parse(key).into_storage_result() { Ok(key) => key, Err(err) => { // Propagate key encoding errors into Iterator's Item @@ -253,12 +240,12 @@ where /// don't pass the filter. For `iter_prefix_bytes`, `filter` works fine. pub fn iter_prefix_with_filter<'a, T, F>( storage: &'a impl StorageRead, - prefix: &storage::Key, + prefix: &Key, filter: F, -) -> Result> + 'a> +) -> Result> + 'a> where T: BorshDeserialize, - F: Fn(&storage::Key) -> bool + 'a, + F: Fn(&Key) -> bool + 'a, { let iter = storage.iter_prefix(prefix)?; let iter = itertools::unfold(iter, move |iter| { @@ -267,15 +254,14 @@ where loop { match storage.iter_next(iter) { Ok(Some((key, val))) => { - let key = - match storage::Key::parse(key).into_storage_result() { - Ok(key) => key, - Err(err) => { - // Propagate key encoding errors into Iterator's - // Item - return Some(Err(err)); - } - }; + let key = match Key::parse(key).into_storage_result() { + Ok(key) => key, + Err(err) => { + // Propagate key encoding errors into Iterator's + // Item + return Some(Err(err)); + } + }; // Check the predicate if !filter(&key) { continue; @@ -305,9 +291,9 @@ where /// Helpers for testing components that depend on storage #[cfg(any(test, feature = "testing"))] pub mod testing { - - use namada_core::types::address; - use namada_core::types::chain::ChainId; + use namada_core::address; + use namada_core::chain::ChainId; + pub use namada_core::storage::testing::*; use super::mockdb::MockDB; use super::*; @@ -322,10 +308,10 @@ pub mod testing { pred_epochs: Epochs, native_token: Address, conversion_state: ConversionState, - merkle_tree_key_filter: fn(&storage::Key) -> bool, + merkle_tree_key_filter: fn(&Key) -> bool, } - fn merklize_all_keys(_key: &storage::Key) -> bool { + fn merklize_all_keys(_key: &Key) -> bool { true } @@ -348,17 +334,17 @@ pub mod testing { impl StorageRead for TestStorage { type PrefixIter<'iter> = PrefixIter<'iter> where Self: 'iter; - fn read_bytes(&self, key: &storage::Key) -> Result>> { + fn read_bytes(&self, key: &Key) -> Result>> { self.db.read_subspace_val(key).into_storage_result() } - fn has_key(&self, key: &storage::Key) -> Result { + fn has_key(&self, key: &Key) -> Result { Ok(self.read_bytes(key)?.is_some()) } fn iter_prefix<'iter>( &'iter self, - prefix: &storage::Key, + prefix: &Key, ) -> Result> { let storage_iter = self.db.iter_prefix(Some(prefix)); Ok(PrefixIter { @@ -412,7 +398,7 @@ pub mod testing { impl StorageWrite for TestStorage { fn write_bytes( &mut self, - key: &storage::Key, + key: &Key, val: impl AsRef<[u8]>, ) -> Result<()> { let is_key_merklized = (self.merkle_tree_key_filter)(key); @@ -422,7 +408,7 @@ pub mod testing { Ok(()) } - fn delete(&mut self, key: &storage::Key) -> Result<()> { + fn delete(&mut self, key: &Key) -> Result<()> { let is_key_merklized = (self.merkle_tree_key_filter)(key); self.db .delete_subspace_val(self.height, key, is_key_merklized) diff --git a/crates/storage/src/mockdb.rs b/crates/storage/src/mockdb.rs index 2827bed5d9..43eb0915db 100644 --- a/crates/storage/src/mockdb.rs +++ b/crates/storage/src/mockdb.rs @@ -8,18 +8,17 @@ use std::str::FromStr; use itertools::Either; use namada_core::borsh::{BorshDeserialize, BorshSerializeExt}; -use namada_core::types; -use namada_core::types::hash::Hash; -use namada_core::types::storage::{ +use namada_core::hash::Hash; +use namada_core::storage::{ BlockHeight, BlockResults, Epoch, EthEventsQueue, Header, Key, KeySeg, KEY_SEGMENT_SEPARATOR, }; -use namada_core::types::time::DateTimeUtc; -use namada_core::types::{ethereum_events, ethereum_structs}; +use namada_core::time::DateTimeUtc; +use namada_core::{decode, encode, ethereum_events, ethereum_structs}; use namada_merkle_tree::{ base_tree_key_prefix, subtree_key_prefix, MerkleTreeStoresRead, StoreType, }; -use namada_replay_protection as replay_protection; +use {namada_core, namada_replay_protection as replay_protection}; use crate::conversion_state::ConversionState; use crate::db::{ @@ -67,66 +66,52 @@ impl DB for MockDB { fn read_last_block(&self) -> Result> { // Block height let height: BlockHeight = match self.0.borrow().get("height") { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; // Block results let results_path = format!("results/{}", height.raw()); let results: BlockResults = match self.0.borrow().get(results_path.as_str()) { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; // Epoch start height and time let next_epoch_min_start_height: BlockHeight = match self.0.borrow().get("next_epoch_min_start_height") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let next_epoch_min_start_time: DateTimeUtc = match self.0.borrow().get("next_epoch_min_start_time") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let update_epoch_blocks_delay: Option = match self.0.borrow().get("update_epoch_blocks_delay") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let conversion_state: ConversionState = match self.0.borrow().get("conversion_state") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let tx_queue: TxQueue = match self.0.borrow().get("tx_queue") { - Some(bytes) => types::decode(bytes).map_err(Error::CodingError)?, + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let ethereum_height: Option = match self.0.borrow().get("ethereum_height") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; let eth_events_queue: EthEventsQueue = match self.0.borrow().get("ethereum_height") { - Some(bytes) => { - types::decode(bytes).map_err(Error::CodingError)? - } + Some(bytes) => decode(bytes).map_err(Error::CodingError)?, None => return Ok(None), }; @@ -154,7 +139,7 @@ impl DB for MockDB { match segments.get(3) { Some(&"root") => merkle_tree_stores.set_root( &st, - types::decode(bytes) + decode(bytes) .map_err(Error::CodingError)?, ), Some(&"store") => merkle_tree_stores @@ -168,29 +153,21 @@ impl DB for MockDB { // the block header doesn't have to be restored } "hash" => { - hash = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + hash = Some(decode(bytes).map_err(Error::CodingError)?) } "time" => { - time = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + time = Some(decode(bytes).map_err(Error::CodingError)?) } "epoch" => { - epoch = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + epoch = Some(decode(bytes).map_err(Error::CodingError)?) } "pred_epochs" => { - pred_epochs = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ) + pred_epochs = + Some(decode(bytes).map_err(Error::CodingError)?) } "address_gen" => { - address_gen = Some( - types::decode(bytes).map_err(Error::CodingError)?, - ); + address_gen = + Some(decode(bytes).map_err(Error::CodingError)?); } _ => unknown_key_error(path)?, }, @@ -207,7 +184,7 @@ impl DB for MockDB { { merkle_tree_stores.set_root( st, - types::decode(bytes).map_err(Error::CodingError)?, + decode(bytes).map_err(Error::CodingError)?, ); } let store_key = prefix_key.with_segment("store".to_owned()); @@ -276,29 +253,28 @@ impl DB for MockDB { // Epoch start height and time self.0.borrow_mut().insert( "next_epoch_min_start_height".into(), - types::encode(&next_epoch_min_start_height), + encode(&next_epoch_min_start_height), ); self.0.borrow_mut().insert( "next_epoch_min_start_time".into(), - types::encode(&next_epoch_min_start_time), + encode(&next_epoch_min_start_time), ); self.0.borrow_mut().insert( "update_epoch_blocks_delay".into(), - types::encode(&update_epoch_blocks_delay), + encode(&update_epoch_blocks_delay), ); self.0 .borrow_mut() - .insert("ethereum_height".into(), types::encode(ðereum_height)); - self.0.borrow_mut().insert( - "eth_events_queue".into(), - types::encode(ð_events_queue), - ); + .insert("ethereum_height".into(), encode(ðereum_height)); + self.0 + .borrow_mut() + .insert("eth_events_queue".into(), encode(ð_events_queue)); self.0 .borrow_mut() - .insert("tx_queue".into(), types::encode(&tx_queue)); + .insert("tx_queue".into(), encode(&tx_queue)); self.0 .borrow_mut() - .insert("conversion_state".into(), types::encode(conversion_state)); + .insert("conversion_state".into(), encode(conversion_state)); let prefix_key = Key::from(height.to_db_key()); // Merkle tree @@ -314,7 +290,7 @@ impl DB for MockDB { key_prefix.clone().with_segment("root".to_owned()); self.0.borrow_mut().insert( root_key.to_string(), - types::encode(merkle_tree_stores.root(st)), + encode(merkle_tree_stores.root(st)), ); let store_key = key_prefix.with_segment("store".to_owned()); self.0.borrow_mut().insert( @@ -340,27 +316,21 @@ impl DB for MockDB { let key = prefix_key .push(&"hash".to_owned()) .map_err(Error::KeyError)?; - self.0 - .borrow_mut() - .insert(key.to_string(), types::encode(&hash)); + self.0.borrow_mut().insert(key.to_string(), encode(&hash)); } // Block time { let key = prefix_key .push(&"time".to_owned()) .map_err(Error::KeyError)?; - self.0 - .borrow_mut() - .insert(key.to_string(), types::encode(&time)); + self.0.borrow_mut().insert(key.to_string(), encode(&time)); } // Block epoch { let key = prefix_key .push(&"epoch".to_owned()) .map_err(Error::KeyError)?; - self.0 - .borrow_mut() - .insert(key.to_string(), types::encode(&epoch)); + self.0.borrow_mut().insert(key.to_string(), encode(&epoch)); } // Predecessor block epochs { @@ -369,7 +339,7 @@ impl DB for MockDB { .map_err(Error::KeyError)?; self.0 .borrow_mut() - .insert(key.to_string(), types::encode(&pred_epochs)); + .insert(key.to_string(), encode(&pred_epochs)); } // Address gen { @@ -377,19 +347,15 @@ impl DB for MockDB { .push(&"address_gen".to_owned()) .map_err(Error::KeyError)?; let value = &address_gen; - self.0 - .borrow_mut() - .insert(key.to_string(), types::encode(value)); + self.0.borrow_mut().insert(key.to_string(), encode(value)); } self.0 .borrow_mut() - .insert("height".to_owned(), types::encode(&height)); + .insert("height".to_owned(), encode(&height)); // Block results { let results_path = format!("results/{}", height.raw()); - self.0 - .borrow_mut() - .insert(results_path, types::encode(&results)); + self.0.borrow_mut().insert(results_path, encode(&results)); } Ok(()) } @@ -430,7 +396,7 @@ impl DB for MockDB { let bytes = self.0.borrow().get(&root_key.to_string()).cloned(); match bytes { Some(b) => { - let root = types::decode(b).map_err(Error::CodingError)?; + let root = decode(b).map_err(Error::CodingError)?; merkle_tree_stores.set_root(st, root); } None => return Ok(None), diff --git a/crates/storage/src/tx_queue.rs b/crates/storage/src/tx_queue.rs index a183ec649f..3d5d9c7d87 100644 --- a/crates/storage/src/tx_queue.rs +++ b/crates/storage/src/tx_queue.rs @@ -1,5 +1,5 @@ use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::ethereum_events::EthereumEvent; +use namada_core::ethereum_events::EthereumEvent; use namada_gas::Gas; use namada_tx::Tx; diff --git a/crates/test_utils/src/tx_data.rs b/crates/test_utils/src/tx_data.rs index a985479237..945873b3ad 100644 --- a/crates/test_utils/src/tx_data.rs +++ b/crates/test_utils/src/tx_data.rs @@ -2,9 +2,9 @@ //! Namada transaction. use borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::storage; -use namada_core::types::token::Amount; +use namada_core::address::Address; +use namada_core::storage; +use namada_core::token::Amount; /// Represents an arbitrary write to storage at the specified key. This should /// be used alongside the test `tx_write.wasm`. diff --git a/crates/tests/src/e2e/eth_bridge_tests.rs b/crates/tests/src/e2e/eth_bridge_tests.rs index ece8eb2ee0..95d9dbc9c5 100644 --- a/crates/tests/src/e2e/eth_bridge_tests.rs +++ b/crates/tests/src/e2e/eth_bridge_tests.rs @@ -7,24 +7,24 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; use color_eyre::eyre::{eyre, Result}; use expectrl::ControlCode; +use namada::control_flow::time::{Constant, Sleep}; +use namada::core::address::wnam; +use namada::core::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; +use namada::core::ethereum_events::EthAddress; +use namada::core::storage::{self, Epoch}; +use namada::core::{address, token}; use namada::eth_bridge::oracle; use namada::eth_bridge::storage::vote_tallies; use namada::ledger::eth_bridge::{ ContractVersion, Contracts, EthereumBridgeParams, MinimumConfirmations, UpgradeableContract, }; -use namada::types::address::wnam; -use namada::types::control_flow::time::{Constant, Sleep}; -use namada::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; -use namada::types::ethereum_events::EthAddress; -use namada::types::storage::{self, Epoch}; -use namada::types::{address, token}; use namada_apps::config::ethereum_bridge; -use namada_core::types::address::Address; -use namada_core::types::ethereum_events::{ +use namada_core::address::Address; +use namada_core::ethereum_events::{ EthereumEvent, TransferToEthereum, TransferToNamada, }; -use namada_core::types::token::Amount; +use namada_core::token::Amount; use namada_test_utils::tx_data::TxWriteData; use namada_test_utils::TestWasms; use tokio::time::{Duration, Instant}; diff --git a/crates/tests/src/e2e/eth_bridge_tests/helpers.rs b/crates/tests/src/e2e/eth_bridge_tests/helpers.rs index 70e27b02ca..813cad5e99 100644 --- a/crates/tests/src/e2e/eth_bridge_tests/helpers.rs +++ b/crates/tests/src/e2e/eth_bridge_tests/helpers.rs @@ -7,15 +7,15 @@ use data_encoding::HEXLOWER; use eyre::{eyre, Context, Result}; use hyper::client::HttpConnector; use hyper::{Body, Client, Method, Request, StatusCode}; +use namada::core::address::{wnam, Address}; +use namada::core::ethereum_events::{ + EthAddress, EthereumEvent, TransferToNamada, Uint, +}; use namada::ledger::eth_bridge::{ wrapped_erc20s, ContractVersion, Contracts, EthereumBridgeParams, MinimumConfirmations, UpgradeableContract, }; use namada::token; -use namada::types::address::{wnam, Address}; -use namada::types::ethereum_events::{ - EthAddress, EthereumEvent, TransferToNamada, Uint, -}; use namada_apps::config::ethereum_bridge; use crate::e2e::helpers::{ diff --git a/crates/tests/src/e2e/helpers.rs b/crates/tests/src/e2e/helpers.rs index 8a24b1f304..b35da30c88 100644 --- a/crates/tests/src/e2e/helpers.rs +++ b/crates/tests/src/e2e/helpers.rs @@ -15,18 +15,18 @@ use color_eyre::owo_colors::OwoColorize; use data_encoding::HEXLOWER; use escargot::CargoBuild; use eyre::eyre; +use namada::core::address::Address; +use namada::core::key::*; +use namada::core::storage::Epoch; use namada::ledger::queries::{Rpc, RPC}; use namada::tendermint_rpc::HttpClient; use namada::token; -use namada::types::address::Address; -use namada::types::key::*; -use namada::types::storage::Epoch; use namada_apps::cli::context::ENV_VAR_CHAIN_ID; use namada_apps::config::genesis::chain::DeriveEstablishedAddress; use namada_apps::config::genesis::templates; use namada_apps::config::utils::convert_tm_addr_to_socket_addr; use namada_apps::config::{Config, TendermintMode}; -use namada_core::types::token::NATIVE_MAX_DECIMAL_PLACES; +use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_sdk::wallet::fs::FsWalletUtils; use namada_sdk::wallet::Wallet; use toml::Value; diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index 4cd825b8c8..a742c05bf2 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -17,6 +17,10 @@ use std::path::{Path, PathBuf}; use color_eyre::eyre::Result; use eyre::eyre; +use namada::core::address::{Address, InternalAddress}; +use namada::core::key::PublicKey; +use namada::core::storage::{BlockHeight, Epoch, Key}; +use namada::core::token::Amount; use namada::governance::cli::onchain::PgfFunding; use namada::governance::storage::proposal::{PGFIbcTarget, PGFTarget}; use namada::ibc::apps::transfer::types::VERSION as ICS20_VERSION; @@ -63,10 +67,6 @@ use namada::ledger::storage::ics23_specs::ibc_proof_specs; use namada::state::Sha256Hasher; use namada::tendermint::abci::Event as AbciEvent; use namada::tendermint::block::Height as TmHeight; -use namada::types::address::{Address, InternalAddress}; -use namada::types::key::PublicKey; -use namada::types::storage::{BlockHeight, Epoch, Key}; -use namada::types::token::Amount; use namada_apps::cli::context::ENV_VAR_CHAIN_ID; use namada_apps::client::rpc::{ query_pos_parameters, query_storage_value, query_storage_value_bytes, @@ -79,7 +79,7 @@ use namada_apps::facade::tendermint::block::Header as TmHeader; use namada_apps::facade::tendermint::merkle::proof::ProofOps as TmProof; use namada_apps::facade::tendermint_config::net::Address as TendermintAddress; use namada_apps::facade::tendermint_rpc::{Client, HttpClient, Url}; -use namada_core::types::string_encoding::StringEncoded; +use namada_core::string_encoding::StringEncoded; use namada_sdk::masp::fs::FsShieldedUtils; use prost::Message; use setup::constants::*; diff --git a/crates/tests/src/e2e/ledger_tests.rs b/crates/tests/src/e2e/ledger_tests.rs index 9c904e095c..03f4650af4 100644 --- a/crates/tests/src/e2e/ledger_tests.rs +++ b/crates/tests/src/e2e/ledger_tests.rs @@ -21,15 +21,15 @@ use borsh_ext::BorshSerializeExt; use color_eyre::eyre::Result; use color_eyre::owo_colors::OwoColorize; use data_encoding::HEXLOWER; +use namada::core::address::Address; +use namada::core::storage::Epoch; use namada::governance::cli::onchain::{PgfFunding, StewardsUpdate}; use namada::governance::storage::proposal::{PGFInternalTarget, PGFTarget}; use namada::token; -use namada::types::address::Address; -use namada::types::storage::Epoch; use namada_apps::config::ethereum_bridge; use namada_apps::config::utils::convert_tm_addr_to_socket_addr; use namada_apps::facade::tendermint_config::net::Address as TendermintAddress; -use namada_core::types::token::NATIVE_MAX_DECIMAL_PLACES; +use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_sdk::governance::pgf::cli::steward::Commission; use namada_sdk::masp::fs::FsShieldedUtils; use namada_test_utils::TestWasms; @@ -536,7 +536,7 @@ fn ledger_txs_and_queries() -> Result<()> { vec![ "init-account", "--public-keys", - // Value obtained from `namada::types::key::ed25519::tests::gen_keypair` + // Value obtained from `namada::core::key::ed25519::tests::gen_keypair` "tpknam1qpqfzxu3gt05jx2mvg82f4anf90psqerkwqhjey4zlqv0qfgwuvkzt5jhkp", "--threshold", "1", @@ -2662,7 +2662,7 @@ fn double_signing_gets_slashed() -> Result<()> { use std::net::SocketAddr; use std::str::FromStr; - use namada::types::key::{self, ed25519, SigScheme}; + use namada::core::key::{self, ed25519, SigScheme}; use namada_apps::client; use namada_apps::config::Config; diff --git a/crates/tests/src/e2e/multitoken_tests/helpers.rs b/crates/tests/src/e2e/multitoken_tests/helpers.rs index caddb88f41..948fc750da 100644 --- a/crates/tests/src/e2e/multitoken_tests/helpers.rs +++ b/crates/tests/src/e2e/multitoken_tests/helpers.rs @@ -5,8 +5,8 @@ use std::str::FromStr; use borsh::BorshSerialize; use color_eyre::eyre::Result; use eyre::Context; -use namada_core::types::address::Address; -use namada_core::types::{storage, token}; +use namada_core::address::Address; +use namada_core::{storage, token}; use namada_test_utils::tx_data::TxWriteData; use namada_test_utils::TestWasms; use namada_tx_prelude::storage::KeySeg; @@ -41,7 +41,7 @@ pub fn init_multitoken_vp(test: &Test, rpc_addr: &str) -> Result { ARBITRARY_SIGNER, "--public-key", // Value obtained from - // `namada::types::key::ed25519::tests::gen_keypair` + // `namada::core::key::ed25519::tests::gen_keypair` "001be519a321e29020fa3cbfbfd01bd5e92db134305609270b71dace25b5a21168", "--code-path", &multitoken_vp_wasm_path, diff --git a/crates/tests/src/e2e/setup.rs b/crates/tests/src/e2e/setup.rs index 34517848c3..a7f8f968e2 100644 --- a/crates/tests/src/e2e/setup.rs +++ b/crates/tests/src/e2e/setup.rs @@ -18,7 +18,7 @@ use expectrl::stream::log::LogStream; use expectrl::{ControlCode, Eof, WaitStatus}; use eyre::eyre; use itertools::{Either, Itertools}; -use namada::types::chain::ChainId; +use namada::core::chain::ChainId; use namada_apps::cli::context::ENV_VAR_CHAIN_ID; use namada_apps::client::utils::{ self, validator_pre_genesis_dir, validator_pre_genesis_txs_file, @@ -27,10 +27,10 @@ use namada_apps::config::genesis::utils::read_toml; use namada_apps::config::genesis::{templates, transactions, GenesisAddress}; use namada_apps::config::{ethereum_bridge, genesis, Config}; use namada_apps::{config, wallet}; -use namada_core::types::address::Address; -use namada_core::types::key::{RefTo, SchemeType}; -use namada_core::types::string_encoding::StringEncoded; -use namada_core::types::token::NATIVE_MAX_DECIMAL_PLACES; +use namada_core::address::Address; +use namada_core::key::{RefTo, SchemeType}; +use namada_core::string_encoding::StringEncoded; +use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_sdk::wallet::alias::Alias; use namada_tx_prelude::token; use once_cell::sync::Lazy; diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index deef3c1061..6846895030 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -7,7 +7,7 @@ use namada::state::StorageWrite; use namada::token; use namada_apps::node::ledger::shell::testing::client::run; use namada_apps::node::ledger::shell::testing::utils::{Bin, CapturedOutput}; -use namada_core::types::dec::Dec; +use namada_core::dec::Dec; use namada_sdk::masp::fs::FsShieldedUtils; use test_log::test; diff --git a/crates/tests/src/integration/setup.rs b/crates/tests/src/integration/setup.rs index beb9bf1798..da21de8dda 100644 --- a/crates/tests/src/integration/setup.rs +++ b/crates/tests/src/integration/setup.rs @@ -5,8 +5,8 @@ use std::str::FromStr; use std::sync::{Arc, Mutex}; use color_eyre::eyre::{eyre, Result}; +use namada::core::dec::Dec; use namada::token; -use namada::types::dec::Dec; use namada_apps::cli::args; use namada_apps::client::utils::PRE_GENESIS_DIR; use namada_apps::config; @@ -23,7 +23,7 @@ use namada_apps::node::ledger::shell::testing::node::{ use namada_apps::node::ledger::shell::testing::utils::TestDir; use namada_apps::node::ledger::shell::Shell; use namada_apps::wallet::pre_genesis; -use namada_core::types::chain::ChainIdPrefix; +use namada_core::chain::ChainIdPrefix; use namada_sdk::wallet::alias::Alias; use crate::e2e::setup::{copy_wasm_to_chain_dir, SINGLE_NODE_NET_GENESIS}; diff --git a/crates/tests/src/native_vp/eth_bridge_pool.rs b/crates/tests/src/native_vp/eth_bridge_pool.rs index 2f0109c73f..18d707cf66 100644 --- a/crates/tests/src/native_vp/eth_bridge_pool.rs +++ b/crates/tests/src/native_vp/eth_bridge_pool.rs @@ -4,17 +4,17 @@ mod test_bridge_pool_vp { use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; + use namada::core::address::{nam, wnam}; + use namada::core::chain::ChainId; + use namada::core::eth_bridge_pool::{ + GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, + }; + use namada::core::ethereum_events::EthAddress; + use namada::core::key::{common, ed25519, SecretKey}; + use namada::core::token::Amount; use namada::eth_bridge::storage::bridge_pool::BRIDGE_POOL_ADDRESS; use namada::ledger::native_vp::ethereum_bridge::bridge_pool_vp::BridgePoolVp; use namada::tx::Tx; - use namada::types::address::{nam, wnam}; - use namada::types::chain::ChainId; - use namada::types::eth_bridge_pool::{ - GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, - }; - use namada::types::ethereum_events::EthAddress; - use namada::types::key::{common, ed25519, SecretKey}; - use namada::types::token::Amount; use namada_apps::wallet::defaults::{albert_address, bertha_address}; use namada_apps::wasm_loader; use namada_sdk::eth_bridge::{ @@ -35,7 +35,7 @@ mod test_bridge_pool_vp { /// A signing keypair for good old Bertha. fn bertha_keypair() -> common::SecretKey { // generated from - // [`namada::types::key::ed25519::gen_keypair`] + // [`namada::core::key::ed25519::gen_keypair`] let bytes = [ 240, 3, 224, 69, 201, 148, 60, 53, 112, 79, 80, 107, 101, 127, 186, 6, 176, 162, 113, 224, 62, 8, 183, 187, 124, 234, 244, 251, 92, 36, diff --git a/crates/tests/src/native_vp/mod.rs b/crates/tests/src/native_vp/mod.rs index f2928545b0..75dd2344df 100644 --- a/crates/tests/src/native_vp/mod.rs +++ b/crates/tests/src/native_vp/mod.rs @@ -4,12 +4,12 @@ pub mod pos; use std::cell::RefCell; use std::collections::BTreeSet; +use namada::core::address::Address; +use namada::core::storage; use namada::ledger::gas::VpGasMeter; use namada::ledger::native_vp::{Ctx, NativeVp}; use namada::state::mockdb::MockDB; use namada::state::Sha256Hasher; -use namada::types::address::Address; -use namada::types::storage; use namada::vm::WasmCacheRwAccess; use crate::tx::TestTxEnv; diff --git a/crates/tests/src/native_vp/pos.rs b/crates/tests/src/native_vp/pos.rs index f4a3c6bc5e..73e2eb7315 100644 --- a/crates/tests/src/native_vp/pos.rs +++ b/crates/tests/src/native_vp/pos.rs @@ -95,10 +95,10 @@ //! - add slashes //! - add rewards +use namada::core::storage::Epoch; use namada::proof_of_stake::parameters::{OwnedPosParams, PosParams}; use namada::proof_of_stake::test_utils::test_init_genesis as init_genesis; use namada::proof_of_stake::types::GenesisValidator; -use namada::types::storage::Epoch; use crate::tx::tx_host_env; @@ -147,11 +147,11 @@ pub fn init_pos( #[cfg(test)] mod tests { + use namada::core::address; + use namada::core::key::common::PublicKey; + use namada::core::storage::Epoch; use namada::ledger::pos::{PosParams, PosVP}; use namada::token; - use namada::types::address; - use namada::types::key::common::PublicKey; - use namada::types::storage::Epoch; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; use namada_tx_prelude::Address; use proptest::prelude::*; @@ -571,6 +571,11 @@ pub mod testing { use derivative::Derivative; use itertools::Either; + use namada::core::dec::Dec; + use namada::core::key::common::PublicKey; + use namada::core::key::RefTo; + use namada::core::storage::Epoch; + use namada::core::{address, key}; use namada::ledger::gas::TxGasMeter; use namada::proof_of_stake::epoched::DynEpochOffset; use namada::proof_of_stake::parameters::testing::arb_rate; @@ -582,11 +587,6 @@ pub mod testing { use namada::proof_of_stake::ADDRESS as POS_ADDRESS; use namada::token; use namada::token::{Amount, Change}; - use namada::types::dec::Dec; - use namada::types::key::common::PublicKey; - use namada::types::key::RefTo; - use namada::types::storage::Epoch; - use namada::types::{address, key}; use namada_tx_prelude::{Address, StorageRead, StorageWrite}; use proptest::prelude::*; diff --git a/crates/tests/src/storage.rs b/crates/tests/src/storage.rs index 154b55de56..3a5c9a5118 100644 --- a/crates/tests/src/storage.rs +++ b/crates/tests/src/storage.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use derivative::Derivative; -use namada::types::storage; +use namada::core::storage; /// A list of changes, which must be applied in the same order to get to the /// current state. diff --git a/crates/tests/src/storage_api/collections/lazy_map.rs b/crates/tests/src/storage_api/collections/lazy_map.rs index 0e9309df49..91ef7a1fb8 100644 --- a/crates/tests/src/storage_api/collections/lazy_map.rs +++ b/crates/tests/src/storage_api/collections/lazy_map.rs @@ -4,8 +4,8 @@ mod tests { use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; - use namada::types::address::{self, Address}; - use namada::types::storage; + use namada::core::address::{self, Address}; + use namada::core::storage; use namada_tx_prelude::collections::{LazyCollection, LazyMap}; use namada_tx_prelude::storage::KeySeg; use namada_vp_prelude::collection_validation::{self, LazyCollectionExt}; diff --git a/crates/tests/src/storage_api/collections/lazy_set.rs b/crates/tests/src/storage_api/collections/lazy_set.rs index 2fa04a3e40..3817ac90a5 100644 --- a/crates/tests/src/storage_api/collections/lazy_set.rs +++ b/crates/tests/src/storage_api/collections/lazy_set.rs @@ -3,8 +3,8 @@ mod tests { use std::collections::BTreeSet; use std::convert::TryInto; - use namada::types::address::{self, Address}; - use namada::types::storage; + use namada::core::address::{self, Address}; + use namada::core::storage; use namada_tx_prelude::collections::{LazyCollection, LazySet}; use namada_tx_prelude::storage::KeySeg; use namada_vp_prelude::collection_validation::{self, LazyCollectionExt}; diff --git a/crates/tests/src/storage_api/collections/lazy_vec.rs b/crates/tests/src/storage_api/collections/lazy_vec.rs index 7a3c3f0b14..523204627d 100644 --- a/crates/tests/src/storage_api/collections/lazy_vec.rs +++ b/crates/tests/src/storage_api/collections/lazy_vec.rs @@ -3,8 +3,8 @@ mod tests { use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; - use namada::types::address::{self, Address}; - use namada::types::storage; + use namada::core::address::{self, Address}; + use namada::core::storage; use namada_tx_prelude::collections::{lazy_vec, LazyCollection, LazyVec}; use namada_tx_prelude::storage::KeySeg; use namada_vp_prelude::collection_validation::{self, LazyCollectionExt}; diff --git a/crates/tests/src/storage_api/collections/nested_lazy_map.rs b/crates/tests/src/storage_api/collections/nested_lazy_map.rs index 9a4d487886..b247cbed58 100644 --- a/crates/tests/src/storage_api/collections/nested_lazy_map.rs +++ b/crates/tests/src/storage_api/collections/nested_lazy_map.rs @@ -4,8 +4,8 @@ mod tests { use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; - use namada::types::address::{self, Address}; - use namada::types::storage; + use namada::core::address::{self, Address}; + use namada::core::storage; use namada_tx_prelude::collections::lazy_map::{ NestedMap, NestedSubKey, SubKey, }; diff --git a/crates/tests/src/vm_host_env/ibc.rs b/crates/tests/src/vm_host_env/ibc.rs index 97e564324a..0cf6910ba1 100644 --- a/crates/tests/src/vm_host_env/ibc.rs +++ b/crates/tests/src/vm_host_env/ibc.rs @@ -6,6 +6,12 @@ use ibc_testkit::testapp::ibc::clients::mock::client_state::{ }; use ibc_testkit::testapp::ibc::clients::mock::consensus_state::MockConsensusState; use ibc_testkit::testapp::ibc::clients::mock::header::MockHeader; +use namada::core::address::{self, Address, InternalAddress}; +use namada::core::hash::Hash; +use namada::core::storage::{ + self, BlockHash, BlockHeight, Epoch, Key, TxIndex, +}; +use namada::core::time::DurationSecs; use namada::gas::TxGasMeter; use namada::governance::parameters::GovernanceParameters; use namada::ibc::apps::transfer::types::error::TokenTransferError; @@ -75,12 +81,6 @@ use namada::state::Sha256Hasher; use namada::tendermint::time::Time as TmTime; use namada::token::{self, Amount, DenominatedAmount}; use namada::tx::Tx; -use namada::types::address::{self, Address, InternalAddress}; -use namada::types::hash::Hash; -use namada::types::storage::{ - self, BlockHash, BlockHeight, Epoch, Key, TxIndex, -}; -use namada::types::time::DurationSecs; use namada::vm::{wasm, WasmCacheRwAccess}; use namada_test_utils::TestWasms; use namada_tx_prelude::BorshSerializeExt; @@ -266,7 +266,7 @@ pub fn init_storage() -> (Address, Address) { // max_expected_time_per_block let time = DurationSecs::from(Duration::new(60, 0)); let key = get_max_expected_time_per_block_key(); - let bytes = namada::types::encode(&time); + let bytes = namada::core::encode(&time); tx_host_env::with(|env| { env.wl_storage.storage.write(&key, &bytes).unwrap(); }); diff --git a/crates/tests/src/vm_host_env/mod.rs b/crates/tests/src/vm_host_env/mod.rs index 2269acf1a8..40981f3e5e 100644 --- a/crates/tests/src/vm_host_env/mod.rs +++ b/crates/tests/src/vm_host_env/mod.rs @@ -24,6 +24,11 @@ mod tests { use borsh_ext::BorshSerializeExt; use itertools::Itertools; use namada::account::pks_handle; + use namada::core::hash::Hash; + use namada::core::key::*; + use namada::core::storage::{self, BlockHash, BlockHeight, Key, KeySeg}; + use namada::core::time::DateTimeUtc; + use namada::core::{address, key}; use namada::ibc::context::transfer_mod::testing::DummyTransferModule; use namada::ibc::primitives::Msg; use namada::ibc::Error as IbcActionError; @@ -34,11 +39,6 @@ mod tests { use namada::ledger::tx_env::TxEnv; use namada::token::{self, Amount}; use namada::tx::Tx; - use namada::types::hash::Hash; - use namada::types::key::*; - use namada::types::storage::{self, BlockHash, BlockHeight, Key, KeySeg}; - use namada::types::time::DateTimeUtc; - use namada::types::{address, key}; use namada_test_utils::TestWasms; use namada_tx_prelude::address::InternalAddress; use namada_tx_prelude::chain::ChainId; diff --git a/crates/tests/src/vm_host_env/tx.rs b/crates/tests/src/vm_host_env/tx.rs index c91807589a..25fc05fbb1 100644 --- a/crates/tests/src/vm_host_env/tx.rs +++ b/crates/tests/src/vm_host_env/tx.rs @@ -1,6 +1,10 @@ use std::borrow::Borrow; use std::collections::BTreeSet; +use namada::core::address::Address; +use namada::core::hash::Hash; +use namada::core::storage::{Key, TxIndex}; +use namada::core::time::DurationSecs; use namada::ledger::gas::TxGasMeter; use namada::ledger::parameters::{self, EpochDuration}; use namada::ledger::storage::mockdb::MockDB; @@ -9,10 +13,6 @@ use namada::ledger::storage::write_log::WriteLog; use namada::ledger::storage::{Sha256Hasher, WlStorage}; pub use namada::tx::data::TxType; use namada::tx::Tx; -use namada::types::address::Address; -use namada::types::hash::Hash; -use namada::types::storage::{Key, TxIndex}; -use namada::types::time::DurationSecs; use namada::vm::prefix_iter::PrefixIterators; use namada::vm::wasm::run::Error; use namada::vm::wasm::{self, TxCache, VpCache}; @@ -524,8 +524,8 @@ mod native_tx_host_env { #[cfg(test)] mod tests { + use namada::core::storage; use namada::ledger::storage::mockdb::MockDB; - use namada::types::storage; use namada::vm::host_env::{self, TxVmEnv}; use namada::vm::memory::VmMemory; use proptest::prelude::*; @@ -772,7 +772,7 @@ mod tests { any::(), any::(), any::(), - namada::types::storage::testing::arb_key(), + namada::core::storage::testing::arb_key(), arb_u64(), arb_u64(), any::>(), diff --git a/crates/tests/src/vm_host_env/vp.rs b/crates/tests/src/vm_host_env/vp.rs index a1963fe4ce..c99e3dea9d 100644 --- a/crates/tests/src/vm_host_env/vp.rs +++ b/crates/tests/src/vm_host_env/vp.rs @@ -1,5 +1,7 @@ use std::collections::BTreeSet; +use namada::core::address::{self, Address}; +use namada::core::storage::{self, Key, TxIndex}; use namada::gas::TxGasMeter; use namada::ledger::gas::VpGasMeter; use namada::ledger::storage::mockdb::MockDB; @@ -8,8 +10,6 @@ use namada::ledger::storage::write_log::WriteLog; use namada::ledger::storage::{Sha256Hasher, WlStorage}; use namada::tx::data::TxType; use namada::tx::Tx; -use namada::types::address::{self, Address}; -use namada::types::storage::{self, Key, TxIndex}; use namada::vm::prefix_iter::PrefixIterators; use namada::vm::wasm::{self, VpCache}; use namada::vm::{self, WasmCacheRwAccess}; @@ -239,7 +239,7 @@ mod native_vp_host_env { _ctx: VpCtx<'static, Self::Db, Self::H, Self::Eval, Self::CA>, _vp_code_hash: Vec, _input_data: Vec, - ) -> namada::types::internal::HostEnvResult { + ) -> namada::core::internal::HostEnvResult { unimplemented!( "The \"wasm-runtime\" feature must be enabled to test with \ the `eval` function." diff --git a/crates/token/src/lib.rs b/crates/token/src/lib.rs index ceedef5546..136b324001 100644 --- a/crates/token/src/lib.rs +++ b/crates/token/src/lib.rs @@ -9,8 +9,8 @@ pub mod storage_key { pub use namada_trans_token::storage_key::*; } +use namada_core::address::Address; use namada_core::event::EmitEvents; -use namada_core::types::address::Address; use namada_storage::{Result, StorageRead, StorageWrite}; /// Initialize parameters for the token in storage during the genesis block. diff --git a/crates/trans_token/src/inflation.rs b/crates/trans_token/src/inflation.rs index 545970f8de..b9be694a20 100644 --- a/crates/trans_token/src/inflation.rs +++ b/crates/trans_token/src/inflation.rs @@ -2,8 +2,8 @@ //! proof-of-stake, providing liquity to shielded asset pools, and public goods //! funding. -use namada_core::types::dec::Dec; -use namada_core::types::uint::Uint; +use namada_core::dec::Dec; +use namada_core::uint::Uint; /// Holds the PD controller values that should be updated in storage #[allow(missing_docs)] diff --git a/crates/trans_token/src/lib.rs b/crates/trans_token/src/lib.rs index 21c8516a7b..ea8b646005 100644 --- a/crates/trans_token/src/lib.rs +++ b/crates/trans_token/src/lib.rs @@ -4,5 +4,5 @@ pub mod inflation; mod storage; pub mod storage_key; -pub use namada_core::types::token::*; +pub use namada_core::token::*; pub use storage::*; diff --git a/crates/trans_token/src/storage.rs b/crates/trans_token/src/storage.rs index 4f03ed1509..2e38e97fa4 100644 --- a/crates/trans_token/src/storage.rs +++ b/crates/trans_token/src/storage.rs @@ -1,6 +1,6 @@ +use namada_core::address::{Address, InternalAddress}; use namada_core::hints; -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::token::{self, Amount, DenominatedAmount}; +use namada_core::token::{self, Amount, DenominatedAmount}; use namada_storage as storage; use namada_storage::{StorageRead, StorageWrite}; @@ -229,7 +229,7 @@ pub fn denom_to_amount( #[cfg(test)] mod testing { - use namada_core::types::{address, token}; + use namada_core::{address, token}; use namada_storage::testing::TestStorage; use super::{burn_tokens, credit_tokens, read_balance, read_total_supply}; diff --git a/crates/trans_token/src/storage_key.rs b/crates/trans_token/src/storage_key.rs index 7797d68b51..9f0d2247c3 100644 --- a/crates/trans_token/src/storage_key.rs +++ b/crates/trans_token/src/storage_key.rs @@ -1,7 +1,7 @@ //! Transparent token storage keys -use namada_core::types::address::{Address, InternalAddress}; -use namada_core::types::storage::{self, DbKeySeg, KeySeg}; +use namada_core::address::{Address, InternalAddress}; +use namada_core::storage::{self, DbKeySeg, KeySeg}; /// Key segment for a balance key pub const BALANCE_STORAGE_KEY: &str = "balance"; @@ -196,7 +196,7 @@ pub fn is_any_shielded_action_balance_key( [ token, &Address::Internal( - namada_core::types::address::InternalAddress::Ibc, + namada_core::address::InternalAddress::Ibc, ), ] }) diff --git a/crates/tx/src/data/eval_vp.rs b/crates/tx/src/data/eval_vp.rs index e248018ad5..69562734fa 100644 --- a/crates/tx/src/data/eval_vp.rs +++ b/crates/tx/src/data/eval_vp.rs @@ -1,5 +1,5 @@ use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::hash::Hash; +use namada_core::hash::Hash; use serde::{Deserialize, Serialize}; use crate::Tx; diff --git a/crates/tx/src/data/mod.rs b/crates/tx/src/data/mod.rs index f3d93131b7..61b10896ab 100644 --- a/crates/tx/src/data/mod.rs +++ b/crates/tx/src/data/mod.rs @@ -18,14 +18,14 @@ use std::fmt::{self, Display}; use std::str::FromStr; pub use decrypted::*; +use namada_core::address::Address; use namada_core::borsh::{ BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; -use namada_core::types::address::Address; -use namada_core::types::ethereum_structs::EthBridgeEvent; -use namada_core::types::hash::Hash; -use namada_core::types::ibc::IbcEvent; -use namada_core::types::storage; +use namada_core::ethereum_structs::EthBridgeEvent; +use namada_core::hash::Hash; +use namada_core::ibc::IbcEvent; +use namada_core::storage; use namada_gas::{Gas, VpsGas}; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; @@ -341,10 +341,10 @@ impl TxSentinel { #[cfg(test)] mod test_process_tx { use assert_matches::assert_matches; - use namada_core::types::address::nam; - use namada_core::types::key::*; - use namada_core::types::storage::Epoch; - use namada_core::types::token::{Amount, DenominatedAmount}; + use namada_core::address::nam; + use namada_core::key::*; + use namada_core::storage::Epoch; + use namada_core::token::{Amount, DenominatedAmount}; use super::*; use crate::{Code, Data, Section, Signature, Tx, TxError}; @@ -505,7 +505,7 @@ fn test_process_tx_decrypted_unsigned() { /// signature #[test] fn test_process_tx_decrypted_signed() { - use namada_core::types::key::*; + use namada_core::key::*; use crate::{Code, Data, Section, Signature, Tx}; @@ -517,7 +517,7 @@ fn test_process_tx_decrypted_signed() { ed25519::SigScheme::generate(&mut rng).try_to_sk().unwrap() } - use namada_core::types::key::Signature as S; + use namada_core::key::Signature as S; let mut decrypted = Tx::from_type(TxType::Decrypted(DecryptedTx::Decrypted)); // Invalid signed data diff --git a/crates/tx/src/data/pgf.rs b/crates/tx/src/data/pgf.rs index 284b930dd1..5343ae4daa 100644 --- a/crates/tx/src/data/pgf.rs +++ b/crates/tx/src/data/pgf.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; +use namada_core::dec::Dec; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -33,8 +33,8 @@ pub struct UpdateStewardCommission { #[cfg(any(test, feature = "testing"))] /// Tests and strategies for PGF pub mod tests { - use namada_core::types::address::testing::arb_non_internal_address; - use namada_core::types::dec::testing::arb_dec; + use namada_core::address::testing::arb_non_internal_address; + use namada_core::dec::testing::arb_dec; use proptest::{collection, prop_compose}; use super::UpdateStewardCommission; diff --git a/crates/tx/src/data/pos.rs b/crates/tx/src/data/pos.rs index 73d42d997e..3805556780 100644 --- a/crates/tx/src/data/pos.rs +++ b/crates/tx/src/data/pos.rs @@ -1,10 +1,10 @@ //! Types used for PoS system transactions +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::dec::Dec; -use namada_core::types::key::{common, secp256k1}; -use namada_core::types::token; +use namada_core::dec::Dec; +use namada_core::key::{common, secp256k1}; +use namada_core::token; use serde::{Deserialize, Serialize}; /// A tx data type to become a validator account. @@ -214,10 +214,10 @@ pub struct ConsensusKeyChange { #[cfg(any(test, feature = "testing"))] /// Tests and strategies for proof-of-stake pub mod tests { - use namada_core::types::address::testing::arb_non_internal_address; - use namada_core::types::dec::testing::arb_dec; - use namada_core::types::key::testing::{arb_common_pk, arb_pk}; - use namada_core::types::token::testing::arb_amount; + use namada_core::address::testing::arb_non_internal_address; + use namada_core::dec::testing::arb_dec; + use namada_core::key::testing::{arb_common_pk, arb_pk}; + use namada_core::token::testing::arb_amount; use proptest::{option, prop_compose}; use super::*; diff --git a/crates/tx/src/data/protocol.rs b/crates/tx/src/data/protocol.rs index b1ce5892fa..f9244e62d2 100644 --- a/crates/tx/src/data/protocol.rs +++ b/crates/tx/src/data/protocol.rs @@ -4,7 +4,7 @@ use namada_core::borsh::{ BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; -use namada_core::types::key::*; +use namada_core::key::*; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/crates/tx/src/data/wrapper.rs b/crates/tx/src/data/wrapper.rs index a5867ad932..a70ebaa39d 100644 --- a/crates/tx/src/data/wrapper.rs +++ b/crates/tx/src/data/wrapper.rs @@ -8,15 +8,15 @@ pub mod wrapper_tx { pub use ark_bls12_381::Bls12_381 as EllipticCurve; use masp_primitives::transaction::Transaction; + use namada_core::address::{Address, MASP}; use namada_core::borsh::{ BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; - use namada_core::types::address::{Address, MASP}; - use namada_core::types::hash::Hash; - use namada_core::types::key::*; - use namada_core::types::storage::Epoch; - use namada_core::types::token::{Amount, DenominatedAmount, Transfer}; - use namada_core::types::uint::Uint; + use namada_core::hash::Hash; + use namada_core::key::*; + use namada_core::storage::Epoch; + use namada_core::token::{Amount, DenominatedAmount, Transfer}; + use namada_core::uint::Uint; use namada_gas::Gas; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; diff --git a/crates/tx/src/lib.rs b/crates/tx/src/lib.rs index 61e7a9040d..6c866e8513 100644 --- a/crates/tx/src/lib.rs +++ b/crates/tx/src/lib.rs @@ -8,8 +8,8 @@ use std::collections::HashMap; use data::TxType; use namada_core::event::{Event, EventLevel, EventType}; -pub use namada_core::types::key::SignableEthMessage; -pub use namada_core::types::sign::SignatureIndex; +pub use namada_core::key::SignableEthMessage; +pub use namada_core::sign::SignatureIndex; pub use types::{ standalone_signature, verify_standalone_sig, Code, Commitment, CompressedSignature, Data, DecodeError, Header, MaspBuilder, Memo, Section, diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 432e217e29..3c0d51da53 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -10,18 +10,18 @@ use masp_primitives::transaction::builder::Builder; use masp_primitives::transaction::components::sapling::builder::SaplingMetadata; use masp_primitives::transaction::Transaction; use masp_primitives::zip32::ExtendedFullViewingKey; +use namada_core::account::AccountPublicKeysMap; +use namada_core::address::Address; use namada_core::borsh::schema::{add_definition, Declaration, Definition}; use namada_core::borsh::{ BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; -use namada_core::types::account::AccountPublicKeysMap; -use namada_core::types::address::Address; -use namada_core::types::chain::ChainId; -use namada_core::types::key::*; -use namada_core::types::masp::AssetData; -use namada_core::types::sign::SignatureIndex; -use namada_core::types::storage::Epoch; -use namada_core::types::time::DateTimeUtc; +use namada_core::chain::ChainId; +use namada_core::key::*; +use namada_core::masp::AssetData; +use namada_core::sign::SignatureIndex; +use namada_core::storage::Epoch; +use namada_core::time::DateTimeUtc; use serde::de::Error as SerdeError; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -36,7 +36,7 @@ use crate::proto; #[derive(Error, Debug)] pub enum VerifySigError { #[error("{0}")] - VerifySig(#[from] namada_core::types::key::VerifySigError), + VerifySig(#[from] namada_core::key::VerifySigError), #[error("{0}")] Gas(#[from] namada_gas::Error), #[error("The wrapper signature is invalid.")] @@ -249,7 +249,7 @@ pub struct CommitmentError; )] pub enum Commitment { /// Result of applying hash function to bytes - Hash(namada_core::types::hash::Hash), + Hash(namada_core::hash::Hash), /// Result of applying identity function to bytes Id(Vec), } @@ -279,7 +279,7 @@ impl Commitment { } /// Return the contained hash commitment - pub fn hash(&self) -> namada_core::types::hash::Hash { + pub fn hash(&self) -> namada_core::hash::Hash { match self { Self::Id(code) => hash_tx(code), Self::Hash(hash) => *hash, @@ -327,7 +327,7 @@ impl Code { /// Make a new code section with the given hash pub fn from_hash( - hash: namada_core::types::hash::Hash, + hash: namada_core::hash::Hash, tag: Option, ) -> Self { Self { @@ -377,7 +377,7 @@ pub enum Signer { )] pub struct Signature { /// The hash of the section being signed - pub targets: Vec, + pub targets: Vec, /// The public keys against which the signatures should be verified pub signer: Signer, /// The signature over the above hash @@ -387,7 +387,7 @@ pub struct Signature { impl Signature { /// Sign the given section hash with the given key and return a section pub fn new( - targets: Vec, + targets: Vec, secret_keys: BTreeMap, signer: Option
, ) -> Self { @@ -437,13 +437,13 @@ impl Signature { } /// Get the hash of this section - pub fn get_hash(&self) -> namada_core::types::hash::Hash { - namada_core::types::hash::Hash( + pub fn get_hash(&self) -> namada_core::hash::Hash { + namada_core::hash::Hash( self.hash(&mut Sha256::new()).finalize_reset().into(), ) } - pub fn get_raw_hash(&self) -> namada_core::types::hash::Hash { + pub fn get_raw_hash(&self) -> namada_core::hash::Hash { Self { signer: Signer::PubKeys(vec![]), signatures: BTreeMap::new(), @@ -657,7 +657,7 @@ impl From for Vec { )] pub struct MaspBuilder { /// The MASP transaction that this section witnesses - pub target: namada_core::types::hash::Hash, + pub target: namada_core::hash::Hash, /// The decoded set of asset types used by the transaction. Useful for /// offline wallets trying to display AssetTypes. pub asset_types: HashSet, @@ -757,8 +757,8 @@ impl Section { } /// Get the hash of this section - pub fn get_hash(&self) -> namada_core::types::hash::Hash { - namada_core::types::hash::Hash( + pub fn get_hash(&self) -> namada_core::hash::Hash { + namada_core::hash::Hash( self.hash(&mut Sha256::new()).finalize_reset().into(), ) } @@ -864,14 +864,14 @@ pub struct Header { /// A transaction timestamp pub timestamp: DateTimeUtc, /// The SHA-256 hash of the transaction's code section - pub code_hash: namada_core::types::hash::Hash, + pub code_hash: namada_core::hash::Hash, /// The SHA-256 hash of the transaction's data section - pub data_hash: namada_core::types::hash::Hash, + pub data_hash: namada_core::hash::Hash, /// The SHA-256 hash of the transaction's memo section /// /// In case a memo is not present in the transaction, a /// byte array filled with zeroes is present instead - pub memo_hash: namada_core::types::hash::Hash, + pub memo_hash: namada_core::hash::Hash, /// The type of this transaction pub tx_type: TxType, } @@ -884,9 +884,9 @@ impl Header { chain_id: ChainId::default(), expiration: None, timestamp: DateTimeUtc::now(), - code_hash: namada_core::types::hash::Hash::default(), - data_hash: namada_core::types::hash::Hash::default(), - memo_hash: namada_core::types::hash::Hash::default(), + code_hash: namada_core::hash::Hash::default(), + data_hash: namada_core::hash::Hash::default(), + memo_hash: namada_core::hash::Hash::default(), } } @@ -1024,12 +1024,12 @@ impl Tx { } /// Get the transaction header hash - pub fn header_hash(&self) -> namada_core::types::hash::Hash { + pub fn header_hash(&self) -> namada_core::hash::Hash { Section::Header(self.header.clone()).get_hash() } /// Gets the hash of the decrypted transaction's header - pub fn raw_header_hash(&self) -> namada_core::types::hash::Hash { + pub fn raw_header_hash(&self) -> namada_core::hash::Hash { let mut raw_header = self.header(); raw_header.tx_type = TxType::Raw; @@ -1037,7 +1037,7 @@ impl Tx { } /// Get hashes of all the sections in this transaction - pub fn sechashes(&self) -> Vec { + pub fn sechashes(&self) -> Vec { let mut hashes = vec![self.header_hash()]; for sec in &self.sections { hashes.push(sec.get_hash()); @@ -1054,7 +1054,7 @@ impl Tx { /// Get the transaction section with the given hash pub fn get_section( &self, - hash: &namada_core::types::hash::Hash, + hash: &namada_core::hash::Hash, ) -> Option> { if self.header_hash() == *hash { return Some(Cow::Owned(Section::Header(self.header.clone()))); @@ -1072,18 +1072,18 @@ impl Tx { } /// Set the transaction memo hash stored in the header - pub fn set_memo_sechash(&mut self, hash: namada_core::types::hash::Hash) { + pub fn set_memo_sechash(&mut self, hash: namada_core::hash::Hash) { self.header.memo_hash = hash; } /// Get the hash of this transaction's memo from the heeader - pub fn memo_sechash(&self) -> &namada_core::types::hash::Hash { + pub fn memo_sechash(&self) -> &namada_core::hash::Hash { &self.header.memo_hash } /// Get the memo designated by the memo hash in the header pub fn memo(&self) -> Option> { - if self.memo_sechash() == &namada_core::types::hash::Hash::default() { + if self.memo_sechash() == &namada_core::hash::Hash::default() { return None; } match self @@ -1103,12 +1103,12 @@ impl Tx { } /// Get the hash of this transaction's code from the heeader - pub fn code_sechash(&self) -> &namada_core::types::hash::Hash { + pub fn code_sechash(&self) -> &namada_core::hash::Hash { &self.header.code_hash } /// Set the transaction code hash stored in the header - pub fn set_code_sechash(&mut self, hash: namada_core::types::hash::Hash) { + pub fn set_code_sechash(&mut self, hash: namada_core::hash::Hash) { self.header.code_hash = hash } @@ -1133,12 +1133,12 @@ impl Tx { } /// Get the transaction data hash stored in the header - pub fn data_sechash(&self) -> &namada_core::types::hash::Hash { + pub fn data_sechash(&self) -> &namada_core::hash::Hash { &self.header.data_hash } /// Set the transaction data hash stored in the header - pub fn set_data_sechash(&mut self, hash: namada_core::types::hash::Hash) { + pub fn set_data_sechash(&mut self, hash: namada_core::hash::Hash) { self.header.data_hash = hash } @@ -1179,7 +1179,7 @@ impl Tx { /// public key pub fn verify_signatures( &self, - hashes: &[namada_core::types::hash::Hash], + hashes: &[namada_core::hash::Hash], public_keys_index_map: AccountPublicKeysMap, signer: &Option
, threshold: u8, @@ -1252,7 +1252,7 @@ impl Tx { pub fn verify_signature( &self, public_key: &common::PublicKey, - hashes: &[namada_core::types::hash::Hash], + hashes: &[namada_core::hash::Hash], ) -> Result<&Signature, VerifySigError> { self.verify_signatures( hashes, @@ -1390,9 +1390,9 @@ impl Tx { /// Add an extra section to the tx builder by hash pub fn add_extra_section_from_hash( &mut self, - hash: namada_core::types::hash::Hash, + hash: namada_core::hash::Hash, tag: Option, - ) -> namada_core::types::hash::Hash { + ) -> namada_core::hash::Hash { let sechash = self .add_section(Section::ExtraData(Code::from_hash(hash, tag))) .get_hash(); @@ -1404,7 +1404,7 @@ impl Tx { &mut self, code: Vec, tag: Option, - ) -> (&mut Self, namada_core::types::hash::Hash) { + ) -> (&mut Self, namada_core::hash::Hash) { let sechash = self .add_section(Section::ExtraData(Code::new(code, tag))) .get_hash(); @@ -1415,7 +1415,7 @@ impl Tx { pub fn add_memo( &mut self, memo: &[u8], - ) -> (&mut Self, namada_core::types::hash::Hash) { + ) -> (&mut Self, namada_core::hash::Hash) { let sechash = self .add_section(Section::ExtraData(Code::new(memo.to_vec(), None))) .get_hash(); @@ -1427,7 +1427,7 @@ impl Tx { pub fn add_masp_tx_section( &mut self, tx: Transaction, - ) -> (&mut Self, namada_core::types::hash::Hash) { + ) -> (&mut Self, namada_core::hash::Hash) { let sechash = self.add_section(Section::MaspTx(tx)).get_hash(); (self, sechash) } @@ -1441,7 +1441,7 @@ impl Tx { /// Add wasm code to the tx builder from hash pub fn add_code_from_hash( &mut self, - code_hash: namada_core::types::hash::Hash, + code_hash: namada_core::hash::Hash, tag: Option, ) -> &mut Self { self.set_code(Code::from_hash(code_hash, tag)); @@ -1478,7 +1478,7 @@ impl Tx { fee_payer: common::PublicKey, epoch: Epoch, gas_limit: GasLimit, - fee_unshield_hash: Option, + fee_unshield_hash: Option, ) -> &mut Self { self.header.tx_type = TxType::Wrapper(Box::new(WrapperTx::new( fee, diff --git a/crates/tx_env/src/lib.rs b/crates/tx_env/src/lib.rs index bc482d5004..25242bfacf 100644 --- a/crates/tx_env/src/lib.rs +++ b/crates/tx_env/src/lib.rs @@ -1,10 +1,10 @@ //! Transaction environment contains functions that can be called from //! inside a tx. +use namada_core::address::Address; use namada_core::borsh::BorshSerialize; -use namada_core::types::address::Address; -use namada_core::types::ibc::IbcEvent; -use namada_core::types::storage; +use namada_core::ibc::IbcEvent; +use namada_core::storage; use namada_storage::{Result, StorageRead, StorageWrite}; /// Transaction host functions diff --git a/crates/tx_prelude/src/ibc.rs b/crates/tx_prelude/src/ibc.rs index 0857875382..9ae6f732bb 100644 --- a/crates/tx_prelude/src/ibc.rs +++ b/crates/tx_prelude/src/ibc.rs @@ -3,9 +3,9 @@ use std::cell::RefCell; use std::rc::Rc; -use namada_core::types::address::{Address, InternalAddress}; -pub use namada_core::types::ibc::{IbcEvent, IbcShieldedTransfer}; -use namada_core::types::token::DenominatedAmount; +use namada_core::address::{Address, InternalAddress}; +pub use namada_core::ibc::{IbcEvent, IbcShieldedTransfer}; +use namada_core::token::DenominatedAmount; pub use namada_ibc::storage::is_ibc_key; pub use namada_ibc::{ IbcActions, IbcCommonContext, IbcStorageContext, ProofSpec, TransferModule, diff --git a/crates/tx_prelude/src/key.rs b/crates/tx_prelude/src/key.rs index a273d25cc7..7f499b8254 100644 --- a/crates/tx_prelude/src/key.rs +++ b/crates/tx_prelude/src/key.rs @@ -1,6 +1,6 @@ //! Cryptographic signature keys -pub use namada_core::types::key::*; +pub use namada_core::key::*; use super::*; diff --git a/crates/tx_prelude/src/lib.rs b/crates/tx_prelude/src/lib.rs index fcb059fdb7..b83f2cf345 100644 --- a/crates/tx_prelude/src/lib.rs +++ b/crates/tx_prelude/src/lib.rs @@ -17,20 +17,20 @@ use core::slice; use std::marker::PhantomData; use masp_primitives::transaction::Transaction; +use namada_core::account::AccountPublicKeysMap; +pub use namada_core::address::Address; pub use namada_core::borsh::{ BorshDeserialize, BorshSerialize, BorshSerializeExt, }; -use namada_core::types::account::AccountPublicKeysMap; -pub use namada_core::types::address::Address; -use namada_core::types::chain::CHAIN_ID_LENGTH; -pub use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::internal::HostEnvResult; -use namada_core::types::key::common; -use namada_core::types::storage::TxIndex; -pub use namada_core::types::storage::{ +use namada_core::chain::CHAIN_ID_LENGTH; +pub use namada_core::ethereum_events::EthAddress; +use namada_core::internal::HostEnvResult; +use namada_core::key::common; +use namada_core::storage::TxIndex; +pub use namada_core::storage::{ self, BlockHash, BlockHeight, Epoch, Header, BLOCK_HASH_LENGTH, }; -pub use namada_core::types::{encode, eth_bridge_pool, *}; +pub use namada_core::{encode, eth_bridge_pool, *}; pub use namada_governance::storage as gov_storage; pub use namada_macros::transaction; pub use namada_parameters::storage as parameters_storage; @@ -160,9 +160,7 @@ impl StorageRead for Ctx { } } - fn get_block_hash( - &self, - ) -> Result { + fn get_block_hash(&self) -> Result { let result = Vec::with_capacity(BLOCK_HASH_LENGTH); unsafe { namada_tx_get_block_hash(result.as_ptr() as _); @@ -173,22 +171,17 @@ impl StorageRead for Ctx { Ok(BlockHash::try_from(slice).expect("Cannot convert the hash")) } - fn get_block_epoch( - &self, - ) -> Result { + fn get_block_epoch(&self) -> Result { Ok(Epoch(unsafe { namada_tx_get_block_epoch() })) } - fn get_pred_epochs( - &self, - ) -> Result { + fn get_pred_epochs(&self) -> Result { let read_result = unsafe { namada_tx_get_pred_epochs() }; let bytes = read_from_buffer(read_result, namada_tx_result_buffer) .ok_or(Error::SimpleMessage( "Missing result from `namada_tx_get_pred_epochs` call", ))?; - Ok(namada_core::types::decode(bytes) - .expect("Cannot decode pred epochs")) + Ok(namada_core::decode(bytes).expect("Cannot decode pred epochs")) } /// Get the native token address diff --git a/crates/tx_prelude/src/proof_of_stake.rs b/crates/tx_prelude/src/proof_of_stake.rs index 50ad3daf73..96526b80c1 100644 --- a/crates/tx_prelude/src/proof_of_stake.rs +++ b/crates/tx_prelude/src/proof_of_stake.rs @@ -1,8 +1,8 @@ //! Proof of Stake system integration with functions for transactions -use namada_core::types::dec::Dec; -use namada_core::types::key::common; -use namada_core::types::{key, token}; +use namada_core::dec::Dec; +use namada_core::key::common; +use namada_core::{key, token}; pub use namada_proof_of_stake::parameters::PosParams; use namada_proof_of_stake::storage::read_pos_params; use namada_proof_of_stake::types::{ResultSlashing, ValidatorMetaData}; diff --git a/crates/tx_prelude/src/token.rs b/crates/tx_prelude/src/token.rs index 88371c9864..a42794e8bb 100644 --- a/crates/tx_prelude/src/token.rs +++ b/crates/tx_prelude/src/token.rs @@ -1,4 +1,4 @@ -use namada_core::types::address::Address; +use namada_core::address::Address; use namada_proof_of_stake::token::storage_key::{ balance_key, minted_balance_key, minter_key, }; diff --git a/crates/vm_env/src/lib.rs b/crates/vm_env/src/lib.rs index 63b5b01bc7..a8b15a90d4 100644 --- a/crates/vm_env/src/lib.rs +++ b/crates/vm_env/src/lib.rs @@ -8,7 +8,7 @@ use std::mem::ManuallyDrop; use borsh::BorshDeserialize; -use namada_core::types::internal::{HostEnvResult, KeyVal}; +use namada_core::internal::{HostEnvResult, KeyVal}; /// Transaction environment imports pub mod tx { diff --git a/crates/vote_ext/src/bridge_pool_roots.rs b/crates/vote_ext/src/bridge_pool_roots.rs index 2db9dbdfca..41b1f85b54 100644 --- a/crates/vote_ext/src/bridge_pool_roots.rs +++ b/crates/vote_ext/src/bridge_pool_roots.rs @@ -5,11 +5,11 @@ use std::collections::HashSet; use std::ops::{Deref, DerefMut}; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::key::common; -use namada_core::types::key::common::Signature; -use namada_core::types::storage::BlockHeight; +use namada_core::key::common; +use namada_core::key::common::Signature; +use namada_core::storage::BlockHeight; use namada_tx::Signed; /// A vote extension containing a validator's signature diff --git a/crates/vote_ext/src/ethereum_events.rs b/crates/vote_ext/src/ethereum_events.rs index 35733dcdc9..7c9903ddb7 100644 --- a/crates/vote_ext/src/ethereum_events.rs +++ b/crates/vote_ext/src/ethereum_events.rs @@ -4,11 +4,11 @@ use std::collections::{BTreeSet, HashMap}; use std::ops::Deref; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::ethereum_events::EthereumEvent; -use namada_core::types::key::common::{self, Signature}; -use namada_core::types::storage::BlockHeight; +use namada_core::ethereum_events::EthereumEvent; +use namada_core::key::common::{self, Signature}; +use namada_core::storage::BlockHeight; use namada_tx::Signed; /// Type alias for an [`EthereumEventsVext`]. @@ -153,10 +153,10 @@ impl VextDigest { #[cfg(test)] mod tests { - use namada_core::types::address::{self, Address}; - use namada_core::types::ethereum_events::{EthereumEvent, Uint}; - use namada_core::types::hash::Hash; - use namada_core::types::key; + use namada_core::address::{self, Address}; + use namada_core::ethereum_events::{EthereumEvent, Uint}; + use namada_core::hash::Hash; + use namada_core::key; use namada_tx::Signed; use super::*; diff --git a/crates/vote_ext/src/lib.rs b/crates/vote_ext/src/lib.rs index ca49e96801..4c7d84d427 100644 --- a/crates/vote_ext/src/lib.rs +++ b/crates/vote_ext/src/lib.rs @@ -7,8 +7,8 @@ pub mod validator_set_update; use namada_core::borsh::{ BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; -use namada_core::types::chain::ChainId; -use namada_core::types::key::common; +use namada_core::chain::ChainId; +use namada_core::key::common; use namada_tx::data::protocol::{ProtocolTx, ProtocolTxType}; use namada_tx::data::TxType; use namada_tx::{Signature, Signed, Tx, TxError}; diff --git a/crates/vote_ext/src/validator_set_update.rs b/crates/vote_ext/src/validator_set_update.rs index 6e4a181319..0ef30c2d69 100644 --- a/crates/vote_ext/src/validator_set_update.rs +++ b/crates/vote_ext/src/validator_set_update.rs @@ -4,17 +4,15 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::ops::Deref; +use namada_core::address::Address; use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use namada_core::types::address::Address; -use namada_core::types::eth_abi::{AbiEncode, Encode, Token}; -use namada_core::types::ethereum_events::EthAddress; -use namada_core::types::keccak::KeccakHash; -use namada_core::types::key::common::{self, Signature}; -use namada_core::types::storage::Epoch; -use namada_core::types::voting_power::{ - EthBridgeVotingPower, FractionalVotingPower, -}; -use namada_core::types::{ethereum_structs, token}; +use namada_core::eth_abi::{AbiEncode, Encode, Token}; +use namada_core::ethereum_events::EthAddress; +use namada_core::keccak::KeccakHash; +use namada_core::key::common::{self, Signature}; +use namada_core::storage::Epoch; +use namada_core::voting_power::{EthBridgeVotingPower, FractionalVotingPower}; +use namada_core::{ethereum_structs, token}; use namada_tx::Signed; // the contract versions and namespaces plugged into validator set hashes @@ -384,10 +382,10 @@ impl Encode<1> for ValidatorSetArgs { // this is only here so we don't pollute the // outer namespace with serde traits mod tag { - use namada_core::types::eth_abi::{AbiEncode, Encode, Token}; - use namada_core::types::hash::KeccakHasher; - use namada_core::types::keccak::KeccakHash; - use namada_core::types::key::Signable; + use namada_core::eth_abi::{AbiEncode, Encode, Token}; + use namada_core::hash::KeccakHasher; + use namada_core::keccak::KeccakHash; + use namada_core::key::Signable; use serde::{Deserialize, Serialize}; use super::{ @@ -428,7 +426,7 @@ mod tests { use std::str::FromStr; use data_encoding::HEXLOWER; - use namada_core::types::ethereum_events::EthAddress; + use namada_core::ethereum_events::EthAddress; use super::*; diff --git a/crates/vp_env/src/collection_validation/lazy_map.rs b/crates/vp_env/src/collection_validation/lazy_map.rs index c1fd0949fa..80b83d4cd3 100644 --- a/crates/vp_env/src/collection_validation/lazy_map.rs +++ b/crates/vp_env/src/collection_validation/lazy_map.rs @@ -5,7 +5,7 @@ use core::hash::Hash; use std::collections::HashMap; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::storage; +use namada_core::storage; use namada_storage::collections::lazy_map::{LazyMap, NestedSubKey, SubKey}; use namada_storage::collections::{Nested, Simple}; diff --git a/crates/vp_env/src/collection_validation/lazy_set.rs b/crates/vp_env/src/collection_validation/lazy_set.rs index bfa5828b4a..bc450b6a21 100644 --- a/crates/vp_env/src/collection_validation/lazy_set.rs +++ b/crates/vp_env/src/collection_validation/lazy_set.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; -use namada_core::types::storage; +use namada_core::storage; use namada_storage::collections::lazy_set::{LazySet, SubKey}; use super::LazyCollectionExt; diff --git a/crates/vp_env/src/collection_validation/lazy_vec.rs b/crates/vp_env/src/collection_validation/lazy_vec.rs index 9382c21f22..f6af86c805 100644 --- a/crates/vp_env/src/collection_validation/lazy_vec.rs +++ b/crates/vp_env/src/collection_validation/lazy_vec.rs @@ -4,7 +4,7 @@ use std::collections::BTreeSet; use std::fmt::Debug; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; -use namada_core::types::storage; +use namada_core::storage; use namada_storage::collections::lazy_vec::{ Index, LazyVec, SubKey, ValidationError, }; diff --git a/crates/vp_env/src/collection_validation/mod.rs b/crates/vp_env/src/collection_validation/mod.rs index d74053fb6c..a1ba83a683 100644 --- a/crates/vp_env/src/collection_validation/mod.rs +++ b/crates/vp_env/src/collection_validation/mod.rs @@ -8,7 +8,7 @@ use std::fmt::Debug; use derivative::Derivative; use namada_core::borsh::BorshDeserialize; -use namada_core::types::storage; +use namada_core::storage; use namada_storage::collections::LazyCollection; use crate::VpEnv; diff --git a/crates/vp_env/src/lib.rs b/crates/vp_env/src/lib.rs index 9009f72b39..3cbc515343 100644 --- a/crates/vp_env/src/lib.rs +++ b/crates/vp_env/src/lib.rs @@ -5,16 +5,16 @@ pub mod collection_validation; // TODO: this should be re-exported from namada_shielded_token use masp_primitives::transaction::Transaction; +use namada_core::address::Address; use namada_core::borsh::BorshDeserialize; -use namada_core::types::address::Address; -use namada_core::types::hash::Hash; -use namada_core::types::ibc::{ +use namada_core::hash::Hash; +use namada_core::ibc::{ get_shielded_transfer, IbcEvent, MsgShieldedTransfer, EVENT_TYPE_PACKET, }; -use namada_core::types::storage::{ +use namada_core::storage::{ BlockHash, BlockHeight, Epoch, Epochs, Header, Key, TxIndex, }; -use namada_core::types::token::Transfer; +use namada_core::token::Transfer; use namada_storage::{OptionExt, ResultExt, StorageRead}; use namada_tx::Tx; diff --git a/crates/vp_prelude/src/lib.rs b/crates/vp_prelude/src/lib.rs index 0f57f495c4..1ae4c492b5 100644 --- a/crates/vp_prelude/src/lib.rs +++ b/crates/vp_prelude/src/lib.rs @@ -7,7 +7,7 @@ #![deny(rustdoc::private_intra_doc_links)] pub mod ibc { - pub use namada_core::types::ibc::IbcEvent; + pub use namada_core::ibc::IbcEvent; pub use namada_ibc::storage::is_ibc_key; } @@ -18,17 +18,17 @@ pub use std::collections::{BTreeSet, HashSet}; use std::convert::TryFrom; use std::marker::PhantomData; +pub use namada_core::address::Address; pub use namada_core::borsh::{ BorshDeserialize, BorshSerialize, BorshSerializeExt, }; -pub use namada_core::types::address::Address; -use namada_core::types::chain::CHAIN_ID_LENGTH; -use namada_core::types::hash::{Hash, HASH_LENGTH}; -use namada_core::types::internal::HostEnvResult; -use namada_core::types::storage::{ +use namada_core::chain::CHAIN_ID_LENGTH; +use namada_core::hash::{Hash, HASH_LENGTH}; +use namada_core::internal::HostEnvResult; +use namada_core::storage::{ BlockHash, BlockHeight, Epoch, Epochs, Header, TxIndex, BLOCK_HASH_LENGTH, }; -pub use namada_core::types::*; +pub use namada_core::*; pub use namada_governance::pgf::storage as pgf_storage; pub use namada_governance::storage as gov_storage; pub use namada_macros::validity_predicate; @@ -551,7 +551,7 @@ fn get_pred_epochs() -> Result { "Missing result from `namada_vp_get_pred_epochs` call", ), )?; - Ok(namada_core::types::decode(bytes).expect("Cannot decode pred epochs")) + Ok(namada_core::decode(bytes).expect("Cannot decode pred epochs")) } fn get_native_token() -> Result { diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index d8e432eea0..3988a1fa7a 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3420,7 +3420,6 @@ dependencies = [ "k256", "masp_primitives", "namada_macros", - "num-derive", "num-integer", "num-rational 0.4.1", "num-traits", @@ -3428,7 +3427,6 @@ dependencies = [ "num_enum", "primitive-types", "proptest", - "prost 0.12.3", "prost-types 0.12.3", "rand 0.8.5", "rand_core 0.6.4", diff --git a/wasm/wasm_source/src/tx_bond.rs b/wasm/wasm_source/src/tx_bond.rs index 94c2339d49..68283ee00a 100644 --- a/wasm/wasm_source/src/tx_bond.rs +++ b/wasm/wasm_source/src/tx_bond.rs @@ -20,14 +20,14 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { mod tests { use std::collections::BTreeSet; + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{OwnedPosParams, PosVP}; use namada::proof_of_stake::storage::{ bond_handle, read_consensus_validator_set_addresses_with_stake, read_total_stake, read_validator_stake, }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; diff --git a/wasm/wasm_source/src/tx_change_validator_commission.rs b/wasm/wasm_source/src/tx_change_validator_commission.rs index ce95c6d780..c081651b90 100644 --- a/wasm/wasm_source/src/tx_change_validator_commission.rs +++ b/wasm/wasm_source/src/tx_change_validator_commission.rs @@ -22,11 +22,11 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { mod tests { use std::cmp; + use namada::core::dec::{Dec, POS_DECIMAL_PRECISION}; + use namada::core::storage::Epoch; use namada::ledger::pos::{OwnedPosParams, PosVP}; use namada::proof_of_stake::storage::validator_commission_rate_handle; use namada::proof_of_stake::types::GenesisValidator; - use namada::types::dec::{Dec, POS_DECIMAL_PRECISION}; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; diff --git a/wasm/wasm_source/src/tx_redelegate.rs b/wasm/wasm_source/src/tx_redelegate.rs index c4f9e240bb..a00f533ab0 100644 --- a/wasm/wasm_source/src/tx_redelegate.rs +++ b/wasm/wasm_source/src/tx_redelegate.rs @@ -24,14 +24,14 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { mod tests { use std::collections::BTreeSet; + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{OwnedPosParams, PosVP}; use namada::proof_of_stake::storage::{ bond_handle, read_consensus_validator_set_addresses_with_stake, read_total_stake, read_validator_stake, unbond_handle, }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; diff --git a/wasm/wasm_source/src/tx_unbond.rs b/wasm/wasm_source/src/tx_unbond.rs index 5d982c11bb..135b59be69 100644 --- a/wasm/wasm_source/src/tx_unbond.rs +++ b/wasm/wasm_source/src/tx_unbond.rs @@ -27,14 +27,14 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { mod tests { use std::collections::BTreeSet; + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{OwnedPosParams, PosVP}; use namada::proof_of_stake::storage::{ bond_handle, read_consensus_validator_set_addresses_with_stake, read_total_stake, read_validator_stake, unbond_handle, }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; diff --git a/wasm/wasm_source/src/tx_withdraw.rs b/wasm/wasm_source/src/tx_withdraw.rs index 260da26c11..c6578ae3a3 100644 --- a/wasm/wasm_source/src/tx_withdraw.rs +++ b/wasm/wasm_source/src/tx_withdraw.rs @@ -23,11 +23,11 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { #[cfg(test)] mod tests { + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{OwnedPosParams, PosVP}; use namada::proof_of_stake::storage::unbond_handle; use namada::proof_of_stake::types::GenesisValidator; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; diff --git a/wasm/wasm_source/src/vp_implicit.rs b/wasm/wasm_source/src/vp_implicit.rs index e880a75934..c8fdf07455 100644 --- a/wasm/wasm_source/src/vp_implicit.rs +++ b/wasm/wasm_source/src/vp_implicit.rs @@ -286,11 +286,11 @@ fn validate_pos_changes( #[cfg(test)] mod tests { // Use this as `#[test]` annotation to enable logging + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{GenesisValidator, PosParams}; use namada::tx::data::TxType; use namada::tx::{Code, Data, Signature}; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_test_utils::TestWasms; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; diff --git a/wasm/wasm_source/src/vp_user.rs b/wasm/wasm_source/src/vp_user.rs index ca91a20997..fef53b4304 100644 --- a/wasm/wasm_source/src/vp_user.rs +++ b/wasm/wasm_source/src/vp_user.rs @@ -332,11 +332,11 @@ fn validate_pos_changes( #[cfg(test)] mod tests { use address::testing::arb_non_internal_address; + use namada::core::dec::Dec; + use namada::core::storage::Epoch; use namada::ledger::pos::{GenesisValidator, PosParams}; use namada::tx::data::{self, TxType}; use namada::tx::{Code, Data, Signature}; - use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_test_utils::TestWasms; // Use this as `#[test]` annotation to enable logging use namada_tests::log::test; diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 62c9f1aa49..53c7ac7b34 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -3420,7 +3420,6 @@ dependencies = [ "k256", "masp_primitives", "namada_macros", - "num-derive", "num-integer", "num-rational 0.4.1", "num-traits", @@ -3428,7 +3427,6 @@ dependencies = [ "num_enum", "primitive-types", "proptest", - "prost 0.12.3", "prost-types 0.12.3", "rand 0.8.5", "rand_core 0.6.4",