introduce message prototypes

This introduces message prototypes to applicable API endpoints, which
allows us to invert control of message sending and give the user a
chance to intervene with an interactive ui.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
vyzo 2021-03-27 16:35:46 +02:00 committed by Jakub Sztandera
parent 86e90dc6f1
commit e2d0047a2a
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
20 changed files with 852 additions and 323 deletions

View File

@ -586,15 +586,16 @@ type FullNode interface {
// MsigCreate creates a multisig wallet // MsigCreate creates a multisig wallet
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration> // It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
//<initial balance>, <sender address of the create msg>, <gas price> //<initial balance>, <sender address of the create msg>, <gas price>
MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) //perm:sign MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (*MessagePrototype, error) //perm:sign
// 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>
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) //perm:sign MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (*MessagePrototype, error) //perm:sign
// MsigApprove approves a previously-proposed multisig message by transaction ID // MsigApprove approves a previously-proposed multisig message by transaction ID
// It takes the following params: <multisig address>, <proposed transaction ID> <signer address> // It takes the following params: <multisig address>, <proposed transaction ID> <signer address>
MsigApprove(context.Context, address.Address, uint64, address.Address) (cid.Cid, error) //perm:sign MsigApprove(context.Context, address.Address, uint64, address.Address) (*MessagePrototype, error) //perm:sign
// MsigApproveTxnHash approves a previously-proposed multisig message, specified // MsigApproveTxnHash approves a previously-proposed multisig message, specified
// using both transaction ID and a hash of the parameters used in the // using both transaction ID and a hash of the parameters used in the
@ -602,43 +603,49 @@ type FullNode interface {
// exactly the transaction you think you are. // exactly the transaction you think you are.
// 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>, <proposer address>, <recipient address>, <value to transfer>,
// <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>
MsigApproveTxnHash(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) //perm:sign MsigApproveTxnHash(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (*MessagePrototype, error) //perm:sign
// MsigCancel cancels a previously-proposed multisig message // MsigCancel cancels a previously-proposed multisig message
// It takes the following params: <multisig address>, <proposed transaction ID>, <recipient address>, <value to transfer>, // It takes the following params: <multisig address>, <proposed transaction 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>
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) //perm:sign MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (*MessagePrototype, error) //perm:sign
// MsigAddPropose proposes adding a signer in the multisig // MsigAddPropose proposes adding a signer in the multisig
// It takes the following params: <multisig address>, <sender address of the propose msg>, // It takes the following params: <multisig address>, <sender address of the propose msg>,
// <new signer>, <whether the number of required signers should be increased> // <new signer>, <whether the number of required signers should be increased>
MsigAddPropose(context.Context, address.Address, address.Address, address.Address, bool) (cid.Cid, error) //perm:sign MsigAddPropose(context.Context, address.Address, address.Address, address.Address, bool) (*MessagePrototype, error) //perm:sign
// MsigAddApprove approves a previously proposed AddSigner message // MsigAddApprove approves a previously proposed AddSigner message
// It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>, // It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>,
// <proposer address>, <new signer>, <whether the number of required signers should be increased> // <proposer address>, <new signer>, <whether the number of required signers should be increased>
MsigAddApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (cid.Cid, error) //perm:sign MsigAddApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (*MessagePrototype, error) //perm:sign
// MsigAddCancel cancels a previously proposed AddSigner message // MsigAddCancel cancels a previously proposed AddSigner message
// It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>, // It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>,
// <new signer>, <whether the number of required signers should be increased> // <new signer>, <whether the number of required signers should be increased>
MsigAddCancel(context.Context, address.Address, address.Address, uint64, address.Address, bool) (cid.Cid, error) //perm:sign MsigAddCancel(context.Context, address.Address, address.Address, uint64, address.Address, bool) (*MessagePrototype, error) //perm:sign
// MsigSwapPropose proposes swapping 2 signers in the multisig // MsigSwapPropose proposes swapping 2 signers in the multisig
// It takes the following params: <multisig address>, <sender address of the propose msg>, // It takes the following params: <multisig address>, <sender address of the propose msg>,
// <old signer>, <new signer> // <old signer>, <new signer>
MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error) //perm:sign MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (*MessagePrototype, error) //perm:sign
// MsigSwapApprove approves a previously proposed SwapSigner // MsigSwapApprove approves a previously proposed SwapSigner
// It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>, // It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>,
// <proposer address>, <old signer>, <new signer> // <proposer address>, <old signer>, <new signer>
MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error) //perm:sign MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (*MessagePrototype, error) //perm:sign
// MsigSwapCancel cancels a previously proposed SwapSigner message // MsigSwapCancel cancels a previously proposed SwapSigner message
// It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>, // It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>,
// <old signer>, <new signer> // <old signer>, <new signer>
MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error) //perm:sign MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (*MessagePrototype, error) //perm:sign
// MsigRemoveSigner proposes the removal of a signer from the multisig. // MsigRemoveSigner proposes the removal of a signer from the multisig.
// It accepts the multisig to make the change on, the proposer address to // It accepts the multisig to make the change on, the proposer address to
// send the message from, the address to be removed, and a boolean // send the message from, the address to be removed, and a boolean
// indicating whether or not the signing threshold should be lowered by one // indicating whether or not the signing threshold should be lowered by one
// along with the address removal. // along with the address removal.
MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) //perm:sign MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (*MessagePrototype, error) //perm:sign
// MarketAddBalance adds funds to the market actor // MarketAddBalance adds funds to the market actor
MarketAddBalance(ctx context.Context, wallet, addr address.Address, amt types.BigInt) (cid.Cid, error) //perm:sign MarketAddBalance(ctx context.Context, wallet, addr address.Address, amt types.BigInt) (cid.Cid, error) //perm:sign

View File

