mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-27 06:42:02 +00:00
core: unify NEM pager confirm with rest of codebase
This commit is contained in:
parent
cf70f82d90
commit
f680f0c0d3
@ -1,5 +1,6 @@
|
|||||||
from trezor import ui, wire
|
from trezor import ui
|
||||||
from trezor.messages import (
|
from trezor.messages import (
|
||||||
|
ButtonRequestType,
|
||||||
NEMMosaicCreation,
|
NEMMosaicCreation,
|
||||||
NEMMosaicDefinition,
|
NEMMosaicDefinition,
|
||||||
NEMMosaicLevy,
|
NEMMosaicLevy,
|
||||||
@ -7,7 +8,6 @@ from trezor.messages import (
|
|||||||
NEMSupplyChangeType,
|
NEMSupplyChangeType,
|
||||||
NEMTransactionCommon,
|
NEMTransactionCommon,
|
||||||
)
|
)
|
||||||
from trezor.ui.confirm import CONFIRMED, Confirm
|
|
||||||
from trezor.ui.scroll import Paginated
|
from trezor.ui.scroll import Paginated
|
||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text
|
||||||
|
|
||||||
@ -18,17 +18,14 @@ from ..layout import (
|
|||||||
require_confirm_text,
|
require_confirm_text,
|
||||||
)
|
)
|
||||||
|
|
||||||
from apps.common.layout import split_address
|
from apps.common.layout import require_confirm, split_address
|
||||||
|
|
||||||
if __debug__:
|
|
||||||
from apps.debug import confirm_signal
|
|
||||||
|
|
||||||
|
|
||||||
async def ask_mosaic_creation(
|
async def ask_mosaic_creation(
|
||||||
ctx, common: NEMTransactionCommon, creation: NEMMosaicCreation
|
ctx, common: NEMTransactionCommon, creation: NEMMosaicCreation
|
||||||
):
|
):
|
||||||
await require_confirm_content(ctx, "Create mosaic", _creation_message(creation))
|
await require_confirm_content(ctx, "Create mosaic", _creation_message(creation))
|
||||||
await _require_confirm_properties(ctx, creation.definition)
|
await require_confirm_properties(ctx, creation.definition)
|
||||||
await require_confirm_fee(ctx, "Confirm creation fee", creation.fee)
|
await require_confirm_fee(ctx, "Confirm creation fee", creation.fee)
|
||||||
|
|
||||||
await require_confirm_final(ctx, common.fee)
|
await require_confirm_final(ctx, common.fee)
|
||||||
@ -75,21 +72,7 @@ def _supply_message(supply_change):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def _require_confirm_properties(ctx, definition: NEMMosaicDefinition):
|
async def require_confirm_properties(ctx, definition: NEMMosaicDefinition):
|
||||||
# TODO: we should send a button request here
|
|
||||||
pages = _get_mosaic_properties(definition)
|
|
||||||
pages[-1] = Confirm(pages[-1])
|
|
||||||
paginated = Paginated(pages)
|
|
||||||
|
|
||||||
if __debug__:
|
|
||||||
result = await ctx.wait(paginated, confirm_signal)
|
|
||||||
else:
|
|
||||||
result = await ctx.wait(paginated)
|
|
||||||
if result is not CONFIRMED:
|
|
||||||
raise wire.ActionCancelled("Action cancelled")
|
|
||||||
|
|
||||||
|
|
||||||
def _get_mosaic_properties(definition: NEMMosaicDefinition):
|
|
||||||
properties = []
|
properties = []
|
||||||
|
|
||||||
# description
|
# description
|
||||||
@ -156,4 +139,5 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
|
|||||||
t.normal(levy_type)
|
t.normal(levy_type)
|
||||||
properties.append(t)
|
properties.append(t)
|
||||||
|
|
||||||
return properties
|
paginated = Paginated(properties)
|
||||||
|
await require_confirm(ctx, paginated, ButtonRequestType.ConfirmOutput)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
# You should have received a copy of the License along with this library.
|
# You should have received a copy of the License along with this library.
|
||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -177,10 +176,9 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
|
|||||||
self.client.debug.press_yes()
|
self.client.debug.press_yes()
|
||||||
|
|
||||||
# Swipe and confirm
|
# Swipe and confirm
|
||||||
time.sleep(1)
|
yield
|
||||||
for i in range(num_of_swipes):
|
for _ in range(num_of_swipes):
|
||||||
self.client.debug.swipe_down()
|
self.client.debug.swipe_down()
|
||||||
time.sleep(1)
|
|
||||||
self.client.debug.press_yes()
|
self.client.debug.press_yes()
|
||||||
|
|
||||||
# Confirm Action
|
# Confirm Action
|
||||||
@ -196,6 +194,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
|
|||||||
with self.client:
|
with self.client:
|
||||||
self.client.set_expected_responses(
|
self.client.set_expected_responses(
|
||||||
[
|
[
|
||||||
|
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||||
proto.ButtonRequest(code=B.SignTx),
|
proto.ButtonRequest(code=B.SignTx),
|
||||||
|
Loading…
Reference in New Issue
Block a user