diff --git a/x/wasm/internal/types/types.go b/x/wasm/internal/types/types.go index 66537bd33ce..ebc82e3ad9f 100644 --- a/x/wasm/internal/types/types.go +++ b/x/wasm/internal/types/types.go @@ -219,20 +219,21 @@ func NewWasmCoins(cosmosCoins sdk.Coins) (wasmCoins []wasmvmtypes.Coin) { const CustomEventType = "wasm" const AttributeKeyContractAddr = "contract_address" -// ParseEvents converts wasm LogAttributes into an sdk.Events (with 0 or 1 elements) -func ParseEvents(logs []wasmvmtypes.EventAttribute, contractAddr sdk.AccAddress) sdk.Events { - if len(logs) == 0 { - return nil - } +// ParseEvents converts wasm LogAttributes into an sdk.Events +func ParseEvents(wasmOutputAttrs []wasmvmtypes.EventAttribute, contractAddr sdk.AccAddress) sdk.Events { // we always tag with the contract address issuing this event attrs := []sdk.Attribute{sdk.NewAttribute(AttributeKeyContractAddr, contractAddr.String())} - for _, l := range logs { + + // append attributes from wasm to the sdk.Event + for _, l := range wasmOutputAttrs { // and reserve the contract_address key for our use (not contract) if l.Key != AttributeKeyContractAddr { attr := sdk.NewAttribute(l.Key, l.Value) attrs = append(attrs, attr) } } + + // each wasm invokation always returns one sdk.Event return sdk.Events{sdk.NewEvent(CustomEventType, attrs...)} }