Files
3a9331169b Update avalanchego to v1.9.0-fuji (#472)
Co-authored-by: dhrubabasu <[email protected]>
Co-authored-by: Patrick O'Grady <[email protected]>
Co-authored-by: Stephen <[email protected]>
2022-10-02 20:20:49 -04:00

37 lines
904 B
Go

// (c) 2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package utils
import (
"github.com/ava-labs/avalanchego/genesis"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
)
type GenesisContainer struct {
NetworkID uint32
XChainGenesisTx *txs.Tx
XChainID ids.ID
AvaxAssetID ids.ID
GenesisBytes []byte
}
func NewGenesisContainer(networkID uint32) (*GenesisContainer, error) {
gc := &GenesisContainer{NetworkID: networkID}
var err error
gc.GenesisBytes, gc.AvaxAssetID, err = genesis.FromConfig(genesis.GetConfig(gc.NetworkID))
if err != nil {
return nil, err
}
gc.XChainGenesisTx, err = genesis.VMGenesis(gc.GenesisBytes, constants.AVMID)
if err != nil {
return nil, err
}
gc.XChainID = gc.XChainGenesisTx.ID()
return gc, nil
}