Skip to content

Commit

Permalink
Fix ParseEvents to always include wasm.contract_address
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo authored Jan 24, 2021
1 parent 1920f80 commit 09bca64
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x/wasm/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,20 @@ 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 to the
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)
}
}

return sdk.Events{sdk.NewEvent(CustomEventType, attrs...)}
}

Expand Down

0 comments on commit 09bca64

Please # to comment.