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: Correct 'Use Max' Behavior to Set Input Field and Recalculate Output #142

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
21 changes: 21 additions & 0 deletions .github/workflows/check-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prevent Non-Release/Non-Hotfix PRs to Main

on:
pull_request:
branches:
- main
pull_request_target:
branches:
- main

jobs:
check-target-branch:
if: github.base_ref == 'main'
runs-on: ubuntu-latest
steps:
- name: Check if the source branch is a release branch
run: |
if [[ "${{ github.head_ref }}" != release/* && "${{ github.head_ref }}" != hotfix/* ]]; then
echo "Only release and hotfix branches can be merged into the main branch."
exit 1
fi
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: ci
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
branches: [main, dev]
pull_request:
branches: [main]
branches: [main, dev]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mento-protocol/mento-web",
"version": "2.2.1",
"version": "2.2.2",
"description": "A simple DApp for Celo Mento exchanges",
"keywords": [
"Celo",
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function Select({ value, optionValues, onChange, button, option, buttonLa
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-20 w-full py-1 mt-1 overflow-auto dark:bg-[#3F3F46] bg-white rounded-[8px] shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none border border-solid border-black">
<Listbox.Options className="absolute z-20 w-full py-1 mt-1 overflow-auto dark:bg-[#3F3F46] bg-white rounded-[8px] shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none border border-solid border-black sm:mobile-dropdown dropdown-menu">
{optionValues.map((optionValue) => (
<Listbox.Option
key={optionValue}
Expand Down
11 changes: 8 additions & 3 deletions src/features/swap/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ function SwapFormInputs({ balances }: { balances: AccountBalances }) {
const { isLoading, quote, rate } = useSwapQuote(amount, direction, fromTokenId, toTokenId)

useEffect(() => {
setFieldValue('quote', quote)
}, [quote, setFieldValue])
if (values.direction === 'in' && quote) {
setFieldValue('quote', quote);
}
}, [quote, setFieldValue, values.direction]);

useEffect(() => {
if (chain && isConnected && !isSwappable(values.fromTokenId, values.toTokenId, chain?.id)) {
Expand All @@ -122,7 +124,10 @@ function SwapFormInputs({ balances }: { balances: AccountBalances }) {
const roundedBalance = fromWeiRounded(balances[fromTokenId], Tokens[fromTokenId].decimals)
const isRoundedBalanceGreaterThanZero = Boolean(Number.parseInt(roundedBalance) > 0)
const onClickUseMax = () => {
setFieldValue('amount', fromWei(balances[fromTokenId], Tokens[fromTokenId].decimals))
const maxAmount = fromWei(balances[fromTokenId], Tokens[fromTokenId].decimals);
setFieldValue('amount', maxAmount);

setFieldValue('direction', 'in');
if (fromTokenId === TokenId.CELO) {
toast.warn('Consider keeping some CELO for transaction fees')
}
Expand Down
11 changes: 11 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,14 @@ Toasts
--toastify-color-progress-warning: var(--toastify-color-warning);
--toastify-color-progress-error: var(--toastify-color-error);
}

@media (max-width: 640px) {
.dropdown-menu {
position: fixed !important;
bottom: auto !important;
top: auto !important;
max-height: 25vh !important;
width: 48% !important;
z-index: 9999 !important;
}
}
Loading