-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: distribution messages #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "seda-common" | ||
version = "0.2.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
|
||
[features] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,79 @@ | ||
use crate::types::{Bytes, U128}; | ||
|
||
pub mod expire_data_requests; | ||
pub mod remove_requests; | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub struct RemoveDataRequest { | ||
pub dr_id: String, | ||
pub struct DistributionExecutorReward { | ||
/// The amount to burn | ||
pub amount: U128, | ||
/// The identity to reward. | ||
pub identity: String, | ||
} | ||
|
||
impl From<RemoveDataRequest> for crate::msgs::SudoMsg { | ||
fn from(value: RemoveDataRequest) -> Self { | ||
SudoMsg::RemoveDataRequest(value).into() | ||
} | ||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub struct DistributionBurn { | ||
/// The amount to burn | ||
pub amount: U128, | ||
} | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub struct DistributionSend { | ||
/// The address to send the funds to. | ||
pub to: Bytes, | ||
/// The amount to send to the address. | ||
pub amount: U128, | ||
} | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub enum DistributionKind { | ||
/// For burning funds | ||
Burn(DistributionBurn), | ||
/// For rewarding an executor | ||
ExecutorReward(DistributionExecutorReward), | ||
/// For sending the funds to someone | ||
Send(DistributionSend), | ||
} | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub enum DistributionType { | ||
TallyReward, | ||
ExecutorReward, | ||
TimedOut, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We haven't decided what happens with the funds when a timeout happens, nice one! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for this repo, but we discussed that we could have a tally parameter for a fixed gas amount for timeout DRs. That would mean that timeout DRs will have a small cost and the rest can be refunded to the requestor. |
||
NoConsensus, | ||
RemainderRefund, | ||
} | ||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub struct DistributionMessage { | ||
pub kind: DistributionKind, | ||
#[serde(rename = "type")] | ||
pub type_: DistributionType, | ||
} | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub struct DistributionMessages { | ||
pub messages: Vec<DistributionMessage>, | ||
pub refund_type: DistributionType, | ||
} | ||
|
||
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)] | ||
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))] | ||
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))] | ||
pub enum SudoMsg { | ||
RemoveDataRequest(RemoveDataRequest), | ||
RemoveDataRequests(remove_requests::Sudo), | ||
ExpireDataRequests(expire_data_requests::Sudo), | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to start matching versions to the devnet version?
If so, this could be something like
0.5.0-dev1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I don't think matching versions makes sense. Since they could be in very different development cycles, but that's my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna merge for now, and if we decide to do this I can do it in a future PR