Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
524 changes: 371 additions & 153 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/atomic-order-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
injective-cosmwasm = { path = "../../packages/injective-cosmwasm" }
injective-math = { path = "../../packages/injective-math" }
injective-math = { version = "0.3.5-1"}
injective-std = { workspace = true }
prost = { workspace = true }
schemars = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions contracts/atomic-order-example/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{BankMsg, Coin, DepsMut, Env, MessageInfo, Reply, Response, SubMsg, Uint128};
use cosmwasm_std::{BankMsg, Coin, DepsMut, Env, MessageInfo, Reply, Response, SubMsg, Uint256};
use cw2::set_contract_version;
use injective_cosmwasm::{
create_spot_market_order_msg, get_default_subaccount_id_for_checked_address,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn try_swap(
val: "No funds deposited!".to_string(),
});
}
let message_deposit = FPDecimal::from(info.funds[0].amount.u128());
let message_deposit = injective_math::FPDecimal::from(info.funds[0].amount);
if message_deposit < min_deposit {
return Err(ContractError::CustomError {
val: format!("Deposit: {message_deposit} below min_deposit: {min_deposit}"),
Expand Down Expand Up @@ -180,8 +180,8 @@ fn handle_atomic_order_reply(

let purchased_coins = Coin::new(u128::from(quantity), config.base_denom.clone());
let paid = quantity * price + fee;
let leftover = cache.deposited_amount.amount - Uint128::from(u128::from(paid));
let leftover_coins = Coin::new(u128::from(leftover), config.quote_denom);
let leftover = cache.deposited_amount.amount - Uint256::from(u128::from(paid));
let leftover_coins = Coin::new(leftover, config.quote_denom);

let send_message = BankMsg::Send {
to_address: cache.sender_address,
Expand Down
6 changes: 3 additions & 3 deletions contracts/atomic-order-example/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::str::FromStr;
use cosmwasm_std::testing::{message_info, MockApi, MockStorage};
use cosmwasm_std::{
coins, to_json_binary, Addr, BankMsg, Binary, ContractResult, CosmosMsg, MsgResponse,
OwnedDeps, QuerierResult, Reply, SubMsgResponse, SubMsgResult, SystemResult, Uint128,
OwnedDeps, QuerierResult, Reply, SubMsgResponse, SubMsgResult, SystemResult, Uint256,
};

use injective_cosmwasm::InjectiveMsg::CreateSpotMarketOrder;
Expand Down Expand Up @@ -120,9 +120,9 @@ fn test_swap() {
assert_eq!(to_address, sender_addr);
assert_eq!(2, amount.len());
assert_eq!(amount[0].denom, "INJ");
assert_eq!(amount[0].amount, Uint128::from(8u128));
assert_eq!(amount[0].amount, Uint256::from(8u128));
assert_eq!(amount[1].denom, "USDT");
assert_eq!(amount[1].amount, Uint128::from(9000u128 - 8036u128));
assert_eq!(amount[1].amount, Uint256::from(9000u128 - 8036u128));
} else {
panic!("Wrong message type!");
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/dummy/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn execute(
response.data = Some(to_json_binary("pong")?);
Ok(response)
}
ExecuteMsg::Error { .. } => Err(ContractError::Std(StdError::generic_err("oh no!"))),
ExecuteMsg::Error { .. } => Err(ContractError::Std(StdError::msg("oh no!"))),
ExecuteMsg::TriggerPythUpdate { price } => execute_trigger_pyth_update(deps, env, price),
}
}
Expand All @@ -73,7 +73,7 @@ pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result<Response, Contract
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Ping { .. } => to_json_binary("pong"),
QueryMsg::Error { .. } => Err(StdError::generic_err("oh no!")),
QueryMsg::Error { .. } => Err(StdError::msg("oh no!")),
QueryMsg::Runs {} => {
let runs_count = COUNTER.load(deps.storage)?;
to_json_binary(&format!("{runs_count}"))
Expand Down
2 changes: 1 addition & 1 deletion contracts/injective-cosmwasm-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
injective-cosmwasm = { path = "../../packages/injective-cosmwasm" }
injective-math = { path = "../../packages/injective-math" }
injective-math = { version = "0.3.5-1"}
injective-std = { workspace = true }
prost = { workspace = true }
schemars = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/injective-cosmwasm-stargate-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
injective-cosmwasm = { path = "../../packages/injective-cosmwasm" }
injective-math = { path = "../../packages/injective-math" }
injective-math = { version = "0.3.5-1"}
injective-std = { workspace = true }
prost = { workspace = true }
schemars = { workspace = true }
Expand Down
10 changes: 4 additions & 6 deletions contracts/injective-cosmwasm-stargate-example/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ pub fn handle_query_stargate_raw(querier: &QuerierWrapper<InjectiveQueryWrapper>

#[allow(deprecated)]
let request = &QueryRequest::<InjectiveQueryWrapper>::Stargate { path, data };
let raw = to_json_vec(request).map_err(|serialize_err| StdError::generic_err(format!("Serializing QueryRequest: {}", serialize_err)))?;
let raw = to_json_vec(request).map_err(|serialize_err| StdError::msg(format!("Serializing QueryRequest: {}", serialize_err)))?;

let value = match querier.raw_query(&raw) {
SystemResult::Err(system_err) => Err(StdError::generic_err(format!("Querier system error: {}", system_err))),
SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err(format!("Querier contract error: {}", contract_err))),
SystemResult::Err(system_err) => Err(StdError::msg(format!("Querier system error: {}", system_err))),
SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::msg(format!("Querier contract error: {}", contract_err))),
SystemResult::Ok(ContractResult::Ok(value)) => Ok(value),
}?
.to_string();

let decoded_value = BASE64_STANDARD
.decode(value)
.map_err(|_| StdError::generic_err("Decoding base64 value"))?;
let decoded_value = BASE64_STANDARD.decode(value).map_err(|_| StdError::msg("Decoding base64 value"))?;
to_json_binary(&QueryStargateResponse {
value: String::from_utf8(decoded_value)?,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
testing::type_helpers::{BankParams, ParamResponse, QueryBalanceResponse, QueryDenomMetadataResponse, QuerySupplyOffResponse},
utils::{ExchangeType, Setup},
};
use cosmwasm_std::{Coin, Uint128};
use cosmwasm_std::{Coin, Uint256};
use injective_test_tube::{
injective_std::types::{
cosmos::bank::v1beta1::{QueryBalanceRequest, QueryDenomMetadataRequest, QuerySupplyOfRequest},
Expand Down Expand Up @@ -92,7 +92,7 @@ fn test_query_bank_balance() {
response.balance,
Coin {
denom: "inj".to_string(),
amount: Uint128::new(1_000_000_000_000_000_000_000_000),
amount: Uint256::new(1_000_000_000_000_000_000_000_000),
}
);
}
Expand All @@ -114,7 +114,7 @@ fn test_query_supply_of() {
response.amount,
Coin {
denom: "inj".to_string(),
amount: Uint128::new(12000004078367203674350010),
amount: Uint256::new(12000004078367203674350010),
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl AddressGenerator for InjectiveAddressGenerator {
salt: &[u8],
) -> Result<Addr, cosmwasm_std::StdError> {
let canonical_addr = cosmwasm_std::instantiate2_address(checksum, creator, salt)?;
Ok(api.addr_humanize(&canonical_addr)?)
api.addr_humanize(&canonical_addr)
}
}

Expand Down
Loading