diff --git a/Cargo.toml b/Cargo.toml index 8bbd8f3..a42c575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ pending_review_screen = [] curve = ["secp256k1"] flags = "0" path = ["44'/503'"] -name = "Conflux" +name = "Conflux Core" [package.metadata.ledger.nanox] icon = "icons/cfx_14.gif" diff --git a/README.md b/README.md index 6d19f64..d412ab8 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ This is the Conflux Ledger device app, which is developed in Rust. This project ## Work to be done -1. Unit conversion in the tx show UI +1. Unit conversion in the tx show UI ✅ 2. Setting read and write: c app is through action -3. Icons for stax and flex +3. Icons for stax and flex ✅ 4. More test cases -5. Nanox rlp compile issue \ No newline at end of file +5. Nanox rlp compile issue: need manual impl rlp decode \ No newline at end of file diff --git a/docs/APDU.md b/docs/APDU.md index b36362c..50bfe35 100644 --- a/docs/APDU.md +++ b/docs/APDU.md @@ -24,5 +24,5 @@ Status words tend to be similar to common [APDU responses](https://www.eftlab.co | Field name | Length (bytes) | Description | | --- | --- | --- | -| RData | var | Reponse data (can be empty) | +| RData | var | Response data (can be empty) | | SW | 2 | Status word containing command processing status (e.g. `0x9000` for success) | diff --git a/icons/cfx_32.gif b/icons/cfx_32.gif old mode 100755 new mode 100644 index c1dbbf1..3e43387 Binary files a/icons/cfx_32.gif and b/icons/cfx_32.gif differ diff --git a/icons/cfx_32_1.gif b/icons/cfx_32_1.gif deleted file mode 100644 index 0cdb50d..0000000 Binary files a/icons/cfx_32_1.gif and /dev/null differ diff --git a/icons/cfx_40.gif b/icons/cfx_40.gif index c2532c5..c261abd 100644 Binary files a/icons/cfx_40.gif and b/icons/cfx_40.gif differ diff --git a/icons/cfx_40_1.gif b/icons/cfx_40_1.gif deleted file mode 100644 index a1097e0..0000000 Binary files a/icons/cfx_40_1.gif and /dev/null differ diff --git a/icons/cfx_64.gif b/icons/cfx_64.gif index d5bdcef..f7b07e9 100644 Binary files a/icons/cfx_64.gif and b/icons/cfx_64.gif differ diff --git a/icons/cfx_64_1.gif b/icons/cfx_64_1.gif deleted file mode 100644 index 1a52146..0000000 Binary files a/icons/cfx_64_1.gif and /dev/null differ diff --git a/icons/dark_cfx_32.gif b/icons/dark_cfx_32.gif new file mode 100644 index 0000000..2701121 Binary files /dev/null and b/icons/dark_cfx_32.gif differ diff --git a/icons/dark_cfx_40.gif b/icons/dark_cfx_40.gif new file mode 100644 index 0000000..0e175b0 Binary files /dev/null and b/icons/dark_cfx_40.gif differ diff --git a/icons/dark_cfx_64.gif b/icons/dark_cfx_64.gif new file mode 100644 index 0000000..98c1ab7 Binary files /dev/null and b/icons/dark_cfx_64.gif differ diff --git a/src/cfx_addr/consts.rs b/src/cfx_addr/consts.rs index db28c01..9a17d9b 100644 --- a/src/cfx_addr/consts.rs +++ b/src/cfx_addr/consts.rs @@ -40,11 +40,11 @@ pub const TESTNET_PREFIX: &str = "cfxtest"; pub const NETWORK_ID_PREFIX: &str = "net"; // address types -pub const ADDRESS_TYPE_BUILTIN: &'static str = "builtin"; -pub const ADDRESS_TYPE_CONTRACT: &'static str = "contract"; -pub const ADDRESS_TYPE_NULL: &'static str = "null"; -pub const ADDRESS_TYPE_UNKNOWN: &'static str = "unknown"; -pub const ADDRESS_TYPE_USER: &'static str = "user"; +pub const ADDRESS_TYPE_BUILTIN: &str = "builtin"; +pub const ADDRESS_TYPE_CONTRACT: &str = "contract"; +pub const ADDRESS_TYPE_NULL: &str = "null"; +pub const ADDRESS_TYPE_UNKNOWN: &str = "unknown"; +pub const ADDRESS_TYPE_USER: &str = "user"; // These two network_ids are reserved. pub const RESERVED_NETWORK_IDS: [u64; 2] = [1, 1029]; diff --git a/src/consts.rs b/src/consts.rs index c3502cb..7228bc4 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -45,4 +45,4 @@ pub const APP_FLAG_BLIND_SIGNING_ENABLED: usize = 0x01; pub const APP_FLAG_DETAILED_DISPLAY_ENABLED: usize = 0x02; -pub const PERSONAL_SIGN_PREFIX: &'static str = "\x19Conflux Signed Message:\n"; +pub const PERSONAL_SIGN_PREFIX: &str = "\x19Conflux Signed Message:\n"; diff --git a/src/main.rs b/src/main.rs index d99ffc2..11e90c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,7 +170,7 @@ impl TryFrom for Instruction { #[cfg(any(target_os = "stax", target_os = "flex"))] fn show_status_and_home_if_needed(ins: &Instruction, tx_ctx: &mut TxContext, status: &AppSW) { let (show_status, status_type) = match (ins, status) { - (Instruction::GetPubkey { display: true }, AppSW::Deny | AppSW::Ok) => { + (Instruction::GetPubkey { display: true, return_chain_code: _ }, AppSW::Deny | AppSW::Ok) => { (true, StatusType::Address) } (Instruction::SignTx { .. }, AppSW::Deny | AppSW::Ok) if tx_ctx.finished() => { diff --git a/tests/application_client/command_sender.py b/tests/application_client/command_sender.py index 011bbcd..d8935ea 100644 --- a/tests/application_client/command_sender.py +++ b/tests/application_client/command_sender.py @@ -23,7 +23,7 @@ class P2(IntEnum): P2_LAST = 0x00 # Parameter 2 for more APDU to receive. P2_MORE = 0x80 - + # Parameter 2 for true. P2_TRUE = 0x01 class InsType(IntEnum): @@ -92,12 +92,16 @@ def get_public_key(self, path: str) -> RAPDU: @contextmanager - def get_public_key_with_confirmation(self, path: str, chain_id: int) -> Generator[None, None, None]: + def get_public_key_with_confirmation(self, + path: str, + chain_id: int + ) -> Generator[None, None, None]: with self.backend.exchange_async(cla=CLA, ins=InsType.GET_PUBLIC_KEY, p1=P1.P1_CONFIRM, p2=P2.P2_TRUE, - data=pack_derivation_path(path) + chain_id.to_bytes(4, 'big')) as response: + data=pack_derivation_path(path) + chain_id.to_bytes(4, 'big'), + ) as response: yield response diff --git a/tests/application_client/response_unpacker.py b/tests/application_client/response_unpacker.py index 255fc30..a1c71d9 100644 --- a/tests/application_client/response_unpacker.py +++ b/tests/application_client/response_unpacker.py @@ -22,7 +22,7 @@ def unpack_get_app_name_response(response: bytes) -> str: # PATCH (1) def unpack_get_version_response(response: bytes) -> Tuple[int, int, int]: assert len(response) == 4 - flag, major, minor, patch = unpack("BBBB", response) + _, major, minor, patch = unpack("BBBB", response) return (major, minor, patch) # Unpack from response: diff --git a/tests/application_client/transaction.py b/tests/application_client/transaction.py index 1d42bc4..becc6be 100644 --- a/tests/application_client/transaction.py +++ b/tests/application_client/transaction.py @@ -7,8 +7,10 @@ class TransactionError(Exception): class Transaction: def __init__(self, **kwargs: TxParam): - self.tx = CfxTransaction.from_dict(kwargs) def serialize(self) -> bytes: return self.tx.encode(allow_unsigned=True) + + def get_internal_tx(self) -> dict: + return self.tx.to_dict() diff --git a/tests/snapshots/flex/test_app_mainmenu/00000.png b/tests/snapshots/flex/test_app_mainmenu/00000.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_app_mainmenu/00000.png and b/tests/snapshots/flex/test_app_mainmenu/00000.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00001.png b/tests/snapshots/flex/test_app_mainmenu/00001.png index ca9fbbe..0ff3eca 100644 Binary files a/tests/snapshots/flex/test_app_mainmenu/00001.png and b/tests/snapshots/flex/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00002.png b/tests/snapshots/flex/test_app_mainmenu/00002.png index d6e9c7c..84d217c 100644 Binary files a/tests/snapshots/flex/test_app_mainmenu/00002.png and b/tests/snapshots/flex/test_app_mainmenu/00002.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00003.png b/tests/snapshots/flex/test_app_mainmenu/00003.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_app_mainmenu/00003.png and b/tests/snapshots/flex/test_app_mainmenu/00003.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png index c7d14d8..b704549 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png index f30b803..7b1b745 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png index c7d14d8..b704549 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png index f30b803..7b1b745 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png differ diff --git a/tests/snapshots/flex/test_personal_sign/00000.png b/tests/snapshots/flex/test_personal_sign/00000.png new file mode 100644 index 0000000..6cc0fd3 Binary files /dev/null and b/tests/snapshots/flex/test_personal_sign/00000.png differ diff --git a/tests/snapshots/flex/test_personal_sign/00001.png b/tests/snapshots/flex/test_personal_sign/00001.png new file mode 100644 index 0000000..4c46ac3 Binary files /dev/null and b/tests/snapshots/flex/test_personal_sign/00001.png differ diff --git a/tests/snapshots/flex/test_personal_sign/00002.png b/tests/snapshots/flex/test_personal_sign/00002.png new file mode 100644 index 0000000..cf9ecbd Binary files /dev/null and b/tests/snapshots/flex/test_personal_sign/00002.png differ diff --git a/tests/snapshots/flex/test_personal_sign/00003.png b/tests/snapshots/flex/test_personal_sign/00003.png new file mode 100644 index 0000000..4489fc6 Binary files /dev/null and b/tests/snapshots/flex/test_personal_sign/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00000.png b/tests/snapshots/flex/test_sign_tx_long_tx/00000.png index 40d7387..850d8da 100644 Binary files a/tests/snapshots/flex/test_sign_tx_long_tx/00000.png and b/tests/snapshots/flex/test_sign_tx_long_tx/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00001.png b/tests/snapshots/flex/test_sign_tx_long_tx/00001.png index fa1a974..71b8452 100644 Binary files a/tests/snapshots/flex/test_sign_tx_long_tx/00001.png and b/tests/snapshots/flex/test_sign_tx_long_tx/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00002.png b/tests/snapshots/flex/test_sign_tx_long_tx/00002.png index ff0fd44..df5424b 100644 Binary files a/tests/snapshots/flex/test_sign_tx_long_tx/00002.png and b/tests/snapshots/flex/test_sign_tx_long_tx/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00003.png b/tests/snapshots/flex/test_sign_tx_long_tx/00003.png index fd33e09..be51a9d 100644 Binary files a/tests/snapshots/flex/test_sign_tx_long_tx/00003.png and b/tests/snapshots/flex/test_sign_tx_long_tx/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00004.png b/tests/snapshots/flex/test_sign_tx_long_tx/00004.png index be51a9d..0916396 100644 Binary files a/tests/snapshots/flex/test_sign_tx_long_tx/00004.png and b/tests/snapshots/flex/test_sign_tx_long_tx/00004.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00000.png b/tests/snapshots/flex/test_sign_tx_refused/00000.png index 05f2241..850d8da 100644 Binary files a/tests/snapshots/flex/test_sign_tx_refused/00000.png and b/tests/snapshots/flex/test_sign_tx_refused/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00001.png b/tests/snapshots/flex/test_sign_tx_refused/00001.png index 5d919f7..30b432a 100644 Binary files a/tests/snapshots/flex/test_sign_tx_refused/00001.png and b/tests/snapshots/flex/test_sign_tx_refused/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00002.png b/tests/snapshots/flex/test_sign_tx_refused/00002.png index 9a270f5..df5424b 100644 Binary files a/tests/snapshots/flex/test_sign_tx_refused/00002.png and b/tests/snapshots/flex/test_sign_tx_refused/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00005.png b/tests/snapshots/flex/test_sign_tx_refused/00005.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_sign_tx_refused/00005.png and b/tests/snapshots/flex/test_sign_tx_refused/00005.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00000.png b/tests/snapshots/flex/test_sign_tx_short_tx/00000.png index 05f2241..850d8da 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx/00000.png and b/tests/snapshots/flex/test_sign_tx_short_tx/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00001.png b/tests/snapshots/flex/test_sign_tx_short_tx/00001.png index a2bfbaa..71b8452 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx/00001.png and b/tests/snapshots/flex/test_sign_tx_short_tx/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00002.png b/tests/snapshots/flex/test_sign_tx_short_tx/00002.png index 9a270f5..df5424b 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx/00002.png and b/tests/snapshots/flex/test_sign_tx_short_tx/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00004.png b/tests/snapshots/flex/test_sign_tx_short_tx/00004.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx/00004.png and b/tests/snapshots/flex/test_sign_tx_short_tx/00004.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png index 05f2241..850d8da 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png index 2d0c474..30b432a 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png index 9a270f5..df5424b 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png index 8a9212d..0916396 100644 Binary files a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png index c4c0210..41a0ec2 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00001.png b/tests/snapshots/nanosp/test_sign_tx_refused/00001.png index c4c0210..41a0ec2 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00001.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00001.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png b/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png index c4c0210..41a0ec2 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png and b/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png differ