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
@@ -1,5 +1,8 @@
1
+ import { useQuery } from "@tanstack/react-query";
1
2
  import type { Chain } from "../../../../../chains/types.js";
2
3
  import type { ThirdwebClient } from "../../../../../client/client.js";
4
+ import { getOwnedTokens } from "../../../../../insight/get-tokens.js";
5
+ import { toTokens } from "../../../../../utils/units.js";
3
6
  import { fontSize } from "../../../../core/design-system/index.js";
4
7
  import { useWalletBalance } from "../../../../core/hooks/others/useWalletBalance.js";
5
8
  import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
@@ -38,7 +41,7 @@ export function ViewTokens(props: {
38
41
  >
39
42
  <Container p="lg">
40
43
  <ModalHeader
41
- title={props.connectLocale.viewFunds.title}
44
+ title={props.connectLocale.viewFunds.viewTokens}
42
45
  onBack={props.onBack}
43
46
  />
44
47
  </Container>
@@ -63,15 +66,49 @@ export function ViewTokensContent(props: {
63
66
  client: ThirdwebClient;
64
67
  connectLocale: ConnectLocale;
65
68
  }) {
69
+ const account = useActiveAccount();
66
70
  const activeChain = useActiveWalletChain();
67
- if (!activeChain) {
68
- return null;
69
- }
71
+
70
72
  const supportedTokens = props.supportedTokens || defaultTokens;
71
73
 
72
74
  const tokenList =
73
75
  (activeChain?.id ? supportedTokens[activeChain.id] : undefined) || [];
74
76
 
77
+ const erc20TokensQuery = useQuery({
78
+ queryKey: ["tokens", activeChain?.id, account?.address],
79
+ queryFn: async () => {
80
+ if (!activeChain) {
81
+ throw new Error("No active chain");
82
+ }
83
+
84
+ if (!account) {
85
+ throw new Error("No account");
86
+ }
87
+
88
+ const result = await getOwnedTokens({
89
+ client: props.client,
90
+ chains: [activeChain],
91
+ ownerAddress: account.address,
92
+ });
93
+
94
+ return result.filter(
95
+ (token) =>
96
+ !defaultTokens[activeChain.id]?.some(
97
+ (t) =>
98
+ t.address.toLowerCase() === token.token_address.toLowerCase(),
99
+ ),
100
+ );
101
+ },
102
+ // only fetch tokens if no explicit supported tokens are provided
103
+ enabled:
104
+ !!activeChain &&
105
+ !!account &&
106
+ (!props.supportedTokens || !props.supportedTokens[activeChain.id]),
107
+ });
108
+
109
+ if (!activeChain || !account) {
110
+ return null;
111
+ }
75
112
  return (
76
113
  <>
77
114
  <TokenInfo
@@ -90,6 +127,37 @@ export function ViewTokensContent(props: {
90
127
  />
91
128
  );
92
129
  })}
130
+
131
+ {erc20TokensQuery.isLoading && (
132
+ <Container flex="column" gap="sm" p="sm">
133
+ <Skeleton height={fontSize.md} width="100%" />
134
+ <Skeleton height={fontSize.md} width="100%" />
135
+ </Container>
136
+ )}
137
+
138
+ {erc20TokensQuery.data?.map((token) => {
139
+ return (
140
+ <TokenInfo
141
+ token={{
142
+ address: token.token_address,
143
+ name: token.name ?? "",
144
+ symbol: token.symbol ?? "",
145
+ }}
146
+ key={token.token_address}
147
+ chain={activeChain}
148
+ client={props.client}
149
+ balanceData={{
150
+ symbol: token.symbol ?? "",
151
+ name: token.name ?? "",
152
+ decimals: token.decimals ?? 18,
153
+ displayValue: toTokens(
154
+ BigInt(token.balance),
155
+ token.decimals ?? 18,
156
+ ),
157
+ }}
158
+ />
159
+ );
160
+ })}
93
161
  </>
94
162
  );
95
163
  }
