Skip to content

Commit

Permalink
add bin/schema.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
codeninja819 committed Nov 21, 2023
1 parent b737a1d commit a1e1bd6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
schema = "run schema"
10 changes: 10 additions & 0 deletions src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use cosmwasm_schema::write_api;
use staking::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ExecuteMsg,
query: QueryMsg
}
}
30 changes: 19 additions & 11 deletions src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Coin, Timestamp};
use cw721::Cw721ReceiveMsg;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[cw_serde]
pub struct InstantiateMsg {}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub enum ExecuteMsg {
TransferOwnership {
address: String,
Expand All @@ -27,26 +25,36 @@ pub enum ExecuteMsg {
},
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(ConfigResponse)]
GetConfig {},
#[returns(Vec<CollectionResponse>)]
GetCollections {},
#[returns(Vec<StakingResponse>)]
GetStakingsByOwner { owner: String },
}

// responses
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct ConfigResponse {
pub owner: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct CollectionResponse {
pub address: String,
pub reward: Coin,
pub cycle: u64,
pub is_whitelisted: bool,
}

#[cw_serde]
pub struct StakingResponse {
pub token_address: String, // nft collection ca
pub token_id: String,
pub start_timestamp: Timestamp,
pub end_timestamp: Timestamp,
pub is_paid: bool,
}
Binary file added staking.wasm
Binary file not shown.

0 comments on commit a1e1bd6

Please sign in to comment.