|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "py/objstr.h"
|
|
|
|
|
#include "py/runtime.h"
|
|
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
@ -115,6 +116,18 @@ STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) {
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_halt_obj, 0, 1,
|
|
|
|
|
mod_trezorutils_halt);
|
|
|
|
|
|
|
|
|
|
/// def decode_bytes(b: bytes) -> str:
|
|
|
|
|
/// """
|
|
|
|
|
/// Decodes string from bytes
|
|
|
|
|
/// """
|
|
|
|
|
STATIC mp_obj_t mod_trezorutils_decode_bytes(mp_obj_t b) {
|
|
|
|
|
mp_buffer_info_t bytes;
|
|
|
|
|
mp_get_buffer_raise(b, &bytes, MP_BUFFER_READ);
|
|
|
|
|
return mp_obj_new_str_copy(&mp_type_str, bytes.buf, bytes.len);
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorutils_decode_bytes_obj,
|
|
|
|
|
mod_trezorutils_decode_bytes);
|
|
|
|
|
|
|
|
|
|
#define PASTER(s) MP_QSTR_##s
|
|
|
|
|
#define MP_QSTR(s) PASTER(s)
|
|
|
|
|
|
|
|
|
@ -131,6 +144,8 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_consteq), MP_ROM_PTR(&mod_trezorutils_consteq_obj)},
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_memcpy), MP_ROM_PTR(&mod_trezorutils_memcpy_obj)},
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&mod_trezorutils_halt_obj)},
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_decode_bytes),
|
|
|
|
|
MP_ROM_PTR(&mod_trezorutils_decode_bytes_obj)},
|
|
|
|
|
// various built-in constants
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_GITREV), MP_ROM_QSTR(MP_QSTR(GITREV))},
|
|
|
|
|
{MP_ROM_QSTR(MP_QSTR_VERSION_MAJOR), MP_ROM_INT(VERSION_MAJOR)},
|
|
|
|
|