thirdweb 5.69.0 → 5.70.0-nightly-ecaa304a812188da3c81888bb52ca6064093c139-20241121000332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/client.js +1 -0
- package/dist/cjs/client/client.js.map +1 -1
- package/dist/cjs/exports/react.js +32 -3
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/extensions/erc721/lazyMinting/read/getBatchesToReveal.js +1 -1
- package/dist/cjs/extensions/modules/common/checkModulesCompatibility.js +5 -0
- package/dist/cjs/extensions/modules/common/checkModulesCompatibility.js.map +1 -1
- package/dist/cjs/extensions/pack/createNewPack.js +2 -1
- package/dist/cjs/extensions/pack/createNewPack.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-pack.js +1 -0
- package/dist/cjs/extensions/prebuilts/deploy-pack.js.map +1 -1
- package/dist/cjs/extensions/thirdweb/write/publish.js +4 -0
- package/dist/cjs/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/cjs/react/core/hooks/others/useChainQuery.js +3 -3
- package/dist/cjs/react/core/hooks/rpc/useBlockNumber.js +1 -1
- package/dist/cjs/react/core/hooks/wallets/useCapabilities.js +1 -1
- package/dist/cjs/react/core/hooks/wallets/useSendCalls.js +3 -3
- package/dist/cjs/react/core/providers/connection-manager.js +3 -0
- package/dist/cjs/react/core/providers/connection-manager.js.map +1 -1
- package/dist/cjs/react/core/utils/wallet.js +2 -1
- package/dist/cjs/react/core/utils/wallet.js.map +1 -1
- package/dist/cjs/react/core/utils/walletIcon.js +2 -0
- package/dist/cjs/react/core/utils/walletIcon.js.map +1 -1
- package/dist/cjs/react/native/hooks/wallets/useProfiles.js +1 -1
- package/dist/cjs/react/native/providers/thirdweb-provider.js +1 -0
- package/dist/cjs/react/native/providers/thirdweb-provider.js.map +1 -1
- package/dist/cjs/react/native/ui/AutoConnect/AutoConnect.js +1 -0
- package/dist/cjs/react/native/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectModal.js +1 -0
- package/dist/cjs/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/cjs/react/native/ui/transaction/TransactionButton.js +1 -0
- package/dist/cjs/react/native/ui/transaction/TransactionButton.js.map +1 -1
- package/dist/cjs/react/web/hooks/wallets/useProfiles.js +1 -1
- package/dist/cjs/react/web/providers/thirdweb-provider.js +1 -0
- package/dist/cjs/react/web/providers/thirdweb-provider.js.map +1 -1
- package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js +1 -0
- package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Blobbie.js +19 -4
- package/dist/cjs/react/web/ui/ConnectWallet/Blobbie.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +21 -19
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +18 -13
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +9 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +15 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +1 -0
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/SiteEmbed.js +3 -2
- package/dist/cjs/react/web/ui/SiteEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/SiteLink.js +2 -1
- package/dist/cjs/react/web/ui/SiteLink.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/index.js +1 -0
- package/dist/cjs/react/web/ui/TransactionButton/index.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/address.js +49 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/address.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js +144 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/balance.js +122 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/balance.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js +16 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/name.js +106 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/name.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/provider.js +43 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/provider.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/description.js +69 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/description.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/hooks.js +45 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/hooks.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/media.js +82 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/media.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/name.js +68 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/name.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js +55 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/icon.js +113 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/icon.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/name.js +137 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/name.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/provider.js +54 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/provider.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js +134 -0
- package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js.map +1 -0
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
- package/dist/cjs/storage/unpin.js +1 -1
- package/dist/cjs/storage/upload.js +1 -0
- package/dist/cjs/storage/upload.js.map +1 -1
- package/dist/cjs/transaction/actions/to-serializable-transaction.js +1 -1
- package/dist/cjs/transaction/actions/zksync/send-eip712-transaction.js +5 -0
- package/dist/cjs/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +5 -0
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/utils/config.js +9 -0
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/json.js +7 -4
- package/dist/cjs/utils/json.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/eip5792/get-calls-status.js +1 -1
- package/dist/cjs/wallets/eip5792/get-capabilities.js +1 -1
- package/dist/cjs/wallets/eip5792/send-calls.js +2 -2
- package/dist/cjs/wallets/eip5792/wait-for-bundle.js +1 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js +1 -1
- package/dist/cjs/wallets/in-app/web/ecosystem.js +7 -17
- package/dist/cjs/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/in-app.js +2 -17
- package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js +1 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/passkeys.js +17 -16
- package/dist/cjs/wallets/in-app/web/lib/auth/passkeys.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +1 -0
- package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/esm/client/client.js +1 -0
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/exports/react.js +17 -1
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/extensions/erc721/lazyMinting/read/getBatchesToReveal.js +1 -1
- package/dist/esm/extensions/modules/common/checkModulesCompatibility.js +5 -0
- package/dist/esm/extensions/modules/common/checkModulesCompatibility.js.map +1 -1
- package/dist/esm/extensions/pack/createNewPack.js +2 -1
- package/dist/esm/extensions/pack/createNewPack.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-pack.js +1 -0
- package/dist/esm/extensions/prebuilts/deploy-pack.js.map +1 -1
- package/dist/esm/extensions/thirdweb/write/publish.js +4 -0
- package/dist/esm/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/esm/react/core/hooks/others/useChainQuery.js +3 -3
- package/dist/esm/react/core/hooks/rpc/useBlockNumber.js +1 -1
- package/dist/esm/react/core/hooks/wallets/useCapabilities.js +1 -1
- package/dist/esm/react/core/hooks/wallets/useSendCalls.js +3 -3
- package/dist/esm/react/core/providers/connection-manager.js +3 -0
- package/dist/esm/react/core/providers/connection-manager.js.map +1 -1
- package/dist/esm/react/core/utils/wallet.js +2 -1
- package/dist/esm/react/core/utils/wallet.js.map +1 -1
- package/dist/esm/react/core/utils/walletIcon.js +2 -0
- package/dist/esm/react/core/utils/walletIcon.js.map +1 -1
- package/dist/esm/react/native/hooks/wallets/useProfiles.js +1 -1
- package/dist/esm/react/native/providers/thirdweb-provider.js +1 -0
- package/dist/esm/react/native/providers/thirdweb-provider.js.map +1 -1
- package/dist/esm/react/native/ui/AutoConnect/AutoConnect.js +1 -0
- package/dist/esm/react/native/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectModal.js +1 -0
- package/dist/esm/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/esm/react/native/ui/transaction/TransactionButton.js +1 -0
- package/dist/esm/react/native/ui/transaction/TransactionButton.js.map +1 -1
- package/dist/esm/react/web/hooks/wallets/useProfiles.js +1 -1
- package/dist/esm/react/web/providers/thirdweb-provider.js +1 -0
- package/dist/esm/react/web/providers/thirdweb-provider.js.map +1 -1
- package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js +1 -0
- package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Blobbie.js +19 -4
- package/dist/esm/react/web/ui/ConnectWallet/Blobbie.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +21 -19
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +19 -14
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +9 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +15 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +1 -0
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/SiteEmbed.js +3 -2
- package/dist/esm/react/web/ui/SiteEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/SiteLink.js +2 -1
- package/dist/esm/react/web/ui/SiteLink.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/index.js +1 -0
- package/dist/esm/react/web/ui/TransactionButton/index.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Account/address.js +46 -0
- package/dist/esm/react/web/ui/prebuilt/Account/address.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/avatar.js +141 -0
- package/dist/esm/react/web/ui/prebuilt/Account/avatar.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/balance.js +119 -0
- package/dist/esm/react/web/ui/prebuilt/Account/balance.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js +13 -0
- package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/name.js +103 -0
- package/dist/esm/react/web/ui/prebuilt/Account/name.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/provider.js +39 -0
- package/dist/esm/react/web/ui/prebuilt/Account/provider.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/description.js +66 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/description.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/hooks.js +41 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/hooks.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/media.js +79 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/media.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/name.js +65 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/name.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/provider.js +50 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/provider.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Token/icon.js +110 -0
- package/dist/esm/react/web/ui/prebuilt/Token/icon.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Token/name.js +134 -0
- package/dist/esm/react/web/ui/prebuilt/Token/name.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Token/provider.js +50 -0
- package/dist/esm/react/web/ui/prebuilt/Token/provider.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/Token/symbol.js +131 -0
- package/dist/esm/react/web/ui/prebuilt/Token/symbol.js.map +1 -0
- package/dist/esm/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
- package/dist/esm/storage/unpin.js +1 -1
- package/dist/esm/storage/upload.js +1 -0
- package/dist/esm/storage/upload.js.map +1 -1
- package/dist/esm/transaction/actions/to-serializable-transaction.js +1 -1
- package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js +5 -0
- package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +5 -0
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/utils/config.js +9 -0
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/json.js +6 -2
- package/dist/esm/utils/json.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/eip5792/get-calls-status.js +1 -1
- package/dist/esm/wallets/eip5792/get-capabilities.js +1 -1
- package/dist/esm/wallets/eip5792/send-calls.js +2 -2
- package/dist/esm/wallets/eip5792/wait-for-bundle.js +1 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js +1 -1
- package/dist/esm/wallets/in-app/web/ecosystem.js +7 -17
- package/dist/esm/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/esm/wallets/in-app/web/in-app.js +2 -17
- package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/index.js +1 -0
- package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/passkeys.js +18 -17
- package/dist/esm/wallets/in-app/web/lib/auth/passkeys.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +1 -0
- package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/types/client/client.d.ts +1 -0
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/exports/react.d.ts +14 -1
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/extensions/erc721/lazyMinting/read/getBatchesToReveal.d.ts +1 -1
- package/dist/types/extensions/modules/common/checkModulesCompatibility.d.ts +5 -0
- package/dist/types/extensions/modules/common/checkModulesCompatibility.d.ts.map +1 -1
- package/dist/types/extensions/pack/createNewPack.d.ts +2 -2
- package/dist/types/extensions/pack/createNewPack.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/deploy-pack.d.ts +1 -0
- package/dist/types/extensions/prebuilts/deploy-pack.d.ts.map +1 -1
- package/dist/types/extensions/thirdweb/write/publish.d.ts +4 -0
- package/dist/types/extensions/thirdweb/write/publish.d.ts.map +1 -1
- package/dist/types/react/core/hooks/others/useChainQuery.d.ts +3 -3
- package/dist/types/react/core/hooks/rpc/useBlockNumber.d.ts +1 -1
- package/dist/types/react/core/hooks/wallets/useCapabilities.d.ts +1 -1
- package/dist/types/react/core/hooks/wallets/useSendCalls.d.ts +3 -3
- package/dist/types/react/core/providers/connection-manager.d.ts +3 -0
- package/dist/types/react/core/providers/connection-manager.d.ts.map +1 -1
- package/dist/types/react/core/utils/wallet.d.ts +2 -1
- package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
- package/dist/types/react/core/utils/walletIcon.d.ts +2 -0
- package/dist/types/react/core/utils/walletIcon.d.ts.map +1 -1
- package/dist/types/react/native/hooks/wallets/useProfiles.d.ts +1 -1
- package/dist/types/react/native/providers/thirdweb-provider.d.ts +1 -0
- package/dist/types/react/native/providers/thirdweb-provider.d.ts.map +1 -1
- package/dist/types/react/native/ui/AutoConnect/AutoConnect.d.ts +1 -0
- package/dist/types/react/native/ui/AutoConnect/AutoConnect.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/ConnectModal.d.ts +1 -0
- package/dist/types/react/native/ui/connect/ConnectModal.d.ts.map +1 -1
- package/dist/types/react/native/ui/transaction/TransactionButton.d.ts +1 -0
- package/dist/types/react/native/ui/transaction/TransactionButton.d.ts.map +1 -1
- package/dist/types/react/web/hooks/wallets/useProfiles.d.ts +1 -1
- package/dist/types/react/web/providers/thirdweb-provider.d.ts +1 -0
- package/dist/types/react/web/providers/thirdweb-provider.d.ts.map +1 -1
- package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts +1 -0
- package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Blobbie.d.ts +22 -5
- package/dist/types/react/web/ui/ConnectWallet/Blobbie.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts +2 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +2 -2
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/SiteEmbed.d.ts +3 -2
- package/dist/types/react/web/ui/SiteEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/SiteLink.d.ts +2 -1
- package/dist/types/react/web/ui/SiteLink.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/index.d.ts +1 -0
- package/dist/types/react/web/ui/TransactionButton/index.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/address.d.ts +52 -0
- package/dist/types/react/web/ui/prebuilt/Account/address.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Account/avatar.d.ts +142 -0
- package/dist/types/react/web/ui/prebuilt/Account/avatar.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts +137 -0
- package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Account/blobbie.d.ts +8 -0
- package/dist/types/react/web/ui/prebuilt/Account/blobbie.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Account/name.d.ts +119 -0
- package/dist/types/react/web/ui/prebuilt/Account/name.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Account/provider.d.ts +45 -0
- package/dist/types/react/web/ui/prebuilt/Account/provider.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/NFT/description.d.ts +59 -0
- package/dist/types/react/web/ui/prebuilt/NFT/description.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/NFT/hooks.d.ts +14 -0
- package/dist/types/react/web/ui/prebuilt/NFT/hooks.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/NFT/media.d.ts +75 -0
- package/dist/types/react/web/ui/prebuilt/NFT/media.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/NFT/name.d.ts +59 -0
- package/dist/types/react/web/ui/prebuilt/NFT/name.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/NFT/provider.d.ts +55 -0
- package/dist/types/react/web/ui/prebuilt/NFT/provider.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts +95 -0
- package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Token/name.d.ts +140 -0
- package/dist/types/react/web/ui/prebuilt/Token/name.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Token/provider.d.ts +61 -0
- package/dist/types/react/web/ui/prebuilt/Token/provider.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts +137 -0
- package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts.map +1 -0
- package/dist/types/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.d.ts +1 -0
- package/dist/types/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/thirdweb/ClaimButton/index.d.ts +1 -0
- package/dist/types/react/web/ui/prebuilt/thirdweb/ClaimButton/index.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.d.ts +1 -0
- package/dist/types/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.d.ts.map +1 -1
- package/dist/types/storage/unpin.d.ts +1 -1
- package/dist/types/storage/upload.d.ts +1 -0
- package/dist/types/storage/upload.d.ts.map +1 -1
- package/dist/types/transaction/actions/to-serializable-transaction.d.ts +1 -1
- package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts +5 -0
- package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts +5 -0
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +9 -0
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/json.d.ts +1 -1
- package/dist/types/utils/json.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/get-calls-status.d.ts +1 -1
- package/dist/types/wallets/eip5792/get-capabilities.d.ts +1 -1
- package/dist/types/wallets/eip5792/send-calls.d.ts +2 -2
- package/dist/types/wallets/eip5792/wait-for-bundle.d.ts +1 -1
- package/dist/types/wallets/in-app/core/users/getUser.d.ts +1 -1
- package/dist/types/wallets/in-app/web/ecosystem.d.ts +7 -17
- package/dist/types/wallets/in-app/web/ecosystem.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/in-app.d.ts +2 -17
- package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts +1 -0
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/passkeys.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts +1 -0
- package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client/client.ts +1 -0
- package/src/exports/react.ts +56 -2
- package/src/extensions/erc721/lazyMinting/read/getBatchesToReveal.ts +1 -1
- package/src/extensions/modules/common/checkModulesCompatibility.ts +5 -0
- package/src/extensions/pack/createNewPack.ts +8 -3
- package/src/extensions/prebuilts/deploy-pack.ts +1 -0
- package/src/extensions/thirdweb/write/publish.ts +4 -0
- package/src/react/core/hooks/others/useChainQuery.ts +3 -3
- package/src/react/core/hooks/rpc/useBlockNumber.ts +1 -1
- package/src/react/core/hooks/wallets/useCapabilities.ts +1 -1
- package/src/react/core/hooks/wallets/useSendCalls.ts +3 -3
- package/src/react/core/providers/connection-manager.tsx +3 -0
- package/src/react/core/utils/wallet.ts +2 -1
- package/src/react/core/utils/walletIcon.ts +2 -0
- package/src/react/native/hooks/wallets/useProfiles.ts +1 -1
- package/src/react/native/providers/thirdweb-provider.tsx +1 -0
- package/src/react/native/ui/AutoConnect/AutoConnect.tsx +1 -0
- package/src/react/native/ui/connect/ConnectModal.tsx +1 -0
- package/src/react/native/ui/transaction/TransactionButton.tsx +1 -0
- package/src/react/web/hooks/wallets/useProfiles.ts +1 -1
- package/src/react/web/providers/thirdweb-provider.tsx +1 -0
- package/src/react/web/ui/AutoConnect/AutoConnect.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/Blobbie.tsx +31 -4
- package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +36 -32
- package/src/react/web/ui/ConnectWallet/Details.tsx +91 -58
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +23 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +43 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +2 -3
- package/src/react/web/ui/PayEmbed.tsx +2 -2
- package/src/react/web/ui/SiteEmbed.tsx +3 -2
- package/src/react/web/ui/SiteLink.tsx +2 -1
- package/src/react/web/ui/TransactionButton/index.tsx +1 -0
- package/src/react/web/ui/prebuilt/Account/address.test.tsx +28 -0
- package/src/react/web/ui/prebuilt/Account/address.tsx +64 -0
- package/src/react/web/ui/prebuilt/Account/avatar.test.tsx +48 -0
- package/src/react/web/ui/prebuilt/Account/avatar.tsx +221 -0
- package/src/react/web/ui/prebuilt/Account/balance.test.tsx +54 -0
- package/src/react/web/ui/prebuilt/Account/balance.tsx +202 -0
- package/src/react/web/ui/prebuilt/Account/blobbie.tsx +12 -0
- package/src/react/web/ui/prebuilt/Account/name.test.tsx +62 -0
- package/src/react/web/ui/prebuilt/Account/name.tsx +175 -0
- package/src/react/web/ui/prebuilt/Account/provider.test.tsx +38 -0
- package/src/react/web/ui/prebuilt/Account/provider.tsx +69 -0
- package/src/react/web/ui/prebuilt/NFT/NFT.test.tsx +17 -14
- package/src/react/web/ui/prebuilt/NFT/description.tsx +87 -0
- package/src/react/web/ui/prebuilt/NFT/hooks.tsx +53 -0
- package/src/react/web/ui/prebuilt/NFT/media.tsx +119 -0
- package/src/react/web/ui/prebuilt/NFT/name.tsx +85 -0
- package/src/react/web/ui/prebuilt/NFT/provider.tsx +75 -0
- package/src/react/web/ui/prebuilt/Token/icon.tsx +164 -0
- package/src/react/web/ui/prebuilt/Token/name.tsx +201 -0
- package/src/react/web/ui/prebuilt/Token/provider.tsx +86 -0
- package/src/react/web/ui/prebuilt/Token/symbol.tsx +201 -0
- package/src/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.tsx +1 -0
- package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/index.tsx +1 -0
- package/src/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.tsx +1 -0
- package/src/storage/unpin.ts +1 -1
- package/src/storage/upload.ts +1 -0
- package/src/transaction/actions/to-serializable-transaction.ts +1 -1
- package/src/transaction/actions/zksync/send-eip712-transaction.ts +5 -0
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +5 -0
- package/src/utils/config.ts +9 -0
- package/src/utils/json.ts +8 -2
- package/src/version.ts +1 -1
- package/src/wallets/eip5792/get-calls-status.ts +1 -1
- package/src/wallets/eip5792/get-capabilities.ts +1 -1
- package/src/wallets/eip5792/send-calls.ts +2 -2
- package/src/wallets/eip5792/wait-for-bundle.ts +1 -1
- package/src/wallets/in-app/core/users/getUser.ts +1 -1
- package/src/wallets/in-app/web/ecosystem.ts +7 -17
- package/src/wallets/in-app/web/in-app.ts +2 -17
- package/src/wallets/in-app/web/lib/auth/index.ts +1 -0
- package/src/wallets/in-app/web/lib/auth/passkeys.ts +24 -23
- package/src/wallets/smart/smart-wallet.ts +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/NFT.js +0 -217
- package/dist/cjs/react/web/ui/prebuilt/NFT/NFT.js.map +0 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/NFT.js +0 -212
- package/dist/esm/react/web/ui/prebuilt/NFT/NFT.js.map +0 -1
- package/dist/types/react/web/ui/prebuilt/NFT/NFT.d.ts +0 -76
- package/dist/types/react/web/ui/prebuilt/NFT/NFT.d.ts.map +0 -1
- package/src/extensions/prebuilts/deploy-published.test.ts +0 -132
- package/src/react/web/ui/prebuilt/NFT/NFT.tsx +0 -272
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +0 -270
- package/src/wallets/smart/smart-wallet-integration.test.ts +0 -375
@@ -0,0 +1,202 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
4
|
+
import type React from "react";
|
5
|
+
import type { JSX } from "react";
|
6
|
+
import type { Chain } from "../../../../../chains/types.js";
|
7
|
+
import { useActiveWalletChain } from "../../../../../react/core/hooks/wallets/useActiveWalletChain.js";
|
8
|
+
import {
|
9
|
+
type GetWalletBalanceResult,
|
10
|
+
getWalletBalance,
|
11
|
+
} from "../../../../../wallets/utils/getWalletBalance.js";
|
12
|
+
import { useAccountContext } from "./provider.js";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Props for the AccountBalance component
|
16
|
+
* @component
|
17
|
+
* @account
|
18
|
+
*/
|
19
|
+
export interface AccountBalanceProps
|
20
|
+
extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
|
21
|
+
/**
|
22
|
+
* The network to fetch balance on
|
23
|
+
* If not passed, the component will use the current chain that the wallet is connected to (`useActiveWalletChain()`)
|
24
|
+
*/
|
25
|
+
chain?: Chain;
|
26
|
+
/**
|
27
|
+
* By default this component will fetch the balance for the native token on a given chain
|
28
|
+
* If you want to fetch balance for an ERC20 token, use the `tokenAddress` props
|
29
|
+
*/
|
30
|
+
tokenAddress?: string;
|
31
|
+
/**
|
32
|
+
* A function to format the balance's display value
|
33
|
+
* use this function to transform the balance display value like round up the number
|
34
|
+
* Particularly useful to avoid overflowing-UI issues
|
35
|
+
*/
|
36
|
+
formatFn?: (num: number) => number;
|
37
|
+
/**
|
38
|
+
* This component will be shown while the balance of the account is being fetched
|
39
|
+
* If not passed, the component will return `null`.
|
40
|
+
*
|
41
|
+
* You can/should pass a loading sign or spinner to this prop.
|
42
|
+
* @example
|
43
|
+
* ```tsx
|
44
|
+
* <AccountBalance
|
45
|
+
* chain={ethereum}
|
46
|
+
* loadingComponent={<Spinner />}
|
47
|
+
* />
|
48
|
+
* ```
|
49
|
+
*/
|
50
|
+
loadingComponent?: JSX.Element;
|
51
|
+
/**
|
52
|
+
* This component will be shown if the balance fails to be retreived
|
53
|
+
* If not passed, the component will return `null`.
|
54
|
+
*
|
55
|
+
* You can/should pass a descriptive text/component to this prop, indicating that the
|
56
|
+
* balance was not fetched succesfully
|
57
|
+
* @example
|
58
|
+
* ```tsx
|
59
|
+
* <AccountBalance
|
60
|
+
* chain={nonExistentChain}
|
61
|
+
* fallbackComponent={"Failed to load"}
|
62
|
+
* />
|
63
|
+
* ```
|
64
|
+
*/
|
65
|
+
fallbackComponent?: JSX.Element;
|
66
|
+
/**
|
67
|
+
* Optional `useQuery` params
|
68
|
+
*/
|
69
|
+
queryOptions?: Omit<
|
70
|
+
UseQueryOptions<GetWalletBalanceResult>,
|
71
|
+
"queryFn" | "queryKey"
|
72
|
+
>;
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* This component fetches and shows the balance of the wallet address on a given chain.
|
77
|
+
* It inherits all the attributes of a HTML <span> component, hence you can style it just like how you would style a normal <span>
|
78
|
+
*
|
79
|
+
*
|
80
|
+
* @example
|
81
|
+
* ### Basic usage
|
82
|
+
* ```tsx
|
83
|
+
* import { AccountProvider, AccountBalance } from "thirdweb/react";
|
84
|
+
* import { ethereum } from "thirdweb/chains";
|
85
|
+
*
|
86
|
+
* <AccountProvider address="0x...">
|
87
|
+
* <AccountBalance chain={ethereum} />
|
88
|
+
* </AccountProvider>
|
89
|
+
* ```
|
90
|
+
* Result:
|
91
|
+
* ```html
|
92
|
+
* <span>1.091435 ETH</span>
|
93
|
+
* ```
|
94
|
+
*
|
95
|
+
*
|
96
|
+
* ### Format the balance (round up, shorten etc.)
|
97
|
+
* The AccountBalance component accepts a `formatFn` which takes in a number and outputs a number
|
98
|
+
* The function is used to modify the display value of the wallet balance
|
99
|
+
*
|
100
|
+
* ```tsx
|
101
|
+
* const roundTo1Decimal = (num: number):number => Math.round(num * 10) / 10;
|
102
|
+
*
|
103
|
+
* <AccountBalance formatFn={roundTo1Decimal} />
|
104
|
+
* ```
|
105
|
+
*
|
106
|
+
* Result:
|
107
|
+
* ```html
|
108
|
+
* <span>1.1 ETH</span>
|
109
|
+
* ```
|
110
|
+
*
|
111
|
+
* ### Show a loading sign when the balance is being fetched
|
112
|
+
* ```tsx
|
113
|
+
* import { AccountProvider, AccountBalance } from "thirdweb/react";
|
114
|
+
*
|
115
|
+
* <AccountProvider address="0x...">
|
116
|
+
* <AccountBalance
|
117
|
+
* chain={ethereum}
|
118
|
+
* loadingComponent={<Spinner />}
|
119
|
+
* />
|
120
|
+
* </AccountProvider>
|
121
|
+
* ```
|
122
|
+
*
|
123
|
+
* ### Fallback to something when the balance fails to resolve
|
124
|
+
* ```tsx
|
125
|
+
* <AccountProvider address="0x...">
|
126
|
+
* <AccountBalance
|
127
|
+
* chain={nonExistentChain}
|
128
|
+
* fallbackComponent={"Failed to load"}
|
129
|
+
* />
|
130
|
+
* </AccountProvider>
|
131
|
+
* ```
|
132
|
+
*
|
133
|
+
* ### Custom query options for useQuery
|
134
|
+
* This component uses `@tanstack-query`'s useQuery internally.
|
135
|
+
* You can use the `queryOptions` prop for more fine-grained control
|
136
|
+
* ```tsx
|
137
|
+
* <AccountBalance
|
138
|
+
* queryOptions={{
|
139
|
+
* enabled: isEnabled,
|
140
|
+
* retry: 4,
|
141
|
+
* }}
|
142
|
+
* />
|
143
|
+
* ```
|
144
|
+
*
|
145
|
+
* @component
|
146
|
+
* @account
|
147
|
+
* @beta
|
148
|
+
*/
|
149
|
+
export function AccountBalance({
|
150
|
+
chain,
|
151
|
+
tokenAddress,
|
152
|
+
formatFn,
|
153
|
+
loadingComponent,
|
154
|
+
fallbackComponent,
|
155
|
+
queryOptions,
|
156
|
+
...restProps
|
157
|
+
}: AccountBalanceProps) {
|
158
|
+
const { address, client } = useAccountContext();
|
159
|
+
const walletChain = useActiveWalletChain();
|
160
|
+
const chainToLoad = chain || walletChain;
|
161
|
+
const balanceQuery = useQuery({
|
162
|
+
queryKey: [
|
163
|
+
"walletBalance",
|
164
|
+
chainToLoad?.id || -1,
|
165
|
+
address || "0x0",
|
166
|
+
{ tokenAddress },
|
167
|
+
] as const,
|
168
|
+
queryFn: async () => {
|
169
|
+
if (!chainToLoad) {
|
170
|
+
throw new Error("chain is required");
|
171
|
+
}
|
172
|
+
if (!client) {
|
173
|
+
throw new Error("client is required");
|
174
|
+
}
|
175
|
+
return getWalletBalance({
|
176
|
+
chain: chainToLoad,
|
177
|
+
client,
|
178
|
+
address,
|
179
|
+
tokenAddress,
|
180
|
+
});
|
181
|
+
},
|
182
|
+
...queryOptions,
|
183
|
+
});
|
184
|
+
|
185
|
+
if (balanceQuery.isLoading) {
|
186
|
+
return loadingComponent || null;
|
187
|
+
}
|
188
|
+
|
189
|
+
if (!balanceQuery.data) {
|
190
|
+
return fallbackComponent || null;
|
191
|
+
}
|
192
|
+
|
193
|
+
const displayValue = formatFn
|
194
|
+
? formatFn(Number(balanceQuery.data.displayValue))
|
195
|
+
: balanceQuery.data.displayValue;
|
196
|
+
|
197
|
+
return (
|
198
|
+
<span {...restProps}>
|
199
|
+
{displayValue} {balanceQuery.data.symbol}
|
200
|
+
</span>
|
201
|
+
);
|
202
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Blobbie, type BlobbieProps } from "../../ConnectWallet/Blobbie.js";
|
2
|
+
import { useAccountContext } from "./provider.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* A wrapper for the Blobbie component
|
6
|
+
* @param props BlobbieProps
|
7
|
+
* @beta
|
8
|
+
*/
|
9
|
+
export function AccountBlobbie(props: Omit<BlobbieProps, "address">) {
|
10
|
+
const { address } = useAccountContext();
|
11
|
+
return <Blobbie {...props} address={address} />;
|
12
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { render, screen, waitFor } from "~test/react-render.js";
|
3
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
|
+
import { AccountName } from "./name.js";
|
5
|
+
import { AccountProvider } from "./provider.js";
|
6
|
+
|
7
|
+
describe.runIf(process.env.TW_SECRET_KEY)("AccountName component", () => {
|
8
|
+
it("should return the correct social name", () => {
|
9
|
+
render(
|
10
|
+
<AccountProvider
|
11
|
+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
|
12
|
+
client={TEST_CLIENT}
|
13
|
+
>
|
14
|
+
<AccountName />
|
15
|
+
</AccountProvider>,
|
16
|
+
);
|
17
|
+
waitFor(() =>
|
18
|
+
expect(
|
19
|
+
screen.getByText("kien-ngo", {
|
20
|
+
exact: true,
|
21
|
+
selector: "span",
|
22
|
+
}),
|
23
|
+
).toBeInTheDocument(),
|
24
|
+
);
|
25
|
+
});
|
26
|
+
|
27
|
+
it("should return the correct FORMATTED social name", () => {
|
28
|
+
render(
|
29
|
+
<AccountProvider
|
30
|
+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
|
31
|
+
client={TEST_CLIENT}
|
32
|
+
>
|
33
|
+
<AccountName formatFn={(str: string) => `${str}-formatted`} />
|
34
|
+
</AccountProvider>,
|
35
|
+
);
|
36
|
+
waitFor(() =>
|
37
|
+
expect(
|
38
|
+
screen.getByText("kien-ngo-formatted", {
|
39
|
+
exact: true,
|
40
|
+
selector: "span",
|
41
|
+
}),
|
42
|
+
).toBeInTheDocument(),
|
43
|
+
);
|
44
|
+
});
|
45
|
+
|
46
|
+
it("should fallback properly when fail to resolve social name", () => {
|
47
|
+
render(
|
48
|
+
<AccountProvider address="invalid-wallet-address" client={TEST_CLIENT}>
|
49
|
+
<AccountName fallbackComponent={<span>oops</span>} />
|
50
|
+
</AccountProvider>,
|
51
|
+
);
|
52
|
+
|
53
|
+
waitFor(() =>
|
54
|
+
expect(
|
55
|
+
screen.getByText("oops", {
|
56
|
+
exact: true,
|
57
|
+
selector: "span",
|
58
|
+
}),
|
59
|
+
).toBeInTheDocument(),
|
60
|
+
);
|
61
|
+
});
|
62
|
+
});
|
@@ -0,0 +1,175 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
4
|
+
import type React from "react";
|
5
|
+
import type { JSX } from "react";
|
6
|
+
import {
|
7
|
+
type ResolveNameOptions,
|
8
|
+
resolveName,
|
9
|
+
} from "../../../../../extensions/ens/resolve-name.js";
|
10
|
+
import { getSocialProfiles } from "../../../../../social/profiles.js";
|
11
|
+
import type { SocialProfile } from "../../../../../social/types.js";
|
12
|
+
import { useAccountContext } from "./provider.js";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Props for the AccountName component
|
16
|
+
* @component
|
17
|
+
* @account
|
18
|
+
*/
|
19
|
+
export interface AccountNameProps
|
20
|
+
extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children">,
|
21
|
+
Omit<ResolveNameOptions, "client" | "address"> {
|
22
|
+
/**
|
23
|
+
* A function used to transform (format) the name of the account.
|
24
|
+
* it should take in a string and output a string.
|
25
|
+
*
|
26
|
+
* This function is particularly useful
|
27
|
+
*/
|
28
|
+
formatFn?: (str: string) => string;
|
29
|
+
/**
|
30
|
+
* Use this prop to prioritize the social profile that you want to display
|
31
|
+
* This is useful for a wallet containing multiple social profiles
|
32
|
+
*/
|
33
|
+
socialType?: SocialProfile["type"];
|
34
|
+
/**
|
35
|
+
* This component will be shown while the name of the account is being fetched
|
36
|
+
* If not passed, the component will return `null`.
|
37
|
+
*
|
38
|
+
* You can pass a loading sign or spinner to this prop.
|
39
|
+
* @example
|
40
|
+
* ```tsx
|
41
|
+
* <AccountName loadingComponent={<Spinner />} />
|
42
|
+
* ```
|
43
|
+
*/
|
44
|
+
loadingComponent?: JSX.Element;
|
45
|
+
/**
|
46
|
+
* This component will be shown if the request for fetching the name is done but could not retreive any result.
|
47
|
+
* You can pass the wallet address as the fallback option if that's the case.
|
48
|
+
*
|
49
|
+
* If not passed, the component will return `null`
|
50
|
+
*
|
51
|
+
* @example
|
52
|
+
* ```tsx
|
53
|
+
* <AccountName fallbackComponent={"0x1234....3f3f"} />
|
54
|
+
* ```
|
55
|
+
*/
|
56
|
+
fallbackComponent?: JSX.Element;
|
57
|
+
/**
|
58
|
+
* Optional `useQuery` params
|
59
|
+
*/
|
60
|
+
queryOptions?: Omit<UseQueryOptions<string>, "queryKey" | "queryFn">;
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* This component is used to display the name of the account.
|
65
|
+
* A "name" in this context is the username, or account of the social profiles that the wallet may have.
|
66
|
+
* In case a name is not found or failed to resolve, you can always fallback to displaying the wallet address instead by using the `fallbackComponent` prop.
|
67
|
+
*
|
68
|
+
* This component inherits all attribute of a native HTML <span> element, so you can style it just like how you would style a <span>.
|
69
|
+
*
|
70
|
+
* @param props
|
71
|
+
* @returns A `<span>` containing the name of the account
|
72
|
+
* ```html
|
73
|
+
* <span>{name}</span>
|
74
|
+
* ```
|
75
|
+
*
|
76
|
+
* @example
|
77
|
+
* ### Basic usage
|
78
|
+
* ```tsx
|
79
|
+
* import { AccountProvider, AccountName } from "thirdweb/react";
|
80
|
+
*
|
81
|
+
* <AccountProvider address="0x1234...3f3f" client={client}>
|
82
|
+
* <AccountName />
|
83
|
+
* </AccountProvider>
|
84
|
+
* ```
|
85
|
+
*
|
86
|
+
* ### Show wallet address while social name is being loaded
|
87
|
+
* ```tsx
|
88
|
+
* <AccountName
|
89
|
+
* loadingComponent={<AccountAddress />}
|
90
|
+
* />
|
91
|
+
* ```
|
92
|
+
*
|
93
|
+
*
|
94
|
+
* ### Fallback to showing wallet address if fail to resolve social name
|
95
|
+
* ```tsx
|
96
|
+
* <AccountName
|
97
|
+
* fallbackComponent={<AccountAddress />}
|
98
|
+
* />
|
99
|
+
* ```
|
100
|
+
*
|
101
|
+
* ### Transform the account name using `formatFn` prop
|
102
|
+
* ```tsx
|
103
|
+
* import { isAddress, shortenAddress } from "thirdweb/utils";
|
104
|
+
* import { AccountProvider, AccountName } from "thirdweb/react";
|
105
|
+
*
|
106
|
+
* // Let's say we want the name to be capitalized without using CSS
|
107
|
+
* const formatName = (name: string) => name.toUpperCase();
|
108
|
+
*
|
109
|
+
* return <AccountName formatFn={formatName} />
|
110
|
+
* ```
|
111
|
+
*
|
112
|
+
*
|
113
|
+
* ### Custom query options for useQuery
|
114
|
+
* This component uses `@tanstack-query`'s useQuery internally.
|
115
|
+
* You can use the `queryOptions` prop for more fine-grained control
|
116
|
+
* ```tsx
|
117
|
+
* <AccountName
|
118
|
+
* queryOptions={{
|
119
|
+
* enabled: isEnabled,
|
120
|
+
* retry: 3
|
121
|
+
* }}
|
122
|
+
* />
|
123
|
+
* ```
|
124
|
+
*
|
125
|
+
* @component
|
126
|
+
* @account
|
127
|
+
* @beta
|
128
|
+
*/
|
129
|
+
export function AccountName({
|
130
|
+
resolverAddress,
|
131
|
+
resolverChain,
|
132
|
+
socialType,
|
133
|
+
formatFn,
|
134
|
+
queryOptions,
|
135
|
+
loadingComponent,
|
136
|
+
fallbackComponent,
|
137
|
+
...restProps
|
138
|
+
}: AccountNameProps) {
|
139
|
+
const { address, client } = useAccountContext();
|
140
|
+
const nameQuery = useQuery({
|
141
|
+
queryKey: ["account-name", address],
|
142
|
+
queryFn: async () => {
|
143
|
+
const [socialData, ensName] = await Promise.all([
|
144
|
+
getSocialProfiles({ address, client }),
|
145
|
+
resolveName({
|
146
|
+
client,
|
147
|
+
address,
|
148
|
+
resolverAddress,
|
149
|
+
resolverChain,
|
150
|
+
}),
|
151
|
+
]);
|
152
|
+
|
153
|
+
const name =
|
154
|
+
socialData?.filter(
|
155
|
+
(p) => p.name && (socialType ? p.type === socialType : true),
|
156
|
+
)[0]?.name || ensName;
|
157
|
+
|
158
|
+
if (!name) {
|
159
|
+
throw new Error("Failed to resolve account name");
|
160
|
+
}
|
161
|
+
return formatFn ? formatFn(name) : name;
|
162
|
+
},
|
163
|
+
...queryOptions,
|
164
|
+
});
|
165
|
+
|
166
|
+
if (nameQuery.isLoading) {
|
167
|
+
return loadingComponent || null;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (!nameQuery.data) {
|
171
|
+
return fallbackComponent || null;
|
172
|
+
}
|
173
|
+
|
174
|
+
return <span {...restProps}>{nameQuery.data}</span>;
|
175
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { render, screen } from "~test/react-render.js";
|
3
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
|
+
import { AccountAddress } from "./address.js";
|
5
|
+
import { AccountProvider } from "./provider.js";
|
6
|
+
|
7
|
+
describe.runIf(process.env.TW_SECRET_KEY)("AccountProvider component", () => {
|
8
|
+
it("should render children correctly", () => {
|
9
|
+
render(
|
10
|
+
<AccountProvider
|
11
|
+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
|
12
|
+
client={TEST_CLIENT}
|
13
|
+
>
|
14
|
+
<div>Child Component</div>
|
15
|
+
</AccountProvider>,
|
16
|
+
);
|
17
|
+
|
18
|
+
expect(screen.getByText("Child Component")).toBeInTheDocument();
|
19
|
+
});
|
20
|
+
|
21
|
+
it("should pass the address correctly to the children props", () => {
|
22
|
+
render(
|
23
|
+
<AccountProvider
|
24
|
+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
|
25
|
+
client={TEST_CLIENT}
|
26
|
+
>
|
27
|
+
<AccountAddress />
|
28
|
+
</AccountProvider>,
|
29
|
+
);
|
30
|
+
|
31
|
+
expect(
|
32
|
+
screen.getByText("0x12345674b599ce99958242b3D3741e7b01841DF3", {
|
33
|
+
exact: true,
|
34
|
+
selector: "span",
|
35
|
+
}),
|
36
|
+
).toBeInTheDocument();
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use client";
|
2
|
+
import type { Address } from "abitype";
|
3
|
+
import type React from "react";
|
4
|
+
import { createContext, useContext } from "react";
|
5
|
+
import type { ThirdwebClient } from "../../../../../client/client.js";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Props for the <AccountProvider /> component
|
9
|
+
* @component
|
10
|
+
* @account
|
11
|
+
*/
|
12
|
+
export type AccountProviderProps = {
|
13
|
+
/**
|
14
|
+
* The user's wallet address
|
15
|
+
*/
|
16
|
+
address: Address;
|
17
|
+
/**
|
18
|
+
* thirdweb Client
|
19
|
+
*/
|
20
|
+
client: ThirdwebClient;
|
21
|
+
};
|
22
|
+
|
23
|
+
const AccountProviderContext = /* @__PURE__ */ createContext<
|
24
|
+
AccountProviderProps | undefined
|
25
|
+
>(undefined);
|
26
|
+
|
27
|
+
/**
|
28
|
+
* A React context provider component that supplies Account-related data to its child components.
|
29
|
+
*
|
30
|
+
* This component serves as a wrapper around the `AccountProviderContext.Provider` and passes
|
31
|
+
* the provided account data down to all of its child components through the context API.
|
32
|
+
*
|
33
|
+
* @example
|
34
|
+
* ```tsx
|
35
|
+
* import { AccountProvider, AccountAvatar, AccountName, AccountAddress } from "thirdweb/react";
|
36
|
+
*
|
37
|
+
* <AccountProvider>
|
38
|
+
* <AccountAvatar />
|
39
|
+
* <AccountName />
|
40
|
+
* <AccountAddress />
|
41
|
+
* </AccountProvider>
|
42
|
+
* ```
|
43
|
+
*
|
44
|
+
* @component
|
45
|
+
* @account
|
46
|
+
* @beta
|
47
|
+
*/
|
48
|
+
export function AccountProvider(
|
49
|
+
props: React.PropsWithChildren<AccountProviderProps>,
|
50
|
+
) {
|
51
|
+
return (
|
52
|
+
<AccountProviderContext.Provider value={props}>
|
53
|
+
{props.children}
|
54
|
+
</AccountProviderContext.Provider>
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @internal
|
60
|
+
*/
|
61
|
+
export function useAccountContext() {
|
62
|
+
const ctx = useContext(AccountProviderContext);
|
63
|
+
if (!ctx) {
|
64
|
+
throw new Error(
|
65
|
+
"AccountProviderContext not found. Make sure you are using AccountName, AccountAvatar, etc. inside an <AccountProvider /> component",
|
66
|
+
);
|
67
|
+
}
|
68
|
+
return ctx;
|
69
|
+
}
|
@@ -2,7 +2,10 @@ import { useContext } from "react";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
3
3
|
import { render, screen, waitFor } from "~test/react-render.js";
|
4
4
|
import { DOODLES_CONTRACT } from "~test/test-contracts.js";
|
5
|
-
import {
|
5
|
+
import { getNFTInfo } from "./hooks.js";
|
6
|
+
import { NFTMedia } from "./media.js";
|
7
|
+
import { NFTName } from "./name.js";
|
8
|
+
import { NFTProvider, NFTProviderContext } from "./provider.js";
|
6
9
|
|
7
10
|
describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
8
11
|
it("should fetch the NFT metadata", async () => {
|
@@ -42,9 +45,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
|
42
45
|
|
43
46
|
it("should render children correctly", () => {
|
44
47
|
render(
|
45
|
-
<
|
48
|
+
<NFTProvider contract={DOODLES_CONTRACT} tokenId={0n}>
|
46
49
|
<div>Child Component</div>
|
47
|
-
</
|
50
|
+
</NFTProvider>,
|
48
51
|
);
|
49
52
|
|
50
53
|
expect(screen.getByText("Child Component")).toBeInTheDocument();
|
@@ -64,9 +67,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
|
64
67
|
);
|
65
68
|
}
|
66
69
|
render(
|
67
|
-
<
|
70
|
+
<NFTProvider contract={DOODLES_CONTRACT} tokenId={0n}>
|
68
71
|
<NFTConsumer />
|
69
|
-
</
|
72
|
+
</NFTProvider>,
|
70
73
|
);
|
71
74
|
|
72
75
|
expect(screen.getByText(/Contract:/)).toBeInTheDocument();
|
@@ -75,9 +78,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
|
75
78
|
|
76
79
|
it("should render the NFT image", () => {
|
77
80
|
render(
|
78
|
-
<
|
79
|
-
<
|
80
|
-
</
|
81
|
+
<NFTProvider contract={DOODLES_CONTRACT} tokenId={0n}>
|
82
|
+
<NFTMedia />
|
83
|
+
</NFTProvider>,
|
81
84
|
);
|
82
85
|
|
83
86
|
waitFor(() => expect(screen.getByRole("img")).toBeInTheDocument());
|
@@ -85,9 +88,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
|
85
88
|
|
86
89
|
it("should render the NFT name", () => {
|
87
90
|
render(
|
88
|
-
<
|
89
|
-
<
|
90
|
-
</
|
91
|
+
<NFTProvider contract={DOODLES_CONTRACT} tokenId={1n}>
|
92
|
+
<NFTName />
|
93
|
+
</NFTProvider>,
|
91
94
|
);
|
92
95
|
|
93
96
|
waitFor(() => expect(screen.getByText("Doodle #1")).toBeInTheDocument());
|
@@ -95,9 +98,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("NFT prebuilt component", () => {
|
|
95
98
|
|
96
99
|
it("should render the NFT description", () => {
|
97
100
|
render(
|
98
|
-
<
|
99
|
-
<
|
100
|
-
</
|
101
|
+
<NFTProvider contract={DOODLES_CONTRACT} tokenId={1n}>
|
102
|
+
<NFTName />
|
103
|
+
</NFTProvider>,
|
101
104
|
);
|
102
105
|
|
103
106
|
waitFor(() =>
|