Merge pull request #2377 from filecoin-project/asr/msig-api
API improvements
This commit is contained in:
commit
3f017688c7
@ -26,8 +26,6 @@ import (
|
|||||||
type FullNode interface {
|
type FullNode interface {
|
||||||
Common
|
Common
|
||||||
|
|
||||||
// TODO: TipSetKeys
|
|
||||||
|
|
||||||
// MethodGroup: Chain
|
// MethodGroup: Chain
|
||||||
// The Chain method group contains methods for interacting with the
|
// The Chain method group contains methods for interacting with the
|
||||||
// blockchain, but that do not require any form of state computation.
|
// blockchain, but that do not require any form of state computation.
|
||||||
@ -308,9 +306,9 @@ type FullNode interface {
|
|||||||
// MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent
|
// MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent
|
||||||
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
// MsigGetAvailableBalance creates a multisig wallet
|
// MsigGetAvailableBalance creates a multisig wallet
|
||||||
// It takes the following params: <required number of senders>, <approving addresses>, <initial balance>,
|
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
|
||||||
// <sender address of the create msg>, <gas price>
|
//<initial balance>, <sender address of the create msg>, <gas price>
|
||||||
MsigCreate(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
|
MsigCreate(context.Context, int64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
|
||||||
// MsigPropose proposes a multisig message
|
// MsigPropose proposes a multisig message
|
||||||
// It takes the following params: <multisig address>, <recipient address>, <value to transfer>,
|
// It takes the following params: <multisig address>, <recipient address>, <value to transfer>,
|
||||||
// <sender address of the propose msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
// <sender address of the propose msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
||||||
@ -320,10 +318,9 @@ type FullNode interface {
|
|||||||
// <sender address of the approve msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
// <sender address of the approve msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
||||||
MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
// MsigCancel cancels a previously-proposed multisig message
|
// MsigCancel cancels a previously-proposed multisig message
|
||||||
// It takes the following params: <multisig address>, <proposed message ID>, <proposer address>, <recipient address>, <value to transfer>,
|
// It takes the following params: <multisig address>, <proposed message ID>, <recipient address>, <value to transfer>,
|
||||||
// <sender address of the cancel msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
// <sender address of the cancel msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
||||||
// TODO: You can't cancel someone else's proposed message, so "src" and "proposer" here are redundant
|
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
MsigCancel(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
|
||||||
|
|
||||||
MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error)
|
MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error)
|
||||||
// MarketFreeBalance
|
// MarketFreeBalance
|
||||||
@ -380,8 +377,8 @@ type DealInfo struct {
|
|||||||
type MsgLookup struct {
|
type MsgLookup struct {
|
||||||
Receipt types.MessageReceipt
|
Receipt types.MessageReceipt
|
||||||
ReturnDec interface{}
|
ReturnDec interface{}
|
||||||
// TODO: This should probably a tipsetkey?
|
TipSet types.TipSetKey
|
||||||
TipSet *types.TipSet
|
Height abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockMessages struct {
|
type BlockMessages struct {
|
||||||
|
@ -158,10 +158,10 @@ type FullNodeStruct struct {
|
|||||||
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
||||||
|
|
||||||
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
MsigCreate func(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MsigCreate func(context.Context, int64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigCancel func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigCancel func(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
|
|
||||||
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
|
|
||||||
@ -692,8 +692,8 @@ func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.
|
|||||||
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req int64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req int64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
||||||
return c.Internal.MsigCreate(ctx, req, addrs, val, src, gp)
|
return c.Internal.MsigCreate(ctx, req, addrs, duration, val, src, gp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
||||||
@ -704,8 +704,8 @@ func (c *FullNodeStruct) MsigApprove(ctx context.Context, msig address.Address,
|
|||||||
return c.Internal.MsigApprove(ctx, msig, txID, proposer, to, amt, src, method, params)
|
return c.Internal.MsigApprove(ctx, msig, txID, proposer, to, amt, src, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
||||||
return c.Internal.MsigCancel(ctx, msig, txID, proposer, to, amt, src, method, params)
|
return c.Internal.MsigCancel(ctx, msig, txID, to, amt, src, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr, wallet address.Address, amt types.BigInt) (cid.Cid, error) {
|
func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr, wallet address.Address, amt types.BigInt) (cid.Cid, error) {
|
||||||
|
@ -53,7 +53,7 @@ func (ve Version) EqMajorMinor(v2 Version) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// APIVersion is a semver version of the rpc api exposed
|
// APIVersion is a semver version of the rpc api exposed
|
||||||
var APIVersion Version = newVer(0, 5, 0)
|
var APIVersion Version = newVer(0, 6, 0)
|
||||||
|
|
||||||
//nolint:varcheck,deadcode
|
//nolint:varcheck,deadcode
|
||||||
const (
|
const (
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -57,6 +58,11 @@ var msigCreateCmd = &cli.Command{
|
|||||||
Usage: "initial funds to give to multisig",
|
Usage: "initial funds to give to multisig",
|
||||||
Value: "0",
|
Value: "0",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "duration",
|
||||||
|
Usage: "length of the period over which funds unlock",
|
||||||
|
Value: "0",
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "from",
|
Name: "from",
|
||||||
Usage: "account to send the create message from",
|
Usage: "account to send the create message from",
|
||||||
@ -114,9 +120,11 @@ var msigCreateCmd = &cli.Command{
|
|||||||
required = int64(len(addrs))
|
required = int64(len(addrs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d := abi.ChainEpoch(cctx.Uint64("duration"))
|
||||||
|
|
||||||
gp := types.NewInt(1)
|
gp := types.NewInt(1)
|
||||||
|
|
||||||
msgCid, err := api.MsigCreate(ctx, required, addrs, intVal, sendAddr, gp)
|
msgCid, err := api.MsigCreate(ctx, required, addrs, d, intVal, sendAddr, gp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,11 @@ var stateReplaySetCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("finding message in chain: %w", err)
|
return xerrors.Errorf("finding message in chain: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ts, err = fapi.ChainGetTipSet(ctx, r.TipSet.Parents())
|
childTs, err := fapi.ChainGetTipSet(ctx, r.TipSet)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("loading tipset: %w", err)
|
||||||
|
}
|
||||||
|
ts, err = fapi.ChainGetTipSet(ctx, childTs.Parents())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -26,7 +26,7 @@ type MsigAPI struct {
|
|||||||
MpoolAPI MpoolAPI
|
MpoolAPI MpoolAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MsigAPI) MsigCreate(ctx context.Context, req int64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
func (a *MsigAPI) MsigCreate(ctx context.Context, req int64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
||||||
|
|
||||||
lenAddrs := int64(len(addrs))
|
lenAddrs := int64(len(addrs))
|
||||||
|
|
||||||
@ -50,6 +50,7 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req int64, addrs []address.Add
|
|||||||
msigParams := &samsig.ConstructorParams{
|
msigParams := &samsig.ConstructorParams{
|
||||||
Signers: addrs,
|
Signers: addrs,
|
||||||
NumApprovalsThreshold: req,
|
NumApprovalsThreshold: req,
|
||||||
|
UnlockDuration: duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, actErr := actors.SerializeParams(msigParams)
|
enc, actErr := actors.SerializeParams(msigParams)
|
||||||
@ -138,8 +139,8 @@ func (a *MsigAPI) MsigApprove(ctx context.Context, msig address.Address, txID ui
|
|||||||
return a.msigApproveOrCancel(ctx, api.MsigApprove, msig, txID, proposer, to, amt, src, method, params)
|
return a.msigApproveOrCancel(ctx, api.MsigApprove, msig, txID, proposer, to, amt, src, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MsigAPI) MsigCancel(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
func (a *MsigAPI) MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
||||||
return a.msigApproveOrCancel(ctx, api.MsigCancel, msig, txID, proposer, to, amt, src, method, params)
|
return a.msigApproveOrCancel(ctx, api.MsigCancel, msig, txID, src, to, amt, src, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MsigAPI) msigApproveOrCancel(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
func (a *MsigAPI) msigApproveOrCancel(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
|
||||||
|
@ -385,7 +385,8 @@ func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uin
|
|||||||
return &api.MsgLookup{
|
return &api.MsgLookup{
|
||||||
Receipt: *recpt,
|
Receipt: *recpt,
|
||||||
ReturnDec: returndec,
|
ReturnDec: returndec,
|
||||||
TipSet: ts,
|
TipSet: ts.Key(),
|
||||||
|
Height: ts.Height(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +399,8 @@ func (a *StateAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLoo
|
|||||||
if ts != nil {
|
if ts != nil {
|
||||||
return &api.MsgLookup{
|
return &api.MsgLookup{
|
||||||
Receipt: *recpt,
|
Receipt: *recpt,
|
||||||
TipSet: ts,
|
TipSet: ts.Key(),
|
||||||
|
Height: ts.Height(),
|
||||||
}, nil
|
}, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -93,8 +93,8 @@ func (s SealingAPIAdapter) StateWaitMsg(ctx context.Context, mcid cid.Cid) (seal
|
|||||||
Return: wmsg.Receipt.Return,
|
Return: wmsg.Receipt.Return,
|
||||||
GasUsed: wmsg.Receipt.GasUsed,
|
GasUsed: wmsg.Receipt.GasUsed,
|
||||||
},
|
},
|
||||||
TipSetTok: wmsg.TipSet.Key().Bytes(),
|
TipSetTok: wmsg.TipSet.Bytes(),
|
||||||
Height: wmsg.TipSet.Height(),
|
Height: wmsg.Height,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user