thirdweb 5.94.2 → 5.95.0-nightly-64bd603301b3067b6a69a29f66a28dee7ffa38f5-20250416000349

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 (202) hide show
  1. package/dist/cjs/chains/utils.js +41 -0
  2. package/dist/cjs/chains/utils.js.map +1 -1
  3. package/dist/cjs/event/actions/get-events.js +65 -11
  4. package/dist/cjs/event/actions/get-events.js.map +1 -1
  5. package/dist/cjs/exports/insight.js +5 -0
  6. package/dist/cjs/exports/insight.js.map +1 -0
  7. package/dist/cjs/exports/thirdweb.js +6 -2
  8. package/dist/cjs/exports/thirdweb.js.map +1 -1
  9. package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js +104 -0
  10. package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js.map +1 -0
  11. package/dist/cjs/extensions/thirdweb/write/publish.js +9 -4
  12. package/dist/cjs/extensions/thirdweb/write/publish.js.map +1 -1
  13. package/dist/cjs/insight/get-events.js +54 -0
  14. package/dist/cjs/insight/get-events.js.map +1 -0
  15. package/dist/cjs/insight/get-nfts.js +45 -0
  16. package/dist/cjs/insight/get-nfts.js.map +1 -0
  17. package/dist/cjs/insight/get-tokens.js +46 -0
  18. package/dist/cjs/insight/get-tokens.js.map +1 -0
  19. package/dist/cjs/insight/get-transactions.js +45 -0
  20. package/dist/cjs/insight/get-transactions.js.map +1 -0
  21. package/dist/cjs/insight/index.js +12 -0
  22. package/dist/cjs/insight/index.js.map +1 -0
  23. package/dist/cjs/pay/buyWithCrypto/getHistory.js +2 -2
  24. package/dist/cjs/pay/buyWithCrypto/getHistory.js.map +1 -1
  25. package/dist/cjs/pay/buyWithCrypto/getStatus.js +2 -2
  26. package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
  27. package/dist/cjs/pay/buyWithFiat/getHistory.js +2 -2
  28. package/dist/cjs/pay/buyWithFiat/getHistory.js.map +1 -1
  29. package/dist/cjs/pay/buyWithFiat/getStatus.js +2 -2
  30. package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
  31. package/dist/cjs/pay/getBuyHistory.js +2 -2
  32. package/dist/cjs/pay/getBuyHistory.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +4 -14
  34. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +6 -2
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +3 -1
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/SendFunds.js +3 -1
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/SendFunds.js.map +1 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js +1 -1
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  45. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewNFTs.js +74 -32
  46. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
  47. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js +46 -6
  48. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
  49. package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js +4 -1
  50. package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
  51. package/dist/cjs/rpc/fetch-rpc.js +4 -4
  52. package/dist/cjs/rpc/fetch-rpc.js.map +1 -1
  53. package/dist/cjs/transaction/actions/gasless/providers/biconomy.js +0 -1
  54. package/dist/cjs/transaction/actions/gasless/providers/biconomy.js.map +1 -1
  55. package/dist/cjs/transaction/actions/gasless/providers/openzeppelin.js +0 -1
  56. package/dist/cjs/transaction/actions/gasless/providers/openzeppelin.js.map +1 -1
  57. package/dist/cjs/transaction/transaction-store.js +11 -10
  58. package/dist/cjs/transaction/transaction-store.js.map +1 -1
  59. package/dist/cjs/utils/fetch.js +5 -4
  60. package/dist/cjs/utils/fetch.js.map +1 -1
  61. package/dist/cjs/version.js +1 -1
  62. package/dist/cjs/version.js.map +1 -1
  63. package/dist/esm/chains/utils.js +40 -0
  64. package/dist/esm/chains/utils.js.map +1 -1
  65. package/dist/esm/event/actions/get-events.js +62 -8
  66. package/dist/esm/event/actions/get-events.js.map +1 -1
  67. package/dist/esm/exports/insight.js +2 -0
  68. package/dist/esm/exports/insight.js.map +1 -0
  69. package/dist/esm/exports/thirdweb.js +4 -0
  70. package/dist/esm/exports/thirdweb.js.map +1 -1
  71. package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js +98 -0
  72. package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js.map +1 -0
  73. package/dist/esm/extensions/thirdweb/write/publish.js +9 -4
  74. package/dist/esm/extensions/thirdweb/write/publish.js.map +1 -1
  75. package/dist/esm/insight/get-events.js +51 -0
  76. package/dist/esm/insight/get-events.js.map +1 -0
  77. package/dist/esm/insight/get-nfts.js +42 -0
  78. package/dist/esm/insight/get-nfts.js.map +1 -0
  79. package/dist/esm/insight/get-tokens.js +43 -0
  80. package/dist/esm/insight/get-tokens.js.map +1 -0
  81. package/dist/esm/insight/get-transactions.js +42 -0
  82. package/dist/esm/insight/get-transactions.js.map +1 -0
  83. package/dist/esm/insight/index.js +5 -0
  84. package/dist/esm/insight/index.js.map +1 -0
  85. package/dist/esm/pay/buyWithCrypto/getHistory.js +2 -2
  86. package/dist/esm/pay/buyWithCrypto/getHistory.js.map +1 -1
  87. package/dist/esm/pay/buyWithCrypto/getStatus.js +2 -2
  88. package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
  89. package/dist/esm/pay/buyWithFiat/getHistory.js +2 -2
  90. package/dist/esm/pay/buyWithFiat/getHistory.js.map +1 -1
  91. package/dist/esm/pay/buyWithFiat/getStatus.js +2 -2
  92. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  93. package/dist/esm/pay/getBuyHistory.js +2 -2
  94. package/dist/esm/pay/getBuyHistory.js.map +1 -1
  95. package/dist/esm/react/web/ui/ConnectWallet/Details.js +4 -14
  96. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +6 -2
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  101. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +3 -1
  102. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  103. package/dist/esm/react/web/ui/ConnectWallet/screens/SendFunds.js +3 -1
  104. package/dist/esm/react/web/ui/ConnectWallet/screens/SendFunds.js.map +1 -1
  105. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js +1 -1
  106. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  107. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewNFTs.js +75 -33
  108. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
  109. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js +46 -6
  110. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
  111. package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js +4 -1
  112. package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
  113. package/dist/esm/rpc/fetch-rpc.js +4 -4
  114. package/dist/esm/rpc/fetch-rpc.js.map +1 -1
  115. package/dist/esm/transaction/actions/gasless/providers/biconomy.js +0 -1
  116. package/dist/esm/transaction/actions/gasless/providers/biconomy.js.map +1 -1
  117. package/dist/esm/transaction/actions/gasless/providers/openzeppelin.js +0 -1
  118. package/dist/esm/transaction/actions/gasless/providers/openzeppelin.js.map +1 -1
  119. package/dist/esm/transaction/transaction-store.js +11 -10
  120. package/dist/esm/transaction/transaction-store.js.map +1 -1
  121. package/dist/esm/utils/fetch.js +5 -4
  122. package/dist/esm/utils/fetch.js.map +1 -1
  123. package/dist/esm/version.js +1 -1
  124. package/dist/esm/version.js.map +1 -1
  125. package/dist/types/chains/types.d.ts +7 -0
  126. package/dist/types/chains/types.d.ts.map +1 -1
  127. package/dist/types/chains/utils.d.ts +15 -1
  128. package/dist/types/chains/utils.d.ts.map +1 -1
  129. package/dist/types/event/actions/get-events.d.ts +1 -6
  130. package/dist/types/event/actions/get-events.d.ts.map +1 -1
  131. package/dist/types/exports/insight.d.ts +2 -0
  132. package/dist/types/exports/insight.d.ts.map +1 -0
  133. package/dist/types/exports/thirdweb.d.ts +4 -0
  134. package/dist/types/exports/thirdweb.d.ts.map +1 -1
  135. package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.d.ts +64 -0
  136. package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.d.ts.map +1 -0
  137. package/dist/types/extensions/thirdweb/write/publish.d.ts.map +1 -1
  138. package/dist/types/insight/get-events.d.ts +31 -0
  139. package/dist/types/insight/get-events.d.ts.map +1 -0
  140. package/dist/types/insight/get-nfts.d.ts +25 -0
  141. package/dist/types/insight/get-nfts.d.ts.map +1 -0
  142. package/dist/types/insight/get-tokens.d.ts +25 -0
  143. package/dist/types/insight/get-tokens.d.ts.map +1 -0
  144. package/dist/types/insight/get-transactions.d.ts +25 -0
  145. package/dist/types/insight/get-transactions.d.ts.map +1 -0
  146. package/dist/types/insight/index.d.ts +5 -0
  147. package/dist/types/insight/index.d.ts.map +1 -0
  148. package/dist/types/pay/buyWithCrypto/getHistory.d.ts.map +1 -1
  149. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  150. package/dist/types/pay/buyWithFiat/getHistory.d.ts.map +1 -1
  151. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  152. package/dist/types/pay/getBuyHistory.d.ts.map +1 -1
  153. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  154. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
  155. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
  156. package/dist/types/react/web/ui/ConnectWallet/screens/SendFunds.d.ts.map +1 -1
  157. package/dist/types/react/web/ui/ConnectWallet/screens/ViewNFTs.d.ts.map +1 -1
  158. package/dist/types/react/web/ui/ConnectWallet/screens/ViewTokens.d.ts.map +1 -1
  159. package/dist/types/react/web/ui/MediaRenderer/useResolvedMediaType.d.ts +1 -1
  160. package/dist/types/react/web/ui/MediaRenderer/useResolvedMediaType.d.ts.map +1 -1
  161. package/dist/types/rpc/fetch-rpc.d.ts.map +1 -1
  162. package/dist/types/transaction/actions/gasless/providers/biconomy.d.ts.map +1 -1
  163. package/dist/types/transaction/actions/gasless/providers/openzeppelin.d.ts.map +1 -1
  164. package/dist/types/transaction/transaction-store.d.ts.map +1 -1
  165. package/dist/types/utils/fetch.d.ts +1 -1
  166. package/dist/types/utils/fetch.d.ts.map +1 -1
  167. package/dist/types/version.d.ts +1 -1
  168. package/dist/types/version.d.ts.map +1 -1
  169. package/package.json +8 -2
  170. package/src/chains/types.ts +8 -0
  171. package/src/chains/utils.ts +61 -0
  172. package/src/event/actions/get-events.test.ts +96 -0
  173. package/src/event/actions/get-events.ts +99 -12
  174. package/src/exports/insight.ts +1 -0
  175. package/src/exports/thirdweb.ts +5 -0
  176. package/src/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.ts +104 -0
  177. package/src/extensions/thirdweb/write/publish.ts +12 -4
  178. package/src/insight/get-events.ts +78 -0
  179. package/src/insight/get-nfts.ts +65 -0
  180. package/src/insight/get-tokens.ts +66 -0
  181. package/src/insight/get-transactions.ts +66 -0
  182. package/src/insight/index.ts +4 -0
  183. package/src/pay/buyWithCrypto/getHistory.ts +4 -2
  184. package/src/pay/buyWithCrypto/getStatus.ts +4 -2
  185. package/src/pay/buyWithFiat/getHistory.ts +4 -2
  186. package/src/pay/buyWithFiat/getStatus.ts +4 -2
  187. package/src/pay/getBuyHistory.ts +4 -2
  188. package/src/react/web/ui/ConnectWallet/Details.tsx +15 -33
  189. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +10 -2
  190. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +2 -2
  191. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +5 -1
  192. package/src/react/web/ui/ConnectWallet/screens/SendFunds.tsx +5 -1
  193. package/src/react/web/ui/ConnectWallet/screens/ViewAssets.tsx +1 -1
  194. package/src/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx +107 -55
  195. package/src/react/web/ui/ConnectWallet/screens/ViewTokens.tsx +94 -11
  196. package/src/react/web/ui/MediaRenderer/useResolvedMediaType.ts +4 -1
  197. package/src/rpc/fetch-rpc.ts +6 -4
  198. package/src/transaction/actions/gasless/providers/biconomy.ts +0 -1
  199. package/src/transaction/actions/gasless/providers/openzeppelin.ts +0 -1
  200. package/src/transaction/transaction-store.ts +11 -22
  201. package/src/utils/fetch.ts +6 -5
  202. package/src/version.ts +1 -1
