-
Notifications
You must be signed in to change notification settings - Fork 547
Feature: New UB Components #7354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
fe64ae4
WIP brige embed
joaquim-verges 88618c8
refactor: account for fee action
gregfromstl 337f52f
fix: disable start transaction button on autostart
gregfromstl 0c0b747
fix: respect updated amount
gregfromstl 8763876
feat: include prices in routes
gregfromstl a906c6e
feat: sort by dollar balance
gregfromstl 11e831e
nit: adjust chain icon position
gregfromstl 8b24014
feat: improve number formatting
gregfromstl c6737a0
polish direct payment screen ui
joaquim-verges a486c8a
code cleanup
joaquim-verges c6112fe
top up label
joaquim-verges dcd7b08
TransactionPayment component
joaquim-verges ec80659
update paymentMachine tests
joaquim-verges c0da29c
update FundWallet look
joaquim-verges a10b218
feat: adds token not supported screen
gregfromstl 90fef12
docs: adds theme stories
gregfromstl c0429e1
feat: auto-add unsupported tokens
gregfromstl 224e2af
refactor: make token name and symbol optional
gregfromstl 2221dcf
feat: enable passing quickOptions
gregfromstl 74faebe
ui polish, reuse header accross all modes
joaquim-verges 2998cfe
UI polish for transactions and tokens
joaquim-verges e600e26
update useSendTransaction to use new widget
joaquim-verges f3f49cd
transaction execution
joaquim-verges 6499e49
incorporate post buy transaction in the state machine
joaquim-verges 7ae018b
update payment state machine tests
joaquim-verges 984c348
playground build
joaquim-verges d2dcf7c
refactor: rename quickOptions to presetOptions for consistency across…
gregfromstl 84a5e8c
feat: adds onramp logos
gregfromstl 484a3e1
feat: show quotes for onramp providers
gregfromstl b88f8ba
refactor: refresh quote on step runner
gregfromstl 8ec1bf5
Merge branch 'main' into 05-30-wip_brige_embed
gregfromstl a675f08
fix: include erc20 value in docs
gregfromstl 76c0e00
Merge branch 'main' into 05-30-wip_brige_embed
gregfromstl b386d39
feat: adds BuyEmbed
gregfromstl 355eecd
feat: CheckoutWidget component
gregfromstl 1cc003d
feat: TransactionWidget
gregfromstl 271840e
lint
gregfromstl 919531b
lint
gregfromstl f90fcdc
fix: update playground bridge form
gregfromstl 581127c
Merge branch 'main' into greg/new-ub-components
gregfromstl f267b5d
lint
gregfromstl 4489854
nit: remove @buyCrypto tag
gregfromstl 0ad85a1
chore: adds changeset
gregfromstl 7c734ca
fix: Remove AI tasks lists
gregfromstl 1ce2227
fix: storybook versions
gregfromstl 5e73246
lint
gregfromstl ce05d89
remove storybook-dependant tests
gregfromstl 1ad187b
lint
gregfromstl 00c4f27
fix tests
gregfromstl 74717d7
fix dashboard build
gregfromstl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Adds new components BuyWidget, CheckoutWidget, and TransactionWidget | ||
|
||
## BuyWidget | ||
A component that allows users to purchase tokens or NFTs directly within your application. | ||
|
||
### Example: | ||
```tsx | ||
import { BuyWidget } from "thirdweb/react"; | ||
|
||
function App() { | ||
return ( | ||
<BuyWidget | ||
client={client} | ||
chain={chain} | ||
tokenAddress="0x..." // Token or NFT contract address | ||
recipient="0x..." // Optional: recipient address | ||
theme="light" // Optional: "light" or "dark" | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
## CheckoutWidget | ||
A comprehensive checkout experience for purchasing digital assets with multiple payment options. | ||
|
||
### Example: | ||
```tsx | ||
import { CheckoutWidget } from "thirdweb/react"; | ||
|
||
function App() { | ||
return ( | ||
<CheckoutWidget | ||
client={client} | ||
chain={chain} | ||
items={[ | ||
{ | ||
tokenAddress: "0x...", | ||
tokenId: "1", // For NFTs | ||
quantity: "1" | ||
} | ||
]} | ||
onSuccess={(result) => console.log("Purchase successful:", result)} | ||
theme="dark" // Optional: "light" or "dark" | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
## TransactionWidget | ||
A widget for executing arbitrary blockchain transactions with a user-friendly interface. | ||
|
||
### Example: | ||
```tsx | ||
import { TransactionWidget } from "thirdweb/react"; | ||
import { prepareContractCall } from "thirdweb"; | ||
|
||
function App() { | ||
const transaction = prepareContractCall({ | ||
contract: myContract, | ||
method: "transfer", | ||
params: [recipientAddress, amount] | ||
}); | ||
|
||
return ( | ||
<TransactionWidget | ||
client={client} | ||
transaction={transaction} | ||
onSuccess={(result) => console.log("Transaction successful:", result)} | ||
onError={(error) => console.error("Transaction failed:", error)} | ||
theme="light" // Optional: "light" or "dark" | ||
/> | ||
); | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Guard against
undefined
before the switch to preserve discriminated-union narrowingUsing
switch (result?.type)
widens the expression to'crypto' | 'fiat' | 'transaction' | undefined
, preventing TypeScript from narrowingresult
inside each case. This forcesresult.status
/result.transactionHash
to be typed asany
, defeating the benefit of the discriminated union and risking silent type regressions.Proposed fix: short-circuit when
result
is falsy, then switch on the guaranteed, non-optionalresult.type
.Optionally add a
default
branch to future-proof against new result types.📝 Committable suggestion
🤖 Prompt for AI Agents