diff --git a/contracts/loyalty/README.md b/contracts/loyalty/README.md deleted file mode 100644 index ab48ebb..0000000 --- a/contracts/loyalty/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Stargaze Core Contracts - -## Stargaze Loyalty Program (SLP) - -The Stargaze Loyalty Program is a program that rewards users for staking STARS in the form of reduced fees. The program is implemented as a set of NFT smart contracts. Users are assigned to a tier based on the amount of STARS they have staked. The tier determines the amount of fees they pay. - -A user mints a Stargaze Loyalty NFT (LNFT) to join the Stargaze Loyalty Program. It contains metadata that includes the amount of STARS they have staked that is populated via an oracle. - -A set of privileged operators as determined by governance are allowed to update the metadata of the LNFT. This is done via an oracle that reads the amount of STARS staked by the user and updates the LNFT metadata. - -## Loyalty Collection (sg721-loyalty) - -The Loyalty Collection is a contract that stores all the LNFTs, and allows operators to update the metadata of the LNFTs. - -```rs -pub struct LoyaltyMetadata { - pub staked_amount: [Coin], - pub data: Option, - pub updated_at: u64, -} -``` - -An optional `data` field makes the metadata future-proof and open for extension. - -### Messages - -```rs -pub enum ExecuteMsg { - UpdateMetadata { - address: String, - staked_amount: [Coin], - data: Option, - }, -} -``` - -```rs -pub enum SudoMsg { - AddOperator { operator: String }, - RemoveOperator { operator: String }, -} -``` - -### Queries - -```rs -pub enum QueryMsg { - Metadata { address: String }, - Operators {}, - TotalStakedAmount { owner: String }, -} -``` - -Note that a user may have multiple wallets that stake. For example they may have a cold wallet that does the majority of staking, and a hot wallet for use for minting on Stargaze. To determine the tier of a user, we need to sum up the amount of STARS staked across all wallets. To associate wallets, a user can transfer their LNFT to their hot wallet. The `TotalStakedAmount` query returns the total amount of STARS staked by a user across all wallets. - -## Loyalty Minter (loyalty-minter) - -The Loyalty Minter is a contract that allows users to mint LNFTs. - -```rs -pub struct MintMsg { - pub token_id: String, // auto-incrementing ID - pub owner: String, - pub token_uri: Option, // ignored - pub extension: T, // `LoyaltyMetadata` -} -``` diff --git a/contracts/loyalty/collection/.cargo/config b/contracts/loyalty/collection/.cargo/config deleted file mode 100644 index af5698e..0000000 --- a/contracts/loyalty/collection/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[alias] -wasm = "build --release --lib --target wasm32-unknown-unknown" -unit-test = "test --lib" -schema = "run --bin schema" diff --git a/contracts/loyalty/collection/Cargo.toml b/contracts/loyalty/collection/Cargo.toml deleted file mode 100644 index 9899933..0000000 --- a/contracts/loyalty/collection/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "loyalty-collection" -authors = ["Shane Vitarana "] -description = "Stargaze Loyalty Collection" -version = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -repository = { workspace = true } -license = { workspace = true } - -exclude = [ - # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. - "contract.wasm", - "hash.txt", -] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[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 } -cosmwasm-storage = { workspace = true } -cw-storage-plus = { workspace = true } -cw2 = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } - -[dev-dependencies] -cw-multi-test = { workspace = true } diff --git a/contracts/loyalty/collection/src/bin/schema.rs b/contracts/loyalty/collection/src/bin/schema.rs deleted file mode 100644 index 0c399f3..0000000 --- a/contracts/loyalty/collection/src/bin/schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use collection::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/loyalty/collection/src/contract.rs b/contracts/loyalty/collection/src/contract.rs deleted file mode 100644 index aed1074..0000000 --- a/contracts/loyalty/collection/src/contract.rs +++ /dev/null @@ -1,41 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; -// use cw2::set_contract_version; - -use crate::error::ContractError; -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -/* -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:collection"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -*/ - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> Result { - unimplemented!() -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: ExecuteMsg, -) -> Result { - unimplemented!() -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult { - unimplemented!() -} - -#[cfg(test)] -mod tests {} diff --git a/contracts/loyalty/collection/src/error.rs b/contracts/loyalty/collection/src/error.rs deleted file mode 100644 index 4a69d8f..0000000 --- a/contracts/loyalty/collection/src/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - // Add any other custom errors you like here. - // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. -} diff --git a/contracts/loyalty/collection/src/helpers.rs b/contracts/loyalty/collection/src/helpers.rs deleted file mode 100644 index a39b155..0000000 --- a/contracts/loyalty/collection/src/helpers.rs +++ /dev/null @@ -1,27 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; - -use crate::msg::ExecuteMsg; - -/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers -/// for working with this. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct CwTemplateContract(pub Addr); - -impl CwTemplateContract { - pub fn addr(&self) -> Addr { - self.0.clone() - } - - pub fn call>(&self, msg: T) -> StdResult { - let msg = to_binary(&msg.into())?; - Ok(WasmMsg::Execute { - contract_addr: self.addr().into(), - msg, - funds: vec![], - } - .into()) - } -} diff --git a/contracts/loyalty/collection/src/lib.rs b/contracts/loyalty/collection/src/lib.rs deleted file mode 100644 index 233dbf5..0000000 --- a/contracts/loyalty/collection/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod contract; -mod error; -pub mod helpers; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/loyalty/collection/src/msg.rs b/contracts/loyalty/collection/src/msg.rs deleted file mode 100644 index 3b6b9b2..0000000 --- a/contracts/loyalty/collection/src/msg.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::{cw_serde, QueryResponses}; - -#[cw_serde] -pub struct InstantiateMsg {} - -#[cw_serde] -pub enum ExecuteMsg {} - -#[cw_serde] -#[derive(QueryResponses)] -pub enum QueryMsg {} diff --git a/contracts/loyalty/collection/src/state.rs b/contracts/loyalty/collection/src/state.rs deleted file mode 100644 index 8b13789..0000000 --- a/contracts/loyalty/collection/src/state.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/contracts/loyalty/minter/.cargo/config b/contracts/loyalty/minter/.cargo/config deleted file mode 100644 index af5698e..0000000 --- a/contracts/loyalty/minter/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[alias] -wasm = "build --release --lib --target wasm32-unknown-unknown" -unit-test = "test --lib" -schema = "run --bin schema" diff --git a/contracts/loyalty/minter/Cargo.toml b/contracts/loyalty/minter/Cargo.toml deleted file mode 100644 index 3618ee8..0000000 --- a/contracts/loyalty/minter/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "loyalty-minter" -authors = ["Shane Vitarana "] -description = "Stargaze Loyalty Minter" -version = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -repository = { workspace = true } -license = { workspace = true } - -exclude = [ - # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. - "contract.wasm", - "hash.txt", -] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[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 } -cosmwasm-storage = { workspace = true } -cw-storage-plus = { workspace = true } -cw2 = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } - -[dev-dependencies] -cw-multi-test = { workspace = true } diff --git a/contracts/loyalty/minter/src/bin/schema.rs b/contracts/loyalty/minter/src/bin/schema.rs deleted file mode 100644 index 82201cf..0000000 --- a/contracts/loyalty/minter/src/bin/schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use minter::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/loyalty/minter/src/contract.rs b/contracts/loyalty/minter/src/contract.rs deleted file mode 100644 index 69a05b3..0000000 --- a/contracts/loyalty/minter/src/contract.rs +++ /dev/null @@ -1,41 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; -// use cw2::set_contract_version; - -use crate::error::ContractError; -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -/* -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:minter"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -*/ - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> Result { - unimplemented!() -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: ExecuteMsg, -) -> Result { - unimplemented!() -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult { - unimplemented!() -} - -#[cfg(test)] -mod tests {} diff --git a/contracts/loyalty/minter/src/error.rs b/contracts/loyalty/minter/src/error.rs deleted file mode 100644 index 4a69d8f..0000000 --- a/contracts/loyalty/minter/src/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - // Add any other custom errors you like here. - // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. -} diff --git a/contracts/loyalty/minter/src/helpers.rs b/contracts/loyalty/minter/src/helpers.rs deleted file mode 100644 index a39b155..0000000 --- a/contracts/loyalty/minter/src/helpers.rs +++ /dev/null @@ -1,27 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; - -use crate::msg::ExecuteMsg; - -/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers -/// for working with this. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct CwTemplateContract(pub Addr); - -impl CwTemplateContract { - pub fn addr(&self) -> Addr { - self.0.clone() - } - - pub fn call>(&self, msg: T) -> StdResult { - let msg = to_binary(&msg.into())?; - Ok(WasmMsg::Execute { - contract_addr: self.addr().into(), - msg, - funds: vec![], - } - .into()) - } -} diff --git a/contracts/loyalty/minter/src/lib.rs b/contracts/loyalty/minter/src/lib.rs deleted file mode 100644 index 233dbf5..0000000 --- a/contracts/loyalty/minter/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod contract; -mod error; -pub mod helpers; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/loyalty/minter/src/msg.rs b/contracts/loyalty/minter/src/msg.rs deleted file mode 100644 index 3b6b9b2..0000000 --- a/contracts/loyalty/minter/src/msg.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::{cw_serde, QueryResponses}; - -#[cw_serde] -pub struct InstantiateMsg {} - -#[cw_serde] -pub enum ExecuteMsg {} - -#[cw_serde] -#[derive(QueryResponses)] -pub enum QueryMsg {} diff --git a/contracts/loyalty/minter/src/state.rs b/contracts/loyalty/minter/src/state.rs deleted file mode 100644 index 8b13789..0000000 --- a/contracts/loyalty/minter/src/state.rs +++ /dev/null @@ -1 +0,0 @@ -