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

frontend: improvements of Send component #2966

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Commits on Oct 14, 2024

  1. frontend: utilize send-wrapper for some logic

    Utilize the `SendWrapper` to get the mobile channel error, and (bb01)
    paired status in case a bb01 is connected. This simplifies the `Send`
    component and better distinguishes code for bb01/bb02 stuff.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    5900704 View commit details
    Browse the repository at this point in the history
  2. frontend: type coinUnit in IAccount

    Type `coinUnit` in `IAccount` to use `CoinUnit`.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    a03270f View commit details
    Browse the repository at this point in the history
  3. frontend: remove unused state in send component

    Remove the unused `account` state from the `State` type declaration
    because it is never used.
    
    Remove the `paired?` state from the `Send` `State` declaration and also
    remove its usage in the return statement. It is always `undefined` which
    means `hidden={paired !== false}` is always `true`. This means we can
    remove it completely.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    43b274b View commit details
    Browse the repository at this point in the history
  4. frontend: improve send error handling

    The `txProposalErrorHandling` function should **only** return errors and
    not set any state. Although this isn't causing an issue right now, the
    function should not return an object that is unrelated to errors in
    principle. Additionally, this will be necessary for an upcoming refactor
    of the `Send` component.
    
    Return only `TProposalError` from the function but make all fields
    optional. To keep the logic the same we set `proposedFee` to `undefined`
    according to the same logic (ie. `{}` or `{ amountError: ... }` is
    returned) but in the `Send` component not in the error handling
    function.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    f06e0ae View commit details
    Browse the repository at this point in the history
  5. frontend: improve proposal response state

    Instead of individual variables `proposedFee`, `proposedTotal`, and
    `proposedAmount` we can put the result itself into the component state.
    
    Because of this, it is not possible anymore to reset individual fields
    to `undefined` but this is correct since there should be no "old"
    proposal values available in case the current proposal was invalid
    resulting in an `undefined` `proposalResult`.
    
    Before this commit the amount fields could show false values because
    they would show the last converted `fiatAmount` and the last valid
    `proposedAmount` since it was not reset on error. Now that we reset it
    it would've shown `''` but this is not a good solution which is why this
    commit also falls back to the last typed amount and its fiat equivalent
    in case `sendAll` is `true` but the proposal was invalid.
    
    We also disable the `sendAll` checkbox in case there is an
    `addressError` or `feeError` because it can not work if the proposal is
    not valid. We don't disable it if there's only `amountError` because the
    `amount` is not relevant if `sendAll` is `true`.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    834e36e View commit details
    Browse the repository at this point in the history
  6. frontend: improve setting isUpdatingProposal

    Set the `isUpdatingProposal` to `false` in the `finally` block of
    `validateAndDisplayFee` instead of twice in the `txProposal` funciton.
    This makes the component a bit easier to understand and smaller.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    095b5f5 View commit details
    Browse the repository at this point in the history
  7. frontend: improve note onChange handler

    Improve the onChange handler of the `NoteInput` component to take a
    function that takes a string instead of the `ChangeEvent`.
    
    This will enable us to just pass the `setNote` setter to it when we
    refactor the `Send` component to be functional.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    377272a View commit details
    Browse the repository at this point in the history
  8. frontend: don't reset the custom fee

    Don't reset the custom fee when the fee target changes/is set. The
    backend only uses the custom fee if fee target = custom which means it
    does not need to be set to be empty ('').
    
    Like this the user can select custom, type something, change to some
    other target, but as soon as he chooses custom again, what he typed
    earlier is still there.
    
    This will also enable us to only pass a `setFeeTarget` to the
    sub-component instead of having to define a handler, later when we
    refactor the `Send` component to functional.
    NicolaLS committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    d437c29 View commit details
    Browse the repository at this point in the history