diff --git a/Cargo.lock b/Cargo.lock index fbe9be60938..a7b2ca09d1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4777,11 +4777,17 @@ name = "namada_vp_prelude" version = "0.28.1" dependencies = [ "borsh", - "borsh-ext", + "namada_account", "namada_core", + "namada_governance", "namada_macros", + "namada_parameters", "namada_proof_of_stake", + "namada_storage", + "namada_token", + "namada_tx", "namada_vm_env", + "namada_vp_env", "sha2 0.9.9", "thiserror", ] diff --git a/vp_prelude/Cargo.toml b/vp_prelude/Cargo.toml index 0766b39794c..6de70ae749c 100644 --- a/vp_prelude/Cargo.toml +++ b/vp_prelude/Cargo.toml @@ -16,11 +16,18 @@ version.workspace = true default = [] [dependencies] -namada_core = {path = "../core", default-features = false} -namada_macros = {path = "../macros"} -namada_proof_of_stake = {path = "../proof_of_stake", default-features = false} -namada_vm_env = {path = "../vm_env", default-features = false} +namada_account = { path = "../account" } +namada_core = { path = "../core", default-features = false } +namada_governance = { path = "../governance" } +namada_macros = { path = "../macros" } +namada_parameters = { path = "../parameters" } +namada_proof_of_stake = { path = "../proof_of_stake", default-features = false } +namada_storage = { path = "../storage" } +namada_token = { path = "../token" } +namada_tx = { path = "../tx" } +namada_vm_env = { path = "../vm_env", default-features = false } +namada_vp_env = { path = "../vp_env" } + borsh.workspace = true -borsh-ext.workspace = true sha2.workspace = true thiserror.workspace = true diff --git a/vp_prelude/src/lib.rs b/vp_prelude/src/lib.rs index cb0ff1cc273..190a64c16c6 100644 --- a/vp_prelude/src/lib.rs +++ b/vp_prelude/src/lib.rs @@ -13,17 +13,9 @@ pub use std::collections::{BTreeSet, HashSet}; use std::convert::TryFrom; use std::marker::PhantomData; -pub use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; -pub use namada_core::ledger::governance::storage as gov_storage; -pub use namada_core::ledger::parameters; -pub use namada_core::ledger::pgf::storage as pgf_storage; -pub use namada_core::ledger::storage_api::{ - self, iter_prefix, iter_prefix_bytes, Error, OptionExt, ResultExt, - StorageRead, +pub use namada_core::borsh::{ + BorshDeserialize, BorshSerialize, BorshSerializeExt, }; -pub use namada_core::ledger::vp_env::VpEnv; -pub use namada_core::proto::{Section, Tx}; pub use namada_core::types::address::Address; use namada_core::types::chain::CHAIN_ID_LENGTH; use namada_core::types::hash::{Hash, HASH_LENGTH}; @@ -32,11 +24,21 @@ use namada_core::types::storage::{ BlockHash, BlockHeight, Epoch, Header, TxIndex, BLOCK_HASH_LENGTH, }; pub use namada_core::types::*; +pub use namada_governance::pgf::storage as pgf_storage; +pub use namada_governance::storage as gov_storage; pub use namada_macros::validity_predicate; +pub use namada_storage::{ + iter_prefix, iter_prefix_bytes, Error, OptionExt, ResultExt, StorageRead, +}; +pub use namada_tx::{Section, Tx}; use namada_vm_env::vp::*; use namada_vm_env::{read_from_buffer, read_key_val_bytes_from_buffer}; +pub use namada_vp_env::VpEnv; pub use sha2::{Digest, Sha256, Sha384, Sha512}; -pub use {borsh_ext, namada_proof_of_stake as proof_of_stake}; +pub use { + namada_account as account, namada_parameters as parameters, + namada_proof_of_stake as proof_of_stake, namada_token as token, +}; pub fn sha256(bytes: &[u8]) -> Hash { let digest = Sha256::digest(bytes); @@ -85,9 +87,8 @@ pub fn verify_signatures(ctx: &Ctx, tx: &Tx, owner: &Address) -> VpResult { parameters::max_signatures_per_transaction(&ctx.pre())?; let public_keys_index_map = - storage_api::account::public_keys_index_map(&ctx.pre(), owner)?; - let threshold = - storage_api::account::threshold(&ctx.pre(), owner)?.unwrap_or(1); + account::public_keys_index_map(&ctx.pre(), owner)?; + let threshold = account::threshold(&ctx.pre(), owner)?.unwrap_or(1); // Serialize parameters let max_signatures = max_signatures_per_transaction.serialize_to_vec(); @@ -206,7 +207,7 @@ pub struct CtxPostStorageRead<'a> { _ctx: &'a Ctx, } -/// Result of `VpEnv` or `storage_api::StorageRead` method call +/// Result of `VpEnv` or `namada_storage::StorageRead` method call pub type EnvResult = Result; /// Validity predicate result @@ -417,13 +418,17 @@ impl StorageRead for CtxPreStorageRead<'_> { get_block_epoch() } - fn get_tx_index(&self) -> Result { + fn get_tx_index(&self) -> Result { get_tx_index() } fn get_native_token(&self) -> Result { get_native_token() } + + fn get_pred_epochs(&self) -> namada_storage::Result { + todo!() + } } impl StorageRead for CtxPostStorageRead<'_> { @@ -487,13 +492,17 @@ impl StorageRead for CtxPostStorageRead<'_> { get_block_epoch() } - fn get_tx_index(&self) -> Result { + fn get_tx_index(&self) -> Result { get_tx_index() } fn get_native_token(&self) -> Result { get_native_token() } + + fn get_pred_epochs(&self) -> namada_storage::Result { + todo!() + } } fn iter_prefix_pre_impl( @@ -558,7 +567,7 @@ fn get_block_epoch() -> Result { Ok(Epoch(unsafe { namada_vp_get_block_epoch() })) } -fn get_tx_index() -> Result { +fn get_tx_index() -> Result { Ok(TxIndex(unsafe { namada_vp_get_tx_index() })) }