Skip to content

Commit

Permalink
feat: add instantiate2_address_inj
Browse files Browse the repository at this point in the history
  • Loading branch information
gorgos committed Aug 13, 2024
1 parent 9fd9867 commit ed42161
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cw-utils = { version = "2.0.0" }
cw2 = { version = "2.0.0" }
ethereum-types = { version = "0.5.2" }
hex = { version = "0.4.3", features = [ "serde" ] }
injective-cosmwasm = { version = "0.3.0" }
injective-cosmwasm = { version = "0.3.1" }
injective-math = { version = "0.3.0" }
injective-std = { version = "1.13.0" }
injective-std-derive = { version = "1.13.0" }
Expand Down
2 changes: 1 addition & 1 deletion packages/injective-cosmwasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
name = "injective-cosmwasm"
readme = "README.md"
repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-cosmwasm"
version = "0.3.0"
version = "0.3.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions packages/injective-cosmwasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mod querier;
pub mod query;
pub mod route;
pub mod tokenfactory;
pub mod utils;
pub mod wasmx;

#[cfg(not(target_arch = "wasm32"))]
Expand Down
7 changes: 7 additions & 0 deletions packages/injective-cosmwasm/src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use cosmwasm_std::{instantiate2_address, CanonicalAddr, Instantiate2AddressError};

pub const INJECTIVE_ADDRESS_LENGTH: usize = 20;

pub fn instantiate2_address_inj(checksum: &[u8], creator: &CanonicalAddr, salt: &[u8]) -> Result<CanonicalAddr, Instantiate2AddressError> {
Ok(instantiate2_address(checksum, creator, salt)?[..INJECTIVE_ADDRESS_LENGTH].into())
}
3 changes: 2 additions & 1 deletion packages/injective-testing/src/address_generator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cosmwasm_std::{Addr, Storage};
use cw_multi_test::AddressGenerator;
use injective_cosmwasm::addr_to_bech32;
use injective_cosmwasm::utils::instantiate2_address_inj;
use rand::OsRng;
use secp256k1::Secp256k1;
use std::fmt::Write;
Expand Down Expand Up @@ -29,7 +30,7 @@ impl AddressGenerator for InjectiveAddressGenerator {
creator: &cosmwasm_std::CanonicalAddr,
salt: &[u8],
) -> anyhow::Result<Addr> {
let canonical_addr = cosmwasm_std::instantiate2_address(checksum, creator, salt)?;
let canonical_addr = instantiate2_address_inj(checksum, creator, salt)?;
Ok(api.addr_humanize(&canonical_addr)?)
}
}
Expand Down

0 comments on commit ed42161

Please sign in to comment.