Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
154241a
feat: enhance FallbackPurchaseUI with WaaS fee options integration
mithatakbulut Sep 17, 2025
caec965
fix: improve transaction steps handling by incorporating allowance lo…
mithatakbulut Sep 18, 2025
8f38992
fix format
mithatakbulut Sep 18, 2025
a7bc231
refactor: streamline FallbackPurchaseUI component and improve button …
mithatakbulut Sep 18, 2025
87dda1b
temp: keep `0xsequence/connect/useWaasFeeOptions` until it's fixed in…
mithatakbulut Sep 18, 2025
3d64d86
renamve `useSelectWaasFeeOptions` to have .tsx extension to render Re…
mithatakbulut Sep 18, 2025
6f4001d
refactor waasFeeOption hooks. remove local repetative states, respect…
mithatakbulut Sep 18, 2025
2ddca41
bundle approval + purchase transactions for Sequence embedded wallets…
mithatakbulut Sep 18, 2025
22ec0a8
temp: add necessary sequence packages for useWaasFeeOptions to work
mithatakbulut Sep 18, 2025
c827115
rename useExecutePurchaseWithWaas and add error handling
mithatakbulut Sep 19, 2025
d88017e
add missing type `Transaction`. set `isExecuting` to false once an er…
mithatakbulut Sep 19, 2025
f49b51e
fix SelectWaasFeeOptions.test.tsx
mithatakbulut Sep 19, 2025
dea7388
Update BuyModal to support additional hash types
mithatakbulut Sep 19, 2025
ef0b783
biome-check
mithatakbulut Sep 19, 2025
af2b247
redo type change in Buy Modal store
mithatakbulut Sep 19, 2025
5eb70c4
take 0xtrails package back
mithatakbulut Sep 19, 2025
dadcb13
fix tests: Refactor transaction hooks to maintain backwards compatibi…
mithatakbulut Sep 19, 2025
490e164
remove waas fee selection components and hooks from FallabckPurcaseUI
mithatakbulut Sep 19, 2025
1e7e8a3
remove sequence/hooks and change useWaasFeeOptions to accept requeire…
mithatakbulut Sep 19, 2025
082bfa1
Enhance BuyModalContent to handle pending fee option rejection
mithatakbulut Sep 19, 2025
7347a9b
fix type check: indexer client import of useExecutePurchaseWithwaas
mithatakbulut Sep 19, 2025
65ae74e
Add ErrorLogBox component and integrate error handling in FallbackPur…
mithatakbulut Sep 19, 2025
aa220c9
move ErrorLogBox to more general directory, internal components
mithatakbulut Sep 19, 2025
57fadc3
fix type check usewaasfeeoptionmanager
mithatakbulut Sep 19, 2025
2cf81ed
fix import of error log box
mithatakbulut Sep 19, 2025
239a857
value is not required. remove any from mockCurrencyBalance in test
mithatakbulut Sep 19, 2025
fe2d334
manage display of approve button for sequence wallets. refactor `exec…
mithatakbulut Sep 22, 2025
7d6957d
rename the hook to useExecuteBundledTransactions.ts
mithatakbulut Sep 22, 2025
024cc55
only bundle transactions if there is an approval step
mithatakbulut Sep 22, 2025
3463abe
Refactor useWaasFeeOptions return type from array to object
mithatakbulut Sep 22, 2025
b298be7
Refactor useWaasFeeOptions to utilize a centralized state management …
mithatakbulut Sep 22, 2025
0f21806
move useWaasFeeOptions into hooks directory
mithatakbulut Sep 22, 2025
ce0e733
use currency image
mithatakbulut Sep 23, 2025
73b684c
fix sufficient balance hook to work well for free value
mithatakbulut Sep 23, 2025
3af0b15
Refactor useMarketTransactionSteps to utilize walletKind from useConn…
mithatakbulut Oct 10, 2025
b0641a4
enhance fallback buy modal styles
mithatakbulut Oct 10, 2025
c990dc0
biome-check
mithatakbulut Oct 10, 2025
c539390
fix BuyModal to use salePriceAmount and marketPriceAmount while showi…
mithatakbulut Oct 29, 2025
af45cb4
Refactor BuyModal to use salePrice object instead of salePriceAmount
mithatakbulut Oct 29, 2025
933a78c
use `walletType:unknown` while generating buy steps
mithatakbulut Oct 29, 2025
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 @@ -55,7 +55,10 @@ export function usePrimarySaleTransactionSteps({
});

// Check allowance if using ERC20
const { data: allowance } = useReadContract({
const {
data: allowance,
isLoading: allowanceLoading,
} = useReadContract({
address: paymentToken,
abi: ERC20_ABI,
functionName: 'allowance',
Expand Down Expand Up @@ -138,7 +141,7 @@ export function usePrimarySaleTransactionSteps({

return steps;
},
enabled: enabled && !!buyer && !!abi && !abiLoading,
enabled: enabled && !!buyer && !!abi && !abiLoading && !allowanceLoading,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ import { Media } from '../../../components/media/Media';
import { useBuyModalData } from '../hooks/useBuyModalData';
import { useHasSufficientBalance } from '../hooks/useHasSufficientBalance';
import { FallbackPurchaseUISkeleton } from './FallbackPurchaseUISkeleton';
import {
selectWaasFeeOptionsStore,
useSelectWaasFeeOptionsStore,
} from '../../_internal/components/selectWaasFeeOptions/store';
import { useSelectWaasFeeOptions } from '../../_internal/hooks/useSelectWaasFeeOptions';
import { FeeOption } from '../../../../../types/waas-types';
import SelectWaasFeeOptions from '../../_internal/components/selectWaasFeeOptions';
import { useConnectorMetadata } from '../../../../hooks';
import { getNetwork } from '@0xsequence/connect';
import { NetworkType } from '@0xsequence/network';

export interface FallbackPurchaseUIProps {
chainId: number;
Expand All @@ -35,6 +45,7 @@ export const FallbackPurchaseUI = ({
const [isExecuting, setIsExecuting] = useState(false);
const [isApproving, setIsApproving] = useState(false);
const [isSwitchingChain, setIsSwitchingChain] = useState(false);
const { isWaaS } = useConnectorMetadata();

const buyStep = steps.find((step) => step.id === StepType.buy);
if (!buyStep) throw new Error('Buy step not found');
Expand Down Expand Up @@ -63,6 +74,24 @@ export const FallbackPurchaseUI = ({
? currencyAddress
: (salePrice?.currencyAddress as Address);

const { isVisible: feeOptionsVisible, selectedFeeOption } =
useSelectWaasFeeOptionsStore();
const isAnyTransactionPending =
isApproving || isExecuting || isSwitchingChain;

const network = getNetwork(Number(chainId));
const isTestnet = network.type === NetworkType.TESTNET;

const {
shouldHideActionButton: shouldHideBuyButton,
waasFeeOptionsShown,
getActionLabel,
} = useSelectWaasFeeOptions({
isProcessing: isAnyTransactionPending,
feeOptionsVisible,
selectedFeeOption: selectedFeeOption as FeeOption,
});

const { data, isLoading: isLoadingBalance } = useHasSufficientBalance({
chainId,
value: BigInt(priceAmount || 0),
Expand All @@ -81,7 +110,7 @@ export const FallbackPurchaseUI = ({
const to = step.to as Address;
const value = BigInt(step.value);

if (!data || !to || !value) {
if (!data || !to) {
toast({
title: 'Invalid step',
variant: 'error',
Expand Down Expand Up @@ -129,6 +158,10 @@ export const FallbackPurchaseUI = ({
const executeBuy = async () => {
setIsExecuting(true);
try {
if (isWaaS && !isTestnet) {
selectWaasFeeOptionsStore.send({ type: 'show' });
}

const hash = await executeTransaction(buyStep);

onSuccess(hash);
Expand Down Expand Up @@ -190,8 +223,6 @@ export const FallbackPurchaseUI = ({
return `${formattedPrice} ${currency?.symbol}`;
};

const isAnyTransactionPending =
isApproving || isExecuting || isSwitchingChain;
const canApprove =
hasSufficientBalance &&
!isLoadingBalance &&
Expand All @@ -203,6 +234,7 @@ export const FallbackPurchaseUI = ({
!isLoadingBuyModalData &&
!approvalStep &&
isOnCorrectChain;
const buyButtonLabel = getActionLabel('Buy now');

if (isLoadingBuyModalData || isLoadingBalance) {
return (
Expand Down Expand Up @@ -307,15 +339,27 @@ export const FallbackPurchaseUI = ({
/>
)}

<Button
onClick={executeBuy}
pending={isExecuting}
disabled={!canBuy || isAnyTransactionPending}
variant="primary"
size="lg"
label={isExecuting ? 'Confirming Purchase...' : 'Buy Now'}
className="w-full"
/>
{!shouldHideBuyButton && (
<Button
onClick={executeBuy}
pending={isExecuting}
disabled={!canBuy || isAnyTransactionPending}
variant="primary"
size="lg"
label={isExecuting ? 'Confirming Purchase...' : buyButtonLabel}
className="w-full"
/>
)}

{waasFeeOptionsShown && (
<SelectWaasFeeOptions
chainId={Number(chainId)}
onCancel={() => {
setIsExecuting(false);
}}
titleOnConfirm="Processing purchase..."
/>
)}
</div>
</div>
);
Expand Down