-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
46 lines (39 loc) · 1.18 KB
/
genesis.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
40
41
42
43
44
45
46
// Copyright 2024 NASD Inc.
//
// Use of this source code is governed by a BSL-style
// license that can be found in the LICENSE file or at
// https://mariadb.com/bsl11.
package authority
import (
"context"
"github.com/noble-assets/authority/keeper"
"github.com/noble-assets/authority/types"
)
func InitGenesis(ctx context.Context, k *keeper.Keeper, accountKeeper types.AccountKeeper, genesis types.GenesisState) {
_, err := accountKeeper.AddressCodec().StringToBytes(genesis.Owner)
if err != nil {
panic("failed to decode owner address")
}
err = k.Owner.Set(ctx, genesis.Owner)
if err != nil {
panic("failed to set owner in state")
}
if genesis.PendingOwner != "" {
_, err := accountKeeper.AddressCodec().StringToBytes(genesis.PendingOwner)
if err != nil {
panic("failed to decode pending owner address")
}
err = k.PendingOwner.Set(ctx, genesis.PendingOwner)
if err != nil {
panic("failed to set pending owner in state")
}
}
}
func ExportGenesis(ctx context.Context, k *keeper.Keeper) *types.GenesisState {
owner, _ := k.Owner.Get(ctx)
pendingOwner, _ := k.PendingOwner.Get(ctx)
return &types.GenesisState{
Owner: owner,
PendingOwner: pendingOwner,
}
}