Skip to content

Commit

Permalink
Merge pull request #27 from burnt-labs/feat/treasury-update
Browse files Browse the repository at this point in the history
update treasury for single allowance and multi-any
  • Loading branch information
ash-burnt authored Aug 12, 2024
2 parents 92f4fb3 + 32b2ac6 commit 55eb973
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 200 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
**/schema
.vscode
Cargo.lock
/artifacts
# Cargo+Git helper file
(https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/s$
.cargo-ok
Expand Down
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@ rsa = { version = "0.9.2" }
getrandom = { version = "0.2.10", features = ["custom"] }
p256 = {version = "0.13.2", features = ["ecdsa-core", "arithmetic", "serde"]}
prost = {version = "0.11.2", default-features = false, features = ["prost-derive"]}
cosmos-sdk-proto = {git = "https://github.com/burnt-labs/cosmos-rust.git", rev = "9108ae0517bd9fd543c0662e06598032a642e426", default-features = false, features = ["cosmwasm", "xion"]}
cosmos-sdk-proto = {git = "https://github.com/burnt-labs/cosmos-rust.git", rev = "75e72f446629f98330e209e2f6268250d325cccb", default-features = false, features = ["std", "cosmwasm", "xion", "serde"]}
osmosis-std-derive = "0.13.2"
prost-types = "0.12.6"
pbjson-types = "0.6.0"
1 change: 0 additions & 1 deletion contracts/account/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate core;

mod auth;
#[cfg(not(feature = "library"))]
pub mod contract;
pub mod error;
pub mod execute;
Expand Down
10 changes: 5 additions & 5 deletions contracts/treasury/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]

[features]
# enable feature if you want to disable entry points
library = []

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
Expand All @@ -16,8 +20,4 @@ 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 }
cosmos-sdk-proto = { workspace = true }
17 changes: 14 additions & 3 deletions contracts/treasury/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::ContractResult;
use crate::execute::{revoke_allowance, update_fee_config};
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::{execute, query, CONTRACT_NAME, CONTRACT_VERSION};
use cosmwasm_std::{
Expand All @@ -13,7 +14,14 @@ pub fn instantiate(
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)
execute::init(
deps,
info,
msg.admin,
msg.type_urls,
msg.grant_configs,
msg.fee_config,
)
}

#[entry_point]
Expand All @@ -27,8 +35,7 @@ pub fn execute(
ExecuteMsg::DeployFeeGrant {
authz_granter,
authz_grantee,
msg_type_url,
} => execute::deploy_fee_grant(deps, env, authz_granter, authz_grantee, msg_type_url),
} => execute::deploy_fee_grant(deps, env, authz_granter, authz_grantee),
ExecuteMsg::UpdateAdmin { new_admin } => execute::update_admin(deps, info, new_admin),
ExecuteMsg::UpdateGrantConfig {
msg_type_url,
Expand All @@ -37,6 +44,8 @@ pub fn execute(
ExecuteMsg::RemoveGrantConfig { msg_type_url } => {
execute::remove_grant_config(deps, info, msg_type_url)
}
ExecuteMsg::UpdateFeeConfig { fee_config } => update_fee_config(deps, info, fee_config),
ExecuteMsg::RevokeAllowance { grantee } => revoke_allowance(deps, env, info, grantee),
}
}

Expand All @@ -49,5 +58,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::GrantConfigTypeUrls {} => {
to_json_binary(&query::grant_config_type_urls(deps.storage)?)
}
QueryMsg::FeeConfig {} => to_json_binary(&query::fee_config(deps.storage)?),
QueryMsg::Admin {} => to_json_binary(&query::admin(deps.storage)?),
}
}
7 changes: 5 additions & 2 deletions contracts/treasury/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ pub enum ContractError {
#[error(transparent)]
Encode(#[from] cosmos_sdk_proto::prost::EncodeError),

#[error("authz grant not found")]
AuthzGrantNotFound,
#[error(transparent)]
Decode(#[from] cosmos_sdk_proto::prost::DecodeError),

#[error("authz grant not found, msg_type: {msg_type_url}")]
AuthzGrantNotFound { msg_type_url: String },

#[error("authz grant has no authorization")]
AuthzGrantNoAuthorization,
Expand Down
Loading

0 comments on commit 55eb973

Please sign in to comment.