Skip to content

Commit

Permalink
Fix: Instantiate 2 address length (#467)
Browse files Browse the repository at this point in the history
* fix: instantiate2 injective error

* Bump version for app-contract and app-package
  • Loading branch information
SlayerAnsh authored May 21, 2024
1 parent 2e47830 commit 3f2e750
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 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 @@ -35,7 +35,7 @@ andromeda-fungible-tokens = { path = "./packages/andromeda-fungible-tokens", ver
andromeda-finance = { path = "./packages/andromeda-finance", version = "1.0.0" }
andromeda-data-storage = { path = "./packages/andromeda-data-storage", version = "1.0.0" }
andromeda-modules = { path = "./packages/andromeda-modules", version = "1.0.0" }
andromeda-app = { path = "./packages/andromeda-app", version = "1.0.0" }
andromeda-app = { path = "./packages/andromeda-app", version = "1.0.1" }
andromeda-ecosystem = { path = "./packages/andromeda-ecosystem", version = "1.0.0" }
andromeda-testing = { path = "./packages/andromeda-testing", version = "1.0.0" }

Expand Down
2 changes: 1 addition & 1 deletion contracts/app/andromeda-app-contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "andromeda-app-contract"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
rust-version = "1.65.0"

Expand Down
2 changes: 1 addition & 1 deletion packages/andromeda-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "andromeda-app"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
rust-version = "1.65.0"
description = "Utility methods and message definitions for the Andromeda App Contract"
Expand Down
13 changes: 13 additions & 0 deletions packages/andromeda-app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ impl AppComponent {
let creator = api.addr_canonicalize(parent_addr.as_str())?;
let new_addr = instantiate2_address(&checksum, &creator, &salt).unwrap();

// Instantiate 2 impl uses default cannonical address of 32 bytes (SHA 256). But as mentioned here -
// https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/docs/architecture/adr-028-public-key-addresses.md
// chains can use different length for cannonical address, eg, injective uses 20 (eth based).
// Instead of having fallback for each chain we can use parent address, which itself is a contract.
// Slice the default 32 bytes canonical address to size of parent cannonical address

let cannonical_parent_addr = api.addr_canonicalize(parent_addr.as_str())?;
let new_addr = new_addr
.as_slice()
.split_at(cannonical_parent_addr.len())
.0
.into();

Ok(Some(api.addr_humanize(&new_addr)?))
}

Expand Down
2 changes: 1 addition & 1 deletion packages/andromeda-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ prost = "0.9.0"
anyhow = "1.0.79"

andromeda-non-fungible-tokens = { workspace = true }
andromeda-app = { version = "1.0.0", path = "../andromeda-app" }
andromeda-app = { version = "1.0.1", path = "../andromeda-app" }
andromeda-modules = { version = "1.0.0", path = "../andromeda-modules" }
andromeda-adodb = { version = "1.0.0", path = "../../contracts/os/andromeda-adodb", features = [
"testing",
Expand Down

0 comments on commit 3f2e750

Please sign in to comment.