@net-protocol/bazaar 0.1.1 → 0.1.2
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 +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +45 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +15 -3
- package/dist/react.d.ts +15 -3
- package/dist/react.js +80 -55
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +80 -55
- package/dist/react.mjs.map +1 -1
- package/dist/{types--4_RIuQ5.d.mts → types-KQgBECzI.d.mts} +14 -0
- package/dist/{types--4_RIuQ5.d.ts → types-KQgBECzI.d.ts} +14 -0
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -183,6 +183,7 @@ var BULK_SEAPORT_ORDER_STATUS_FETCHER_ADDRESS = "0x0000009112ABCE652674b4fE3eD9C
|
|
|
183
183
|
var ERC721_OWNER_OF_HELPER_ADDRESS = "0x000000aa4eFa2e5A4a6002C7F08B6e8Ec8cf1dDa";
|
|
184
184
|
var ERC20_BULK_BALANCE_CHECKER_ADDRESS = "0x000000b50a9f2923f2db931391824f6d1278f712";
|
|
185
185
|
var NET_SEAPORT_COLLECTION_OFFER_ZONE_ADDRESS = "0x000000B799ec6D7aCC1B578f62bFc324c25DFC5A";
|
|
186
|
+
var NET_SEAPORT_PRIVATE_ORDER_ZONE_ADDRESS = "0x000000bC63761cbb05305632212e2f3AE2BE7a9B";
|
|
186
187
|
var BAZAAR_CHAIN_CONFIGS = {
|
|
187
188
|
// Base Mainnet
|
|
188
189
|
8453: {
|
|
@@ -575,6 +576,7 @@ function parseListingFromMessage(message, chainId) {
|
|
|
575
576
|
}
|
|
576
577
|
const priceWei = getTotalConsiderationAmount(parameters);
|
|
577
578
|
const tokenId = offerItem.identifierOrCriteria.toString();
|
|
579
|
+
const targetFulfiller = parameters.zone.toLowerCase() === NET_SEAPORT_PRIVATE_ORDER_ZONE_ADDRESS.toLowerCase() && parameters.zoneHash !== "0x0000000000000000000000000000000000000000000000000000000000000000" ? parameters.zoneHash : void 0;
|
|
578
580
|
return {
|
|
579
581
|
maker: parameters.offerer,
|
|
580
582
|
nftAddress: offerItem.token,
|
|
@@ -591,7 +593,8 @@ function parseListingFromMessage(message, chainId) {
|
|
|
591
593
|
orderComponents: {
|
|
592
594
|
...parameters,
|
|
593
595
|
counter: submission.counter
|
|
594
|
-
}
|
|
596
|
+
},
|
|
597
|
+
targetFulfiller
|
|
595
598
|
};
|
|
596
599
|
} catch {
|
|
597
600
|
return null;
|
|
@@ -829,25 +832,30 @@ var BazaarClient = class {
|
|
|
829
832
|
* Results are deduplicated (one per token) and sorted by price (lowest first)
|
|
830
833
|
*/
|
|
831
834
|
async getListings(options) {
|
|
832
|
-
const { nftAddress, excludeMaker, maxMessages = 200 } = options;
|
|
835
|
+
const { nftAddress, excludeMaker, maker, maxMessages = 200 } = options;
|
|
833
836
|
const bazaarAddress = getBazaarAddress(this.chainId);
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
837
|
+
const filter = {
|
|
838
|
+
appAddress: bazaarAddress,
|
|
839
|
+
topic: nftAddress.toLowerCase(),
|
|
840
|
+
maker
|
|
841
|
+
};
|
|
842
|
+
let startIndex;
|
|
843
|
+
let endIndex;
|
|
844
|
+
if (options.startIndex != null && options.endIndex != null) {
|
|
845
|
+
startIndex = options.startIndex;
|
|
846
|
+
endIndex = options.endIndex;
|
|
847
|
+
} else {
|
|
848
|
+
const count = await this.netClient.getMessageCount({ filter });
|
|
849
|
+
if (count === 0) {
|
|
850
|
+
return [];
|
|
838
851
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
return [];
|
|
852
|
+
startIndex = Math.max(0, count - maxMessages);
|
|
853
|
+
endIndex = count;
|
|
842
854
|
}
|
|
843
|
-
const startIndex = Math.max(0, count - maxMessages);
|
|
844
855
|
const messages = await this.netClient.getMessages({
|
|
845
|
-
filter
|
|
846
|
-
appAddress: bazaarAddress,
|
|
847
|
-
topic: nftAddress.toLowerCase()
|
|
848
|
-
},
|
|
856
|
+
filter,
|
|
849
857
|
startIndex,
|
|
850
|
-
endIndex
|
|
858
|
+
endIndex
|
|
851
859
|
});
|
|
852
860
|
let listings = [];
|
|
853
861
|
for (const message of messages) {
|
|
@@ -1080,25 +1088,30 @@ var BazaarClient = class {
|
|
|
1080
1088
|
* all valid listings are returned (grouped by maker in the UI).
|
|
1081
1089
|
*/
|
|
1082
1090
|
async getErc20Listings(options) {
|
|
1083
|
-
const { tokenAddress, excludeMaker, maxMessages = 200 } = options;
|
|
1091
|
+
const { tokenAddress, excludeMaker, maker, maxMessages = 200 } = options;
|
|
1084
1092
|
const erc20BazaarAddress = getErc20BazaarAddress(this.chainId);
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1093
|
+
const filter = {
|
|
1094
|
+
appAddress: erc20BazaarAddress,
|
|
1095
|
+
topic: tokenAddress.toLowerCase(),
|
|
1096
|
+
maker
|
|
1097
|
+
};
|
|
1098
|
+
let startIndex;
|
|
1099
|
+
let endIndex;
|
|
1100
|
+
if (options.startIndex != null && options.endIndex != null) {
|
|
1101
|
+
startIndex = options.startIndex;
|
|
1102
|
+
endIndex = options.endIndex;
|
|
1103
|
+
} else {
|
|
1104
|
+
const count = await this.netClient.getMessageCount({ filter });
|
|
1105
|
+
if (count === 0) {
|
|
1106
|
+
return [];
|
|
1089
1107
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
return [];
|
|
1108
|
+
startIndex = Math.max(0, count - maxMessages);
|
|
1109
|
+
endIndex = count;
|
|
1093
1110
|
}
|
|
1094
|
-
const startIndex = Math.max(0, count - maxMessages);
|
|
1095
1111
|
const messages = await this.netClient.getMessages({
|
|
1096
|
-
filter
|
|
1097
|
-
appAddress: erc20BazaarAddress,
|
|
1098
|
-
topic: tokenAddress.toLowerCase()
|
|
1099
|
-
},
|
|
1112
|
+
filter,
|
|
1100
1113
|
startIndex,
|
|
1101
|
-
endIndex
|
|
1114
|
+
endIndex
|
|
1102
1115
|
});
|
|
1103
1116
|
let listings = [];
|
|
1104
1117
|
for (const message of messages) {
|
|
@@ -1135,8 +1148,8 @@ var BazaarClient = class {
|
|
|
1135
1148
|
const uniqueMakers = [...new Set(listings.map((l) => l.maker))];
|
|
1136
1149
|
const balances = await bulkFetchErc20Balances(this.client, tokenAddress, uniqueMakers);
|
|
1137
1150
|
const balanceMap = /* @__PURE__ */ new Map();
|
|
1138
|
-
uniqueMakers.forEach((
|
|
1139
|
-
balanceMap.set(
|
|
1151
|
+
uniqueMakers.forEach((maker2, index) => {
|
|
1152
|
+
balanceMap.set(maker2.toLowerCase(), balances[index]);
|
|
1140
1153
|
});
|
|
1141
1154
|
listings = listings.filter((listing) => {
|
|
1142
1155
|
const balance = balanceMap.get(listing.maker.toLowerCase()) || BigInt(0);
|
|
@@ -1269,13 +1282,17 @@ function useBazaarListings({
|
|
|
1269
1282
|
chainId,
|
|
1270
1283
|
nftAddress,
|
|
1271
1284
|
excludeMaker,
|
|
1285
|
+
maker,
|
|
1272
1286
|
maxMessages = 200,
|
|
1287
|
+
startIndex: startIndexOverride,
|
|
1288
|
+
endIndex: endIndexOverride,
|
|
1273
1289
|
enabled = true
|
|
1274
1290
|
}) {
|
|
1275
1291
|
const [listings, setListings] = useState([]);
|
|
1276
1292
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
1277
1293
|
const [processingError, setProcessingError] = useState();
|
|
1278
1294
|
const [refetchTrigger, setRefetchTrigger] = useState(0);
|
|
1295
|
+
const hasRangeOverride = startIndexOverride != null && endIndexOverride != null;
|
|
1279
1296
|
const isSupported = useMemo(
|
|
1280
1297
|
() => isBazaarSupportedOnChain(chainId),
|
|
1281
1298
|
[chainId]
|
|
@@ -1287,19 +1304,18 @@ function useBazaarListings({
|
|
|
1287
1304
|
const filter = useMemo(
|
|
1288
1305
|
() => ({
|
|
1289
1306
|
appAddress: bazaarAddress,
|
|
1290
|
-
topic: nftAddress.toLowerCase()
|
|
1307
|
+
topic: nftAddress.toLowerCase(),
|
|
1308
|
+
maker
|
|
1291
1309
|
}),
|
|
1292
|
-
[bazaarAddress, nftAddress]
|
|
1310
|
+
[bazaarAddress, nftAddress, maker]
|
|
1293
1311
|
);
|
|
1294
1312
|
const { count: totalCount, isLoading: isLoadingCount } = useNetMessageCount({
|
|
1295
1313
|
chainId,
|
|
1296
1314
|
filter,
|
|
1297
|
-
enabled: enabled && isSupported
|
|
1315
|
+
enabled: enabled && isSupported && !hasRangeOverride
|
|
1298
1316
|
});
|
|
1299
|
-
const startIndex =
|
|
1300
|
-
|
|
1301
|
-
[totalCount, maxMessages]
|
|
1302
|
-
);
|
|
1317
|
+
const startIndex = hasRangeOverride ? startIndexOverride : Math.max(0, totalCount - maxMessages);
|
|
1318
|
+
const endIndex = hasRangeOverride ? endIndexOverride : totalCount;
|
|
1303
1319
|
const {
|
|
1304
1320
|
messages,
|
|
1305
1321
|
isLoading: isLoadingMessages,
|
|
@@ -1309,8 +1325,8 @@ function useBazaarListings({
|
|
|
1309
1325
|
chainId,
|
|
1310
1326
|
filter,
|
|
1311
1327
|
startIndex,
|
|
1312
|
-
endIndex
|
|
1313
|
-
enabled: enabled && isSupported && totalCount > 0
|
|
1328
|
+
endIndex,
|
|
1329
|
+
enabled: enabled && isSupported && (hasRangeOverride || totalCount > 0)
|
|
1314
1330
|
});
|
|
1315
1331
|
useEffect(() => {
|
|
1316
1332
|
if (!isSupported || !enabled) {
|
|
@@ -1330,7 +1346,10 @@ function useBazaarListings({
|
|
|
1330
1346
|
const validListings = await client.getListings({
|
|
1331
1347
|
nftAddress,
|
|
1332
1348
|
excludeMaker,
|
|
1333
|
-
|
|
1349
|
+
maker,
|
|
1350
|
+
maxMessages,
|
|
1351
|
+
startIndex: hasRangeOverride ? startIndexOverride : void 0,
|
|
1352
|
+
endIndex: hasRangeOverride ? endIndexOverride : void 0
|
|
1334
1353
|
});
|
|
1335
1354
|
if (!cancelled) {
|
|
1336
1355
|
setListings(validListings);
|
|
@@ -1350,14 +1369,14 @@ function useBazaarListings({
|
|
|
1350
1369
|
return () => {
|
|
1351
1370
|
cancelled = true;
|
|
1352
1371
|
};
|
|
1353
|
-
}, [chainId, nftAddress, excludeMaker, maxMessages, messages, isSupported, enabled, refetchTrigger]);
|
|
1372
|
+
}, [chainId, nftAddress, excludeMaker, maker, maxMessages, startIndexOverride, endIndexOverride, hasRangeOverride, messages, isSupported, enabled, refetchTrigger]);
|
|
1354
1373
|
const refetch = () => {
|
|
1355
1374
|
refetchMessages();
|
|
1356
1375
|
setRefetchTrigger((t) => t + 1);
|
|
1357
1376
|
};
|
|
1358
1377
|
return {
|
|
1359
1378
|
listings,
|
|
1360
|
-
isLoading: isLoadingCount || isLoadingMessages || isProcessing,
|
|
1379
|
+
isLoading: (hasRangeOverride ? false : isLoadingCount) || isLoadingMessages || isProcessing,
|
|
1361
1380
|
error: messagesError || processingError,
|
|
1362
1381
|
refetch
|
|
1363
1382
|
};
|
|
@@ -1561,13 +1580,17 @@ function useBazaarErc20Listings({
|
|
|
1561
1580
|
chainId,
|
|
1562
1581
|
tokenAddress,
|
|
1563
1582
|
excludeMaker,
|
|
1583
|
+
maker,
|
|
1564
1584
|
maxMessages = 200,
|
|
1585
|
+
startIndex: startIndexOverride,
|
|
1586
|
+
endIndex: endIndexOverride,
|
|
1565
1587
|
enabled = true
|
|
1566
1588
|
}) {
|
|
1567
1589
|
const [listings, setListings] = useState([]);
|
|
1568
1590
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
1569
1591
|
const [processingError, setProcessingError] = useState();
|
|
1570
1592
|
const [refetchTrigger, setRefetchTrigger] = useState(0);
|
|
1593
|
+
const hasRangeOverride = startIndexOverride != null && endIndexOverride != null;
|
|
1571
1594
|
const isSupported = useMemo(
|
|
1572
1595
|
() => isBazaarSupportedOnChain(chainId),
|
|
1573
1596
|
[chainId]
|
|
@@ -1579,19 +1602,18 @@ function useBazaarErc20Listings({
|
|
|
1579
1602
|
const filter = useMemo(
|
|
1580
1603
|
() => ({
|
|
1581
1604
|
appAddress: erc20BazaarAddress,
|
|
1582
|
-
topic: tokenAddress.toLowerCase()
|
|
1605
|
+
topic: tokenAddress.toLowerCase(),
|
|
1606
|
+
maker
|
|
1583
1607
|
}),
|
|
1584
|
-
[erc20BazaarAddress, tokenAddress]
|
|
1608
|
+
[erc20BazaarAddress, tokenAddress, maker]
|
|
1585
1609
|
);
|
|
1586
1610
|
const { count: totalCount, isLoading: isLoadingCount } = useNetMessageCount({
|
|
1587
1611
|
chainId,
|
|
1588
1612
|
filter,
|
|
1589
|
-
enabled: enabled && isSupported
|
|
1613
|
+
enabled: enabled && isSupported && !hasRangeOverride
|
|
1590
1614
|
});
|
|
1591
|
-
const startIndex =
|
|
1592
|
-
|
|
1593
|
-
[totalCount, maxMessages]
|
|
1594
|
-
);
|
|
1615
|
+
const startIndex = hasRangeOverride ? startIndexOverride : Math.max(0, totalCount - maxMessages);
|
|
1616
|
+
const endIndex = hasRangeOverride ? endIndexOverride : totalCount;
|
|
1595
1617
|
const {
|
|
1596
1618
|
messages,
|
|
1597
1619
|
isLoading: isLoadingMessages,
|
|
@@ -1601,8 +1623,8 @@ function useBazaarErc20Listings({
|
|
|
1601
1623
|
chainId,
|
|
1602
1624
|
filter,
|
|
1603
1625
|
startIndex,
|
|
1604
|
-
endIndex
|
|
1605
|
-
enabled: enabled && isSupported && totalCount > 0
|
|
1626
|
+
endIndex,
|
|
1627
|
+
enabled: enabled && isSupported && (hasRangeOverride || totalCount > 0)
|
|
1606
1628
|
});
|
|
1607
1629
|
useEffect(() => {
|
|
1608
1630
|
if (!isSupported || !enabled) {
|
|
@@ -1622,7 +1644,10 @@ function useBazaarErc20Listings({
|
|
|
1622
1644
|
const validListings = await client.getErc20Listings({
|
|
1623
1645
|
tokenAddress,
|
|
1624
1646
|
excludeMaker,
|
|
1625
|
-
|
|
1647
|
+
maker,
|
|
1648
|
+
maxMessages,
|
|
1649
|
+
startIndex: hasRangeOverride ? startIndexOverride : void 0,
|
|
1650
|
+
endIndex: hasRangeOverride ? endIndexOverride : void 0
|
|
1626
1651
|
});
|
|
1627
1652
|
if (!cancelled) {
|
|
1628
1653
|
setListings(validListings);
|
|
@@ -1642,14 +1667,14 @@ function useBazaarErc20Listings({
|
|
|
1642
1667
|
return () => {
|
|
1643
1668
|
cancelled = true;
|
|
1644
1669
|
};
|
|
1645
|
-
}, [chainId, tokenAddress, excludeMaker, maxMessages, messages, isSupported, enabled, refetchTrigger]);
|
|
1670
|
+
}, [chainId, tokenAddress, excludeMaker, maker, maxMessages, startIndexOverride, endIndexOverride, hasRangeOverride, messages, isSupported, enabled, refetchTrigger]);
|
|
1646
1671
|
const refetch = () => {
|
|
1647
1672
|
refetchMessages();
|
|
1648
1673
|
setRefetchTrigger((t) => t + 1);
|
|
1649
1674
|
};
|
|
1650
1675
|
return {
|
|
1651
1676
|
listings,
|
|
1652
|
-
isLoading: isLoadingCount || isLoadingMessages || isProcessing,
|
|
1677
|
+
isLoading: (hasRangeOverride ? false : isLoadingCount) || isLoadingMessages || isProcessing,
|
|
1653
1678
|
error: messagesError || processingError,
|
|
1654
1679
|
refetch
|
|
1655
1680
|
};
|