forked from ondoprotocol/usdy-noble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
65 lines (61 loc) · 1.87 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package aura
import (
"cosmossdk.io/core/address"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ondoprotocol/usdy-noble/v2/keeper"
"github.com/ondoprotocol/usdy-noble/v2/types"
"github.com/ondoprotocol/usdy-noble/v2/types/blocklist"
)
func InitGenesis(ctx sdk.Context, k *keeper.Keeper, addressCodec address.Codec, genesis types.GenesisState) {
if err := k.SetBlocklistOwner(ctx, genesis.BlocklistState.Owner); err != nil {
panic(err)
}
if err := k.SetBlocklistPendingOwner(ctx, genesis.BlocklistState.PendingOwner); err != nil {
panic(err)
}
for _, account := range genesis.BlocklistState.BlockedAddresses {
address, _ := addressCodec.StringToBytes(account)
if err := k.SetBlockedAddress(ctx, address); err != nil {
panic(err)
}
}
if err := k.SetPaused(ctx, genesis.Paused); err != nil {
panic(err)
}
if err := k.SetOwner(ctx, genesis.Owner); err != nil {
panic(err)
}
if err := k.SetPendingOwner(ctx, genesis.PendingOwner); err != nil {
panic(err)
}
for _, burner := range genesis.Burners {
if err := k.SetBurner(ctx, burner.Address, burner.Allowance); err != nil {
panic(err)
}
}
for _, minter := range genesis.Minters {
if err := k.SetMinter(ctx, minter.Address, minter.Allowance); err != nil {
panic(err)
}
}
for _, pauser := range genesis.Pausers {
if err := k.SetPauser(ctx, pauser); err != nil {
panic(err)
}
}
}
func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState {
return &types.GenesisState{
BlocklistState: blocklist.GenesisState{
Owner: k.GetBlocklistOwner(ctx),
PendingOwner: k.GetBlocklistPendingOwner(ctx),
BlockedAddresses: k.GetBlockedAddresses(ctx),
},
Paused: k.GetPaused(ctx),
Owner: k.GetOwner(ctx),
PendingOwner: k.GetPendingOwner(ctx),
Burners: k.GetBurners(ctx),
Minters: k.GetMinters(ctx),
Pausers: k.GetPausers(ctx),
}
}