52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package genesis
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/filecoin-project/go-address"
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
bstore "github.com/filecoin-project/lotus/lib/blockstore"
|
|
)
|
|
|
|
var RootVerifierID address.Address
|
|
|
|
func init() {
|
|
|
|
idk, err := address.NewFromString("t080")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
RootVerifierID = idk
|
|
}
|
|
|
|
func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|
store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs))
|
|
|
|
h, err := adt.MakeEmptyMap(store).Root()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sms := verifreg0.ConstructState(h, RootVerifierID)
|
|
|
|
stcid, err := store.Put(store.Context(), sms)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
act := &types.Actor{
|
|
Code: builtin.VerifiedRegistryActorCodeID,
|
|
Head: stcid,
|
|
Balance: types.NewInt(0),
|
|
}
|
|
|
|
return act, nil
|
|
}
|