Skip to content

Commit

Permalink
Merge 2344c53 into cd75683
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboydiamonds authored Sep 5, 2024
2 parents cd75683 + 2344c53 commit f9061af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
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 All @@ -59,6 +60,11 @@ export const BridgeTransactionButton = ({
const { showDestinationWarning, isDestinationWarningAccepted } =
useBridgeDisplayState()

console.log(
'hasSameSelectionsAsPreviousQuote: ',
hasSameSelectionsAsPreviousQuote
)

const {
hasValidInput,
hasValidQuote,
Expand Down Expand Up @@ -103,6 +109,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 +166,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

0 comments on commit f9061af

Please sign in to comment.