-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(synapse-interface): bridge quote state validations (#3019)
* Extracts bridgeQuote into own state * Moves quote fetching to async thunk * Bridge approved check hook * Deprecates redux fromValue in favor of local input component behavior * useBridgeSelections * useBridgeValidations * fix: stale output, infinite loader * fix: track when input less than fees * apply validation + selection hook to input/output containes * use bridge state for bridge write actions * Fix chain comparison * feat: compare input amount vs tracked quoted input * Compare stringified bridge quote v bridge state for validation * feat: track quoted tokens <> bridge quote (#3018) * replace validation in callback with button check * memoize bridge selection comparisons * segment tracking state <> quote mismatch error * simplify segment * switch order * Add back doesBridgeStateMatchQuote * add back additional bridge quote fields * remove unused bridge selection vars * fix: conditions for active button for connect wallet * fix: condition for showing amount must be greater than fee * Checks if user is typing * Adds swap behavior --------- Co-authored-by: abtestingalpha <[email protected]> * Post submit * Clears input value post submit --------- Co-authored-by: bigboydiamonds <[email protected]>
- Loading branch information
1 parent
013d4b9
commit 649b3f5
Showing
29 changed files
with
751 additions
and
1,181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/synapse-interface/components/StateManagedBridge/FromChainSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { setFromChainId } from '@/slices/bridge/reducer' | ||
import { ChainSelector } from '@/components/ui/ChainSelector' | ||
import { CHAINS_BY_ID } from '@/constants/chains' | ||
import { useFromChainListArray } from './hooks/useFromChainListArray' | ||
import { useBridgeState } from '@/slices/bridge/hooks' | ||
import { useWalletState } from '@/slices/wallet/hooks' | ||
|
||
export const FromChainSelector = () => { | ||
const { fromChainId } = useBridgeState() | ||
const { isWalletPending } = useWalletState() | ||
|
||
return ( | ||
<ChainSelector | ||
dataTestId="bridge-origin-chain" | ||
selectedItem={CHAINS_BY_ID[fromChainId]} | ||
isOrigin={true} | ||
label="From" | ||
itemListFunction={useFromChainListArray} | ||
setFunction={setFromChainId} | ||
action="Bridge" | ||
disabled={isWalletPending} | ||
/> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/synapse-interface/components/StateManagedBridge/FromTokenSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { setFromToken } from '@/slices/bridge/reducer' | ||
import { TokenSelector } from '@/components/ui/TokenSelector' | ||
import { useBridgeState } from '@/slices/bridge/hooks' | ||
import { useFromTokenListArray } from './hooks/useFromTokenListArray' | ||
import { useWalletState } from '@/slices/wallet/hooks' | ||
|
||
export const FromTokenSelector = () => { | ||
const { fromToken } = useBridgeState() | ||
const { isWalletPending } = useWalletState() | ||
|
||
return ( | ||
<TokenSelector | ||
dataTestId="bridge-origin-token" | ||
selectedItem={fromToken} | ||
isOrigin={true} | ||
placeholder="Out" | ||
itemListFunction={useFromTokenListArray} | ||
setFunction={setFromToken} | ||
action="Bridge" | ||
disabled={isWalletPending} | ||
/> | ||
) | ||
} |
Oops, something went wrong.