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

fix: Display available spending limit amount #1346

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

usame-algan
Copy link
Member

What it solves

Resolves #1310

How this PR fixes it

  • Displays the available spending limit amount (amount-spent) with more precision

How to test it

  1. Open a safe with a spending limit in place
  2. Create a new transaction
  3. Select the token that has a spending limit
  4. Observe the amount is displayed with enough precision
  5. Press Max
  6. Observe the same amount in the input field

Screenshots

Screenshot 2022-12-12 at 11 57 37

@usame-algan usame-algan requested a review from schmanu December 12, 2022 11:18
@github-actions
Copy link

github-actions bot commented Dec 12, 2022

Branch preview

✅ Deploy successful!

https://fixspendinglimitamount--webcore.review-web-core.5afe.dev

selectedToken: TokenInfo | undefined
}) => {
const { control } = useFormContext()

const formattedAmount = formatVisualAmount(spendingLimit.amount, selectedToken?.decimals)
const formattedAmount = safeFormatUnits(availableAmount, selectedToken?.decimals)
Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to change this so that it doesn't cut off decimal places because it is the same as in safe-react.

spendingLimit: SpendingLimitState
availableAmount: BigNumber
Copy link
Member Author

Choose a reason for hiding this comment

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

Simplified this so we don't have to compute amount-spent in two places.

@github-actions
Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link
Member

@schmanu schmanu left a comment

Choose a reason for hiding this comment

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

Works great!

One thing we should consider adding soon here is a cypress test for spending limits. we could setup a safe with a Spending limit and just check that the interface reacts accordingly.

@usame-algan usame-algan merged commit 2dfdb46 into dev Dec 16, 2022
@usame-algan usame-algan deleted the fix-spending-limit-amount branch December 16, 2022 10:04
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI displays the wrong amount for spending limits
2 participants