@net-protocol/bazaar 0.1.6 → 0.1.7
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +50 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +5 -4
- package/dist/react.d.ts +5 -4
- package/dist/react.js +52 -13
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +52 -13
- package/dist/react.mjs.map +1 -1
- package/dist/{types-BwfAmxpu.d.mts → types-5kMf461x.d.mts} +2 -2
- package/dist/{types-BwfAmxpu.d.ts → types-5kMf461x.d.ts} +2 -2
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicClient } from 'viem';
|
|
2
|
-
import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing, S as Sale } from './types-
|
|
2
|
+
import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing, S as Sale } from './types-5kMf461x.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* React hook for fetching NFT listings from Bazaar
|
|
@@ -8,8 +8,8 @@ import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing,
|
|
|
8
8
|
interface UseBazaarListingsOptions {
|
|
9
9
|
/** Chain ID to query */
|
|
10
10
|
chainId: number;
|
|
11
|
-
/** NFT collection address */
|
|
12
|
-
nftAddress
|
|
11
|
+
/** NFT collection address (optional - if omitted, fetches recent listings across all collections) */
|
|
12
|
+
nftAddress?: `0x${string}`;
|
|
13
13
|
/** Exclude listings from this address */
|
|
14
14
|
excludeMaker?: `0x${string}`;
|
|
15
15
|
/** Only include listings from this address */
|
|
@@ -45,7 +45,8 @@ interface UseBazaarListingsResult {
|
|
|
45
45
|
* - Not expired
|
|
46
46
|
* - Seller still owns the NFT
|
|
47
47
|
*
|
|
48
|
-
* Results are deduplicated (one per token) and sorted by price (lowest first)
|
|
48
|
+
* Results are deduplicated (one per token) and sorted by price (lowest first).
|
|
49
|
+
* If `nftAddress` is omitted, fetches recent listings across all collections on the chain.
|
|
49
50
|
*
|
|
50
51
|
* @example
|
|
51
52
|
* ```tsx
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicClient } from 'viem';
|
|
2
|
-
import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing, S as Sale } from './types-
|
|
2
|
+
import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing, S as Sale } from './types-5kMf461x.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* React hook for fetching NFT listings from Bazaar
|
|
@@ -8,8 +8,8 @@ import { L as Listing, C as CollectionOffer, E as Erc20Offer, d as Erc20Listing,
|
|
|
8
8
|
interface UseBazaarListingsOptions {
|
|
9
9
|
/** Chain ID to query */
|
|
10
10
|
chainId: number;
|
|
11
|
-
/** NFT collection address */
|
|
12
|
-
nftAddress
|
|
11
|
+
/** NFT collection address (optional - if omitted, fetches recent listings across all collections) */
|
|
12
|
+
nftAddress?: `0x${string}`;
|
|
13
13
|
/** Exclude listings from this address */
|
|
14
14
|
excludeMaker?: `0x${string}`;
|
|
15
15
|
/** Only include listings from this address */
|
|
@@ -45,7 +45,8 @@ interface UseBazaarListingsResult {
|
|
|
45
45
|
* - Not expired
|
|
46
46
|
* - Seller still owns the NFT
|
|
47
47
|
*
|
|
48
|
-
* Results are deduplicated (one per token) and sorted by price (lowest first)
|
|
48
|
+
* Results are deduplicated (one per token) and sorted by price (lowest first).
|
|
49
|
+
* If `nftAddress` is omitted, fetches recent listings across all collections on the chain.
|
|
49
50
|
*
|
|
50
51
|
* @example
|
|
51
52
|
* ```tsx
|
package/dist/react.js
CHANGED
|
@@ -934,7 +934,7 @@ var BazaarClient = class {
|
|
|
934
934
|
const bazaarAddress = getBazaarAddress(this.chainId);
|
|
935
935
|
const filter = {
|
|
936
936
|
appAddress: bazaarAddress,
|
|
937
|
-
topic: nftAddress
|
|
937
|
+
topic: nftAddress?.toLowerCase(),
|
|
938
938
|
maker
|
|
939
939
|
};
|
|
940
940
|
let startIndex;
|
|
@@ -1007,18 +1007,57 @@ var BazaarClient = class {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
const openListings = listings.filter((l) => l.orderStatus === 2 /* OPEN */);
|
|
1009
1009
|
const expiredListings = includeExpired ? listings.filter((l) => l.orderStatus === 1 /* EXPIRED */) : [];
|
|
1010
|
-
|
|
1011
|
-
const owners = await bulkFetchNftOwners(this.client, nftAddress, tokenIds);
|
|
1010
|
+
let validOpenListings;
|
|
1012
1011
|
const beforeOwnership = openListings.length;
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1012
|
+
if (nftAddress) {
|
|
1013
|
+
const tokenIds = openListings.map((l) => l.tokenId);
|
|
1014
|
+
const owners = await bulkFetchNftOwners(this.client, nftAddress, tokenIds);
|
|
1015
|
+
validOpenListings = openListings.filter((listing, index) => {
|
|
1016
|
+
const owner = owners[index];
|
|
1017
|
+
return isListingValid(
|
|
1018
|
+
listing.orderStatus,
|
|
1019
|
+
listing.expirationDate,
|
|
1020
|
+
listing.maker,
|
|
1021
|
+
owner
|
|
1022
|
+
);
|
|
1023
|
+
});
|
|
1024
|
+
} else {
|
|
1025
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1026
|
+
for (const listing of openListings) {
|
|
1027
|
+
const key = listing.nftAddress.toLowerCase();
|
|
1028
|
+
const group = groups.get(key);
|
|
1029
|
+
if (group) {
|
|
1030
|
+
group.push(listing);
|
|
1031
|
+
} else {
|
|
1032
|
+
groups.set(key, [listing]);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
const groupEntries = Array.from(groups.entries());
|
|
1036
|
+
const ownerResults = await Promise.all(
|
|
1037
|
+
groupEntries.map(
|
|
1038
|
+
([addr, groupListings]) => bulkFetchNftOwners(
|
|
1039
|
+
this.client,
|
|
1040
|
+
addr,
|
|
1041
|
+
groupListings.map((l) => l.tokenId)
|
|
1042
|
+
)
|
|
1043
|
+
)
|
|
1020
1044
|
);
|
|
1021
|
-
|
|
1045
|
+
validOpenListings = [];
|
|
1046
|
+
groupEntries.forEach(([, groupListings], groupIndex) => {
|
|
1047
|
+
const owners = ownerResults[groupIndex];
|
|
1048
|
+
for (let i = 0; i < groupListings.length; i++) {
|
|
1049
|
+
const listing = groupListings[i];
|
|
1050
|
+
if (isListingValid(
|
|
1051
|
+
listing.orderStatus,
|
|
1052
|
+
listing.expirationDate,
|
|
1053
|
+
listing.maker,
|
|
1054
|
+
owners[i]
|
|
1055
|
+
)) {
|
|
1056
|
+
validOpenListings.push(listing);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1022
1061
|
console.log(tag, `after ownership filter: ${validOpenListings.length}/${beforeOwnership} (${beforeOwnership - validOpenListings.length} dropped)`);
|
|
1023
1062
|
const dedupedOpen = sortListingsByPrice(getBestListingPerToken(validOpenListings));
|
|
1024
1063
|
const activeTokenKeys = new Set(dedupedOpen.map((l) => `${l.nftAddress.toLowerCase()}-${l.tokenId}`));
|
|
@@ -1563,7 +1602,7 @@ function useBazaarListings({
|
|
|
1563
1602
|
const filter = react.useMemo(
|
|
1564
1603
|
() => ({
|
|
1565
1604
|
appAddress: bazaarAddress,
|
|
1566
|
-
topic: nftAddress
|
|
1605
|
+
topic: nftAddress?.toLowerCase(),
|
|
1567
1606
|
maker
|
|
1568
1607
|
}),
|
|
1569
1608
|
[bazaarAddress, nftAddress, maker]
|
|
@@ -1587,7 +1626,7 @@ function useBazaarListings({
|
|
|
1587
1626
|
endIndex,
|
|
1588
1627
|
enabled: enabled && isSupported && (hasRangeOverride || totalCount > 0)
|
|
1589
1628
|
});
|
|
1590
|
-
const TAG = `[useBazaarListings chain=${chainId} nft=${nftAddress
|
|
1629
|
+
const TAG = `[useBazaarListings chain=${chainId} nft=${nftAddress?.slice(0, 10) ?? "all"}]`;
|
|
1591
1630
|
react.useEffect(() => {
|
|
1592
1631
|
console.log(TAG, {
|
|
1593
1632
|
enabled,
|