Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codehans committed Mar 11, 2024
1 parent af22e7e commit 22b87ba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ One contract instance is deployed per revenue token.
Each instance has a set of `Action`s that are stepped through on subsequent executions of `ExecuteMsg::Run`.
This is designed to keep execution of the contract in fixed time, and also support more complex routing of token swaps.
At the end of each execution, `revenue_token` balance is read and is deposited to the fee_collector address.

## Deployments

### Testnet

- code-id `3147`
- address `kujira158ydy6qlfq7khtnj5lj9a5dy25ep8hece4d0lqngzxqrwuz6dctsdl5eqx`
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fc9d07aa86894e4bc8422f40da2dc66d7d6eb377ec4c5c25413a425517a14f8d kujira_revenue_converter.wasm
791f7e2cdb823ac017a34503fa9f5a2a6c04eb007e0ba34d4724747cd7de89d1 kujira_revenue_converter.wasm
Binary file modified artifacts/kujira_revenue_converter.wasm
Binary file not shown.
17 changes: 13 additions & 4 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ use crate::state::{Action, Config};
const CONTRACT_NAME: &str = "crates.io:kujira-revenue-converter";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(_deps: DepsMut, _env: Env, _msg: ()) -> Result<Response, ContractError> {
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
Expand Down Expand Up @@ -110,11 +115,15 @@ pub fn reply(deps: DepsMut, env: Env, _msg: Reply) -> Result<Response, ContractE
let balance = deps
.querier
.query_balance(env.contract.address, config.target_denom.to_string())?;
let send = config
.target_denom
.send(&config.target_address, &balance.amount);
let send = if balance.amount.is_zero() {
vec![]
} else {
vec![config
.target_denom
.send(&config.target_address, &balance.amount)]
};
Ok(Response::default()
.add_message(send)
.add_messages(send)
.add_event(Event::new("revenue/reply").add_attribute("send", balance.to_string())))
}

Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::cmp::min;
use crate::msg::{ActionResponse, ConfigResponse, InstantiateMsg};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{
Addr, Binary, Coin, CosmosMsg, Order, StdError, StdResult, Storage, Uint128, WasmMsg,
coins, Addr, Binary, Coin, CosmosMsg, Order, StdError, StdResult, Storage, Uint128, WasmMsg,
};
use cw_storage_plus::{Bound, Item, Map};
use kujira::Denom;
Expand Down Expand Up @@ -146,7 +146,7 @@ impl Action {
Ok(Some(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: self.contract.to_string(),
msg: self.msg.clone(),
funds: vec![amount],
funds: coins(total.u128(), amount.denom),
})))
}
}
Expand Down

0 comments on commit 22b87ba

Please sign in to comment.