From 4fbb945cb85a0cd9ec0b542545426094c064408d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 28 Jul 2021 10:33:33 +0200 Subject: [PATCH] PR Comment: move where truncating address length to 20 --- x/wasm/keeper/keeper.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 68e58b27cb..4666cc9f2e 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -819,7 +819,9 @@ func BuildContractAddress(codeID, instanceID uint64) sdk.AccAddress { contractID := make([]byte, 16) binary.BigEndian.PutUint64(contractID[:8], codeID) binary.BigEndian.PutUint64(contractID[8:], instanceID) - return Module(types.ModuleName, contractID) + // 20 bytes to work with Cosmos SDK 0.42 (0.43 pushes for 32 bytes) + // TODO: remove truncate if we update to 0.43 before wasmd 1.0 + return Module(types.ModuleName, contractID)[:20] } // Hash and Module is taken from https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-rc2/types/address/hash.go @@ -838,10 +840,7 @@ func Hash(typ string, key []byte) []byte { assertNil(err) _, err = hasher.Write(key) assertNil(err) - hashed := hasher.Sum(nil) - // 20 bytes to work with Cosmos SDK 0.42 (0.43 pushes for 32 bytes) - // TODO: remove truncate if we update to 0.43 before wasmd 1.0 - return hashed[:20] + return hasher.Sum(nil) } // Module is a specialized version of a composed address for modules. Each module account