mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-19 14:08:11 +00:00
refactor(core/solana): use local constants
[no changelog]
This commit is contained in:
parent
1c5d47a875
commit
90eef5331a
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
# generated from instructions.py.mako
|
# generated from instructions.py.mako
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
<%def name="getProgramId(program)">${"_".join(program["name"].upper().split(" ") + ["ID"])}</%def>\
|
<%def name="getProgramId(program)">${"_" + "_".join(program["name"].upper().split(" ") + ["ID"])}</%def>\
|
||||||
<%def name="getInstructionIdText(program, instruction)">${"_".join([getProgramId(program)] + ["INS"] + instruction["name"].upper().split(" "))}</%def>\
|
<%def name="getInstructionIdText(program, instruction)">${"_".join([getProgramId(program)] + ["INS"] + instruction["name"].upper().split(" "))}</%def>\
|
||||||
<%def name="getClassName(program, instruction)">${program["name"].replace(" ", "")}${instruction["name"].replace(" ", "")}Instruction</%def>\
|
<%def name="getClassName(program, instruction)">${program["name"].replace(" ", "")}${instruction["name"].replace(" ", "")}Instruction</%def>\
|
||||||
<%def name="getReferenceName(reference)">${"_".join(reference["name"].lower().split(" "))}</%def>\
|
<%def name="getReferenceName(reference)">${"_".join(reference["name"].lower().split(" "))}</%def>\
|
||||||
@ -27,6 +27,7 @@ str\
|
|||||||
int\
|
int\
|
||||||
% endif
|
% endif
|
||||||
</%def>\
|
</%def>\
|
||||||
|
from micropython import const
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from trezor.wire import DataError
|
from trezor.wire import DataError
|
||||||
@ -61,10 +62,18 @@ ${getProgramId(program)} = "${program["id"]}"
|
|||||||
|
|
||||||
% for program in programs["programs"]:
|
% for program in programs["programs"]:
|
||||||
% for instruction in program["instructions"]:
|
% for instruction in program["instructions"]:
|
||||||
|
% if isinstance(instruction["id"], int):
|
||||||
|
${getInstructionIdText(program, instruction)} = const(${instruction["id"]})
|
||||||
|
% else:
|
||||||
${getInstructionIdText(program, instruction)} = ${instruction["id"]}
|
${getInstructionIdText(program, instruction)} = ${instruction["id"]}
|
||||||
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
|
COMPUTE_BUDGET_PROGRAM_ID = _COMPUTE_BUDGET_PROGRAM_ID
|
||||||
|
COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT = _COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT
|
||||||
|
COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE = _COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE
|
||||||
|
|
||||||
def __getattr__(name: str) -> Type[Instruction]:
|
def __getattr__(name: str) -> Type[Instruction]:
|
||||||
def get_id(name: str) -> tuple[str, InstructionId]:
|
def get_id(name: str) -> tuple[str, InstructionId]:
|
||||||
%for program in programs["programs"]:
|
%for program in programs["programs"]:
|
||||||
|
@ -4,17 +4,15 @@ from trezor.crypto import base58
|
|||||||
|
|
||||||
from apps.solana.predefined_transaction import is_predefined_token_transfer
|
from apps.solana.predefined_transaction import is_predefined_token_transfer
|
||||||
from apps.solana.transaction.instruction import Instruction
|
from apps.solana.transaction.instruction import Instruction
|
||||||
from apps.solana.transaction.instructions import (
|
|
||||||
ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID,
|
|
||||||
ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE,
|
|
||||||
SYSTEM_PROGRAM_ID,
|
|
||||||
SYSTEM_PROGRAM_ID_INS_TRANSFER,
|
|
||||||
TOKEN_2022_PROGRAM_ID,
|
|
||||||
TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED,
|
|
||||||
TOKEN_PROGRAM_ID,
|
|
||||||
TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||||
|
ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE = None
|
||||||
|
SYSTEM_PROGRAM_ID = "11111111111111111111111111111111"
|
||||||
|
SYSTEM_PROGRAM_ID_INS_TRANSFER = 2
|
||||||
|
TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
||||||
|
TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED = 12
|
||||||
|
TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
||||||
|
TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED = 12
|
||||||
|
|
||||||
def create_mock_instruction(
|
def create_mock_instruction(
|
||||||
program_id: str, instruction_id: int, parsed_data: dict[str, Any]
|
program_id: str, instruction_id: int, parsed_data: dict[str, Any]
|
||||||
|
Loading…
Reference in New Issue
Block a user