Skip to content

Handle additional swapper errors in errorInfoAction#1634

Merged
DRadmir merged 5 commits intomainfrom
swap-min-amount-autofill
Jan 27, 2026
Merged

Handle additional swapper errors in errorInfoAction#1634
DRadmir merged 5 commits intomainfrom
swap-min-amount-autofill

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Jan 26, 2026

Extended errorInfoAction to handle InputAmountError by applying the minimum amount to the input model. Added applyMinAmount helper to update the input field based on the error context.

Simulator Screenshot - iPhone 17 Pro - 2026-01-27 at 12 16 05

Extended errorInfoAction to handle InputAmountError by applying the minimum amount to the input model. Added applyMinAmount helper to update the input field based on the error context.
@DRadmir DRadmir self-assigned this Jan 26, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DRadmir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the error handling mechanism within the swap feature, particularly for scenarios where the input amount is invalid. By introducing a specific handler for input amount errors and automatically adjusting the input field to a valid minimum, the changes aim to guide users more effectively and prevent common transaction issues, leading to a smoother user experience.

Highlights

  • Enhanced Error Handling: The errorInfoAction has been extended to specifically handle InputAmountError cases, providing a more granular response to different types of swapper errors.
  • Automatic Minimum Amount Application: When an InputAmountError occurs, the system will now automatically apply the minimum required amount to the input model, improving user experience by suggesting a valid input.
  • New Helper Function: A private helper function, applyMinAmount, has been introduced to encapsulate the logic for updating the input field with a formatted minimum amount.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request extends the errorInfoAction to handle InputAmountError by setting the minimum required amount in the input field. The implementation is straightforward with a new helper function applyMinAmount.

My review includes a suggestion to improve the robustness of this new error handling. By parsing the minAmount string earlier, we can ensure the action is only presented to the user when it's valid, and it also simplifies the new helper function. This will prevent a scenario where the user interacts with the error message but nothing happens.

Comment on lines +137 to +141
case .InputAmountError(let minAmount):
guard let minAmount, let fromAsset else { return nil }
return VoidAction { [weak self] in
self?.applyMinAmount(minAmount, asset: fromAsset.asset)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve robustness and avoid creating a VoidAction that does nothing if minAmount is not a valid number, it's better to parse minAmount into a BigInt here. This ensures that the action is only available when it's guaranteed to work.

You can then pass the BigInt value directly to applyMinAmount, which simplifies that function as well. I'll leave a corresponding suggestion on applyMinAmount.

Suggested change
case .InputAmountError(let minAmount):
guard let minAmount, let fromAsset else { return nil }
return VoidAction { [weak self] in
self?.applyMinAmount(minAmount, asset: fromAsset.asset)
}
case .InputAmountError(let minAmount):
guard let minAmount, let value = BigInt(minAmount), let fromAsset else { return nil }
return VoidAction { [weak self] in
self?.applyMinAmount(value, asset: fromAsset.asset)
}

Comment on lines +317 to +320
private func applyMinAmount(_ minAmount: String, asset: Asset) {
guard let value = BigInt(minAmount) else { return }
amountInputModel.text = formatter.format(value: value, decimals: asset.decimals.asInt)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Following the suggestion to parse minAmount in errorInfoAction, this function can be simplified to accept a BigInt directly. This makes the function's responsibility clearer and removes the need for failable string parsing within it.

    private func applyMinAmount(_ value: BigInt, asset: Asset) {
        amountInputModel.text = formatter.format(value: value, decimals: asset.decimals.asInt)
    }

DRadmir and others added 3 commits January 27, 2026 11:50
Introduces a localized 'Use Minimum Amount' button to the swap error section when the input amount is below the minimum. Updates SwapScene and SwapSceneViewModel to support the new action and adds translations for the button in all supported languages.
@DRadmir DRadmir merged commit ac9b9ab into main Jan 27, 2026
1 check passed
@DRadmir DRadmir deleted the swap-min-amount-autofill branch January 27, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants