Skip to content

Commit

Permalink
PR Comment: move where truncating address length to 20
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jul 28, 2021
1 parent 6ea67a4 commit 4fbb945
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4fbb945

Please sign in to comment.