Skip to content

Commit

Permalink
improved UX and error handling for wallet configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Dec 2, 2024
1 parent 0844f8b commit 597f80e
Show file tree
Hide file tree
Showing 5 changed files with 499 additions and 118 deletions.
7 changes: 6 additions & 1 deletion components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface TextInputProps {
ref?: React.Ref<TextInputRN>;
error?: boolean;
onFocus?: any;
onBlur?: any;
}

const TextInput = React.forwardRef<TextInputRN, TextInputProps>(
Expand All @@ -61,7 +62,9 @@ const TextInput = React.forwardRef<TextInputRN, TextInputProps>(
toggleUnits,
onPressIn,
right,
error
error,
onFocus,
onBlur
},
ref
) => {
Expand Down Expand Up @@ -170,6 +173,8 @@ const TextInput = React.forwardRef<TextInputRN, TextInputProps>(
secureTextEntry={secureTextEntry}
onPressIn={onPressIn}
ref={ref}
onFocus={onFocus}
onBlur={onBlur}
/>
{suffix ? (
toggleUnits ? (
Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
"general.count": "Count",
"general.experimental": "Experimental",
"general.defaultNodeNickname": "My Lightning Node",
"general.pastedInvalidData": "The pasted text contains characters we can't use here. Please check and try again.",
"general.invalidHost": "Invalid host. Please enter a valid host, or host:port.",
"restart.title": "Restart required",
"restart.msg": "ZEUS has to be restarted before the new configuration is applied.",
"restart.msg1": "Would you like to restart now?",
Expand Down Expand Up @@ -251,6 +253,7 @@
"views.Settings.WalletConfiguration.walletActive": "Wallet Active",
"views.Settings.AddEditNode.scanLndconnect": "Scan lndconnect config",
"views.Settings.AddEditNode.scanLnc": "Scan LNC QR from Lightning Terminal",
"views.Settings.AddEditNode.wrongLncPairingPhraseLength": "A Lightning Node Connect pairing phrase must contain exactly 10 words. Please check and try again.",
"views.Settings.AddEditNode.scanCLightningRest": "Scan c-lightning-REST QR",
"views.Settings.AddEditNode.scanBtcpay": "Scan BTCPay config",
"views.Settings.AddEditNode.scanLndhub": "Scan LNDHub QR",
Expand Down Expand Up @@ -1094,6 +1097,7 @@
"error.failureReasonError": "A non-recoverable error has occured",
"error.failureReasonIncorrectPaymentDetails": "Payment details incorrect (unknown hash, invalid amt or invalid final cltv delta)",
"error.failureReasonInsufficientBalance": "Insufficient local balance",
"error.invalidMacaroon": "Invalid macaroon. Please check that you've entered the correct macaroon for this node.",
"pos.views.Wallet.PosPane.noOrders": "No orders open at the moment. To send to ZEUS, mark order as 'Other Payment Type' with a note that includes 'Zeus', 'BTC', or 'Bitcoin'",
"pos.views.Wallet.PosPane.noOrdersStandalone": "No orders open at the moment",
"pos.views.Wallet.PosPane.noOrdersPaid": "No orders have been paid yet",
Expand Down
12 changes: 12 additions & 0 deletions utils/ErrorUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ describe('ErrorUtils', () => {
).toEqual(
'Error starting up Tor on your phone. Try restarting Zeus. If the problem persists consider using the Orbot app to connect to Tor, or using an alternative connection method like Lightning Node Connect or Tailscale.'
);
expect(
errorToUserFriendly(
Object.assign(new Error(), {
message:
'Error: {"code":2,"message":"verification failed: signature mismatch after caveat verification","details":[]}',
name: 'test'
}),
false
)
).toEqual(
"Invalid macaroon. Please check that you've entered the correct macaroon for this node."
);
});

it('Returns inputted error if no match found', () => {
Expand Down
2 changes: 2 additions & 0 deletions utils/ErrorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const userFriendlyErrors: any = {
'error.torBootstrap',
'Error: called `Result::unwrap()` on an `Err` value: BootStrapError("Timeout waiting for boostrap")':
'error.torBootstrap',
'Error: {"code":2,"message":"verification failed: signature mismatch after caveat verification","details":[]}':
'error.invalidMacaroon',
FAILURE_REASON_TIMEOUT: 'error.failureReasonTimeout',
FAILURE_REASON_NO_ROUTE: 'error.failureReasonNoRoute',
FAILURE_REASON_ERROR: 'error.failureReasonError',
Expand Down
Loading

0 comments on commit 597f80e

Please sign in to comment.