@@ -125,14 +125,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(
125
125
mod_trezormintlayer_utils_mintlayer_encode_account_spending_input_obj ,
126
126
mod_trezormintlayer_utils_mintlayer_encode_account_spending_input );
127
127
128
- /// def encode_account_command_input (nonce: int, command: int, token_id: bytes,
129
- /// data: bytes) -> bytes:
128
+ /// def encode_token_account_command_input (nonce: int, command: int, token_id:
129
+ /// bytes, data: bytes) -> bytes:
130
130
/// """
131
131
/// encodes an account command from the nonce, command, token id and
132
132
/// additional command data
133
133
/// """
134
134
STATIC mp_obj_t
135
- mod_trezormintlayer_utils_mintlayer_encode_account_command_input (
135
+ mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input (
136
136
size_t n_args , const mp_obj_t * args ) {
137
137
uint64_t nonce = trezor_obj_get_uint64 (args [0 ]);
138
138
uint32_t command = trezor_obj_get_uint (args [1 ]);
@@ -147,7 +147,7 @@ mod_trezormintlayer_utils_mintlayer_encode_account_command_input(
147
147
mp_buffer_info_t data = {0 };
148
148
mp_get_buffer_raise (args [3 ], & data , MP_BUFFER_READ );
149
149
150
- ByteArray arr = mintlayer_encode_account_command_input (
150
+ ByteArray arr = mintlayer_encode_token_account_command_input (
151
151
nonce , command , hash .buf , hash .len , data .buf , data .len );
152
152
handle_err (& arr );
153
153
@@ -162,8 +162,79 @@ mod_trezormintlayer_utils_mintlayer_encode_account_command_input(
162
162
}
163
163
164
164
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (
165
- mod_trezormintlayer_utils_mintlayer_encode_account_command_input_obj , 4 , 4 ,
166
- mod_trezormintlayer_utils_mintlayer_encode_account_command_input );
165
+ mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input_obj ,
166
+ 4 , 4 ,
167
+ mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input );
168
+
169
+ /// def encode_conclude_order_account_command_input(nonce: int, order_id: bytes)
170
+ /// -> bytes:
171
+ /// """
172
+ /// encodes an conclude order account command from the nonce and order id
173
+ /// """
174
+ STATIC mp_obj_t
175
+ mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input (
176
+ mp_obj_t nonce_obj , mp_obj_t order_id_obj ) {
177
+ uint64_t nonce = trezor_obj_get_uint64 (nonce_obj );
178
+ mp_buffer_info_t order_id = {0 };
179
+ mp_get_buffer_raise (order_id_obj , & order_id , MP_BUFFER_READ );
180
+
181
+ ByteArray arr = mintlayer_encode_conclude_order_account_command_input (
182
+ nonce , order_id .buf , order_id .len );
183
+ handle_err (& arr );
184
+
185
+ vstr_t pkh = {0 };
186
+ vstr_init_len (& pkh , arr .len_or_err .len );
187
+ int i = 0 ;
188
+ for (; i < arr .len_or_err .len ; i ++ ) {
189
+ ((uint8_t * )pkh .buf )[i ] = (uint8_t )arr .data [i ];
190
+ }
191
+
192
+ return mp_obj_new_str_from_vstr (& mp_type_bytes , & pkh );
193
+ }
194
+
195
+ STATIC MP_DEFINE_CONST_FUN_OBJ_2 (
196
+ mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input_obj ,
197
+ mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input );
198
+
199
+ /// def encode_fill_order_account_command_input(nonce: int, order_id: bytes,
200
+ /// amount: bytes, token_id: bytes, destination: bytes)
201
+ /// -> bytes:
202
+ /// """
203
+ /// encodes an fill order account command from the nonce, order id, output
204
+ /// value and destination
205
+ /// """
206
+ STATIC mp_obj_t
207
+ mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input (
208
+ size_t n_args , const mp_obj_t * args ) {
209
+ uint64_t nonce = trezor_obj_get_uint64 (args [0 ]);
210
+ mp_buffer_info_t order_id = {0 };
211
+ mp_get_buffer_raise (args [1 ], & order_id , MP_BUFFER_READ );
212
+ mp_buffer_info_t amount = {0 };
213
+ mp_get_buffer_raise (args [2 ], & amount , MP_BUFFER_READ );
214
+ mp_buffer_info_t token_id = {0 };
215
+ mp_get_buffer_raise (args [3 ], & token_id , MP_BUFFER_READ );
216
+ mp_buffer_info_t destination = {0 };
217
+ mp_get_buffer_raise (args [4 ], & destination , MP_BUFFER_READ );
218
+
219
+ ByteArray arr = mintlayer_encode_fill_order_account_command_input (
220
+ nonce , order_id .buf , order_id .len , amount .buf , amount .len , token_id .buf ,
221
+ token_id .len , destination .buf , destination .len );
222
+ handle_err (& arr );
223
+
224
+ vstr_t pkh = {0 };
225
+ vstr_init_len (& pkh , arr .len_or_err .len );
226
+ int i = 0 ;
227
+ for (; i < arr .len_or_err .len ; i ++ ) {
228
+ ((uint8_t * )pkh .buf )[i ] = (uint8_t )arr .data [i ];
229
+ }
230
+
231
+ return mp_obj_new_str_from_vstr (& mp_type_bytes , & pkh );
232
+ }
233
+
234
+ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (
235
+ mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input_obj ,
236
+ 5 , 5 ,
237
+ mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input );
167
238
168
239
/// def encode_transfer_output(amount: bytes, token_id: bytes, address: bytes)
169
240
/// -> bytes:
@@ -557,6 +628,46 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
557
628
mod_trezormintlayer_utils_mintlayer_encode_htlc_output_obj , 5 , 5 ,
558
629
mod_trezormintlayer_utils_mintlayer_encode_htlc_output );
559
630
631
+ /// def encode_anyone_can_take_output(destination: bytes, ask_amount: bytes,
632
+ /// ask_token_id: bytes, give_amount: bytes, give_token_id: bytes) -> bytes:
633
+ /// """
634
+ /// encodes an anyone can take output with given the conclude key, give and
635
+ /// take amounts
636
+ /// """
637
+ STATIC mp_obj_t
638
+ mod_trezormintlayer_utils_mintlayer_encode_anyone_can_take_output (
639
+ size_t n_args , const mp_obj_t * args ) {
640
+ mp_buffer_info_t conclude_key = {0 };
641
+ mp_get_buffer_raise (args [0 ], & conclude_key , MP_BUFFER_READ );
642
+ mp_buffer_info_t ask_amount = {0 };
643
+ mp_get_buffer_raise (args [1 ], & ask_amount , MP_BUFFER_READ );
644
+ mp_buffer_info_t ask_token_id = {0 };
645
+ mp_get_buffer_raise (args [2 ], & ask_token_id , MP_BUFFER_READ );
646
+ mp_buffer_info_t give_amount = {0 };
647
+ mp_get_buffer_raise (args [3 ], & give_amount , MP_BUFFER_READ );
648
+ mp_buffer_info_t give_token_id = {0 };
649
+ mp_get_buffer_raise (args [4 ], & give_token_id , MP_BUFFER_READ );
650
+
651
+ ByteArray arr = mintlayer_encode_anyone_can_take_output (
652
+ conclude_key .buf , conclude_key .len , ask_amount .buf , ask_amount .len ,
653
+ ask_token_id .buf , ask_token_id .len , give_amount .buf , give_amount .len ,
654
+ give_token_id .buf , give_token_id .len );
655
+ handle_err (& arr );
656
+
657
+ vstr_t encoding = {0 };
658
+ vstr_init_len (& encoding , arr .len_or_err .len );
659
+ int i = 0 ;
660
+ for (; i < arr .len_or_err .len ; i ++ ) {
661
+ ((uint8_t * )encoding .buf )[i ] = (uint8_t )arr .data [i ];
662
+ }
663
+
664
+ return mp_obj_new_str_from_vstr (& mp_type_bytes , & encoding );
665
+ }
666
+
667
+ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (
668
+ mod_trezormintlayer_utils_mintlayer_encode_anyone_can_take_output_obj , 5 , 5 ,
669
+ mod_trezormintlayer_utils_mintlayer_encode_anyone_can_take_output );
670
+
560
671
/// def encode_compact_length(length: int) -> bytes:
561
672
/// """
562
673
/// encodes a comapct length to bytes
0 commit comments