Skip to content

Commit

Permalink
Merge pull request #537 from CosmWasm/add-type-assertions
Browse files Browse the repository at this point in the history
Add compile time type assertions for `hasSubMessages` interface
  • Loading branch information
chipshort authored Jun 5, 2024
2 parents 36bb5d2 + 87ce53a commit 48ea39c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib_libwasmvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ type hasSubMessages interface {
SubMessages() []types.SubMsg
}

// make sure the types implement the interface
// cannot put these next to the types, as the interface is private
var (
_ hasSubMessages = (*types.IBCBasicResult)(nil)
_ hasSubMessages = (*types.IBCReceiveResult)(nil)
_ hasSubMessages = (*types.ContractResult)(nil)
)

func DeserializeResponse(gasLimit uint64, deserCost types.UFraction, gasReport *types.GasReport, data []byte, response any) error {
gasForDeserialization := deserCost.Mul(uint64(len(data))).Floor()
if gasLimit < gasForDeserialization+gasReport.UsedInternally {
Expand Down

0 comments on commit 48ea39c

Please sign in to comment.