mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 03:18:09 +00:00
src/apps/wallet/sign_tx: use visual progress
This commit is contained in:
parent
9549ef9865
commit
5ec3ef7835
@ -1,13 +1,12 @@
|
||||
from trezor import wire
|
||||
from trezor import ui, wire
|
||||
from trezor.messages.RequestType import TXFINISHED
|
||||
from trezor.messages.wire_types import TxAck
|
||||
from apps.common import seed
|
||||
|
||||
|
||||
@ui.layout
|
||||
async def sign_tx(ctx, msg):
|
||||
from trezor.messages.RequestType import TXFINISHED
|
||||
from trezor.messages.wire_types import TxAck
|
||||
|
||||
from apps.common import seed
|
||||
from . import signing
|
||||
from . import layout
|
||||
from apps.wallet.sign_tx import layout, progress, signing
|
||||
|
||||
# TODO: rework this so we don't have to pass root to signing.sign_tx
|
||||
root = await seed.derive_node(ctx, [])
|
||||
@ -33,10 +32,13 @@ async def sign_tx(ctx, msg):
|
||||
res = await ctx.call(req, TxAck)
|
||||
elif req.__qualname__ == 'UiConfirmOutput':
|
||||
res = await layout.confirm_output(ctx, req.output, req.coin)
|
||||
progress.report_init()
|
||||
elif req.__qualname__ == 'UiConfirmTotal':
|
||||
res = await layout.confirm_total(ctx, req.spending, req.fee, req.coin)
|
||||
progress.report_init()
|
||||
elif req.__qualname__ == 'UiConfirmFeeOverThreshold':
|
||||
res = await layout.confirm_feeoverthreshold(ctx, req.fee, req.coin)
|
||||
progress.report_init()
|
||||
else:
|
||||
raise TypeError('Invalid signing instruction')
|
||||
return req
|
||||
|
@ -1,3 +1,5 @@
|
||||
from trezor import ui
|
||||
|
||||
_progress = 0
|
||||
_steps = 0
|
||||
|
||||
@ -5,12 +7,22 @@ _steps = 0
|
||||
def init(inputs, outputs):
|
||||
global _progress, _steps
|
||||
_progress = 0
|
||||
_steps = inputs + outputs + inputs + outputs + inputs
|
||||
_steps = inputs + inputs + outputs + inputs
|
||||
report_init()
|
||||
report()
|
||||
|
||||
|
||||
def advance():
|
||||
global _progress, _steps
|
||||
global _progress
|
||||
_progress += 1
|
||||
report()
|
||||
|
||||
|
||||
def report_init():
|
||||
ui.display.clear()
|
||||
ui.header('Signing transaction')
|
||||
|
||||
|
||||
def report():
|
||||
p = int(1000 * _progress / _steps)
|
||||
# TODO: draw progress circle using loader
|
||||
print("%d" % p)
|
||||
ui.display.loader(p, 18, ui.WHITE, ui.BG)
|
||||
|
@ -113,7 +113,6 @@ async def check_tx_fee(tx: SignTx, root: bip32.HDNode):
|
||||
'Wrong input script type')
|
||||
|
||||
for o in range(tx.outputs_count):
|
||||
progress.advance()
|
||||
# STAGE_REQUEST_3_OUTPUT
|
||||
txo = await request_tx_output(tx_req, o)
|
||||
txo_bin.amount = txo.amount
|
||||
|
Loading…
Reference in New Issue
Block a user