diff --git a/Cargo.lock b/Cargo.lock index 7071a3f4..495e73b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,7 +214,7 @@ dependencies = [ "cw-storage-plus", "cw-utils", "cw2", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "injective-std 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.12.6", @@ -961,7 +961,7 @@ dependencies = [ "cosmwasm-std 2.1.1", "cw-storage-plus", "cw2", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "schemars", "serde 1.0.204", "thiserror", @@ -1571,8 +1571,9 @@ dependencies = [ [[package]] name = "injective-cosmwasm" version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e93e9438844b10add3eb40ed1e8c92689824ac080d207f856412a73551c221" dependencies = [ - "cosmwasm-schema 1.5.5", "cosmwasm-std 2.1.1", "cw-storage-plus", "ethereum-types", @@ -1580,19 +1581,16 @@ dependencies = [ "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde 1.0.204", - "serde-json-wasm 1.0.1", "serde_repr", - "serde_test", "subtle-encoding", "tiny-keccak", ] [[package]] name = "injective-cosmwasm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e93e9438844b10add3eb40ed1e8c92689824ac080d207f856412a73551c221" +version = "0.3.1" dependencies = [ + "cosmwasm-schema 1.5.5", "cosmwasm-std 2.1.1", "cw-storage-plus", "ethereum-types", @@ -1600,7 +1598,9 @@ dependencies = [ "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde 1.0.204", + "serde-json-wasm 1.0.1", "serde_repr", + "serde_test", "subtle-encoding", "tiny-keccak", ] @@ -1614,7 +1614,7 @@ dependencies = [ "cosmwasm-std 2.1.1", "cw-storage-plus", "cw2", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "injective-std 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "injective-test-tube", @@ -1720,7 +1720,7 @@ dependencies = [ "cosmrs", "cosmwasm-std 2.1.1", "hex", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "injective-std 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.12.6", "serde 1.0.204", @@ -1737,7 +1737,7 @@ dependencies = [ "base64 0.13.1", "cosmwasm-std 2.1.1", "cw-multi-test", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6", "secp256k1", @@ -1755,7 +1755,7 @@ dependencies = [ "base64 0.13.1", "cosmwasm-std 2.1.1", "cw-multi-test", - "injective-cosmwasm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.3.0", "injective-math 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6", "secp256k1", diff --git a/Cargo.toml b/Cargo.toml index 65737d07..676e6df3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/packages/injective-cosmwasm/Cargo.toml b/packages/injective-cosmwasm/Cargo.toml index a318d3fc..971bb7fd 100644 --- a/packages/injective-cosmwasm/Cargo.toml +++ b/packages/injective-cosmwasm/Cargo.toml @@ -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] diff --git a/packages/injective-cosmwasm/src/lib.rs b/packages/injective-cosmwasm/src/lib.rs index e7554597..a2b35082 100644 --- a/packages/injective-cosmwasm/src/lib.rs +++ b/packages/injective-cosmwasm/src/lib.rs @@ -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"))] diff --git a/packages/injective-cosmwasm/src/utils.rs b/packages/injective-cosmwasm/src/utils.rs new file mode 100644 index 00000000..d0159d41 --- /dev/null +++ b/packages/injective-cosmwasm/src/utils.rs @@ -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 { + Ok(instantiate2_address(checksum, creator, salt)?[..INJECTIVE_ADDRESS_LENGTH].into()) +} diff --git a/packages/injective-testing/src/address_generator.rs b/packages/injective-testing/src/address_generator.rs index 50bebcc0..03f2198b 100644 --- a/packages/injective-testing/src/address_generator.rs +++ b/packages/injective-testing/src/address_generator.rs @@ -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; @@ -29,7 +30,7 @@ impl AddressGenerator for InjectiveAddressGenerator { creator: &cosmwasm_std::CanonicalAddr, salt: &[u8], ) -> anyhow::Result { - 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)?) } }