Skip to content

Commit

Permalink
Remove bank send authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Jan 25, 2024
1 parent a83fac9 commit 81ac41c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Cargo.lock

state.json

typescript/node_modules
typescript/node_modules
cobertura.xml
Binary file modified artifacts/app.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e31e1674db09cc0a5d33f766c4d038223969fe299412325403b7dc1f1249a0f3 app-x86_64.wasm
f334310c60b8f4440d4d56ffaa73d1ee68ae70ed9354da486666180f2874ee27 app-x86_64.wasm
2 changes: 1 addition & 1 deletion artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4cb9315e570f5e0b884a19f2fb9823df53695e7cca9d5f9761c4ae78b6b095d2 app.wasm
4ec4d2bf2f978997cbf8bf02d11800cd07b6082bec5ca1d2962605f5ed7bda5d app.wasm
2 changes: 2 additions & 0 deletions contracts/savings-app/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ fn swap_msg(
Ok(trigger_swap_msg
.messages
.into_iter()
// filter out bank messages
.filter(|m| !matches!(m, CosmosMsg::Bank(_)))
.map(|m| wrap_authz(m, sender.clone(), env))
.collect())
}
Expand Down
29 changes: 13 additions & 16 deletions contracts/savings-app/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use cosmwasm_std::{CosmosMsg, Deps, Env, WasmMsg};
use osmosis_std::{
cosmwasm_to_proto_coins,
shim::Any,
types::{
cosmos::{authz::v1beta1::MsgExec, bank::v1beta1::MsgSend},
cosmwasm::wasm::v1::MsgExecuteContract,
},
types::{cosmos::authz::v1beta1::MsgExec, cosmwasm::wasm::v1::MsgExecuteContract},
};

use prost::Message;
Expand Down Expand Up @@ -40,18 +37,18 @@ pub fn wrap_authz(
not_supported => unimplemented!("{not_supported:?}"),
},
CosmosMsg::Stargate { type_url, value } => (type_url.clone(), value.into()),
CosmosMsg::Bank(bank_msg) => match bank_msg {
cosmwasm_std::BankMsg::Send { to_address, amount } => (
MsgSend::TYPE_URL.to_string(),
MsgSend {
from_address: sender.to_string(),
to_address,
amount: cosmwasm_to_proto_coins(amount),
}
.encode_to_vec(),
),
not_supported => unimplemented!("{not_supported:?}"),
},
// CosmosMsg::Bank(bank_msg) => match bank_msg {
// cosmwasm_std::BankMsg::Send { to_address, amount } => (
// MsgSend::TYPE_URL.to_string(),
// MsgSend {
// from_address: sender.to_string(),
// to_address,
// amount: cosmwasm_to_proto_coins(amount),
// }
// .encode_to_vec(),
// ),
// not_supported => unimplemented!("{not_supported:?}"),
// },
not_supported => unimplemented!("{not_supported:?}"),
};

Expand Down
35 changes: 17 additions & 18 deletions contracts/savings-app/tests/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::a
use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::authz::v1beta1::Grant;
use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::authz::v1beta1::MsgGrant;
use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::authz::v1beta1::MsgGrantResponse;
use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::bank::v1beta1::MsgSend;
use cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::osmosis::gamm::v1beta1::MsgSwapExactAmountIn;
use cw_orch::osmosis_test_tube::osmosis_test_tube::ConcentratedLiquidity;
use cw_orch::osmosis_test_tube::osmosis_test_tube::ExecuteResponse;
Expand Down Expand Up @@ -326,23 +325,23 @@ fn give_authorizations(
)?;
}
// TODO: keeping it separate since we may want to be more restrictive on this one
let _: ExecuteResponse<MsgGrantResponse> = app.execute(
MsgGrant {
granter: chain.sender().to_string(),
grantee: savings_app.addr_str().unwrap(),
grant: Some(Grant {
authorization: Some(
GenericAuthorization {
msg: MsgSend::TYPE_URL.to_string(),
}
.to_any(),
),
expiration: None,
}),
},
MsgGrant::TYPE_URL,
chain.sender.as_ref(),
)?;
// let _: ExecuteResponse<MsgGrantResponse> = app.execute(
// MsgGrant {
// granter: chain.sender().to_string(),
// grantee: savings_app.addr_str().unwrap(),
// grant: Some(Grant {
// authorization: Some(
// GenericAuthorization {
// msg: MsgSend::TYPE_URL.to_string(),
// }
// .to_any(),
// ),
// expiration: None,
// }),
// },
// MsgGrant::TYPE_URL,
// chain.sender.as_ref(),
// )?;

Ok(())
}
Expand Down

0 comments on commit 81ac41c

Please sign in to comment.