Skip to content

Commit

Permalink
build(deps): update to cosmwasm v1.1 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelesbao authored Jan 24, 2023
2 parents 5c1daf8 + 5f44643 commit 1d54299
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 80 deletions.
58 changes: 44 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ overflow-checks = true
opt-level = 3
debug = false
debug-assertions = false

[workspace.dependencies]
cosmwasm-schema = "1.1.9"
cosmwasm-std = { version = "1.1.9", features = ["stargate"] }
cosmwasm-storage = "1.1.9"
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "1.0.1"
schemars = "0.8.11"
serde = { version = "1.0.147", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.37" }
18 changes: 9 additions & 9 deletions contracts/increment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = "=1.0.0"
cosmwasm-storage = "=1.0.0"
archway-bindings = { version = "0.1.0", path = "../../packages/bindings" }
cw-storage-plus = "0.14"
cw-utils = "0.14"
cw2 = "0.14"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde-json-wasm = "0.5"
thiserror = "1.0"
thiserror = { workspace = true }

[dev-dependencies]
cosmwasm-schema = "=1.0.0"
27 changes: 15 additions & 12 deletions contracts/increment/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
use archway_bindings::Coins;
use archway_bindings::{
types::{gov, rewards},
Coins,
};
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Addr;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

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

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub enum ExecuteMsg {
Increment {},
Reset { count: i32 },
UpdateRewardsAddress { rewards_address: Option<Addr> },
WithdrawRewards {},
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
// GetCount returns the current count as a json-encoded number
#[returns(CountResponse)]
GetCount {},
#[returns(rewards::ContractMetadataResponse)]
Metadata { contract_address: Option<Addr> },
#[returns(OutstandingRewardsResponse)]
OutstandingRewards {},
#[returns(gov::VoteResponse)]
GovVote { proposal_id: u64, voter: Addr },
}

// We define a custom struct for each query response
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[cw_serde]
pub struct CountResponse {
pub count: i32,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[cw_serde]
pub struct OutstandingRewardsResponse {
pub rewards_balance: Coins,
pub total_records: u64,
Expand Down
9 changes: 5 additions & 4 deletions packages/bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cosmwasm-std = { version = "=1.0.0", features = ["stargate"] }
schemars = "0.8.11"
serde = { version = "1.0.147", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.37" }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
7 changes: 2 additions & 5 deletions packages/bindings/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{CosmosMsg, CustomMsg};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub enum ArchwayMsg {
UpdateContractMetadata {
owner_address: Option<String>,
Expand Down
10 changes: 4 additions & 6 deletions packages/bindings/src/pagination.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_schema::cw_serde;

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
#[derive(Default)]
pub struct PageRequest {
key: Option<String>,
offset: Option<u64>,
Expand Down Expand Up @@ -42,8 +41,7 @@ impl PageRequest {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct PageResponse {
pub next_key: Option<String>,
pub total: Option<u64>,
Expand Down
21 changes: 9 additions & 12 deletions packages/bindings/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::CustomQuery;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::pagination::PageRequest;
use crate::types::{gov, rewards};

#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
#[derive(QueryResponses)]
pub enum ArchwayQuery {
ContractMetadata {
contract_address: String,
},
#[returns(rewards::ContractMetadataResponse)]
ContractMetadata { contract_address: String },
#[returns(rewards::RewardsRecordsResponse)]
RewardsRecords {
rewards_address: String,
pagination: Option<PageRequest>,
},
GovVote {
proposal_id: u64,
voter: String,
},
#[returns(gov::VoteResponse)]
GovVote { proposal_id: u64, voter: String },
}

impl CustomQuery for ArchwayQuery {}
Expand Down
12 changes: 4 additions & 8 deletions packages/bindings/src/types/gov.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::VoteOption;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct VoteResponse {
pub vote: Vote,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct Vote {
pub proposal_id: u64,
pub voter: String,
pub options: Vec<WeightedVoteOption>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct WeightedVoteOption {
pub option: VoteOption,
pub weight: String,
Expand Down
15 changes: 5 additions & 10 deletions packages/bindings/src/types/rewards.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_schema::cw_serde;

use crate::{Coins, PageResponse};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct WithdrawRewardsResponse {
pub records_num: u64,
pub total_rewards: Coins,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct ContractMetadataResponse {
pub owner_address: String,
pub rewards_address: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct RewardsRecordsResponse {
pub records: Vec<RewardsRecord>,
pub pagination: Option<PageResponse>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cw_serde]
pub struct RewardsRecord {
pub id: u64,
pub rewards_address: String,
Expand Down

0 comments on commit 1d54299

Please sign in to comment.