forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01520c1
commit 50e756d
Showing
9 changed files
with
95 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "solana-reward-info" | ||
description = "Solana vote reward info types" | ||
documentation = "https://docs.rs/solana-reward-info" | ||
version = { workspace = true } | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
serde = { workspace = true, optional = true } | ||
serde_derive = { workspace = true, optional = true } | ||
solana-frozen-abi = { workspace = true, optional = true } | ||
solana-frozen-abi-macro = { workspace = true, optional = true } | ||
|
||
[features] | ||
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] | ||
serde = ["dep:serde", "dep:serde_derive"] | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] |
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,44 @@ | ||
#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] | ||
#[cfg(feature = "serde")] | ||
use serde_derive::{Deserialize, Serialize}; | ||
#[cfg(feature = "frozen-abi")] | ||
use solana_frozen_abi_macro::{AbiEnumVisitor, AbiExample}; | ||
use std::fmt; | ||
|
||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor))] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
pub enum RewardType { | ||
Fee, | ||
Rent, | ||
Staking, | ||
Voting, | ||
} | ||
|
||
impl fmt::Display for RewardType { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
match self { | ||
RewardType::Fee => "fee", | ||
RewardType::Rent => "rent", | ||
RewardType::Staking => "staking", | ||
RewardType::Voting => "voting", | ||
} | ||
) | ||
} | ||
} | ||
|
||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
pub struct RewardInfo { | ||
pub reward_type: RewardType, | ||
/// Reward amount | ||
pub lamports: i64, | ||
/// Account balance in lamports after `lamports` was applied | ||
pub post_balance: u64, | ||
/// Vote account commission when the reward was credited, only present for voting and staking rewards | ||
pub commission: Option<u8>, | ||
} |
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 |
---|---|---|
@@ -1,13 +1 @@ | ||
use crate::reward_type::RewardType; | ||
|
||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] | ||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)] | ||
pub struct RewardInfo { | ||
pub reward_type: RewardType, | ||
/// Reward amount | ||
pub lamports: i64, | ||
/// Account balance in lamports after `lamports` was applied | ||
pub post_balance: u64, | ||
/// Vote account commission when the reward was credited, only present for voting and staking rewards | ||
pub commission: Option<u8>, | ||
} | ||
pub use solana_reward_info::RewardInfo; |
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 |
---|---|---|
@@ -1,27 +1 @@ | ||
//! Enumeration of reward types. | ||
use std::fmt; | ||
|
||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor))] | ||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)] | ||
pub enum RewardType { | ||
Fee, | ||
Rent, | ||
Staking, | ||
Voting, | ||
} | ||
|
||
impl fmt::Display for RewardType { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
match self { | ||
RewardType::Fee => "fee", | ||
RewardType::Rent => "rent", | ||
RewardType::Staking => "staking", | ||
RewardType::Voting => "voting", | ||
} | ||
) | ||
} | ||
} | ||
pub use solana_reward_info::RewardType; |