thirdweb 5.95.0-nightly-4c1f384a635054a8cfaaa487e3ba7ada63b221ec-20250415110008 → 5.95.0-nightly-e7b01108037ebef07fba95f888be1905c8fab5df-20250417000348
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 -2
- package/dist/cjs/chains/utils.js.map +1 -1
- package/dist/cjs/event/actions/get-events.js +56 -8
- package/dist/cjs/event/actions/get-events.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFT.js +2 -0
- package/dist/cjs/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/cjs/extensions/erc20/read/getBalance.js +2 -0
- package/dist/cjs/extensions/erc20/read/getBalance.js.map +1 -1
- package/dist/cjs/extensions/erc721/read/getNFT.js +42 -0
- package/dist/cjs/extensions/erc721/read/getNFT.js.map +1 -1
- package/dist/cjs/extensions/erc721/read/getNFTs.js +44 -17
- package/dist/cjs/extensions/erc721/read/getNFTs.js.map +1 -1
- package/dist/cjs/extensions/erc721/read/getOwnedNFTs.js +46 -0
- package/dist/cjs/extensions/erc721/read/getOwnedNFTs.js.map +1 -1
- package/dist/cjs/extensions/marketplace/direct-listings/utils.js +7 -4
- package/dist/cjs/extensions/marketplace/direct-listings/utils.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/utils.js +9 -4
- package/dist/cjs/extensions/marketplace/english-auctions/utils.js.map +1 -1
- package/dist/cjs/extensions/marketplace/offers/utils.js +7 -4
- package/dist/cjs/extensions/marketplace/offers/utils.js.map +1 -1
- package/dist/cjs/insight/common.js +18 -0
- package/dist/cjs/insight/common.js.map +1 -0
- package/dist/cjs/insight/get-events.js +57 -0
- package/dist/cjs/insight/get-events.js.map +1 -0
- package/dist/cjs/insight/get-nfts.js +159 -17
- package/dist/cjs/insight/get-nfts.js.map +1 -1
- package/dist/cjs/insight/get-tokens.js +35 -15
- package/dist/cjs/insight/get-tokens.js.map +1 -1
- package/dist/cjs/insight/get-transactions.js +17 -11
- package/dist/cjs/insight/get-transactions.js.map +1 -1
- package/dist/cjs/insight/index.js +5 -1
- package/dist/cjs/insight/index.js.map +1 -1
- 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/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/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/ViewNFTs.js +6 -43
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js +3 -9
- package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
- package/dist/cjs/react/web/ui/components/TokenIcon.js +3 -1
- package/dist/cjs/react/web/ui/components/TokenIcon.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/utils.js +7 -2
- package/dist/cjs/react/web/ui/prebuilt/NFT/utils.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/social/profiles.js +3 -8
- package/dist/cjs/social/profiles.js.map +1 -1
- package/dist/cjs/storage/download.js +2 -2
- package/dist/cjs/storage/download.js.map +1 -1
- package/dist/cjs/storage/unpin.js +2 -2
- package/dist/cjs/storage/unpin.js.map +1 -1
- package/dist/cjs/storage/upload/web-node.js +0 -1
- package/dist/cjs/storage/upload/web-node.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/utils/nft/parseNft.js +4 -0
- package/dist/cjs/utils/nft/parseNft.js.map +1 -1
- package/dist/cjs/utils/signatures/resolve-signature.js +0 -2
- package/dist/cjs/utils/signatures/resolve-signature.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/smart/lib/calls.js +2 -2
- package/dist/cjs/wallets/smart/lib/calls.js.map +1 -1
- package/dist/cjs/wallets/utils/getWalletBalance.js +3 -0
- package/dist/cjs/wallets/utils/getWalletBalance.js.map +1 -1
- package/dist/esm/chains/utils.js +40 -2
- package/dist/esm/chains/utils.js.map +1 -1
- package/dist/esm/event/actions/get-events.js +56 -8
- package/dist/esm/event/actions/get-events.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFT.js +2 -0
- package/dist/esm/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/esm/extensions/erc20/read/getBalance.js +2 -0
- package/dist/esm/extensions/erc20/read/getBalance.js.map +1 -1
- package/dist/esm/extensions/erc721/read/getNFT.js +42 -0
- package/dist/esm/extensions/erc721/read/getNFT.js.map +1 -1
- package/dist/esm/extensions/erc721/read/getNFTs.js +44 -17
- package/dist/esm/extensions/erc721/read/getNFTs.js.map +1 -1
- package/dist/esm/extensions/erc721/read/getOwnedNFTs.js +46 -0
- package/dist/esm/extensions/erc721/read/getOwnedNFTs.js.map +1 -1
- package/dist/esm/extensions/marketplace/direct-listings/utils.js +7 -4
- package/dist/esm/extensions/marketplace/direct-listings/utils.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/utils.js +9 -4
- package/dist/esm/extensions/marketplace/english-auctions/utils.js.map +1 -1
- package/dist/esm/extensions/marketplace/offers/utils.js +7 -4
- package/dist/esm/extensions/marketplace/offers/utils.js.map +1 -1
- package/dist/esm/insight/common.js +15 -0
- package/dist/esm/insight/common.js.map +1 -0
- package/dist/esm/insight/get-events.js +54 -0
- package/dist/esm/insight/get-events.js.map +1 -0
- package/dist/esm/insight/get-nfts.js +155 -15
- package/dist/esm/insight/get-nfts.js.map +1 -1
- package/dist/esm/insight/get-tokens.js +32 -12
- package/dist/esm/insight/get-tokens.js.map +1 -1
- package/dist/esm/insight/get-transactions.js +14 -8
- package/dist/esm/insight/get-transactions.js.map +1 -1
- package/dist/esm/insight/index.js +2 -1
- package/dist/esm/insight/index.js.map +1 -1
- 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/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/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/ViewNFTs.js +6 -43
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewNFTs.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js +3 -9
- package/dist/esm/react/web/ui/ConnectWallet/screens/ViewTokens.js.map +1 -1
- package/dist/esm/react/web/ui/components/TokenIcon.js +3 -1
- package/dist/esm/react/web/ui/components/TokenIcon.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/utils.js +7 -2
- package/dist/esm/react/web/ui/prebuilt/NFT/utils.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/social/profiles.js +3 -8
- package/dist/esm/social/profiles.js.map +1 -1
- package/dist/esm/storage/download.js +2 -2
- package/dist/esm/storage/download.js.map +1 -1
- package/dist/esm/storage/unpin.js +2 -2
- package/dist/esm/storage/unpin.js.map +1 -1
- package/dist/esm/storage/upload/web-node.js +0 -1
- package/dist/esm/storage/upload/web-node.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/utils/nft/parseNft.js +4 -0
- package/dist/esm/utils/nft/parseNft.js.map +1 -1
- package/dist/esm/utils/signatures/resolve-signature.js +0 -2
- package/dist/esm/utils/signatures/resolve-signature.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/smart/lib/calls.js +2 -2
- package/dist/esm/wallets/smart/lib/calls.js.map +1 -1
- package/dist/esm/wallets/utils/getWalletBalance.js +3 -0
- package/dist/esm/wallets/utils/getWalletBalance.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/extensions/erc1155/read/getNFT.d.ts.map +1 -1
- package/dist/types/extensions/erc20/read/getBalance.d.ts +2 -0
- package/dist/types/extensions/erc20/read/getBalance.d.ts.map +1 -1
- package/dist/types/extensions/erc721/read/getNFT.d.ts +5 -0
- package/dist/types/extensions/erc721/read/getNFT.d.ts.map +1 -1
- package/dist/types/extensions/erc721/read/getNFTs.d.ts +5 -0
- package/dist/types/extensions/erc721/read/getNFTs.d.ts.map +1 -1
- package/dist/types/extensions/erc721/read/getOwnedNFTs.d.ts +3 -1
- package/dist/types/extensions/erc721/read/getOwnedNFTs.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/direct-listings/utils.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/utils.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/offers/utils.d.ts.map +1 -1
- package/dist/types/insight/common.d.ts +3 -0
- package/dist/types/insight/common.d.ts.map +1 -0
- 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 +52 -4
- package/dist/types/insight/get-nfts.d.ts.map +1 -1
- package/dist/types/insight/get-tokens.d.ts +4 -4
- package/dist/types/insight/get-tokens.d.ts.map +1 -1
- package/dist/types/insight/get-transactions.d.ts +2 -2
- package/dist/types/insight/get-transactions.d.ts.map +1 -1
- package/dist/types/insight/index.d.ts +3 -2
- package/dist/types/insight/index.d.ts.map +1 -1
- 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/core/utils/wallet.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +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/components/TokenIcon.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/utils.d.ts.map +1 -1
- package/dist/types/rpc/fetch-rpc.d.ts.map +1 -1
- package/dist/types/social/profiles.d.ts.map +1 -1
- package/dist/types/storage/download.d.ts.map +1 -1
- package/dist/types/storage/unpin.d.ts.map +1 -1
- package/dist/types/storage/upload/web-node.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/utils/nft/parseNft.d.ts +8 -0
- package/dist/types/utils/nft/parseNft.d.ts.map +1 -1
- package/dist/types/utils/signatures/resolve-signature.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/utils/getWalletBalance.d.ts +2 -7
- package/dist/types/wallets/utils/getWalletBalance.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/chains/types.ts +8 -0
- package/src/chains/utils.ts +65 -2
- package/src/event/actions/get-events.test.ts +96 -0
- package/src/event/actions/get-events.ts +87 -12
- package/src/extensions/erc1155/read/getNFT.test.ts +2 -0
- package/src/extensions/erc1155/read/getNFT.ts +2 -0
- package/src/extensions/erc20/drop20.test.ts +48 -132
- package/src/extensions/erc20/read/getBalance.test.ts +5 -9
- package/src/extensions/erc20/read/getBalance.ts +4 -0
- package/src/extensions/erc721/read/getNFT.test.ts +108 -0
- package/src/extensions/erc721/read/getNFT.ts +55 -1
- package/src/extensions/erc721/read/getNFTs.test.ts +219 -13
- package/src/extensions/erc721/read/getNFTs.ts +59 -20
- package/src/extensions/erc721/read/getOwnedNFTs.test.ts +27 -2
- package/src/extensions/erc721/read/getOwnedNFTs.ts +61 -1
- package/src/extensions/erc721/token721.test.ts +2 -0
- package/src/extensions/marketplace/direct-listings/direct-listings.test.ts +2 -18
- package/src/extensions/marketplace/direct-listings/utils.ts +7 -4
- package/src/extensions/marketplace/english-auctions/utils.ts +9 -4
- package/src/extensions/marketplace/offers/utils.ts +7 -4
- package/src/insight/common.ts +24 -0
- package/src/insight/get-events.ts +92 -0
- package/src/insight/get-nfts.ts +256 -22
- package/src/insight/get-tokens.ts +57 -26
- package/src/insight/get-transactions.ts +30 -20
- package/src/insight/index.ts +7 -2
- 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/screens/Buy/swap/ConfirmationScreen.tsx +10 -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/ViewNFTs.tsx +43 -68
- package/src/react/web/ui/ConnectWallet/screens/ViewTokens.tsx +4 -14
- package/src/react/web/ui/components/TokenIcon.tsx +12 -3
- package/src/react/web/ui/prebuilt/NFT/utils.test.ts +2 -64
- package/src/react/web/ui/prebuilt/NFT/utils.ts +7 -2
- package/src/rpc/fetch-rpc.ts +6 -4
- package/src/social/profiles.ts +5 -9
- package/src/storage/download.ts +4 -2
- package/src/storage/unpin.ts +4 -2
- package/src/storage/upload/web-node.ts +0 -1
- package/src/transaction/actions/gasless/providers/biconomy.ts +0 -1
- package/src/transaction/actions/gasless/providers/openzeppelin.ts +0 -1
- package/src/utils/nft/parseNft.test.ts +8 -0
- package/src/utils/nft/parseNft.ts +12 -0
- package/src/utils/signatures/resolve-signature.ts +0 -2
- package/src/version.ts +1 -1
- package/src/wallets/smart/lib/calls.ts +2 -2
- package/src/wallets/utils/getWalletBalance.ts +5 -7
@@ -26,12 +26,13 @@ export async function mapDirectListing(
|
|
26
26
|
endTimestamp: rawListing.endTimestamp,
|
27
27
|
});
|
28
28
|
|
29
|
+
const currencyContract = getContract({
|
30
|
+
...options.contract,
|
31
|
+
address: rawListing.currency,
|
32
|
+
});
|
29
33
|
const [currencyValuePerToken, nftAsset] = await Promise.all([
|
30
34
|
getCurrencyMetadata({
|
31
|
-
contract:
|
32
|
-
...options.contract,
|
33
|
-
address: rawListing.currency,
|
34
|
-
}),
|
35
|
+
contract: currencyContract,
|
35
36
|
}),
|
36
37
|
getNFTAsset({
|
37
38
|
...options,
|
@@ -57,6 +58,8 @@ export async function mapDirectListing(
|
|
57
58
|
rawListing.pricePerToken,
|
58
59
|
currencyValuePerToken.decimals,
|
59
60
|
),
|
61
|
+
tokenAddress: currencyContract.address,
|
62
|
+
chainId: currencyContract.chain.id,
|
60
63
|
},
|
61
64
|
pricePerToken: rawListing.pricePerToken,
|
62
65
|
asset: nftAsset,
|
@@ -24,12 +24,13 @@ export async function mapEnglishAuction(
|
|
24
24
|
endTimestamp: rawAuction.endTimestamp,
|
25
25
|
});
|
26
26
|
|
27
|
+
const currencyContract = getContract({
|
28
|
+
...options.contract,
|
29
|
+
address: rawAuction.currency,
|
30
|
+
});
|
27
31
|
const [auctionCurrencyMetadata, nftAsset] = await Promise.all([
|
28
32
|
getCurrencyMetadata({
|
29
|
-
contract:
|
30
|
-
...options.contract,
|
31
|
-
address: rawAuction.currency,
|
32
|
-
}),
|
33
|
+
contract: currencyContract,
|
33
34
|
}),
|
34
35
|
getNFTAsset({
|
35
36
|
...options,
|
@@ -60,6 +61,8 @@ export async function mapEnglishAuction(
|
|
60
61
|
rawAuction.minimumBidAmount,
|
61
62
|
auctionCurrencyMetadata.decimals,
|
62
63
|
),
|
64
|
+
tokenAddress: currencyContract.address,
|
65
|
+
chainId: currencyContract.chain.id,
|
63
66
|
},
|
64
67
|
buyoutBidAmount: rawAuction.buyoutBidAmount,
|
65
68
|
buyoutCurrencyValue: {
|
@@ -69,6 +72,8 @@ export async function mapEnglishAuction(
|
|
69
72
|
rawAuction.buyoutBidAmount,
|
70
73
|
auctionCurrencyMetadata.decimals,
|
71
74
|
),
|
75
|
+
tokenAddress: currencyContract.address,
|
76
|
+
chainId: currencyContract.chain.id,
|
72
77
|
},
|
73
78
|
timeBufferInSeconds: rawAuction.timeBufferInSeconds,
|
74
79
|
bidBufferBps: rawAuction.bidBufferBps,
|
@@ -25,12 +25,13 @@ export async function mapOffer(
|
|
25
25
|
endTimestamp: rawOffer.expirationTimestamp,
|
26
26
|
});
|
27
27
|
|
28
|
+
const currencyContract = getContract({
|
29
|
+
...options.contract,
|
30
|
+
address: rawOffer.currency,
|
31
|
+
});
|
28
32
|
const [currencyValuePerToken, nftAsset] = await Promise.all([
|
29
33
|
getCurrencyMetadata({
|
30
|
-
contract:
|
31
|
-
...options.contract,
|
32
|
-
address: rawOffer.currency,
|
33
|
-
}),
|
34
|
+
contract: currencyContract,
|
34
35
|
}),
|
35
36
|
getNFTAsset({
|
36
37
|
...options,
|
@@ -56,6 +57,8 @@ export async function mapOffer(
|
|
56
57
|
rawOffer.totalPrice,
|
57
58
|
currencyValuePerToken.decimals,
|
58
59
|
),
|
60
|
+
tokenAddress: currencyContract.address,
|
61
|
+
chainId: currencyContract.chain.id,
|
59
62
|
},
|
60
63
|
totalPrice: rawOffer.totalPrice,
|
61
64
|
asset: nftAsset,
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { Chain } from "../chains/types.js";
|
2
|
+
import { getChainServices } from "../chains/utils.js";
|
3
|
+
|
4
|
+
export async function assertInsightEnabled(chains: Chain[]) {
|
5
|
+
const chainData = await Promise.all(
|
6
|
+
chains.map((chain) =>
|
7
|
+
getChainServices(chain).then((services) => ({
|
8
|
+
chain,
|
9
|
+
enabled: services.some((c) => c.service === "insight" && c.enabled),
|
10
|
+
})),
|
11
|
+
),
|
12
|
+
);
|
13
|
+
|
14
|
+
const insightEnabled = chainData.every((c) => c.enabled);
|
15
|
+
|
16
|
+
if (!insightEnabled) {
|
17
|
+
throw new Error(
|
18
|
+
`Insight is not available for chains ${chainData
|
19
|
+
.filter((c) => !c.enabled)
|
20
|
+
.map((c) => c.chain.id)
|
21
|
+
.join(", ")}`,
|
22
|
+
);
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import type {
|
2
|
+
GetV1EventsByContractAddressData,
|
3
|
+
GetV1EventsByContractAddressResponse,
|
4
|
+
} from "@thirdweb-dev/insight";
|
5
|
+
import type { AbiEvent } from "ox/AbiEvent";
|
6
|
+
import type { Chain } from "../chains/types.js";
|
7
|
+
import type { ThirdwebClient } from "../client/client.js";
|
8
|
+
import type { PreparedEvent } from "../event/prepare-event.js";
|
9
|
+
|
10
|
+
export type ContractEvent = NonNullable<
|
11
|
+
GetV1EventsByContractAddressResponse["data"]
|
12
|
+
>[number];
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Get contract events
|
16
|
+
* @example
|
17
|
+
* ```ts
|
18
|
+
* import { Insight } from "thirdweb";
|
19
|
+
*
|
20
|
+
* const events = await Insight.getContractEvents({
|
21
|
+
* client,
|
22
|
+
* chains: [sepolia],
|
23
|
+
* contractAddress: "0x1234567890123456789012345678901234567890",
|
24
|
+
* event: transferEvent(),
|
25
|
+
* decodeLogs: true,
|
26
|
+
* });
|
27
|
+
* ```
|
28
|
+
* @insight
|
29
|
+
*/
|
30
|
+
export async function getContractEvents(options: {
|
31
|
+
client: ThirdwebClient;
|
32
|
+
chains: Chain[];
|
33
|
+
contractAddress: string;
|
34
|
+
event?: PreparedEvent<AbiEvent>;
|
35
|
+
decodeLogs?: boolean;
|
36
|
+
queryOptions?: Omit<
|
37
|
+
GetV1EventsByContractAddressData["query"],
|
38
|
+
"chain" | "decode"
|
39
|
+
>;
|
40
|
+
}): Promise<ContractEvent[]> {
|
41
|
+
const [
|
42
|
+
{ getV1EventsByContractAddress },
|
43
|
+
{ getThirdwebDomains },
|
44
|
+
{ getClientFetch },
|
45
|
+
{ assertInsightEnabled },
|
46
|
+
{ stringify },
|
47
|
+
] = await Promise.all([
|
48
|
+
import("@thirdweb-dev/insight"),
|
49
|
+
import("../utils/domains.js"),
|
50
|
+
import("../utils/fetch.js"),
|
51
|
+
import("./common.js"),
|
52
|
+
import("../utils/json.js"),
|
53
|
+
]);
|
54
|
+
|
55
|
+
const { client, chains, contractAddress, event, queryOptions, decodeLogs } =
|
56
|
+
options;
|
57
|
+
|
58
|
+
await assertInsightEnabled(chains);
|
59
|
+
|
60
|
+
const defaultQueryOptions: GetV1EventsByContractAddressData["query"] = {
|
61
|
+
chain: chains.map((chain) => chain.id),
|
62
|
+
limit: 100,
|
63
|
+
decode: decodeLogs,
|
64
|
+
};
|
65
|
+
|
66
|
+
if (event) {
|
67
|
+
defaultQueryOptions.filter_topic_0 = event.topics[0];
|
68
|
+
defaultQueryOptions.filter_topic_1 = event.topics[1];
|
69
|
+
defaultQueryOptions.filter_topic_2 = event.topics[2];
|
70
|
+
defaultQueryOptions.filter_topic_3 = event.topics[3];
|
71
|
+
}
|
72
|
+
|
73
|
+
const result = await getV1EventsByContractAddress({
|
74
|
+
baseUrl: `https://${getThirdwebDomains().insight}`,
|
75
|
+
fetch: getClientFetch(client),
|
76
|
+
path: {
|
77
|
+
contractAddress,
|
78
|
+
},
|
79
|
+
query: {
|
80
|
+
...defaultQueryOptions,
|
81
|
+
...queryOptions,
|
82
|
+
},
|
83
|
+
});
|
84
|
+
|
85
|
+
if (result.error) {
|
86
|
+
throw new Error(
|
87
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
88
|
+
);
|
89
|
+
}
|
90
|
+
|
91
|
+
return result.data?.data ?? [];
|
92
|
+
}
|
package/src/insight/get-nfts.ts
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import type {
|
2
|
+
GetV1NftsByContractAddressByTokenIdData,
|
3
|
+
GetV1NftsByContractAddressData,
|
4
|
+
GetV1NftsByContractAddressResponse,
|
5
|
+
GetV1NftsData,
|
6
|
+
GetV1NftsResponse,
|
5
7
|
} from "@thirdweb-dev/insight";
|
6
|
-
import { stringify } from "viem";
|
7
8
|
import type { Chain } from "../chains/types.js";
|
8
9
|
import type { ThirdwebClient } from "../client/client.js";
|
9
|
-
import {
|
10
|
-
import { getClientFetch } from "../utils/fetch.js";
|
10
|
+
import type { NFT } from "../utils/nft/parseNft.js";
|
11
11
|
|
12
|
-
|
12
|
+
type OwnedNFT = GetV1NftsResponse["data"][number];
|
13
|
+
type ContractNFT = GetV1NftsByContractAddressResponse["data"][number];
|
13
14
|
|
14
15
|
/**
|
15
16
|
* Get NFTs owned by an address
|
@@ -29,34 +30,267 @@ export async function getOwnedNFTs(args: {
|
|
29
30
|
client: ThirdwebClient;
|
30
31
|
chains: Chain[];
|
31
32
|
ownerAddress: string;
|
32
|
-
|
33
|
-
|
33
|
+
includeMetadata?: boolean;
|
34
|
+
queryOptions?: Omit<GetV1NftsData["query"], "owner_address" | "chain">;
|
35
|
+
}): Promise<(NFT & { quantityOwned: bigint })[]> {
|
36
|
+
const [
|
37
|
+
{ getV1Nfts },
|
38
|
+
{ getThirdwebDomains },
|
39
|
+
{ getClientFetch },
|
40
|
+
{ assertInsightEnabled },
|
41
|
+
{ stringify },
|
42
|
+
] = await Promise.all([
|
43
|
+
import("@thirdweb-dev/insight"),
|
44
|
+
import("../utils/domains.js"),
|
45
|
+
import("../utils/fetch.js"),
|
46
|
+
import("./common.js"),
|
47
|
+
import("viem"),
|
48
|
+
]);
|
49
|
+
|
50
|
+
// TODO (insight): add support for contract address filters
|
51
|
+
const { client, chains, ownerAddress, queryOptions } = args;
|
52
|
+
|
53
|
+
await assertInsightEnabled(chains);
|
54
|
+
|
55
|
+
const defaultQueryOptions: GetV1NftsData["query"] = {
|
56
|
+
chain: chains.map((chain) => chain.id),
|
57
|
+
// metadata: includeMetadata ? "true" : "false", TODO (insight): add support for this
|
58
|
+
limit: 50,
|
59
|
+
owner_address: ownerAddress,
|
60
|
+
};
|
61
|
+
|
62
|
+
const result = await getV1Nfts({
|
63
|
+
baseUrl: `https://${getThirdwebDomains().insight}`,
|
64
|
+
fetch: getClientFetch(client),
|
65
|
+
query: {
|
66
|
+
...defaultQueryOptions,
|
67
|
+
...queryOptions,
|
68
|
+
},
|
69
|
+
});
|
70
|
+
|
71
|
+
if (result.error) {
|
72
|
+
throw new Error(
|
73
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
74
|
+
);
|
75
|
+
}
|
76
|
+
|
77
|
+
const transformedNfts = await transformNFTModel(
|
78
|
+
result.data?.data ?? [],
|
79
|
+
ownerAddress,
|
80
|
+
);
|
81
|
+
return transformedNfts.map((nft) => ({
|
82
|
+
...nft,
|
83
|
+
quantityOwned: nft.quantityOwned ?? 1n,
|
84
|
+
}));
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Get all NFTs from a contract
|
89
|
+
* @example
|
90
|
+
* ```ts
|
91
|
+
* import { Insight } from "thirdweb";
|
92
|
+
*
|
93
|
+
* const nfts = await Insight.getContractNFTs({
|
94
|
+
* client,
|
95
|
+
* chains: [sepolia],
|
96
|
+
* contractAddress: "0x1234567890123456789012345678901234567890",
|
97
|
+
* });
|
98
|
+
* ```
|
99
|
+
* @insight
|
100
|
+
*/
|
101
|
+
export async function getContractNFTs(args: {
|
102
|
+
client: ThirdwebClient;
|
103
|
+
chains: Chain[];
|
104
|
+
contractAddress: string;
|
105
|
+
includeMetadata?: boolean;
|
106
|
+
includeOwners?: boolean;
|
107
|
+
queryOptions?: Omit<GetV1NftsByContractAddressData["query"], "chain">;
|
108
|
+
}): Promise<NFT[]> {
|
109
|
+
const [
|
110
|
+
{ getV1NftsByContractAddress },
|
111
|
+
{ getThirdwebDomains },
|
112
|
+
{ getClientFetch },
|
113
|
+
{ assertInsightEnabled },
|
114
|
+
{ stringify },
|
115
|
+
] = await Promise.all([
|
116
|
+
import("@thirdweb-dev/insight"),
|
117
|
+
import("../utils/domains.js"),
|
118
|
+
import("../utils/fetch.js"),
|
119
|
+
import("./common.js"),
|
120
|
+
import("../utils/json.js"),
|
121
|
+
]);
|
122
|
+
|
34
123
|
const {
|
35
124
|
client,
|
36
125
|
chains,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
126
|
+
contractAddress,
|
127
|
+
includeOwners = true,
|
128
|
+
queryOptions,
|
129
|
+
} = args;
|
130
|
+
|
131
|
+
const defaultQueryOptions: GetV1NftsByContractAddressData["query"] = {
|
132
|
+
chain: chains.map((chain) => chain.id),
|
133
|
+
// metadata: includeMetadata ? "true" : "false", TODO (insight): add support for this
|
134
|
+
limit: 50,
|
135
|
+
include_owners:
|
136
|
+
includeOwners === true ? ("true" as const) : ("false" as const),
|
137
|
+
};
|
138
|
+
|
139
|
+
await assertInsightEnabled(chains);
|
140
|
+
|
141
|
+
const result = await getV1NftsByContractAddress({
|
142
|
+
baseUrl: `https://${getThirdwebDomains().insight}`,
|
143
|
+
fetch: getClientFetch(client),
|
144
|
+
path: {
|
145
|
+
contract_address: contractAddress,
|
146
|
+
},
|
147
|
+
query: {
|
148
|
+
...defaultQueryOptions,
|
149
|
+
...queryOptions,
|
43
150
|
},
|
151
|
+
});
|
152
|
+
|
153
|
+
if (result.error) {
|
154
|
+
throw new Error(
|
155
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
156
|
+
);
|
157
|
+
}
|
158
|
+
|
159
|
+
return transformNFTModel(result.data?.data ?? []);
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Get NFT metadata by contract address and token id
|
164
|
+
* @example
|
165
|
+
* ```ts
|
166
|
+
* import { Insight } from "thirdweb";
|
167
|
+
*
|
168
|
+
* const nft = await Insight.getNFT({
|
169
|
+
* client,
|
170
|
+
* chain: sepolia,
|
171
|
+
* contractAddress: "0x1234567890123456789012345678901234567890",
|
172
|
+
* tokenId: 1n,
|
173
|
+
* });
|
174
|
+
* ```
|
175
|
+
* @insight
|
176
|
+
*/
|
177
|
+
export async function getNFT(args: {
|
178
|
+
client: ThirdwebClient;
|
179
|
+
chain: Chain;
|
180
|
+
contractAddress: string;
|
181
|
+
tokenId: bigint | number | string;
|
182
|
+
includeOwners?: boolean;
|
183
|
+
queryOptions?: GetV1NftsByContractAddressByTokenIdData["query"];
|
184
|
+
}): Promise<NFT | undefined> {
|
185
|
+
const [
|
186
|
+
{ getV1NftsByContractAddressByTokenId },
|
187
|
+
{ getThirdwebDomains },
|
188
|
+
{ getClientFetch },
|
189
|
+
{ assertInsightEnabled },
|
190
|
+
{ stringify },
|
191
|
+
] = await Promise.all([
|
192
|
+
import("@thirdweb-dev/insight"),
|
193
|
+
import("../utils/domains.js"),
|
194
|
+
import("../utils/fetch.js"),
|
195
|
+
import("./common.js"),
|
196
|
+
import("../utils/json.js"),
|
197
|
+
]);
|
198
|
+
|
199
|
+
const {
|
200
|
+
client,
|
201
|
+
chain,
|
202
|
+
contractAddress,
|
203
|
+
tokenId,
|
204
|
+
includeOwners = true,
|
205
|
+
queryOptions,
|
44
206
|
} = args;
|
45
207
|
|
46
|
-
|
208
|
+
await assertInsightEnabled([chain]);
|
209
|
+
|
210
|
+
const defaultQueryOptions: GetV1NftsByContractAddressByTokenIdData["query"] =
|
211
|
+
{
|
212
|
+
chain: chain.id,
|
213
|
+
include_owners:
|
214
|
+
includeOwners === true ? ("true" as const) : ("false" as const),
|
215
|
+
};
|
216
|
+
|
217
|
+
const result = await getV1NftsByContractAddressByTokenId({
|
47
218
|
baseUrl: `https://${getThirdwebDomains().insight}`,
|
48
219
|
fetch: getClientFetch(client),
|
49
220
|
path: {
|
50
|
-
|
221
|
+
contract_address: contractAddress,
|
222
|
+
token_id: tokenId.toString(),
|
51
223
|
},
|
52
224
|
query: {
|
225
|
+
...defaultQueryOptions,
|
53
226
|
...queryOptions,
|
54
|
-
chain: chains.map((chain) => chain.id),
|
55
227
|
},
|
56
228
|
});
|
57
229
|
|
58
|
-
if (
|
59
|
-
throw new Error(
|
230
|
+
if (result.error) {
|
231
|
+
throw new Error(
|
232
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
233
|
+
);
|
60
234
|
}
|
61
|
-
|
235
|
+
|
236
|
+
const transformedNfts = await transformNFTModel(result.data?.data ?? []);
|
237
|
+
return transformedNfts?.[0];
|
238
|
+
}
|
239
|
+
|
240
|
+
async function transformNFTModel(
|
241
|
+
nfts: (ContractNFT | OwnedNFT)[],
|
242
|
+
ownerAddress?: string,
|
243
|
+
): Promise<(NFT & { quantityOwned?: bigint })[]> {
|
244
|
+
const { parseNFT } = await import("../utils/nft/parseNft.js");
|
245
|
+
|
246
|
+
return nfts.map((nft) => {
|
247
|
+
let parsedNft: NFT;
|
248
|
+
const {
|
249
|
+
contract,
|
250
|
+
extra_metadata,
|
251
|
+
collection,
|
252
|
+
metadata_url,
|
253
|
+
chain_id,
|
254
|
+
token_id,
|
255
|
+
status,
|
256
|
+
balance,
|
257
|
+
token_type,
|
258
|
+
...rest
|
259
|
+
} = nft;
|
260
|
+
const metadata = {
|
261
|
+
uri: nft.metadata_url ?? "",
|
262
|
+
image: nft.image_url,
|
263
|
+
attributes: nft.extra_metadata?.attributes ?? undefined,
|
264
|
+
...rest,
|
265
|
+
};
|
266
|
+
|
267
|
+
const owner_addresses = ownerAddress
|
268
|
+
? [ownerAddress]
|
269
|
+
: "owner_addresses" in nft
|
270
|
+
? nft.owner_addresses
|
271
|
+
: undefined;
|
272
|
+
|
273
|
+
if (contract?.type === "erc1155") {
|
274
|
+
parsedNft = parseNFT(metadata, {
|
275
|
+
tokenId: BigInt(token_id),
|
276
|
+
tokenUri: metadata_url ?? "",
|
277
|
+
type: "ERC1155",
|
278
|
+
owner: owner_addresses?.[0],
|
279
|
+
tokenAddress: contract?.address ?? "",
|
280
|
+
chainId: contract?.chain_id ?? 0,
|
281
|
+
supply: balance ? BigInt(balance) : 0n, // TODO (insight): this is wrong, needs to be added in the API
|
282
|
+
});
|
283
|
+
} else {
|
284
|
+
parsedNft = parseNFT(metadata, {
|
285
|
+
tokenId: BigInt(token_id),
|
286
|
+
type: "ERC721",
|
287
|
+
owner: owner_addresses?.[0],
|
288
|
+
tokenUri: metadata_url ?? "",
|
289
|
+
tokenAddress: contract?.address ?? "",
|
290
|
+
chainId: contract?.chain_id ?? 0,
|
291
|
+
});
|
292
|
+
}
|
293
|
+
|
294
|
+
return parsedNft;
|
295
|
+
});
|
62
296
|
}
|
@@ -1,15 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
getV1TokensErc20ByOwnerAddress,
|
1
|
+
import type {
|
2
|
+
GetV1TokensErc20ByOwnerAddressData,
|
3
|
+
GetV1TokensErc20ByOwnerAddressResponse,
|
5
4
|
} from "@thirdweb-dev/insight";
|
6
|
-
import { stringify } from "viem";
|
7
5
|
import type { Chain } from "../chains/types.js";
|
8
6
|
import type { ThirdwebClient } from "../client/client.js";
|
9
|
-
import {
|
10
|
-
import { getClientFetch } from "../utils/fetch.js";
|
7
|
+
import type { GetWalletBalanceResult } from "../wallets/utils/getWalletBalance.js";
|
11
8
|
|
12
|
-
|
9
|
+
type OwnedToken = GetV1TokensErc20ByOwnerAddressResponse["data"][number];
|
13
10
|
|
14
11
|
/**
|
15
12
|
* Get ERC20 tokens owned by an address
|
@@ -29,20 +26,32 @@ export async function getOwnedTokens(args: {
|
|
29
26
|
client: ThirdwebClient;
|
30
27
|
chains: Chain[];
|
31
28
|
ownerAddress: string;
|
32
|
-
queryOptions?:
|
33
|
-
}): Promise<
|
34
|
-
const
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
29
|
+
queryOptions?: GetV1TokensErc20ByOwnerAddressData["query"];
|
30
|
+
}): Promise<GetWalletBalanceResult[]> {
|
31
|
+
const [
|
32
|
+
{ getV1TokensErc20ByOwnerAddress },
|
33
|
+
{ getThirdwebDomains },
|
34
|
+
{ getClientFetch },
|
35
|
+
{ assertInsightEnabled },
|
36
|
+
{ stringify },
|
37
|
+
] = await Promise.all([
|
38
|
+
import("@thirdweb-dev/insight"),
|
39
|
+
import("../utils/domains.js"),
|
40
|
+
import("../utils/fetch.js"),
|
41
|
+
import("./common.js"),
|
42
|
+
import("../utils/json.js"),
|
43
|
+
]);
|
44
|
+
|
45
|
+
const { client, chains, ownerAddress, queryOptions } = args;
|
46
|
+
|
47
|
+
await assertInsightEnabled(chains);
|
48
|
+
|
49
|
+
const defaultQueryOptions: GetV1TokensErc20ByOwnerAddressData["query"] = {
|
50
|
+
chain: chains.map((chain) => chain.id),
|
51
|
+
include_spam: "false",
|
52
|
+
metadata: "true",
|
53
|
+
limit: 50,
|
54
|
+
};
|
46
55
|
|
47
56
|
const result = await getV1TokensErc20ByOwnerAddress({
|
48
57
|
baseUrl: `https://${getThirdwebDomains().insight}`,
|
@@ -51,13 +60,35 @@ export async function getOwnedTokens(args: {
|
|
51
60
|
ownerAddress: ownerAddress,
|
52
61
|
},
|
53
62
|
query: {
|
63
|
+
...defaultQueryOptions,
|
54
64
|
...queryOptions,
|
55
|
-
chain: chains.map((chain) => chain.id),
|
56
65
|
},
|
57
66
|
});
|
58
67
|
|
59
|
-
if (
|
60
|
-
throw new Error(
|
68
|
+
if (result.error) {
|
69
|
+
throw new Error(
|
70
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
71
|
+
);
|
61
72
|
}
|
62
|
-
|
73
|
+
|
74
|
+
return transformOwnedToken(result.data?.data ?? []);
|
75
|
+
}
|
76
|
+
|
77
|
+
async function transformOwnedToken(
|
78
|
+
token: OwnedToken[],
|
79
|
+
): Promise<GetWalletBalanceResult[]> {
|
80
|
+
const { toTokens } = await import("../utils/units.js");
|
81
|
+
return token.map((t) => {
|
82
|
+
const decimals = t.decimals ?? 18;
|
83
|
+
const value = BigInt(t.balance);
|
84
|
+
return {
|
85
|
+
value,
|
86
|
+
displayValue: toTokens(value, decimals),
|
87
|
+
tokenAddress: t.token_address,
|
88
|
+
chainId: t.chain_id,
|
89
|
+
decimals,
|
90
|
+
symbol: t.symbol ?? "",
|
91
|
+
name: t.name ?? "",
|
92
|
+
};
|
93
|
+
});
|
63
94
|
}
|
@@ -1,12 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
getV1WalletsByWalletAddressTransactions,
|
1
|
+
import type {
|
2
|
+
GetV1WalletsByWalletAddressTransactionsData,
|
3
|
+
GetV1WalletsByWalletAddressTransactionsResponse,
|
5
4
|
} from "@thirdweb-dev/insight";
|
6
5
|
import type { Chain } from "../chains/types.js";
|
7
6
|
import type { ThirdwebClient } from "../client/client.js";
|
8
|
-
import { getThirdwebDomains } from "../utils/domains.js";
|
9
|
-
import { getClientFetch } from "../utils/fetch.js";
|
10
7
|
|
11
8
|
export type Transaction = NonNullable<
|
12
9
|
GetV1WalletsByWalletAddressTransactionsResponse["data"]
|
@@ -30,37 +27,50 @@ export async function getTransactions(args: {
|
|
30
27
|
client: ThirdwebClient;
|
31
28
|
walletAddress: string;
|
32
29
|
chains: Chain[];
|
33
|
-
queryOptions?:
|
34
|
-
GetV1WalletsByWalletAddressTransactionsData["query"],
|
35
|
-
"chain"
|
36
|
-
>;
|
30
|
+
queryOptions?: GetV1WalletsByWalletAddressTransactionsData["query"];
|
37
31
|
}): Promise<Transaction[]> {
|
32
|
+
const [
|
33
|
+
{ getV1WalletsByWalletAddressTransactions },
|
34
|
+
{ getThirdwebDomains },
|
35
|
+
{ getClientFetch },
|
36
|
+
{ assertInsightEnabled },
|
37
|
+
{ stringify },
|
38
|
+
] = await Promise.all([
|
39
|
+
import("@thirdweb-dev/insight"),
|
40
|
+
import("../utils/domains.js"),
|
41
|
+
import("../utils/fetch.js"),
|
42
|
+
import("./common.js"),
|
43
|
+
import("../utils/json.js"),
|
44
|
+
]);
|
45
|
+
|
46
|
+
await assertInsightEnabled(args.chains);
|
38
47
|
const threeMonthsAgoInSeconds = Math.floor(
|
39
48
|
(Date.now() - 3 * 30 * 24 * 60 * 60 * 1000) / 1000,
|
40
49
|
);
|
41
|
-
const {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
const { client, walletAddress, chains, queryOptions } = args;
|
51
|
+
|
52
|
+
const defaultQueryOptions: GetV1WalletsByWalletAddressTransactionsData["query"] =
|
53
|
+
{
|
54
|
+
chain: chains.map((chain) => chain.id),
|
46
55
|
filter_block_timestamp_gte: threeMonthsAgoInSeconds,
|
47
56
|
limit: 100,
|
48
|
-
|
49
|
-
|
50
|
-
} = args;
|
57
|
+
};
|
58
|
+
|
51
59
|
const result = await getV1WalletsByWalletAddressTransactions({
|
52
60
|
baseUrl: `https://${getThirdwebDomains().insight}`,
|
53
61
|
fetch: getClientFetch(client),
|
54
62
|
query: {
|
63
|
+
...defaultQueryOptions,
|
55
64
|
...queryOptions,
|
56
|
-
chain: chains.map((chain) => chain.id),
|
57
65
|
},
|
58
66
|
path: {
|
59
67
|
wallet_address: walletAddress,
|
60
68
|
},
|
61
69
|
});
|
62
70
|
if (result.error) {
|
63
|
-
throw new Error(
|
71
|
+
throw new Error(
|
72
|
+
`${result.response.status} ${result.response.statusText} - ${result.error ? stringify(result.error) : "Unknown error"}`,
|
73
|
+
);
|
64
74
|
}
|
65
75
|
return result.data.data || [];
|
66
76
|
}
|