@@ -0,0 +1,65 @@
1
+ import {
2
+ type GetV1NftsBalanceByOwnerAddressData,
3
+ type GetV1NftsBalanceByOwnerAddressResponse,
4
+ getV1NftsBalanceByOwnerAddress,
5
+ } from "@thirdweb-dev/insight";
6
+ import { stringify } from "viem";
7
+ import type { Chain } from "../chains/types.js";
8
+ import type { ThirdwebClient } from "../client/client.js";
9
+ import { getThirdwebDomains } from "../utils/domains.js";
10
+ import { getClientFetch } from "../utils/fetch.js";
11
+
12
+ export type OwnedNFT = GetV1NftsBalanceByOwnerAddressResponse["data"][number];
13
+
14
+ /**
15
+ * Get NFTs owned by an address
16
+ * @example
17
+ * ```ts
18
+ * import { Insight } from "thirdweb";
19
+ *
20
+ * const nfts = await Insight.getOwnedNFTs({
21
+ * client,
22
+ * chains: [sepolia],
23
+ * ownerAddress: "0x1234567890123456789012345678901234567890",
24
+ * });
25
+ * ```
26
+ * @insight
27
+ */
28
+ export async function getOwnedNFTs(args: {
29
+ client: ThirdwebClient;
30
+ chains: Chain[];
31
+ ownerAddress: string;
32
+ queryOptions?: GetV1NftsBalanceByOwnerAddressData["query"];
33
+ }): Promise<OwnedNFT[]> {
34
+ const {
35
+ client,
36
+ chains,
37
+ ownerAddress,
38
+ queryOptions = {
39
+ chain: chains.map((chain) => chain.id),
40
+ metadata: "true",
41
+ limit: 100,
42
+ page: 1,
43
+ },
44
+ } = args;
45
+
46
+ const result = await getV1NftsBalanceByOwnerAddress({
47
+ baseUrl: `https://${getThirdwebDomains().insight}`,
48
+ fetch: getClientFetch(client),
49
+ path: {
50
+ ownerAddress: ownerAddress,
51
+ },
52
+ query: {
53
+ chain: chains.map((chain) => chain.id),
54
+ ...queryOptions,
55
+ },
56
+ });
57
+
58
+ if (result.error) {
59
+ throw new Error(
60
+ `${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
61
+ );
62
+ }
63
+
64
+ return result.data?.data ?? [];
65
+ }
@@ -0,0 +1,66 @@
1
+ import {
2
+ type GetV1TokensErc20ByOwnerAddressData,
3
+ type GetV1TokensErc20ByOwnerAddressResponse,
4
+ getV1TokensErc20ByOwnerAddress,
5
+ } from "@thirdweb-dev/insight";
6
+ import { stringify } from "viem";
7
+ import type { Chain } from "../chains/types.js";
8
+ import type { ThirdwebClient } from "../client/client.js";
9
+ import { getThirdwebDomains } from "../utils/domains.js";
10
+ import { getClientFetch } from "../utils/fetch.js";
11
+
12
+ export type OwnedToken = GetV1TokensErc20ByOwnerAddressResponse["data"][number];
13
+
14
+ /**
15
+ * Get ERC20 tokens owned by an address
16
+ * @example
17
+ * ```ts
18
+ * import { Insight } from "thirdweb";
19
+ *
20
+ * const tokens = await Insight.getOwnedTokens({
21
+ * client,
22
+ * chains: [sepolia],
23
+ * ownerAddress: "0x1234567890123456789012345678901234567890",
24
+ * });
25
+ * ```
26
+ * @insight
27
+ */
28
+ export async function getOwnedTokens(args: {
29
+ client: ThirdwebClient;
30
+ chains: Chain[];
31
+ ownerAddress: string;
32
+ queryOptions?: GetV1TokensErc20ByOwnerAddressData["query"];
33
+ }): Promise<OwnedToken[]> {
34
+ const {
35
+ client,
36
+ chains,
37
+ ownerAddress,
38
+ queryOptions = {
39
+ chain: chains.map((chain) => chain.id),
40
+ include_spam: "false",
41
+ metadata: "true",
42
+ limit: 100,
43
+ page: 1,
44
+ },
45
+ } = args;
46
+
47
+ const result = await getV1TokensErc20ByOwnerAddress({
48
+ baseUrl: `https://${getThirdwebDomains().insight}`,
49
+ fetch: getClientFetch(client),
50
+ path: {
51
+ ownerAddress: ownerAddress,
52
+ },
53
+ query: {
54
+ chain: chains.map((chain) => chain.id),
55
+ ...queryOptions,
56
+ },
57
+ });
58
+
59
+ if (result.error) {
60
+ throw new Error(
61
+ `${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
62
+ );
63
+ }
64
+
65
+ return result.data?.data ?? [];
66
+ }
@@ -0,0 +1,66 @@
1
+ import {
2
+ type GetV1WalletsByWalletAddressTransactionsData,
3
+ type GetV1WalletsByWalletAddressTransactionsResponse,
4
+ getV1WalletsByWalletAddressTransactions,
5
+ } from "@thirdweb-dev/insight";
6
+ import { stringify } from "viem";
7
+ import type { Chain } from "../chains/types.js";
8
+ import type { ThirdwebClient } from "../client/client.js";
9
+ import { getThirdwebDomains } from "../utils/domains.js";
10
+ import { getClientFetch } from "../utils/fetch.js";
11
+
12
+ export type Transaction = NonNullable<
13
+ GetV1WalletsByWalletAddressTransactionsResponse["data"]
14
+ >[number];
15
+
16
+ /**
17
+ * Get transactions for a wallet
18
+ * @example
19
+ * ```ts
20
+ * import { Insight } from "thirdweb";
21
+ *
22
+ * const transactions = await Insight.getTransactions({
23
+ * client,
24
+ * walletAddress: "0x1234567890123456789012345678901234567890",
25
+ * chains: [sepolia],
26
+ * });
27
+ * ```
28
+ * @insight
29
+ */
30
+ export async function getTransactions(args: {
31
+ client: ThirdwebClient;
32
+ walletAddress: string;
33
+ chains: Chain[];
34
+ queryOptions?: GetV1WalletsByWalletAddressTransactionsData["query"];
35
+ }): Promise<Transaction[]> {
36
+ const threeMonthsAgoInSeconds = Math.floor(
37
+ (Date.now() - 3 * 30 * 24 * 60 * 60 * 1000) / 1000,
38
+ );
39
+ const {
40
+ client,
41
+ walletAddress,
42
+ chains,
43
+ queryOptions = {
44
+ filter_block_timestamp_gte: threeMonthsAgoInSeconds,
45
+ limit: 100,
46
+ page: 1,
47
+ },
48
+ } = args;
49
+ const result = await getV1WalletsByWalletAddressTransactions({
50
+ baseUrl: `https://${getThirdwebDomains().insight}`,
51
+ fetch: getClientFetch(client),
52
+ query: {
53
+ chain: chains.map((chain) => chain.id),
54
+ ...queryOptions,
55
+ },
56
+ path: {
57
+ wallet_address: walletAddress,
58
+ },
59
+ });
60
+ if (result.error) {
61
+ throw new Error(
62
+ `${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
63
+ );
64
+ }
65
+ return result.data.data || [];
66
+ }
@@ -0,0 +1,4 @@
1
+ export { getOwnedNFTs, type OwnedNFT } from "./get-nfts.js";
2
+ export { getOwnedTokens, type OwnedToken } from "./get-tokens.js";
3
+ export { getTransactions, type Transaction } from "./get-transactions.js";
4
+ export { getContractEvents, type ContractEvent } from "./get-events.js";
@@ -79,8 +79,10 @@ export async function getBuyWithCryptoHistory(
79
79
 
80
80
  // Assuming the response directly matches the SwapResponse interface
81
81
  if (!response.ok) {
82
- response.body?.cancel();
83
- throw new Error(`HTTP error! status: ${response.status}`);
82
+ const error = await response.text().catch(() => null);
83
+ throw new Error(
84
+ `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
85
+ );
84
86
  }
85
87
 
86
88
  const data: BuyWithCryptoHistoryData = (await response.json()).result;
@@ -142,8 +142,10 @@ export async function getBuyWithCryptoStatus(
142
142
 
143
143
  // Assuming the response directly matches the BuyWithCryptoStatus interface
144
144
  if (!response.ok) {
145
- response.body?.cancel();
146
- throw new Error(`HTTP error! status: ${response.status}`);
145
+ const error = await response.text().catch(() => null);
146
+ throw new Error(
147
+ `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
148
+ );
147
149
  }
148
150
 
149
151
  const data: BuyWithCryptoStatus = (await response.json()).result;
@@ -78,8 +78,10 @@ export async function getBuyWithFiatHistory(
78
78
 
79
79
  // Assuming the response directly matches the BuyWithFiatStatus response interface
80
80
  if (!response.ok) {
81
- response.body?.cancel();
82
- throw new Error(`HTTP error! status: ${response.status}`);
81
+ const error = await response.text().catch(() => null);
82
+ throw new Error(
83
+ `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
84
+ );
83
85
  }
84
86
 
85
87
  const data: BuyWithFiatHistoryData = (await response.json()).result;
@@ -188,8 +188,10 @@ export async function getBuyWithFiatStatus(
188
188
  const response = await getClientFetch(params.client)(url);
189
189
 
190
190
  if (!response.ok) {
191
- response.body?.cancel();
192
- throw new Error(`HTTP error! status: ${response.status}`);
191
+ const error = await response.text().catch(() => null);
192
+ throw new Error(
193
+ `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
194
+ );
193
195
  }
194
196
 
195
197
  return (await response.json()).result;
@@ -93,8 +93,10 @@ export async function getBuyHistory(
93
93
 
94
94
  // Assuming the response directly matches the SwapResponse interface
95
95
  if (!response.ok) {
96
- response.body?.cancel();
97
- throw new Error(`HTTP error! status: ${response.status}`);
96
+ const error = await response.text().catch(() => null);
97
+ throw new Error(
98
+ `HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
99
+ );
98
100
  }
99
101
 
100
102
  const data: BuyHistoryData = (await response.json()).result;
@@ -703,11 +703,7 @@ export function DetailsModal(props: {
703
703
  }}
704
704
  >
705
705
  <CoinsIcon size={iconSize.md} />
706
- <Text color="primaryText">
707
- {props.supportedNFTs
708
- ? locale.viewFunds.viewAssets
709
- : locale.viewFunds.title}
710
- </Text>
706
+ <Text color="primaryText">{locale.viewFunds.viewAssets}</Text>
711
707
  </MenuButton>
712
708
  )}
713
709
 
@@ -841,34 +837,20 @@ export function DetailsModal(props: {
841
837
  />
842
838
  );
843
839
  } else if (screen === "view-assets") {
844
- if (props.supportedNFTs) {
845
- content = (
846
- <ViewAssets
847
- supportedTokens={props.supportedTokens}
848
- supportedNFTs={props.supportedNFTs}
849
- onBack={() => {
850
- setScreen("main");
851
- }}
852
- theme={props.theme}
853
- setScreen={setScreen}
854
- client={client}
855
- connectLocale={locale}
856
- assetTabs={props.detailsModal?.assetTabs}
857
- />
858
- );
859
- } else {
860
- // Always show tokens (has the native token at least)
861
- content = (
862
- <ViewTokens
863
- supportedTokens={props.supportedTokens}
864
- onBack={() => {
865
- setScreen("main");
866
- }}
867
- client={client}
868
- connectLocale={locale}
869
- />
870
- );
871
- }
840
+ content = (
841
+ <ViewAssets
842
+ supportedTokens={props.supportedTokens}
843
+ supportedNFTs={props.supportedNFTs}
844
+ onBack={() => {
845
+ setScreen("main");
846
+ }}
847
+ theme={props.theme}
848
+ setScreen={setScreen}
849
+ client={client}
850
+ connectLocale={locale}
851
+ assetTabs={props.detailsModal?.assetTabs}
852
+ />
853
+ );
872
854
  } else if (screen === "view-nfts") {
873
855
  content = (
874
856
  <ViewNFTs
@@ -68,7 +68,11 @@ export function SwapConfirmationScreen(props: {
68
68
 
69
69
  const uiErrorMessage = useMemo(() => {
70
70
  if (step === "approval" && status === "error" && error) {
71
- if (error.toLowerCase().includes("user rejected")) {
71
+ if (
72
+ error.toLowerCase().includes("user rejected") ||
73
+ error.toLowerCase().includes("user closed modal") ||
74
+ error.toLowerCase().includes("user denied")
75
+ ) {
72
76
  return {
73
77
  title: "Failed to Approve",
74
78
  message: "Your wallet rejected the approval request.",
@@ -82,7 +86,11 @@ export function SwapConfirmationScreen(props: {
82
86
  }
83
87
 
84
88
  if (step === "swap" && status === "error" && error) {
85
- if (error.toLowerCase().includes("user rejected")) {
89
+ if (
90
+ error.toLowerCase().includes("user rejected") ||
91
+ error.toLowerCase().includes("user closed modal") ||
92
+ error.toLowerCase().includes("user denied")
93
+ ) {
86
94
  return {
87
95
  title: "Failed to Confirm",
88
96
  message: "Your wallet rejected the confirmation request.",
@@ -176,11 +176,11 @@ export function TokenSelectorScreen(props: {
176
176
  enabled: !!props.sourceSupportedTokens && !!chainInfo.data,
177
177
  });
178
178
 
179
- if (walletsAndBalances.isLoading || !walletsAndBalances.data) {
179
+ if (walletsAndBalances.isLoading || chainInfo.isLoading) {
180
180
  return <LoadingScreen />;
181
181
  }
182
182
 
183
- const filteredWallets = Array.from(walletsAndBalances.data.entries() || [])
183
+ const filteredWallets = Array.from(walletsAndBalances.data?.entries() || [])
184
184
  .filter(([w]) => !props.hiddenWallets?.includes(w.id))
185
185
  .filter(([, balances]) => {
186
186
  const hasEnoughBalance = balances.some((b) => b.balance.value > 0);
@@ -112,7 +112,11 @@ export function TransferConfirmationScreen(
112
112
 
113
113
  const uiErrorMessage = useMemo(() => {
114
114
  if (step === "approve" && status.id === "error" && status.error) {
115
- if (status.error.toLowerCase().includes("user rejected")) {
115
+ if (
116
+ status.error.toLowerCase().includes("user rejected") ||
117
+ status.error.toLowerCase().includes("user closed modal") ||
118
+ status.error.toLowerCase().includes("user denied")
119
+ ) {
116
120
  return {
117
121
  title: "Failed to Approve",
118
122
  message: "Your wallet rejected the approval request.",
@@ -145,7 +145,11 @@ export function SendFundsForm(props: {
145
145
  return locale.transactionFailed;
146
146
  }
147
147
 
148
- if (message.includes("user rejected")) {
148
+ if (
149
+ message.includes("user rejected") ||
150
+ message.includes("user closed modal") ||
151
+ message.includes("user denied")
152
+ ) {
149
153
  return locale.transactionRejected;
150
154
  }
151
155
 
@@ -82,7 +82,7 @@ export function ViewAssets(props: {
82
82
  >
83
83
  <Container p="lg">
84
84
  <ModalHeader
85
- title={connectLocale.viewFunds.title}
85
+ title={connectLocale.viewFunds.viewAssets}
86
86
  onBack={props.onBack}
87
87
  />
88
88
  </Container>
@@ -1,5 +1,4 @@
1
- import { useQueries } from "@tanstack/react-query";
2
- import { useMemo } from "react";
1
+ import { useQuery } from "@tanstack/react-query";
3
2
  import type { Chain } from "../../../../../chains/types.js";
4
3
  import { getCachedChain } from "../../../../../chains/utils.js";
5
4
  import type { ThirdwebClient } from "../../../../../client/client.js";
@@ -8,6 +7,9 @@ import { getOwnedNFTs as getErc721OwnedNFTs } from "../../../../../extensions/er
8
7
  import { isERC721 } from "../../../../../extensions/erc721/read/isERC721.js";
9
8
  import { getOwnedNFTs as getErc1155OwnedNFTs } from "../../../../../extensions/erc1155/read/getOwnedNFTs.js";
10
9
  import { isERC1155 } from "../../../../../extensions/erc1155/read/isERC1155.js";
10
+ import { getOwnedNFTs } from "../../../../../insight/get-nfts.js";
11
+ import type { Address } from "../../../../../utils/address.js";
12
+ import type { NFT } from "../../../../../utils/nft/parseNft.js";
11
13
  import type { Theme } from "../../../../core/design-system/index.js";
12
14
  import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
13
15
  import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js";
@@ -16,6 +18,7 @@ import { MediaRenderer } from "../../MediaRenderer/MediaRenderer.js";
16
18
  import { Skeleton } from "../../components/Skeleton.js";
17
19
  import { Spacer } from "../../components/Spacer.js";
18
20
  import { Container, Line, ModalHeader } from "../../components/basic.js";
21
+ import { Text } from "../../components/text.js";
19
22
  import type { ConnectLocale } from "../locale/types.js";
20
23
 
21
24
  const fetchNFTs = async (
@@ -108,44 +111,90 @@ export function ViewNFTsContent(props: {
108
111
  const activeAccount = useActiveAccount();
109
112
  const activeChain = useActiveWalletChain();
110
113
 
111
- const nftList = useMemo(() => {
112
- const nfts = [];
113
- if (!props.supportedNFTs) return [];
114
- for (const chainId in props.supportedNFTs) {
115
- if (props.supportedNFTs[chainId]) {
116
- nfts.push(
117
- ...props.supportedNFTs[chainId].map((address) => ({
118
- address,
119
- chain: getCachedChain(Number.parseInt(chainId)),
120
- })),
121
- );
114
+ const nftQuery = useQuery({
115
+ queryKey: ["nfts", activeChain?.id, activeAccount?.address],
116
+ queryFn: async (): Promise<
117
+ (NFT & { chain: Chain; address: Address; quantityOwned: bigint })[]
118
+ > => {
119
+ if (!activeAccount) {
120
+ throw new Error("No active account");
122
121
  }
123
- }
124
- return nfts;
125
- }, [props.supportedNFTs]);
122
+ if (!activeChain) {
123
+ throw new Error("No active chain");
124
+ }
125
+
126
+ const result = await getOwnedNFTs({
127
+ client: props.client,
128
+ chains: [activeChain],
129
+ ownerAddress: activeAccount.address,
130
+ });
131
+
132
+ return result
133
+ .filter((nft) => !!nft.name && !!nft.image_url)
134
+ .map((nft) => {
135
+ let parsedNft: NFT;
136
+ const metadata = {
137
+ name: nft.name,
138
+ description: nft.description,
139
+ image: nft.image_url,
140
+ animation_url: nft.video_url,
141
+ external_url: nft.external_url,
142
+ background_color: nft.background_color,
143
+ uri: nft.metadata_url ?? "",
144
+ image_url: nft.image_url,
145
+ attributes: Array.isArray(nft.extra_metadata?.attributes)
146
+ ? nft.extra_metadata?.attributes?.reduce(
147
+ (acc, attr) => {
148
+ acc[attr.trait_type] = attr.value;
149
+ return acc;
150
+ },
151
+ {} as Record<string, unknown>,
152
+ )
153
+ : {},
154
+ };
126
155
 
127
- const results = useQueries({
128
- queries: nftList.map((nft) => ({
129
- queryKey: ["readContract", nft.chain.id, nft.address],
130
- queryFn: () => {
131
- if (!activeAccount) {
132
- throw new Error("No active account");
133
- }
134
- return fetchNFTs(
135
- props.client,
136
- nft.chain,
137
- nft.address,
138
- activeAccount.address,
139
- );
140
- },
141
- enabled: !!activeAccount,
142
- })),
156
+ if (nft.contract?.type === "erc1155") {
157
+ parsedNft = {
158
+ id: BigInt(nft.token_id),
159
+ type: "ERC1155",
160
+ owner: activeAccount.address,
161
+ tokenURI: nft.metadata_url ?? "",
162
+ supply: BigInt(nft.balance), // TODO: this is wrong
163
+ metadata,
164
+ };
165
+ } else {
166
+ parsedNft = {
167
+ id: BigInt(nft.token_id),
168
+ type: "ERC721",
169
+ owner: activeAccount.address,
170
+ tokenURI: nft.metadata_url ?? "",
171
+ metadata,
172
+ };
173
+ }
174
+
175
+ return {
176
+ chain: getCachedChain(nft.chain_id),
177
+ address: nft.token_address as Address,
178
+ quantityOwned: BigInt(nft.balance),
179
+ ...parsedNft,
180
+ };
181
+ });
182
+ },
183
+ enabled: !!activeChain && !!activeAccount,
143
184
  });
144
185
 
145
186
  if (!activeChain?.id || !activeAccount?.address) {
146
187
  return null;
147
188
  }
148
189
 
190
+ const filteredNFTs = props.supportedNFTs?.[activeChain.id]
191
+ ? nftQuery.data?.filter((nft) =>
192
+ props.supportedNFTs?.[activeChain.id]
193
+ ?.map((supportedNFTAddress) => supportedNFTAddress.toLowerCase())
194
+ .includes(nft.address.toLowerCase()),
195
+ )
196
+ : nftQuery.data;
197
+
149
198
  return (
150
199
  <>
151
200
  <Container
@@ -155,29 +204,21 @@ export function ViewNFTsContent(props: {
155
204
  gap: "12px",
156
205
  }}
157
206
  >
158
- {results.map((result, index) => {
159
- if (result.error) {
160
- console.error(result.error);
161
- return null;
162
- }
163
- return result.isLoading || !result.data ? (
164
- <Skeleton
165
- key={`${nftList[index]?.chain?.id}:${nftList[index]?.address}`}
166
- height="150px"
167
- width="150px"
207
+ {nftQuery.error ? (
208
+ <Text>Error loading NFTs</Text>
209
+ ) : nftQuery.isLoading || !filteredNFTs ? (
210
+ <Skeleton height="150px" width="150px" />
211
+ ) : (
212
+ filteredNFTs.map((nft) => (
213
+ <NftCard
214
+ key={`${nft.chain.id}:${nft.address}:${nft.id}`}
215
+ {...nft}
216
+ client={props.client}
217
+ chain={nft.chain}
218
+ theme={props.theme}
168
219
  />
169
- ) : (
170
- result.data.map((nft) => (
171
- <NftCard
172
- key={`${nft.chain.id}:${nft.address}:${nft.id}`}
173
- {...nft}
174
- client={props.client}
175
- chain={nft.chain}
176
- theme={props.theme}
177
- />
178
- ))
179
- );
180
- })}
220
+ ))
221
+ )}
181
222
  </Container>
182
223
  <Spacer y="lg" />
183
224
  </>
@@ -198,6 +239,7 @@ function NftCard(
198
239
  <div
199
240
  style={{
200
241
  display: "flex",
242
+ width: "150px",
201
243
  flexDirection: "column",
202
244
  gap: "4px",
203
245
  alignItems: "center",
@@ -263,7 +305,17 @@ function NftCard(
263
305
  />
264
306
  )}
265
307
  </div>
266
- <span style={{ fontWeight: 600 }}>{props.metadata.name}</span>
308
+ <Text
309
+ size="xs"
310
+ color="primaryText"
311
+ style={{
312
+ fontWeight: 600,
313
+ textAlign: "center",
314
+ maxLines: 2,
315
+ }}
316
+ >
317
+ {props.metadata.name}
318
+ </Text>
267
319
  </div>
268
320
  );
269
321