2020-04-21 18:25:43 +00:00
|
|
|
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"
|
2020-09-18 21:59:27 +00:00
|
|
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
2020-07-23 00:14:54 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
2020-04-21 18:25:43 +00:00
|
|
|
|
2021-01-29 20:01:00 +00:00
|
|
|
bstore "github.com/filecoin-project/lotus/blockstore"
|
2020-04-21 18:25:43 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2020-05-14 02:32:04 +00:00
|
|
|
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) {
|
2020-07-23 00:14:54 +00:00
|
|
|
store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs))
|
2020-05-14 02:32:04 +00:00
|
|
|
|
2020-07-23 00:14:54 +00:00
|
|
|
h, err := adt.MakeEmptyMap(store).Root()
|
2020-05-14 00:04:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-04-21 18:25:43 +00:00
|
|
|
|
2020-09-18 21:59:27 +00:00
|
|
|
sms := verifreg0.ConstructState(h, RootVerifierID)
|
2020-04-21 18:25:43 +00:00
|
|
|
|
2020-07-23 00:14:54 +00:00
|
|
|
stcid, err := store.Put(store.Context(), sms)
|
2020-04-21 18:25:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
act := &types.Actor{
|
|
|
|
Code: builtin.VerifiedRegistryActorCodeID,
|
|
|
|
Head: stcid,
|
|
|
|
Balance: types.NewInt(0),
|
|
|
|
}
|
|
|
|
|
|
|
|
return act, nil
|
|
|
|
}
|