Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sg-std and sg-multi-test from Launchpad #15

Merged
merged 113 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
eaab9b3
rename package name
jhernandezb Feb 17, 2022
698e5f1
impl cw721 custom msg for wrapper
jhernandezb Feb 18, 2022
79ef6e5
Add fee denom to sg-std
shanev Feb 20, 2022
8147966
Move native denom constant into sg-std
shanev Feb 20, 2022
f2ff0be
Merge pull request #143 from public-awesome/shanev/native-denom
shanev Feb 20, 2022
9d8b0f8
wip
yubrew Feb 22, 2022
e7e3be9
start time on or after genesis mint
yubrew Feb 23, 2022
8039824
change default start time to 3/1/22 12:00ET
yubrew Feb 24, 2022
71f4da2
change genesis mint time for testnet
yubrew Feb 24, 2022
09538b2
Add fees to sg-std
shanev Feb 24, 2022
fabdd20
Reverted whitelist
shanev Feb 24, 2022
cda557f
Fix types
shanev Feb 24, 2022
b85dfd6
Rename function
shanev Feb 24, 2022
8a59110
Remove unneeded bank send message
JakeHartnell Feb 24, 2022
2282835
Merge pull request #21 from public-awesome/shanev/std-fee
shanev Feb 24, 2022
fb63dcd
Added back whitelist tests
shanev Feb 25, 2022
995fe91
Merge pull request #48 from public-awesome/shanev/remove-cp
shanev Feb 25, 2022
bada221
add send community pool, fix whitelist types
jhernandezb Feb 26, 2022
3cea071
add sg721 for custom message
jhernandezb Feb 26, 2022
a22a4e8
Make fees more general
shanev Feb 26, 2022
c1de9c4
Merge pull request #65 from public-awesome/shanev/55-mint-fee
shanev Feb 26, 2022
c7ba4b8
Check correct fee amounts
shanev Feb 27, 2022
e0c05a4
Merge pull request #71 from public-awesome/shanev/64-validate-creatio…
shanev Feb 27, 2022
e44f73b
more println for debugging
yubrew Feb 27, 2022
ac88bad
simplify error in happy path
yubrew Feb 27, 2022
14c61e1
happy_path works
yubrew Feb 27, 2022
b61ce36
clean up
yubrew Feb 27, 2022
d73db8b
change back to stricter must_pay
yubrew Feb 27, 2022
2975f5d
Updated cw721 deps
shanev Feb 28, 2022
bc244b4
Use cw721-base as a library
shanev Feb 28, 2022
0690594
Merge pull request #87 from public-awesome/shanev/85-query
shanev Feb 28, 2022
d0fb074
update genesis mint time
yubrew Mar 1, 2022
84e684f
Merge pull request #98 from public-awesome/yubrew/83-update-genesis-m…
shanev Mar 1, 2022
5439843
Update versions
shanev Mar 5, 2022
c88d891
Merge pull request #129 from public-awesome/shanev/release-6
shanev Mar 5, 2022
76cc3a9
Update versions
shanev Mar 5, 2022
ca5fcd5
Update genesis mint start time
shanev Mar 7, 2022
d4430af
Update versions and tests
shanev Mar 7, 2022
5627cea
Merge pull request #150 from public-awesome/shanev/update-genesis
shanev Mar 7, 2022
e06b72f
prepare 0.8.0 release
jhernandezb Mar 8, 2022
ec75072
Merge pull request #158 from public-awesome/jhernandezb/bump-versions
shanev Mar 8, 2022
a93c571
Removed unused Env
shanev Mar 26, 2022
fa4010a
Merge pull request #194 from public-awesome/shanev/remove-env
shanev Mar 26, 2022
ffa16bd
Update sg721 version
shanev Mar 26, 2022
8a3cef7
Moved multi to its own package
shanev Mar 25, 2022
c01a3fb
Add lib
shanev Mar 25, 2022
75fba74
Fix deps
shanev Mar 25, 2022
8420408
Re-org imports
shanev Mar 25, 2022
62f4cf7
Export just what is needed
shanev Mar 25, 2022
2a25b89
Updated deps
shanev Mar 25, 2022
9e1608f
Updated sg-std dep
shanev Mar 26, 2022
2a1d514
Upgraded CW
shanev Mar 26, 2022
e536b37
Upgrade cw721
shanev Mar 26, 2022
b388384
Updated sg-std version
shanev Mar 27, 2022
72af6e9
Use local paths instead of crates
shanev Mar 27, 2022
cab1f74
Merge pull request #192 from public-awesome/shanev/move-multi
shanev Mar 27, 2022
34c6304
Add wrapped type helpers
shanev Mar 27, 2022
ea9d5e8
Merge pull request #198 from public-awesome/shanev/add-wrapped-types
shanev Mar 27, 2022
7748df7
Update multitest version
shanev Mar 27, 2022
323092c
Merge pull request #199 from public-awesome/shanev/publish-multitest
shanev Mar 27, 2022
b8a9659
Split Fair Burn into two functions
shanev Apr 2, 2022
68b0bf6
Merge pull request #204 from public-awesome/shanev/moar-burn
shanev Apr 2, 2022
637e05e
Updated to use new Fair Burn messages
shanev Apr 2, 2022
cdc7b50
Update versions
shanev Apr 2, 2022
b28f530
Merge pull request #205 from public-awesome/shanev/updated-to-new-burn
shanev Apr 2, 2022
ad0abf1
Remove fees from sg-std
shanev Apr 9, 2022
33a15e2
Update versions
shanev Apr 9, 2022
4128849
Add README
shanev Apr 9, 2022
d473cd6
Updated versions
shanev Apr 21, 2022
72dbfd3
Use new Fair Burn
shanev Apr 21, 2022
42921ea
Update multitest version
shanev Apr 21, 2022
d0858dc
Merge pull request #237 from public-awesome/shanev/cw-update
shanev Apr 21, 2022
aad4ef2
Update sg-multi-test error
shanev Apr 25, 2022
fd9ba6d
add claim for message handling
jhernandezb Apr 26, 2022
f7c12f9
Merge pull request #245 from public-awesome/jhernandezb/fix-claim-hoo…
shanev Apr 26, 2022
3361fd8
Check if sale was finalized and update versions
shanev Apr 26, 2022
c944083
Merge pull request #240 from public-awesome/shanev/239-claim-hook
shanev Apr 27, 2022
d5a6a60
add fund fairburn pool msg (#286)
jhernandezb Jun 29, 2022
b315781
Merge pull request #328 from public-awesome/fix-tests
shanev Jun 30, 2022
51314bd
Merge pull request #208 from public-awesome/yubrew/132-implement-rand
shanev Jun 30, 2022
357e346
Add u64 trait extension
shanev Jul 15, 2022
319be68
Better naming in trait extension
shanev Jul 15, 2022
1c3d764
Upgraded cw-plus version
shanev Jul 19, 2022
58f43ad
Update sg1 version
shanev Jul 25, 2022
4e1d5dd
Merge pull request #336 from public-awesome/hook-max
shanev Jul 25, 2022
bf8230c
merge main, remove claim contract
jhernandezb Aug 10, 2022
98d8830
Merge pull request #7 from public-awesome/v2
shanev Aug 10, 2022
1af8d87
Merge pull request #340 from public-awesome/launchpad-v2
jhernandezb Aug 10, 2022
838067c
Update sg-std version
shanev Aug 22, 2022
fd1230d
Update sg-multi-test version
shanev Aug 22, 2022
bd93a56
Update repo
shanev Aug 27, 2022
b719bf1
Updated sg-std
shanev Aug 27, 2022
668cf10
Removed unused deps with udep
shanev Aug 27, 2022
6fd549e
Fixed repos
shanev Aug 27, 2022
d3ee8d2
cargos to local path
yubrew Sep 13, 2022
e982c7f
update schema
jhernandezb Sep 19, 2022
74c2b7e
Fix main issue, update to v0.15 across all packages
JakeHartnell Oct 6, 2022
df7a709
Everything builds
JakeHartnell Oct 6, 2022
f368cbc
Merge pull request #428 from JakeHartnell/JakeHartnell/fix-update-v0.15
shanev Oct 9, 2022
a9f05da
use workspace package and dependencies
larry0x Oct 18, 2022
215a054
Merge pull request #438 from larry0x/main
shanev Oct 22, 2022
683894c
Migrate to using cw-serde
shanev Oct 22, 2022
43e21f4
Merge pull request #440 from public-awesome/workspace-fix
shanev Oct 22, 2022
2e583fa
Publish crates
shanev Oct 22, 2022
0a6e1d3
Merge pull request #441 from public-awesome/publish-crates-020
shanev Oct 23, 2022
0203aad
Upgraded to latest cw-nfts
shanev Oct 26, 2022
afd0ff3
Merge pull request #452 from public-awesome/version-21
shanev Oct 26, 2022
ac469c0
Update README.md (#490)
jhernandezb Jan 4, 2023
71c837c
Merge remote-tracking branch 'src/main'
shanev Aug 8, 2023
8b2dd22
Update manifest
shanev Aug 8, 2023
61299d1
Add publish script
shanev Aug 8, 2023
355958f
Update versions
shanev Aug 8, 2023
642dc65
Update README
shanev Aug 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 14 additions & 57 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["contracts/fair-burn", "test/*"]
members = ["packages/*", "contracts/fair-burn", "test/*"]
resolver = "2"

[workspace.package]
Expand All @@ -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 = "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"
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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. |
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../..
17 changes: 17 additions & 0 deletions packages/sg-multi-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "sg-multi-test"
authors = ["Jorge Hernandez <[email protected]>"]
description = "Integration test helpers for Stargaze custom contracts"
version = "3.1.0"
edition = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }

[dependencies]
anyhow = "1"
cosmwasm-std = { workspace = true }
cw-multi-test = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
sg-std = { workspace = true }
3 changes: 3 additions & 0 deletions packages/sg-multi-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod multi;

pub use crate::multi::{mock_deps, StargazeApp, StargazeDeps, StargazeModule};
147 changes: 147 additions & 0 deletions packages/sg-multi-test/src/multi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage};
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 {}

