-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add namada_systems crate with systems' abstract interfaces
- Loading branch information
1 parent
095f13f
commit ea854f4
Showing
16 changed files
with
201 additions
and
137 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "namada_systems" | ||
description = "Namada systems abstract interfaces" | ||
resolver = "2" | ||
authors.workspace = true | ||
edition.workspace = true | ||
documentation.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
repository.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
namada_core = { path = "../core" } | ||
namada_storage = { path = "../storage" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! Ethereum bridge abstract interfaces |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! IBC abstract interfaces | ||
|
||
use std::collections::{BTreeMap, BTreeSet}; | ||
|
||
use masp_primitives::transaction::components::ValueSum; | ||
use masp_primitives::transaction::TransparentAddress; | ||
use namada_core::address::Address; | ||
use namada_core::masp::TAddrData; | ||
use namada_core::{masp_primitives, storage, token}; | ||
|
||
/// Abstract IBC storage read interface | ||
pub trait Read<S> { | ||
/// Storage error | ||
type Err; | ||
|
||
/// Extract MASP transaction from IBC envelope | ||
fn try_extract_masp_tx_from_envelope( | ||
tx_data: &[u8], | ||
) -> Result<Option<masp_primitives::transaction::Transaction>, Self::Err>; | ||
|
||
/// Apply relevant IBC packets to the changed balances structure | ||
fn apply_ibc_packet( | ||
storage: &S, | ||
tx_data: &[u8], | ||
acc: ChangedBalances, | ||
keys_changed: &BTreeSet<storage::Key>, | ||
) -> Result<ChangedBalances, Self::Err>; | ||
} | ||
|
||
/// Balances changed by a transaction | ||
#[derive(Default, Debug, Clone)] | ||
pub struct ChangedBalances { | ||
/// Map between MASP transparent address and namada types | ||
pub decoder: BTreeMap<TransparentAddress, TAddrData>, | ||
/// Balances before the tx | ||
pub pre: BTreeMap<TransparentAddress, ValueSum<Address, token::Amount>>, | ||
/// Balances after the tx | ||
pub post: BTreeMap<TransparentAddress, ValueSum<Address, token::Amount>>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! Abstract interfaces for interacting with Namada systems. | ||
|
||
#![doc(html_favicon_url = "https://dev.namada.net/master/favicon.png")] | ||
#![doc(html_logo_url = "https://dev.namada.net/master/rustdoc-logo.png")] | ||
#![deny(rustdoc::broken_intra_doc_links)] | ||
#![deny(rustdoc::private_intra_doc_links)] | ||
#![warn( | ||
missing_docs, | ||
rust_2018_idioms, | ||
clippy::cast_sign_loss, | ||
clippy::cast_possible_truncation, | ||
clippy::cast_possible_wrap, | ||
clippy::cast_lossless, | ||
clippy::arithmetic_side_effects, | ||
clippy::dbg_macro, | ||
clippy::print_stdout, | ||
clippy::print_stderr | ||
)] | ||
|
||
pub mod ethereum_bridge; | ||
pub mod governance; | ||
pub mod ibc; | ||
pub mod parameters; | ||
pub mod pgf; | ||
pub mod proof_of_stake; | ||
pub mod shielded_token; | ||
pub mod trans_token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Parameters abstract interfaces | ||
|
||
pub use namada_core::parameters::*; | ||
use namada_core::storage; | ||
|
||
/// Abstract parameters storage keys interface | ||
pub trait Keys { | ||
/// Key for implicit VP | ||
fn implicit_vp_key() -> storage::Key; | ||
} | ||
|
||
/// Abstract parameters storage read interface | ||
pub trait Read<S> { | ||
/// Storage error | ||
type Err; | ||
|
||
/// Read all parameters | ||
fn read(storage: &S) -> Result<Parameters, Self::Err>; | ||
|
||
/// Read MASP epoch multiplier | ||
fn masp_epoch_multiplier(storage: &S) -> Result<u64, Self::Err>; | ||
|
||
/// Read the the epoch duration parameter from store | ||
fn epoch_duration_parameter( | ||
storage: &S, | ||
) -> Result<EpochDuration, Self::Err>; | ||
|
||
/// Helper function to retrieve the `is_native_token_transferable` protocol | ||
/// parameter from storage | ||
fn is_native_token_transferable(storage: &S) -> Result<bool, Self::Err>; | ||
} | ||
|
||
/// Abstract parameters storage write interface | ||
pub trait Write<S>: Read<S> { | ||
/// Write all parameters | ||
fn write(storage: &mut S, parameters: &Parameters) | ||
-> Result<(), Self::Err>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! PGF abstract interfaces |
4 changes: 2 additions & 2 deletions
4
crates/core/src/proof_of_stake.rs → crates/systems/src/proof_of_stake.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! Shielded token abstract interfaces |
Oops, something went wrong.