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

fe/updating-quote #3104

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const BridgeTransactionButton = ({
} = useBridgeState()
const { bridgeQuote, isLoading } = useBridgeQuoteState()
const {
hasSameSelectionsAsPreviousQuote,
hasQuoteOutputChanged,
hasUserConfirmedChange,
handleUserAcceptChange,
Expand Down Expand Up @@ -103,6 +104,16 @@ export const BridgeTransactionButton = ({
label: `Please select an Origin token`,
onClick: null,
}
} else if (isConnected && !hasSufficientBalance) {
buttonProperties = {
label: 'Insufficient balance',
onClick: null,
}
} else if (isLoading && hasSameSelectionsAsPreviousQuote) {
buttonProperties = {
label: 'Updating quote',
onClick: null,
}
} else if (isLoading) {
buttonProperties = {
label: `Bridge ${fromToken?.symbol}`,
Expand Down Expand Up @@ -150,11 +161,6 @@ export const BridgeTransactionButton = ({
label: 'Invalid bridge quote',
onClick: null,
}
} else if (!isLoading && isConnected && !hasSufficientBalance) {
buttonProperties = {
label: 'Insufficient balance',
onClick: null,
}
} else if (destinationAddress && !isAddress(destinationAddress)) {
buttonProperties = {
label: 'Invalid Destination address',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const useConfirmNewBridgePrice = () => {
[previousBridgeQuote, createBridgeSelections]
)

const hasSameSelectionsAsPreviousQuote = useMemo(
() => currentBridgeQuoteSelections === previousBridgeQuoteSelections,
[currentBridgeQuoteSelections, previousBridgeQuoteSelections]
)

const calculateOutputRelativeDifference = useCallback((quoteA, quoteB) => {
if (!quoteA?.outputAmountString || !quoteB?.outputAmountString) return null

Expand All @@ -48,8 +53,8 @@ export const useConfirmNewBridgePrice = () => {
if (!hasQuoteOutputChanged && !hasUserConfirmedChange) {
quoteRef.current = previousQuote
setHasQuoteOutputChanged(true)
setHasUserConfirmedChange(false)
}
setHasUserConfirmedChange(false)
}

const handleUserAcceptChange = () => {
Expand Down Expand Up @@ -110,6 +115,7 @@ export const useConfirmNewBridgePrice = () => {
])

return {
hasSameSelectionsAsPreviousQuote,
hasQuoteOutputChanged,
hasUserConfirmedChange,
handleUserAcceptChange,
Expand Down
Loading