6
6
#include < eosio/transaction.hpp>
7
7
8
8
namespace eosio {
9
- /* *
10
- * Clone of `eosio::binary_extension` that includes `operator=` to avoid
11
- * bumping the `eosio.cdt` dependency version of the v1.8.x patch release of
12
- * `eosio.contracts`.
13
- */
14
- template <typename T>
15
- class eosio_msig_binary_extension {
16
- public:
17
- using value_type = T;
18
-
19
- constexpr eosio_msig_binary_extension () {}
20
- constexpr eosio_msig_binary_extension ( const T& ext )
21
- :_has_value(true )
22
- {
23
- ::new (&_data) T (ext);
24
- }
25
- constexpr eosio_msig_binary_extension ( T&& ext )
26
- :_has_value(true )
27
- {
28
- ::new (&_data) T (std::move (ext));
29
- }
30
- /* * construct contained type in place */
31
- template <typename ... Args>
32
- constexpr eosio_msig_binary_extension ( std::in_place_t , Args&&... args )
33
- :_has_value(true )
34
- {
35
- ::new (&_data) T (std::forward<Args>(args)...);
36
- }
37
-
38
- constexpr eosio_msig_binary_extension ( const eosio_msig_binary_extension& other )
39
- :_has_value(other._has_value)
40
- {
41
- if ( other._has_value ) ::new (&_data) T ( *other );
42
- }
43
-
44
- constexpr eosio_msig_binary_extension ( eosio_msig_binary_extension&& other )
45
- :_has_value(other._has_value)
46
- {
47
- if ( other._has_value ) {
48
- ::new (&_data) T ( *std::move (other) );
49
- other._has_value = false ;
50
- }
51
- }
52
-
53
- // / @cond INTERNAL
54
- ~eosio_msig_binary_extension () { reset (); }
55
-
56
- // / @cond INTERNAL
57
- constexpr eosio_msig_binary_extension& operator = (const eosio_msig_binary_extension& other) {
58
- if (has_value ())
59
- reset ();
60
-
61
- if (other.has_value ()) {
62
- ::new (&_data) T (*other);
63
- _has_value = true ;
64
- }
65
- return *this ;
66
- }
67
-
68
- // / @cond INTERNAL
69
- constexpr eosio_msig_binary_extension& operator = (eosio_msig_binary_extension&& other) {
70
- if (has_value ())
71
- reset ();
72
-
73
- if (other.has_value ()) {
74
- ::new (&_data) T (*other);
75
- _has_value = true ;
76
- other._has_value = false ;
77
- }
78
- return *this ;
79
- }
80
- /* * test if container is holding a value */
81
- constexpr explicit operator bool ()const { return _has_value; }
82
- /* * test if container is holding a value */
83
- constexpr bool has_value ()const { return _has_value; }
84
-
85
- /* * get the contained value */
86
- constexpr T& value ()& {
87
- if (!_has_value) {
88
- check (false , " cannot get value of empty eosio_msig_binary_extension" );
89
- }
90
- return _get ();
91
- }
92
-
93
- // / @cond INTERNAL
94
-
95
- /* * get the contained value */
96
- constexpr const T& value ()const & {
97
- if (!_has_value) {
98
- check (false , " cannot get value of empty eosio_msig_binary_extension" );
99
- }
100
- return _get ();
101
- }
102
-
103
- /* * get the contained value or a user specified default
104
- * @pre def should be convertible to type T
105
- * */
106
- template <typename U>
107
- constexpr auto value_or ( U&& def ) -> std::enable_if_t<std::is_convertible<U, T>::value, T&>& {
108
- if (_has_value)
109
- return _get ();
110
- return def;
111
- }
112
-
113
- constexpr T value_or () const { return (_has_value) ? _get () : T{}; }
114
-
115
- constexpr T* operator ->() {
116
- return &_get ();
117
- }
118
- constexpr const T* operator ->()const {
119
- return &_get ();
120
- }
121
-
122
- constexpr T& operator *()& {
123
- return _get ();
124
- }
125
- constexpr const T& operator *()const & {
126
- return _get ();
127
- }
128
- constexpr const T&& operator *()const && {
129
- return std::move (_get ());
130
- }
131
- constexpr T&& operator *()&& {
132
- return std::move (_get ());
133
- }
134
-
135
- template <typename ...Args>
136
- T& emplace (Args&& ... args)& {
137
- if (_has_value) {
138
- reset ();
139
- }
140
-
141
- ::new (&_data) T ( std::forward<Args>(args)... );
142
- _has_value = true ;
143
-
144
- return _get ();
145
- }
146
-
147
- void reset () {
148
- if ( _has_value ) {
149
- _get ().~value_type ();
150
- _has_value = false ;
151
- }
152
- }
153
-
154
- // / @endcond
155
-
156
- private:
157
- bool _has_value = false ;
158
- typename std::aligned_storage<sizeof (T), alignof(T)>::type _data;
159
-
160
- constexpr T& _get () {
161
- return *reinterpret_cast <T*>(&_data);
162
- }
163
-
164
- constexpr const T& _get ()const {
165
- return *reinterpret_cast <const T*>(&_data);
166
- }
167
- };
168
-
169
9
// / @cond IMPLEMENTATIONS
170
10
171
- /* *
172
- * Serialize a eosio_msig_binary_extension into a stream
173
- *
174
- * @ingroup eosio_msig_binary_extension
175
- * @brief Serialize a eosio_msig_binary_extension
176
- * @param ds - The stream to write
177
- * @param opt - The value to serialize
178
- * @tparam DataStream - Type of datastream buffer
179
- * @return DataStream& - Reference to the datastream
180
- */
181
- template <typename DataStream, typename T>
182
- inline DataStream& operator <<(DataStream& ds, const eosio::eosio_msig_binary_extension<T>& be) {
183
- ds << be.value_or ();
184
- return ds;
185
- }
186
-
187
- /* *
188
- * Deserialize a eosio_msig_binary_extension from a stream
189
- *
190
- * @ingroup eosio_msig_binary_extension
191
- * @brief Deserialize a eosio_msig_binary_extension
192
- * @param ds - The stream to read
193
- * @param opt - The destination for deserialized value
194
- * @tparam DataStream - Type of datastream buffer
195
- * @return DataStream& - Reference to the datastream
196
- */
197
- template <typename DataStream, typename T>
198
- inline DataStream& operator >>(DataStream& ds, eosio::eosio_msig_binary_extension<T>& be) {
199
- if ( ds.remaining () ) {
200
- T val;
201
- ds >> val;
202
- be.emplace (val);
203
- }
204
- return ds;
205
- }
206
-
207
11
/* *
208
12
* The `eosio.msig` system contract allows for creation of proposed transactions which require authorization from a list of accounts, approval of the proposed transactions by those accounts required to approve it, and finally, it also allows the execution of the approved transactions on the blockchain.
209
13
*
@@ -311,16 +115,16 @@ namespace eosio {
311
115
using invalidate_action = eosio::action_wrapper<" invalidate" _n, &multisig::invalidate>;
312
116
};
313
117
314
- struct [[eosio::table]] proposal {
118
+ struct [[eosio::table, eosio::contract( " eosio.msig " ) ]] proposal {
315
119
name proposal_name;
316
120
std::vector<char > packed_transaction;
317
- eosio::eosio_msig_binary_extension < std::optional<time_point> > earliest_exec_time;
121
+ eosio::binary_extension < std::optional<time_point> > earliest_exec_time;
318
122
319
123
uint64_t primary_key ()const { return proposal_name.value ; }
320
124
};
321
125
typedef eosio::multi_index< " proposal" _n, proposal > proposals;
322
126
323
- struct [[eosio::table]] old_approvals_info {
127
+ struct [[eosio::table, eosio::contract( " eosio.msig " ) ]] old_approvals_info {
324
128
name proposal_name;
325
129
std::vector<permission_level> requested_approvals;
326
130
std::vector<permission_level> provided_approvals;
@@ -334,7 +138,7 @@ namespace eosio {
334
138
time_point time;
335
139
};
336
140
337
- struct [[eosio::table]] approvals_info {
141
+ struct [[eosio::table, eosio::contract( " eosio.msig " ) ]] approvals_info {
338
142
uint8_t version = 1 ;
339
143
name proposal_name;
340
144
// requested approval doesn't need to contain time, but we want requested approval
@@ -347,7 +151,7 @@ namespace eosio {
347
151
};
348
152
typedef eosio::multi_index< " approvals2" _n, approvals_info > approvals;
349
153
350
- struct [[eosio::table]] invalidation {
154
+ struct [[eosio::table, eosio::contract( " eosio.msig " ) ]] invalidation {
351
155
name account;
352
156
time_point last_invalidation_time;
353
157
0 commit comments