From 667a90e76c0f958c37b6b760af4228657df0332d Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Tue, 18 Jun 2024 16:37:58 -0700 Subject: [PATCH 1/2] fix(synapse-interface): disable input pending wallet (#2738) * Disable input when wallet prompt pending * Lift isWalletPending to store * Disable input during approve wallet pending --- .../components/StateManagedBridge/InputContainer.tsx | 11 +++++++++-- .../pages/state-managed-bridge/index.tsx | 12 +++++++----- packages/synapse-interface/slices/bridge/reducer.ts | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx b/packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx index b17b6b285d..f526706f2d 100644 --- a/packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx +++ b/packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx @@ -37,8 +37,14 @@ export const InputContainer = () => { const dispatch = useAppDispatch() const { chain, isConnected } = useAccount() const { balances } = usePortfolioState() - const { fromChainId, toChainId, fromToken, toToken, fromValue } = - useBridgeState() + const { + fromChainId, + toChainId, + fromToken, + toToken, + fromValue, + isWalletPending, + } = useBridgeState() const [showValue, setShowValue] = useState('') const [hasMounted, setHasMounted] = useState(false) @@ -152,6 +158,7 @@ export const InputContainer = () => { inputRef={inputRef} showValue={showValue} handleFromValueChange={handleFromValueChange} + disabled={isWalletPending} /> { debouncedFromValue, destinationAddress, isLoading: isQuoteLoading, + isWalletPending, }: BridgeState = useBridgeState() const { showSettingsSlideOver, showDestinationAddress } = useSelector( (state: RootState) => state.bridgeDisplay ) - const [isWalletPending, setIsWalletPending] = useState(false) const [isApproved, setIsApproved] = useState(false) const dispatch = useAppDispatch() @@ -327,6 +326,7 @@ const StateManagedBridge = () => { const approveTxn = async () => { try { + dispatch(setIsWalletPending(true)) const tx = approveToken( bridgeQuote?.routerAddress, fromChainId, @@ -338,6 +338,8 @@ const StateManagedBridge = () => { getAndSetBridgeQuote() } catch (error) { return txErrorHandler(error) + } finally { + dispatch(setIsWalletPending(false)) } } @@ -377,7 +379,7 @@ const StateManagedBridge = () => { }) ) try { - setIsWalletPending(true) + dispatch(setIsWalletPending(true)) const wallet = await getWalletClient(wagmiConfig, { chainId: fromChainId, }) @@ -524,7 +526,7 @@ const StateManagedBridge = () => { return txErrorHandler(error) } finally { - setIsWalletPending(false) + dispatch(setIsWalletPending(false)) } } diff --git a/packages/synapse-interface/slices/bridge/reducer.ts b/packages/synapse-interface/slices/bridge/reducer.ts index 8a63215acf..6fbf365bb6 100644 --- a/packages/synapse-interface/slices/bridge/reducer.ts +++ b/packages/synapse-interface/slices/bridge/reducer.ts @@ -34,6 +34,7 @@ export interface BridgeState { toTokensBridgeQuotes: BridgeQuoteResponse[] toTokensBridgeQuotesStatus: FetchState isLoading: boolean + isWalletPending: boolean deadlineMinutes: number | null destinationAddress: Address | null } @@ -71,6 +72,7 @@ export const initialState: BridgeState = { toTokensBridgeQuotes: [], toTokensBridgeQuotesStatus: FetchState.IDLE, isLoading: false, + isWalletPending: false, deadlineMinutes: null, destinationAddress: null, } @@ -82,6 +84,9 @@ export const bridgeSlice = createSlice({ setIsLoading: (state, action: PayloadAction) => { state.isLoading = action.payload }, + setIsWalletPending: (state, action: PayloadAction) => { + state.isWalletPending = action.payload + }, setFromChainId: (state, action: PayloadAction) => { const incomingFromChainId = action.payload @@ -509,6 +514,7 @@ export const { setDeadlineMinutes, setDestinationAddress, setIsLoading, + setIsWalletPending, resetBridgeInputs, clearDestinationAddress, resetFetchedBridgeQuotes, From 1710a846d071ff2092c8ee5cc0aae088d75c9a2f Mon Sep 17 00:00:00 2001 From: bigboydiamonds Date: Tue, 18 Jun 2024 23:42:11 +0000 Subject: [PATCH 2/2] Publish - @synapsecns/synapse-interface@0.26.2 --- packages/synapse-interface/CHANGELOG.md | 11 +++++++++++ packages/synapse-interface/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 5194c28c6a..24fbbcf4f1 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.26.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.26.1...@synapsecns/synapse-interface@0.26.2) (2024-06-18) + + +### Bug Fixes + +* **synapse-interface:** disable input pending wallet ([#2738](https://github.com/synapsecns/sanguine/issues/2738)) ([667a90e](https://github.com/synapsecns/sanguine/commit/667a90e76c0f958c37b6b760af4228657df0332d)) + + + + + ## [0.26.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.26.0...@synapsecns/synapse-interface@0.26.1) (2024-06-18) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index c8dfcc923d..2229aeb3a4 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.26.1", + "version": "0.26.2", "private": true, "engines": { "node": ">=18.18.0"