mirror of https://github.com/certusone/wasmd.git
Fix ParseEvents to always include wasm.contract_address
This commit is contained in:
parent
1920f80d18
commit
09bca64f9d
|
@ -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...)}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue