Skip to content

Commit

Permalink
fix Python typings Mintlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
OBorce committed Sep 11, 2024
1 parent 0829525 commit c297902
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 488 deletions.
55 changes: 47 additions & 8 deletions core/embed/extmod/modtrezormintlayer/modtrezormintlayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,60 @@

// #if MICROPY_PY_TREZORMINTLAYER

#include "modtrezormintlayer-utils.h"
#include "modtrezormintlayer.h"

STATIC const mp_rom_map_elem_t mp_module_trezormintlayer_globals_table[] = {
STATIC const mp_rom_map_elem_t mod_trezormintlayer_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_trezormintlayer)},
{MP_ROM_QSTR(MP_QSTR_utils), MP_ROM_PTR(&mod_trezormintlayer_utils_module)},
{MP_ROM_QSTR(MP_QSTR_encode_utxo_input),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_utxo_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_account_spending_input),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_account_spending_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_account_command_input),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_account_command_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_transfer_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_transfer_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_lock_then_transfer_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_burn_output),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_burn_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_create_stake_pool_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_produce_from_stake_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_create_delegation_id_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_delegate_staking_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_issue_fungible_token_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_issue_nft_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_data_deposit_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_htlc_output),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_htlc_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_compact_length),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_comact_length_obj)},
};
STATIC MP_DEFINE_CONST_DICT(mp_module_trezormintlayer_globals,
mp_module_trezormintlayer_globals_table);
STATIC MP_DEFINE_CONST_DICT(mod_trezormintlayer_globals,
mod_trezormintlayer_globals_table);

const mp_obj_module_t mp_module_trezormintlayer = {
STATIC const mp_obj_module_t mp_module_trezormintlayer = {
.base = {&mp_type_module},
.globals = (mp_obj_dict_t *)&mp_module_trezormintlayer_globals,
.globals = (mp_obj_dict_t *)&mod_trezormintlayer_globals,
};

MP_REGISTER_MODULE(MP_QSTR_trezormintlayer, mp_module_trezormintlayer);

// #endif // MICROPY_PY_TREZORMINTLAYER

Original file line number Diff line number Diff line change
Expand Up @@ -578,55 +578,3 @@ mod_trezormintlayer_utils_mintlayer_encode_comact_length(mp_obj_t length) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(
mod_trezormintlayer_utils_mintlayer_encode_comact_length_obj,
mod_trezormintlayer_utils_mintlayer_encode_comact_length);

STATIC const mp_rom_map_elem_t mod_trezormintlayer_utils_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bip32)},
{MP_ROM_QSTR(MP_QSTR_encode_utxo_input),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_utxo_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_account_spending_input),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_account_spending_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_account_command_input),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_account_command_input_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_transfer_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_transfer_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_lock_then_transfer_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_burn_output),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_burn_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_create_stake_pool_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_produce_from_stake_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_create_delegation_id_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_delegate_staking_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_issue_fungible_token_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_issue_nft_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_data_deposit_output),
MP_ROM_PTR(
&mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_htlc_output),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_htlc_output_obj)},
{MP_ROM_QSTR(MP_QSTR_encode_compact_length),
MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_comact_length_obj)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezormintlayer_utils_globals,
mod_trezormintlayer_utils_globals_table);

STATIC const mp_obj_module_t mod_trezormintlayer_utils_module = {
.base = {&mp_type_module},
.globals = (mp_obj_dict_t *)&mod_trezormintlayer_utils_globals,
};
30 changes: 15 additions & 15 deletions core/mocks/generated/trezormintlayer.pyi
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
from typing import *


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_utxo_input(tx_hash: bytes, index: int, utxo_type: int) -> bytes:
"""
encodes an utxo input from tx_hash and index
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_account_spending_input(nonce: int, delegation_id: str, amount:
bytes) -> bytes:
"""
encodes an utxo account spendinf from nonce and delegation id
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_account_command_input(nonce: int, command: int token_id: str,
data: bytes) -> bytes:
"""
encodes an account command from the nonce, command, token id and additional command data
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_transfer_output(amount: str, token_id: str, address: str) ->
bytes:
"""
encodes a transfer output with given amount and destination address
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_lock_then_transfer_output(amount: str, token_id: str, lock_type:
int, lock_amount:int, address: str) -> bytes:
"""
encodes a transfer output with given amount, lock type and amount, and destination address
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_burn_output(amount: str, token_id: str) ->
bytes:
"""
encodes a burn output with given amount
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_create_stake_pool_output(pool_id: str, pledge_amount: str,
staker: str, vrf_public_key: str, decommission_key: str,
margin_ratio_per_thousand: int, cost_per_block: str) -> bytes:
Expand All @@ -57,31 +57,31 @@ margin_ratio_per_thousand: int, cost_per_block: str) -> bytes:
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_produce_from_stake_output(destination: str, pool_id: str) ->
bytes:
"""
encodes a produce from stake output
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_create_delegation_id_output(destination: str, pool_id: str) ->
bytes:
"""
encodes a create delegation id output
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_delegate_staking_output(amount: str, delegation_id: str) ->
bytes:
"""
encodes a delegation staking output, given the amount and delegation id
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_issue_fungible_token_output(token_ticker: str,
number_of_decimals: int, metadata_uri: str, total_supply_type: int,
fixed_amount: str, authority: str, is_freezable: int) -> bytes:
Expand All @@ -90,7 +90,7 @@ fixed_amount: str, authority: str, is_freezable: int) -> bytes:
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_issue_nft_output(token_id: str,
creator: str, name: str, destination: str,
ticker: str, icon_uri: str, additional_metadata_uri: str, media_uri: str,
Expand All @@ -100,15 +100,15 @@ media_hash: str, destination: str) -> bytes:
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_data_deposit_output(deposit: str) ->
bytes:
"""
encodes a data deposit output
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_htlc_output(amount: str, token_id: str, lock_type:
int, lock_amount:int, refund_key: str, spend_key: str, secret_has: bytes) ->
bytes:
Expand All @@ -117,7 +117,7 @@ bytes:
"""


# extmod/modtrezormintlayer/modtrezormintlayer-utils.h
# extmod/modtrezormintlayer/modtrezormintlayer.h
def encode_compact_length(length: int) -> bytes:
"""
encodes a comapct length to bytes
Expand Down
2 changes: 0 additions & 2 deletions core/src/all_modules.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c297902

Please sign in to comment.