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