Skip to content
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export WC_PROJECT_ID=""
export GA_KEY=""
export SOCKET_API_KEY=""

# SQUID
export SQUID_API_URL=""
export SQUID_INTEGRATOR_ID=""

# Passkey envs
export NEXT_PUBLIC_ZERO_DEV_PASSKEY_PROJECT_ID=""
export NEXT_PUBLIC_ZERO_DEV_BUNDLER_URL=""
Expand Down
28 changes: 11 additions & 17 deletions src/app/(mobile-ui)/withdraw/crypto/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { interfaces as peanutInterfaces } from '@squirrel-labs/peanut-sdk'
import { PEANUT_WALLET_CHAIN, PEANUT_WALLET_TOKEN } from '@/constants'
import { useRouter } from 'next/navigation'
import { useCallback, useEffect, useMemo } from 'react'
import { captureMessage } from '@sentry/nextjs'

export default function WithdrawCryptoPage() {
const router = useRouter()
Expand Down Expand Up @@ -75,10 +76,9 @@ export default function WithdrawCryptoPage() {
router.push('/withdraw')
return
}
dispatch(paymentActions.setChargeDetails(null))
clearErrors()
setCurrentView('INITIAL')
}, [amountToWithdraw, router, dispatch, setAmountToWithdraw, setCurrentView])
dispatch(paymentActions.setChargeDetails(null))
}, [amountToWithdraw])

useEffect(() => {
setPaymentError(paymentErrorFromHook)
Expand Down Expand Up @@ -205,19 +205,6 @@ export default function WithdrawCryptoPage() {

if (result.success && result.txHash) {
setCurrentView('STATUS')

// reset the entire withdraw flow after successful payment
setTimeout(() => {
setAmountToWithdraw('')
setWithdrawData(null)
setCurrentView('INITIAL')

// clear any errors
clearErrors()

// clear charge details
dispatch(paymentActions.setChargeDetails(null))
}, 3000) // wait 3 seconds to show success status before resetting
} else {
console.error('Withdrawal execution failed:', result.error)
const errMsg = result.error || 'Withdrawal processing failed.'
Expand Down Expand Up @@ -279,7 +266,14 @@ export default function WithdrawCryptoPage() {

// For peanut wallet flows, only RFQ routes are allowed
if (xChainRoute.type === 'swap') {
return 'This token pair is not available for withdraw.'
captureMessage('No RFQ route found for this token pair', {
level: 'warning',
extra: {
flow: 'withdraw',
routeObject: xChainRoute,
},
})
return 'No route found for this token pair. You can try with a different token pair, or try again later'
}

return null
Expand Down
7 changes: 7 additions & 0 deletions src/app/(mobile-ui)/withdraw/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function WithdrawPage() {
setError,
error,
resetWithdrawFlow,
setWithdrawData,
} = useWithdrawFlow()

const { balance } = useWallet()
Expand Down Expand Up @@ -93,6 +94,12 @@ export default function WithdrawPage() {
[setRawTokenAmount]
)

// Clean state
useEffect(() => {
setAmountToWithdraw('')
setWithdrawData(null)
}, [])

useEffect(() => {
if (rawTokenAmount === '') {
if (!amountFromContext) {
Expand Down
10 changes: 9 additions & 1 deletion src/components/Payment/Views/Confirm.payment.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useAccount } from 'wagmi'
import { PaymentInfoRow } from '../PaymentInfoRow'
import { formatUnits } from 'viem'
import { PEANUT_WALLET_CHAIN, PEANUT_WALLET_TOKEN } from '@/constants'
import { captureMessage } from '@sentry/nextjs'

type ConfirmPaymentViewProps = {
isPintaReq?: boolean
Expand Down Expand Up @@ -344,7 +345,14 @@ export default function ConfirmPaymentView({

// For peanut wallet flows, only RFQ routes are allowed
if (xChainRoute.type === 'swap') {
return 'This route requires external wallet payment. Peanut Wallet only supports RFQ (Request for Quote) routes.'
captureMessage('No RFQ route found for this token pair', {
level: 'warning',
extra: {
flow: 'payment',
routeObject: xChainRoute,
},
})
return 'No route found for this token pair. You can try with a different token pair, or try again later'
}

return null
Expand Down
3 changes: 3 additions & 0 deletions src/components/TransactionDetails/TransactionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ const TransactionCard: React.FC<TransactionCardProps> = ({
: transaction.currencySymbol || getDisplayCurrencySymbol(actualCurrencyCode) // Use provided sign+symbol or derive symbol

let amountString = Math.abs(amount).toString()
if (transaction.currency?.code === 'USD') {
amountString = transaction.currency?.amount
}
// If it's a token and not USD/ARS, transaction.tokenSymbol should be displayed after amount.
// And `displayDecimals` might need to come from token itself if available, else default.
const decimalsForDisplay = actualCurrencyCode // If it's a known currency (USD, ARS)
Expand Down
2 changes: 1 addition & 1 deletion src/constants/general.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const peanutWalletIsInPreview = true

export const INFURA_API_KEY = process.env.NEXT_PUBLIC_INFURA_API_KEY

export const SQUID_INTEGRATOR_ID = '11CBA45B-5EE9-4331-B146-48CCD7ED4C7C'
export const SQUID_INTEGRATOR_ID = process.env.SQUID_INTEGRATOR_ID!
export const SQUID_API_URL = process.env.SQUID_API_URL

export const infuraRpcUrls: Record<number, string> = {
Expand Down
14 changes: 8 additions & 6 deletions src/hooks/usePaymentInitiator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,14 @@ export const usePaymentInitiator = () => {

setIsCalculatingFees(true)
setEstimatedGasCost(
await estimateTransactionCostUsd(
tx.unsignedTx.from! as Address,
tx.unsignedTx.to! as Address,
tx.unsignedTx.data! as Hex,
selectedChainID
)
isPeanutWallet
? 0
: await estimateTransactionCostUsd(
tx.unsignedTx.from! as Address,
tx.unsignedTx.to! as Address,
tx.unsignedTx.data! as Hex,
selectedChainID
)
)
setIsCalculatingFees(false)
setUnsignedTx(tx.unsignedTx)
Expand Down
Loading