@ -1262,10 +1262,10 @@ func (mr *MockFullNodeMockRecorder) MpoolSub(arg0 interface{}) *gomock.Call {
} }
// MsigAddApprove mocks base method // MsigAddApprove mocks base method
func (m *MockFullNode) MsigAddApprove(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5 address.Address, arg6 bool) (cid.Cid, error) { func (m *MockFullNode) MsigAddApprove(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5 address.Address, arg6 bool) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigAddApprove", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret := m.ctrl.Call(m, "MsigAddApprove", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1277,10 +1277,10 @@ func (mr *MockFullNodeMockRecorder) MsigAddApprove(arg0, arg1, arg2, arg3, arg4,
} }
// MsigAddCancel mocks base method // MsigAddCancel mocks base method
func (m *MockFullNode) MsigAddCancel(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4 address.Address, arg5 bool) (cid.Cid, error) { func (m *MockFullNode) MsigAddCancel(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4 address.Address, arg5 bool) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigAddCancel", arg0, arg1, arg2, arg3, arg4, arg5) ret := m.ctrl.Call(m, "MsigAddCancel", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1292,10 +1292,10 @@ func (mr *MockFullNodeMockRecorder) MsigAddCancel(arg0, arg1, arg2, arg3, arg4,
} }
// MsigAddPropose mocks base method // MsigAddPropose mocks base method
func (m *MockFullNode) MsigAddPropose(arg0 context.Context, arg1, arg2, arg3 address.Address, arg4 bool) (cid.Cid, error) { func (m *MockFullNode) MsigAddPropose(arg0 context.Context, arg1, arg2, arg3 address.Address, arg4 bool) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigAddPropose", arg0, arg1, arg2, arg3, arg4) ret := m.ctrl.Call(m, "MsigAddPropose", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1307,10 +1307,10 @@ func (mr *MockFullNodeMockRecorder) MsigAddPropose(arg0, arg1, arg2, arg3, arg4
} }
// MsigApprove mocks base method // MsigApprove mocks base method
func (m *MockFullNode) MsigApprove(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3 address.Address) (cid.Cid, error) { func (m *MockFullNode) MsigApprove(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3 address.Address) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigApprove", arg0, arg1, arg2, arg3) ret := m.ctrl.Call(m, "MsigApprove", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1322,10 +1322,10 @@ func (mr *MockFullNodeMockRecorder) MsigApprove(arg0, arg1, arg2, arg3 interface
} }
// MsigApproveTxnHash mocks base method // MsigApproveTxnHash mocks base method
func (m *MockFullNode) MsigApproveTxnHash(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3, arg4 address.Address, arg5 big.Int, arg6 address.Address, arg7 uint64, arg8 []byte) (cid.Cid, error) { func (m *MockFullNode) MsigApproveTxnHash(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3, arg4 address.Address, arg5 big.Int, arg6 address.Address, arg7 uint64, arg8 []byte) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigApproveTxnHash", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ret := m.ctrl.Call(m, "MsigApproveTxnHash", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1337,10 +1337,10 @@ func (mr *MockFullNodeMockRecorder) MsigApproveTxnHash(arg0, arg1, arg2, arg3, a
} }
// MsigCancel mocks base method // MsigCancel mocks base method
func (m *MockFullNode) MsigCancel(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3 address.Address, arg4 big.Int, arg5 address.Address, arg6 uint64, arg7 []byte) (cid.Cid, error) { func (m *MockFullNode) MsigCancel(arg0 context.Context, arg1 address.Address, arg2 uint64, arg3 address.Address, arg4 big.Int, arg5 address.Address, arg6 uint64, arg7 []byte) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigCancel", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ret := m.ctrl.Call(m, "MsigCancel", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1352,10 +1352,10 @@ func (mr *MockFullNodeMockRecorder) MsigCancel(arg0, arg1, arg2, arg3, arg4, arg
} }
// MsigCreate mocks base method // MsigCreate mocks base method
func (m *MockFullNode) MsigCreate(arg0 context.Context, arg1 uint64, arg2 []address.Address, arg3 abi.ChainEpoch, arg4 big.Int, arg5 address.Address, arg6 big.Int) (cid.Cid, error) { func (m *MockFullNode) MsigCreate(arg0 context.Context, arg1 uint64, arg2 []address.Address, arg3 abi.ChainEpoch, arg4 big.Int, arg5 address.Address, arg6 big.Int) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigCreate", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret := m.ctrl.Call(m, "MsigCreate", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1427,10 +1427,10 @@ func (mr *MockFullNodeMockRecorder) MsigGetVestingSchedule(arg0, arg1, arg2 inte
} }
// MsigPropose mocks base method // MsigPropose mocks base method
func (m *MockFullNode) MsigPropose(arg0 context.Context, arg1, arg2 address.Address, arg3 big.Int, arg4 address.Address, arg5 uint64, arg6 []byte) (cid.Cid, error) { func (m *MockFullNode) MsigPropose(arg0 context.Context, arg1, arg2 address.Address, arg3 big.Int, arg4 address.Address, arg5 uint64, arg6 []byte) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigPropose", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret := m.ctrl.Call(m, "MsigPropose", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1442,10 +1442,10 @@ func (mr *MockFullNodeMockRecorder) MsigPropose(arg0, arg1, arg2, arg3, arg4, ar
} }
// MsigRemoveSigner mocks base method // MsigRemoveSigner mocks base method
func (m *MockFullNode) MsigRemoveSigner(arg0 context.Context, arg1, arg2, arg3 address.Address, arg4 bool) (cid.Cid, error) { func (m *MockFullNode) MsigRemoveSigner(arg0 context.Context, arg1, arg2, arg3 address.Address, arg4 bool) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigRemoveSigner", arg0, arg1, arg2, arg3, arg4) ret := m.ctrl.Call(m, "MsigRemoveSigner", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1457,10 +1457,10 @@ func (mr *MockFullNodeMockRecorder) MsigRemoveSigner(arg0, arg1, arg2, arg3, arg
} }
// MsigSwapApprove mocks base method // MsigSwapApprove mocks base method
func (m *MockFullNode) MsigSwapApprove(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5, arg6 address.Address) (cid.Cid, error) { func (m *MockFullNode) MsigSwapApprove(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5, arg6 address.Address) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigSwapApprove", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret := m.ctrl.Call(m, "MsigSwapApprove", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1472,10 +1472,10 @@ func (mr *MockFullNodeMockRecorder) MsigSwapApprove(arg0, arg1, arg2, arg3, arg4
} }
// MsigSwapCancel mocks base method // MsigSwapCancel mocks base method
func (m *MockFullNode) MsigSwapCancel(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5 address.Address) (cid.Cid, error) { func (m *MockFullNode) MsigSwapCancel(arg0 context.Context, arg1, arg2 address.Address, arg3 uint64, arg4, arg5 address.Address) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigSwapCancel", arg0, arg1, arg2, arg3, arg4, arg5) ret := m.ctrl.Call(m, "MsigSwapCancel", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -1487,10 +1487,10 @@ func (mr *MockFullNodeMockRecorder) MsigSwapCancel(arg0, arg1, arg2, arg3, arg4,
} }
// MsigSwapPropose mocks base method // MsigSwapPropose mocks base method
func (m *MockFullNode) MsigSwapPropose(arg0 context.Context, arg1, arg2, arg3, arg4 address.Address) (cid.Cid, error) { func (m *MockFullNode) MsigSwapPropose(arg0 context.Context, arg1, arg2, arg3, arg4 address.Address) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MsigSwapPropose", arg0, arg1, arg2, arg3, arg4) ret := m.ctrl.Call(m, "MsigSwapPropose", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(cid.Cid) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }

View File

@ -261,19 +261,19 @@ type FullNodeStruct struct {
MpoolSub func(p0 context.Context) (<-chan MpoolUpdate, error) `perm:"read"` MpoolSub func(p0 context.Context) (<-chan MpoolUpdate, error) `perm:"read"`
MsigAddApprove func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (cid.Cid, error) `perm:"sign"` MsigAddApprove func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (*MessagePrototype, error) `perm:"sign"`
MsigAddCancel func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (cid.Cid, error) `perm:"sign"` MsigAddCancel func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (*MessagePrototype, error) `perm:"sign"`
MsigAddPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) `perm:"sign"` MsigAddPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) `perm:"sign"`
MsigApprove func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (cid.Cid, error) `perm:"sign"` MsigApprove func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (*MessagePrototype, error) `perm:"sign"`
MsigApproveTxnHash func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (cid.Cid, error) `perm:"sign"` MsigApproveTxnHash func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (*MessagePrototype, error) `perm:"sign"`
MsigCancel func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (cid.Cid, error) `perm:"sign"` MsigCancel func(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (*MessagePrototype, error) `perm:"sign"`
MsigCreate func(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (cid.Cid, error) `perm:"sign"` MsigCreate func(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (*MessagePrototype, error) `perm:"sign"`
MsigGetAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"` MsigGetAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -283,15 +283,15 @@ type FullNodeStruct struct {
MsigGetVestingSchedule func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MsigVesting, error) `perm:"read"` MsigGetVestingSchedule func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MsigVesting, error) `perm:"read"`
MsigPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (cid.Cid, error) `perm:"sign"` MsigPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (*MessagePrototype, error) `perm:"sign"`
MsigRemoveSigner func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) `perm:"sign"` MsigRemoveSigner func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) `perm:"sign"`
MsigSwapApprove func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (cid.Cid, error) `perm:"sign"` MsigSwapApprove func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (*MessagePrototype, error) `perm:"sign"`
MsigSwapCancel func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (cid.Cid, error) `perm:"sign"` MsigSwapCancel func(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (*MessagePrototype, error) `perm:"sign"`
MsigSwapPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (cid.Cid, error) `perm:"sign"` MsigSwapPropose func(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (*MessagePrototype, error) `perm:"sign"`
NodeStatus func(p0 context.Context, p1 bool) (NodeStatus, error) `perm:"read"` NodeStatus func(p0 context.Context, p1 bool) (NodeStatus, error) `perm:"read"`
@ -1619,60 +1619,60 @@ func (s *FullNodeStub) MpoolSub(p0 context.Context) (<-chan MpoolUpdate, error)
return nil, xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigAddApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (cid.Cid, error) { func (s *FullNodeStruct) MsigAddApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (*MessagePrototype, error) {
return s.Internal.MsigAddApprove(p0, p1, p2, p3, p4, p5, p6) return s.Internal.MsigAddApprove(p0, p1, p2, p3, p4, p5, p6)
} }
func (s *FullNodeStub) MsigAddApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (cid.Cid, error) { func (s *FullNodeStub) MsigAddApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 bool) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigAddCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (cid.Cid, error) { func (s *FullNodeStruct) MsigAddCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (*MessagePrototype, error) {
return s.Internal.MsigAddCancel(p0, p1, p2, p3, p4, p5) return s.Internal.MsigAddCancel(p0, p1, p2, p3, p4, p5)
} }
func (s *FullNodeStub) MsigAddCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (cid.Cid, error) { func (s *FullNodeStub) MsigAddCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 bool) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigAddPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) { func (s *FullNodeStruct) MsigAddPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) {
return s.Internal.MsigAddPropose(p0, p1, p2, p3, p4) return s.Internal.MsigAddPropose(p0, p1, p2, p3, p4)
} }
func (s *FullNodeStub) MsigAddPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) { func (s *FullNodeStub) MsigAddPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigApprove(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (cid.Cid, error) { func (s *FullNodeStruct) MsigApprove(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (*MessagePrototype, error) {
return s.Internal.MsigApprove(p0, p1, p2, p3) return s.Internal.MsigApprove(p0, p1, p2, p3)
} }
func (s *FullNodeStub) MsigApprove(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (cid.Cid, error) { func (s *FullNodeStub) MsigApprove(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigApproveTxnHash(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (cid.Cid, error) { func (s *FullNodeStruct) MsigApproveTxnHash(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (*MessagePrototype, error) {
return s.Internal.MsigApproveTxnHash(p0, p1, p2, p3, p4, p5, p6, p7, p8) return s.Internal.MsigApproveTxnHash(p0, p1, p2, p3, p4, p5, p6, p7, p8)
} }
func (s *FullNodeStub) MsigApproveTxnHash(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (cid.Cid, error) { func (s *FullNodeStub) MsigApproveTxnHash(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 address.Address, p5 types.BigInt, p6 address.Address, p7 uint64, p8 []byte) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigCancel(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (cid.Cid, error) { func (s *FullNodeStruct) MsigCancel(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (*MessagePrototype, error) {
return s.Internal.MsigCancel(p0, p1, p2, p3, p4, p5, p6, p7) return s.Internal.MsigCancel(p0, p1, p2, p3, p4, p5, p6, p7)
} }
func (s *FullNodeStub) MsigCancel(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (cid.Cid, error) { func (s *FullNodeStub) MsigCancel(p0 context.Context, p1 address.Address, p2 uint64, p3 address.Address, p4 types.BigInt, p5 address.Address, p6 uint64, p7 []byte) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigCreate(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (cid.Cid, error) { func (s *FullNodeStruct) MsigCreate(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (*MessagePrototype, error) {
return s.Internal.MsigCreate(p0, p1, p2, p3, p4, p5, p6) return s.Internal.MsigCreate(p0, p1, p2, p3, p4, p5, p6)
} }
func (s *FullNodeStub) MsigCreate(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (cid.Cid, error) { func (s *FullNodeStub) MsigCreate(p0 context.Context, p1 uint64, p2 []address.Address, p3 abi.ChainEpoch, p4 types.BigInt, p5 address.Address, p6 types.BigInt) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigGetAvailableBalance(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) { func (s *FullNodeStruct) MsigGetAvailableBalance(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) {
@ -1707,44 +1707,44 @@ func (s *FullNodeStub) MsigGetVestingSchedule(p0 context.Context, p1 address.Add
return *new(MsigVesting), xerrors.New("method not supported") return *new(MsigVesting), xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (cid.Cid, error) { func (s *FullNodeStruct) MsigPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (*MessagePrototype, error) {
return s.Internal.MsigPropose(p0, p1, p2, p3, p4, p5, p6) return s.Internal.MsigPropose(p0, p1, p2, p3, p4, p5, p6)
} }
func (s *FullNodeStub) MsigPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (cid.Cid, error) { func (s *FullNodeStub) MsigPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt, p4 address.Address, p5 uint64, p6 []byte) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigRemoveSigner(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) { func (s *FullNodeStruct) MsigRemoveSigner(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) {
return s.Internal.MsigRemoveSigner(p0, p1, p2, p3, p4) return s.Internal.MsigRemoveSigner(p0, p1, p2, p3, p4)
} }
func (s *FullNodeStub) MsigRemoveSigner(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (cid.Cid, error) { func (s *FullNodeStub) MsigRemoveSigner(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 bool) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigSwapApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (cid.Cid, error) { func (s *FullNodeStruct) MsigSwapApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (*MessagePrototype, error) {
return s.Internal.MsigSwapApprove(p0, p1, p2, p3, p4, p5, p6) return s.Internal.MsigSwapApprove(p0, p1, p2, p3, p4, p5, p6)
} }
func (s *FullNodeStub) MsigSwapApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (cid.Cid, error) { func (s *FullNodeStub) MsigSwapApprove(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address, p6 address.Address) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigSwapCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (cid.Cid, error) { func (s *FullNodeStruct) MsigSwapCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (*MessagePrototype, error) {
return s.Internal.MsigSwapCancel(p0, p1, p2, p3, p4, p5) return s.Internal.MsigSwapCancel(p0, p1, p2, p3, p4, p5)
} }
func (s *FullNodeStub) MsigSwapCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (cid.Cid, error) { func (s *FullNodeStub) MsigSwapCancel(p0 context.Context, p1 address.Address, p2 address.Address, p3 uint64, p4 address.Address, p5 address.Address) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) MsigSwapPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (cid.Cid, error) { func (s *FullNodeStruct) MsigSwapPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (*MessagePrototype, error) {
return s.Internal.MsigSwapPropose(p0, p1, p2, p3, p4) return s.Internal.MsigSwapPropose(p0, p1, p2, p3, p4)
} }
func (s *FullNodeStub) MsigSwapPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (cid.Cid, error) { func (s *FullNodeStub) MsigSwapPropose(p0 context.Context, p1 address.Address, p2 address.Address, p3 address.Address, p4 address.Address) (*MessagePrototype, error) {
return *new(cid.Cid), xerrors.New("method not supported") return nil, xerrors.New("method not supported")
} }
func (s *FullNodeStruct) NodeStatus(p0 context.Context, p1 bool) (NodeStatus, error) { func (s *FullNodeStruct) NodeStatus(p0 context.Context, p1 bool) (NodeStatus, error) {

View File

@ -5,6 +5,8 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/filecoin-project/lotus/chain/types"
datatransfer "github.com/filecoin-project/go-data-transfer" datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -169,3 +171,8 @@ type MessageCheckStatus struct {
Cid cid.Cid Cid cid.Cid
CheckStatus CheckStatus
} }
type MessagePrototype struct {
Message types.Message
ValidNonce bool
}

View File

@ -3,7 +3,9 @@ package v0api
import ( import (
"context" "context"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -57,4 +59,129 @@ func (w *WrapperV1Full) Version(ctx context.Context) (api.APIVersion, error) {
return ver, nil return ver, nil
} }
func (w *WrapperV1Full) executePrototype(ctx context.Context, p *api.MessagePrototype) (cid.Cid, error) {
sm, err := w.FullNode.MpoolPushMessage(ctx, &p.Message, nil)
if err != nil {
return cid.Undef, xerrors.Errorf("pushing message: %w", err)
}
return sm.Cid(), nil
}
func (w *WrapperV1Full) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
p, err := w.FullNode.MsigCreate(ctx, req, addrs, duration, val, src, gp)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
p, err := w.FullNode.MsigPropose(ctx, msig, to, amt, src, method, params)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) {
p, err := w.FullNode.MsigApprove(ctx, msig, txID, src)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigApproveTxnHash(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) {
p, err := w.FullNode.MsigApproveTxnHash(ctx, msig, txID, proposer, to, amt, src, method, params)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) 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) {
p, err := w.FullNode.MsigCancel(ctx, msig, txID, to, amt, src, method, params)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {
p, err := w.FullNode.MsigAddPropose(ctx, msig, src, newAdd, inc)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {
p, err := w.FullNode.MsigAddApprove(ctx, msig, src, txID, proposer, newAdd, inc)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) {
p, err := w.FullNode.MsigAddCancel(ctx, msig, src, txID, newAdd, inc)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
p, err := w.FullNode.MsigSwapPropose(ctx, msig, src, oldAdd, newAdd)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
p, err := w.FullNode.MsigSwapApprove(ctx, msig, src, txID, proposer, oldAdd, newAdd)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
p, err := w.FullNode.MsigSwapCancel(ctx, msig, src, txID, oldAdd, newAdd)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
func (w *WrapperV1Full) MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) {
p, err := w.FullNode.MsigRemoveSigner(ctx, msig, proposer, toRemove, decrease)
if err != nil {
return cid.Undef, xerrors.Errorf("creating prototype: %w", err)
}
return w.executePrototype(ctx, p)
}
var _ FullNode = &WrapperV1Full{} var _ FullNode = &WrapperV1Full{}

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
cli/init_test.go Normal file
View File

@ -0,0 +1,9 @@
package cli
import (
logging "github.com/ipfs/go-log/v2"
)
func init() {
logging.SetLogLevel("watchdog", "ERROR")
}

View File

@ -95,11 +95,13 @@ var msigCreateCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("multisigs must have at least one signer")) return ShowHelp(cctx, fmt.Errorf("multisigs must have at least one signer"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
var addrs []address.Address var addrs []address.Address
@ -146,13 +148,20 @@ var msigCreateCmd = &cli.Command{
gp := types.NewInt(1) gp := types.NewInt(1)
msgCid, err := api.MsigCreate(ctx, required, addrs, d, intVal, sendAddr, gp) proto, err := api.MsigCreate(ctx, required, addrs, d, intVal, sendAddr, gp)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
// wait for it to get mined into a block // wait for it to get mined into a block
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -364,11 +373,13 @@ var msigProposeCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must either pass three or five arguments")) return ShowHelp(cctx, fmt.Errorf("must either pass three or five arguments"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -426,14 +437,21 @@ var msigProposeCmd = &cli.Command{
return fmt.Errorf("actor %s is not a multisig actor", msig) return fmt.Errorf("actor %s is not a multisig actor", msig)
} }
msgCid, err := api.MsigPropose(ctx, msig, dest, types.BigInt(value), from, method, params) proto, err := api.MsigPropose(ctx, msig, dest, types.BigInt(value), from, method, params)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("send proposal in message: ", msgCid) fmt.Println("send proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -481,11 +499,13 @@ var msigApproveCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("usage: msig approve <msig addr> <message ID> <proposer address> <desination> <value> [ <method> <params> ]")) return ShowHelp(cctx, fmt.Errorf("usage: msig approve <msig addr> <message ID> <proposer address> <desination> <value> [ <method> <params> ]"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -515,10 +535,17 @@ var msigApproveCmd = &cli.Command{
var msgCid cid.Cid var msgCid cid.Cid
if cctx.Args().Len() == 2 { if cctx.Args().Len() == 2 {
msgCid, err = api.MsigApprove(ctx, msig, txid, from) proto, err := api.MsigApprove(ctx, msig, txid, from)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid = sm.Cid()
} else { } else {
proposer, err := address.NewFromString(cctx.Args().Get(2)) proposer, err := address.NewFromString(cctx.Args().Get(2))
if err != nil { if err != nil {
@ -558,15 +585,22 @@ var msigApproveCmd = &cli.Command{
params = p params = p
} }
msgCid, err = api.MsigApproveTxnHash(ctx, msig, txid, proposer, dest, types.BigInt(value), from, method, params) proto, err := api.MsigApproveTxnHash(ctx, msig, txid, proposer, dest, types.BigInt(value), from, method, params)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid = sm.Cid()
} }
fmt.Println("sent approval in message: ", msgCid) fmt.Println("sent approval in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -598,11 +632,13 @@ var msigRemoveProposeCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -630,14 +666,21 @@ var msigRemoveProposeCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigRemoveSigner(ctx, msig, from, addr, cctx.Bool("decrease-threshold")) proto, err := api.MsigRemoveSigner(ctx, msig, from, addr, cctx.Bool("decrease-threshold"))
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent remove proposal in message: ", msgCid) fmt.Println("sent remove proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -676,11 +719,13 @@ var msigAddProposeCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -708,14 +753,21 @@ var msigAddProposeCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigAddPropose(ctx, msig, from, addr, cctx.Bool("increase-threshold")) proto, err := api.MsigAddPropose(ctx, msig, from, addr, cctx.Bool("increase-threshold"))
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Fprintln(cctx.App.Writer, "sent add proposal in message: ", msgCid) fmt.Fprintln(cctx.App.Writer, "sent add proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -743,11 +795,13 @@ var msigAddApproveCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, new signer address, whether to increase threshold")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, new signer address, whether to increase threshold"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -790,14 +844,21 @@ var msigAddApproveCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigAddApprove(ctx, msig, from, txid, prop, newAdd, inc) proto, err := api.MsigAddApprove(ctx, msig, from, txid, prop, newAdd, inc)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent add approval in message: ", msgCid) fmt.Println("sent add approval in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -825,11 +886,13 @@ var msigAddCancelCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, new signer address, whether to increase threshold")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, new signer address, whether to increase threshold"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -867,14 +930,21 @@ var msigAddCancelCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigAddCancel(ctx, msig, from, txid, newAdd, inc) proto, err := api.MsigAddCancel(ctx, msig, from, txid, newAdd, inc)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent add cancellation in message: ", msgCid) fmt.Println("sent add cancellation in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -902,11 +972,13 @@ var msigSwapProposeCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, old signer address, new signer address")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, old signer address, new signer address"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -939,14 +1011,21 @@ var msigSwapProposeCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigSwapPropose(ctx, msig, from, oldAdd, newAdd) proto, err := api.MsigSwapPropose(ctx, msig, from, oldAdd, newAdd)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent swap proposal in message: ", msgCid) fmt.Println("sent swap proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -974,11 +1053,13 @@ var msigSwapApproveCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, old signer address, new signer address")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, old signer address, new signer address"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1021,14 +1102,21 @@ var msigSwapApproveCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigSwapApprove(ctx, msig, from, txid, prop, oldAdd, newAdd) proto, err := api.MsigSwapApprove(ctx, msig, from, txid, prop, oldAdd, newAdd)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent swap approval in message: ", msgCid) fmt.Println("sent swap approval in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -1056,11 +1144,13 @@ var msigSwapCancelCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, old signer address, new signer address")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, old signer address, new signer address"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1098,14 +1188,21 @@ var msigSwapCancelCmd = &cli.Command{
from = defaddr from = defaddr
} }
msgCid, err := api.MsigSwapCancel(ctx, msig, from, txid, oldAdd, newAdd) proto, err := api.MsigSwapCancel(ctx, msig, from, txid, oldAdd, newAdd)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent swap cancellation in message: ", msgCid) fmt.Println("sent swap cancellation in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -1133,11 +1230,13 @@ var msigLockProposeCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, start epoch, unlock duration, and amount")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, start epoch, unlock duration, and amount"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1185,14 +1284,21 @@ var msigLockProposeCmd = &cli.Command{
return actErr return actErr
} }
msgCid, err := api.MsigPropose(ctx, msig, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params) proto, err := api.MsigPropose(ctx, msig, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent lock proposal in message: ", msgCid) fmt.Println("sent lock proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -1220,11 +1326,13 @@ var msigLockApproveCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, tx id, start epoch, unlock duration, and amount")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, tx id, start epoch, unlock duration, and amount"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1282,14 +1390,21 @@ var msigLockApproveCmd = &cli.Command{
return actErr return actErr
} }
msgCid, err := api.MsigApproveTxnHash(ctx, msig, txid, prop, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params) proto, err := api.MsigApproveTxnHash(ctx, msig, txid, prop, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent lock approval in message: ", msgCid) fmt.Println("sent lock approval in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -1317,11 +1432,13 @@ var msigLockCancelCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, tx id, start epoch, unlock duration, and amount")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address, tx id, start epoch, unlock duration, and amount"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1374,14 +1491,21 @@ var msigLockCancelCmd = &cli.Command{
return actErr return actErr
} }
msgCid, err := api.MsigCancel(ctx, msig, txid, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params) proto, err := api.MsigCancel(ctx, msig, txid, msig, big.Zero(), from, uint64(multisig.Methods.LockBalance), params)
if err != nil { if err != nil {
return err return err
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent lock cancellation in message: ", msgCid) fmt.Println("sent lock cancellation in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }
@ -1471,11 +1595,13 @@ var msigProposeThresholdCmd = &cli.Command{
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and new threshold value")) return ShowHelp(cctx, fmt.Errorf("must pass multisig address and new threshold value"))
} }
api, closer, err := GetFullNodeAPI(cctx) srv, err := GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))
@ -1511,14 +1637,21 @@ var msigProposeThresholdCmd = &cli.Command{
return actErr return actErr
} }
msgCid, err := api.MsigPropose(ctx, msig, msig, types.NewInt(0), from, uint64(multisig.Methods.ChangeNumApprovalsThreshold), params) proto, err := api.MsigPropose(ctx, msig, msig, types.NewInt(0), from, uint64(multisig.Methods.ChangeNumApprovalsThreshold), params)
if err != nil { if err != nil {
return fmt.Errorf("failed to propose change of threshold: %w", err) return fmt.Errorf("failed to propose change of threshold: %w", err)
} }
sm, _, err := srv.PublishMessage(ctx, proto, true)
if err != nil {
return err
}
msgCid := sm.Cid()
fmt.Println("sent change threshold proposal in message: ", msgCid) fmt.Println("sent change threshold proposal in message: ", msgCid)
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
if err != nil { if err != nil {
return err return err
} }

View File

@ -147,12 +147,12 @@ var sendCmd = &cli.Command{
} }
msg, checks, err := srv.PublishMessage(ctx, proto, cctx.Bool("force")) msg, checks, err := srv.PublishMessage(ctx, proto, cctx.Bool("force"))
if xerrors.Is(err, ErrCheckFailed) { if xerrors.Is(err, ErrCheckFailed) {
proto, err = resolveChecks(ctx, srv, cctx.App.Writer, proto, checks, true) proto, err := resolveChecks(ctx, srv, cctx.App.Writer, proto, checks, true)
if err != nil { if err != nil {
return xerrors.Errorf("from UI: %w", err) return xerrors.Errorf("from UI: %w", err)
} }
msg, _, err = srv.PublishMessage(ctx, proto, true) msg, _, err = srv.PublishMessage(ctx, proto, true) //nolint
} }
if err != nil { if err != nil {

View File

@ -41,17 +41,17 @@ func baseFeeFromHints(hint map[string]interface{}) big.Int {
} }
func resolveChecks(ctx context.Context, s ServicesAPI, printer io.Writer, func resolveChecks(ctx context.Context, s ServicesAPI, printer io.Writer,
proto *types.Message, checkGroups [][]api.MessageCheckStatus, proto *api.MessagePrototype, checkGroups [][]api.MessageCheckStatus,
interactive bool) (*types.Message, error) { interactive bool) (*api.MessagePrototype, error) {
fmt.Fprintf(printer, "Following checks have failed:\n") fmt.Fprintf(printer, "Following checks have failed:\n")
printChecks(printer, checkGroups, proto.Cid()) printChecks(printer, checkGroups, proto.Message.Cid())
if !interactive { if !interactive {
return nil, ErrCheckFailed return nil, ErrCheckFailed
} }
if interactive { if interactive {
if feeCapBad, baseFee := isFeeCapProblem(checkGroups, proto.Cid()); feeCapBad { if feeCapBad, baseFee := isFeeCapProblem(checkGroups, proto.Message.Cid()); feeCapBad {
fmt.Fprintf(printer, "Fee of the message can be adjusted\n") fmt.Fprintf(printer, "Fee of the message can be adjusted\n")
if askUser(printer, "Do you wish to do that? [Yes/no]: ", true) { if askUser(printer, "Do you wish to do that? [Yes/no]: ", true) {
var err error var err error
@ -65,7 +65,7 @@ func resolveChecks(ctx context.Context, s ServicesAPI, printer io.Writer,
return nil, err return nil, err
} }
fmt.Fprintf(printer, "Following checks still failed:\n") fmt.Fprintf(printer, "Following checks still failed:\n")
printChecks(printer, checks, proto.Cid()) printChecks(printer, checks, proto.Message.Cid())
} }
if !askUser(printer, "Do you wish to send this message? [yes/No]: ", false) { if !askUser(printer, "Do you wish to send this message? [yes/No]: ", false) {
@ -125,15 +125,15 @@ func isFeeCapProblem(checkGroups [][]api.MessageCheckStatus, protoCid cid.Cid) (
return yes, baseFee return yes, baseFee
} }
func runFeeCapAdjustmentUI(proto *types.Message, baseFee abi.TokenAmount) (*types.Message, error) { func runFeeCapAdjustmentUI(proto *api.MessagePrototype, baseFee abi.TokenAmount) (*api.MessagePrototype, error) {
t, err := imtui.NewTui() t, err := imtui.NewTui()
if err != nil { if err != nil {
return nil, err return nil, err
} }
maxFee := big.Mul(proto.GasFeeCap, big.NewInt(proto.GasLimit)) maxFee := big.Mul(proto.Message.GasFeeCap, big.NewInt(proto.Message.GasLimit))
send := false send := false
t.SetScene(ui(baseFee, proto.GasLimit, &maxFee, &send)) t.SetScene(ui(baseFee, proto.Message.GasLimit, &maxFee, &send))
err = t.Run() err = t.Run()
if err != nil { if err != nil {
@ -143,7 +143,7 @@ func runFeeCapAdjustmentUI(proto *types.Message, baseFee abi.TokenAmount) (*type
return nil, fmt.Errorf("aborted by user") return nil, fmt.Errorf("aborted by user")
} }
proto.GasFeeCap = big.Div(maxFee, big.NewInt(proto.GasLimit)) proto.Message.GasFeeCap = big.Div(maxFee, big.NewInt(proto.Message.GasLimit))
return proto, nil return proto, nil
} }

View File

@ -22,22 +22,24 @@ import (
//go:generate go run github.com/golang/mock/mockgen -destination=servicesmock_test.go -package=cli -self_package github.com/filecoin-project/lotus/cli . ServicesAPI //go:generate go run github.com/golang/mock/mockgen -destination=servicesmock_test.go -package=cli -self_package github.com/filecoin-project/lotus/cli . ServicesAPI
type ServicesAPI interface { type ServicesAPI interface {
FullNodeAPI() api.FullNode
GetBaseFee(ctx context.Context) (abi.TokenAmount, error) GetBaseFee(ctx context.Context) (abi.TokenAmount, error)
// MessageForSend creates a prototype of a message based on SendParams // MessageForSend creates a prototype of a message based on SendParams
MessageForSend(ctx context.Context, params SendParams) (*types.Message, error) MessageForSend(ctx context.Context, params SendParams) (*api.MessagePrototype, error)
// DecodeTypedParamsFromJSON takes in information needed to identify a method and converts JSON // DecodeTypedParamsFromJSON takes in information needed to identify a method and converts JSON
// parameters to bytes of their CBOR encoding // parameters to bytes of their CBOR encoding
DecodeTypedParamsFromJSON(ctx context.Context, to address.Address, method abi.MethodNum, paramstr string) ([]byte, error) DecodeTypedParamsFromJSON(ctx context.Context, to address.Address, method abi.MethodNum, paramstr string) ([]byte, error)
RunChecksForPrototype(ctx context.Context, prototype *types.Message) ([][]api.MessageCheckStatus, error) RunChecksForPrototype(ctx context.Context, prototype *api.MessagePrototype) ([][]api.MessageCheckStatus, error)
// PublishMessage takes in a message prototype and publishes it // PublishMessage takes in a message prototype and publishes it
// before publishing the message, it runs checks on the node, message and mpool to verify that // before publishing the message, it runs checks on the node, message and mpool to verify that
// message is valid and won't be stuck. // message is valid and won't be stuck.
// if `force` is true, it skips the checks // if `force` is true, it skips the checks
PublishMessage(ctx context.Context, prototype *types.Message, interactive bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error) PublishMessage(ctx context.Context, prototype *api.MessagePrototype, interactive bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error)
// Close ends the session of services and disconnects from RPC, using Services after Close is called // Close ends the session of services and disconnects from RPC, using Services after Close is called
// most likely will result in an error // most likely will result in an error
@ -50,6 +52,10 @@ type ServicesImpl struct {
closer jsonrpc.ClientCloser closer jsonrpc.ClientCloser
} }
func (s *ServicesImpl) FullNodeAPI() api.FullNode {
return s.api
}
func (s *ServicesImpl) Close() error { func (s *ServicesImpl) Close() error {
if s.closer == nil { if s.closer == nil {
return xerrors.Errorf("Services already closed") return xerrors.Errorf("Services already closed")
@ -102,15 +108,24 @@ type CheckInfo struct {
var ErrCheckFailed = fmt.Errorf("check has failed") var ErrCheckFailed = fmt.Errorf("check has failed")
func (s *ServicesImpl) RunChecksForPrototype(ctx context.Context, prototype *types.Message) ([][]api.MessageCheckStatus, error) { func (s *ServicesImpl) RunChecksForPrototype(ctx context.Context, prototype *api.MessagePrototype) ([][]api.MessageCheckStatus, error) {
if !prototype.ValidNonce {
nonce, err := s.api.MpoolGetNonce(ctx, prototype.Message.From)
if err != nil {
return nil, xerrors.Errorf("mpool get nonce: %w", err)
}
prototype.Message.Nonce = nonce
prototype.ValidNonce = true
}
var outChecks [][]api.MessageCheckStatus var outChecks [][]api.MessageCheckStatus
checks, err := s.api.MpoolCheckMessages(ctx, []*types.Message{prototype}) checks, err := s.api.MpoolCheckMessages(ctx, []*types.Message{&prototype.Message})
if err != nil { if err != nil {
return nil, xerrors.Errorf("message check: %w", err) return nil, xerrors.Errorf("message check: %w", err)
} }
outChecks = append(outChecks, checks...) outChecks = append(outChecks, checks...)
checks, err = s.api.MpoolCheckPendingMessages(ctx, prototype.From) checks, err = s.api.MpoolCheckPendingMessages(ctx, prototype.Message.From)
if err != nil { if err != nil {
return nil, xerrors.Errorf("pending mpool check: %w", err) return nil, xerrors.Errorf("pending mpool check: %w", err)
} }
@ -123,27 +138,30 @@ func (s *ServicesImpl) RunChecksForPrototype(ctx context.Context, prototype *typ
// Errors with ErrCheckFailed if any of the checks fail // Errors with ErrCheckFailed if any of the checks fail
// First group of checks is related to the message prototype // First group of checks is related to the message prototype
func (s *ServicesImpl) PublishMessage(ctx context.Context, func (s *ServicesImpl) PublishMessage(ctx context.Context,
prototype *types.Message, force bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error) { prototype *api.MessagePrototype, force bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error) {
gasedMsg, err := s.api.GasEstimateMessageGas(ctx, prototype, nil, types.EmptyTSK) gasedMsg, err := s.api.GasEstimateMessageGas(ctx, &prototype.Message, nil, types.EmptyTSK)
if err != nil { if err != nil {
return nil, nil, xerrors.Errorf("estimating gas: %w", err) return nil, nil, xerrors.Errorf("estimating gas: %w", err)
} }
*prototype = *gasedMsg prototype.Message = *gasedMsg
if !force { if !force {
checks, err := s.RunChecksForPrototype(ctx, prototype) checks, err := s.RunChecksForPrototype(ctx, prototype)
if err != nil { if err != nil {
return nil, nil, xerrors.Errorf("running checks: %w", err) return nil, nil, xerrors.Errorf("running checks: %w", err)
} }
if len(checks) != 0 { for _, chks := range checks {
for _, c := range chks {
if !c.OK {
return nil, checks, ErrCheckFailed return nil, checks, ErrCheckFailed
} }
} }
}
}
//TODO: message prototype needs to have "IsNonceSet" if prototype.ValidNonce {
if prototype.Nonce != 0 { sm, err := s.api.WalletSignMessage(ctx, prototype.Message.From, &prototype.Message)
sm, err := s.api.WalletSignMessage(ctx, prototype.From, prototype)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -155,7 +173,7 @@ func (s *ServicesImpl) PublishMessage(ctx context.Context,
return sm, nil, nil return sm, nil, nil
} }
sm, err := s.api.MpoolPushMessage(ctx, prototype, nil) sm, err := s.api.MpoolPushMessage(ctx, &prototype.Message, nil)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -177,7 +195,7 @@ type SendParams struct {
Params []byte Params []byte
} }
func (s *ServicesImpl) MessageForSend(ctx context.Context, params SendParams) (*types.Message, error) { func (s *ServicesImpl) MessageForSend(ctx context.Context, params SendParams) (*api.MessagePrototype, error) {
if params.From == address.Undef { if params.From == address.Undef {
defaddr, err := s.api.WalletDefaultAddress(ctx) defaddr, err := s.api.WalletDefaultAddress(ctx)
if err != nil { if err != nil {
@ -186,7 +204,7 @@ func (s *ServicesImpl) MessageForSend(ctx context.Context, params SendParams) (*
params.From = defaddr params.From = defaddr
} }
msg := &types.Message{ msg := types.Message{
From: params.From, From: params.From,
To: params.To, To: params.To,
Value: params.Val, Value: params.Val,
@ -210,9 +228,15 @@ func (s *ServicesImpl) MessageForSend(ctx context.Context, params SendParams) (*
} else { } else {
msg.GasLimit = 0 msg.GasLimit = 0
} }
validNonce := false
if params.Nonce != nil { if params.Nonce != nil {
msg.Nonce = *params.Nonce msg.Nonce = *params.Nonce
validNonce = true
} }
return msg, nil prototype := &api.MessagePrototype{
Message: msg,
ValidNonce: validNonce,
}
return prototype, nil
} }

View File

@ -7,12 +7,10 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
mocks "github.com/filecoin-project/lotus/api/v0api/v0mocks" mocks "github.com/filecoin-project/lotus/api/v0api/v0mocks"
types "github.com/filecoin-project/lotus/chain/types" types "github.com/filecoin-project/lotus/chain/types"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
cid "github.com/ipfs/go-cid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -61,22 +59,23 @@ func setupMockSrvcs(t *testing.T) (*ServicesImpl, *mocks.MockFullNode) {
return srvcs, mockApi return srvcs, mockApi
} }
func fakeSign(msg *types.Message) *types.SignedMessage { // linter doesn't like dead code, so these are commented out.
return &types.SignedMessage{ // func fakeSign(msg *types.Message) *types.SignedMessage {
Message: *msg, // return &types.SignedMessage{
Signature: crypto.Signature{Type: crypto.SigTypeSecp256k1, Data: make([]byte, 32)}, // Message: *msg,
} // Signature: crypto.Signature{Type: crypto.SigTypeSecp256k1, Data: make([]byte, 32)},
} // }
// }
func makeMessageSigner() (*cid.Cid, interface{}) { // func makeMessageSigner() (*cid.Cid, interface{}) {
smCid := cid.Undef // smCid := cid.Undef
return &smCid, // return &smCid,
func(_ context.Context, msg *types.Message, _ *api.MessageSendSpec) (*types.SignedMessage, error) { // func(_ context.Context, msg *types.Message, _ *api.MessageSendSpec) (*types.SignedMessage, error) {
sm := fakeSign(msg) // sm := fakeSign(msg)
smCid = sm.Cid() // smCid = sm.Cid()
return sm, nil // return sm, nil
} // }
} // }
type MessageMatcher SendParams type MessageMatcher SendParams
@ -84,11 +83,13 @@ var _ gomock.Matcher = MessageMatcher{}
// Matches returns whether x is a match. // Matches returns whether x is a match.
func (mm MessageMatcher) Matches(x interface{}) bool { func (mm MessageMatcher) Matches(x interface{}) bool {
m, ok := x.(*types.Message) proto, ok := x.(*api.MessagePrototype)
if !ok { if !ok {
return false return false
} }
m := &proto.Message
if mm.From != address.Undef && mm.From != m.From { if mm.From != address.Undef && mm.From != m.From {
return false return false
} }

View File

@ -67,6 +67,20 @@ func (mr *MockServicesAPIMockRecorder) DecodeTypedParamsFromJSON(arg0, arg1, arg
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecodeTypedParamsFromJSON", reflect.TypeOf((*MockServicesAPI)(nil).DecodeTypedParamsFromJSON), arg0, arg1, arg2, arg3) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecodeTypedParamsFromJSON", reflect.TypeOf((*MockServicesAPI)(nil).DecodeTypedParamsFromJSON), arg0, arg1, arg2, arg3)
} }
// FullNodeAPI mocks base method
func (m *MockServicesAPI) FullNodeAPI() api.FullNode {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FullNodeAPI")
ret0, _ := ret[0].(api.FullNode)
return ret0
}
// FullNodeAPI indicates an expected call of FullNodeAPI
func (mr *MockServicesAPIMockRecorder) FullNodeAPI() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FullNodeAPI", reflect.TypeOf((*MockServicesAPI)(nil).FullNodeAPI))
}
// GetBaseFee mocks base method // GetBaseFee mocks base method
func (m *MockServicesAPI) GetBaseFee(arg0 context.Context) (big.Int, error) { func (m *MockServicesAPI) GetBaseFee(arg0 context.Context) (big.Int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
@ -83,10 +97,10 @@ func (mr *MockServicesAPIMockRecorder) GetBaseFee(arg0 interface{}) *gomock.Call
} }
// MessageForSend mocks base method // MessageForSend mocks base method
func (m *MockServicesAPI) MessageForSend(arg0 context.Context, arg1 SendParams) (*types.Message, error) { func (m *MockServicesAPI) MessageForSend(arg0 context.Context, arg1 SendParams) (*api.MessagePrototype, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MessageForSend", arg0, arg1) ret := m.ctrl.Call(m, "MessageForSend", arg0, arg1)
ret0, _ := ret[0].(*types.Message) ret0, _ := ret[0].(*api.MessagePrototype)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -98,7 +112,7 @@ func (mr *MockServicesAPIMockRecorder) MessageForSend(arg0, arg1 interface{}) *g
} }
// PublishMessage mocks base method // PublishMessage mocks base method
func (m *MockServicesAPI) PublishMessage(arg0 context.Context, arg1 *types.Message, arg2 bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error) { func (m *MockServicesAPI) PublishMessage(arg0 context.Context, arg1 *api.MessagePrototype, arg2 bool) (*types.SignedMessage, [][]api.MessageCheckStatus, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PublishMessage", arg0, arg1, arg2) ret := m.ctrl.Call(m, "PublishMessage", arg0, arg1, arg2)
ret0, _ := ret[0].(*types.SignedMessage) ret0, _ := ret[0].(*types.SignedMessage)
@ -114,7 +128,7 @@ func (mr *MockServicesAPIMockRecorder) PublishMessage(arg0, arg1, arg2 interface
} }
// RunChecksForPrototype mocks base method // RunChecksForPrototype mocks base method
func (m *MockServicesAPI) RunChecksForPrototype(arg0 context.Context, arg1 *types.Message) ([][]api.MessageCheckStatus, error) { func (m *MockServicesAPI) RunChecksForPrototype(arg0 context.Context, arg1 *api.MessagePrototype) ([][]api.MessageCheckStatus, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RunChecksForPrototype", arg0, arg1) ret := m.ctrl.Call(m, "RunChecksForPrototype", arg0, arg1)
ret0, _ := ret[0].([][]api.MessageCheckStatus) ret0, _ := ret[0].([][]api.MessageCheckStatus)

View File

@ -18,6 +18,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
@ -102,7 +104,28 @@ func TestWalletMsig(t *testing.T) {
// Create an msig with three of the addresses and threshold of two sigs // Create an msig with three of the addresses and threshold of two sigs
msigAddrs := walletAddrs[:3] msigAddrs := walletAddrs[:3]
amt := types.NewInt(1000) amt := types.NewInt(1000)
addProposal, err := lite.MsigCreate(ctx, 2, msigAddrs, abi.ChainEpoch(50), amt, liteWalletAddr, types.NewInt(0)) proto, err := lite.MsigCreate(ctx, 2, msigAddrs, abi.ChainEpoch(50), amt, liteWalletAddr, types.NewInt(0))
require.NoError(t, err)
doSend := func(proto *api.MessagePrototype) (cid.Cid, error) {
if proto.ValidNonce {
sm, err := lite.WalletSignMessage(ctx, proto.Message.From, &proto.Message)
if err != nil {
return cid.Undef, err
}
return lite.MpoolPush(ctx, sm)
}
sm, err := lite.MpoolPushMessage(ctx, &proto.Message, nil)
if err != nil {
return cid.Undef, err
}
return sm.Cid(), nil
}
addProposal, err := doSend(proto)
require.NoError(t, err) require.NoError(t, err)
res, err := lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true) res, err := lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true)
@ -122,7 +145,10 @@ func TestWalletMsig(t *testing.T) {
require.Less(t, msigBalance.Int64(), amt.Int64()) require.Less(t, msigBalance.Int64(), amt.Int64())
// Propose to add a new address to the msig // Propose to add a new address to the msig
addProposal, err = lite.MsigAddPropose(ctx, msig, walletAddrs[0], walletAddrs[3], false) proto, err = lite.MsigAddPropose(ctx, msig, walletAddrs[0], walletAddrs[3], false)
require.NoError(t, err)
addProposal, err = doSend(proto)
require.NoError(t, err) require.NoError(t, err)
res, err = lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true) res, err = lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true)
@ -136,7 +162,10 @@ func TestWalletMsig(t *testing.T) {
// Approve proposal (proposer is first (implicit) signer, approver is // Approve proposal (proposer is first (implicit) signer, approver is
// second signer // second signer
txnID := uint64(proposeReturn.TxnID) txnID := uint64(proposeReturn.TxnID)
approval1, err := lite.MsigAddApprove(ctx, msig, walletAddrs[1], txnID, walletAddrs[0], walletAddrs[3], false) proto, err = lite.MsigAddApprove(ctx, msig, walletAddrs[1], txnID, walletAddrs[0], walletAddrs[3], false)
require.NoError(t, err)
approval1, err := doSend(proto)
require.NoError(t, err) require.NoError(t, err)
res, err = lite.StateWaitMsg(ctx, approval1, 1, api.LookbackNoLimit, true) res, err = lite.StateWaitMsg(ctx, approval1, 1, api.LookbackNoLimit, true)

View File

@ -67,11 +67,13 @@ var verifRegAddVerifierCmd = &cli.Command{
return err return err
} }
api, closer, err := lcli.GetFullNodeAPI(cctx) srv, err := lcli.GetFullNodeServices(cctx)
if err != nil { if err != nil {
return err return err
} }
defer closer() defer srv.Close() //nolint:errcheck
api := srv.FullNodeAPI()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
vrk, err := api.StateVerifiedRegistryRootKey(ctx, types.EmptyTSK) vrk, err := api.StateVerifiedRegistryRootKey(ctx, types.EmptyTSK)
@ -79,14 +81,21 @@ var verifRegAddVerifierCmd = &cli.Command{
return err return err
} }
smsg, err := api.MsigPropose(ctx, vrk, verifreg.Address, big.Zero(), sender, uint64(verifreg.Methods.AddVerifier), params) proto, err := api.MsigPropose(ctx, vrk, verifreg.Address, big.Zero(), sender, uint64(verifreg.Methods.AddVerifier), params)
if err != nil { if err != nil {
return err return err
} }
fmt.Printf("message sent, now waiting on cid: %s\n", smsg) sm, _, err := srv.PublishMessage(ctx, proto, false)
if err != nil {
return err
}
mwait, err := api.StateWaitMsg(ctx, smsg, build.MessageConfidence) msgCid := sm.Cid()
fmt.Printf("message sent, now waiting on cid: %s\n", msgCid)
mwait, err := api.StateWaitMsg(ctx, msgCid, build.MessageConfidence)
if err != nil { if err != nil {
return err return err
} }

View File

@ -82,9 +82,6 @@
* [MpoolBatchPush](#MpoolBatchPush) * [MpoolBatchPush](#MpoolBatchPush)
* [MpoolBatchPushMessage](#MpoolBatchPushMessage) * [MpoolBatchPushMessage](#MpoolBatchPushMessage)
* [MpoolBatchPushUntrusted](#MpoolBatchPushUntrusted) * [MpoolBatchPushUntrusted](#MpoolBatchPushUntrusted)
* [MpoolCheckMessages](#MpoolCheckMessages)
* [MpoolCheckPendingMessages](#MpoolCheckPendingMessages)
* [MpoolCheckReplaceMessages](#MpoolCheckReplaceMessages)
* [MpoolClear](#MpoolClear) * [MpoolClear](#MpoolClear)
* [MpoolGetConfig](#MpoolGetConfig) * [MpoolGetConfig](#MpoolGetConfig)
* [MpoolGetNonce](#MpoolGetNonce) * [MpoolGetNonce](#MpoolGetNonce)
@ -1997,51 +1994,6 @@ Inputs:
Response: `null` Response: `null`
### MpoolCheckMessages
MpoolCheckMessages performs logical checks on a batch of messages
Perms: read
Inputs:
```json
[
null
]
```
Response: `null`
### MpoolCheckPendingMessages
MpoolCheckPendingMessages performs logical checks for all pending messages from a given address
Perms: read
Inputs:
```json
[
"f01234"
]
```
Response: `null`
### MpoolCheckReplaceMessages
MpoolCheckMessages performs logical checks on pending messages with replacement
Perms: read
Inputs:
```json
[
null
]
```
Response: `null`
### MpoolClear ### MpoolClear
MpoolClear clears pending messages from the mpool MpoolClear clears pending messages from the mpool

View File

@ -82,6 +82,9 @@
* [MpoolBatchPush](#MpoolBatchPush) * [MpoolBatchPush](#MpoolBatchPush)
* [MpoolBatchPushMessage](#MpoolBatchPushMessage) * [MpoolBatchPushMessage](#MpoolBatchPushMessage)
* [MpoolBatchPushUntrusted](#MpoolBatchPushUntrusted) * [MpoolBatchPushUntrusted](#MpoolBatchPushUntrusted)
* [MpoolCheckMessages](#MpoolCheckMessages)
* [MpoolCheckPendingMessages](#MpoolCheckPendingMessages)
* [MpoolCheckReplaceMessages](#MpoolCheckReplaceMessages)
* [MpoolClear](#MpoolClear) * [MpoolClear](#MpoolClear)
* [MpoolGetConfig](#MpoolGetConfig) * [MpoolGetConfig](#MpoolGetConfig)
* [MpoolGetNonce](#MpoolGetNonce) * [MpoolGetNonce](#MpoolGetNonce)
@ -1993,6 +1996,51 @@ Inputs:
Response: `null` Response: `null`
### MpoolCheckMessages
MpoolCheckMessages performs logical checks on a batch of messages
Perms: read
Inputs:
```json
[
null
]
```
Response: `null`
### MpoolCheckPendingMessages
MpoolCheckPendingMessages performs logical checks for all pending messages from a given address
Perms: read
Inputs:
```json
[
"f01234"
]
```
Response: `null`
### MpoolCheckReplaceMessages
MpoolCheckReplaceMessages performs logical checks on pending messages with replacement
Perms: read
Inputs:
```json
[
null
]
```
Response: `null`
### MpoolClear ### MpoolClear
MpoolClear clears pending messages from the mpool MpoolClear clears pending messages from the mpool
@ -2326,7 +2374,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2352,7 +2415,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2377,7 +2455,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2400,7 +2493,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2432,7 +2540,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2460,7 +2583,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2487,7 +2625,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2624,7 +2777,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2651,7 +2819,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2678,7 +2861,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2704,7 +2902,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```
@ -2729,7 +2942,22 @@ Inputs:
Response: Response:
```json ```json
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "Message": {
"Version": 42,
"To": "f01234",
"From": "f01234",
"Nonce": 42,
"Value": "0",
"GasLimit": 9,
"GasFeeCap": "0",
"GasPremium": "0",
"Method": 1,
"Params": "Ynl0ZSBhcnJheQ==",
"CID": {
"/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s"
}
},
"ValidNonce": true
} }
``` ```

View File

@ -14,7 +14,6 @@ import (
multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
"github.com/ipfs/go-cid"
"go.uber.org/fx" "go.uber.org/fx"
"golang.org/x/xerrors" "golang.org/x/xerrors"
) )
@ -37,134 +36,129 @@ func (a *MsigAPI) messageBuilder(ctx context.Context, from address.Address) (mul
// TODO: remove gp (gasPrice) from arguments // TODO: remove gp (gasPrice) from arguments
// TODO: Add "vesting start" to arguments. // TODO: Add "vesting start" to arguments.
func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) { func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (*api.MessagePrototype, error) {
mb, err := a.messageBuilder(ctx, src) mb, err := a.messageBuilder(ctx, src)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
msg, err := mb.Create(addrs, req, 0, duration, val) msg, err := mb.Create(addrs, req, 0, duration, val)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
// send the message out to the network return &api.MessagePrototype{
smsg, err := a.MpoolAPI.MpoolPushMessage(ctx, msg, nil) Message: *msg,
if err != nil { ValidNonce: false,
return cid.Undef, err }, nil
}
return smsg.Cid(), nil
} }
func (a *MsigAPI) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { func (a *MsigAPI) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*api.MessagePrototype, error) {
mb, err := a.messageBuilder(ctx, src) mb, err := a.messageBuilder(ctx, src)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
msg, err := mb.Propose(msig, to, amt, abi.MethodNum(method), params) msg, err := mb.Propose(msig, to, amt, abi.MethodNum(method), params)
if err != nil { if err != nil {
return cid.Undef, xerrors.Errorf("failed to create proposal: %w", err) return nil, xerrors.Errorf("failed to create proposal: %w", err)
} }
smsg, err := a.MpoolAPI.MpoolPushMessage(ctx, msg, nil) return &api.MessagePrototype{
if err != nil { Message: *msg,
return cid.Undef, xerrors.Errorf("failed to push message: %w", err) ValidNonce: false,
} }, nil
return smsg.Cid(), nil
} }
func (a *MsigAPI) MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) { func (a *MsigAPI) MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (*api.MessagePrototype, error) {
enc, actErr := serializeAddParams(newAdd, inc) enc, actErr := serializeAddParams(newAdd, inc)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc) return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
} }
func (a *MsigAPI) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) { func (a *MsigAPI) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (*api.MessagePrototype, error) {
enc, actErr := serializeAddParams(newAdd, inc) enc, actErr := serializeAddParams(newAdd, inc)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc) return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
} }
func (a *MsigAPI) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) { func (a *MsigAPI) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (*api.MessagePrototype, error) {
enc, actErr := serializeAddParams(newAdd, inc) enc, actErr := serializeAddParams(newAdd, inc)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc) return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
} }
func (a *MsigAPI) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) { func (a *MsigAPI) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (*api.MessagePrototype, error) {
enc, actErr := serializeSwapParams(oldAdd, newAdd) enc, actErr := serializeSwapParams(oldAdd, newAdd)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc) return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
} }
func (a *MsigAPI) MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) { func (a *MsigAPI) MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (*api.MessagePrototype, error) {
enc, actErr := serializeSwapParams(oldAdd, newAdd) enc, actErr := serializeSwapParams(oldAdd, newAdd)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc) return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
} }
func (a *MsigAPI) MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) { func (a *MsigAPI) MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (*api.MessagePrototype, error) {
enc, actErr := serializeSwapParams(oldAdd, newAdd) enc, actErr := serializeSwapParams(oldAdd, newAdd)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc) return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
} }
func (a *MsigAPI) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) { func (a *MsigAPI) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (*api.MessagePrototype, error) {
return a.msigApproveOrCancelSimple(ctx, api.MsigApprove, msig, txID, src) return a.msigApproveOrCancelSimple(ctx, api.MsigApprove, msig, txID, src)
} }
func (a *MsigAPI) MsigApproveTxnHash(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) MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*api.MessagePrototype, error) {
return a.msigApproveOrCancelTxnHash(ctx, api.MsigApprove, msig, txID, proposer, to, amt, src, method, params) return a.msigApproveOrCancelTxnHash(ctx, api.MsigApprove, msig, txID, proposer, to, amt, src, method, params)
} }
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) { 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) (*api.MessagePrototype, error) {
return a.msigApproveOrCancelTxnHash(ctx, api.MsigCancel, msig, txID, src, to, amt, src, method, params) return a.msigApproveOrCancelTxnHash(ctx, api.MsigCancel, msig, txID, src, to, amt, src, method, params)
} }
func (a *MsigAPI) MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) { func (a *MsigAPI) MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (*api.MessagePrototype, error) {
enc, actErr := serializeRemoveParams(toRemove, decrease) enc, actErr := serializeRemoveParams(toRemove, decrease)
if actErr != nil { if actErr != nil {
return cid.Undef, actErr return nil, actErr
} }
return a.MsigPropose(ctx, msig, msig, types.NewInt(0), proposer, uint64(multisig.Methods.RemoveSigner), enc) return a.MsigPropose(ctx, msig, msig, types.NewInt(0), proposer, uint64(multisig.Methods.RemoveSigner), enc)
} }
func (a *MsigAPI) msigApproveOrCancelSimple(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) { func (a *MsigAPI) msigApproveOrCancelSimple(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, src address.Address) (*api.MessagePrototype, error) {
if msig == address.Undef { if msig == address.Undef {
return cid.Undef, xerrors.Errorf("must provide multisig address") return nil, xerrors.Errorf("must provide multisig address")
} }
if src == address.Undef { if src == address.Undef {
return cid.Undef, xerrors.Errorf("must provide source address") return nil, xerrors.Errorf("must provide source address")
} }
mb, err := a.messageBuilder(ctx, src) mb, err := a.messageBuilder(ctx, src)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
var msg *types.Message var msg *types.Message
@ -174,34 +168,31 @@ func (a *MsigAPI) msigApproveOrCancelSimple(ctx context.Context, operation api.M
case api.MsigCancel: case api.MsigCancel:
msg, err = mb.Cancel(msig, txID, nil) msg, err = mb.Cancel(msig, txID, nil)
default: default:
return cid.Undef, xerrors.Errorf("Invalid operation for msigApproveOrCancel") return nil, xerrors.Errorf("Invalid operation for msigApproveOrCancel")
} }
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
smsg, err := a.MpoolAPI.MpoolPushMessage(ctx, msg, nil) return &api.MessagePrototype{
if err != nil { Message: *msg,
return cid.Undef, err ValidNonce: false,
} }, nil
return smsg.Cid(), nil
} }
func (a *MsigAPI) msigApproveOrCancelTxnHash(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) msigApproveOrCancelTxnHash(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) (*api.MessagePrototype, error) {
if msig == address.Undef { if msig == address.Undef {
return cid.Undef, xerrors.Errorf("must provide multisig address") return nil, xerrors.Errorf("must provide multisig address")
} }
if src == address.Undef { if src == address.Undef {
return cid.Undef, xerrors.Errorf("must provide source address") return nil, xerrors.Errorf("must provide source address")
} }
if proposer.Protocol() != address.ID { if proposer.Protocol() != address.ID {
proposerID, err := a.StateAPI.StateLookupID(ctx, proposer, types.EmptyTSK) proposerID, err := a.StateAPI.StateLookupID(ctx, proposer, types.EmptyTSK)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
proposer = proposerID proposer = proposerID
} }
@ -216,7 +207,7 @@ func (a *MsigAPI) msigApproveOrCancelTxnHash(ctx context.Context, operation api.
mb, err := a.messageBuilder(ctx, src) mb, err := a.messageBuilder(ctx, src)
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
var msg *types.Message var msg *types.Message
@ -226,18 +217,16 @@ func (a *MsigAPI) msigApproveOrCancelTxnHash(ctx context.Context, operation api.
case api.MsigCancel: case api.MsigCancel:
msg, err = mb.Cancel(msig, txID, &p) msg, err = mb.Cancel(msig, txID, &p)
default: default:
return cid.Undef, xerrors.Errorf("Invalid operation for msigApproveOrCancel") return nil, xerrors.Errorf("Invalid operation for msigApproveOrCancel")
} }
if err != nil { if err != nil {
return cid.Undef, err return nil, err
} }
smsg, err := a.MpoolAPI.MpoolPushMessage(ctx, msg, nil) return &api.MessagePrototype{
if err != nil { Message: *msg,
return cid.Undef, err ValidNonce: false,
} }, nil
return smsg.Cid(), nil
} }
func serializeAddParams(new address.Address, inc bool) ([]byte, error) { func serializeAddParams(new address.Address, inc bool) ([]byte, error) {