Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: propagate expert mode error to client #94

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/app_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {
false => "Disabled",
};

app_version = String::from("x");
// app_version = String::from("x");
let pages = [
&Page::from((_first_page_label, &APP_ICON)),
&Page::from((["Expert Mode", expert_mode_label], true, true)),
Expand Down
8 changes: 2 additions & 6 deletions app/src/app_ui/run_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ pub fn ui_review_transaction<'a>(

#[cfg(not(any(target_os = "stax", target_os = "flex")))]
{
let field_pairs = transaction
.review_fields(ovk)
.map_err(|_| AppSW::BufferOutOfBounds)?;
let field_pairs = transaction.review_fields(ovk)?;

// Create a vector to hold the Field structs
let fields: Vec<Field> = field_pairs
Expand Down Expand Up @@ -77,9 +75,7 @@ pub fn ui_review_transaction<'a>(
#[cfg(target_os = "flex")]
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("flex_icon.gif", NBGL));

let field_pairs = transaction
.review_fields(ovk)
.map_err(|_| AppSW::BufferOutOfBounds)?;
let field_pairs = transaction.review_fields(ovk)?;

// Create a vector to hold the Field structs
let fields: Vec<Field> = field_pairs
Expand Down
1 change: 1 addition & 0 deletions app/src/ironfish/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ pub enum IronfishError {
RandomnessError,
RoundTwoSigningFailure,
TryFromInt,
ErrExpertModeMustBeEnabled,
Utf8,
}
1 change: 1 addition & 0 deletions app/src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum ParserError {
BufferFull,
InvalidTokenList,
UnknownToken,
ErrExpertModeMustBeEnabled,

UnexpectedError,
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/parser/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Note {

#[cfg(feature = "ledger")]
if !Settings.app_expert_mode() {
return Err(ParserError::UnknownToken);
return Err(ParserError::ErrExpertModeMustBeEnabled);
}

let amount_label = String::from("Raw Amount ");
Expand Down
6 changes: 4 additions & 2 deletions app/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ pub enum AppSW {
WrongP1P2 = 0x6A86,
InsNotSupported = 0x6D00,
ClaNotSupported = 0x6E00,
TxDisplayFail = 0xB001,
AddrDisplayFail = 0xB002,
TxWrongLength = 0xB004,
TxParsingFail = 0xB005,
TxHashFail = 0xB006,
TxSignFail = 0xB008,
KeyDeriveFail = 0xB009,
VersionParsingFail = 0xB00A,
Expand All @@ -43,6 +41,7 @@ pub enum AppSW {
TooManyParticipants = 0xB024,
InvalidTxHash = 0xB025,
InvalidToken = 0xB026,
ErrExpertModeMustBeEnabled = 0xB027,
#[cfg(feature = "ledger")]
WrongApduLength = StatusWords::BadLen as u16,
Ok = 0x9000,
Expand All @@ -61,6 +60,7 @@ impl From<IronfishError> for AppSW {
IronfishError::RoundTwoSigningFailure => AppSW::DkgRound2Fail,
IronfishError::InvalidSigningKey => AppSW::KeyDeriveFail,
IronfishError::InvalidSecret => AppSW::InvalidGroupSecretKey,
IronfishError::ErrExpertModeMustBeEnabled => AppSW::ErrExpertModeMustBeEnabled,
// For errors that don't have a direct mapping, use a generic error
_ => AppSW::Deny,
}
Expand Down Expand Up @@ -89,6 +89,7 @@ impl From<ParserError> for AppSW {
ParserError::BufferFull => AppSW::BufferOutOfBounds,
ParserError::InvalidTokenList => AppSW::InvalidPublicPackage,
ParserError::UnknownToken => AppSW::InvalidToken,
ParserError::ErrExpertModeMustBeEnabled => AppSW::ErrExpertModeMustBeEnabled,
}
}
}
Expand Down Expand Up @@ -133,6 +134,7 @@ impl From<ParserError> for IronfishError {
ParserError::InvalidTokenList => IronfishError::InvalidAssetIdentifier,
ParserError::UnexpectedError => IronfishError::InvalidData,
ParserError::UnknownToken => IronfishError::InvalidData,
ParserError::ErrExpertModeMustBeEnabled => IronfishError::ErrExpertModeMustBeEnabled,
}
}
}
Expand Down
Binary file modified tests_zemu/snapshots/fl-mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-mainmenu/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p2-m2-0-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p2-m2-1-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p3-m2-0-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p3-m2-1-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p3-m2-2-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p4-m2-0-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p4-m2-1-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p4-m2-2-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-dkg-p4-m2-3-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-review-transaction/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-review-transaction/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-review-transaction/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-tmp-review-transaction/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p2-m2-0-backup/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p2-m2-0-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p2-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p2-m2-1-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-0-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-0-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-1-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-2-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p3-m2-2-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-0-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-0-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-1-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-2-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-2-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-3-backup/00001.png
Binary file modified tests_zemu/snapshots/sp-tmp-dkg-p4-m2-3-backup/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00002.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00003.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00004.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00005.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00007.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00008.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00010.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00011.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00012.png
Binary file modified tests_zemu/snapshots/sp-tmp-review-transaction/00013.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00000.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00001.png
Binary file added tests_zemu/snapshots/st-mainmenu/00002.png
Binary file added tests_zemu/snapshots/st-mainmenu/00003.png
Binary file added tests_zemu/snapshots/st-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p2-m2-0-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p2-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p3-m2-0-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p3-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p3-m2-2-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p4-m2-0-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p4-m2-1-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p4-m2-2-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-dkg-p4-m2-3-backup/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-review-transaction/00001.png
Binary file modified tests_zemu/snapshots/st-tmp-review-transaction/00002.png
Binary file modified tests_zemu/snapshots/st-tmp-review-transaction/00003.png
5 changes: 3 additions & 2 deletions tests_zemu/tests/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ describe.each(models)('wrong actions', function (m) {
} catch (error) {
// Convert unknown error to string for comparison
const errorStr = String(error)
if (errorStr.includes('Unknown Return Code: 0xB010') || errorStr.includes('Timeout waiting for screen')) {
console.log('ErrorStr ', errorStr)
if (errorStr.includes('Unknown Return Code: 0xB027') || errorStr.includes('Timeout waiting for screen')) {
throw new Error(errorStr)
}
throw error
}
}),
).rejects.toThrow(/Unknown Return Code: 0xB010|Timeout waiting for screen/)
).rejects.toThrow(/Error: Unknown Return Code: 0xB027|Timeout waiting for screen/)
}
} finally {
for (let i = 0; i < globalSims.length; i++) await globalSims[i].close()
Expand Down
Loading