thirdweb 5.69.1-nightly-f368793375d099eec53569330af7a083e558e483-20241120000334 → 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.
Files changed (398) hide show
  1. package/dist/cjs/client/client.js +1 -0
  2. package/dist/cjs/client/client.js.map +1 -1
  3. package/dist/cjs/exports/react.js +32 -3
  4. package/dist/cjs/exports/react.js.map +1 -1
  5. package/dist/cjs/extensions/erc721/lazyMinting/read/getBatchesToReveal.js +1 -1
  6. package/dist/cjs/extensions/modules/common/checkModulesCompatibility.js +5 -0
  7. package/dist/cjs/extensions/modules/common/checkModulesCompatibility.js.map +1 -1
  8. package/dist/cjs/extensions/prebuilts/deploy-pack.js +1 -0
  9. package/dist/cjs/extensions/prebuilts/deploy-pack.js.map +1 -1
  10. package/dist/cjs/extensions/thirdweb/write/publish.js +4 -0
  11. package/dist/cjs/extensions/thirdweb/write/publish.js.map +1 -1
  12. package/dist/cjs/react/core/hooks/others/useChainQuery.js +3 -3
  13. package/dist/cjs/react/core/hooks/rpc/useBlockNumber.js +1 -1
  14. package/dist/cjs/react/core/hooks/wallets/useCapabilities.js +1 -1
  15. package/dist/cjs/react/core/hooks/wallets/useSendCalls.js +3 -3
  16. package/dist/cjs/react/core/providers/connection-manager.js +3 -0
  17. package/dist/cjs/react/core/providers/connection-manager.js.map +1 -1
  18. package/dist/cjs/react/core/utils/wallet.js +2 -1
  19. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  20. package/dist/cjs/react/core/utils/walletIcon.js +2 -0
  21. package/dist/cjs/react/core/utils/walletIcon.js.map +1 -1
  22. package/dist/cjs/react/native/hooks/wallets/useProfiles.js +1 -1
  23. package/dist/cjs/react/native/providers/thirdweb-provider.js +1 -0
  24. package/dist/cjs/react/native/providers/thirdweb-provider.js.map +1 -1
  25. package/dist/cjs/react/native/ui/AutoConnect/AutoConnect.js +1 -0
  26. package/dist/cjs/react/native/ui/AutoConnect/AutoConnect.js.map +1 -1
  27. package/dist/cjs/react/native/ui/connect/ConnectModal.js +1 -0
  28. package/dist/cjs/react/native/ui/connect/ConnectModal.js.map +1 -1
  29. package/dist/cjs/react/native/ui/transaction/TransactionButton.js +1 -0
  30. package/dist/cjs/react/native/ui/transaction/TransactionButton.js.map +1 -1
  31. package/dist/cjs/react/web/hooks/wallets/useProfiles.js +1 -1
  32. package/dist/cjs/react/web/providers/thirdweb-provider.js +1 -0
  33. package/dist/cjs/react/web/providers/thirdweb-provider.js.map +1 -1
  34. package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js +1 -0
  35. package/dist/cjs/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/Blobbie.js +19 -4
  37. package/dist/cjs/react/web/ui/ConnectWallet/Blobbie.js.map +1 -1
  38. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +21 -19
  39. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  40. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +18 -13
  41. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  42. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -0
  43. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  44. package/dist/cjs/react/web/ui/PayEmbed.js +1 -0
  45. package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
  46. package/dist/cjs/react/web/ui/SiteEmbed.js +3 -2
  47. package/dist/cjs/react/web/ui/SiteEmbed.js.map +1 -1
  48. package/dist/cjs/react/web/ui/SiteLink.js +2 -1
  49. package/dist/cjs/react/web/ui/SiteLink.js.map +1 -1
  50. package/dist/cjs/react/web/ui/TransactionButton/index.js +1 -0
  51. package/dist/cjs/react/web/ui/TransactionButton/index.js.map +1 -1
  52. package/dist/cjs/react/web/ui/prebuilt/Account/address.js +49 -0
  53. package/dist/cjs/react/web/ui/prebuilt/Account/address.js.map +1 -0
  54. package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js +144 -0
  55. package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js.map +1 -0
  56. package/dist/cjs/react/web/ui/prebuilt/Account/balance.js +122 -0
  57. package/dist/cjs/react/web/ui/prebuilt/Account/balance.js.map +1 -0
  58. package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js +16 -0
  59. package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js.map +1 -0
  60. package/dist/cjs/react/web/ui/prebuilt/Account/name.js +106 -0
  61. package/dist/cjs/react/web/ui/prebuilt/Account/name.js.map +1 -0
  62. package/dist/cjs/react/web/ui/prebuilt/Account/provider.js +43 -0
  63. package/dist/cjs/react/web/ui/prebuilt/Account/provider.js.map +1 -0
  64. package/dist/cjs/react/web/ui/prebuilt/NFT/description.js +69 -0
  65. package/dist/cjs/react/web/ui/prebuilt/NFT/description.js.map +1 -0
  66. package/dist/cjs/react/web/ui/prebuilt/NFT/hooks.js +45 -0
  67. package/dist/cjs/react/web/ui/prebuilt/NFT/hooks.js.map +1 -0
  68. package/dist/cjs/react/web/ui/prebuilt/NFT/media.js +82 -0
  69. package/dist/cjs/react/web/ui/prebuilt/NFT/media.js.map +1 -0
  70. package/dist/cjs/react/web/ui/prebuilt/NFT/name.js +68 -0
  71. package/dist/cjs/react/web/ui/prebuilt/NFT/name.js.map +1 -0
  72. package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js +55 -0
  73. package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js.map +1 -0
  74. package/dist/cjs/react/web/ui/prebuilt/Token/icon.js +113 -0
  75. package/dist/cjs/react/web/ui/prebuilt/Token/icon.js.map +1 -0
  76. package/dist/cjs/react/web/ui/prebuilt/Token/name.js +137 -0
  77. package/dist/cjs/react/web/ui/prebuilt/Token/name.js.map +1 -0
  78. package/dist/cjs/react/web/ui/prebuilt/Token/provider.js +54 -0
  79. package/dist/cjs/react/web/ui/prebuilt/Token/provider.js.map +1 -0
  80. package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js +134 -0
  81. package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js.map +1 -0
  82. package/dist/cjs/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js +1 -0
  83. package/dist/cjs/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js.map +1 -1
  84. package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +1 -0
  85. package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
  86. package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +1 -0
  87. package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
  88. package/dist/cjs/storage/unpin.js +1 -1
  89. package/dist/cjs/storage/upload.js +1 -0
  90. package/dist/cjs/storage/upload.js.map +1 -1
  91. package/dist/cjs/transaction/actions/to-serializable-transaction.js +1 -1
  92. package/dist/cjs/transaction/actions/zksync/send-eip712-transaction.js +5 -0
  93. package/dist/cjs/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
  94. package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +5 -0
  95. package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
  96. package/dist/cjs/utils/config.js +9 -0
  97. package/dist/cjs/utils/config.js.map +1 -1
  98. package/dist/cjs/utils/json.js +7 -4
  99. package/dist/cjs/utils/json.js.map +1 -1
  100. package/dist/cjs/version.js +1 -1
  101. package/dist/cjs/wallets/eip5792/get-calls-status.js +1 -1
  102. package/dist/cjs/wallets/eip5792/get-capabilities.js +1 -1
  103. package/dist/cjs/wallets/eip5792/send-calls.js +2 -2
  104. package/dist/cjs/wallets/eip5792/wait-for-bundle.js +1 -1
  105. package/dist/cjs/wallets/in-app/core/users/getUser.js +1 -1
  106. package/dist/cjs/wallets/smart/smart-wallet.js +1 -0
  107. package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
  108. package/dist/esm/client/client.js +1 -0
  109. package/dist/esm/client/client.js.map +1 -1
  110. package/dist/esm/exports/react.js +17 -1
  111. package/dist/esm/exports/react.js.map +1 -1
  112. package/dist/esm/extensions/erc721/lazyMinting/read/getBatchesToReveal.js +1 -1
  113. package/dist/esm/extensions/modules/common/checkModulesCompatibility.js +5 -0
  114. package/dist/esm/extensions/modules/common/checkModulesCompatibility.js.map +1 -1
  115. package/dist/esm/extensions/prebuilts/deploy-pack.js +1 -0
  116. package/dist/esm/extensions/prebuilts/deploy-pack.js.map +1 -1
  117. package/dist/esm/extensions/thirdweb/write/publish.js +4 -0
  118. package/dist/esm/extensions/thirdweb/write/publish.js.map +1 -1
  119. package/dist/esm/react/core/hooks/others/useChainQuery.js +3 -3
  120. package/dist/esm/react/core/hooks/rpc/useBlockNumber.js +1 -1
  121. package/dist/esm/react/core/hooks/wallets/useCapabilities.js +1 -1
  122. package/dist/esm/react/core/hooks/wallets/useSendCalls.js +3 -3
  123. package/dist/esm/react/core/providers/connection-manager.js +3 -0
  124. package/dist/esm/react/core/providers/connection-manager.js.map +1 -1
  125. package/dist/esm/react/core/utils/wallet.js +2 -1
  126. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  127. package/dist/esm/react/core/utils/walletIcon.js +2 -0
  128. package/dist/esm/react/core/utils/walletIcon.js.map +1 -1
  129. package/dist/esm/react/native/hooks/wallets/useProfiles.js +1 -1
  130. package/dist/esm/react/native/providers/thirdweb-provider.js +1 -0
  131. package/dist/esm/react/native/providers/thirdweb-provider.js.map +1 -1
  132. package/dist/esm/react/native/ui/AutoConnect/AutoConnect.js +1 -0
  133. package/dist/esm/react/native/ui/AutoConnect/AutoConnect.js.map +1 -1
  134. package/dist/esm/react/native/ui/connect/ConnectModal.js +1 -0
  135. package/dist/esm/react/native/ui/connect/ConnectModal.js.map +1 -1
  136. package/dist/esm/react/native/ui/transaction/TransactionButton.js +1 -0
  137. package/dist/esm/react/native/ui/transaction/TransactionButton.js.map +1 -1
  138. package/dist/esm/react/web/hooks/wallets/useProfiles.js +1 -1
  139. package/dist/esm/react/web/providers/thirdweb-provider.js +1 -0
  140. package/dist/esm/react/web/providers/thirdweb-provider.js.map +1 -1
  141. package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js +1 -0
  142. package/dist/esm/react/web/ui/AutoConnect/AutoConnect.js.map +1 -1
  143. package/dist/esm/react/web/ui/ConnectWallet/Blobbie.js +19 -4
  144. package/dist/esm/react/web/ui/ConnectWallet/Blobbie.js.map +1 -1
  145. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +21 -19
  146. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  147. package/dist/esm/react/web/ui/ConnectWallet/Details.js +19 -14
  148. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  149. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -0
  150. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  151. package/dist/esm/react/web/ui/PayEmbed.js +1 -0
  152. package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
  153. package/dist/esm/react/web/ui/SiteEmbed.js +3 -2
  154. package/dist/esm/react/web/ui/SiteEmbed.js.map +1 -1
  155. package/dist/esm/react/web/ui/SiteLink.js +2 -1
  156. package/dist/esm/react/web/ui/SiteLink.js.map +1 -1
  157. package/dist/esm/react/web/ui/TransactionButton/index.js +1 -0
  158. package/dist/esm/react/web/ui/TransactionButton/index.js.map +1 -1
  159. package/dist/esm/react/web/ui/prebuilt/Account/address.js +46 -0
  160. package/dist/esm/react/web/ui/prebuilt/Account/address.js.map +1 -0
  161. package/dist/esm/react/web/ui/prebuilt/Account/avatar.js +141 -0
  162. package/dist/esm/react/web/ui/prebuilt/Account/avatar.js.map +1 -0
  163. package/dist/esm/react/web/ui/prebuilt/Account/balance.js +119 -0
  164. package/dist/esm/react/web/ui/prebuilt/Account/balance.js.map +1 -0
  165. package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js +13 -0
  166. package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js.map +1 -0
  167. package/dist/esm/react/web/ui/prebuilt/Account/name.js +103 -0
  168. package/dist/esm/react/web/ui/prebuilt/Account/name.js.map +1 -0
  169. package/dist/esm/react/web/ui/prebuilt/Account/provider.js +39 -0
  170. package/dist/esm/react/web/ui/prebuilt/Account/provider.js.map +1 -0
  171. package/dist/esm/react/web/ui/prebuilt/NFT/description.js +66 -0
  172. package/dist/esm/react/web/ui/prebuilt/NFT/description.js.map +1 -0
  173. package/dist/esm/react/web/ui/prebuilt/NFT/hooks.js +41 -0
  174. package/dist/esm/react/web/ui/prebuilt/NFT/hooks.js.map +1 -0
  175. package/dist/esm/react/web/ui/prebuilt/NFT/media.js +79 -0
  176. package/dist/esm/react/web/ui/prebuilt/NFT/media.js.map +1 -0
  177. package/dist/esm/react/web/ui/prebuilt/NFT/name.js +65 -0
  178. package/dist/esm/react/web/ui/prebuilt/NFT/name.js.map +1 -0
  179. package/dist/esm/react/web/ui/prebuilt/NFT/provider.js +50 -0
  180. package/dist/esm/react/web/ui/prebuilt/NFT/provider.js.map +1 -0
  181. package/dist/esm/react/web/ui/prebuilt/Token/icon.js +110 -0
  182. package/dist/esm/react/web/ui/prebuilt/Token/icon.js.map +1 -0
  183. package/dist/esm/react/web/ui/prebuilt/Token/name.js +134 -0
  184. package/dist/esm/react/web/ui/prebuilt/Token/name.js.map +1 -0
  185. package/dist/esm/react/web/ui/prebuilt/Token/provider.js +50 -0
  186. package/dist/esm/react/web/ui/prebuilt/Token/provider.js.map +1 -0
  187. package/dist/esm/react/web/ui/prebuilt/Token/symbol.js +131 -0
  188. package/dist/esm/react/web/ui/prebuilt/Token/symbol.js.map +1 -0
  189. package/dist/esm/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js +1 -0
  190. package/dist/esm/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.js.map +1 -1
  191. package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +1 -0
  192. package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
  193. package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +1 -0
  194. package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
  195. package/dist/esm/storage/unpin.js +1 -1
  196. package/dist/esm/storage/upload.js +1 -0
  197. package/dist/esm/storage/upload.js.map +1 -1
  198. package/dist/esm/transaction/actions/to-serializable-transaction.js +1 -1
  199. package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js +5 -0
  200. package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
  201. package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +5 -0
  202. package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
  203. package/dist/esm/utils/config.js +9 -0
  204. package/dist/esm/utils/config.js.map +1 -1
  205. package/dist/esm/utils/json.js +6 -2
  206. package/dist/esm/utils/json.js.map +1 -1
  207. package/dist/esm/version.js +1 -1
  208. package/dist/esm/wallets/eip5792/get-calls-status.js +1 -1
  209. package/dist/esm/wallets/eip5792/get-capabilities.js +1 -1
  210. package/dist/esm/wallets/eip5792/send-calls.js +2 -2
  211. package/dist/esm/wallets/eip5792/wait-for-bundle.js +1 -1
  212. package/dist/esm/wallets/in-app/core/users/getUser.js +1 -1
  213. package/dist/esm/wallets/smart/smart-wallet.js +1 -0
  214. package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
  215. package/dist/types/client/client.d.ts +1 -0
  216. package/dist/types/client/client.d.ts.map +1 -1
  217. package/dist/types/exports/react.d.ts +14 -1
  218. package/dist/types/exports/react.d.ts.map +1 -1
  219. package/dist/types/extensions/erc721/lazyMinting/read/getBatchesToReveal.d.ts +1 -1
  220. package/dist/types/extensions/modules/common/checkModulesCompatibility.d.ts +5 -0
  221. package/dist/types/extensions/modules/common/checkModulesCompatibility.d.ts.map +1 -1
  222. package/dist/types/extensions/prebuilts/deploy-pack.d.ts +1 -0
  223. package/dist/types/extensions/prebuilts/deploy-pack.d.ts.map +1 -1
  224. package/dist/types/extensions/thirdweb/write/publish.d.ts +4 -0
  225. package/dist/types/extensions/thirdweb/write/publish.d.ts.map +1 -1
  226. package/dist/types/react/core/hooks/others/useChainQuery.d.ts +3 -3
  227. package/dist/types/react/core/hooks/rpc/useBlockNumber.d.ts +1 -1
  228. package/dist/types/react/core/hooks/wallets/useCapabilities.d.ts +1 -1
  229. package/dist/types/react/core/hooks/wallets/useSendCalls.d.ts +3 -3
  230. package/dist/types/react/core/providers/connection-manager.d.ts +3 -0
  231. package/dist/types/react/core/providers/connection-manager.d.ts.map +1 -1
  232. package/dist/types/react/core/utils/wallet.d.ts +2 -1
  233. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  234. package/dist/types/react/core/utils/walletIcon.d.ts +2 -0
  235. package/dist/types/react/core/utils/walletIcon.d.ts.map +1 -1
  236. package/dist/types/react/native/hooks/wallets/useProfiles.d.ts +1 -1
  237. package/dist/types/react/native/providers/thirdweb-provider.d.ts +1 -0
  238. package/dist/types/react/native/providers/thirdweb-provider.d.ts.map +1 -1
  239. package/dist/types/react/native/ui/AutoConnect/AutoConnect.d.ts +1 -0
  240. package/dist/types/react/native/ui/AutoConnect/AutoConnect.d.ts.map +1 -1
  241. package/dist/types/react/native/ui/connect/ConnectModal.d.ts +1 -0
  242. package/dist/types/react/native/ui/connect/ConnectModal.d.ts.map +1 -1
  243. package/dist/types/react/native/ui/transaction/TransactionButton.d.ts +1 -0
  244. package/dist/types/react/native/ui/transaction/TransactionButton.d.ts.map +1 -1
  245. package/dist/types/react/web/hooks/wallets/useProfiles.d.ts +1 -1
  246. package/dist/types/react/web/providers/thirdweb-provider.d.ts +1 -0
  247. package/dist/types/react/web/providers/thirdweb-provider.d.ts.map +1 -1
  248. package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts +1 -0
  249. package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts.map +1 -1
  250. package/dist/types/react/web/ui/ConnectWallet/Blobbie.d.ts +22 -5
  251. package/dist/types/react/web/ui/ConnectWallet/Blobbie.d.ts.map +1 -1
  252. package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts +2 -1
  253. package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
  254. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  255. package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts +1 -0
  256. package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
  257. package/dist/types/react/web/ui/PayEmbed.d.ts +2 -2
  258. package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
  259. package/dist/types/react/web/ui/SiteEmbed.d.ts +3 -2
  260. package/dist/types/react/web/ui/SiteEmbed.d.ts.map +1 -1
  261. package/dist/types/react/web/ui/SiteLink.d.ts +2 -1
  262. package/dist/types/react/web/ui/SiteLink.d.ts.map +1 -1
  263. package/dist/types/react/web/ui/TransactionButton/index.d.ts +1 -0
  264. package/dist/types/react/web/ui/TransactionButton/index.d.ts.map +1 -1
  265. package/dist/types/react/web/ui/prebuilt/Account/address.d.ts +52 -0
  266. package/dist/types/react/web/ui/prebuilt/Account/address.d.ts.map +1 -0
  267. package/dist/types/react/web/ui/prebuilt/Account/avatar.d.ts +142 -0
  268. package/dist/types/react/web/ui/prebuilt/Account/avatar.d.ts.map +1 -0
  269. package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts +137 -0
  270. package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts.map +1 -0
  271. package/dist/types/react/web/ui/prebuilt/Account/blobbie.d.ts +8 -0
  272. package/dist/types/react/web/ui/prebuilt/Account/blobbie.d.ts.map +1 -0
  273. package/dist/types/react/web/ui/prebuilt/Account/name.d.ts +119 -0
  274. package/dist/types/react/web/ui/prebuilt/Account/name.d.ts.map +1 -0
  275. package/dist/types/react/web/ui/prebuilt/Account/provider.d.ts +45 -0
  276. package/dist/types/react/web/ui/prebuilt/Account/provider.d.ts.map +1 -0
  277. package/dist/types/react/web/ui/prebuilt/NFT/description.d.ts +59 -0
  278. package/dist/types/react/web/ui/prebuilt/NFT/description.d.ts.map +1 -0
  279. package/dist/types/react/web/ui/prebuilt/NFT/hooks.d.ts +14 -0
  280. package/dist/types/react/web/ui/prebuilt/NFT/hooks.d.ts.map +1 -0
  281. package/dist/types/react/web/ui/prebuilt/NFT/media.d.ts +75 -0
  282. package/dist/types/react/web/ui/prebuilt/NFT/media.d.ts.map +1 -0
  283. package/dist/types/react/web/ui/prebuilt/NFT/name.d.ts +59 -0
  284. package/dist/types/react/web/ui/prebuilt/NFT/name.d.ts.map +1 -0
  285. package/dist/types/react/web/ui/prebuilt/NFT/provider.d.ts +55 -0
  286. package/dist/types/react/web/ui/prebuilt/NFT/provider.d.ts.map +1 -0
  287. package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts +95 -0
  288. package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts.map +1 -0
  289. package/dist/types/react/web/ui/prebuilt/Token/name.d.ts +140 -0
  290. package/dist/types/react/web/ui/prebuilt/Token/name.d.ts.map +1 -0
  291. package/dist/types/react/web/ui/prebuilt/Token/provider.d.ts +61 -0
  292. package/dist/types/react/web/ui/prebuilt/Token/provider.d.ts.map +1 -0
  293. package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts +137 -0
  294. package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts.map +1 -0
  295. package/dist/types/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.d.ts +1 -0
  296. package/dist/types/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.d.ts.map +1 -1
  297. package/dist/types/react/web/ui/prebuilt/thirdweb/ClaimButton/index.d.ts +1 -0
  298. package/dist/types/react/web/ui/prebuilt/thirdweb/ClaimButton/index.d.ts.map +1 -1
  299. package/dist/types/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.d.ts +1 -0
  300. package/dist/types/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.d.ts.map +1 -1
  301. package/dist/types/storage/unpin.d.ts +1 -1
  302. package/dist/types/storage/upload.d.ts +1 -0
  303. package/dist/types/storage/upload.d.ts.map +1 -1
  304. package/dist/types/transaction/actions/to-serializable-transaction.d.ts +1 -1
  305. package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts +5 -0
  306. package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts.map +1 -1
  307. package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts +5 -0
  308. package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
  309. package/dist/types/utils/config.d.ts +9 -0
  310. package/dist/types/utils/config.d.ts.map +1 -1
  311. package/dist/types/utils/json.d.ts +1 -1
  312. package/dist/types/utils/json.d.ts.map +1 -1
  313. package/dist/types/version.d.ts +1 -1
  314. package/dist/types/wallets/eip5792/get-calls-status.d.ts +1 -1
  315. package/dist/types/wallets/eip5792/get-capabilities.d.ts +1 -1
  316. package/dist/types/wallets/eip5792/send-calls.d.ts +2 -2
  317. package/dist/types/wallets/eip5792/wait-for-bundle.d.ts +1 -1
  318. package/dist/types/wallets/in-app/core/users/getUser.d.ts +1 -1
  319. package/dist/types/wallets/smart/smart-wallet.d.ts +1 -0
  320. package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
  321. package/package.json +1 -1
  322. package/src/client/client.ts +1 -0
  323. package/src/exports/react.ts +56 -2
  324. package/src/extensions/erc721/lazyMinting/read/getBatchesToReveal.ts +1 -1
  325. package/src/extensions/modules/common/checkModulesCompatibility.ts +5 -0
  326. package/src/extensions/prebuilts/deploy-pack.ts +1 -0
  327. package/src/extensions/thirdweb/write/publish.ts +4 -0
  328. package/src/react/core/hooks/others/useChainQuery.ts +3 -3
  329. package/src/react/core/hooks/rpc/useBlockNumber.ts +1 -1
  330. package/src/react/core/hooks/wallets/useCapabilities.ts +1 -1
  331. package/src/react/core/hooks/wallets/useSendCalls.ts +3 -3
  332. package/src/react/core/providers/connection-manager.tsx +3 -0
  333. package/src/react/core/utils/wallet.ts +2 -1
  334. package/src/react/core/utils/walletIcon.ts +2 -0
  335. package/src/react/native/hooks/wallets/useProfiles.ts +1 -1
  336. package/src/react/native/providers/thirdweb-provider.tsx +1 -0
  337. package/src/react/native/ui/AutoConnect/AutoConnect.tsx +1 -0
  338. package/src/react/native/ui/connect/ConnectModal.tsx +1 -0
  339. package/src/react/native/ui/transaction/TransactionButton.tsx +1 -0
  340. package/src/react/web/hooks/wallets/useProfiles.ts +1 -1
  341. package/src/react/web/providers/thirdweb-provider.tsx +1 -0
  342. package/src/react/web/ui/AutoConnect/AutoConnect.tsx +1 -0
  343. package/src/react/web/ui/ConnectWallet/Blobbie.tsx +31 -4
  344. package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +36 -32
  345. package/src/react/web/ui/ConnectWallet/Details.tsx +91 -58
  346. package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +1 -0
  347. package/src/react/web/ui/PayEmbed.tsx +2 -2
  348. package/src/react/web/ui/SiteEmbed.tsx +3 -2
  349. package/src/react/web/ui/SiteLink.tsx +2 -1
  350. package/src/react/web/ui/TransactionButton/index.tsx +1 -0
  351. package/src/react/web/ui/prebuilt/Account/address.test.tsx +28 -0
  352. package/src/react/web/ui/prebuilt/Account/address.tsx +64 -0
  353. package/src/react/web/ui/prebuilt/Account/avatar.test.tsx +48 -0
  354. package/src/react/web/ui/prebuilt/Account/avatar.tsx +221 -0
  355. package/src/react/web/ui/prebuilt/Account/balance.test.tsx +54 -0
  356. package/src/react/web/ui/prebuilt/Account/balance.tsx +202 -0
  357. package/src/react/web/ui/prebuilt/Account/blobbie.tsx +12 -0
  358. package/src/react/web/ui/prebuilt/Account/name.test.tsx +62 -0
  359. package/src/react/web/ui/prebuilt/Account/name.tsx +175 -0
  360. package/src/react/web/ui/prebuilt/Account/provider.test.tsx +38 -0
  361. package/src/react/web/ui/prebuilt/Account/provider.tsx +69 -0
  362. package/src/react/web/ui/prebuilt/NFT/NFT.test.tsx +17 -14
  363. package/src/react/web/ui/prebuilt/NFT/description.tsx +87 -0
  364. package/src/react/web/ui/prebuilt/NFT/hooks.tsx +53 -0
  365. package/src/react/web/ui/prebuilt/NFT/media.tsx +119 -0
  366. package/src/react/web/ui/prebuilt/NFT/name.tsx +85 -0
  367. package/src/react/web/ui/prebuilt/NFT/provider.tsx +75 -0
  368. package/src/react/web/ui/prebuilt/Token/icon.tsx +164 -0
  369. package/src/react/web/ui/prebuilt/Token/name.tsx +201 -0
  370. package/src/react/web/ui/prebuilt/Token/provider.tsx +86 -0
  371. package/src/react/web/ui/prebuilt/Token/symbol.tsx +201 -0
  372. package/src/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/index.tsx +1 -0
  373. package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/index.tsx +1 -0
  374. package/src/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.tsx +1 -0
  375. package/src/storage/unpin.ts +1 -1
  376. package/src/storage/upload.ts +1 -0
  377. package/src/transaction/actions/to-serializable-transaction.ts +1 -1
  378. package/src/transaction/actions/zksync/send-eip712-transaction.ts +5 -0
  379. package/src/utils/any-evm/zksync/isZkSyncChain.ts +5 -0
  380. package/src/utils/config.ts +9 -0
  381. package/src/utils/json.ts +8 -2
  382. package/src/version.ts +1 -1
  383. package/src/wallets/eip5792/get-calls-status.ts +1 -1
  384. package/src/wallets/eip5792/get-capabilities.ts +1 -1
  385. package/src/wallets/eip5792/send-calls.ts +2 -2
  386. package/src/wallets/eip5792/wait-for-bundle.ts +1 -1
  387. package/src/wallets/in-app/core/users/getUser.ts +1 -1
  388. package/src/wallets/smart/smart-wallet.ts +1 -0
  389. package/dist/cjs/react/web/ui/prebuilt/NFT/NFT.js +0 -217
  390. package/dist/cjs/react/web/ui/prebuilt/NFT/NFT.js.map +0 -1
  391. package/dist/esm/react/web/ui/prebuilt/NFT/NFT.js +0 -212
  392. package/dist/esm/react/web/ui/prebuilt/NFT/NFT.js.map +0 -1
  393. package/dist/types/react/web/ui/prebuilt/NFT/NFT.d.ts +0 -76
  394. package/dist/types/react/web/ui/prebuilt/NFT/NFT.d.ts.map +0 -1
  395. package/src/extensions/prebuilts/deploy-published.test.ts +0 -132
  396. package/src/react/web/ui/prebuilt/NFT/NFT.tsx +0 -272
  397. package/src/wallets/smart/smart-wallet-integration-v07.test.ts +0 -270
  398. package/src/wallets/smart/smart-wallet-integration.test.ts +0 -375
