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/fluffy-rings-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix PayEmbed purchase success callback and insufficient funds displayed when no metadata is passed in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js";
import type { AssetTabs } from "../../../../react/web/ui/ConnectWallet/screens/ViewAssets.js";
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
import type { Hex } from "../../../../utils/encoding/hex.js";
import type { Prettify } from "../../../../utils/type-utils.js";
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
Expand Down Expand Up @@ -114,6 +115,11 @@ export type PayUIOptions = Prettify<
| {
type: "fiat";
status: BuyWithFiatStatus;
}
| {
type: "transaction";
chainId: number;
transactionHash: Hex;
},
) => void;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { sendTransaction } from "../../../../transaction/actions/send-transactio
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
import { getTransactionGasCost } from "../../../../transaction/utils.js";
import type { Hex } from "../../../../utils/encoding/hex.js";
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import { getTokenBalance } from "../../../../wallets/utils/getTokenBalance.js";
Expand Down Expand Up @@ -74,6 +75,11 @@ export type SendTransactionPayModalConfig =
| {
type: "fiat";
status: BuyWithFiatStatus;
}
| {
type: "transaction";
chainId: number;
transactionHash: Hex;
},
) => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
return <LoadingScreen />;
}

const insufficientFunds =
balanceQuery.data &&
balanceQuery.data.value < transactionCostAndData.transactionValueWei;

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

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx#L128-L130

Added lines #L128 - L130 were not covered by tests

return (
<Container p="lg">
<ModalHeader title={metadata?.name || "Transaction"} />
Expand All @@ -144,9 +148,11 @@
/>
) : activeAccount ? (
<Container flex="column" gap="sm">
<Text size="sm" color="danger" style={{ textAlign: "center" }}>
Insufficient funds
</Text>
{insufficientFunds && (
<Text size="sm" color="danger" style={{ textAlign: "center" }}>

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

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx#L151-L152

Added lines #L151 - L152 were not covered by tests
Insufficient funds
</Text>

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L154 was not covered by tests
)}
<Container
flex="row"
style={{
Expand Down
8 changes: 7 additions & 1 deletion packages/thirdweb/src/react/web/ui/PayEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@
onBack={() => {
setScreen("buy");
}}
onTxSent={() => {}}
onTxSent={(data) => {
props.payOptions?.onPurchaseSuccess?.({
type: "transaction",
chainId: data.chain.id,
transactionHash: data.transactionHash,
});
}}

Check warning on line 374 in packages/thirdweb/src/react/web/ui/PayEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/PayEmbed.tsx#L368-L374

Added lines #L368 - L374 were not covered by tests
/>
)}
</>
Expand Down
Loading