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
5 changes: 5 additions & 0 deletions .changeset/cool-pumpkins-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Dont retry on quote errors, show fiat value in every step
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"queryFn" | "queryKey" | "enabled"
>;

/**
* @internal
*/
type BuyWithCryptoQuoteError = {
status: string;
code: string;
statusCode: number;
};

/**
* Hook to get a price quote for performing a "Buy with crypto" transaction that allows users to buy a token with another token - aka a swap.
*
Expand Down Expand Up @@ -97,26 +88,6 @@
return getBuyWithCryptoQuote(params);
},
enabled: !!params,
retry(failureCount, error) {
if (failureCount > 3) {
return false;
}
try {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
const serverError = (error as any).error as BuyWithCryptoQuoteError;

if (serverError.code === "MINIMUM_PURCHASE_AMOUNT") {
return false;
}

if (serverError.statusCode === 404 || serverError.statusCode >= 500) {
return false;
}
} catch {
return true;
}

return true;
},
retry: false,

Check warning on line 91 in packages/thirdweb/src/react/core/hooks/pay/useBuyWithCryptoQuote.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/pay/useBuyWithCryptoQuote.ts#L91

Added line #L91 was not covered by tests
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"queryFn" | "queryKey" | "enabled"
>;

/**
* @internal
*/
type BuyWithFiatQuoteError = {
status: string;
code: string;
statusCode: number;
};

/**
* Hook to get a price quote for performing a "Buy with Fiat" transaction that allows users to buy a token with fiat currency.
*
Expand Down Expand Up @@ -85,26 +76,6 @@
return getBuyWithFiatQuote(params);
},
enabled: !!params,
retry(failureCount, error) {
if (failureCount > 3) {
return false;
}
try {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
const serverError = (error as any).error as BuyWithFiatQuoteError;

if (serverError.code === "MINIMUM_PURCHASE_AMOUNT") {
return false;
}

if (serverError.statusCode === 404 || serverError.statusCode >= 500) {
return false;
}
} catch {
return true;
}

return true;
},
retry: false,

Check warning on line 79 in packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuote.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuote.ts#L79

Added line #L79 was not covered by tests
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
useToTokenSelectionStates,
} from "./main/useUISelectionStates.js";
import { BuyTokenInput } from "./swap/BuyTokenInput.js";
import { FiatValue } from "./swap/FiatValue.js";
import { PaymentSelectionScreen } from "./swap/PaymentSelectionScreen.js";
import { SwapFlow } from "./swap/SwapFlow.js";
import { SwapScreenContent } from "./swap/SwapScreenContent.js";
Expand Down Expand Up @@ -669,7 +670,7 @@
justifyContent: "space-between",
}}
>
<Container flex="row" gap="xs" center="y">
<Container flex="row" gap="xxs" center="y">

Check warning on line 673 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx#L673

Added line #L673 was not covered by tests
<Input
variant="outline"
pattern="^[0-9]*[.,]?[0-9]*$"
Expand Down Expand Up @@ -738,6 +739,14 @@
token={props.selectedToken}
/>
</Container>

<FiatValue
chain={props.selectedChain}
client={props.client}
tokenAmount={props.tokenAmount}
token={props.selectedToken}
size="sm"
/>

Check warning on line 749 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx#L743-L749

Added lines #L743 - L749 were not covered by tests
</Container>

<ChainName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@

const toTokenInfo = partialSuccessToTokenInfo || (
<Text color="primaryText" size="sm">
{formatNumber(Number(toTokenAmount), 6)}
{formatNumber(Number(toTokenAmount), 6)}{" "}

Check warning on line 236 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx#L236

Added line #L236 was not covered by tests
<TokenSymbol token={toToken} chain={toChain} size="sm" inline />
</Text>
);
Expand Down
Loading