forked from filecoin-project/go-state-types
/
multisig_types.go
110 lines (92 loc) · 2.76 KB
/
multisig_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package multisig
import (
"bytes"
"github.com/CluEleSsUK/go-state-types/exitcode"
"github.com/CluEleSsUK/go-state-types/abi"
addr "github.com/filecoin-project/go-address"
)
type TxnID int64
type Transaction struct {
To addr.Address
Value abi.TokenAmount
Method abi.MethodNum
Params []byte
// This address at index 0 is the transaction proposer, order of this slice must be preserved.
Approved []addr.Address
}
//Data for a BLAKE2B-256 to be attached to methods referencing proposals via TXIDs.
//Ensures the existence of a cryptographic reference to the original proposal. Useful
//for offline signers and for protection when reorgs change a multisig TXID.
//
//Requester - The requesting multisig wallet member.
//All other fields - From the "Transaction" struct.
type ProposalHashData struct {
Requester addr.Address
To addr.Address
Value abi.TokenAmount
Method abi.MethodNum
Params []byte
}
type ConstructorParams struct {
Signers []addr.Address
NumApprovalsThreshold uint64
UnlockDuration abi.ChainEpoch
StartEpoch abi.ChainEpoch
}
type ProposeParams struct {
To addr.Address
Value abi.TokenAmount
Method abi.MethodNum
Params []byte
}
type ProposeReturn struct {
// TxnID is the ID of the proposed transaction
TxnID TxnID
// Applied indicates if the transaction was applied as opposed to proposed but not applied due to lack of approvals
Applied bool
// Code is the exitcode of the transaction, if Applied is false this field should be ignored.
Code exitcode.ExitCode
// Ret is the return vale of the transaction, if Applied is false this field should be ignored.
Ret []byte
}
type TxnIDParams struct {
ID TxnID
// Optional hash of proposal to ensure an operation can only apply to a
// specific proposal.
ProposalHash []byte
}
type ApproveReturn struct {
// Applied indicates if the transaction was applied as opposed to proposed but not applied due to lack of approvals
Applied bool
// Code is the exitcode of the transaction, if Applied is false this field should be ignored.
Code exitcode.ExitCode
// Ret is the return vale of the transaction, if Applied is false this field should be ignored.
Ret []byte
}
type AddSignerParams struct {
Signer addr.Address
Increase bool
}
type RemoveSignerParams struct {
Signer addr.Address
Decrease bool
}
type SwapSignerParams struct {
From addr.Address
To addr.Address
}
type ChangeNumApprovalsThresholdParams struct {
NewThreshold uint64
}
type LockBalanceParams struct {
StartEpoch abi.ChainEpoch
UnlockDuration abi.ChainEpoch
Amount abi.TokenAmount
}
func (phd *ProposalHashData) Serialize() ([]byte, error) {
buf := new(bytes.Buffer)
if err := phd.MarshalCBOR(buf); err != nil {
return nil, err
}
return buf.Bytes(), nil
}