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.
- package/dist/cjs/chains/utils.js +41 -0
- package/dist/cjs/chains/utils.js.map +1 -1
- package/dist/cjs/event/actions/get-events.js +65 -11
- package/dist/cjs/event/actions/get-events.js.map +1 -1
- package/dist/cjs/exports/insight.js +5 -0
- package/dist/cjs/exports/insight.js.map +1 -0
- package/dist/cjs/exports/thirdweb.js +6 -2
- package/dist/cjs/exports/thirdweb.js.map +1 -1
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js +104 -0
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js.map +1 -0
- package/dist/cjs/extensions/thirdweb/write/publish.js +9 -4
- package/dist/cjs/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/cjs/insight/get-events.js +54 -0
- package/dist/cjs/insight/get-events.js.map +1 -0
- package/dist/cjs/insight/get-nfts.js +45 -0
- package/dist/cjs/insight/get-nfts.js.map +1 -0
- package/dist/cjs/insight/get-tokens.js +46 -0
- package/dist/cjs/insight/get-tokens.js.map +1 -0
- package/dist/cjs/insight/get-transactions.js +45 -0
- package/dist/cjs/insight/get-transactions.js.map +1 -0
- package/dist/cjs/insight/index.js +12 -0
- package/dist/cjs/insight/index.js.map +1 -0
- package/dist/cjs/pay/buyWithCrypto/getHistory.js +2 -2
- package/dist/cjs/pay/buyWithCrypto/getHistory.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getStatus.js +2 -2
- package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getHistory.js +2 -2
- package/dist/cjs/pay/buyWithFiat/getHistory.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getStatus.js +2 -2
- package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/cjs/pay/getBuyHistory.js +2 -2
- package/dist/cjs/pay/getBuyHistory.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +4 -14
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +6 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SendFunds.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SendFunds.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewNFTs.js +74 -32
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js +46 -6
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
- package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js +4 -1
- package/dist/cjs/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
- package/dist/cjs/rpc/fetch-rpc.js +4 -4
- package/dist/cjs/rpc/fetch-rpc.js.map +1 -1
- package/dist/cjs/transaction/actions/gasless/providers/biconomy.js +0 -1
- package/dist/cjs/transaction/actions/gasless/providers/biconomy.js.map +1 -1
- package/dist/cjs/transaction/actions/gasless/providers/openzeppelin.js +0 -1
- package/dist/cjs/transaction/actions/gasless/providers/openzeppelin.js.map +1 -1
- package/dist/cjs/transaction/transaction-store.js +11 -10
- package/dist/cjs/transaction/transaction-store.js.map +1 -1
- package/dist/cjs/utils/fetch.js +5 -4
- package/dist/cjs/utils/fetch.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/chains/utils.js +40 -0
- package/dist/esm/chains/utils.js.map +1 -1
- package/dist/esm/event/actions/get-events.js +62 -8
- package/dist/esm/event/actions/get-events.js.map +1 -1
- package/dist/esm/exports/insight.js +2 -0
- package/dist/esm/exports/insight.js.map +1 -0
- package/dist/esm/exports/thirdweb.js +4 -0
- package/dist/esm/exports/thirdweb.js.map +1 -1
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js +98 -0
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js.map +1 -0
- package/dist/esm/extensions/thirdweb/write/publish.js +9 -4
- package/dist/esm/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/esm/insight/get-events.js +51 -0
- package/dist/esm/insight/get-events.js.map +1 -0
- package/dist/esm/insight/get-nfts.js +42 -0
- package/dist/esm/insight/get-nfts.js.map +1 -0
- package/dist/esm/insight/get-tokens.js +43 -0
- package/dist/esm/insight/get-tokens.js.map +1 -0
- package/dist/esm/insight/get-transactions.js +42 -0
- package/dist/esm/insight/get-transactions.js.map +1 -0
- package/dist/esm/insight/index.js +5 -0
- package/dist/esm/insight/index.js.map +1 -0
- package/dist/esm/pay/buyWithCrypto/getHistory.js +2 -2
- package/dist/esm/pay/buyWithCrypto/getHistory.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getStatus.js +2 -2
- package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getHistory.js +2 -2
- package/dist/esm/pay/buyWithFiat/getHistory.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getStatus.js +2 -2
- package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/esm/pay/getBuyHistory.js +2 -2
- package/dist/esm/pay/getBuyHistory.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +4 -14
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +6 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/SendFunds.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/SendFunds.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewNFTs.js +75 -33
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js +46 -6
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
- package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js +4 -1
- package/dist/esm/react/web/ui/MediaRenderer/useResolvedMediaType.js.map +1 -1
- package/dist/esm/rpc/fetch-rpc.js +4 -4
- package/dist/esm/rpc/fetch-rpc.js.map +1 -1
- package/dist/esm/transaction/actions/gasless/providers/biconomy.js +0 -1
- package/dist/esm/transaction/actions/gasless/providers/biconomy.js.map +1 -1
- package/dist/esm/transaction/actions/gasless/providers/openzeppelin.js +0 -1
- package/dist/esm/transaction/actions/gasless/providers/openzeppelin.js.map +1 -1
- package/dist/esm/transaction/transaction-store.js +11 -10
- package/dist/esm/transaction/transaction-store.js.map +1 -1
- package/dist/esm/utils/fetch.js +5 -4
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/chains/types.d.ts +7 -0
- package/dist/types/chains/types.d.ts.map +1 -1
- package/dist/types/chains/utils.d.ts +15 -1
- package/dist/types/chains/utils.d.ts.map +1 -1
- package/dist/types/event/actions/get-events.d.ts +1 -6
- package/dist/types/event/actions/get-events.d.ts.map +1 -1
- package/dist/types/exports/insight.d.ts +2 -0
- package/dist/types/exports/insight.d.ts.map +1 -0
- package/dist/types/exports/thirdweb.d.ts +4 -0
- package/dist/types/exports/thirdweb.d.ts.map +1 -1
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.d.ts +64 -0
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.d.ts.map +1 -0
- package/dist/types/extensions/thirdweb/write/publish.d.ts.map +1 -1
- package/dist/types/insight/get-events.d.ts +31 -0
- package/dist/types/insight/get-events.d.ts.map +1 -0
- package/dist/types/insight/get-nfts.d.ts +25 -0
- package/dist/types/insight/get-nfts.d.ts.map +1 -0
- package/dist/types/insight/get-tokens.d.ts +25 -0
- package/dist/types/insight/get-tokens.d.ts.map +1 -0
- package/dist/types/insight/get-transactions.d.ts +25 -0
- package/dist/types/insight/get-transactions.d.ts.map +1 -0
- package/dist/types/insight/index.d.ts +5 -0
- package/dist/types/insight/index.d.ts.map +1 -0
- package/dist/types/pay/buyWithCrypto/getHistory.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getHistory.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
- package/dist/types/pay/getBuyHistory.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/SendFunds.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/ViewNFTs.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/ViewTokens.d.ts.map +1 -1
- package/dist/types/react/web/ui/MediaRenderer/useResolvedMediaType.d.ts +1 -1
- package/dist/types/react/web/ui/MediaRenderer/useResolvedMediaType.d.ts.map +1 -1
- package/dist/types/rpc/fetch-rpc.d.ts.map +1 -1
- package/dist/types/transaction/actions/gasless/providers/biconomy.d.ts.map +1 -1
- package/dist/types/transaction/actions/gasless/providers/openzeppelin.d.ts.map +1 -1
- package/dist/types/transaction/transaction-store.d.ts.map +1 -1
- package/dist/types/utils/fetch.d.ts +1 -1
- package/dist/types/utils/fetch.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/chains/types.ts +8 -0
- package/src/chains/utils.ts +61 -0
- package/src/event/actions/get-events.test.ts +96 -0
- package/src/event/actions/get-events.ts +99 -12
- package/src/exports/insight.ts +1 -0
- package/src/exports/thirdweb.ts +5 -0
- package/src/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.ts +104 -0
- package/src/extensions/thirdweb/write/publish.ts +12 -4
- package/src/insight/get-events.ts +78 -0
- package/src/insight/get-nfts.ts +65 -0
- package/src/insight/get-tokens.ts +66 -0
- package/src/insight/get-transactions.ts +66 -0
- package/src/insight/index.ts +4 -0
- package/src/pay/buyWithCrypto/getHistory.ts +4 -2
- package/src/pay/buyWithCrypto/getStatus.ts +4 -2
- package/src/pay/buyWithFiat/getHistory.ts +4 -2
- package/src/pay/buyWithFiat/getStatus.ts +4 -2
- package/src/pay/getBuyHistory.ts +4 -2
- package/src/react/web/ui/ConnectWallet/Details.tsx +15 -33
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +10 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +2 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +5 -1
- package/src/react/web/ui/ConnectWallet/screens/SendFunds.tsx +5 -1
- package/src/react/web/ui/ConnectWallet/screens/ViewAssets.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx +107 -55
- package/src/react/web/ui/ConnectWallet/screens/ViewTokens.tsx +94 -11
- package/src/react/web/ui/MediaRenderer/useResolvedMediaType.ts +4 -1
- package/src/rpc/fetch-rpc.ts +6 -4
- package/src/transaction/actions/gasless/providers/biconomy.ts +0 -1
- package/src/transaction/actions/gasless/providers/openzeppelin.ts +0 -1
- package/src/transaction/transaction-store.ts +11 -22
- package/src/utils/fetch.ts +6 -5
- 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.
|
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
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
{
|
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: {
|
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
|
}
|
package/src/rpc/fetch-rpc.ts
CHANGED
@@ -72,9 +72,9 @@ export async function fetchRpc(
|
|
72
72
|
});
|
73
73
|
|
74
74
|
if (!response.ok) {
|
75
|
-
response.
|
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.
|
120
|
-
throw new Error(
|
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();
|
@@ -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
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
);
|
88
|
-
|
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: {
|
package/src/utils/fetch.ts
CHANGED
@@ -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(
|
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(
|
53
|
-
!isInAppWalletUrl(
|
54
|
-
!isBundlerUrl(
|
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.
|
1
|
+
export const version = "5.95.0-nightly-64bd603301b3067b6a69a29f66a28dee7ffa38f5-20250416000349";
|