-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63a0f1a
commit 5617264
Showing
8 changed files
with
174 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
[package] | ||
name = "burnauction" | ||
name = "burn-auction" | ||
version = "0.1.0" | ||
authors = { workspace = true } | ||
#edition = { workspace = true } | ||
edition = { workspace = true } | ||
repository = { workspace = true } | ||
license = { workspace = true } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
# use library feature to disable all instantiate/execute/query exports | ||
library = [] | ||
|
||
[dependencies] | ||
cosmwasm-std = "1.5" | ||
# itertools.workspace = true | ||
# common = { path = "../common" } | ||
cosmwasm-schema.workspace = true | ||
cosmwasm-std.workspace = true | ||
cw-storage-plus.workspace = true | ||
cw2.workspace = true | ||
|
||
schemars.workspace=true | ||
serde.workspace=true | ||
thiserror.workspace=true | ||
|
||
[dev-dependencies] | ||
# anyhow.workspace = true | ||
# [dev-dependencies] | ||
# cw-multi-test = "0.18.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use cosmwasm_schema::write_api; | ||
|
||
use {{crate_name}}::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
migrate: MigrateMsg, | ||
execute: ExecuteMsg, | ||
query: QueryMsg, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult}; | ||
use cw2::set_contract_version; | ||
|
||
use crate::error::ContractError; | ||
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; | ||
|
||
// version info for migration info | ||
const CONTRACT_NAME: &str = "crates.io:{{project-name}}"; | ||
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
/// Handling contract instantiation | ||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_env: Env, | ||
info: MessageInfo, | ||
_msg: InstantiateMsg, | ||
) -> Result<Response, ContractError> { | ||
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
|
||
// With `Response` type, it is possible to dispatch message to invoke external logic. | ||
// See: https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#dispatching-messages | ||
Ok(Response::new() | ||
.add_attribute("method", "instantiate") | ||
.add_attribute("owner", info.sender)) | ||
} | ||
|
||
/// Handling contract migration | ||
/// To make a contract migratable, you need | ||
/// - this entry_point implemented | ||
/// - only contract admin can migrate, so admin has to be set at contract initiation time | ||
/// Handling contract execution | ||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn migrate(_deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> { | ||
match msg { | ||
// Find matched incoming message variant and execute them with your custom logic. | ||
// | ||
// With `Response` type, it is possible to dispatch message to invoke external logic. | ||
// See: https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#dispatching-messages | ||
} | ||
} | ||
|
||
/// Handling contract execution | ||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn execute( | ||
_deps: DepsMut, | ||
_env: Env, | ||
_info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> Result<Response, ContractError> { | ||
match msg { | ||
// Find matched incoming message variant and execute them with your custom logic. | ||
// | ||
// With `Response` type, it is possible to dispatch message to invoke external logic. | ||
// See: https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#dispatching-messages | ||
} | ||
} | ||
|
||
/// Handling contract query | ||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> { | ||
match msg { | ||
// Find matched incoming message variant and query them your custom logic | ||
// and then construct your query response with the type usually defined | ||
// `msg.rs` alongside with the query message itself. | ||
// | ||
// use `cosmwasm_std::to_binary` to serialize query response to json binary. | ||
} | ||
} | ||
|
||
/// Handling submessage reply. | ||
/// For more info on submessage and reply, see https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#submessages | ||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn reply(_deps: DepsMut, _env: Env, _msg: Reply) -> Result<Response, ContractError> { | ||
// With `Response` type, it is still possible to dispatch message to invoke external logic. | ||
// See: https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#dispatching-messages | ||
|
||
todo!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use cosmwasm_std::StdError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum ContractError { | ||
#[error("{0}")] | ||
Std(#[from] StdError), | ||
|
||
#[error("Unauthorized")] | ||
Unauthorized {}, | ||
|
||
#[error("Custom Error val: {val:?}")] | ||
CustomError { val: String }, | ||
// Add any other custom errors you like here. | ||
// Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
use cosmwasm_std::{ | ||
entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, | ||
}; | ||
pub mod contract; | ||
mod error; | ||
pub mod msg; | ||
pub mod state; | ||
|
||
#[entry_point] | ||
pub fn instantiate( | ||
_deps: DepsMut, | ||
_env: Env, | ||
_info: MessageInfo, | ||
_msg: Empty, | ||
) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
} | ||
pub use crate::error::ContractError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use cosmwasm_schema::{cw_serde, QueryResponses}; | ||
|
||
/// Message type for `instantiate` entry_point | ||
#[cw_serde] | ||
pub struct InstantiateMsg {} | ||
|
||
/// Message type for `execute` entry_point | ||
#[cw_serde] | ||
pub enum ExecuteMsg {} | ||
|
||
/// Message type for `migrate` entry_point | ||
#[cw_serde] | ||
pub enum MigrateMsg {} | ||
|
||
/// Message type for `query` entry_point | ||
#[cw_serde] | ||
#[derive(QueryResponses)] | ||
pub enum QueryMsg { | ||
// This example query variant indicates that any client can query the contract | ||
// using `YourQuery` and it will return `YourQueryResponse` | ||
// This `returns` information will be included in contract's schema | ||
// which is used for client code generation. | ||
// | ||
// #[returns(YourQueryResponse)] | ||
// YourQuery {}, | ||
} | ||
|
||
// We define a custom struct for each query response | ||
// #[cw_serde] | ||
// pub struct YourQueryResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// use `cw_storage_plus` to create ORM-like interface to storage | ||
// see: https://crates.io/crates/cw-storage-plus |