@@ -98,14 +166,27 @@ function TokenInfo(props: {
98
166
  token: ERC20OrNativeToken;
99
167
  chain: Chain;
100
168
  client: ThirdwebClient;
169
+ balanceData?: {
170
+ symbol: string;
171
+ name: string;
172
+ decimals: number;
173
+ displayValue: string;
174
+ };
101
175
  }) {
102
176
  const account = useActiveAccount();
103
- const tokenBalanceQuery = useWalletBalance({
104
- address: account?.address,
105
- chain: props.chain,
106
- tokenAddress: isNativeToken(props.token) ? undefined : props.token.address,
107
- client: props.client,
108
- });
177
+ const tokenBalanceQuery = useWalletBalance(
178
+ {
179
+ address: account?.address,
180
+ chain: props.chain,
181
+ tokenAddress: isNativeToken(props.token)
182
+ ? undefined
183
+ : props.token.address,
184
+ client: props.client,
185
+ },
186
+ {
187
+ enabled: props.balanceData === undefined,
188
+ },
189
+ );
109
190
 
110
191
  const tokenName = isNativeToken(props.token)
111
192
  ? tokenBalanceQuery.data?.name
@@ -129,7 +210,9 @@ function TokenInfo(props: {
129
210
  <Skeleton height={fontSize.md} width="150px" />
130
211
  )}
131
212
 
132
- {tokenBalanceQuery.data ? (
213
+ {props.balanceData ? (
214
+ <Text size="xs"> {formatTokenBalance(props.balanceData)}</Text>
215
+ ) : tokenBalanceQuery.data ? (
133
216
  <Text size="xs"> {formatTokenBalance(tokenBalanceQuery.data)}</Text>
134
217
  ) : (
135
218
  <Skeleton height={fontSize.xs} width="100px" />
@@ -42,7 +42,10 @@ export function useResolvedMediaType(
42
42
  });
43
43
 
44
44
  return {
45
- mediaInfo: { url: resolvedUrl, mimeType: resolvedMimeType.data },
45
+ mediaInfo: {
46
+ url: resolvedUrl,
47
+ mimeType: resolvedMimeType.data || "image/", // default to image if no mime type is found
48
+ },
46
49
  isFetched: resolvedMimeType.isFetched || !!mimeType,
47
50
  };
48
51
  }
@@ -72,9 +72,9 @@ export async function fetchRpc(
72
72
  });
73
73
 
74
74
  if (!response.ok) {
75
- response.body?.cancel();
75
+ const error = await response.text().catch(() => null);
76
76
  throw new Error(
77
- `RPC request failed with status ${response.status} - ${response.statusText}`,
77
+ `RPC request failed with status ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
78
78
  );
79
79
  }
80
80
 
@@ -116,8 +116,10 @@ export async function fetchSingleRpc(
116
116
  });
117
117
 
118
118
  if (!response.ok) {
119
- response.body?.cancel();
120
- throw new Error(`RPC request failed with status ${response.status}`);
119
+ const error = await response.text().catch(() => null);
120
+ throw new Error(
121
+ `RPC request failed with status ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
122
+ );
121
123
  }
122
124
  if (response.headers.get("Content-Type")?.startsWith("application/json")) {
123
125
  return await response.json();
@@ -139,7 +139,6 @@ export async function relayBiconomyTransaction(
139
139
  },
140
140
  );
141
141
  if (!response.ok) {
142
- response.body?.cancel();
143
142
  throw new Error(`Failed to send transaction: ${await response.text()}`);
144
143
  }
145
144
  const json = await response.json();
@@ -157,7 +157,6 @@ export async function relayOpenZeppelinTransaction(
157
157
  });
158
158
 
159
159
  if (!response.ok) {
160
- response.body?.cancel();
161
160
  throw new Error(`Failed to send transaction: ${await response.text()}`);
162
161
  }
163
162
  const json = await response.json();
@@ -1,9 +1,8 @@
1
1
  import type { Chain } from "../chains/types.js";
2
2
  import type { ThirdwebClient } from "../client/client.js";
3
+ import { getTransactions } from "../insight/get-transactions.js";
3
4
  import { type Store, createStore } from "../reactive/store.js";
4
- import { getThirdwebDomains } from "../utils/domains.js";
5
5
  import type { Hex } from "../utils/encoding/hex.js";
6
- import { getClientFetch } from "../utils/fetch.js";
7
6
 
8
7
  export type StoredTransaction = {
9
8
  transactionHash: Hex;
@@ -76,26 +75,16 @@ export async function getPastTransactions(options: {
76
75
  const oneMonthsAgoInSeconds = Math.floor(
77
76
  (Date.now() - 1 * 30 * 24 * 60 * 60 * 1000) / 1000,
78
77
  );
79
- const url = new URL(
80
- `https://${getThirdwebDomains().insight}/v1/wallets/${walletAddress}/transactions`,
81
- );
82
- url.searchParams.set("limit", "10");
83
- url.searchParams.set("chain", chain.id.toString());
84
- url.searchParams.set(
85
- "filter_block_timestamp_gte",
86
- oneMonthsAgoInSeconds.toString(),
87
- );
88
- const clientFetch = getClientFetch(client);
89
- const result = await clientFetch(url.toString());
90
- const json = (await result.json()) as {
91
- data: {
92
- chain_id: number;
93
- hash: string;
94
- status: number;
95
- to_address: string;
96
- }[];
97
- };
98
- return json.data.map((tx) => ({
78
+ const result = await getTransactions({
79
+ client,
80
+ walletAddress,
81
+ chains: [chain],
82
+ queryOptions: {
83
+ filter_block_timestamp_gte: oneMonthsAgoInSeconds,
84
+ limit: 20,
85
+ },
86
+ });
87
+ return result.map((tx) => ({
99
88
  transactionHash: tx.hash as Hex,
100
89
  chainId: tx.chain_id,
101
90
  receipt: {
@@ -20,16 +20,17 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
20
20
  * @internal
21
21
  */
22
22
  async function fetchWithHeaders(
23
- url: string,
23
+ url: string | Request,
24
24
  init?: Omit<RequestInit, "signal"> & { requestTimeoutMs?: number },
25
25
  ): Promise<Response> {
26
26
  const { requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT, ...restInit } =
27
27
  init || {};
28
28
 
29
29
  let headers = restInit.headers ? new Headers(restInit.headers) : undefined;
30
+ const urlString = typeof url === "string" ? url : url.url;
30
31
 
31
32
  // check if we are making a request to a thirdweb service (we don't want to send any headers to non-thirdweb services)
32
- if (isThirdwebUrl(url)) {
33
+ if (isThirdwebUrl(urlString)) {
33
34
  if (!headers) {
34
35
  headers = new Headers();
35
36
  }
@@ -49,9 +50,9 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
49
50
  // pay urls should never send the auth token, because we always want the "developer" to be the one making the request, not the "end user"
50
51
  if (
51
52
  authToken &&
52
- !isPayUrl(url) &&
53
- !isInAppWalletUrl(url) &&
54
- !isBundlerUrl(url)
53
+ !isPayUrl(urlString) &&
54
+ !isInAppWalletUrl(urlString) &&
55
+ !isBundlerUrl(urlString)
55
56
  ) {
56
57
  headers.set("authorization", `Bearer ${authToken}`);
57
58
  } else if (secretKey) {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.94.2";
1
+ export const version = "5.95.0-nightly-64bd603301b3067b6a69a29f66a28dee7ffa38f5-20250416000349";