Skip to content

Commit

Permalink
Merge pull request #5 from persistenceOne/betterclever/test-tube-x
Browse files Browse the repository at this point in the history
Add staking module support and remove failing Github workflows
  • Loading branch information
betterclever authored Jan 12, 2024
2 parents 07007c8 + f6777a7 commit 8e9aa06
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 117 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/schedule-persistence-test-tube-update.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/test.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/update-persistence-test-tube.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions packages/persistence-test-tube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"
name = "persistence-test-tube"
repository = "https://github.com/persistenceOne/test-tube"
version = "1.0.0"
version = "1.1.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

exclude = ["persistenceCore", "test_artifacts"]
Expand All @@ -13,11 +13,11 @@ exclude = ["persistenceCore", "test_artifacts"]
base64 = "0.13.0"
cosmrs = {version = "0.15.0", features = ["cosmwasm"]}
cosmwasm-std = "1.4.0"
persistence-std = "1.0.0"
persistence-std = "1.1.1"
prost = "0.12.0"
serde = "1.0.144"
serde_json = "1.0.85"
test-tube-x = {version = "1.0.0", path = "../test-tube-x", features = ["module-wrappers"]}
test-tube-x = {version = "1.1.0", path = "../test-tube-x", features = ["module-wrappers"]}
thiserror = "1.0.34"

[build-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions packages/persistence-test-tube/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ mod gov;
pub use test_tube_x::macros;
pub use test_tube_x::module::bank;
pub use test_tube_x::module::wasm;
pub use test_tube_x::module::staking;
pub use test_tube_x::module::Module;

pub use bank::Bank;
pub use gov::Gov;
pub use staking::Staking;
pub use gov::GovWithAppAccess;
pub use wasm::Wasm;
7 changes: 4 additions & 3 deletions packages/test-tube-x/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ edition = "2021"
license = "MIT OR Apache-2.0"
name = "test-tube-x"
repository = "https://github.com/persistenceCore/test-tube"
version = "1.0.0"
version = "1.1.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
base64 = "0.13.0"
cosmrs = {version = "0.15.0", features = ["cosmwasm", "rpc"]}
cosmwasm-std = {version = "1.4.0", features = ["stargate"]}
persistence-std = {version = "1.0.0", optional = true}
persistence-std = {version = "1.1.1", optional = true}
prost = "0.12.0"
serde = "1.0.144"
serde_json = "1.0.85"
Expand All @@ -25,7 +25,8 @@ rayon = "1.5.3"
[features]
default = []

module-wrappers = ["bank", "wasm"]
module-wrappers = ["bank", "wasm", "staking"]

bank = ["persistence-std"]
wasm = ["persistence-std"]
staking = ["persistence-std"]
4 changes: 4 additions & 0 deletions packages/test-tube-x/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ use crate::runner::Runner;

pub mod bank;
pub mod wasm;
pub mod staking;

#[cfg(feature = "bank")]
pub use bank::Bank;

#[cfg(feature = "wasm")]
pub use wasm::Wasm;

#[cfg(feature = "staking")]
pub use staking::Staking;

#[macro_use]
pub mod macros;

Expand Down
88 changes: 88 additions & 0 deletions packages/test-tube-x/src/module/staking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#![cfg(feature = "bank")]

use crate::{fn_execute, fn_query};
use persistence_std::types::cosmos::staking::v1beta1::{
MsgBeginRedelegate, MsgBeginRedelegateResponse, MsgCreateValidator, MsgCreateValidatorResponse,
MsgDelegate, MsgDelegateResponse, MsgEditValidator, MsgEditValidatorResponse,
MsgUnbondValidator, QueryDelegationRequest, QueryDelegationResponse,
QueryDelegatorDelegationsRequest, QueryDelegatorDelegationsResponse,
QueryDelegatorUnbondingDelegationsRequest, QueryDelegatorUnbondingDelegationsResponse,
QueryParamsRequest, QueryParamsResponse, QueryPoolRequest, QueryPoolResponse,
QueryRedelegationsRequest, QueryRedelegationsResponse, QueryUnbondingDelegationRequest,
QueryUnbondingDelegationResponse, QueryValidatorRequest, QueryValidatorResponse,
QueryValidatorsRequest, QueryValidatorsResponse,
};

use crate::module::Module;
use crate::runner::Runner;

pub struct Staking<'a, R: Runner<'a>> {
runner: &'a R,
}

impl<'a, R: Runner<'a>> Module<'a, R> for Staking<'a, R> {
fn new(runner: &'a R) -> Self {
Self { runner }
}
}

impl<'a, R> Staking<'a, R>
where
R: Runner<'a>,
{
fn_execute! {
pub delegate: MsgDelegate["/cosmos.staking.v1beta1.MsgDelegate"] => MsgDelegateResponse
}

fn_execute! {
pub create_validator: MsgCreateValidator["/cosmos.staking.v1beta1.MsgCreateValidator"] => MsgCreateValidatorResponse
}

fn_execute! {
pub edit_validator: MsgEditValidator["/cosmos.staking.v1beta1.MsgEditValidator"] => MsgEditValidatorResponse
}

fn_execute! {
pub redelegate: MsgBeginRedelegate["/cosmos.staking.v1beta1.MsgBeginRedelegate"] => MsgBeginRedelegateResponse
}

fn_execute! {
pub unbond: MsgUnbondValidator["/cosmos.staking.v1beta1.MsgUnbondValidator"] => MsgUnbondValidator
}

fn_query! {
pub query_delegation ["/cosmos.bank.v1beta1.Query/Balance"]: QueryDelegationRequest => QueryDelegationResponse
}

fn_query! {
pub query_delegations ["/cosmos.bank.v1beta1.Query/AllBalances"]: QueryDelegatorDelegationsRequest => QueryDelegatorDelegationsResponse
}

fn_query! {
pub query_unbonding_delegation ["/cosmos.bank.v1beta1.Query/Balance"]: QueryUnbondingDelegationRequest => QueryUnbondingDelegationResponse
}

fn_query! {
pub query_unbonding_delegations ["/cosmos.bank.v1beta1.Query/AllBalances"]: QueryDelegatorUnbondingDelegationsRequest => QueryDelegatorUnbondingDelegationsResponse
}

fn_query! {
pub query_redelegations ["/cosmos.staking.v1beta1.Query/Redelegations"]: QueryRedelegationsRequest => QueryRedelegationsResponse
}

fn_query! {
pub query_validator ["/cosmos.bank.v1beta1.Query/Balance"]: QueryValidatorRequest => QueryValidatorResponse
}

fn_query! {
pub query_validators ["/cosmos.bank.v1beta1.Query/AllBalances"]: QueryValidatorsRequest => QueryValidatorsResponse
}

fn_query! {
pub query_params ["/cosmos.bank.v1beta1.Query/AllBalances"]: QueryParamsRequest => QueryParamsResponse
}

fn_query! {
pub query_pool ["/cosmos.bank.v1beta1.Query/AllBalances"]: QueryPoolRequest => QueryPoolResponse
}
}

0 comments on commit 8e9aa06

Please sign in to comment.