Skip to content

Commit 38e089a

Browse files
[SDK] Only onramp for required transaction amount (#6605)
1 parent ef2f86c commit 38e089a

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

.changeset/cyan-kids-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Only onramp for the amount required for transaction flows in PayEmbed

packages/thirdweb/src/bridge/Buy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.quote", () => {
3535
});
3636
});
3737

38-
describe("Bridge.Buy.prepare", () => {
38+
describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.prepare", () => {
3939
it("should get a valid prepared quote", async () => {
4040
const quote = await Buy.prepare({
4141
originChainId: 1,

packages/thirdweb/src/bridge/Sell.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.quote", () => {
3535
});
3636
});
3737

38-
describe("Bridge.Sell.prepare", () => {
38+
describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.prepare", () => {
3939
it("should get a valid prepared quote", async () => {
4040
const quote = await Sell.prepare({
4141
originChainId: 1,

packages/thirdweb/src/pay/buyWithCrypto/getQuote.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ export async function getBuyWithCryptoQuote(
259259
data: data.transactionRequest.data as Hash,
260260
to: data.transactionRequest.to,
261261
value: BigInt(data.transactionRequest.value),
262-
gas: BigInt(data.transactionRequest.gasLimit),
263-
gasPrice: undefined, // ignore gas price returned by the quote, we handle it ourselves
264262
},
265263
approvalData,
266264
swapDetails: {

packages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export async function getBuyWithCryptoTransfer(
155155
data: data.transactionRequest.data as Hash,
156156
to: data.transactionRequest.to as Address,
157157
value: BigInt(data.transactionRequest.value),
158-
gas: BigInt(data.transactionRequest.gasLimit),
159158
},
160159
approvalData: data.approval,
161160
fromAddress: data.fromAddress,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ function SelectedTokenInfo(props: {
625625
disabled?: boolean;
626626
}) {
627627
const getWidth = () => {
628-
const amount = formatNumber(Number(props.tokenAmount), 5).toString();
628+
const amount = formatNumber(Number(props.tokenAmount), 6).toString();
629629
let chars = amount.replace(".", "").length;
630630
const hasDot = amount.includes(".");
631631
if (hasDot) {

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ export function TransactionModeScreen(props: {
334334
variant="accent"
335335
fullWidth
336336
onClick={() => {
337-
let totalCostWei = transactionCostAndData.transactionValueWei;
337+
let totalCostWei = insufficientFunds
338+
? transactionCostAndData.transactionValueWei -
339+
(balanceQuery.data?.value || 0n)
340+
: transactionCostAndData.transactionValueWei;
338341
if (
339342
transactionCostAndData.token.address === NATIVE_TOKEN_ADDRESS &&
340343
!sponsoredTransactionsEnabled

0 commit comments

Comments
 (0)