thirdweb 5.95.0-nightly-64bd603301b3067b6a69a29f66a28dee7ffa38f5-20250416000349 → 5.95.0-nightly-4cf15a2475fce1c5b55d19f7cf51ab080e80e33f-20250418000341
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 +2 -4
- package/dist/cjs/chains/utils.js.map +1 -1
- package/dist/cjs/event/actions/get-events.js +4 -10
- package/dist/cjs/event/actions/get-events.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFT.js +40 -0
- package/dist/cjs/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFTs.js +26 -0
- package/dist/cjs/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getOwnedNFTs.js +46 -0
- package/dist/cjs/extensions/erc1155/read/getOwnedNFTs.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 +12 -9
- package/dist/cjs/insight/get-events.js.map +1 -1
- package/dist/cjs/insight/get-nfts.js +213 -16
- package/dist/cjs/insight/get-nfts.js.map +1 -1
- package/dist/cjs/insight/get-tokens.js +34 -14
- package/dist/cjs/insight/get-tokens.js.map +1 -1
- package/dist/cjs/insight/get-transactions.js +17 -12
- package/dist/cjs/insight/get-transactions.js.map +1 -1
- package/dist/cjs/insight/index.js +3 -1
- package/dist/cjs/insight/index.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 +2 -22
- package/dist/cjs/rpc/fetch-rpc.js.map +1 -1
- package/dist/cjs/rpc/rpc.js +1 -1
- package/dist/cjs/rpc/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/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/in-app/core/users/getUser.js +2 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js.map +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 +2 -4
- package/dist/esm/chains/utils.js.map +1 -1
- package/dist/esm/event/actions/get-events.js +1 -7
- package/dist/esm/event/actions/get-events.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFT.js +40 -0
- package/dist/esm/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFTs.js +26 -0
- package/dist/esm/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getOwnedNFTs.js +46 -0
- package/dist/esm/extensions/erc1155/read/getOwnedNFTs.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 +8 -5
- package/dist/esm/insight/get-events.js.map +1 -1
- package/dist/esm/insight/get-nfts.js +208 -13
- package/dist/esm/insight/get-nfts.js.map +1 -1
- package/dist/esm/insight/get-tokens.js +30 -10
- package/dist/esm/insight/get-tokens.js.map +1 -1
- package/dist/esm/insight/get-transactions.js +13 -8
- package/dist/esm/insight/get-transactions.js.map +1 -1
- package/dist/esm/insight/index.js +1 -1
- package/dist/esm/insight/index.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 +2 -22
- package/dist/esm/rpc/fetch-rpc.js.map +1 -1
- package/dist/esm/rpc/rpc.js +1 -1
- package/dist/esm/rpc/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/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/in-app/core/users/getUser.js +2 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js.map +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/utils.d.ts.map +1 -1
- package/dist/types/event/actions/get-events.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getNFT.d.ts +5 -0
- package/dist/types/extensions/erc1155/read/getNFT.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getNFTs.d.ts +5 -0
- package/dist/types/extensions/erc1155/read/getNFTs.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getOwnedNFTs.d.ts +7 -1
- package/dist/types/extensions/erc1155/read/getOwnedNFTs.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 +2 -2
- package/dist/types/insight/get-events.d.ts.map +1 -1
- 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 +3 -3
- package/dist/types/insight/get-tokens.d.ts.map +1 -1
- package/dist/types/insight/get-transactions.d.ts +1 -1
- package/dist/types/insight/get-transactions.d.ts.map +1 -1
- package/dist/types/insight/index.d.ts +2 -2
- package/dist/types/insight/index.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/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/rpc/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/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/in-app/core/users/getUser.d.ts.map +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/utils.ts +6 -4
- package/src/event/actions/get-events.ts +1 -13
- package/src/extensions/erc1155/read/getNFT.test.ts +13 -0
- package/src/extensions/erc1155/read/getNFT.ts +53 -1
- package/src/extensions/erc1155/read/getNFTs.ts +38 -0
- package/src/extensions/erc1155/read/getOwnedNFTs.ts +65 -2
- 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 +106 -0
- package/src/extensions/erc721/read/getNFT.ts +55 -1
- package/src/extensions/erc721/read/getNFTs.test.ts +212 -6
- 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 +23 -9
- package/src/insight/get-nfts.ts +315 -20
- package/src/insight/get-tokens.ts +51 -23
- package/src/insight/get-transactions.ts +26 -16
- package/src/insight/index.ts +6 -2
- 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 +2 -20
- package/src/rpc/rpc.ts +5 -1
- 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/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/in-app/core/users/getUser.test.ts +4 -1
- package/src/wallets/in-app/core/users/getUser.ts +4 -1
- package/src/wallets/smart/lib/calls.ts +2 -2
- package/src/wallets/utils/getWalletBalance.ts +5 -7
@@ -6,16 +6,18 @@ import {
|
|
6
6
|
import { getNFTs } from "./getNFTs.js";
|
7
7
|
|
8
8
|
describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
9
|
-
it("works for a contract with
|
9
|
+
it("works for a contract with indexer", async () => {
|
10
10
|
const nfts = await getNFTs({
|
11
11
|
contract: DOODLES_CONTRACT,
|
12
12
|
count: 5,
|
13
13
|
});
|
14
14
|
|
15
15
|
expect(nfts.length).toBe(5);
|
16
|
+
// TODO (insight): re-enable once insight fixes the client id caching issue
|
16
17
|
expect(nfts).toMatchInlineSnapshot(`
|
17
18
|
[
|
18
19
|
{
|
20
|
+
"chainId": 1,
|
19
21
|
"id": 0n,
|
20
22
|
"metadata": {
|
21
23
|
"attributes": [
|
@@ -42,13 +44,17 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
42
44
|
],
|
43
45
|
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
44
46
|
"image": "ipfs://QmUEfFfwAh4wyB5UfHCVPUxis4j4Q4kJXtm5x5p3g1fVUn",
|
47
|
+
"image_url": "ipfs://QmUEfFfwAh4wyB5UfHCVPUxis4j4Q4kJXtm5x5p3g1fVUn",
|
45
48
|
"name": "Doodle #0",
|
49
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
|
46
50
|
},
|
47
51
|
"owner": null,
|
52
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
48
53
|
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
|
49
54
|
"type": "ERC721",
|
50
55
|
},
|
51
56
|
{
|
57
|
+
"chainId": 1,
|
52
58
|
"id": 1n,
|
53
59
|
"metadata": {
|
54
60
|
"attributes": [
|
@@ -75,13 +81,17 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
75
81
|
],
|
76
82
|
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
77
83
|
"image": "ipfs://QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
|
84
|
+
"image_url": "ipfs://QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
|
78
85
|
"name": "Doodle #1",
|
86
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
|
79
87
|
},
|
80
88
|
"owner": null,
|
89
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
81
90
|
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
|
82
91
|
"type": "ERC721",
|
83
92
|
},
|
84
93
|
{
|
94
|
+
"chainId": 1,
|
85
95
|
"id": 2n,
|
86
96
|
"metadata": {
|
87
97
|
"attributes": [
|
@@ -108,13 +118,17 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
108
118
|
],
|
109
119
|
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
110
120
|
"image": "ipfs://QmbvZ2hbF3nEq5r3ijMEiSGssAmJvtyFwiejTAGHv74LR5",
|
121
|
+
"image_url": "ipfs://QmbvZ2hbF3nEq5r3ijMEiSGssAmJvtyFwiejTAGHv74LR5",
|
111
122
|
"name": "Doodle #2",
|
123
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
|
112
124
|
},
|
113
125
|
"owner": null,
|
126
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
114
127
|
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
|
115
128
|
"type": "ERC721",
|
116
129
|
},
|
117
130
|
{
|
131
|
+
"chainId": 1,
|
118
132
|
"id": 3n,
|
119
133
|
"metadata": {
|
120
134
|
"attributes": [
|
@@ -141,13 +155,17 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
141
155
|
],
|
142
156
|
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
143
157
|
"image": "ipfs://QmVpwaCqLut3wqwB5KSQr2fGnbLuJt5e3LhNvzvcisewZB",
|
158
|
+
"image_url": "ipfs://QmVpwaCqLut3wqwB5KSQr2fGnbLuJt5e3LhNvzvcisewZB",
|
144
159
|
"name": "Doodle #3",
|
160
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
|
145
161
|
},
|
146
162
|
"owner": null,
|
163
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
147
164
|
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
|
148
165
|
"type": "ERC721",
|
149
166
|
},
|
150
167
|
{
|
168
|
+
"chainId": 1,
|
151
169
|
"id": 4n,
|
152
170
|
"metadata": {
|
153
171
|
"attributes": [
|
@@ -174,9 +192,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
174
192
|
],
|
175
193
|
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
176
194
|
"image": "ipfs://QmcyuFVLbfBmSeQ9ynu4dk67r97nB1abEekotuVuRGWedm",
|
195
|
+
"image_url": "ipfs://QmcyuFVLbfBmSeQ9ynu4dk67r97nB1abEekotuVuRGWedm",
|
177
196
|
"name": "Doodle #4",
|
197
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
|
178
198
|
},
|
179
199
|
"owner": null,
|
200
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
180
201
|
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
|
181
202
|
"type": "ERC721",
|
182
203
|
},
|
@@ -184,15 +205,200 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
184
205
|
`);
|
185
206
|
});
|
186
207
|
|
187
|
-
it.todo("works for a contract with `1` indexed NFTs", async () => {
|
188
|
-
// TODO find a contract that we can use that has "1 indexed" NFTs, then re-enable this test
|
189
|
-
});
|
190
|
-
|
191
208
|
it("should throw error if totalSupply and nextTokenIdToMint are not supported", async () => {
|
192
209
|
await expect(
|
193
|
-
getNFTs({ contract: UNISWAPV3_FACTORY_CONTRACT }),
|
210
|
+
getNFTs({ contract: UNISWAPV3_FACTORY_CONTRACT, useIndexer: false }),
|
194
211
|
).rejects.toThrowError(
|
195
212
|
"Contract requires either `nextTokenIdToMint` or `totalSupply` function available to determine the next token ID to mint",
|
196
213
|
);
|
197
214
|
});
|
215
|
+
|
216
|
+
it("works for a contract with 0 indexed NFTs using RPC", async () => {
|
217
|
+
const nfts = await getNFTs({
|
218
|
+
contract: DOODLES_CONTRACT,
|
219
|
+
count: 5,
|
220
|
+
useIndexer: false,
|
221
|
+
});
|
222
|
+
|
223
|
+
expect(nfts.length).toBe(5);
|
224
|
+
expect(nfts).toMatchInlineSnapshot(`
|
225
|
+
[
|
226
|
+
{
|
227
|
+
"chainId": 1,
|
228
|
+
"id": 0n,
|
229
|
+
"metadata": {
|
230
|
+
"attributes": [
|
231
|
+
{
|
232
|
+
"trait_type": "face",
|
233
|
+
"value": "mustache",
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"trait_type": "hair",
|
237
|
+
"value": "purple long",
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"trait_type": "body",
|
241
|
+
"value": "blue and yellow jacket",
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"trait_type": "background",
|
245
|
+
"value": "green",
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"trait_type": "head",
|
249
|
+
"value": "tan",
|
250
|
+
},
|
251
|
+
],
|
252
|
+
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
253
|
+
"image": "ipfs://QmUEfFfwAh4wyB5UfHCVPUxis4j4Q4kJXtm5x5p3g1fVUn",
|
254
|
+
"name": "Doodle #0",
|
255
|
+
},
|
256
|
+
"owner": null,
|
257
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
258
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
|
259
|
+
"type": "ERC721",
|
260
|
+
},
|
261
|
+
{
|
262
|
+
"chainId": 1,
|
263
|
+
"id": 1n,
|
264
|
+
"metadata": {
|
265
|
+
"attributes": [
|
266
|
+
{
|
267
|
+
"trait_type": "face",
|
268
|
+
"value": "holographic beard",
|
269
|
+
},
|
270
|
+
{
|
271
|
+
"trait_type": "hair",
|
272
|
+
"value": "white bucket cap",
|
273
|
+
},
|
274
|
+
{
|
275
|
+
"trait_type": "body",
|
276
|
+
"value": "purple sweater with satchel",
|
277
|
+
},
|
278
|
+
{
|
279
|
+
"trait_type": "background",
|
280
|
+
"value": "grey",
|
281
|
+
},
|
282
|
+
{
|
283
|
+
"trait_type": "head",
|
284
|
+
"value": "gradient 2",
|
285
|
+
},
|
286
|
+
],
|
287
|
+
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
288
|
+
"image": "ipfs://QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
|
289
|
+
"name": "Doodle #1",
|
290
|
+
},
|
291
|
+
"owner": null,
|
292
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
293
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
|
294
|
+
"type": "ERC721",
|
295
|
+
},
|
296
|
+
{
|
297
|
+
"chainId": 1,
|
298
|
+
"id": 2n,
|
299
|
+
"metadata": {
|
300
|
+
"attributes": [
|
301
|
+
{
|
302
|
+
"trait_type": "face",
|
303
|
+
"value": "designer glasses",
|
304
|
+
},
|
305
|
+
{
|
306
|
+
"trait_type": "hair",
|
307
|
+
"value": "poopie",
|
308
|
+
},
|
309
|
+
{
|
310
|
+
"trait_type": "body",
|
311
|
+
"value": "blue fleece",
|
312
|
+
},
|
313
|
+
{
|
314
|
+
"trait_type": "background",
|
315
|
+
"value": "yellow",
|
316
|
+
},
|
317
|
+
{
|
318
|
+
"trait_type": "head",
|
319
|
+
"value": "purple",
|
320
|
+
},
|
321
|
+
],
|
322
|
+
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
323
|
+
"image": "ipfs://QmbvZ2hbF3nEq5r3ijMEiSGssAmJvtyFwiejTAGHv74LR5",
|
324
|
+
"name": "Doodle #2",
|
325
|
+
},
|
326
|
+
"owner": null,
|
327
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
328
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
|
329
|
+
"type": "ERC721",
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"chainId": 1,
|
333
|
+
"id": 3n,
|
334
|
+
"metadata": {
|
335
|
+
"attributes": [
|
336
|
+
{
|
337
|
+
"trait_type": "face",
|
338
|
+
"value": "designer glasses",
|
339
|
+
},
|
340
|
+
{
|
341
|
+
"trait_type": "hair",
|
342
|
+
"value": "holographic mohawk",
|
343
|
+
},
|
344
|
+
{
|
345
|
+
"trait_type": "body",
|
346
|
+
"value": "pink fleece",
|
347
|
+
},
|
348
|
+
{
|
349
|
+
"trait_type": "background",
|
350
|
+
"value": "gradient 1",
|
351
|
+
},
|
352
|
+
{
|
353
|
+
"trait_type": "head",
|
354
|
+
"value": "pale",
|
355
|
+
},
|
356
|
+
],
|
357
|
+
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
358
|
+
"image": "ipfs://QmVpwaCqLut3wqwB5KSQr2fGnbLuJt5e3LhNvzvcisewZB",
|
359
|
+
"name": "Doodle #3",
|
360
|
+
},
|
361
|
+
"owner": null,
|
362
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
363
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
|
364
|
+
"type": "ERC721",
|
365
|
+
},
|
366
|
+
{
|
367
|
+
"chainId": 1,
|
368
|
+
"id": 4n,
|
369
|
+
"metadata": {
|
370
|
+
"attributes": [
|
371
|
+
{
|
372
|
+
"trait_type": "face",
|
373
|
+
"value": "happy",
|
374
|
+
},
|
375
|
+
{
|
376
|
+
"trait_type": "hair",
|
377
|
+
"value": "purple long",
|
378
|
+
},
|
379
|
+
{
|
380
|
+
"trait_type": "body",
|
381
|
+
"value": "spotted hoodie",
|
382
|
+
},
|
383
|
+
{
|
384
|
+
"trait_type": "background",
|
385
|
+
"value": "gradient 2",
|
386
|
+
},
|
387
|
+
{
|
388
|
+
"trait_type": "head",
|
389
|
+
"value": "purple",
|
390
|
+
},
|
391
|
+
],
|
392
|
+
"description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
|
393
|
+
"image": "ipfs://QmcyuFVLbfBmSeQ9ynu4dk67r97nB1abEekotuVuRGWedm",
|
394
|
+
"name": "Doodle #4",
|
395
|
+
},
|
396
|
+
"owner": null,
|
397
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
398
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
|
399
|
+
"type": "ERC721",
|
400
|
+
},
|
401
|
+
]
|
402
|
+
`);
|
403
|
+
});
|
198
404
|
});
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getContractNFTs } from "../../../insight/index.js";
|
1
2
|
import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
2
3
|
import { min } from "../../../utils/bigint.js";
|
3
4
|
import type { NFT } from "../../../utils/nft/parseNft.js";
|
@@ -41,6 +42,11 @@ export type GetNFTsParams = {
|
|
41
42
|
* In this case, the provided tokenId will be considered as token-index and actual tokenId will be fetched from the contract.
|
42
43
|
*/
|
43
44
|
tokenByIndex?: boolean;
|
45
|
+
/**
|
46
|
+
* Whether to use the insight API to fetch the NFTs.
|
47
|
+
* @default true
|
48
|
+
*/
|
49
|
+
useIndexer?: boolean;
|
44
50
|
};
|
45
51
|
|
46
52
|
/**
|
@@ -61,6 +67,59 @@ export type GetNFTsParams = {
|
|
61
67
|
*/
|
62
68
|
export async function getNFTs(
|
63
69
|
options: BaseTransactionOptions<GetNFTsParams>,
|
70
|
+
): Promise<NFT[]> {
|
71
|
+
const { useIndexer = true } = options;
|
72
|
+
if (useIndexer) {
|
73
|
+
try {
|
74
|
+
return await getNFTsFromInsight(options);
|
75
|
+
} catch {
|
76
|
+
return await getNFTsFromRPC(options);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return await getNFTsFromRPC(options);
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Checks if the `getNFTs` method is supported by the given contract.
|
84
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
85
|
+
* @returns A boolean indicating if the `getNFTs` method is supported.
|
86
|
+
* @extension ERC721
|
87
|
+
* @example
|
88
|
+
* ```ts
|
89
|
+
* import { isGetNFTsSupported } from "thirdweb/extensions/erc721";
|
90
|
+
*
|
91
|
+
* const supported = isGetNFTsSupported(["0x..."]);
|
92
|
+
* ```
|
93
|
+
*/
|
94
|
+
export function isGetNFTsSupported(availableSelectors: string[]) {
|
95
|
+
return (
|
96
|
+
isGetNFTSupported(availableSelectors) &&
|
97
|
+
(isTotalSupplySupported(availableSelectors) ||
|
98
|
+
isNextTokenIdToMintSupported(availableSelectors))
|
99
|
+
);
|
100
|
+
}
|
101
|
+
|
102
|
+
async function getNFTsFromInsight(
|
103
|
+
options: BaseTransactionOptions<GetNFTsParams>,
|
104
|
+
): Promise<NFT[]> {
|
105
|
+
const { contract, start, count = Number(DEFAULT_QUERY_ALL_COUNT) } = options;
|
106
|
+
|
107
|
+
const result = await getContractNFTs({
|
108
|
+
client: contract.client,
|
109
|
+
chains: [contract.chain],
|
110
|
+
contractAddress: contract.address,
|
111
|
+
includeOwners: options.includeOwners ?? false,
|
112
|
+
queryOptions: {
|
113
|
+
limit: count,
|
114
|
+
page: start ? Math.floor(start / count) : undefined,
|
115
|
+
},
|
116
|
+
});
|
117
|
+
|
118
|
+
return result;
|
119
|
+
}
|
120
|
+
|
121
|
+
async function getNFTsFromRPC(
|
122
|
+
options: BaseTransactionOptions<GetNFTsParams>,
|
64
123
|
): Promise<NFT[]> {
|
65
124
|
const [startTokenId_, maxSupply] = await Promise.allSettled([
|
66
125
|
startTokenId(options),
|
@@ -105,23 +164,3 @@ export async function getNFTs(
|
|
105
164
|
|
106
165
|
return await Promise.all(promises);
|
107
166
|
}
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Checks if the `getNFTs` method is supported by the given contract.
|
111
|
-
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
112
|
-
* @returns A boolean indicating if the `getNFTs` method is supported.
|
113
|
-
* @extension ERC721
|
114
|
-
* @example
|
115
|
-
* ```ts
|
116
|
-
* import { isGetNFTsSupported } from "thirdweb/extensions/erc721";
|
117
|
-
*
|
118
|
-
* const supported = isGetNFTsSupported(["0x..."]);
|
119
|
-
* ```
|
120
|
-
*/
|
121
|
-
export function isGetNFTsSupported(availableSelectors: string[]) {
|
122
|
-
return (
|
123
|
-
isGetNFTSupported(availableSelectors) &&
|
124
|
-
(isTotalSupplySupported(availableSelectors) ||
|
125
|
-
isNextTokenIdToMintSupported(availableSelectors))
|
126
|
-
);
|
127
|
-
}
|
@@ -6,12 +6,36 @@ import { getContract } from "../../../contract/contract.js";
|
|
6
6
|
import { getOwnedNFTs } from "./getOwnedNFTs.js";
|
7
7
|
|
8
8
|
describe.runIf(process.env.TW_SECRET_KEY)("erc721.getOwnedNFTs", () => {
|
9
|
-
it("should return the correct data", async () => {
|
9
|
+
it("should return the correct data using indexer", async () => {
|
10
10
|
const owner = "0x3010775D16E7B79AF280035c64a1Df5F705CfdDb";
|
11
11
|
const nfts = await getOwnedNFTs({
|
12
12
|
contract: DOODLES_CONTRACT,
|
13
13
|
owner,
|
14
14
|
});
|
15
|
+
expect(nfts.length).greaterThan(0);
|
16
|
+
});
|
17
|
+
|
18
|
+
it("should detect ownership functions using indexer", async () => {
|
19
|
+
const contract = getContract({
|
20
|
+
client: TEST_CLIENT,
|
21
|
+
chain: defineChain(421614),
|
22
|
+
address: "0x90450885977EE8F8F21AC79Fc2Dd51a18B13123E",
|
23
|
+
});
|
24
|
+
|
25
|
+
const ownedNFTs = await getOwnedNFTs({
|
26
|
+
contract,
|
27
|
+
owner: "0x1813D5Ff6f2B229a6Ba8FcDFa14004d91aa58e36",
|
28
|
+
});
|
29
|
+
expect(ownedNFTs.length).greaterThan(0);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("should return the correct data using RPC", async () => {
|
33
|
+
const owner = "0x3010775D16E7B79AF280035c64a1Df5F705CfdDb";
|
34
|
+
const nfts = await getOwnedNFTs({
|
35
|
+
contract: DOODLES_CONTRACT,
|
36
|
+
owner,
|
37
|
+
useIndexer: false,
|
38
|
+
});
|
15
39
|
|
16
40
|
// The following code is based on the state of the forked chain
|
17
41
|
// so the data should not change
|
@@ -21,7 +45,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getOwnedNFTs", () => {
|
|
21
45
|
}
|
22
46
|
});
|
23
47
|
|
24
|
-
it("should detect ownership functions", async () => {
|
48
|
+
it("should detect ownership functions using RPC", async () => {
|
25
49
|
const contract = getContract({
|
26
50
|
client: TEST_CLIENT,
|
27
51
|
chain: defineChain(421614),
|
@@ -31,6 +55,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getOwnedNFTs", () => {
|
|
31
55
|
const ownedNFTs = await getOwnedNFTs({
|
32
56
|
contract,
|
33
57
|
owner: "0x1813D5Ff6f2B229a6Ba8FcDFa14004d91aa58e36",
|
58
|
+
useIndexer: false,
|
34
59
|
});
|
35
60
|
expect(ownedNFTs.length).greaterThan(0);
|
36
61
|
});
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getOwnedNFTs as getInsightNFTs } from "../../../insight/index.js";
|
1
2
|
import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
2
3
|
import type { NFT } from "../../../utils/nft/parseNft.js";
|
3
4
|
import { getNFT } from "./getNFT.js";
|
@@ -9,7 +10,9 @@ import {
|
|
9
10
|
/**
|
10
11
|
* @extension ERC721
|
11
12
|
*/
|
12
|
-
export type GetOwnedNFTsParams = GetOwnedTokenIdsParams
|
13
|
+
export type GetOwnedNFTsParams = GetOwnedTokenIdsParams & {
|
14
|
+
useIndexer?: boolean;
|
15
|
+
};
|
13
16
|
|
14
17
|
/**
|
15
18
|
* Retrieves the owned NFTs for a given owner.
|
@@ -29,6 +32,20 @@ export type GetOwnedNFTsParams = GetOwnedTokenIdsParams;
|
|
29
32
|
*/
|
30
33
|
export async function getOwnedNFTs(
|
31
34
|
options: BaseTransactionOptions<GetOwnedNFTsParams>,
|
35
|
+
): Promise<NFT[]> {
|
36
|
+
const { useIndexer = true } = options;
|
37
|
+
if (useIndexer) {
|
38
|
+
try {
|
39
|
+
return await getOwnedNFTsFromInsight(options);
|
40
|
+
} catch {
|
41
|
+
return await getOwnedNFTsFromRPC(options);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return await getOwnedNFTsFromRPC(options);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function getOwnedNFTsFromRPC(
|
48
|
+
options: BaseTransactionOptions<GetOwnedNFTsParams>,
|
32
49
|
): Promise<NFT[]> {
|
33
50
|
const tokenIds = await getOwnedTokenIds(options);
|
34
51
|
|
@@ -45,3 +62,46 @@ export async function getOwnedNFTs(
|
|
45
62
|
),
|
46
63
|
);
|
47
64
|
}
|
65
|
+
|
66
|
+
async function getOwnedNFTsFromInsight(
|
67
|
+
options: BaseTransactionOptions<GetOwnedNFTsParams>,
|
68
|
+
): Promise<NFT[]> {
|
69
|
+
const limit = 50;
|
70
|
+
const nfts: NFT[] = [];
|
71
|
+
let page = 0;
|
72
|
+
let hasMore = true;
|
73
|
+
|
74
|
+
// TODO (insight): add support for contract address filters
|
75
|
+
while (hasMore) {
|
76
|
+
const pageResults = await getInsightNFTs({
|
77
|
+
client: options.contract.client,
|
78
|
+
chains: [options.contract.chain],
|
79
|
+
ownerAddress: options.owner,
|
80
|
+
queryOptions: {
|
81
|
+
limit,
|
82
|
+
page,
|
83
|
+
},
|
84
|
+
});
|
85
|
+
|
86
|
+
nfts.push(...pageResults);
|
87
|
+
|
88
|
+
// If we got fewer results than the limit, we've reached the end
|
89
|
+
if (pageResults.length < limit) {
|
90
|
+
hasMore = false;
|
91
|
+
} else {
|
92
|
+
page++;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
const results = nfts;
|
97
|
+
|
98
|
+
return results
|
99
|
+
.filter(
|
100
|
+
(n) =>
|
101
|
+
n.tokenAddress.toLowerCase() === options.contract.address.toLowerCase(),
|
102
|
+
)
|
103
|
+
.map((result) => ({
|
104
|
+
...result,
|
105
|
+
owner: options.owner,
|
106
|
+
}));
|
107
|
+
}
|
@@ -204,15 +204,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Marketplace Direct Listings", () => {
|
|
204
204
|
expect(firstListing.creatorAddress).toBe(TEST_ACCOUNT_B.address);
|
205
205
|
expect(firstListing.assetContractAddress).toBe(erc721Contract.address);
|
206
206
|
expect(firstListing.tokenId).toBe(0n);
|
207
|
-
expect(firstListing.currencyValuePerToken).
|
208
|
-
{
|
209
|
-
"decimals": 18,
|
210
|
-
"displayValue": "1",
|
211
|
-
"name": "Anvil Ether",
|
212
|
-
"symbol": "ETH",
|
213
|
-
"value": 1000000000000000000n,
|
214
|
-
}
|
215
|
-
`);
|
207
|
+
expect(firstListing.currencyValuePerToken.displayValue).toBe("1");
|
216
208
|
expect(firstListing.asset.metadata.name).toBe("erc721 #0");
|
217
209
|
expect(firstListing.asset.id).toBe(0n);
|
218
210
|
expect(firstListing.asset.owner).toBe(null);
|
@@ -351,15 +343,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Marketplace Direct Listings", () => {
|
|
351
343
|
expect(secondListing.creatorAddress).toBe(TEST_ACCOUNT_C.address);
|
352
344
|
expect(secondListing.assetContractAddress).toBe(erc1155Contract.address);
|
353
345
|
expect(secondListing.tokenId).toBe(0n);
|
354
|
-
expect(secondListing.currencyValuePerToken).
|
355
|
-
{
|
356
|
-
"decimals": 18,
|
357
|
-
"displayValue": "0.05",
|
358
|
-
"name": "Anvil Ether",
|
359
|
-
"symbol": "ETH",
|
360
|
-
"value": 50000000000000000n,
|
361
|
-
}
|
362
|
-
`);
|
346
|
+
expect(secondListing.currencyValuePerToken.displayValue).toBe("0.05");
|
363
347
|
expect(secondListing.asset.metadata.name).toBe("erc1155 #0");
|
364
348
|
expect(secondListing.asset.id).toBe(0n);
|
365
349
|
|
@@ -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,
|