DA0-DA0 / polytone

An account on every blockchain for every smart contract.
42 stars 5 forks source link

Voice does not work on Injective #64

Closed NoahSaso closed 1 month ago

NoahSaso commented 1 month ago

The voice does not work on injective. It successfully generates proxy contracts on message execution events but saves the incorrect address to state, so it fails to find the generated proxy contract when attempting to execute. This has to do with the way Injective creates contract addresses.

I believe the issue is here: https://github.com/DA0-DA0/polytone/blob/63cbae87bb3e3872aaf1c05bbb940f541ecf3a36/contracts/main/voice/src/contract.rs#L109-L116

In one on-chain attempt, the instantiated proxy contract had address inj1mlrq3jpkftn7ad2r2fp4n772s7ekl4w7medmth, but the voice contract saved inj1mlrq3jpkftn7ad2r2fp4n772s7ekl4w744m6dz0632umxrv3dneqgy06fl to the SENDER_TO_PROXY map.

The instantiated contract has the following bech32 data:

[223, 198, 8, 200, 54, 74, 231, 238, 181, 67, 82, 67, 89, 251, 202, 135, 179, 111, 213, 222]

while the address saved to the voice's map has the following:

[223, 198, 8, 200, 54, 74, 231, 238, 181, 67, 82, 67, 89, 251, 202, 135, 179, 111, 213, 222, 173, 119, 166, 137, 250, 138, 185, 179, 13, 145, 108, 242]

They contain the same first 20 bytes, but the voice contract is generating 12 more bytes (32 bytes being the length of contract addresses on standard CosmWasm chains).

The normal instantiate2 implementation uses a SHA-256 hash to produce 32 bytes that get converted into a bech32 contract address. It appears Injective just slices off the first 20, but we need to verify this with the Injective wasm module.