Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Jan 2, 2024
1 parent bf4f042 commit 6e2b43d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
9 changes: 6 additions & 3 deletions core/src/apps/stellar/layout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ubinascii
from typing import TYPE_CHECKING

import trezor.ui.layouts as layouts
Expand Down Expand Up @@ -180,12 +179,16 @@ async def confirm_value(val: str, val_type: str) -> None:
await confirm_value(strings.format_amount(v, 0), "i128")
elif val.type == StellarSCValType.SCV_U256:
assert val.u256
value_bytes = ustruct.pack(">QQQQ", val.u256.hi_hi, val.u256.hi_lo, val.u256.lo_hi, val.u256.lo_lo)
value_bytes = ustruct.pack(
">QQQQ", val.u256.hi_hi, val.u256.hi_lo, val.u256.lo_hi, val.u256.lo_lo
)
v = helpers.bytes_to_int(value_bytes)
await confirm_value(strings.format_amount(v, 0), "u256")
elif val.type == StellarSCValType.SCV_I256:
assert val.i256
value_bytes = ustruct.pack(">qQQQ", val.i256.hi_hi, val.i256.hi_lo, val.i256.lo_hi, val.i256.lo_lo)
value_bytes = ustruct.pack(
">qQQQ", val.i256.hi_hi, val.i256.hi_lo, val.i256.lo_hi, val.i256.lo_lo
)
v = helpers.bytes_to_int(value_bytes, True)
await confirm_value(strings.format_amount(v, 0), "i256")
elif val.type == StellarSCValType.SCV_BYTES:
Expand Down
4 changes: 2 additions & 2 deletions core/src/apps/stellar/operations/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ async def confirm_soroban_credentials(
await confirm_metadata(
"confirm_soroban_credentials",
title,
"Authorization needs to be done using the source account",
"Authorize using the source account",
)
elif credentials.type == StellarSorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS:
assert credentials.address
await confirm_metadata(
"confirm_soroban_credentials",
title,
"Authorization is required using {}",
"Authorize using {}",
credentials.address.address.address,
)
else:
Expand Down
34 changes: 0 additions & 34 deletions python/src/trezorlib/stellar.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,6 @@ def _read_sc_val(val: "SCVal") -> messages.StellarSCVal:
return messages.StellarSCVal(type=messages.StellarSCValType.SCV_BOOL, b=val.b)
elif val.type == SCValType.SCV_VOID:
return messages.StellarSCVal(type=messages.StellarSCValType.SCV_VOID)
# elif val.type == SCValType.SCV_ERROR:
# pass # Not supported yet
elif val.type == SCValType.SCV_U32:
return messages.StellarSCVal(
type=messages.StellarSCValType.SCV_U32, u32=val.u32.uint32
Expand Down Expand Up @@ -538,38 +536,6 @@ def _read_sc_val(val: "SCVal") -> messages.StellarSCVal:
type=messages.StellarSCValType.SCV_LEDGER_KEY_NONCE,
nonce_key=val.nonce_key.nonce.int64,
)
elif val.type == SCValType.SCV_CONTRACT_INSTANCE:
if (
val.instance.executable.type
== messages.StellarContractExecutableType.CONTRACT_EXECUTABLE_WASM
):
executable = messages.StellarContractExecutable(
type=messages.StellarContractExecutableType.CONTRACT_EXECUTABLE_WASM,
wasm_hash=val.instance.executable.wasm_hash.hash,
)
elif (
val.instance.executable.type
== messages.StellarContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET
):
executable = messages.StellarContractExecutable(
type=messages.StellarContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET,
)
else:
raise ValueError(
f"Unsupported executable type: {val.instance.executable.type}"
)
return messages.StellarSCVal(
type=messages.StellarSCValType.SCV_CONTRACT_INSTANCE,
instance=messages.StellarSCContractInstance(
executable=executable,
storage=[
messages.StellarSCValMapEntry(
key=_read_sc_val(k), value=_read_sc_val(v)
)
for k, v in val.instance.storage.sc_map
],
),
)
else:
raise ValueError(f"Unsupported SCVal type: {val.type}")

Expand Down

0 comments on commit 6e2b43d

Please sign in to comment.