-
Notifications
You must be signed in to change notification settings - Fork 947
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
daaae7b
commit e3875bf
Showing
15 changed files
with
167 additions
and
105 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
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 @@ | ||
//! IBC abstract interfaces |
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,43 @@ | ||
//! 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>; | ||
|
||
/// Get the max signatures per transactio parameter | ||
fn max_signatures_per_transaction( | ||
storage: &S, | ||
) -> Result<Option<u8>, 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 |
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,65 @@ | ||
//! Transparent token abstract interfaces | ||
|
||
use namada_core::address::Address; | ||
use namada_core::storage; | ||
pub use namada_core::token::*; | ||
|
||
/// Abstract token keys interface | ||
pub trait Keys { | ||
/// Key for transparent token balance | ||
fn balance_key(token: &Address, owner: &Address) -> storage::Key; | ||
|
||
/// Returns the owner address if the given storage key is a balance key for | ||
/// the given token. | ||
fn is_balance_key<'a>( | ||
token_addr: &Address, | ||
key: &'a storage::Key, | ||
) -> Option<&'a Address>; | ||
|
||
/// Check if the given storage key is a balance key for an unspecified | ||
/// token. If it is, return the token and owner address. | ||
fn is_any_token_balance_key(key: &storage::Key) -> Option<[&Address; 2]>; | ||
|
||
/// Obtain a storage key for the multitoken minter. | ||
fn minter_key(token_addr: &Address) -> storage::Key; | ||
} | ||
|
||
/// Abstract token storage read interface | ||
pub trait Read<S> { | ||
/// Storage error | ||
type Err; | ||
} | ||
|
||
/// Abstract token storage write interface | ||
pub trait Write<S>: Read<S> { | ||
/// Transfer `token` from `src` to `dest`. Returns an `Err` if `src` has | ||
/// insufficient balance or if the transfer the `dest` would overflow (This | ||
/// can only happen if the total supply doesn't fit in `token::Amount`). | ||
fn transfer( | ||
storage: &mut S, | ||
token: &Address, | ||
src: &Address, | ||
dest: &Address, | ||
amount: Amount, | ||
) -> Result<(), Self::Err>; | ||
|
||
/// Burn a specified amount of tokens from some address. If the burn amount | ||
/// is larger than the total balance of the given address, then the | ||
/// remaining balance is burned. The total supply of the token is | ||
/// properly adjusted. | ||
fn burn_tokens( | ||
storage: &mut S, | ||
token: &Address, | ||
source: &Address, | ||
amount: Amount, | ||
) -> Result<(), Self::Err>; | ||
|
||
/// Credit tokens to an account, to be used only by protocol. In | ||
/// transactions, this would get rejected by the default `vp_token`. | ||
fn credit_tokens( | ||
storage: &mut S, | ||
token: &Address, | ||
dest: &Address, | ||
amount: Amount, | ||
) -> Result<(), Self::Err>; | ||
} |