2020-09-15 21:44:03 +00:00
|
|
|
package multisig
|
|
|
|
|
|
|
|
import (
|
2020-11-04 01:25:53 +00:00
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
2020-09-15 21:44:03 +00:00
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2020-09-21 20:13:38 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2020-09-15 21:44:03 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/cbor"
|
2020-09-24 00:40:29 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-09-21 20:13:38 +00:00
|
|
|
|
2020-09-18 21:59:27 +00:00
|
|
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-09-21 20:13:38 +00:00
|
|
|
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
2020-09-28 20:13:18 +00:00
|
|
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
2020-09-15 21:44:03 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
2020-09-24 00:40:29 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
2020-09-15 21:44:03 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2020-09-24 00:40:29 +00:00
|
|
|
func init() {
|
|
|
|
builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
|
|
|
return load0(store, root)
|
|
|
|
})
|
2020-09-28 20:13:18 +00:00
|
|
|
builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
|
|
|
return load2(store, root)
|
2020-09-24 00:40:29 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-09-15 21:44:03 +00:00
|
|
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
|
|
|
switch act.Code {
|
2020-09-18 21:59:27 +00:00
|
|
|
case builtin0.MultisigActorCodeID:
|
2020-09-24 00:40:29 +00:00
|
|
|
return load0(store, act.Head)
|
2020-09-28 20:13:18 +00:00
|
|
|
case builtin2.MultisigActorCodeID:
|
|
|
|
return load2(store, act.Head)
|
2020-09-15 21:44:03 +00:00
|
|
|
}
|
|
|
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
|
|
|
}
|
|
|
|
|
|
|
|
type State interface {
|
|
|
|
cbor.Marshaler
|
|
|
|
|
|
|
|
LockedBalance(epoch abi.ChainEpoch) (abi.TokenAmount, error)
|
2020-09-23 05:19:43 +00:00
|
|
|
StartEpoch() (abi.ChainEpoch, error)
|
|
|
|
UnlockDuration() (abi.ChainEpoch, error)
|
|
|
|
InitialBalance() (abi.TokenAmount, error)
|
|
|
|
Threshold() (uint64, error)
|
|
|
|
Signers() ([]address.Address, error)
|
2020-09-21 20:13:38 +00:00
|
|
|
|
|
|
|
ForEachPendingTxn(func(id int64, txn Transaction) error) error
|
2020-11-04 01:25:53 +00:00
|
|
|
PendingTxnChanged(State) (bool, error)
|
|
|
|
|
|
|
|
transactions() (adt.Map, error)
|
|
|
|
decodeTransaction(val *cbg.Deferred) (Transaction, error)
|
2020-09-15 21:44:03 +00:00
|
|
|
}
|
2020-09-21 20:13:38 +00:00
|
|
|
|
|
|
|
type Transaction = msig0.Transaction
|