From eaab9b32673ca68e20e031270b8c35696413af80 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 17 Feb 2022 11:38:25 -0600 Subject: [PATCH 01/82] rename package name --- packages/sg-std/Cargo.toml | 27 +++++ packages/sg-std/examples/schema.rs | 15 +++ packages/sg-std/schema/stargaze_msg.json | 82 +++++++++++++ .../sg-std/schema/stargaze_msg_wrapper.json | 111 ++++++++++++++++++ packages/sg-std/src/lib.rs | 13 ++ packages/sg-std/src/msg.rs | 64 ++++++++++ packages/sg-std/src/route.rs | 12 ++ 7 files changed, 324 insertions(+) create mode 100644 packages/sg-std/Cargo.toml create mode 100644 packages/sg-std/examples/schema.rs create mode 100644 packages/sg-std/schema/stargaze_msg.json create mode 100644 packages/sg-std/schema/stargaze_msg_wrapper.json create mode 100644 packages/sg-std/src/lib.rs create mode 100644 packages/sg-std/src/msg.rs create mode 100644 packages/sg-std/src/route.rs diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml new file mode 100644 index 0000000..4589a8a --- /dev/null +++ b/packages/sg-std/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "sg-std" +version = "0.1.0" +edition = "2021" + +authors = ["Jorge Hernandez "] +description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze" +license = "Apache-2.0" +repository = "https://github.com/public-awesome/contracts" +homepage = "https://stargaze.zone" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] + +[dependencies] +cosmwasm-std = { version = "1.0.0-beta" } +schemars = "0.8.8" +serde = { version = "1.0.133", default-features = false, features = ["derive"] } + +[dev-dependencies] +cosmwasm-schema = { version = "1.0.0-beta" } \ No newline at end of file diff --git a/packages/sg-std/examples/schema.rs b/packages/sg-std/examples/schema.rs new file mode 100644 index 0000000..f70a354 --- /dev/null +++ b/packages/sg-std/examples/schema.rs @@ -0,0 +1,15 @@ +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; + +use sg_std::{StargazeMsg, StargazeMsgWrapper}; +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(StargazeMsgWrapper), &out_dir); + export_schema(&schema_for!(StargazeMsg), &out_dir); +} diff --git a/packages/sg-std/schema/stargaze_msg.json b/packages/sg-std/schema/stargaze_msg.json new file mode 100644 index 0000000..08cd31d --- /dev/null +++ b/packages/sg-std/schema/stargaze_msg.json @@ -0,0 +1,82 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StargazeMsg", + "description": "StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types", + "oneOf": [ + { + "type": "object", + "required": [ + "claim_for" + ], + "properties": { + "claim_for": { + "type": "object", + "required": [ + "action", + "address" + ], + "properties": { + "action": { + "$ref": "#/definitions/ClaimAction" + }, + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "fund_community_pool" + ], + "properties": { + "fund_community_pool": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "ClaimAction": { + "type": "string", + "enum": [ + "mint_nft", + "bid_nft" + ] + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/packages/sg-std/schema/stargaze_msg_wrapper.json b/packages/sg-std/schema/stargaze_msg_wrapper.json new file mode 100644 index 0000000..d82ca4a --- /dev/null +++ b/packages/sg-std/schema/stargaze_msg_wrapper.json @@ -0,0 +1,111 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StargazeMsgWrapper", + "description": "StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types", + "type": "object", + "required": [ + "msg_data", + "route", + "version" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/StargazeMsg" + }, + "route": { + "$ref": "#/definitions/StargazeRoute" + }, + "version": { + "type": "string" + } + }, + "definitions": { + "ClaimAction": { + "type": "string", + "enum": [ + "mint_nft", + "bid_nft" + ] + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "StargazeMsg": { + "description": "StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types", + "oneOf": [ + { + "type": "object", + "required": [ + "claim_for" + ], + "properties": { + "claim_for": { + "type": "object", + "required": [ + "action", + "address" + ], + "properties": { + "action": { + "$ref": "#/definitions/ClaimAction" + }, + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "fund_community_pool" + ], + "properties": { + "fund_community_pool": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "StargazeRoute": { + "description": "StargazeRoute is enum type to represent stargaze query route path", + "type": "string", + "enum": [ + "alloc", + "claim", + "distribution" + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs new file mode 100644 index 0000000..5bb790c --- /dev/null +++ b/packages/sg-std/src/lib.rs @@ -0,0 +1,13 @@ +mod msg; +mod route; + +pub use msg::{ + create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, + StargazeMsgWrapper, +}; +pub use route::StargazeRoute; + +// This export is added to all contracts that import this package, signifying that they require +// "stargaze" support on the chain they run on. +#[no_mangle] +extern "C" fn requires_stargaze() {} diff --git a/packages/sg-std/src/msg.rs b/packages/sg-std/src/msg.rs new file mode 100644 index 0000000..eec1ca3 --- /dev/null +++ b/packages/sg-std/src/msg.rs @@ -0,0 +1,64 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use crate::route::StargazeRoute; +use cosmwasm_std::{Coin, CosmosMsg, CustomMsg}; + +static MSG_DATA_VERSION: &str = "1.0.0"; + +/// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub struct StargazeMsgWrapper { + pub route: StargazeRoute, + pub msg_data: StargazeMsg, + pub version: String, +} + +impl From for CosmosMsg { + fn from(original: StargazeMsgWrapper) -> Self { + CosmosMsg::Custom(original) + } +} + +impl CustomMsg for StargazeMsgWrapper {} + +/// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum StargazeMsg { + ClaimFor { + address: String, + action: ClaimAction, + }, + FundCommunityPool { + amount: Vec, + }, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ClaimAction { + #[serde(rename = "mint_nft")] + MintNFT, + #[serde(rename = "bid_nft")] + BidNFT, +} + +pub fn create_claim_for_msg(address: String, action: ClaimAction) -> CosmosMsg { + StargazeMsgWrapper { + route: StargazeRoute::Claim, + msg_data: StargazeMsg::ClaimFor { address, action }, + version: MSG_DATA_VERSION.to_owned(), + } + .into() +} + +pub fn create_fund_community_pool_msg(amount: Vec) -> CosmosMsg { + StargazeMsgWrapper { + route: StargazeRoute::Distribution, + msg_data: StargazeMsg::FundCommunityPool { amount }, + version: MSG_DATA_VERSION.to_owned(), + } + .into() +} diff --git a/packages/sg-std/src/route.rs b/packages/sg-std/src/route.rs new file mode 100644 index 0000000..3f7a9b1 --- /dev/null +++ b/packages/sg-std/src/route.rs @@ -0,0 +1,12 @@ +use schemars::JsonSchema; + +use serde::{Deserialize, Serialize}; + +/// StargazeRoute is enum type to represent stargaze query route path +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum StargazeRoute { + Alloc, + Claim, + Distribution, +} From 698e5f1020b34695e680306165ff832eaa15bfe0 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 17 Feb 2022 19:00:15 -0600 Subject: [PATCH 02/82] impl cw721 custom msg for wrapper --- packages/sg-std/Cargo.toml | 1 + packages/sg-std/src/msg.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 4589a8a..7efe74e 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -20,6 +20,7 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0-beta" } +cw721 = "0.11" schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } diff --git a/packages/sg-std/src/msg.rs b/packages/sg-std/src/msg.rs index eec1ca3..5f6a8d0 100644 --- a/packages/sg-std/src/msg.rs +++ b/packages/sg-std/src/msg.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::route::StargazeRoute; use cosmwasm_std::{Coin, CosmosMsg, CustomMsg}; - +use cw721::CustomMsg as Cw721CustomMsg; static MSG_DATA_VERSION: &str = "1.0.0"; /// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types @@ -22,8 +22,8 @@ impl From for CosmosMsg { } impl CustomMsg for StargazeMsgWrapper {} +impl Cw721CustomMsg for StargazeMsgWrapper {} -/// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum StargazeMsg { From 79ef6e533ce0dcfa5aaa9ed6eeda3cef78a25ecb Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 19 Feb 2022 22:54:07 -0500 Subject: [PATCH 03/82] Add fee denom to sg-std --- packages/sg-std/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 5bb790c..25eab96 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,6 +1,8 @@ mod msg; mod route; +pub const FEE_DENOM: &str = "ustars"; + pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, StargazeMsgWrapper, From 8147966463f2771855963dd73d2797f2c0b3520d Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 19 Feb 2022 23:29:01 -0500 Subject: [PATCH 04/82] Move native denom constant into sg-std --- packages/sg-std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 25eab96..e76e36a 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,7 +1,7 @@ mod msg; mod route; -pub const FEE_DENOM: &str = "ustars"; +pub const NATIVE_DENOM: &str = "ustars"; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From 9d8b0f89c8895b4a13c553476c7061ecc2dce1aa Mon Sep 17 00:00:00 2001 From: John Y Date: Tue, 22 Feb 2022 15:30:23 -0500 Subject: [PATCH 05/82] wip --- packages/sg-std/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index e76e36a..1728083 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -2,6 +2,8 @@ mod msg; mod route; pub const NATIVE_DENOM: &str = "ustars"; +// 3/1/2022 00:00:00GMT +pub const START_TIME: u64 = 1646092800000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From e7e3be9bc25a8d4a52a543992c53745ab8b72c51 Mon Sep 17 00:00:00 2001 From: John Y Date: Wed, 23 Feb 2022 10:55:03 -0500 Subject: [PATCH 06/82] start time on or after genesis mint --- packages/sg-std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 1728083..ae8e5f9 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -3,7 +3,7 @@ mod route; pub const NATIVE_DENOM: &str = "ustars"; // 3/1/2022 00:00:00GMT -pub const START_TIME: u64 = 1646092800000000000; +pub const GENESIS_MINT_START_TIME: u64 = 1646092800000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From 80398247385ccd68a1fc96f1e758dea4ebdcd9fe Mon Sep 17 00:00:00 2001 From: John Y Date: Wed, 23 Feb 2022 19:13:17 -0500 Subject: [PATCH 07/82] change default start time to 3/1/22 12:00ET --- packages/sg-std/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index ae8e5f9..1acc33f 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -2,8 +2,8 @@ mod msg; mod route; pub const NATIVE_DENOM: &str = "ustars"; -// 3/1/2022 00:00:00GMT -pub const GENESIS_MINT_START_TIME: u64 = 1646092800000000000; +// 3/1/2022 12:00:00 ET +pub const GENESIS_MINT_START_TIME: u64 = 1646154000000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From 71f4da2f4a40800083b47806ee319545b462b3fd Mon Sep 17 00:00:00 2001 From: John Y Date: Thu, 24 Feb 2022 12:15:34 -0500 Subject: [PATCH 08/82] change genesis mint time for testnet --- packages/sg-std/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 1acc33f..d29d2b6 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -2,8 +2,8 @@ mod msg; mod route; pub const NATIVE_DENOM: &str = "ustars"; -// 3/1/2022 12:00:00 ET -pub const GENESIS_MINT_START_TIME: u64 = 1646154000000000000; +// 3/1/2022 12:00:00 ET 1646154000000000000 +pub const GENESIS_MINT_START_TIME: u64 = 1645376400000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From 09538b2090d1df19db2f4968529af42fb8d16164 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Wed, 23 Feb 2022 19:39:36 -0500 Subject: [PATCH 09/82] Add fees to sg-std --- packages/sg-std/Cargo.toml | 4 ++- packages/sg-std/src/fees.rs | 49 +++++++++++++++++++++++++++++++++++++ packages/sg-std/src/lib.rs | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 packages/sg-std/src/fees.rs diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 7efe74e..7d69042 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -20,9 +20,11 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0-beta" } +cw-utils = "0.12.1" cw721 = "0.11" schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } +thiserror = "1.0.30" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } \ No newline at end of file +cosmwasm-schema = { version = "1.0.0-beta" } diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs new file mode 100644 index 0000000..3ea521c --- /dev/null +++ b/packages/sg-std/src/fees.rs @@ -0,0 +1,49 @@ +use crate::{create_fund_community_pool_msg, NATIVE_DENOM}; +use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; +use cw_utils::{must_pay, PaymentError}; +use thiserror::Error; + +const FEE_BURN_PERCENT: u64 = 50; + +pub fn handle_fee( + env: Env, + info: &MessageInfo, + expected_fee: u128, +) -> Result>, FeeError> { + let payment = must_pay(info, NATIVE_DENOM)?; + if payment.u128() != expected_fee { + return Err(FeeError::InvalidFee {}); + } + + // calculate the fee to burn + let burn_percent = Decimal::percent(FEE_BURN_PERCENT); + let burn_fee = payment * burn_percent; + let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); + // send fee to contract to be burned + let send_fee_msg = BankMsg::Send { + to_address: env.contract.address.to_string(), + amount: vec![burn_coin.clone()], + }; + // burn half the fee + let fee_burn_msg = BankMsg::Burn { + amount: vec![burn_coin], + }; + + let fund_community_pool_msg = + create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); + + Ok(vec![ + cosmwasm_std::CosmosMsg::Bank(send_fee_msg), + cosmwasm_std::CosmosMsg::Bank(fee_burn_msg), + fund_community_pool_msg, + ]) +} + +#[derive(Error, Debug, PartialEq)] +pub enum FeeError { + #[error("InvalidFee")] + InvalidFee {}, + + #[error("{0}")] + Payment(#[from] PaymentError), +} diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index d29d2b6..a0d881d 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,3 +1,4 @@ +mod fees; mod msg; mod route; From fabdd20688ba825c869ac166d86747f37ba940db Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Wed, 23 Feb 2022 20:22:16 -0500 Subject: [PATCH 10/82] Reverted whitelist --- packages/sg-std/src/fees.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 3ea521c..adfd508 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,15 +1,15 @@ -use crate::{create_fund_community_pool_msg, NATIVE_DENOM}; +use crate::{create_fund_community_pool_msg, StargazeMsg, NATIVE_DENOM}; use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; const FEE_BURN_PERCENT: u64 = 50; -pub fn handle_fee( +pub fn handle_fee( env: Env, info: &MessageInfo, expected_fee: u128, -) -> Result>, FeeError> { +) -> Result, FeeError> { let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() != expected_fee { return Err(FeeError::InvalidFee {}); @@ -33,9 +33,9 @@ pub fn handle_fee( create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); Ok(vec![ - cosmwasm_std::CosmosMsg::Bank(send_fee_msg), - cosmwasm_std::CosmosMsg::Bank(fee_burn_msg), - fund_community_pool_msg, + CosmosMsg::Bank(send_fee_msg), + CosmosMsg::Bank(fee_burn_msg), + CosmosMsg::Custom(fund_community_pool_msg), ]) } From cda557f2f2d03ea6572be618520ade671bf4b1cf Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Wed, 23 Feb 2022 20:51:52 -0500 Subject: [PATCH 11/82] Fix types --- packages/sg-std/src/fees.rs | 6 +++--- packages/sg-std/src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index adfd508..1fa21c7 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,4 +1,4 @@ -use crate::{create_fund_community_pool_msg, StargazeMsg, NATIVE_DENOM}; +use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; @@ -9,7 +9,7 @@ pub fn handle_fee( env: Env, info: &MessageInfo, expected_fee: u128, -) -> Result, FeeError> { +) -> Result>, FeeError> { let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() != expected_fee { return Err(FeeError::InvalidFee {}); @@ -35,7 +35,7 @@ pub fn handle_fee( Ok(vec![ CosmosMsg::Bank(send_fee_msg), CosmosMsg::Bank(fee_burn_msg), - CosmosMsg::Custom(fund_community_pool_msg), + fund_community_pool_msg, ]) } diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index a0d881d..9e5d013 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,4 +1,4 @@ -mod fees; +pub mod fees; mod msg; mod route; From b85dfd6bae20183d458b3abe6d9becb5d33d089f Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Wed, 23 Feb 2022 21:13:56 -0500 Subject: [PATCH 12/82] Rename function --- packages/sg-std/src/fees.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 1fa21c7..2d82a35 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -5,7 +5,7 @@ use thiserror::Error; const FEE_BURN_PERCENT: u64 = 50; -pub fn handle_fee( +pub fn burn_and_distribute_fee( env: Env, info: &MessageInfo, expected_fee: u128, From 8a59110c5daf172b9c3a7016279774a5b7c93ed8 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Wed, 23 Feb 2022 18:33:56 -0800 Subject: [PATCH 13/82] Remove unneeded bank send message --- packages/sg-std/src/fees.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 2d82a35..daca3f6 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -6,7 +6,7 @@ use thiserror::Error; const FEE_BURN_PERCENT: u64 = 50; pub fn burn_and_distribute_fee( - env: Env, + _env: Env, info: &MessageInfo, expected_fee: u128, ) -> Result>, FeeError> { @@ -19,24 +19,16 @@ pub fn burn_and_distribute_fee( let burn_percent = Decimal::percent(FEE_BURN_PERCENT); let burn_fee = payment * burn_percent; let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); - // send fee to contract to be burned - let send_fee_msg = BankMsg::Send { - to_address: env.contract.address.to_string(), - amount: vec![burn_coin.clone()], - }; // burn half the fee let fee_burn_msg = BankMsg::Burn { amount: vec![burn_coin], }; + // Send other half to community pool let fund_community_pool_msg = create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); - Ok(vec![ - CosmosMsg::Bank(send_fee_msg), - CosmosMsg::Bank(fee_burn_msg), - fund_community_pool_msg, - ]) + Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) } #[derive(Error, Debug, PartialEq)] From fb63dcd5da49521476c27a66142fb8f3e8bf1ed8 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Feb 2022 12:39:18 -0500 Subject: [PATCH 14/82] Added back whitelist tests --- packages/sg-std/src/fees.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index daca3f6..396c19a 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,5 +1,5 @@ -use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; +use crate::NATIVE_DENOM; +use cosmwasm_std::{coin, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; @@ -9,7 +9,7 @@ pub fn burn_and_distribute_fee( _env: Env, info: &MessageInfo, expected_fee: u128, -) -> Result>, FeeError> { +) -> Result, FeeError> { let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() != expected_fee { return Err(FeeError::InvalidFee {}); @@ -24,11 +24,14 @@ pub fn burn_and_distribute_fee( amount: vec![burn_coin], }; - // Send other half to community pool - let fund_community_pool_msg = - create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); + // TODO: add back after fixing: https://github.com/public-awesome/stargaze-contracts/issues/46 + // // Send other half to community pool + // let fund_community_pool_msg = + // create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); - Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) + // Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) + + Ok(vec![CosmosMsg::Bank(fee_burn_msg)]) } #[derive(Error, Debug, PartialEq)] From bada221cbac704dacc7038d0c725ea4a7dda077e Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 25 Feb 2022 22:56:35 -0600 Subject: [PATCH 15/82] add send community pool, fix whitelist types --- packages/sg-std/src/fees.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 396c19a..c91a13c 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,15 +1,16 @@ -use crate::NATIVE_DENOM; -use cosmwasm_std::{coin, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; +use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; +use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; const FEE_BURN_PERCENT: u64 = 50; +type SubMsg = CosmosMsg; pub fn burn_and_distribute_fee( _env: Env, info: &MessageInfo, expected_fee: u128, -) -> Result, FeeError> { +) -> Result, FeeError> { let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() != expected_fee { return Err(FeeError::InvalidFee {}); @@ -25,13 +26,11 @@ pub fn burn_and_distribute_fee( }; // TODO: add back after fixing: https://github.com/public-awesome/stargaze-contracts/issues/46 - // // Send other half to community pool - // let fund_community_pool_msg = - // create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); + // Send other half to community pool + let fund_community_pool_msg = + create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); - // Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) - - Ok(vec![CosmosMsg::Bank(fee_burn_msg)]) + Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) } #[derive(Error, Debug, PartialEq)] From 3cea0710d9fe0e207cdecf17ae3ef921fceeae4c Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 25 Feb 2022 23:13:22 -0600 Subject: [PATCH 16/82] add sg721 for custom message --- packages/sg-std/Cargo.toml | 5 ++++- packages/sg-std/src/lib.rs | 4 ++++ packages/sg-std/src/query.rs | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 packages/sg-std/src/query.rs diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 7d69042..0236bb8 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -21,7 +21,10 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0-beta" } cw-utils = "0.12.1" -cw721 = "0.11" +cw721 = { git = "https://github.com/public-awesome/cw-nfts", branch = "shanev/fix-versions" } +cw721-base = { git = "https://github.com/public-awesome/cw-nfts", branch = "shanev/fix-versions", features = [ + "library", +] } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 9e5d013..a8f8bc1 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,5 +1,6 @@ pub mod fees; mod msg; +mod query; mod route; pub const NATIVE_DENOM: &str = "ustars"; @@ -10,6 +11,9 @@ pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, StargazeMsgWrapper, }; + +pub use fees::burn_and_distribute_fee; +pub use query::StargazeQuery; pub use route::StargazeRoute; // This export is added to all contracts that import this package, signifying that they require diff --git a/packages/sg-std/src/query.rs b/packages/sg-std/src/query.rs new file mode 100644 index 0000000..b67fd93 --- /dev/null +++ b/packages/sg-std/src/query.rs @@ -0,0 +1,10 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::CustomQuery; + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub enum StargazeQuery {} + +impl CustomQuery for StargazeQuery {} From a22a4e81d53d1a88d46975d08291e13bf0f9bb1e Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Feb 2022 11:04:24 -0500 Subject: [PATCH 17/82] Make fees more general --- packages/sg-std/src/fees.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index c91a13c..d91fb7a 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,43 +1,37 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo}; +use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; +// governance parameters const FEE_BURN_PERCENT: u64 = 50; type SubMsg = CosmosMsg; pub fn burn_and_distribute_fee( _env: Env, info: &MessageInfo, - expected_fee: u128, + fee_amount: u128, ) -> Result, FeeError> { - let payment = must_pay(info, NATIVE_DENOM)?; - if payment.u128() != expected_fee { - return Err(FeeError::InvalidFee {}); - } + must_pay(info, NATIVE_DENOM)?; // calculate the fee to burn let burn_percent = Decimal::percent(FEE_BURN_PERCENT); - let burn_fee = payment * burn_percent; + let burn_fee = Uint128::from(fee_amount) * burn_percent; let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); // burn half the fee let fee_burn_msg = BankMsg::Burn { amount: vec![burn_coin], }; - // TODO: add back after fixing: https://github.com/public-awesome/stargaze-contracts/issues/46 // Send other half to community pool let fund_community_pool_msg = - create_fund_community_pool_msg(coins(payment.u128() - burn_fee.u128(), NATIVE_DENOM)); + create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) } #[derive(Error, Debug, PartialEq)] pub enum FeeError { - #[error("InvalidFee")] - InvalidFee {}, - #[error("{0}")] Payment(#[from] PaymentError), } From c7ba4b873ccc50851d82069a91d2f98090bb33f8 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Feb 2022 19:14:33 -0500 Subject: [PATCH 18/82] Check correct fee amounts --- packages/sg-std/src/fees.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index d91fb7a..cd24445 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -12,7 +12,10 @@ pub fn burn_and_distribute_fee( info: &MessageInfo, fee_amount: u128, ) -> Result, FeeError> { - must_pay(info, NATIVE_DENOM)?; + let payment = must_pay(info, NATIVE_DENOM)?; + if payment.u128() < fee_amount { + return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); + }; // calculate the fee to burn let burn_percent = Decimal::percent(FEE_BURN_PERCENT); @@ -32,6 +35,9 @@ pub fn burn_and_distribute_fee( #[derive(Error, Debug, PartialEq)] pub enum FeeError { + #[error("Insufficient fee: expected {0}, got {1}")] + InsufficientFee(u128, u128), + #[error("{0}")] Payment(#[from] PaymentError), } From e44f73b00bfe12a583942f21b9c8026de89d307c Mon Sep 17 00:00:00 2001 From: John Y Date: Sun, 27 Feb 2022 12:21:10 -0500 Subject: [PATCH 19/82] more println for debugging --- packages/sg-std/src/fees.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index cd24445..7a359c4 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,11 +1,21 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; +use cosmwasm_std::{coin, BankMsg, Coin, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; // governance parameters const FEE_BURN_PERCENT: u64 = 50; +// deal with zero and non-zero coin amounts for msgs +fn convert_coins_for_msg(msg_coin: Coin) -> Vec { + if msg_coin.amount > Uint128::zero() { + vec![msg_coin] + } else { + println!("sg-std fees: no funds sent"); + vec![] + } +} + type SubMsg = CosmosMsg; pub fn burn_and_distribute_fee( _env: Env, @@ -23,12 +33,17 @@ pub fn burn_and_distribute_fee( let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); // burn half the fee let fee_burn_msg = BankMsg::Burn { - amount: vec![burn_coin], + amount: convert_coins_for_msg(burn_coin), }; + println!("fee burn msg: {:?}", fee_burn_msg); // Send other half to community pool - let fund_community_pool_msg = - create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); + let fund_community_pool_msg = create_fund_community_pool_msg(convert_coins_for_msg(coin( + fee_amount - burn_fee.u128(), + NATIVE_DENOM, + ))); + + println!("fund community pool msg: {:?}", fund_community_pool_msg); Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) } From ac88bad5c7ae0642671c0ac05a70b3dcc49505df Mon Sep 17 00:00:00 2001 From: John Y Date: Sun, 27 Feb 2022 13:50:12 -0500 Subject: [PATCH 20/82] simplify error in happy path --- packages/sg-std/src/fees.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 7a359c4..ce3c8fa 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,6 +1,6 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coin, BankMsg, Coin, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; -use cw_utils::{must_pay, PaymentError}; +use cosmwasm_std::{coin, coins, BankMsg, Coin, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; +use cw_utils::{may_pay, PaymentError}; use thiserror::Error; // governance parameters @@ -12,7 +12,7 @@ fn convert_coins_for_msg(msg_coin: Coin) -> Vec { vec![msg_coin] } else { println!("sg-std fees: no funds sent"); - vec![] + coins(0, NATIVE_DENOM) } } @@ -22,16 +22,22 @@ pub fn burn_and_distribute_fee( info: &MessageInfo, fee_amount: u128, ) -> Result, FeeError> { - let payment = must_pay(info, NATIVE_DENOM)?; + println!("inside burn and distribute fee"); + let payment = may_pay(info, NATIVE_DENOM)?; if payment.u128() < fee_amount { return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); }; + println!("before burn calc"); // calculate the fee to burn let burn_percent = Decimal::percent(FEE_BURN_PERCENT); let burn_fee = Uint128::from(fee_amount) * burn_percent; let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); // burn half the fee + println!( + "fee burn msg: {:?}", + convert_coins_for_msg(burn_coin.clone()) + ); let fee_burn_msg = BankMsg::Burn { amount: convert_coins_for_msg(burn_coin), }; From 14c61e122676fbee7043df2c9855d2d7dc243ca7 Mon Sep 17 00:00:00 2001 From: John Y Date: Sun, 27 Feb 2022 15:06:02 -0500 Subject: [PATCH 21/82] happy_path works --- packages/sg-std/src/fees.rs | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index ce3c8fa..8c86c7f 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,21 +1,11 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coin, coins, BankMsg, Coin, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; +use cosmwasm_std::{coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; use cw_utils::{may_pay, PaymentError}; use thiserror::Error; // governance parameters const FEE_BURN_PERCENT: u64 = 50; -// deal with zero and non-zero coin amounts for msgs -fn convert_coins_for_msg(msg_coin: Coin) -> Vec { - if msg_coin.amount > Uint128::zero() { - vec![msg_coin] - } else { - println!("sg-std fees: no funds sent"); - coins(0, NATIVE_DENOM) - } -} - type SubMsg = CosmosMsg; pub fn burn_and_distribute_fee( _env: Env, @@ -28,26 +18,17 @@ pub fn burn_and_distribute_fee( return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); }; - println!("before burn calc"); // calculate the fee to burn let burn_percent = Decimal::percent(FEE_BURN_PERCENT); let burn_fee = Uint128::from(fee_amount) * burn_percent; - let burn_coin = coin(burn_fee.u128(), NATIVE_DENOM); + let burn_coin = coins(burn_fee.u128(), NATIVE_DENOM); // burn half the fee - println!( - "fee burn msg: {:?}", - convert_coins_for_msg(burn_coin.clone()) - ); - let fee_burn_msg = BankMsg::Burn { - amount: convert_coins_for_msg(burn_coin), - }; + let fee_burn_msg = BankMsg::Burn { amount: burn_coin }; println!("fee burn msg: {:?}", fee_burn_msg); // Send other half to community pool - let fund_community_pool_msg = create_fund_community_pool_msg(convert_coins_for_msg(coin( - fee_amount - burn_fee.u128(), - NATIVE_DENOM, - ))); + let fund_community_pool_msg = + create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); println!("fund community pool msg: {:?}", fund_community_pool_msg); From b61ce36ad25d5a338b210d765796ebf5e32020bb Mon Sep 17 00:00:00 2001 From: John Y Date: Sun, 27 Feb 2022 16:07:22 -0500 Subject: [PATCH 22/82] clean up --- packages/sg-std/src/fees.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 8c86c7f..824a1c7 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -12,26 +12,22 @@ pub fn burn_and_distribute_fee( info: &MessageInfo, fee_amount: u128, ) -> Result, FeeError> { - println!("inside burn and distribute fee"); let payment = may_pay(info, NATIVE_DENOM)?; if payment.u128() < fee_amount { return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); }; // calculate the fee to burn + // burn half the fee let burn_percent = Decimal::percent(FEE_BURN_PERCENT); let burn_fee = Uint128::from(fee_amount) * burn_percent; let burn_coin = coins(burn_fee.u128(), NATIVE_DENOM); - // burn half the fee let fee_burn_msg = BankMsg::Burn { amount: burn_coin }; - println!("fee burn msg: {:?}", fee_burn_msg); // Send other half to community pool let fund_community_pool_msg = create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); - println!("fund community pool msg: {:?}", fund_community_pool_msg); - Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) } From d73db8b867551c2ec7fdd12bf08c68760ef8f33f Mon Sep 17 00:00:00 2001 From: John Y Date: Sun, 27 Feb 2022 17:21:00 -0500 Subject: [PATCH 23/82] change back to stricter must_pay --- packages/sg-std/src/fees.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 824a1c7..df8adf7 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,6 +1,6 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; use cosmwasm_std::{coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; -use cw_utils::{may_pay, PaymentError}; +use cw_utils::{must_pay, PaymentError}; use thiserror::Error; // governance parameters @@ -12,7 +12,7 @@ pub fn burn_and_distribute_fee( info: &MessageInfo, fee_amount: u128, ) -> Result, FeeError> { - let payment = may_pay(info, NATIVE_DENOM)?; + let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() < fee_amount { return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); }; From 2975f5dcbe0027a4a653e10a96fee328253d9676 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 28 Feb 2022 15:47:53 -0500 Subject: [PATCH 24/82] Updated cw721 deps --- packages/sg-std/Cargo.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 0236bb8..6f6b08e 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -21,10 +21,8 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0-beta" } cw-utils = "0.12.1" -cw721 = { git = "https://github.com/public-awesome/cw-nfts", branch = "shanev/fix-versions" } -cw721-base = { git = "https://github.com/public-awesome/cw-nfts", branch = "shanev/fix-versions", features = [ - "library", -] } +cw721 = "0.12.0" +cw721-base = "0.12.0" schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" From bc244b49640aca356524021b5a02d70b74c28cde Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 28 Feb 2022 15:53:10 -0500 Subject: [PATCH 25/82] Use cw721-base as a library --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 6f6b08e..4d05ca1 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -22,7 +22,7 @@ library = [] cosmwasm-std = { version = "1.0.0-beta" } cw-utils = "0.12.1" cw721 = "0.12.0" -cw721-base = "0.12.0" +cw721-base = { version = "0.12.0", features = ["library"] } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" From d0fb0745ce70443a223f1bf5a567e5ab52f804c6 Mon Sep 17 00:00:00 2001 From: John Y Date: Tue, 1 Mar 2022 07:26:59 -0500 Subject: [PATCH 26/82] update genesis mint time --- packages/sg-std/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index a8f8bc1..ef95ea6 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -4,8 +4,8 @@ mod query; mod route; pub const NATIVE_DENOM: &str = "ustars"; -// 3/1/2022 12:00:00 ET 1646154000000000000 -pub const GENESIS_MINT_START_TIME: u64 = 1645376400000000000; +// 3/4/2022 16:00:00 ET 1646427600000000000 +pub const GENESIS_MINT_START_TIME: u64 = 1646427600000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From 54398438df913d7ed308a7a236446d62eb676b22 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 4 Mar 2022 20:13:12 -0500 Subject: [PATCH 27/82] Update versions --- packages/sg-std/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 4d05ca1..d544a8f 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.1.0" +version = "0.6.0" edition = "2021" authors = ["Jorge Hernandez "] @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta5" } cw-utils = "0.12.1" cw721 = "0.12.0" cw721-base = { version = "0.12.0", features = ["library"] } @@ -28,4 +28,4 @@ serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta5" } From 76cc3a96bef8179a2b8cdaea666b116a9e1db13f Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 4 Mar 2022 20:21:09 -0500 Subject: [PATCH 28/82] Update versions --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index d544a8f..f05ecf4 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.6.0" +version = "0.6.1" edition = "2021" authors = ["Jorge Hernandez "] From ca5fcd56728054e5c124ee0efdd7c82148dde0be Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 10:21:12 -0500 Subject: [PATCH 29/82] Update genesis mint start time --- packages/sg-std/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index ef95ea6..7ee5b4f 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -4,8 +4,8 @@ mod query; mod route; pub const NATIVE_DENOM: &str = "ustars"; -// 3/4/2022 16:00:00 ET 1646427600000000000 -pub const GENESIS_MINT_START_TIME: u64 = 1646427600000000000; +// 3/11/2022 16:00:00 ET +pub const GENESIS_MINT_START_TIME: u64 = 1647032400000000000; pub use msg::{ create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, From d4430af03340b16e9f23faeb0e78bda59cf79a19 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 10:41:05 -0500 Subject: [PATCH 30/82] Update versions and tests --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index f05ecf4..a272036 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.6.1" +version = "0.7.2" edition = "2021" authors = ["Jorge Hernandez "] From e06b72f91b2e6feec938858c6e4daa888d482dd9 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Mon, 7 Mar 2022 21:07:23 -0600 Subject: [PATCH 31/82] prepare 0.8.0 release --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index a272036..8ddc082 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.7.2" +version = "0.8.0" edition = "2021" authors = ["Jorge Hernandez "] From a93c57167cc60ba646d37d7d28093961926e4568 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Mar 2022 01:36:20 -0400 Subject: [PATCH 32/82] Removed unused Env --- packages/sg-std/src/fees.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index df8adf7..2879a86 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -1,5 +1,5 @@ use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coins, BankMsg, CosmosMsg, Decimal, Env, MessageInfo, Uint128}; +use cosmwasm_std::{coins, BankMsg, CosmosMsg, Decimal, MessageInfo, Uint128}; use cw_utils::{must_pay, PaymentError}; use thiserror::Error; @@ -8,7 +8,6 @@ const FEE_BURN_PERCENT: u64 = 50; type SubMsg = CosmosMsg; pub fn burn_and_distribute_fee( - _env: Env, info: &MessageInfo, fee_amount: u128, ) -> Result, FeeError> { From ffa16bdbb80a4a107ead091ced1bb987f643febb Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Mar 2022 02:21:59 -0400 Subject: [PATCH 33/82] Update sg721 version --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 8ddc082..a0c27cb 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.8.0" +version = "0.9.0" edition = "2021" authors = ["Jorge Hernandez "] From 8a3cef7e97a49cd690a1fce8acca2be6afb98ef3 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 10:35:01 -0400 Subject: [PATCH 34/82] Moved multi to its own package --- packages/sg-multi-test/Cargo.toml | 29 ++++++ packages/sg-multi-test/src/multi.rs | 141 ++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 packages/sg-multi-test/Cargo.toml create mode 100644 packages/sg-multi-test/src/multi.rs diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml new file mode 100644 index 0000000..55378cf --- /dev/null +++ b/packages/sg-multi-test/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "sg-multi-test" +version = "0.8.0" +edition = "2021" + +authors = [ + "Jorge Hernandez ", + "Shane Vitarana ", +] +description = "Integration test helpers for Stargaze custom contracts" +license = "Apache-2.0" +repository = "https://github.com/public-awesome/contracts" +homepage = "https://stargaze.zone" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] + +[dependencies] +anyhow = "1" +cw-multi-test = "0.12.1" +cosmwasm-std = { version = "1.0.0-beta5" } +schemars = "0.8.8" +serde = { version = "1.0.133", default-features = false, features = ["derive"] } diff --git a/packages/sg-multi-test/src/multi.rs b/packages/sg-multi-test/src/multi.rs new file mode 100644 index 0000000..2e10b98 --- /dev/null +++ b/packages/sg-multi-test/src/multi.rs @@ -0,0 +1,141 @@ +use anyhow::{bail, Result as AnyResult}; +use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; +use cosmwasm_std::{BankMsg, OwnedDeps}; +use std::fmt::Debug; +use std::marker::PhantomData; + +use schemars::JsonSchema; +use serde::de::DeserializeOwned; + +use std::ops::{Deref, DerefMut}; + +use cosmwasm_std::{ + Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, QuerierResult, Storage, +}; +use cw_multi_test::{ + App, AppResponse, BankKeeper, BasicAppBuilder, CosmosRouter, Module, WasmKeeper, +}; + +use sg_std::{StargazeMsgWrapper, StargazeQuery}; + +pub struct StargazeModule {} + +pub type StargazeDeps = OwnedDeps; + +pub fn mock_deps() -> StargazeDeps { + OwnedDeps { + storage: MockStorage::default(), + api: MockApi::default(), + querier: MockQuerier::default(), + custom_query_type: PhantomData, + } +} + +impl StargazeModule {} + +impl Module for StargazeModule { + type ExecT = StargazeMsgWrapper; + type QueryT = Empty; + type SudoT = Empty; + + fn execute( + &self, + api: &dyn Api, + storage: &mut dyn Storage, + router: &dyn CosmosRouter, + block: &BlockInfo, + sender: Addr, + msg: StargazeMsgWrapper, + ) -> AnyResult + where + ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static, + QueryC: CustomQuery + DeserializeOwned + 'static, + { + let StargazeMsgWrapper { + route: _, + msg_data, + version: _, + } = msg; + + match msg_data { + sg_std::StargazeMsg::FundCommunityPool { amount } => { + let msg = BankMsg::Send { + to_address: "community_pool".to_owned(), + amount, + } + .into(); + router.execute(api, storage, block, sender, msg)?; + Ok(AppResponse::default()) + } + _ => { + bail!("not implemented") + } + } + } + fn sudo( + &self, + _api: &dyn Api, + _storage: &mut dyn Storage, + _router: &dyn CosmosRouter, + _block: &BlockInfo, + _msg: Self::SudoT, + ) -> AnyResult + where + ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static, + QueryC: CustomQuery + DeserializeOwned + 'static, + { + bail!("sudo not implemented") + } + + fn query( + &self, + _api: &dyn Api, + _storage: &dyn Storage, + _querier: &dyn Querier, + _block: &BlockInfo, + request: Empty, + ) -> anyhow::Result { + bail!("custom query not implemented {:?}", request) + } +} + +pub type StargazeBasicApp = + App>; + +pub struct StargazeApp(StargazeBasicApp); + +impl Deref for StargazeApp { + type Target = StargazeBasicApp; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for StargazeApp { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl Querier for StargazeApp { + fn raw_query(&self, bin_request: &[u8]) -> QuerierResult { + self.0.raw_query(bin_request) + } +} + +impl StargazeApp { + pub fn new() -> Self { + Self( + BasicAppBuilder::::new_custom() + .with_custom(StargazeModule {}) + .build(|_, _, _| {}), + ) + } +} + +impl Default for StargazeApp { + fn default() -> Self { + Self::new() + } +} From c01a3fb9f5e8c343ea44a691875a67565c653974 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 10:43:55 -0400 Subject: [PATCH 35/82] Add lib --- packages/sg-multi-test/Cargo.toml | 10 ---------- packages/sg-multi-test/src/lib.rs | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) create mode 100644 packages/sg-multi-test/src/lib.rs diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 55378cf..f614941 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -2,7 +2,6 @@ name = "sg-multi-test" version = "0.8.0" edition = "2021" - authors = [ "Jorge Hernandez ", "Shane Vitarana ", @@ -12,15 +11,6 @@ license = "Apache-2.0" repository = "https://github.com/public-awesome/contracts" homepage = "https://stargaze.zone" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - - -[features] -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - [dependencies] anyhow = "1" cw-multi-test = "0.12.1" diff --git a/packages/sg-multi-test/src/lib.rs b/packages/sg-multi-test/src/lib.rs new file mode 100644 index 0000000..5e07a63 --- /dev/null +++ b/packages/sg-multi-test/src/lib.rs @@ -0,0 +1 @@ +mod multi; From 75fba742ca428c60f508eb4bd8f6d03fc6273d40 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 10:46:10 -0400 Subject: [PATCH 36/82] Fix deps --- packages/sg-multi-test/Cargo.toml | 6 ++---- packages/sg-multi-test/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index f614941..6417926 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -2,10 +2,7 @@ name = "sg-multi-test" version = "0.8.0" edition = "2021" -authors = [ - "Jorge Hernandez ", - "Shane Vitarana ", -] +authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" license = "Apache-2.0" repository = "https://github.com/public-awesome/contracts" @@ -17,3 +14,4 @@ cw-multi-test = "0.12.1" cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } +sg-std = "0.8.1" diff --git a/packages/sg-multi-test/src/lib.rs b/packages/sg-multi-test/src/lib.rs index 5e07a63..3a8965d 100644 --- a/packages/sg-multi-test/src/lib.rs +++ b/packages/sg-multi-test/src/lib.rs @@ -1 +1 @@ -mod multi; +pub mod multi; From 8420408a7403791bb9324e5a4360e4ebf07d669b Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 17:13:20 -0400 Subject: [PATCH 37/82] Re-org imports --- packages/sg-multi-test/src/multi.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/sg-multi-test/src/multi.rs b/packages/sg-multi-test/src/multi.rs index 2e10b98..484d0a7 100644 --- a/packages/sg-multi-test/src/multi.rs +++ b/packages/sg-multi-test/src/multi.rs @@ -1,22 +1,18 @@ use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; -use cosmwasm_std::{BankMsg, OwnedDeps}; -use std::fmt::Debug; -use std::marker::PhantomData; - -use schemars::JsonSchema; -use serde::de::DeserializeOwned; - -use std::ops::{Deref, DerefMut}; - use cosmwasm_std::{ Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, QuerierResult, Storage, }; +use cosmwasm_std::{BankMsg, OwnedDeps}; use cw_multi_test::{ App, AppResponse, BankKeeper, BasicAppBuilder, CosmosRouter, Module, WasmKeeper, }; - +use schemars::JsonSchema; +use serde::de::DeserializeOwned; use sg_std::{StargazeMsgWrapper, StargazeQuery}; +use std::fmt::Debug; +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; pub struct StargazeModule {} From 62f4cf723bab223a98e06dc6d0d85f418ae0210f Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 18:01:10 -0400 Subject: [PATCH 38/82] Export just what is needed --- packages/sg-multi-test/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sg-multi-test/src/lib.rs b/packages/sg-multi-test/src/lib.rs index 3a8965d..6ba3c69 100644 --- a/packages/sg-multi-test/src/lib.rs +++ b/packages/sg-multi-test/src/lib.rs @@ -1 +1,3 @@ -pub mod multi; +mod multi; + +pub use crate::multi::{mock_deps, StargazeApp, StargazeDeps, StargazeModule}; From 2a25b89341ee1c0d0a4b412e53111b86c6a1547f Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 25 Mar 2022 18:20:45 -0400 Subject: [PATCH 39/82] Updated deps --- packages/sg-multi-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 6417926..dbc1508 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -12,6 +12,6 @@ homepage = "https://stargaze.zone" anyhow = "1" cw-multi-test = "0.12.1" cosmwasm-std = { version = "1.0.0-beta5" } -schemars = "0.8.8" -serde = { version = "1.0.133", default-features = false, features = ["derive"] } +schemars = "0.8" +serde = { version = "1.0", default-features = false, features = ["derive"] } sg-std = "0.8.1" From 9e1608f3cd3c8680a42e776e9c7e197809d69c00 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Mar 2022 02:30:02 -0400 Subject: [PATCH 40/82] Updated sg-std dep --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index dbc1508..54feaf8 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.12.1" cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.8.1" +sg-std = "0.9.0" From 2a1d514cf3440d854d1463fd9eb673a392389f17 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Mar 2022 12:04:41 -0400 Subject: [PATCH 41/82] Upgraded CW --- packages/sg-multi-test/Cargo.toml | 4 ++-- packages/sg-std/Cargo.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 54feaf8..c730465 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -10,8 +10,8 @@ homepage = "https://stargaze.zone" [dependencies] anyhow = "1" -cw-multi-test = "0.12.1" -cosmwasm-std = { version = "1.0.0-beta5" } +cw-multi-test = "0.13.1" +cosmwasm-std = { version = "1.0.0-beta7" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } sg-std = "0.9.0" diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index a0c27cb..e742498 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -19,8 +19,8 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.0.0-beta5" } -cw-utils = "0.12.1" +cosmwasm-std = { version = "1.0.0-beta7" } +cw-utils = "0.13.1" cw721 = "0.12.0" cw721-base = { version = "0.12.0", features = ["library"] } schemars = "0.8.8" @@ -28,4 +28,4 @@ serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta7" } From e536b37ee42ff189172a80b263125d7d6e5de281 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 26 Mar 2022 13:34:50 -0400 Subject: [PATCH 42/82] Upgrade cw721 --- packages/sg-std/Cargo.toml | 4 ++-- packages/sg-std/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index e742498..23f589b 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -21,8 +21,8 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0-beta7" } cw-utils = "0.13.1" -cw721 = "0.12.0" -cw721-base = { version = "0.12.0", features = ["library"] } +cw721 = "0.13.1" +cw721-base = { version = "0.13.1", features = ["library"] } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 7ee5b4f..11b38c1 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,4 +1,4 @@ -pub mod fees; +mod fees; mod msg; mod query; mod route; @@ -12,7 +12,7 @@ pub use msg::{ StargazeMsgWrapper, }; -pub use fees::burn_and_distribute_fee; +pub use fees::{burn_and_distribute_fee, FeeError}; pub use query::StargazeQuery; pub use route::StargazeRoute; From b388384cd7ba07513954eb76a238e2fcb7d8e1fa Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sun, 27 Mar 2022 01:22:31 -0400 Subject: [PATCH 43/82] Updated sg-std version --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 23f589b..e09b4ea 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.9.0" +version = "0.9.1" edition = "2021" authors = ["Jorge Hernandez "] From 72af6e9982df193d020bec9d3b396e4ae36a7e57 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sun, 27 Mar 2022 02:06:19 -0400 Subject: [PATCH 44/82] Use local paths instead of crates --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index c730465..af4bee8 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.1" cosmwasm-std = { version = "1.0.0-beta7" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.9.0" +sg-std = { path = "../sg-std" } From 34c63044a2526cbb3577ab8d91253c7040ba2db0 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sun, 27 Mar 2022 13:25:38 -0400 Subject: [PATCH 45/82] Add wrapped type helpers --- packages/sg-std/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 11b38c1..f290d8d 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -12,6 +12,10 @@ pub use msg::{ StargazeMsgWrapper, }; +pub type Response = cosmwasm_std::Response; +pub type SubMsg = cosmwasm_std::SubMsg; +pub type CosmosMsg = cosmwasm_std::CosmosMsg; + pub use fees::{burn_and_distribute_fee, FeeError}; pub use query::StargazeQuery; pub use route::StargazeRoute; From 7748df78d2286a53dcb38861ca8ba020da752c15 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sun, 27 Mar 2022 14:47:16 -0400 Subject: [PATCH 46/82] Update multitest version --- packages/sg-multi-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index af4bee8..a429265 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.8.0" +version = "0.9.1" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" @@ -14,4 +14,4 @@ cw-multi-test = "0.13.1" cosmwasm-std = { version = "1.0.0-beta7" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = { path = "../sg-std" } +sg-std = "0.9.1" From b8a965978910ac0ec0a65012a393e2cadc1f87a4 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 1 Apr 2022 20:41:21 -0400 Subject: [PATCH 47/82] Split Fair Burn into two functions --- packages/sg-std/Cargo.toml | 2 +- packages/sg-std/src/fees.rs | 14 +++++++++----- packages/sg-std/src/lib.rs | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index e09b4ea..ff76e3b 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.9.1" +version = "0.10.0" edition = "2021" authors = ["Jorge Hernandez "] diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs index 2879a86..0344811 100644 --- a/packages/sg-std/src/fees.rs +++ b/packages/sg-std/src/fees.rs @@ -7,15 +7,19 @@ use thiserror::Error; const FEE_BURN_PERCENT: u64 = 50; type SubMsg = CosmosMsg; -pub fn burn_and_distribute_fee( - info: &MessageInfo, - fee_amount: u128, -) -> Result, FeeError> { + +/// Burn and distribute fees and return an error if the fee is not enough +pub fn checked_fair_burn(info: &MessageInfo, fee_amount: u128) -> Result, FeeError> { let payment = must_pay(info, NATIVE_DENOM)?; if payment.u128() < fee_amount { return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); }; + Ok(fair_burn(fee_amount)) +} + +/// Burn and distribute fees, assuming the right fee is passed in +pub fn fair_burn(fee_amount: u128) -> Vec { // calculate the fee to burn // burn half the fee let burn_percent = Decimal::percent(FEE_BURN_PERCENT); @@ -27,7 +31,7 @@ pub fn burn_and_distribute_fee( let fund_community_pool_msg = create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); - Ok(vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]) + return vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]; } #[derive(Error, Debug, PartialEq)] diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index f290d8d..7dec98e 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -16,7 +16,7 @@ pub type Response = cosmwasm_std::Response; pub type SubMsg = cosmwasm_std::SubMsg; pub type CosmosMsg = cosmwasm_std::CosmosMsg; -pub use fees::{burn_and_distribute_fee, FeeError}; +pub use fees::{checked_fair_burn, fair_burn, FeeError}; pub use query::StargazeQuery; pub use route::StargazeRoute; From 637e05e4e4f2ac04f73c3233b5e4dacdf882b773 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 2 Apr 2022 00:02:15 -0400 Subject: [PATCH 48/82] Updated to use new Fair Burn messages --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index a429265..3a9ab25 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.1" cosmwasm-std = { version = "1.0.0-beta7" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.9.1" +sg-std = "0.10.0" From cdc7b50636b9e220247629a29f49b9aa392bcfee Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 2 Apr 2022 00:04:08 -0400 Subject: [PATCH 49/82] Update versions --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 3a9ab25..783adf0 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.9.1" +version = "0.10.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" From ad0abf161a316925246f3b5a2a1614b05085e0b8 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 8 Apr 2022 22:14:25 -0400 Subject: [PATCH 50/82] Remove fees from sg-std --- packages/sg-std/.cargo/config | 4 ++ packages/sg-std/schema/stargaze_msg.json | 1 - .../sg-std/schema/stargaze_msg_wrapper.json | 1 - packages/sg-std/src/fees.rs | 44 ------------------- packages/sg-std/src/lib.rs | 2 - 5 files changed, 4 insertions(+), 48 deletions(-) create mode 100644 packages/sg-std/.cargo/config delete mode 100644 packages/sg-std/src/fees.rs diff --git a/packages/sg-std/.cargo/config b/packages/sg-std/.cargo/config new file mode 100644 index 0000000..336b618 --- /dev/null +++ b/packages/sg-std/.cargo/config @@ -0,0 +1,4 @@ +[alias] +wasm = "build --release --target wasm32-unknown-unknown" +unit-test = "test --lib" +schema = "run --example schema" diff --git a/packages/sg-std/schema/stargaze_msg.json b/packages/sg-std/schema/stargaze_msg.json index 08cd31d..f9be1e1 100644 --- a/packages/sg-std/schema/stargaze_msg.json +++ b/packages/sg-std/schema/stargaze_msg.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "StargazeMsg", - "description": "StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types", "oneOf": [ { "type": "object", diff --git a/packages/sg-std/schema/stargaze_msg_wrapper.json b/packages/sg-std/schema/stargaze_msg_wrapper.json index d82ca4a..f18d2d8 100644 --- a/packages/sg-std/schema/stargaze_msg_wrapper.json +++ b/packages/sg-std/schema/stargaze_msg_wrapper.json @@ -43,7 +43,6 @@ } }, "StargazeMsg": { - "description": "StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types", "oneOf": [ { "type": "object", diff --git a/packages/sg-std/src/fees.rs b/packages/sg-std/src/fees.rs deleted file mode 100644 index 0344811..0000000 --- a/packages/sg-std/src/fees.rs +++ /dev/null @@ -1,44 +0,0 @@ -use crate::{create_fund_community_pool_msg, StargazeMsgWrapper, NATIVE_DENOM}; -use cosmwasm_std::{coins, BankMsg, CosmosMsg, Decimal, MessageInfo, Uint128}; -use cw_utils::{must_pay, PaymentError}; -use thiserror::Error; - -// governance parameters -const FEE_BURN_PERCENT: u64 = 50; - -type SubMsg = CosmosMsg; - -/// Burn and distribute fees and return an error if the fee is not enough -pub fn checked_fair_burn(info: &MessageInfo, fee_amount: u128) -> Result, FeeError> { - let payment = must_pay(info, NATIVE_DENOM)?; - if payment.u128() < fee_amount { - return Err(FeeError::InsufficientFee(fee_amount, payment.u128())); - }; - - Ok(fair_burn(fee_amount)) -} - -/// Burn and distribute fees, assuming the right fee is passed in -pub fn fair_burn(fee_amount: u128) -> Vec { - // calculate the fee to burn - // burn half the fee - let burn_percent = Decimal::percent(FEE_BURN_PERCENT); - let burn_fee = Uint128::from(fee_amount) * burn_percent; - let burn_coin = coins(burn_fee.u128(), NATIVE_DENOM); - let fee_burn_msg = BankMsg::Burn { amount: burn_coin }; - - // Send other half to community pool - let fund_community_pool_msg = - create_fund_community_pool_msg(coins(fee_amount - burn_fee.u128(), NATIVE_DENOM)); - - return vec![CosmosMsg::Bank(fee_burn_msg), fund_community_pool_msg]; -} - -#[derive(Error, Debug, PartialEq)] -pub enum FeeError { - #[error("Insufficient fee: expected {0}, got {1}")] - InsufficientFee(u128, u128), - - #[error("{0}")] - Payment(#[from] PaymentError), -} diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 7dec98e..a55c335 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,4 +1,3 @@ -mod fees; mod msg; mod query; mod route; @@ -16,7 +15,6 @@ pub type Response = cosmwasm_std::Response; pub type SubMsg = cosmwasm_std::SubMsg; pub type CosmosMsg = cosmwasm_std::CosmosMsg; -pub use fees::{checked_fair_burn, fair_burn, FeeError}; pub use query::StargazeQuery; pub use route::StargazeRoute; From 33a15e25a9cfb309fa5667fcf9108372c8db4201 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 8 Apr 2022 22:21:43 -0400 Subject: [PATCH 51/82] Update versions --- packages/sg-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index ff76e3b..e7cf7ae 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.10.0" +version = "0.11.0" edition = "2021" authors = ["Jorge Hernandez "] From 412884945106b8f60f0789f7fd52bf88261df79c Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 8 Apr 2022 22:29:14 -0400 Subject: [PATCH 52/82] Add README --- packages/sg-std/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 packages/sg-std/README.md diff --git a/packages/sg-std/README.md b/packages/sg-std/README.md new file mode 100644 index 0000000..78e6d56 --- /dev/null +++ b/packages/sg-std/README.md @@ -0,0 +1,9 @@ +# Stargaze Standard Library + +Common library for Stargaze smart contracts. + +## Messages + +`ClaimFor{address, action}` - Claim airdrop for a given action. + +`FundCommunityPool{amount}` - Fund the Stargaze Community Pool for a specified amount. From d473cd6f74498ade94ea40c359909e93926dd569 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Thu, 21 Apr 2022 11:57:42 -0400 Subject: [PATCH 53/82] Updated versions --- packages/sg-multi-test/Cargo.toml | 4 ++-- packages/sg-std/Cargo.toml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 783adf0..2862eea 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -10,8 +10,8 @@ homepage = "https://stargaze.zone" [dependencies] anyhow = "1" -cw-multi-test = "0.13.1" -cosmwasm-std = { version = "1.0.0-beta7" } +cw-multi-test = "0.13.2" +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } sg-std = "0.10.0" diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index e7cf7ae..6b15cbb 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.11.0" +version = "0.12.0" edition = "2021" authors = ["Jorge Hernandez "] @@ -19,13 +19,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.0.0-beta7" } -cw-utils = "0.13.1" -cw721 = "0.13.1" -cw721-base = { version = "0.13.1", features = ["library"] } +cosmwasm-std = { version = "1.0.0-beta8" } +cw-utils = "0.13.2" +cw721 = "0.13.2" +cw721-base = { version = "0.13.2", features = ["library"] } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta7" } +cosmwasm-schema = { version = "1.0.0-beta8" } From 72dbfd3b76eaeb720697940d4cbc381d57f8bb2d Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Thu, 21 Apr 2022 12:11:35 -0400 Subject: [PATCH 54/82] Use new Fair Burn --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 2862eea..16bb2c7 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.2" cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.10.0" +sg-std = "0.12.0" From 42921ea1136a85fe2519561698dbdfb5b669f769 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Thu, 21 Apr 2022 13:13:44 -0400 Subject: [PATCH 55/82] Update multitest version --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 16bb2c7..ba873ed 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.10.0" +version = "0.12.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" From aad4ef21a854dfbd16aef065093f116b056a35af Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 25 Apr 2022 17:08:01 -0400 Subject: [PATCH 56/82] Update sg-multi-test error --- packages/sg-multi-test/Cargo.toml | 2 +- packages/sg-multi-test/src/multi.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index ba873ed..abee423 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.12.0" +version = "0.12.1" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" diff --git a/packages/sg-multi-test/src/multi.rs b/packages/sg-multi-test/src/multi.rs index 484d0a7..fca1756 100644 --- a/packages/sg-multi-test/src/multi.rs +++ b/packages/sg-multi-test/src/multi.rs @@ -64,7 +64,7 @@ impl Module for StargazeModule { Ok(AppResponse::default()) } _ => { - bail!("not implemented") + bail!("stargaze msg not implemented") } } } From fd9ba6d5e3ae093a1d5db3edbe92cee91a9813bc Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 26 Apr 2022 09:44:48 -0600 Subject: [PATCH 57/82] add claim for message handling --- packages/sg-multi-test/src/multi.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/sg-multi-test/src/multi.rs b/packages/sg-multi-test/src/multi.rs index fca1756..33edf6d 100644 --- a/packages/sg-multi-test/src/multi.rs +++ b/packages/sg-multi-test/src/multi.rs @@ -63,9 +63,10 @@ impl Module for StargazeModule { router.execute(api, storage, block, sender, msg)?; Ok(AppResponse::default()) } - _ => { - bail!("stargaze msg not implemented") - } + sg_std::StargazeMsg::ClaimFor { + action: _, + address: _, + } => Ok(AppResponse::default()), } } fn sudo( From 3361fd83a3e50339f47903ef7fb4fe62a118a3f0 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 26 Apr 2022 12:21:46 -0400 Subject: [PATCH 58/82] Check if sale was finalized and update versions --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index abee423..c860b29 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.12.1" +version = "0.13.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" From d5a6a60a74b1114f2570ed7a2b084d5298e17474 Mon Sep 17 00:00:00 2001 From: Jorge Hernandez <3452489+jhernandezb@users.noreply.github.com> Date: Wed, 29 Jun 2022 10:32:32 -0600 Subject: [PATCH 59/82] add fund fairburn pool msg (#286) * fund fee collector * add fund fairburn pool message * update multitest * update e2e tests to fairburn pool * update comments * update version * fix e2e tets * update optimizer * disable claim tests * update fee * update readme --- packages/sg-multi-test/Cargo.toml | 4 ++-- packages/sg-multi-test/src/multi.rs | 9 +++++++++ packages/sg-std/Cargo.toml | 6 +++--- packages/sg-std/README.md | 1 + packages/sg-std/src/lib.rs | 4 ++-- packages/sg-std/src/msg.rs | 12 ++++++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index c860b29..ecc4d0a 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://stargaze.zone" [dependencies] anyhow = "1" cw-multi-test = "0.13.2" -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.12.0" +sg-std = { path = "../../packages/sg-std" } diff --git a/packages/sg-multi-test/src/multi.rs b/packages/sg-multi-test/src/multi.rs index 33edf6d..ac76640 100644 --- a/packages/sg-multi-test/src/multi.rs +++ b/packages/sg-multi-test/src/multi.rs @@ -63,6 +63,15 @@ impl Module for StargazeModule { router.execute(api, storage, block, sender, msg)?; Ok(AppResponse::default()) } + sg_std::StargazeMsg::FundFairburnPool { amount } => { + let msg = BankMsg::Send { + to_address: "fairburn_pool".to_owned(), + amount, + } + .into(); + router.execute(api, storage, block, sender, msg)?; + Ok(AppResponse::default()) + } sg_std::StargazeMsg::ClaimFor { action: _, address: _, diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 6b15cbb..ac7f760 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.12.0" +version = "0.12.1" edition = "2021" authors = ["Jorge Hernandez "] @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } cw-utils = "0.13.2" cw721 = "0.13.2" cw721-base = { version = "0.13.2", features = ["library"] } @@ -28,4 +28,4 @@ serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/sg-std/README.md b/packages/sg-std/README.md index 78e6d56..d76eec5 100644 --- a/packages/sg-std/README.md +++ b/packages/sg-std/README.md @@ -7,3 +7,4 @@ Common library for Stargaze smart contracts. `ClaimFor{address, action}` - Claim airdrop for a given action. `FundCommunityPool{amount}` - Fund the Stargaze Community Pool for a specified amount. +`FundFairburnPool{amount}` - Fund the Fairburn Pool for a specified amount. diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index a55c335..073ddd5 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -7,8 +7,8 @@ pub const NATIVE_DENOM: &str = "ustars"; pub const GENESIS_MINT_START_TIME: u64 = 1647032400000000000; pub use msg::{ - create_claim_for_msg, create_fund_community_pool_msg, ClaimAction, StargazeMsg, - StargazeMsgWrapper, + create_claim_for_msg, create_fund_community_pool_msg, create_fund_fairburn_pool_msg, + ClaimAction, StargazeMsg, StargazeMsgWrapper, }; pub type Response = cosmwasm_std::Response; diff --git a/packages/sg-std/src/msg.rs b/packages/sg-std/src/msg.rs index 5f6a8d0..90cc5bc 100644 --- a/packages/sg-std/src/msg.rs +++ b/packages/sg-std/src/msg.rs @@ -34,6 +34,9 @@ pub enum StargazeMsg { FundCommunityPool { amount: Vec, }, + FundFairburnPool { + amount: Vec, + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -62,3 +65,12 @@ pub fn create_fund_community_pool_msg(amount: Vec) -> CosmosMsg) -> CosmosMsg { + StargazeMsgWrapper { + route: StargazeRoute::Alloc, + msg_data: StargazeMsg::FundFairburnPool { amount }, + version: MSG_DATA_VERSION.to_owned(), + } + .into() +} From 357e346a96a4d203f0f86ba16464a2270853ee4f Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 15 Jul 2022 02:27:04 -0400 Subject: [PATCH 60/82] Add u64 trait extension --- packages/sg-std/src/lib.rs | 1 + packages/sg-std/src/math.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 packages/sg-std/src/math.rs diff --git a/packages/sg-std/src/lib.rs b/packages/sg-std/src/lib.rs index 073ddd5..c4ff502 100644 --- a/packages/sg-std/src/lib.rs +++ b/packages/sg-std/src/lib.rs @@ -1,3 +1,4 @@ +pub mod math; mod msg; mod query; mod route; diff --git a/packages/sg-std/src/math.rs b/packages/sg-std/src/math.rs new file mode 100644 index 0000000..7378dbe --- /dev/null +++ b/packages/sg-std/src/math.rs @@ -0,0 +1,11 @@ +use cosmwasm_std::{Decimal, Uint128}; + +pub trait U64Ext { + fn to_percent(self) -> Decimal; +} + +impl U64Ext for u64 { + fn to_percent(self) -> Decimal { + Decimal::percent(self) / Uint128::from(100u128) + } +} From 319be6803810d713122f803d9619f62b2ff41e49 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 15 Jul 2022 03:04:45 -0400 Subject: [PATCH 61/82] Better naming in trait extension --- packages/sg-std/src/math.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/src/math.rs b/packages/sg-std/src/math.rs index 7378dbe..060e610 100644 --- a/packages/sg-std/src/math.rs +++ b/packages/sg-std/src/math.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{Decimal, Uint128}; pub trait U64Ext { - fn to_percent(self) -> Decimal; + fn bps_to_decimal(self) -> Decimal; } impl U64Ext for u64 { - fn to_percent(self) -> Decimal { + fn bps_to_decimal(self) -> Decimal { Decimal::percent(self) / Uint128::from(100u128) } } From 1c3d764a6f5ded9d259ab024cad4f52709488f98 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 19 Jul 2022 11:07:46 -0400 Subject: [PATCH 62/82] Upgraded cw-plus version --- packages/sg-multi-test/Cargo.toml | 2 +- packages/sg-std/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index ecc4d0a..d326dc0 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://stargaze.zone" [dependencies] anyhow = "1" -cw-multi-test = "0.13.2" +cw-multi-test = "0.13.4" cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index ac7f760..6f001e0 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -20,7 +20,7 @@ library = [] [dependencies] cosmwasm-std = { version = "1.0.0" } -cw-utils = "0.13.2" +cw-utils = "0.13.4" cw721 = "0.13.2" cw721-base = { version = "0.13.2", features = ["library"] } schemars = "0.8.8" From 58f43ad72842c527b9930201983661782d69d5c5 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 25 Jul 2022 15:21:29 -0400 Subject: [PATCH 63/82] Update sg1 version --- packages/sg-multi-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index ecc4d0a..31480c6 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.13.0" +version = "0.14.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" @@ -14,4 +14,4 @@ cw-multi-test = "0.13.2" cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = { path = "../../packages/sg-std" } +sg-std = { version = "0.12.1" } From 838067c08ac29d6c0027a11dc9cba7cfa63d716c Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 22 Aug 2022 11:45:57 -0400 Subject: [PATCH 64/82] Update sg-std version --- packages/sg-multi-test/Cargo.toml | 2 +- packages/sg-std/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 91cb5af..f13b8af 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.4" cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = { path = "../sg-std" } +sg-std = "0.13.0" diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 6f001e0..3af55e7 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.12.1" +version = "0.13.0" edition = "2021" authors = ["Jorge Hernandez "] From fd1230d4f03fa8a248c29aaa4c386ed8682f5c94 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 22 Aug 2022 12:02:02 -0400 Subject: [PATCH 65/82] Update sg-multi-test version --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index f13b8af..a4d87e2 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-multi-test" -version = "0.14.0" +version = "0.15.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" From bd93a5681fa13d37789db1b1085a7c3cd4cd4385 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 26 Aug 2022 20:39:58 -0400 Subject: [PATCH 66/82] Update repo --- packages/sg-std/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 3af55e7..fcbcda3 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "sg-std" -version = "0.13.0" +version = "0.14.0" edition = "2021" authors = ["Jorge Hernandez "] description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze" license = "Apache-2.0" -repository = "https://github.com/public-awesome/contracts" +repository = "https://github.com/public-awesome/launchpad" homepage = "https://stargaze.zone" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From b719bf1af9056bbceddbf3cf254d8bfd4aa15926 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 26 Aug 2022 20:41:50 -0400 Subject: [PATCH 67/82] Updated sg-std --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index a4d87e2..f0fa4dc 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.4" cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.13.0" +sg-std = "0.14.0" From 668cf10acc9c51f4891235e93567e92d675dee2d Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 26 Aug 2022 21:12:36 -0400 Subject: [PATCH 68/82] Removed unused deps with udep --- packages/sg-std/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index fcbcda3..88f05ce 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -22,7 +22,6 @@ library = [] cosmwasm-std = { version = "1.0.0" } cw-utils = "0.13.4" cw721 = "0.13.2" -cw721-base = { version = "0.13.2", features = ["library"] } schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" From 6fd549e74654b7aff7276b9dbc9399ef9740e0e7 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Fri, 26 Aug 2022 21:57:19 -0400 Subject: [PATCH 69/82] Fixed repos --- packages/sg-multi-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index f0fa4dc..a869509 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "sg-multi-test" -version = "0.15.0" +version = "0.15.1" edition = "2021" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" license = "Apache-2.0" -repository = "https://github.com/public-awesome/contracts" +repository = "https://github.com/public-awesome/launchpad" homepage = "https://stargaze.zone" [dependencies] From d3ee8d221831e94125c247a336da0fabb2c50469 Mon Sep 17 00:00:00 2001 From: John Y Date: Tue, 13 Sep 2022 15:41:22 -0400 Subject: [PATCH 70/82] cargos to local path --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index a869509..08fbf5d 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cw-multi-test = "0.13.4" cosmwasm-std = { version = "1.0.0" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = "0.14.0" +sg-std = { path = "../sg-std" } From e982c7f64b1d38e657ab305db6447a61c0d8845d Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Mon, 19 Sep 2022 17:45:45 -0600 Subject: [PATCH 71/82] update schema --- packages/sg-std/schema/stargaze_msg.json | 23 +++++++++++++++++++ .../sg-std/schema/stargaze_msg_wrapper.json | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/sg-std/schema/stargaze_msg.json b/packages/sg-std/schema/stargaze_msg.json index f9be1e1..ceaf840 100644 --- a/packages/sg-std/schema/stargaze_msg.json +++ b/packages/sg-std/schema/stargaze_msg.json @@ -48,6 +48,29 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "fund_fairburn_pool" + ], + "properties": { + "fund_fairburn_pool": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false } ], "definitions": { diff --git a/packages/sg-std/schema/stargaze_msg_wrapper.json b/packages/sg-std/schema/stargaze_msg_wrapper.json index f18d2d8..ab3756b 100644 --- a/packages/sg-std/schema/stargaze_msg_wrapper.json +++ b/packages/sg-std/schema/stargaze_msg_wrapper.json @@ -90,6 +90,29 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "fund_fairburn_pool" + ], + "properties": { + "fund_fairburn_pool": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false } ] }, From 74c2b7e5060055e40efd10e682fe5a154b0ad27f Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Thu, 6 Oct 2022 13:13:24 -0700 Subject: [PATCH 72/82] Fix main issue, update to v0.15 across all packages --- packages/sg-std/Cargo.toml | 12 +++++------- packages/sg-std/src/msg.rs | 13 ++++--------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 88f05ce..adcdff4 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-std" -version = "0.14.0" +version = "0.15.0" edition = "2021" authors = ["Jorge Hernandez "] @@ -19,12 +19,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.0.0" } -cw-utils = "0.13.4" -cw721 = "0.13.2" +cosmwasm-std = { version = "1.1.4" } +cw-utils = "0.15.0" +cw721 = "0.15.0" schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = "1.0.30" - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.4" } diff --git a/packages/sg-std/src/msg.rs b/packages/sg-std/src/msg.rs index 90cc5bc..4b75f62 100644 --- a/packages/sg-std/src/msg.rs +++ b/packages/sg-std/src/msg.rs @@ -1,14 +1,11 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use crate::route::StargazeRoute; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, CosmosMsg, CustomMsg}; use cw721::CustomMsg as Cw721CustomMsg; static MSG_DATA_VERSION: &str = "1.0.0"; /// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub struct StargazeMsgWrapper { pub route: StargazeRoute, pub msg_data: StargazeMsg, @@ -24,8 +21,7 @@ impl From for CosmosMsg { impl CustomMsg for StargazeMsgWrapper {} impl Cw721CustomMsg for StargazeMsgWrapper {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum StargazeMsg { ClaimFor { address: String, @@ -39,8 +35,7 @@ pub enum StargazeMsg { }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ClaimAction { #[serde(rename = "mint_nft")] MintNFT, From df7a709af97455e63c0ebc46d76fc5cc64902670 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Thu, 6 Oct 2022 14:38:34 -0700 Subject: [PATCH 73/82] Everything builds --- packages/sg-multi-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 08fbf5d..5cb3614 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -10,8 +10,8 @@ homepage = "https://stargaze.zone" [dependencies] anyhow = "1" -cw-multi-test = "0.13.4" -cosmwasm-std = { version = "1.0.0" } +cw-multi-test = "0.15.0" +cosmwasm-std = { version = "1.1.4" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } sg-std = { path = "../sg-std" } From a9f05da7ad2cfee052f369d4abb7c1ecfb498c42 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Tue, 18 Oct 2022 06:44:20 +0100 Subject: [PATCH 74/82] use workspace package and dependencies --- packages/sg-multi-test/Cargo.toml | 26 +++++++++++++------------- packages/sg-std/Cargo.toml | 30 ++++++++++++++---------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 5cb3614..9fc215e 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "sg-multi-test" -version = "0.15.1" -edition = "2021" -authors = ["Jorge Hernandez "] +name = "sg-multi-test" +authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" -license = "Apache-2.0" -repository = "https://github.com/public-awesome/launchpad" -homepage = "https://stargaze.zone" +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +license = { workspace = true } [dependencies] -anyhow = "1" -cw-multi-test = "0.15.0" -cosmwasm-std = { version = "1.1.4" } -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } -sg-std = { path = "../sg-std" } +anyhow = "1" +cosmwasm-std = { workspace = true } +cw-multi-test = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +sg-std = { path = "../sg-std" } diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index adcdff4..3561fe6 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -1,17 +1,15 @@ [package] -name = "sg-std" -version = "0.15.0" -edition = "2021" - -authors = ["Jorge Hernandez "] +name = "sg-std" +authors = ["Jorge Hernandez "] description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze" -license = "Apache-2.0" -repository = "https://github.com/public-awesome/launchpad" -homepage = "https://stargaze.zone" +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +license = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] @@ -19,10 +17,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { version = "1.1.4" } -cw-utils = "0.15.0" -cw721 = "0.15.0" -schemars = "0.8.8" -serde = { version = "1.0.133", default-features = false, features = ["derive"] } -thiserror = "1.0.30" -cosmwasm-schema = { version = "1.1.4" } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw721 = { workspace = true } +cw-utils = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +thiserror = { workspace = true } From 683894c90b37406367321475efbf0f57efabe97e Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 22 Oct 2022 18:02:06 -0400 Subject: [PATCH 75/82] Migrate to using cw-serde --- packages/sg-std/src/query.rs | 6 ++---- packages/sg-std/src/route.rs | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/sg-std/src/query.rs b/packages/sg-std/src/query.rs index b67fd93..872a50e 100644 --- a/packages/sg-std/src/query.rs +++ b/packages/sg-std/src/query.rs @@ -1,10 +1,8 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::CustomQuery; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum StargazeQuery {} impl CustomQuery for StargazeQuery {} diff --git a/packages/sg-std/src/route.rs b/packages/sg-std/src/route.rs index 3f7a9b1..c2d249e 100644 --- a/packages/sg-std/src/route.rs +++ b/packages/sg-std/src/route.rs @@ -1,10 +1,7 @@ -use schemars::JsonSchema; - -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; /// StargazeRoute is enum type to represent stargaze query route path -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum StargazeRoute { Alloc, Claim, From 2e583fa6ac2cddc5a7819c4ae0ced529db2b1d20 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Sat, 22 Oct 2022 19:49:51 -0400 Subject: [PATCH 76/82] Publish crates --- packages/sg-multi-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 9fc215e..d8fde7d 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -14,4 +14,4 @@ cosmwasm-std = { workspace = true } cw-multi-test = { workspace = true } schemars = { workspace = true } serde = { workspace = true } -sg-std = { path = "../sg-std" } +sg-std = { workspace = true } From 0203aadb6f4891f3cf20955e1ccddcdb3a573545 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 25 Oct 2022 20:03:51 -0400 Subject: [PATCH 77/82] Upgraded to latest cw-nfts --- packages/sg-std/src/msg.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/sg-std/src/msg.rs b/packages/sg-std/src/msg.rs index 4b75f62..9705e7c 100644 --- a/packages/sg-std/src/msg.rs +++ b/packages/sg-std/src/msg.rs @@ -1,7 +1,6 @@ use crate::route::StargazeRoute; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, CosmosMsg, CustomMsg}; -use cw721::CustomMsg as Cw721CustomMsg; static MSG_DATA_VERSION: &str = "1.0.0"; /// StargazeMsg is an override of CosmosMsg::Custom to add support for Stargaze's custom message types @@ -19,7 +18,6 @@ impl From for CosmosMsg { } impl CustomMsg for StargazeMsgWrapper {} -impl Cw721CustomMsg for StargazeMsgWrapper {} #[cw_serde] pub enum StargazeMsg { From ac469c0bdf0f95d00ac2a63c9a17a7d0981069b3 Mon Sep 17 00:00:00 2001 From: Jorge Hernandez <3452489+jhernandezb@users.noreply.github.com> Date: Tue, 3 Jan 2023 20:12:02 -0600 Subject: [PATCH 78/82] Update README.md (#490) --- packages/sg-std/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sg-std/README.md b/packages/sg-std/README.md index d76eec5..26996b5 100644 --- a/packages/sg-std/README.md +++ b/packages/sg-std/README.md @@ -7,4 +7,5 @@ Common library for Stargaze smart contracts. `ClaimFor{address, action}` - Claim airdrop for a given action. `FundCommunityPool{amount}` - Fund the Stargaze Community Pool for a specified amount. + `FundFairburnPool{amount}` - Fund the Fairburn Pool for a specified amount. From 8b2dd224eb7a49e3680bf6bac952c3af0be53815 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 8 Aug 2023 17:02:06 -0400 Subject: [PATCH 79/82] Update manifest --- Cargo.lock | 71 ++++++------------------------- Cargo.toml | 6 +-- packages/sg-multi-test/Cargo.toml | 2 +- packages/sg-std/Cargo.toml | 2 +- 4 files changed, 19 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67fdea2..0641bb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -479,8 +479,8 @@ checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" dependencies = [ "anyhow", "cosmwasm-std", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", + "cw-storage-plus", + "cw-utils", "derivative", "itertools", "k256", @@ -490,17 +490,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-storage-plus" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", -] - [[package]] name = "cw-storage-plus" version = "1.1.0" @@ -512,21 +501,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw-utils" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6a84c6c1c0acc3616398eba50783934bd6c964bad6974241eaee3460c8f5b26" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw2 0.16.0", - "schemars", - "semver", - "serde", - "thiserror", -] - [[package]] name = "cw-utils" version = "1.0.1" @@ -535,26 +509,13 @@ checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2 1.1.0", + "cw2", "schemars", "semver", "serde", "thiserror", ] -[[package]] -name = "cw2" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91398113b806f4d2a8d5f8d05684704a20ffd5968bf87e3473e1973710b884ad" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 0.16.0", - "schemars", - "serde", -] - [[package]] name = "cw2" version = "1.1.0" @@ -563,7 +524,7 @@ checksum = "29ac2dc7a55ad64173ca1e0a46697c31b7a5c51342f55a1e84a724da4eb99908" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus", "schemars", "serde", "thiserror", @@ -571,13 +532,13 @@ dependencies = [ [[package]] name = "cw721" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a1ea6e6277bdd6dfc043a9b1380697fe29d6e24b072597439523658d21d791" +checksum = "e3c4d286625ccadc957fe480dd3bdc54ada19e0e6b5b9325379db3130569e914" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils 0.16.0", + "cw-utils", "schemars", "serde", ] @@ -643,7 +604,7 @@ dependencies = [ "cosm-orc", "cosm-tome", "cosmwasm-std", - "cw-utils 1.0.1", + "cw-utils", "env_logger", "itertools", "once_cell", @@ -1877,9 +1838,7 @@ dependencies = [ [[package]] name = "sg-multi-test" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255283d8f69fcea7f6a98e82dcc2032f52fe28e02b3ecfeb57feea963818a3dc" +version = "2.3.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -1891,13 +1850,11 @@ dependencies = [ [[package]] name = "sg-std" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e507149fe22e0dd1b968553efd2d5ecfd5e3b467a1eaf98bac8bd811ec2e7a0b" +version = "2.3.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils 0.16.0", + "cw-utils", "cw721", "schemars", "serde", @@ -2002,9 +1959,9 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cw-multi-test", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.1.0", + "cw-storage-plus", + "cw-utils", + "cw2", "schemars", "serde", "sg-multi-test", diff --git a/Cargo.toml b/Cargo.toml index 99eff8d..92d2ee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["contracts/fair-burn", "test/*"] +members = ["packages/*", "contracts/fair-burn", "test/*"] resolver = "2" [workspace.package] @@ -26,8 +26,8 @@ semver = "1.0.16" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = "1.0.31" anyhow = "1.0.41" -sg-std = { version = "2.3.0" } -sg-multi-test = { version = "2.3.0" } +sg-std = { version = "2.3.0", path = "packages/sg-std" } +sg-multi-test = { version = "2.3.0", path = "packages/sg-multi-test" } # dev-dependencies cw-multi-test = "0.16.5" diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index d8fde7d..793c756 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -2,7 +2,7 @@ name = "sg-multi-test" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" -version = { workspace = true } +version = "2.3.0" edition = { workspace = true } homepage = { workspace = true } repository = { workspace = true } diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 3561fe6..7231a76 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -2,7 +2,7 @@ name = "sg-std" authors = ["Jorge Hernandez "] description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze" -version = { workspace = true } +version = "2.3.0" edition = { workspace = true } homepage = { workspace = true } repository = { workspace = true } From 61299d1c06ca1ab5891d12fd7bacc9623ddb66a8 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 8 Aug 2023 17:07:44 -0400 Subject: [PATCH 80/82] Add publish script --- justfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/justfile b/justfile index 75d67dc..156acfc 100644 --- a/justfile +++ b/justfile @@ -46,3 +46,7 @@ e2e-test-arm: deploy-local-arm # e2e-test-full: dl-artifacts optimize e2e-test # e2e-test-full-arm: dl-artifacts optimize-arm e2e-test-arm + +publish: + cd packages/sg-std && cargo publish && cd ../.. + cd packages/sg-multi-test && cargo publish && cd ../.. \ No newline at end of file From 355958f2942ff89244b3e7fcb3d9cc1a8056bd30 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 8 Aug 2023 17:14:22 -0400 Subject: [PATCH 81/82] Update versions --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- packages/sg-multi-test/Cargo.toml | 2 +- packages/sg-std/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0641bb7..0ffd4ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1838,7 +1838,7 @@ dependencies = [ [[package]] name = "sg-multi-test" -version = "2.3.0" +version = "3.1.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "sg-std" -version = "2.3.0" +version = "3.1.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index 92d2ee1..4cffeac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ semver = "1.0.16" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = "1.0.31" anyhow = "1.0.41" -sg-std = { version = "2.3.0", path = "packages/sg-std" } -sg-multi-test = { version = "2.3.0", path = "packages/sg-multi-test" } +sg-std = { version = "3.1.0", path = "packages/sg-std" } +sg-multi-test = { version = "3.1.0", path = "packages/sg-multi-test" } # dev-dependencies cw-multi-test = "0.16.5" diff --git a/packages/sg-multi-test/Cargo.toml b/packages/sg-multi-test/Cargo.toml index 793c756..e940390 100644 --- a/packages/sg-multi-test/Cargo.toml +++ b/packages/sg-multi-test/Cargo.toml @@ -2,7 +2,7 @@ name = "sg-multi-test" authors = ["Jorge Hernandez "] description = "Integration test helpers for Stargaze custom contracts" -version = "2.3.0" +version = "3.1.0" edition = { workspace = true } homepage = { workspace = true } repository = { workspace = true } diff --git a/packages/sg-std/Cargo.toml b/packages/sg-std/Cargo.toml index 7231a76..abfb4c7 100644 --- a/packages/sg-std/Cargo.toml +++ b/packages/sg-std/Cargo.toml @@ -2,7 +2,7 @@ name = "sg-std" authors = ["Jorge Hernandez "] description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze" -version = "2.3.0" +version = "3.1.0" edition = { workspace = true } homepage = { workspace = true } repository = { workspace = true } From 642dc651980bbf8b7ce964db3aebbb9cb39b1d41 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Tue, 8 Aug 2023 17:43:27 -0400 Subject: [PATCH 82/82] Update README --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7edd5a9..c1ee8d3 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -# Stargaze Core Contracts +# Stargaze Core Libraries + +This repository contains the core contracts and libraries that are shared among all Stargaze protocols. + +| Package | Description | +|-------------------------------------------------------------|--------------------------------------------------------------------------------------------------| +| [Stargaze Fair Burn](./contracts//fair-burn/README.md) | Contract for fees and Developer Royalties. | +| [Stargaze Standard Library](./packages/sg-std/README.md) | Common Stargaze libraries for interfacing with CosmWasm smart contracts. |