-
Notifications
You must be signed in to change notification settings - Fork 2
/
event.go
39 lines (33 loc) · 855 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-FileCopyrightText: 2023 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"github.com/cosmos/cosmos-sdk/types"
"github.com/pkg/errors"
)
type CoinReceived struct {
Amount *types.Coin
Receiver string
}
func NewCoinReceived(m map[string]any) (body CoinReceived, err error) {
body.Receiver = StringFromMap(m, "receiver")
if body.Receiver == "" {
err = errors.Errorf("receiver key not found in %##v", m)
return
}
body.Amount, err = BalanceFromMap(m, "amount")
return
}
type CoinSpent struct {
Amount *types.Coin
Spender string
}
func NewCoinSpent(m map[string]any) (body CoinSpent, err error) {
body.Spender = StringFromMap(m, "spender")
if body.Spender == "" {
err = errors.Errorf("spender key not found in %##v", m)
return
}
body.Amount, err = BalanceFromMap(m, "amount")
return
}