-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from burnt-labs/feat/treasury
Treasury Contract
- Loading branch information
Showing
28 changed files
with
637 additions
and
21 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
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,23 @@ | ||
[package] | ||
name = "treasury" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
cosmwasm-schema = { workspace = true } | ||
cosmwasm-std = { workspace = true } | ||
cw2 = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
thiserror = { workspace = true } | ||
serde = { workspace = true } | ||
serde_json = { workspace = true } | ||
schemars = { workspace = true } | ||
cosmos-sdk-proto = { workspace = true } | ||
prost = { workspace = true } | ||
osmosis-std-derive = { workspace = true } | ||
prost-types = { workspace = true } | ||
pbjson-types = { workspace = true } |
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,53 @@ | ||
use crate::error::ContractResult; | ||
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; | ||
use crate::{execute, query, CONTRACT_NAME, CONTRACT_VERSION}; | ||
use cosmwasm_std::{ | ||
entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, | ||
}; | ||
|
||
#[entry_point] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_env: Env, | ||
info: MessageInfo, | ||
msg: InstantiateMsg, | ||
) -> ContractResult<Response> { | ||
cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
execute::init(deps, info, msg.admin, msg.type_urls, msg.grant_configs) | ||
} | ||
|
||
#[entry_point] | ||
pub fn execute( | ||
deps: DepsMut, | ||
env: Env, | ||
info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> ContractResult<Response> { | ||
match msg { | ||
ExecuteMsg::DeployFeeGrant { | ||
authz_granter, | ||
authz_grantee, | ||
msg_type_url, | ||
} => execute::deploy_fee_grant(deps, env, authz_granter, authz_grantee, msg_type_url), | ||
ExecuteMsg::UpdateAdmin { new_admin } => execute::update_admin(deps, info, new_admin), | ||
ExecuteMsg::UpdateGrantConfig { | ||
msg_type_url, | ||
grant_config, | ||
} => execute::update_grant_config(deps, info, msg_type_url, grant_config), | ||
ExecuteMsg::RemoveGrantConfig { msg_type_url } => { | ||
execute::remove_grant_config(deps, info, msg_type_url) | ||
} | ||
} | ||
} | ||
|
||
#[entry_point] | ||
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> { | ||
match msg { | ||
QueryMsg::GrantConfigByTypeUrl { msg_type_url } => to_binary( | ||
&query::grant_config_by_type_url(deps.storage, msg_type_url)?, | ||
), | ||
QueryMsg::GrantConfigTypeUrls {} => { | ||
to_binary(&query::grant_config_type_urls(deps.storage)?) | ||
} | ||
} | ||
} |
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,31 @@ | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum ContractError { | ||
#[error(transparent)] | ||
Std(#[from] cosmwasm_std::StdError), | ||
|
||
#[error(transparent)] | ||
Encode(#[from] cosmos_sdk_proto::prost::EncodeError), | ||
|
||
#[error("authz grant not found")] | ||
AuthzGrantNotFound, | ||
|
||
#[error("authz grant has no authorization")] | ||
AuthzGrantNoAuthorization, | ||
|
||
#[error("authz grant did not match config")] | ||
AuthzGrantMismatch, | ||
|
||
#[error("invalid allowance type: {msg_type_url}")] | ||
InvalidAllowanceType { msg_type_url: String }, | ||
|
||
#[error("allowance unset")] | ||
AllowanceUnset, | ||
|
||
#[error("config mismatch")] | ||
ConfigurationMismatch, | ||
|
||
#[error("unauthorized")] | ||
Unauthorized, | ||
} | ||
|
||
pub type ContractResult<T> = Result<T, ContractError>; |
Oops, something went wrong.