@@ -0,0 +1,221 @@
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 { resolveAvatar } from "../../../../../extensions/ens/resolve-avatar.js";
7
+ import {
8
+ type ResolveNameOptions,
9
+ resolveName,
10
+ } from "../../../../../extensions/ens/resolve-name.js";
11
+ import { getSocialProfiles } from "../../../../../social/profiles.js";
12
+ import type { SocialProfile } from "../../../../../social/types.js";
13
+ import { parseAvatarRecord } from "../../../../../utils/ens/avatar.js";
14
+ import { useAccountContext } from "./provider.js";
15
+
16
+ /**
17
+ * Props for the AccountAvatar component
18
+ * @component
19
+ * @account
20
+ */
21
+ export interface AccountAvatarProps
22
+ extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src">,
23
+ Omit<ResolveNameOptions, "client" | "address"> {
24
+ /**
25
+ * Use this prop to prioritize the social profile that you want to display
26
+ * This is useful for a wallet containing multiple social profiles.
27
+ * This component inherits all attributes of a HTML's <img />, so you can interact with it just like a normal <img />
28
+ *
29
+ * @example
30
+ * If you have ENS, Lens and Farcaster profiles linked to your wallet
31
+ * you can prioritize showing the image for Lens by:
32
+ * ```tsx
33
+ * <AccountAvatar
34
+ * socialType="lens" // Choose between: "farcaster" | "lens" | "ens"
35
+ * />
36
+ * ```
37
+ */
38
+ socialType?: SocialProfile["type"];
39
+
40
+ /**
41
+ * This component will be shown while the avatar of the account is being fetched
42
+ * If not passed, the component will return `null`.
43
+ *
44
+ * You can pass a loading sign or spinner to this prop.
45
+ * @example
46
+ * ```tsx
47
+ * <AccountAvatar loadingComponent={<Spinner />} />
48
+ * ```
49
+ */
50
+ loadingComponent?: JSX.Element;
51
+ /**
52
+ * This component will be shown if the request for fetching the avatar is done
53
+ * but could not retreive any result.
54
+ * You can pass a dummy avatar/image to this prop.
55
+ *
56
+ * If not passed, the component will return `null`
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * <AccountAvatar fallbackComponent={<DummyImage />} />
61
+ * ```
62
+ */
63
+ fallbackComponent?: JSX.Element;
64
+
65
+ /**
66
+ * Optional query options for `useQuery`
67
+ */
68
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
69
+ }
70
+
71
+ /**
72
+ * The component for showing the avatar of the account.
73
+ * If fetches all the social profiles linked to your wallet, including: Farcaster, ENS, Lens (more to be added)
74
+ * You can choose which social profile you want to display. Defaults to the first item in the list.
75
+ *
76
+ * @example
77
+ * ### Basic usage
78
+ * ```tsx
79
+ * import { AccountProvider, AccountAvatar } from "thirdweb/react";
80
+ *
81
+ * <AccountProvider address="0x...">
82
+ * <AccountAvatar />
83
+ * </AccountProvider>
84
+ * ```
85
+ * Result: An <img /> component, if the avatar is resolved successfully
86
+ * ```html
87
+ * <img alt="" src="resolved-url-for-the-avatar" />
88
+ * ```
89
+ *
90
+ * ### Show a loading sign when the avatar is being resolved
91
+ * ```tsx
92
+ * import { AccountProvider, AccountAvatar } from "thirdweb/react";
93
+ *
94
+ * <AccountProvider address="0x...">
95
+ * <AccountAvatar
96
+ * loadingComponent={<YourLoadingComponent />}
97
+ * />
98
+ * </AccountProvider>
99
+ * ```
100
+ *
101
+ * ### Fallback to something when the avatar fails to resolve
102
+ * ```tsx
103
+ * import { AccountProvider, AccountAvatar } from "thirdweb/react";
104
+ *
105
+ * <AccountProvider address="0x...">
106
+ * <AccountAvatar
107
+ * fallbackComponent={<DummyImage />}
108
+ * />
109
+ * </AccountProvider>
110
+ * ```
111
+ *
112
+ * ### Select a social profile to display
113
+ * If you wallet associates with more than one social profiles (Lens, Farcaster, ENS, etc.)
114
+ * You can specify which service you want to prioritize using the `socialType` props
115
+ * ```tsx
116
+ * import { AccountProvider, AccountAvatar } from "thirdweb/react";
117
+ *
118
+ * <AccountProvider address="0x...">
119
+ * <AccountAvatar
120
+ * // Choose between: "farcaster" | "lens" | "ens"
121
+ * socialType={"ens"}
122
+ * />
123
+ * </AccountProvider>
124
+ * ```
125
+ *
126
+ * ### Custom ENS resolver chain
127
+ * This component shares the same props with the ENS extension `resolveAvatar`
128
+ * ```tsx
129
+ * import { AccountProvider, AccountAvatar } from "thirdweb/react";
130
+ * import { base } from "thirdweb/chains";
131
+ *
132
+ * <AccountProvider address="0x...">
133
+ * <AccountAvatar
134
+ * resolverAddress={"0x..."}
135
+ * resolverChain={base}
136
+ * />
137
+ * </AccountProvider>
138
+ * ```
139
+ *
140
+ * ### Custom query options for useQuery
141
+ * This component uses `@tanstack-query`'s useQuery internally.
142
+ * You can use the `queryOptions` prop for more fine-grained control
143
+ * ```tsx
144
+ * <AccountAvatar
145
+ * queryOptions={{
146
+ * enabled: isEnabled,
147
+ * retry: 3,
148
+ * }}
149
+ * />
150
+ * ```
151
+ * @returns An <img /> if the avatar is resolved successfully
152
+ * @component
153
+ * @account
154
+ * @beta
155
+ */
156
+ export function AccountAvatar({
157
+ socialType,
158
+ resolverAddress,
159
+ resolverChain,
160
+ loadingComponent,
161
+ fallbackComponent,
162
+ queryOptions,
163
+ ...restProps
164
+ }: AccountAvatarProps) {
165
+ const { address, client } = useAccountContext();
166
+ const avatarQuery = useQuery({
167
+ queryKey: ["account-avatar", address],
168
+ queryFn: async (): Promise<string> => {
169
+ const [socialData, ensName] = await Promise.all([
170
+ getSocialProfiles({ address, client }),
171
+ resolveName({
172
+ client,
173
+ address: address || "",
174
+ resolverAddress,
175
+ resolverChain,
176
+ }),
177
+ ]);
178
+
179
+ const uri = socialData?.filter(
180
+ (p) => p.avatar && (socialType ? p.type === socialType : true),
181
+ )[0]?.avatar;
182
+
183
+ const [resolvedSocialAvatar, resolvedENSAvatar] = await Promise.all([
184
+ uri ? parseAvatarRecord({ client, uri }) : undefined,
185
+ ensName
186
+ ? resolveAvatar({
187
+ client,
188
+ name: ensName,
189
+ })
190
+ : undefined,
191
+ ]);
192
+
193
+ // If no social image + ens name found -> exit and show <Blobbie />
194
+ if (!resolvedSocialAvatar && !resolvedENSAvatar) {
195
+ throw new Error("Failed to resolve social + ens avatar");
196
+ }
197
+
198
+ // else, prioritize the social image first
199
+ if (resolvedSocialAvatar) {
200
+ return resolvedSocialAvatar;
201
+ }
202
+
203
+ if (resolvedENSAvatar) {
204
+ return resolvedENSAvatar;
205
+ }
206
+
207
+ throw new Error("Failed to resolve social + ens avatar");
208
+ },
209
+ ...queryOptions,
210
+ });
211
+
212
+ if (avatarQuery.isLoading) {
213
+ return loadingComponent || null;
214
+ }
215
+
216
+ if (!avatarQuery.data) {
217
+ return fallbackComponent || null;
218
+ }
219
+
220
+ return <img src={avatarQuery.data} {...restProps} alt={restProps.alt} />;
221
+ }
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { ANVIL_CHAIN } from "~test/chains.js";
3
+ import { render, screen, waitFor } from "~test/react-render.js";
4
+ import { TEST_CLIENT } from "~test/test-clients.js";
5
+ import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
6
+ import { getWalletBalance } from "../../../../../wallets/utils/getWalletBalance.js";
7
+ import { AccountBalance } from "./balance.js";
8
+ import { AccountProvider } from "./provider.js";
9
+
10
+ describe.runIf(process.env.TW_SECRET_KEY)("AccountBalance component", () => {
11
+ it("format the balance properly", async () => {
12
+ const roundTo1Decimal = (num: number): number => Math.round(num * 10) / 10;
13
+ const balance = await getWalletBalance({
14
+ chain: ANVIL_CHAIN,
15
+ client: TEST_CLIENT,
16
+ address: TEST_ACCOUNT_A.address,
17
+ });
18
+
19
+ render(
20
+ <AccountProvider address={TEST_ACCOUNT_A.address} client={TEST_CLIENT}>
21
+ <AccountBalance chain={ANVIL_CHAIN} formatFn={roundTo1Decimal} />
22
+ </AccountProvider>,
23
+ );
24
+
25
+ waitFor(() =>
26
+ expect(
27
+ screen.getByText(roundTo1Decimal(Number(balance.displayValue)), {
28
+ exact: true,
29
+ selector: "span",
30
+ }),
31
+ ).toBeInTheDocument(),
32
+ );
33
+ });
34
+
35
+ it("should fallback properly if failed to load", () => {
36
+ render(
37
+ <AccountProvider address={TEST_ACCOUNT_A.address} client={TEST_CLIENT}>
38
+ <AccountBalance
39
+ chain={undefined}
40
+ fallbackComponent={<span>oops</span>}
41
+ />
42
+ </AccountProvider>,
43
+ );
44
+
45
+ waitFor(() =>
46
+ expect(
47
+ screen.getByText("oops", {
48
+ exact: true,
49
+ selector: "span",
50
+ }),
51
+ ).toBeInTheDocument(),
52
+ );
53
+ });
54
+ });
@@ -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
+ });