-
Notifications
You must be signed in to change notification settings - Fork 9
/
module.go
38 lines (29 loc) · 1.03 KB
/
module.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
package auth
import (
"bytes"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/sedaprotocol/seda-chain/plugins/indexing/log"
"github.com/sedaprotocol/seda-chain/plugins/indexing/types"
)
const StoreKey = authtypes.StoreKey
type wrappedAccount struct {
cdc codec.Codec
Account sdk.AccountI
}
func (s wrappedAccount) MarshalJSON() ([]byte, error) {
return s.cdc.MarshalInterfaceJSON(s.Account)
}
func ExtractUpdate(ctx *types.BlockContext, cdc codec.Codec, logger *log.Logger, change *storetypes.StoreKVPair) (*types.Message, error) {
if _, found := bytes.CutPrefix(change.Key, authtypes.AddressStoreKeyPrefix); found {
acc, err := codec.CollInterfaceValue[sdk.AccountI](cdc).Decode(change.Value)
if err != nil {
return nil, err
}
return types.NewMessage("account", &wrappedAccount{cdc: cdc, Account: acc}, ctx), nil
}
logger.Trace("skipping change", "change", change)
return nil, nil
}