Skip to content

Commit

Permalink
Map moment destroyed event (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkenji authored Sep 28, 2021
1 parent d73033e commit 49cd3ff
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/go/events/destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package events

import (
"github.com/onflow/cadence"
jsoncdc "github.com/onflow/cadence/encoding/json"
)

var (
EventMomentDestroyed = "TopShot.MomentDestroyed"
)

type MomentDestroyedEvent interface {
Id() uint64
}

type momentDestroyedEvent cadence.Event

func (a momentDestroyedEvent) Id() uint64 {
return uint64(a.Fields[0].(cadence.UInt64))
}

func DecodeMomentDestroyedEvent(b []byte) (MomentDestroyedEvent, error) {
value, err := jsoncdc.Decode(b)
if err != nil {
return nil, err
}
return momentDestroyedEvent(value.(cadence.Event)), nil
}

0 comments on commit 49cd3ff

Please sign in to comment.