From 0a75cbb0e9fc7b9ba2ff379b342d1744e17f0409 Mon Sep 17 00:00:00 2001 From: Bayo Sodimu <6872903+bayological@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:40:19 -0500 Subject: [PATCH 1/3] Release/2.2.2 (#141) --- .github/workflows/check-branch.yml | 21 +++++++++++++++++++++ .github/workflows/ci.yml | 4 ++-- package.json | 2 +- src/components/input/Select.tsx | 2 +- src/styles/globals.css | 11 +++++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check-branch.yml diff --git a/.github/workflows/check-branch.yml b/.github/workflows/check-branch.yml new file mode 100644 index 0000000..69b5dd8 --- /dev/null +++ b/.github/workflows/check-branch.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54f2c4c..5d353e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/package.json b/package.json index 1757b27..4caae45 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/input/Select.tsx b/src/components/input/Select.tsx index b5e5909..25f074e 100644 --- a/src/components/input/Select.tsx +++ b/src/components/input/Select.tsx @@ -23,7 +23,7 @@ export function Select({ value, optionValues, onChange, button, option, buttonLa leaveFrom="opacity-100" leaveTo="opacity-0" > - + {optionValues.map((optionValue) => ( Date: Thu, 3 Oct 2024 22:13:44 +0100 Subject: [PATCH 2/3] ensure useMax sets correct input value and recalculates output after typing in output field --- src/features/swap/SwapForm.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/features/swap/SwapForm.tsx b/src/features/swap/SwapForm.tsx index 05a42ce..81435c6 100644 --- a/src/features/swap/SwapForm.tsx +++ b/src/features/swap/SwapForm.tsx @@ -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)) { @@ -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') } From 823ec2ab1c3e6ff1beb88255eb0e39e7c9b53132 Mon Sep 17 00:00:00 2001 From: Gabriel Temtsen Date: Tue, 15 Oct 2024 16:19:42 +0100 Subject: [PATCH 3/3] chore: run prettier to format --- src/features/swap/SwapForm.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/swap/SwapForm.tsx b/src/features/swap/SwapForm.tsx index 81435c6..917d8de 100644 --- a/src/features/swap/SwapForm.tsx +++ b/src/features/swap/SwapForm.tsx @@ -108,9 +108,9 @@ function SwapFormInputs({ balances }: { balances: AccountBalances }) { useEffect(() => { if (values.direction === 'in' && quote) { - setFieldValue('quote', quote); + setFieldValue('quote', quote) } - }, [quote, setFieldValue, values.direction]); + }, [quote, setFieldValue, values.direction]) useEffect(() => { if (chain && isConnected && !isSwappable(values.fromTokenId, values.toTokenId, chain?.id)) { @@ -124,10 +124,10 @@ function SwapFormInputs({ balances }: { balances: AccountBalances }) { const roundedBalance = fromWeiRounded(balances[fromTokenId], Tokens[fromTokenId].decimals) const isRoundedBalanceGreaterThanZero = Boolean(Number.parseInt(roundedBalance) > 0) const onClickUseMax = () => { - const maxAmount = fromWei(balances[fromTokenId], Tokens[fromTokenId].decimals); - setFieldValue('amount', maxAmount); + const maxAmount = fromWei(balances[fromTokenId], Tokens[fromTokenId].decimals) + setFieldValue('amount', maxAmount) - setFieldValue('direction', 'in'); + setFieldValue('direction', 'in') if (fromTokenId === TokenId.CELO) { toast.warn('Consider keeping some CELO for transaction fees') }