Skip to content

Commit 64cce0a

Browse files
authored
Release 2.3.1 (#160)
1 parent 249dd38 commit 64cce0a

File tree

11 files changed

+128
-23
lines changed

11 files changed

+128
-23
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report task
3+
about: Create a bug report task to help us fix an existing bug
4+
---
5+
6+
#### **Description**
7+
8+
<!-- A clear and concise description of what the bug is. -->
9+
10+
#### **Steps To Reproduce**
11+
12+
<!-- Steps that can be followed to reproduce the bug.
13+
14+
1. Navigate to the '...'
15+
2. Click on '....'
16+
3. Scroll down to '....'
17+
4. See error
18+
19+
-->
20+
21+
#### **Actual result**
22+
23+
<!-- A clear and concise description of what actually happened. -->
24+
25+
#### **Expected result**
26+
27+
<!-- A clear and concise description of what you expected to happen. -->
28+
29+
#### **Attachments**
30+
31+
<!-- If applicable, add screenshots or video to help explain your problem. -->
32+
33+
#### **Additional context**
34+
35+
<!-- Add any other context about the problem here. -->

.github/issue_template/common_task.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Common task
3+
about: Create a common task to implement a feature, do refactor, or update docs
4+
---
5+
6+
## Description
7+
8+
<!-- A couple of sentences explaining the proposed task. -->
9+
10+
## Acceptance Criteria
11+
- [ ] _Your acceptance criteria_
12+
13+
#### **Attachments**
14+
15+
<!-- If applicable, add screenshots, video, or documentation to help explain your task. -->
16+
17+
## Additional context
18+
19+
<!-- Add any other context feature request here. -->

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ yarn-error.log*
4343

4444
# vercel
4545
.vercel
46+
47+
.idea

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mento-protocol/mento-web",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "A simple DApp for Celo Mento exchanges",
55
"keywords": [
66
"Celo",

src/components/nav/ConnectButton.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Identicon } from 'src/components/Identicon'
66
import { SolidButton } from 'src/components/buttons/SolidButton'
77
import { BalancesSummary } from 'src/components/nav/BalancesSummary'
88
import { NetworkModal } from 'src/components/nav/NetworkModal'
9+
import { cleanupStaleWalletSessions } from 'src/config/wallets'
910
import ClipboardDark from 'src/images/icons/clipboard-plus-dark.svg'
1011
import Clipboard from 'src/images/icons/clipboard-plus.svg'
1112
import CubeDark from 'src/images/icons/cube-dark.svg'
@@ -24,6 +25,11 @@ export function ConnectButton() {
2425
const { openConnectModal } = useConnectModal()
2526
const { disconnect } = useDisconnect()
2627

28+
const onClickConnect = () => {
29+
cleanupStaleWalletSessions()
30+
openConnectModal?.()
31+
}
32+
2733
const onClickCopy = async () => {
2834
if (!address) return
2935
await tryClipboardSet(address)
@@ -91,7 +97,7 @@ export function ConnectButton() {
9197
styles="sm:mr-3"
9298
/>
9399
}
94-
onClick={openConnectModal}
100+
onClick={onClickConnect}
95101
>
96102
<div className="hidden sm:block">Connect</div>
97103
</SolidButton>

src/components/nav/NetworkModal.tsx

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { toast } from 'react-toastify'
22
import { ChainMetadata, allChains, chainIdToChain } from 'src/config/chains'
3+
import { cleanupStaleWalletSessions } from 'src/config/wallets'
34
import { reset as accountReset } from 'src/features/accounts/accountSlice'
45
import { reset as blockReset } from 'src/features/blocks/blockSlice'
56
import { resetTokenPrices } from 'src/features/chart/tokenPriceSlice'
@@ -25,6 +26,7 @@ export function NetworkModal({ isOpen, close }: Props) {
2526
try {
2627
if (!switchNetworkAsync) throw new Error('switchNetworkAsync undefined')
2728
logger.debug('Resetting and switching to network', c.name)
29+
cleanupStaleWalletSessions()
2830
await switchNetworkAsync(c.chainId)
2931
dispatch(blockReset())
3032
dispatch(accountReset())
@@ -38,9 +40,9 @@ export function NetworkModal({ isOpen, close }: Props) {
3840

3941
return (
4042
<Modal isOpen={isOpen} close={close} title="Network details" width="max-w-md">
41-
<div className="px-4 sm:px-6 w-full justify-between items-end inline-flex">
42-
<div className="w-full py-3 sm:py-4 bg-gray-100 dark:bg-zinc-900 rounded-xl font-inter border border-gray-200 dark:border-zinc-800 flex-col justify-start items-center gap-4 inline-flex">
43-
<div className="px-3 sm:px-4 w-full justify-between items-end inline-flex">
43+
<div className="inline-flex items-end justify-between w-full px-4 sm:px-6">
44+
<div className="inline-flex flex-col items-center justify-start w-full gap-4 py-3 bg-gray-100 border border-gray-200 sm:py-4 dark:bg-zinc-900 rounded-xl font-inter dark:border-zinc-800">
45+
<div className="inline-flex items-end justify-between w-full px-3 sm:px-4">
4446
<div className="text-neutral-500 dark:text-gray-400 text-[14px] sm:text-[15px] font-normal leading-tight">
4547
Connected to:
4648
</div>
@@ -49,7 +51,7 @@ export function NetworkModal({ isOpen, close }: Props) {
4951
</div>
5052
</div>
5153
<div className="w-full h-[0px] border-t border-gray-200 dark:border-zinc-800"></div>
52-
<div className="px-3 sm:px-4 w-full justify-between items-end inline-flex">
54+
<div className="inline-flex items-end justify-between w-full px-3 sm:px-4">
5355
<div className="text-neutral-500 dark:text-gray-400 text-[14px] sm:text-[15px] font-normal leading-tight">
5456
Block Number:
5557
</div>
@@ -58,7 +60,7 @@ export function NetworkModal({ isOpen, close }: Props) {
5860
</div>
5961
</div>
6062
<div className="w-full h-[0px] border-t border-gray-200 dark:border-zinc-800"></div>
61-
<div className="px-3 sm:px-4 w-full justify-between items-end inline-flex">
63+
<div className="inline-flex items-end justify-between w-full px-3 sm:px-4">
6264
<div className="text-neutral-500 dark:text-gray-400 text-[14px] sm:text-[15px] font-normal leading-tight">
6365
Node Rpc Url:
6466
</div>
@@ -69,7 +71,7 @@ export function NetworkModal({ isOpen, close }: Props) {
6971
</div>
7072
</div>
7173
<div className="mt-4 sm:mt-6 w-full h-[0px] border-t border-gray-200 dark:border-zinc-800"></div>
72-
<div className="py-4 sm:py-6 px-4 sm:px-6 w-full justify-start items-start gap-4 inline-flex font-inter">
74+
<div className="inline-flex items-start justify-start w-full gap-4 px-4 py-4 sm:py-6 sm:px-6 font-inter">
7375
{allChains.map((c) => (
7476
<button
7577
onClick={() => switchToNetwork(c)}
@@ -97,27 +99,27 @@ export function NetworkModal({ isOpen, close }: Props) {
9799
}
98100
/*
99101
<div className="grow shrink basis-0 h-[50px] px-4 py-3 rounded-lg border border border border border-gray-950 justify-center items-center flex">
100-
<div className="justify-start items-center gap-1 flex">
102+
<div className="flex items-center justify-start gap-1">
101103
<div className="text-gray-950 text-[16px] font-semibold leading-relaxed">Baklava</div>
102104
</div>
103105
</div>
104106
105107
106108
<div className="relative flex flex-col items-center">
107-
<div className="flex justify-between items-center mt-3">
108-
<div className="mr-2 w-28 text-left text-sm">Connected to:</div>
109+
<div className="flex items-center justify-between mt-3">
110+
<div className="mr-2 text-sm text-left w-28">Connected to:</div>
109111
<div className="w-48 ml-1 text-sm">{currentChain?.name || 'Unknown'}</div>
110112
</div>
111-
<div className="flex justify-between items-center mt-3">
112-
<div className="mr-2 w-28 text-left text-sm">Block Number:</div>
113+
<div className="flex items-center justify-between mt-3">
114+
<div className="mr-2 text-sm text-left w-28">Block Number:</div>
113115
<div className="w-48 ml-1 text-sm">{latestBlock?.number || 'Unknown'}</div>
114116
</div>
115-
<div className="flex justify-between items-center mt-3">
116-
<div className="mr-2 w-28 text-left text-sm">Node Rpc Url:</div>
117+
<div className="flex items-center justify-between mt-3">
118+
<div className="mr-2 text-sm text-left w-28">Node Rpc Url:</div>
117119
<div className="w-48 ml-1 text-sm">{shortenUrl(currentChain?.rpcUrl) || 'Unknown'}</div>
118120
</div>
119121
<HrDivider classes="my-6" />
120-
<div className="flex items-center space-x-6 pb-2">
122+
<div className="flex items-center pb-2 space-x-6">
121123
{allChains.map((c) => (
122124
<button
123125
onClick={() => switchToNetwork(c)}

src/config/wallets.ts

+28
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@rainbow-me/rainbowkit/wallets'
88
import { Valora } from 'src/config/celoWallets'
99
import { config } from 'src/config/config'
10+
import { logger } from 'src/utils/logger'
1011

1112
export function getWalletConnectors(chains: Chain[]) {
1213
const connectorConfig = {
@@ -24,3 +25,30 @@ export function getWalletConnectors(chains: Chain[]) {
2425
trustWallet(connectorConfig),
2526
]
2627
}
28+
29+
/**
30+
* Remove wallet connect local storage data
31+
* @dev We got into an issue where the walletconnect data was in a corrupted state
32+
* and causing issues with wallet connection. This will remove the data from
33+
* localStorage to clean up the state.
34+
*/
35+
export const cleanupStaleWalletSessions = () => {
36+
logger.debug('Clearing wallet connect local storage data')
37+
const wcStorageKeys = Object.keys(localStorage).filter(
38+
(key) => key.startsWith('wc@') || key.startsWith('walletconnect')
39+
)
40+
41+
logger.debug(`Found ${wcStorageKeys.length} wallet connect keys`)
42+
43+
wcStorageKeys.forEach((key) => {
44+
try {
45+
const item = localStorage.getItem(key)
46+
if (!item) return
47+
48+
localStorage.removeItem(key)
49+
logger.debug(`Removed wallet connect value for key: ${key}`)
50+
} catch (error) {
51+
logger.error(`Failed to remove wallet connect value for key: ${key}`, error)
52+
}
53+
})
54+
}

src/features/swap/SwapConfirm.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { toastToYourSuccess } from 'src/components/TxSuccessToast'
66
import { Button3D } from 'src/components/buttons/3DButton'
77
import { TokenId, Tokens } from 'src/config/tokens'
88
import { useAppDispatch, useAppSelector } from 'src/features/store/hooks'
9-
import { setFormValues } from 'src/features/swap/swapSlice'
9+
import { setConfirmView, setFormValues } from 'src/features/swap/swapSlice'
1010
import { SwapFormValues } from 'src/features/swap/types'
1111
import { useApproveTransaction } from 'src/features/swap/useApproveTransaction'
1212
import { useSwapQuote } from 'src/features/swap/useSwapQuote'
@@ -142,7 +142,7 @@ export function SwapConfirmCard({ formValues }: Props) {
142142
}, [isApproveTxSuccess, isSwapTxLoading, isSwapTxSuccess, sendSwapTx, chainId, dispatch])
143143

144144
const onClickBack = () => {
145-
dispatch(setFormValues(null))
145+
dispatch(setConfirmView(false))
146146
}
147147

148148
const onClickRefresh = () => {

src/features/swap/SwapForm.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { reset as blockReset } from 'src/features/blocks/blockSlice'
2020
import { resetTokenPrices } from 'src/features/chart/tokenPriceSlice'
2121
import { useAppDispatch, useAppSelector } from 'src/features/store/hooks'
2222
import { SettingsMenu } from 'src/features/swap/SettingsMenu'
23-
import { setFormValues, reset as swapReset } from 'src/features/swap/swapSlice'
23+
import { setConfirmView, setFormValues, reset as swapReset } from 'src/features/swap/swapSlice'
2424
import { SwapDirection, SwapFormValues } from 'src/features/swap/types'
2525
import { useFormValidator } from 'src/features/swap/useFormValidator'
2626
import { useSwapQuote } from 'src/features/swap/useSwapQuote'
@@ -66,12 +66,15 @@ function SwapForm() {
6666
const dispatch = useAppDispatch()
6767
const onSubmit = (values: SwapFormValues) => {
6868
dispatch(setFormValues(values))
69+
dispatch(setConfirmView(true)) // Switch to confirm view
6970
}
7071
const validateForm = useFormValidator(balances)
72+
const storedFormValues = useAppSelector((s) => s.swap.formValues) // Get stored form values
73+
const initialFormValues = storedFormValues || initialValues // Use stored values if they exist
7174

7275
return (
7376
<Formik<SwapFormValues>
74-
initialValues={initialValues}
77+
initialValues={initialFormValues}
7578
onSubmit={onSubmit}
7679
validate={validateForm}
7780
validateOnChange={true}

src/features/swap/swapSlice.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ export interface SwapState {
66
toCeloRates: ToCeloRates
77
showSlippage: boolean
88
showChart: boolean
9+
confirmView: boolean
910
}
1011

1112
const initialState: SwapState = {
1213
formValues: null,
1314
toCeloRates: {},
1415
showSlippage: false,
1516
showChart: false,
17+
confirmView: false,
1618
}
1719

1820
export const swapSlice = createSlice({
@@ -29,8 +31,12 @@ export const swapSlice = createSlice({
2931
state.showChart = action.payload
3032
},
3133
reset: () => initialState,
34+
setConfirmView(state, action) {
35+
state.confirmView = action.payload
36+
},
3237
},
3338
})
3439

35-
export const { setFormValues, setShowSlippage, setShowChart, reset } = swapSlice.actions
40+
export const { setFormValues, setShowSlippage, setShowChart, reset, setConfirmView } =
41+
swapSlice.actions
3642
export const swapReducer = swapSlice.reducer

src/pages/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import { SwapConfirmCard } from 'src/features/swap/SwapConfirm'
66
import { SwapFormCard } from 'src/features/swap/SwapForm'
77

88
export default function SwapPage() {
9-
const { formValues, showChart } = useAppSelector((state) => state.swap)
9+
const { formValues, showChart, confirmView } = useAppSelector((state) => state.swap)
1010
return (
1111
<div className="flex justify-center items-center h-full flex-wrap w-full">
1212
<div className="mb-6 w-full max-w-md">
13-
{!formValues ? <SwapFormCard /> : <SwapConfirmCard formValues={formValues} />}
13+
{!formValues || !confirmView ? (
14+
<SwapFormCard />
15+
) : (
16+
<SwapConfirmCard formValues={formValues} />
17+
)}{' '}
1418
</div>
1519
{config.showPriceChart && showChart && (
1620
<div className="mb-6 md:ml-10">

0 commit comments

Comments
 (0)