-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathgenesis.go
32 lines (27 loc) · 931 Bytes
/
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
package genutil
import (
"context"
"errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)
// TxHandler is an interface that defines how genesis txs are handled.
type TxHandler interface {
ExecuteGenesisTx([]byte) error
}
// InitGenesis - initialize accounts and deliver genesis transactions
// NOTE: It isn't used in server/v2 applications.
func InitGenesis(
ctx context.Context, stakingKeeper types.StakingKeeper,
deliverTx TxHandler, genesisState types.GenesisState,
txEncodingConfig client.TxEncodingConfig,
) (validatorUpdates []module.ValidatorUpdate, err error) {
if deliverTx == nil {
return nil, errors.New("deliverTx (genesis.TxHandler) not defined, verify x/genutil wiring")
}
if len(genesisState.GenTxs) > 0 {
return DeliverGenTxs(ctx, genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig)
}
return
}