deduct taxes from coins sent to wormhole contract from token bridge, in case fee denom switches from uluna
Change-Id: I141b53b51c883162b49d6caa74225ce1c030995f
This commit is contained in:
parent
7945662d8a
commit
e08116635e
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.15.1"
|
version = "0.15.1"
|
||||||
|
@ -1047,6 +1049,31 @@ version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
|
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "terra-cosmwasm"
|
||||||
|
version = "1.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4d7275aacd385e4f41647634c35692b1982085917b4dcfc1fdfa3984ee4ce45d"
|
||||||
|
dependencies = [
|
||||||
|
"cosmwasm-std",
|
||||||
|
"schemars",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "terraswap"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "02334ec5ad280fcc09c86467d40383ea1e4d977103345e53a4f03006c4be51c2"
|
||||||
|
dependencies = [
|
||||||
|
"cosmwasm-std",
|
||||||
|
"cosmwasm-storage",
|
||||||
|
"cw20",
|
||||||
|
"schemars",
|
||||||
|
"serde",
|
||||||
|
"terra-cosmwasm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.25"
|
version = "1.0.25"
|
||||||
|
@ -1086,6 +1113,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha3",
|
"sha3",
|
||||||
|
"terraswap",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wormhole",
|
"wormhole",
|
||||||
]
|
]
|
||||||
|
|
|
@ -21,6 +21,7 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] }
|
||||||
cw20 = "0.2.2"
|
cw20 = "0.2.2"
|
||||||
cw20-base = { version = "0.2.2", features = ["library"] }
|
cw20-base = { version = "0.2.2", features = ["library"] }
|
||||||
cw20-wrapped = { path = "../cw20-wrapped", features = ["library"] }
|
cw20-wrapped = { path = "../cw20-wrapped", features = ["library"] }
|
||||||
|
terraswap = "1.1.0"
|
||||||
wormhole = { path = "../wormhole", features = ["library"] }
|
wormhole = { path = "../wormhole", features = ["library"] }
|
||||||
|
|
||||||
thiserror = { version = "1.0.20" }
|
thiserror = { version = "1.0.20" }
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use crate::msg::WrappedRegistryResponse;
|
use crate::msg::WrappedRegistryResponse;
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
log, to_binary, Api, Binary, CanonicalAddr, CosmosMsg, Env, Extern, HandleResponse, HumanAddr,
|
log, to_binary, Api, Binary, CanonicalAddr, Coin, CosmosMsg, Env, Extern, HandleResponse,
|
||||||
InitResponse, Querier, QueryRequest, StdError, StdResult, Storage, Uint128, WasmMsg, WasmQuery,
|
HumanAddr, InitResponse, Querier, QueryRequest, StdError, StdResult, Storage, Uint128, WasmMsg,
|
||||||
|
WasmQuery,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::msg::{HandleMsg, InitMsg, QueryMsg};
|
use crate::msg::{HandleMsg, InitMsg, QueryMsg};
|
||||||
|
@ -28,6 +29,7 @@ use cw20_wrapped::msg::HandleMsg as WrappedMsg;
|
||||||
use cw20_wrapped::msg::InitMsg as WrappedInit;
|
use cw20_wrapped::msg::InitMsg as WrappedInit;
|
||||||
use cw20_wrapped::msg::QueryMsg as WrappedQuery;
|
use cw20_wrapped::msg::QueryMsg as WrappedQuery;
|
||||||
use cw20_wrapped::msg::{InitHook, WrappedAssetInfoResponse};
|
use cw20_wrapped::msg::{InitHook, WrappedAssetInfoResponse};
|
||||||
|
use terraswap::asset::{Asset, AssetInfo};
|
||||||
|
|
||||||
use sha3::{Digest, Keccak256};
|
use sha3::{Digest, Keccak256};
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
@ -54,6 +56,23 @@ pub fn init<S: Storage, A: Api, Q: Querier>(
|
||||||
Ok(InitResponse::default())
|
Ok(InitResponse::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn coins_after_tax<S: Storage, A: Api, Q: Querier>(
|
||||||
|
deps: &mut Extern<S, A, Q>,
|
||||||
|
coins: Vec<Coin>,
|
||||||
|
) -> StdResult<Vec<Coin>> {
|
||||||
|
let mut res = vec![];
|
||||||
|
for coin in coins {
|
||||||
|
let asset = Asset {
|
||||||
|
amount: coin.amount.clone(),
|
||||||
|
info: AssetInfo::NativeToken {
|
||||||
|
denom: coin.denom.clone(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
res.push(asset.deduct_tax(&deps)?);
|
||||||
|
}
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_vaa<S: Storage, A: Api, Q: Querier>(
|
pub fn parse_vaa<S: Storage, A: Api, Q: Querier>(
|
||||||
deps: &mut Extern<S, A, Q>,
|
deps: &mut Extern<S, A, Q>,
|
||||||
block_time: u64,
|
block_time: u64,
|
||||||
|
@ -233,7 +252,7 @@ fn handle_create_asset_meta<S: Storage, A: Api, Q: Querier>(
|
||||||
nonce,
|
nonce,
|
||||||
})?,
|
})?,
|
||||||
// forward coins sent to this message
|
// forward coins sent to this message
|
||||||
send: env.message.sent_funds.clone(),
|
send: coins_after_tax(deps, env.message.sent_funds.clone())?,
|
||||||
})],
|
})],
|
||||||
log: vec![
|
log: vec![
|
||||||
log("meta.token_chain", CHAIN_ID),
|
log("meta.token_chain", CHAIN_ID),
|
||||||
|
@ -592,7 +611,7 @@ fn handle_initiate_transfer<S: Storage, A: Api, Q: Querier>(
|
||||||
nonce,
|
nonce,
|
||||||
})?,
|
})?,
|
||||||
// forward coins sent to this message
|
// forward coins sent to this message
|
||||||
send: env.message.sent_funds.clone(),
|
send: coins_after_tax(deps, env.message.sent_funds.clone())?,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Ok(HandleResponse {
|
Ok(HandleResponse {
|
||||||
|
|
Loading…
Reference in New Issue