pub type StargazeDeps = OwnedDeps<MockStorage, MockApi, MockQuerier, StargazeQuery>;

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<ExecC, QueryC>(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
sender: Addr,
msg: StargazeMsgWrapper,
) -> AnyResult<AppResponse>
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())
}
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: _,
} => Ok(AppResponse::default()),
}
}
fn sudo<ExecC, QueryC>(
&self,
_api: &dyn Api,
_storage: &mut dyn Storage,
_router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
_block: &BlockInfo,
_msg: Self::SudoT,
) -> AnyResult<AppResponse>
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<Binary> {
bail!("custom query not implemented {:?}", request)
}
}

pub type StargazeBasicApp =
App<BankKeeper, MockApi, MockStorage, StargazeModule, WasmKeeper<StargazeMsgWrapper, Empty>>;

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::<StargazeMsgWrapper, Empty>::new_custom()
.with_custom(StargazeModule {})
.build(|_, _, _| {}),
)
}
}

impl Default for StargazeApp {
fn default() -> Self {
Self::new()
}
}
4 changes: 4 additions & 0 deletions packages/sg-std/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
26 changes: 26 additions & 0 deletions packages/sg-std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "sg-std"
authors = ["Jorge Hernandez <[email protected]>"]
description = "Bindings for CosmWasm contracts to call into custom modules of Stargaze"
version = "3.1.0"
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"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw721 = { workspace = true }
cw-utils = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
Loading
Loading