lotus/chain/actors/builtin/paych/message14.go
Phi-rjan 2d57bfe273
feat: Skeleton for nv23 (#11964)
* Use local GST

Use local GST

* Import actors and define upgrade heights

Creatin a mock actor-bundle and define upgrade heights

* Generate adapters

Updates gen/inlinegen-data.json, and runs make actors-gen

* Add schedule and migration

Add schedule and migration

* Add upgrade and network version fields/params

Add upgrade and network version fields/params

* Run make gen / make docsgen-cli

Run make gen / make docsgen-cli

* Update filecoin-ffi

Update filecoin-ffi to the v1.28.0-dev tag, which supports the nv23 skeleton.

* Update GST to v0.14.0-dev

Update GST to v0.14.0-dev, which includes the nv23 skeleton

* Add support for actor version 14 in actor registry

Add support for actor version 14 in actor registry
2024-05-07 09:40:49 +02:00

110 lines
3.0 KiB
Go
Generated

package paych
import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin14 "github.com/filecoin-project/go-state-types/builtin"
init14 "github.com/filecoin-project/go-state-types/builtin/v14/init"
paych14 "github.com/filecoin-project/go-state-types/builtin/v14/paych"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/types"
)
type message14 struct{ from address.Address }
func (m message14) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version14, "paymentchannel")
if !ok {
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 14)
}
params, aerr := actors.SerializeParams(&paych14.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init14.ExecParams{
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: init_.Address,
From: m.from,
Value: initialAmount,
Method: builtin14.MethodsInit.Exec,
Params: enc,
}, nil
}
func (m message14) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych14.UpdateChannelStateParams{
Sv: toV14SignedVoucher(*sv),
Secret: secret,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin14.MethodsPaych.UpdateChannelState,
Params: params,
}, nil
}
func toV14SignedVoucher(sv paychtypes.SignedVoucher) paych14.SignedVoucher {
merges := make([]paych14.Merge, len(sv.Merges))
for i := range sv.Merges {
merges[i] = paych14.Merge{
Lane: sv.Merges[i].Lane,
Nonce: sv.Merges[i].Nonce,
}
}
return paych14.SignedVoucher{
ChannelAddr: sv.ChannelAddr,
TimeLockMin: sv.TimeLockMin,
TimeLockMax: sv.TimeLockMax,
SecretHash: sv.SecretHash,
Extra: (*paych14.ModVerifyParams)(sv.Extra),
Lane: sv.Lane,
Nonce: sv.Nonce,
Amount: sv.Amount,
MinSettleHeight: sv.MinSettleHeight,
Merges: merges,
Signature: sv.Signature,
}
}
func (m message14) Settle(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin14.MethodsPaych.Settle,
}, nil
}
func (m message14) Collect(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin14.MethodsPaych.Collect,
}, nil
}