@0xsequence/marketplace-sdk 0.8.9 → 0.8.11
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/.changeset/fluffy-jokes-lay.md +5 -0
- package/.changeset/wise-bugs-boil.md +8 -0
- package/CHANGELOG.md +43 -0
- package/dist/{chunk-FMEEJFAF.js → chunk-5C6ZZ6WX.js} +1 -1
- package/dist/{chunk-YEGD7PWE.js → chunk-5O44EPXZ.js} +2 -2
- package/dist/chunk-6CTFVBKU.js +1 -0
- package/dist/{chunk-DWTLVJAW.js → chunk-6OPMUCGX.js} +1 -1
- package/dist/chunk-6OPMUCGX.js.map +1 -0
- package/dist/{chunk-O34GCB47.js → chunk-L6KWLCER.js} +4 -4
- package/dist/chunk-L6KWLCER.js.map +1 -0
- package/dist/{chunk-4XLXOEXQ.js → chunk-LAP2CKLN.js} +78 -4
- package/dist/chunk-LAP2CKLN.js.map +1 -0
- package/dist/{chunk-Y63BOO6M.js → chunk-LECCEZAO.js} +1 -1
- package/dist/{chunk-YALXP2PW.js → chunk-N7SQWS2R.js} +3 -3
- package/dist/{chunk-KGM2WLSP.js → chunk-OAOONM4S.js} +695 -440
- package/dist/chunk-OAOONM4S.js.map +1 -0
- package/dist/chunk-Q3ECVC4F.js +811 -0
- package/dist/chunk-Q3ECVC4F.js.map +1 -0
- package/dist/chunk-QY52UADF.js +107 -0
- package/dist/chunk-QY52UADF.js.map +1 -0
- package/dist/{chunk-I2BYHDFE.js → chunk-TNAR3XEF.js} +3898 -844
- package/dist/chunk-TNAR3XEF.js.map +1 -0
- package/dist/chunk-XABYNWXO.js +549 -0
- package/dist/chunk-XABYNWXO.js.map +1 -0
- package/dist/chunk-YB5UUF2G.js +11 -0
- package/dist/chunk-YB5UUF2G.js.map +1 -0
- package/dist/{chunk-35WWD5V6.js → chunk-YWGFI4PN.js} +88 -25
- package/dist/chunk-YWGFI4PN.js.map +1 -0
- package/dist/{create-config-DwrnzwpM.d.ts → create-config-DLMvMTkZ.d.ts} +2 -2
- package/dist/index.css +7 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +19 -14
- package/dist/{lowestListing-BQHIuvNF.d.ts → marketCurrencies-enNVYwBk.d.ts} +95 -3
- package/dist/{marketplace.gen-DQzWciwC.d.ts → marketplace.gen-D24veUQs.d.ts} +3 -2
- package/dist/marketplaceConfig-BwNAbLPw.d.ts +21 -0
- package/dist/new-marketplace-types-BCw19X9S.d.ts +102 -0
- package/dist/react/_internal/api/index.d.ts +4 -3
- package/dist/react/_internal/api/index.js +5 -1
- package/dist/react/_internal/databeat/index.css +2764 -0
- package/dist/react/_internal/databeat/index.css.map +1 -0
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +15 -14
- package/dist/react/_internal/index.d.ts +62 -9
- package/dist/react/_internal/index.js +7 -3
- package/dist/react/_internal/wagmi/index.d.ts +5 -6
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.css +2764 -0
- package/dist/react/hooks/index.css.map +1 -0
- package/dist/react/hooks/index.d.ts +74 -222
- package/dist/react/hooks/index.js +21 -22
- package/dist/react/hooks/options/index.d.ts +5 -4
- package/dist/react/hooks/options/index.js +9 -7
- package/dist/react/index.css +7 -7
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +12 -11
- package/dist/react/index.js +34 -37
- package/dist/react/queries/index.d.ts +4 -3
- package/dist/react/queries/index.js +19 -6
- package/dist/react/ssr/index.d.ts +3 -3
- package/dist/react/ssr/index.js +6 -5
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +7 -7
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +9 -6
- package/dist/react/ui/components/collectible-card/index.js +19 -23
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +9 -8
- package/dist/react/ui/index.css +7 -7
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +2 -2
- package/dist/react/ui/index.js +17 -21
- package/dist/react/ui/modals/_internal/components/actionModal/index.css +2764 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +15 -14
- package/dist/sdk-config-qorA0TgF.d.ts +165 -0
- package/dist/{services-BI_w8Eq4.d.ts → services-WrshxCqc.d.ts} +6 -3
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +7 -7
- package/dist/{index-DGsVBflk.d.ts → useCollection-YAdXfVO7.d.ts} +1 -2
- package/dist/utils/abi/index.d.ts +1 -0
- package/dist/utils/abi/index.js +7 -1
- package/dist/utils/abi/primary-sale/index.d.ts +1054 -0
- package/dist/utils/abi/primary-sale/index.js +9 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +13 -6
- package/package.json +32 -32
- package/src/react/_internal/api/__mocks__/builder.msw.ts +157 -80
- package/src/react/_internal/api/builder-api.ts +2 -2
- package/src/react/_internal/api/builder.gen.ts +667 -112
- package/src/react/_internal/api/marketplace.gen.ts +1981 -1316
- package/src/react/_internal/api/services.ts +12 -1
- package/src/react/_internal/types.ts +1 -13
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +99 -84
- package/src/react/_internal/wagmi/create-config.ts +8 -4
- package/src/react/_internal/wagmi/get-connectors.ts +24 -19
- package/src/react/hooks/__tests__/__snapshots__/useListCollections.test.tsx.snap +114 -0
- package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +85 -83
- package/src/react/hooks/__tests__/useFilters.test.tsx +0 -16
- package/src/react/hooks/__tests__/useInventory.test.tsx +16 -16
- package/src/react/hooks/__tests__/useListCollections.test.tsx +23 -56
- package/src/react/hooks/__tests__/{useCurrencies.test.tsx → useMarketCurrencies.test.tsx} +21 -15
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +2 -59
- package/src/react/hooks/index.ts +3 -1
- package/src/react/hooks/useBalanceOfCollectible.tsx +5 -3
- package/src/react/hooks/useConvertPriceToUSD.tsx +1 -1
- package/src/react/hooks/useFilters.tsx +14 -22
- package/src/react/hooks/useGetTokenSuppliesMap.ts +28 -0
- package/src/react/hooks/useInventory.tsx +4 -3
- package/src/react/hooks/useList1155SaleSupplies.tsx +62 -0
- package/src/react/hooks/useListBalances.tsx +5 -3
- package/src/react/hooks/useListCollectibles.tsx +5 -3
- package/src/react/hooks/useListCollections.tsx +14 -76
- package/src/react/hooks/useListTokenMetadata.ts +19 -0
- package/src/react/hooks/useMarketCurrencies.tsx +8 -0
- package/src/react/hooks/useMarketplaceConfig.tsx +0 -2
- package/src/react/queries/index.ts +2 -0
- package/src/react/queries/inventory.ts +1 -1
- package/src/react/queries/listCollections.ts +118 -0
- package/src/react/queries/listTokenMetadata.ts +38 -0
- package/src/react/queries/marketCurrencies.ts +77 -0
- package/src/react/queries/marketplaceConfig.ts +83 -55
- package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +85 -83
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
- package/src/react/ui/components/collectible-card/__tests__/{CollectibleAsset.test.tsx → Media.test.tsx} +48 -14
- package/src/react/ui/components/collectible-card/index.ts +1 -1
- package/src/react/ui/components/collectible-card/media/Media.tsx +211 -0
- package/src/react/ui/components/collectible-card/{collectible-asset/CollectibleAssetSkeleton.tsx → media/MediaSkeleton.tsx} +2 -2
- package/src/react/ui/components/collectible-card/media/types.ts +18 -0
- package/src/react/ui/components/collectible-card/{collectible-asset → media}/utils.ts +8 -3
- package/src/react/ui/index.ts +1 -1
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +9 -3
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +31 -21
- package/src/react/ui/modals/BuyModal/hooks/useFees.ts +3 -2
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +28 -3
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -5
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +5 -3
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -3
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +4 -3
- package/src/react/ui/modals/SellModal/Modal.tsx +0 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +1 -1
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +0 -1
- package/src/react/ui/modals/TransferModal/index.tsx +0 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +2 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +7 -6
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +13 -7
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +3 -5
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +5 -3
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
- package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +2 -12
- package/src/types/index.ts +1 -6
- package/src/types/new-marketplace-types.ts +119 -0
- package/src/types/sdk-config.ts +19 -2
- package/src/types/types.ts +1 -0
- package/src/utils/abi/index.ts +1 -0
- package/src/utils/abi/primary-sale/index.ts +2 -0
- package/src/utils/abi/primary-sale/sequence-1155-sales-contract.ts +450 -0
- package/src/utils/abi/primary-sale/sequence-721-sales-contract.ts +352 -0
- package/src/utils/abi/token/sequence-erc1155-items.ts +454 -0
- package/src/utils/fetchContentType.ts +5 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-35WWD5V6.js.map +0 -1
- package/dist/chunk-4XLXOEXQ.js.map +0 -1
- package/dist/chunk-D7RVSZAQ.js +0 -332
- package/dist/chunk-D7RVSZAQ.js.map +0 -1
- package/dist/chunk-DWTLVJAW.js.map +0 -1
- package/dist/chunk-EODKQL6Y.js +0 -76
- package/dist/chunk-EODKQL6Y.js.map +0 -1
- package/dist/chunk-G3447GIP.js +0 -2880
- package/dist/chunk-G3447GIP.js.map +0 -1
- package/dist/chunk-HHYNOPPI.js +0 -53
- package/dist/chunk-HHYNOPPI.js.map +0 -1
- package/dist/chunk-I2BYHDFE.js.map +0 -1
- package/dist/chunk-JKCF7HEA.js +0 -1
- package/dist/chunk-KGM2WLSP.js.map +0 -1
- package/dist/chunk-MAD64DLJ.js +0 -81
- package/dist/chunk-MAD64DLJ.js.map +0 -1
- package/dist/chunk-N7BPFK46.js +0 -1
- package/dist/chunk-O34GCB47.js.map +0 -1
- package/dist/chunk-UISBTKFF.js +0 -1
- package/dist/chunk-UISBTKFF.js.map +0 -1
- package/dist/chunk-YBOFRP65.js +0 -128
- package/dist/chunk-YBOFRP65.js.map +0 -1
- package/dist/marketplaceConfig-B4Fdsmxu.d.ts +0 -17
- package/dist/sdk-config-txlivEKe.d.ts +0 -133
- package/dist/types-isjvwapz.d.ts +0 -68
- package/src/react/hooks/useCurrencies.tsx +0 -77
- package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +0 -174
- /package/dist/{chunk-FMEEJFAF.js.map → chunk-5C6ZZ6WX.js.map} +0 -0
- /package/dist/{chunk-YEGD7PWE.js.map → chunk-5O44EPXZ.js.map} +0 -0
- /package/dist/{chunk-JKCF7HEA.js.map → chunk-6CTFVBKU.js.map} +0 -0
- /package/dist/{chunk-Y63BOO6M.js.map → chunk-LECCEZAO.js.map} +0 -0
- /package/dist/{chunk-YALXP2PW.js.map → chunk-N7SQWS2R.js.map} +0 -0
- /package/dist/{chunk-N7BPFK46.js.map → utils/abi/primary-sale/index.js.map} +0 -0
package/dist/chunk-G3447GIP.js
DELETED
|
@@ -1,2880 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
collectionOptions
|
|
5
|
-
} from "./chunk-YALXP2PW.js";
|
|
6
|
-
import {
|
|
7
|
-
InfoIcon_default
|
|
8
|
-
} from "./chunk-EODKQL6Y.js";
|
|
9
|
-
import {
|
|
10
|
-
SEQUENCE_MARKET_V1_ADDRESS,
|
|
11
|
-
SEQUENCE_MARKET_V2_ADDRESS
|
|
12
|
-
} from "./chunk-Y63BOO6M.js";
|
|
13
|
-
import {
|
|
14
|
-
compareAddress,
|
|
15
|
-
getPresentableChainName
|
|
16
|
-
} from "./chunk-YEGD7PWE.js";
|
|
17
|
-
import {
|
|
18
|
-
ERC1155_ABI
|
|
19
|
-
} from "./chunk-FUM4OGOQ.js";
|
|
20
|
-
import {
|
|
21
|
-
EIP2981_ABI
|
|
22
|
-
} from "./chunk-XX4EVWBF.js";
|
|
23
|
-
import {
|
|
24
|
-
balanceOfCollectibleOptions,
|
|
25
|
-
highestOfferOptions,
|
|
26
|
-
inventoryOptions,
|
|
27
|
-
listBalancesOptions,
|
|
28
|
-
listCollectiblesOptions,
|
|
29
|
-
lowestListingOptions
|
|
30
|
-
} from "./chunk-4XLXOEXQ.js";
|
|
31
|
-
import {
|
|
32
|
-
marketplaceConfigOptions
|
|
33
|
-
} from "./chunk-MAD64DLJ.js";
|
|
34
|
-
import {
|
|
35
|
-
AddressSchema,
|
|
36
|
-
CollectableIdSchema,
|
|
37
|
-
PROVIDER_ID,
|
|
38
|
-
QueryArgSchema
|
|
39
|
-
} from "./chunk-DWTLVJAW.js";
|
|
40
|
-
import {
|
|
41
|
-
CollectibleStatus,
|
|
42
|
-
CollectionStatus,
|
|
43
|
-
ContractType,
|
|
44
|
-
MarketplaceKind,
|
|
45
|
-
OrderSide,
|
|
46
|
-
OrderStatus,
|
|
47
|
-
OrderbookKind,
|
|
48
|
-
ProjectStatus,
|
|
49
|
-
PropertyType,
|
|
50
|
-
SortOrder,
|
|
51
|
-
SourceKind,
|
|
52
|
-
StepType,
|
|
53
|
-
TransactionCrypto,
|
|
54
|
-
TransactionNFTCheckoutProvider,
|
|
55
|
-
TransactionOnRampProvider,
|
|
56
|
-
TransactionSwapProvider,
|
|
57
|
-
WalletKind,
|
|
58
|
-
balanceQueries,
|
|
59
|
-
collectableKeys,
|
|
60
|
-
collectionKeys,
|
|
61
|
-
currencyKeys,
|
|
62
|
-
getIndexerClient,
|
|
63
|
-
getMarketplaceClient,
|
|
64
|
-
getMetadataClient,
|
|
65
|
-
getQueryClient
|
|
66
|
-
} from "./chunk-KGM2WLSP.js";
|
|
67
|
-
import {
|
|
68
|
-
BaseError,
|
|
69
|
-
ChainSwitchError,
|
|
70
|
-
ChainSwitchUserRejectedError,
|
|
71
|
-
NoWalletConnectedError,
|
|
72
|
-
TransactionConfirmationError,
|
|
73
|
-
TransactionExecutionError,
|
|
74
|
-
TransactionSignatureError,
|
|
75
|
-
UserRejectedRequestError,
|
|
76
|
-
WalletInstanceNotFoundError
|
|
77
|
-
} from "./chunk-NX52D7NX.js";
|
|
78
|
-
|
|
79
|
-
// src/react/hooks/useAutoSelectFeeOption.tsx
|
|
80
|
-
import { zeroAddress } from "viem";
|
|
81
|
-
import { useChain } from "@0xsequence/connect";
|
|
82
|
-
import { useCallback, useEffect } from "react";
|
|
83
|
-
import { useAccount } from "wagmi";
|
|
84
|
-
|
|
85
|
-
// src/react/hooks/useCollectionBalanceDetails.tsx
|
|
86
|
-
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
87
|
-
import { z } from "zod";
|
|
88
|
-
|
|
89
|
-
// src/react/hooks/useConfig.tsx
|
|
90
|
-
import { useContext } from "react";
|
|
91
|
-
|
|
92
|
-
// src/utils/_internal/error/context.ts
|
|
93
|
-
var MarketplaceSdkProviderNotFoundError = class extends BaseError {
|
|
94
|
-
name = "MarketplaceSDKProviderNotFoundError";
|
|
95
|
-
constructor() {
|
|
96
|
-
super("`useConfig` must be used within `MarketplaceSdkProvider`.");
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// src/react/provider.tsx
|
|
101
|
-
import { QueryClientProvider } from "@tanstack/react-query";
|
|
102
|
-
import { createContext } from "react";
|
|
103
|
-
|
|
104
|
-
// src/utils/_internal/error/config.ts
|
|
105
|
-
var ConfigError = class extends BaseError {
|
|
106
|
-
name = "ConfigError";
|
|
107
|
-
};
|
|
108
|
-
var InvalidProjectAccessKeyError = class extends ConfigError {
|
|
109
|
-
name = "InvalidProjectAccessKeyError";
|
|
110
|
-
constructor(projectAccessKey) {
|
|
111
|
-
super(`Invalid project access key: ${projectAccessKey}`);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// src/react/provider.tsx
|
|
116
|
-
import { jsx } from "react/jsx-runtime";
|
|
117
|
-
var MarketplaceSdkContext = createContext({});
|
|
118
|
-
function MarketplaceQueryClientProvider({
|
|
119
|
-
children
|
|
120
|
-
}) {
|
|
121
|
-
const queryClient = getQueryClient();
|
|
122
|
-
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
|
|
123
|
-
}
|
|
124
|
-
function MarketplaceProvider({
|
|
125
|
-
config,
|
|
126
|
-
children
|
|
127
|
-
}) {
|
|
128
|
-
if (config.projectAccessKey === "" || !config.projectAccessKey) {
|
|
129
|
-
throw new InvalidProjectAccessKeyError(config.projectAccessKey);
|
|
130
|
-
}
|
|
131
|
-
return /* @__PURE__ */ jsx(MarketplaceQueryClientProvider, { children: /* @__PURE__ */ jsx(MarketplaceSdkContext.Provider, { value: config, children: /* @__PURE__ */ jsx("div", { id: PROVIDER_ID, children }) }) });
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/react/hooks/useConfig.tsx
|
|
135
|
-
function useConfig() {
|
|
136
|
-
const context = useContext(MarketplaceSdkContext);
|
|
137
|
-
if (!context) {
|
|
138
|
-
throw new MarketplaceSdkProviderNotFoundError();
|
|
139
|
-
}
|
|
140
|
-
return context;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// src/react/hooks/useCollectionBalanceDetails.tsx
|
|
144
|
-
var filterSchema = z.object({
|
|
145
|
-
accountAddresses: z.array(AddressSchema),
|
|
146
|
-
contractWhitelist: z.array(AddressSchema).optional(),
|
|
147
|
-
omitNativeBalances: z.boolean()
|
|
148
|
-
});
|
|
149
|
-
var useCollectionBalanceDetailsArgsSchema = z.object({
|
|
150
|
-
chainId: z.number(),
|
|
151
|
-
filter: filterSchema,
|
|
152
|
-
query: QueryArgSchema.optional()
|
|
153
|
-
});
|
|
154
|
-
var fetchCollectionBalanceDetails = async (args, indexerClient) => {
|
|
155
|
-
const promises = args.filter.accountAddresses.map(
|
|
156
|
-
(accountAddress) => indexerClient.getTokenBalancesDetails({
|
|
157
|
-
filter: {
|
|
158
|
-
accountAddresses: [accountAddress],
|
|
159
|
-
contractWhitelist: args.filter.contractWhitelist,
|
|
160
|
-
omitNativeBalances: args.filter.omitNativeBalances
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
);
|
|
164
|
-
const responses = await Promise.all(promises);
|
|
165
|
-
const mergedResponse = responses.reduce(
|
|
166
|
-
(acc, curr) => {
|
|
167
|
-
if (!curr) return acc;
|
|
168
|
-
return {
|
|
169
|
-
page: curr.page,
|
|
170
|
-
nativeBalances: [
|
|
171
|
-
...acc.nativeBalances || [],
|
|
172
|
-
...curr.nativeBalances || []
|
|
173
|
-
],
|
|
174
|
-
balances: [...acc.balances || [], ...curr.balances || []]
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
{ page: {}, nativeBalances: [], balances: [] }
|
|
178
|
-
);
|
|
179
|
-
if (!mergedResponse) {
|
|
180
|
-
throw new Error("Failed to fetch collection balance details");
|
|
181
|
-
}
|
|
182
|
-
return mergedResponse;
|
|
183
|
-
};
|
|
184
|
-
var collectionBalanceDetailsOptions = (args, config) => {
|
|
185
|
-
const parsedArgs = useCollectionBalanceDetailsArgsSchema.parse(args);
|
|
186
|
-
const indexerClient = getIndexerClient(parsedArgs.chainId, config);
|
|
187
|
-
return queryOptions({
|
|
188
|
-
queryKey: [...balanceQueries.collectionBalanceDetails, args, config],
|
|
189
|
-
queryFn: () => fetchCollectionBalanceDetails(parsedArgs, indexerClient),
|
|
190
|
-
...args.query
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
var useCollectionBalanceDetails = (args) => {
|
|
194
|
-
const config = useConfig();
|
|
195
|
-
return useQuery(collectionBalanceDetailsOptions(args, config));
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// src/react/hooks/useAutoSelectFeeOption.tsx
|
|
199
|
-
function useAutoSelectFeeOption({
|
|
200
|
-
pendingFeeOptionConfirmation,
|
|
201
|
-
enabled
|
|
202
|
-
}) {
|
|
203
|
-
const { address: userAddress } = useAccount();
|
|
204
|
-
const contractWhitelist = pendingFeeOptionConfirmation.options?.map(
|
|
205
|
-
(option) => option.token.contractAddress === null ? zeroAddress : option.token.contractAddress
|
|
206
|
-
);
|
|
207
|
-
const {
|
|
208
|
-
data: balanceDetails,
|
|
209
|
-
isLoading: isBalanceDetailsLoading,
|
|
210
|
-
isError: isBalanceDetailsError
|
|
211
|
-
} = useCollectionBalanceDetails({
|
|
212
|
-
chainId: pendingFeeOptionConfirmation.chainId,
|
|
213
|
-
filter: {
|
|
214
|
-
accountAddresses: userAddress ? [userAddress] : [],
|
|
215
|
-
contractWhitelist,
|
|
216
|
-
omitNativeBalances: false
|
|
217
|
-
},
|
|
218
|
-
query: {
|
|
219
|
-
enabled: !!pendingFeeOptionConfirmation.options && !!userAddress && enabled
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
const chain = useChain(pendingFeeOptionConfirmation.chainId);
|
|
223
|
-
const combinedBalances = balanceDetails && [
|
|
224
|
-
...balanceDetails.nativeBalances.map((b) => ({
|
|
225
|
-
chainId: pendingFeeOptionConfirmation.chainId,
|
|
226
|
-
balance: b.balance,
|
|
227
|
-
symbol: chain?.nativeCurrency.symbol,
|
|
228
|
-
contractAddress: zeroAddress
|
|
229
|
-
})),
|
|
230
|
-
...balanceDetails.balances.map((b) => ({
|
|
231
|
-
chainId: b.chainId,
|
|
232
|
-
balance: b.balance,
|
|
233
|
-
symbol: b.contractInfo?.symbol,
|
|
234
|
-
contractAddress: b.contractAddress
|
|
235
|
-
}))
|
|
236
|
-
];
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
if (combinedBalances) {
|
|
239
|
-
console.debug("currency balances", combinedBalances);
|
|
240
|
-
}
|
|
241
|
-
}, [combinedBalances]);
|
|
242
|
-
const autoSelectedOption = useCallback(async () => {
|
|
243
|
-
if (!userAddress) {
|
|
244
|
-
return {
|
|
245
|
-
selectedOption: null,
|
|
246
|
-
error: "User not connected" /* UserNotConnected */
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
if (!pendingFeeOptionConfirmation.options) {
|
|
250
|
-
return {
|
|
251
|
-
selectedOption: null,
|
|
252
|
-
error: "No options provided" /* NoOptionsProvided */
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
if (isBalanceDetailsLoading) {
|
|
256
|
-
return { selectedOption: null, error: null, isLoading: true };
|
|
257
|
-
}
|
|
258
|
-
if (isBalanceDetailsError || !combinedBalances) {
|
|
259
|
-
return {
|
|
260
|
-
selectedOption: null,
|
|
261
|
-
error: "Failed to check balances" /* FailedToCheckBalances */
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
const selectedOption = pendingFeeOptionConfirmation.options.find(
|
|
265
|
-
(option) => {
|
|
266
|
-
const tokenBalance = combinedBalances.find(
|
|
267
|
-
(balance) => balance.contractAddress.toLowerCase() === (option.token.contractAddress === null ? zeroAddress : option.token.contractAddress).toLowerCase()
|
|
268
|
-
);
|
|
269
|
-
if (!tokenBalance) return false;
|
|
270
|
-
return BigInt(tokenBalance.balance) >= BigInt(option.value);
|
|
271
|
-
}
|
|
272
|
-
);
|
|
273
|
-
if (!selectedOption) {
|
|
274
|
-
return {
|
|
275
|
-
selectedOption: null,
|
|
276
|
-
error: "Insufficient balance for any fee option" /* InsufficientBalanceForAnyFeeOption */
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
console.debug("auto selected option", selectedOption);
|
|
280
|
-
return { selectedOption, error: null };
|
|
281
|
-
}, [
|
|
282
|
-
userAddress,
|
|
283
|
-
pendingFeeOptionConfirmation.options,
|
|
284
|
-
isBalanceDetailsLoading,
|
|
285
|
-
isBalanceDetailsError,
|
|
286
|
-
combinedBalances
|
|
287
|
-
]);
|
|
288
|
-
return autoSelectedOption();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// src/react/hooks/useBalanceOfCollectible.tsx
|
|
292
|
-
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
293
|
-
|
|
294
|
-
// src/react/hooks/useMarketplaceConfig.tsx
|
|
295
|
-
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
296
|
-
var useMarketplaceConfig = () => {
|
|
297
|
-
const config = useConfig();
|
|
298
|
-
return useQuery2(marketplaceConfigOptions(config));
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// src/react/hooks/useBalanceOfCollectible.tsx
|
|
302
|
-
function useBalanceOfCollectible(args) {
|
|
303
|
-
const config = useConfig();
|
|
304
|
-
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
305
|
-
const isLaos721 = marketplaceConfig?.collections.find(
|
|
306
|
-
(collection) => collection.address === args.collectionAddress
|
|
307
|
-
)?.isLAOSERC721;
|
|
308
|
-
if (isLaos721) {
|
|
309
|
-
args.isLaos721 = true;
|
|
310
|
-
}
|
|
311
|
-
return useQuery3(balanceOfCollectibleOptions(args, config));
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// src/react/hooks/useCountOfCollectables.tsx
|
|
315
|
-
import { queryOptions as queryOptions2, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
316
|
-
import { z as z3 } from "zod";
|
|
317
|
-
|
|
318
|
-
// src/react/_internal/api/zod-schema.ts
|
|
319
|
-
import { z as z2 } from "zod";
|
|
320
|
-
var assetSchema = z2.object({
|
|
321
|
-
id: z2.number(),
|
|
322
|
-
collectionId: z2.number(),
|
|
323
|
-
tokenId: z2.string(),
|
|
324
|
-
url: z2.string().optional(),
|
|
325
|
-
metadataField: z2.string(),
|
|
326
|
-
name: z2.string().optional(),
|
|
327
|
-
filesize: z2.number().optional(),
|
|
328
|
-
mimeType: z2.string().optional(),
|
|
329
|
-
width: z2.number().optional(),
|
|
330
|
-
height: z2.number().optional(),
|
|
331
|
-
updatedAt: z2.string().optional()
|
|
332
|
-
});
|
|
333
|
-
var sortOrderSchema = z2.nativeEnum(SortOrder);
|
|
334
|
-
var propertyTypeSchema = z2.nativeEnum(PropertyType);
|
|
335
|
-
var marketplaceKindSchema = z2.nativeEnum(MarketplaceKind);
|
|
336
|
-
var orderbookKindSchema = z2.nativeEnum(OrderbookKind);
|
|
337
|
-
var sourceKindSchema = z2.nativeEnum(SourceKind);
|
|
338
|
-
var orderSideSchema = z2.nativeEnum(OrderSide);
|
|
339
|
-
var orderStatusSchema = z2.nativeEnum(OrderStatus);
|
|
340
|
-
var contractTypeSchema = z2.nativeEnum(ContractType);
|
|
341
|
-
var collectionStatusSchema = z2.nativeEnum(CollectionStatus);
|
|
342
|
-
var projectStatusSchema = z2.nativeEnum(ProjectStatus);
|
|
343
|
-
var collectibleStatusSchema = z2.nativeEnum(CollectibleStatus);
|
|
344
|
-
var walletKindSchema = z2.nativeEnum(WalletKind);
|
|
345
|
-
var stepTypeSchema = z2.nativeEnum(StepType);
|
|
346
|
-
var transactionCryptoSchema = z2.nativeEnum(TransactionCrypto);
|
|
347
|
-
var transactionNFTCheckoutProviderSchema = z2.nativeEnum(
|
|
348
|
-
TransactionNFTCheckoutProvider
|
|
349
|
-
);
|
|
350
|
-
var transactionOnRampProviderSchema = z2.nativeEnum(
|
|
351
|
-
TransactionOnRampProvider
|
|
352
|
-
);
|
|
353
|
-
var transactionSwapProviderSchema = z2.nativeEnum(
|
|
354
|
-
TransactionSwapProvider
|
|
355
|
-
);
|
|
356
|
-
var sortBySchema = z2.object({
|
|
357
|
-
column: z2.string(),
|
|
358
|
-
order: sortOrderSchema
|
|
359
|
-
});
|
|
360
|
-
var propertyFilterSchema = z2.object({
|
|
361
|
-
name: z2.string(),
|
|
362
|
-
type: propertyTypeSchema,
|
|
363
|
-
min: z2.number().optional(),
|
|
364
|
-
max: z2.number().optional(),
|
|
365
|
-
values: z2.array(z2.any()).optional()
|
|
366
|
-
});
|
|
367
|
-
var collectiblesFilterSchema = z2.object({
|
|
368
|
-
includeEmpty: z2.boolean(),
|
|
369
|
-
searchText: z2.string().optional(),
|
|
370
|
-
properties: z2.array(propertyFilterSchema).optional(),
|
|
371
|
-
marketplaces: z2.array(marketplaceKindSchema).optional(),
|
|
372
|
-
inAccounts: z2.array(z2.string()).optional(),
|
|
373
|
-
notInAccounts: z2.array(z2.string()).optional(),
|
|
374
|
-
ordersCreatedBy: z2.array(z2.string()).optional(),
|
|
375
|
-
ordersNotCreatedBy: z2.array(z2.string()).optional()
|
|
376
|
-
});
|
|
377
|
-
var feeBreakdownSchema = z2.object({
|
|
378
|
-
kind: z2.string(),
|
|
379
|
-
recipientAddress: z2.string(),
|
|
380
|
-
bps: z2.number()
|
|
381
|
-
});
|
|
382
|
-
var orderFilterSchema = z2.object({
|
|
383
|
-
createdBy: z2.array(z2.string()).optional(),
|
|
384
|
-
marketplace: z2.array(marketplaceKindSchema).optional(),
|
|
385
|
-
currencies: z2.array(z2.string()).optional()
|
|
386
|
-
});
|
|
387
|
-
var collectionLastSyncedSchema = z2.object({
|
|
388
|
-
allOrders: z2.string(),
|
|
389
|
-
newOrders: z2.string()
|
|
390
|
-
});
|
|
391
|
-
var projectSchema = z2.object({
|
|
392
|
-
projectId: z2.number(),
|
|
393
|
-
chainId: z2.number(),
|
|
394
|
-
contractAddress: z2.string(),
|
|
395
|
-
status: projectStatusSchema,
|
|
396
|
-
createdAt: z2.string(),
|
|
397
|
-
updatedAt: z2.string(),
|
|
398
|
-
deletedAt: z2.string().optional()
|
|
399
|
-
});
|
|
400
|
-
var collectibleSchema = z2.object({
|
|
401
|
-
chainId: z2.number(),
|
|
402
|
-
contractAddress: z2.string(),
|
|
403
|
-
status: collectibleStatusSchema,
|
|
404
|
-
tokenId: z2.string(),
|
|
405
|
-
createdAt: z2.string(),
|
|
406
|
-
updatedAt: z2.string(),
|
|
407
|
-
deletedAt: z2.string().optional()
|
|
408
|
-
});
|
|
409
|
-
var currencySchema = z2.object({
|
|
410
|
-
chainId: z2.number(),
|
|
411
|
-
contractAddress: z2.string(),
|
|
412
|
-
name: z2.string(),
|
|
413
|
-
symbol: z2.string(),
|
|
414
|
-
decimals: z2.number(),
|
|
415
|
-
imageUrl: z2.string(),
|
|
416
|
-
exchangeRate: z2.number(),
|
|
417
|
-
defaultChainCurrency: z2.boolean(),
|
|
418
|
-
nativeCurrency: z2.boolean(),
|
|
419
|
-
createdAt: z2.string(),
|
|
420
|
-
updatedAt: z2.string(),
|
|
421
|
-
deletedAt: z2.string().optional()
|
|
422
|
-
});
|
|
423
|
-
var orderDataSchema = z2.object({
|
|
424
|
-
orderId: z2.string(),
|
|
425
|
-
quantity: z2.string()
|
|
426
|
-
});
|
|
427
|
-
var additionalFeeSchema = z2.object({
|
|
428
|
-
amount: z2.string(),
|
|
429
|
-
receiver: z2.string()
|
|
430
|
-
});
|
|
431
|
-
var postRequestSchema = z2.object({
|
|
432
|
-
endpoint: z2.string(),
|
|
433
|
-
method: z2.string(),
|
|
434
|
-
body: z2.any()
|
|
435
|
-
});
|
|
436
|
-
var createReqSchema = z2.object({
|
|
437
|
-
tokenId: z2.string(),
|
|
438
|
-
quantity: z2.string(),
|
|
439
|
-
expiry: z2.string(),
|
|
440
|
-
currencyAddress: z2.string(),
|
|
441
|
-
pricePerToken: z2.string()
|
|
442
|
-
});
|
|
443
|
-
var getOrdersInputSchema = z2.object({
|
|
444
|
-
contractAddress: z2.string(),
|
|
445
|
-
orderId: z2.string(),
|
|
446
|
-
marketplace: marketplaceKindSchema
|
|
447
|
-
});
|
|
448
|
-
var domainSchema = z2.object({
|
|
449
|
-
name: z2.string(),
|
|
450
|
-
version: z2.string(),
|
|
451
|
-
chainId: z2.number(),
|
|
452
|
-
verifyingContract: z2.string()
|
|
453
|
-
});
|
|
454
|
-
var checkoutOptionsMarketplaceOrderSchema = z2.object({
|
|
455
|
-
contractAddress: z2.string(),
|
|
456
|
-
orderId: z2.string(),
|
|
457
|
-
marketplace: marketplaceKindSchema
|
|
458
|
-
});
|
|
459
|
-
var checkoutOptionsItemSchema = z2.object({
|
|
460
|
-
tokenId: z2.string(),
|
|
461
|
-
quantity: z2.string()
|
|
462
|
-
});
|
|
463
|
-
var checkoutOptionsSchema = z2.object({
|
|
464
|
-
crypto: transactionCryptoSchema,
|
|
465
|
-
swap: z2.array(transactionSwapProviderSchema),
|
|
466
|
-
nftCheckout: z2.array(transactionNFTCheckoutProviderSchema),
|
|
467
|
-
onRamp: z2.array(transactionOnRampProviderSchema)
|
|
468
|
-
});
|
|
469
|
-
var listCurrenciesArgsSchema = z2.object({});
|
|
470
|
-
var listCurrenciesReturnSchema = z2.object({
|
|
471
|
-
currencies: z2.array(currencySchema)
|
|
472
|
-
});
|
|
473
|
-
var getCollectibleArgsSchema = z2.object({
|
|
474
|
-
contractAddress: z2.string(),
|
|
475
|
-
tokenId: z2.string()
|
|
476
|
-
});
|
|
477
|
-
var getLowestPriceOfferForCollectibleArgsSchema = z2.object({
|
|
478
|
-
contractAddress: z2.string(),
|
|
479
|
-
tokenId: z2.string(),
|
|
480
|
-
filter: orderFilterSchema.optional()
|
|
481
|
-
});
|
|
482
|
-
var getHighestPriceOfferForCollectibleArgsSchema = z2.object({
|
|
483
|
-
contractAddress: z2.string(),
|
|
484
|
-
tokenId: z2.string(),
|
|
485
|
-
filter: orderFilterSchema.optional()
|
|
486
|
-
});
|
|
487
|
-
var getLowestPriceListingForCollectibleArgsSchema = z2.object({
|
|
488
|
-
contractAddress: z2.string(),
|
|
489
|
-
tokenId: z2.string(),
|
|
490
|
-
filter: orderFilterSchema.optional()
|
|
491
|
-
});
|
|
492
|
-
var getHighestPriceListingForCollectibleArgsSchema = z2.object({
|
|
493
|
-
contractAddress: z2.string(),
|
|
494
|
-
tokenId: z2.string(),
|
|
495
|
-
filter: orderFilterSchema.optional()
|
|
496
|
-
});
|
|
497
|
-
var getCollectibleLowestOfferArgsSchema = z2.object({
|
|
498
|
-
contractAddress: z2.string(),
|
|
499
|
-
tokenId: z2.string(),
|
|
500
|
-
filter: orderFilterSchema.optional()
|
|
501
|
-
});
|
|
502
|
-
var getCollectibleHighestOfferArgsSchema = z2.object({
|
|
503
|
-
contractAddress: z2.string(),
|
|
504
|
-
tokenId: z2.string(),
|
|
505
|
-
filter: orderFilterSchema.optional()
|
|
506
|
-
});
|
|
507
|
-
var getCollectibleLowestListingArgsSchema = z2.object({
|
|
508
|
-
contractAddress: z2.string(),
|
|
509
|
-
tokenId: z2.string(),
|
|
510
|
-
filters: orderFilterSchema.optional()
|
|
511
|
-
});
|
|
512
|
-
var getCollectibleHighestListingArgsSchema = z2.object({
|
|
513
|
-
contractAddress: z2.string(),
|
|
514
|
-
tokenId: z2.string(),
|
|
515
|
-
filter: orderFilterSchema.optional()
|
|
516
|
-
});
|
|
517
|
-
var generateBuyTransactionArgsSchema = z2.object({
|
|
518
|
-
collectionAddress: z2.string(),
|
|
519
|
-
buyer: z2.string(),
|
|
520
|
-
marketplace: marketplaceKindSchema,
|
|
521
|
-
ordersData: z2.array(orderDataSchema),
|
|
522
|
-
additionalFees: z2.array(additionalFeeSchema),
|
|
523
|
-
walletType: walletKindSchema.optional()
|
|
524
|
-
});
|
|
525
|
-
var generateSellTransactionArgsSchema = z2.object({
|
|
526
|
-
collectionAddress: z2.string(),
|
|
527
|
-
seller: z2.string(),
|
|
528
|
-
marketplace: marketplaceKindSchema,
|
|
529
|
-
ordersData: z2.array(orderDataSchema),
|
|
530
|
-
additionalFees: z2.array(additionalFeeSchema),
|
|
531
|
-
walletType: walletKindSchema.optional()
|
|
532
|
-
});
|
|
533
|
-
var generateListingTransactionArgsSchema = z2.object({
|
|
534
|
-
collectionAddress: z2.string(),
|
|
535
|
-
owner: z2.string(),
|
|
536
|
-
contractType: contractTypeSchema,
|
|
537
|
-
orderbook: orderbookKindSchema,
|
|
538
|
-
listing: createReqSchema,
|
|
539
|
-
walletType: walletKindSchema.optional()
|
|
540
|
-
});
|
|
541
|
-
var generateOfferTransactionArgsSchema = z2.object({
|
|
542
|
-
collectionAddress: z2.string(),
|
|
543
|
-
maker: z2.string(),
|
|
544
|
-
contractType: contractTypeSchema,
|
|
545
|
-
orderbook: orderbookKindSchema,
|
|
546
|
-
offer: createReqSchema,
|
|
547
|
-
walletType: walletKindSchema.optional()
|
|
548
|
-
});
|
|
549
|
-
var getCountOfAllCollectiblesArgsSchema = z2.object({
|
|
550
|
-
contractAddress: z2.string()
|
|
551
|
-
});
|
|
552
|
-
var getCountOfAllCollectiblesReturnSchema = z2.object({
|
|
553
|
-
count: z2.number()
|
|
554
|
-
});
|
|
555
|
-
var getCountOfFilteredCollectiblesArgsSchema = z2.object({
|
|
556
|
-
side: orderSideSchema,
|
|
557
|
-
contractAddress: z2.string(),
|
|
558
|
-
filter: collectiblesFilterSchema.optional()
|
|
559
|
-
});
|
|
560
|
-
var getCountOfFilteredCollectiblesReturnSchema = z2.object({
|
|
561
|
-
count: z2.number()
|
|
562
|
-
});
|
|
563
|
-
var getFloorOrderArgsSchema = z2.object({
|
|
564
|
-
contractAddress: z2.string(),
|
|
565
|
-
filter: collectiblesFilterSchema.optional()
|
|
566
|
-
});
|
|
567
|
-
var syncOrderReturnSchema = z2.object({});
|
|
568
|
-
var syncOrdersReturnSchema = z2.object({});
|
|
569
|
-
var checkoutOptionsMarketplaceArgsSchema = z2.object({
|
|
570
|
-
wallet: z2.string(),
|
|
571
|
-
orders: z2.array(checkoutOptionsMarketplaceOrderSchema),
|
|
572
|
-
additionalFee: z2.number()
|
|
573
|
-
});
|
|
574
|
-
var checkoutOptionsMarketplaceReturnSchema = z2.object({
|
|
575
|
-
options: checkoutOptionsSchema
|
|
576
|
-
});
|
|
577
|
-
var checkoutOptionsSalesContractArgsSchema = z2.object({
|
|
578
|
-
wallet: z2.string(),
|
|
579
|
-
contractAddress: z2.string(),
|
|
580
|
-
collectionAddress: z2.string(),
|
|
581
|
-
items: z2.array(checkoutOptionsItemSchema)
|
|
582
|
-
});
|
|
583
|
-
var checkoutOptionsSalesContractReturnSchema = z2.object({
|
|
584
|
-
options: checkoutOptionsSchema
|
|
585
|
-
});
|
|
586
|
-
var countListingsForCollectibleArgsSchema = z2.object({
|
|
587
|
-
contractAddress: z2.string(),
|
|
588
|
-
tokenId: z2.string(),
|
|
589
|
-
filter: orderFilterSchema.optional()
|
|
590
|
-
});
|
|
591
|
-
var countListingsForCollectibleReturnSchema = z2.object({
|
|
592
|
-
count: z2.number()
|
|
593
|
-
});
|
|
594
|
-
var countOffersForCollectibleArgsSchema = z2.object({
|
|
595
|
-
contractAddress: z2.string(),
|
|
596
|
-
tokenId: z2.string(),
|
|
597
|
-
filter: orderFilterSchema.optional()
|
|
598
|
-
});
|
|
599
|
-
var countOffersForCollectibleReturnSchema = z2.object({
|
|
600
|
-
count: z2.number()
|
|
601
|
-
});
|
|
602
|
-
var tokenMetadataSchema = z2.object({
|
|
603
|
-
tokenId: z2.string(),
|
|
604
|
-
name: z2.string(),
|
|
605
|
-
description: z2.string().optional(),
|
|
606
|
-
image: z2.string().optional(),
|
|
607
|
-
video: z2.string().optional(),
|
|
608
|
-
audio: z2.string().optional(),
|
|
609
|
-
properties: z2.record(z2.any()).optional(),
|
|
610
|
-
attributes: z2.array(z2.record(z2.any())),
|
|
611
|
-
image_data: z2.string().optional(),
|
|
612
|
-
external_url: z2.string().optional(),
|
|
613
|
-
background_color: z2.string().optional(),
|
|
614
|
-
animation_url: z2.string().optional(),
|
|
615
|
-
decimals: z2.number().optional(),
|
|
616
|
-
updatedAt: z2.string().optional(),
|
|
617
|
-
assets: z2.array(assetSchema).optional()
|
|
618
|
-
});
|
|
619
|
-
var pageSchema = z2.object({
|
|
620
|
-
page: z2.number(),
|
|
621
|
-
pageSize: z2.number(),
|
|
622
|
-
more: z2.boolean().optional(),
|
|
623
|
-
sort: z2.array(sortBySchema).optional()
|
|
624
|
-
});
|
|
625
|
-
var filterSchema2 = z2.object({
|
|
626
|
-
text: z2.string().optional(),
|
|
627
|
-
properties: z2.array(propertyFilterSchema).optional()
|
|
628
|
-
});
|
|
629
|
-
var orderSchema = z2.object({
|
|
630
|
-
orderId: z2.string(),
|
|
631
|
-
marketplace: marketplaceKindSchema,
|
|
632
|
-
side: orderSideSchema,
|
|
633
|
-
status: orderStatusSchema,
|
|
634
|
-
chainId: z2.number(),
|
|
635
|
-
collectionContractAddress: z2.string(),
|
|
636
|
-
tokenId: z2.string(),
|
|
637
|
-
createdBy: z2.string(),
|
|
638
|
-
priceAmount: z2.string(),
|
|
639
|
-
priceAmountFormatted: z2.string(),
|
|
640
|
-
priceAmountNet: z2.string(),
|
|
641
|
-
priceAmountNetFormatted: z2.string(),
|
|
642
|
-
priceCurrencyAddress: z2.string(),
|
|
643
|
-
priceDecimals: z2.number(),
|
|
644
|
-
priceUSD: z2.number(),
|
|
645
|
-
quantityInitial: z2.string(),
|
|
646
|
-
quantityInitialFormatted: z2.string(),
|
|
647
|
-
quantityRemaining: z2.string(),
|
|
648
|
-
quantityRemainingFormatted: z2.string(),
|
|
649
|
-
quantityAvailable: z2.string(),
|
|
650
|
-
quantityAvailableFormatted: z2.string(),
|
|
651
|
-
quantityDecimals: z2.number(),
|
|
652
|
-
feeBps: z2.number(),
|
|
653
|
-
feeBreakdown: z2.array(feeBreakdownSchema),
|
|
654
|
-
validFrom: z2.string(),
|
|
655
|
-
validUntil: z2.string(),
|
|
656
|
-
blockNumber: z2.number(),
|
|
657
|
-
orderCreatedAt: z2.string().optional(),
|
|
658
|
-
orderUpdatedAt: z2.string().optional(),
|
|
659
|
-
createdAt: z2.string(),
|
|
660
|
-
updatedAt: z2.string(),
|
|
661
|
-
deletedAt: z2.string().optional()
|
|
662
|
-
});
|
|
663
|
-
var collectibleOrderSchema = z2.object({
|
|
664
|
-
metadata: tokenMetadataSchema,
|
|
665
|
-
order: orderSchema.optional()
|
|
666
|
-
});
|
|
667
|
-
var activitySchema = z2.object({
|
|
668
|
-
type: z2.string(),
|
|
669
|
-
fromAddress: z2.string(),
|
|
670
|
-
toAddress: z2.string(),
|
|
671
|
-
txHash: z2.string(),
|
|
672
|
-
timestamp: z2.number(),
|
|
673
|
-
tokenId: z2.string(),
|
|
674
|
-
tokenImage: z2.string(),
|
|
675
|
-
tokenName: z2.string(),
|
|
676
|
-
currency: currencySchema.optional()
|
|
677
|
-
});
|
|
678
|
-
var collectionConfigSchema = z2.object({
|
|
679
|
-
lastSynced: z2.record(collectionLastSyncedSchema),
|
|
680
|
-
collectiblesSynced: z2.string()
|
|
681
|
-
});
|
|
682
|
-
var signatureSchema = z2.object({
|
|
683
|
-
domain: domainSchema,
|
|
684
|
-
types: z2.any(),
|
|
685
|
-
primaryType: z2.string(),
|
|
686
|
-
value: z2.any()
|
|
687
|
-
});
|
|
688
|
-
var getCollectibleReturnSchema = z2.object({
|
|
689
|
-
metadata: tokenMetadataSchema
|
|
690
|
-
});
|
|
691
|
-
var getLowestPriceOfferForCollectibleReturnSchema = z2.object({
|
|
692
|
-
order: orderSchema
|
|
693
|
-
});
|
|
694
|
-
var getHighestPriceOfferForCollectibleReturnSchema = z2.object({
|
|
695
|
-
order: orderSchema
|
|
696
|
-
});
|
|
697
|
-
var getLowestPriceListingForCollectibleReturnSchema = z2.object({
|
|
698
|
-
order: orderSchema
|
|
699
|
-
});
|
|
700
|
-
var getHighestPriceListingForCollectibleReturnSchema = z2.object({
|
|
701
|
-
order: orderSchema
|
|
702
|
-
});
|
|
703
|
-
var listListingsForCollectibleArgsSchema = z2.object({
|
|
704
|
-
contractAddress: z2.string(),
|
|
705
|
-
tokenId: z2.string(),
|
|
706
|
-
filter: orderFilterSchema.optional(),
|
|
707
|
-
page: pageSchema.optional()
|
|
708
|
-
});
|
|
709
|
-
var listListingsForCollectibleReturnSchema = z2.object({
|
|
710
|
-
listings: z2.array(orderSchema),
|
|
711
|
-
page: pageSchema.optional()
|
|
712
|
-
});
|
|
713
|
-
var listOffersForCollectibleArgsSchema = z2.object({
|
|
714
|
-
contractAddress: z2.string(),
|
|
715
|
-
tokenId: z2.string(),
|
|
716
|
-
filter: orderFilterSchema.optional(),
|
|
717
|
-
page: pageSchema.optional()
|
|
718
|
-
});
|
|
719
|
-
var listOffersForCollectibleReturnSchema = z2.object({
|
|
720
|
-
offers: z2.array(orderSchema),
|
|
721
|
-
page: pageSchema.optional()
|
|
722
|
-
});
|
|
723
|
-
var getListCollectibleActivitiesArgsSchema = z2.object({
|
|
724
|
-
chainId: z2.number(),
|
|
725
|
-
collectionAddress: AddressSchema,
|
|
726
|
-
tokenId: CollectableIdSchema.pipe(z2.coerce.string()),
|
|
727
|
-
query: pageSchema.extend({
|
|
728
|
-
enabled: z2.boolean().optional()
|
|
729
|
-
}).optional()
|
|
730
|
-
});
|
|
731
|
-
var getListCollectibleActivitiesReturnSchema = z2.object({
|
|
732
|
-
activities: z2.array(activitySchema),
|
|
733
|
-
page: pageSchema.optional()
|
|
734
|
-
});
|
|
735
|
-
var getListCollectionActivitiesArgsSchema = z2.object({
|
|
736
|
-
chainId: z2.number(),
|
|
737
|
-
collectionAddress: AddressSchema,
|
|
738
|
-
query: pageSchema.extend({
|
|
739
|
-
enabled: z2.boolean().optional()
|
|
740
|
-
}).optional()
|
|
741
|
-
});
|
|
742
|
-
var getListCollectionActivitiesReturnSchema = z2.object({
|
|
743
|
-
activities: z2.array(activitySchema),
|
|
744
|
-
page: pageSchema.optional()
|
|
745
|
-
});
|
|
746
|
-
var getCollectibleLowestOfferReturnSchema = z2.object({
|
|
747
|
-
order: orderSchema.optional()
|
|
748
|
-
});
|
|
749
|
-
var getCollectibleHighestOfferReturnSchema = z2.object({
|
|
750
|
-
order: orderSchema.optional()
|
|
751
|
-
});
|
|
752
|
-
var getCollectibleLowestListingReturnSchema = z2.object({
|
|
753
|
-
order: orderSchema.optional()
|
|
754
|
-
});
|
|
755
|
-
var getCollectibleHighestListingReturnSchema = z2.object({
|
|
756
|
-
order: orderSchema.optional()
|
|
757
|
-
});
|
|
758
|
-
var listCollectibleListingsArgsSchema = z2.object({
|
|
759
|
-
contractAddress: z2.string(),
|
|
760
|
-
tokenId: z2.string(),
|
|
761
|
-
filter: orderFilterSchema.optional(),
|
|
762
|
-
page: pageSchema.optional()
|
|
763
|
-
});
|
|
764
|
-
var listCollectibleListingsReturnSchema = z2.object({
|
|
765
|
-
listings: z2.array(orderSchema),
|
|
766
|
-
page: pageSchema.optional()
|
|
767
|
-
});
|
|
768
|
-
var listCollectibleOffersArgsSchema = z2.object({
|
|
769
|
-
contractAddress: z2.string(),
|
|
770
|
-
tokenId: z2.string(),
|
|
771
|
-
filter: orderFilterSchema.optional(),
|
|
772
|
-
page: pageSchema.optional()
|
|
773
|
-
});
|
|
774
|
-
var listCollectibleOffersReturnSchema = z2.object({
|
|
775
|
-
offers: z2.array(orderSchema),
|
|
776
|
-
page: pageSchema.optional()
|
|
777
|
-
});
|
|
778
|
-
var listCollectiblesArgsSchema = z2.object({
|
|
779
|
-
side: orderSideSchema,
|
|
780
|
-
contractAddress: z2.string(),
|
|
781
|
-
filter: collectiblesFilterSchema.optional(),
|
|
782
|
-
page: pageSchema.optional()
|
|
783
|
-
});
|
|
784
|
-
var listCollectiblesReturnSchema = z2.object({
|
|
785
|
-
collectibles: z2.array(collectibleOrderSchema),
|
|
786
|
-
page: pageSchema.optional()
|
|
787
|
-
});
|
|
788
|
-
var getFloorOrderReturnSchema = z2.object({
|
|
789
|
-
collectible: collectibleOrderSchema
|
|
790
|
-
});
|
|
791
|
-
var listCollectiblesWithLowestListingArgsSchema = z2.object({
|
|
792
|
-
contractAddress: z2.string(),
|
|
793
|
-
filter: collectiblesFilterSchema.optional(),
|
|
794
|
-
page: pageSchema.optional()
|
|
795
|
-
});
|
|
796
|
-
var listCollectiblesWithLowestListingReturnSchema = z2.object({
|
|
797
|
-
collectibles: z2.array(collectibleOrderSchema),
|
|
798
|
-
page: pageSchema.optional()
|
|
799
|
-
});
|
|
800
|
-
var listCollectiblesWithHighestOfferArgsSchema = z2.object({
|
|
801
|
-
contractAddress: z2.string(),
|
|
802
|
-
filter: collectiblesFilterSchema.optional(),
|
|
803
|
-
page: pageSchema.optional()
|
|
804
|
-
});
|
|
805
|
-
var listCollectiblesWithHighestOfferReturnSchema = z2.object({
|
|
806
|
-
collectibles: z2.array(collectibleOrderSchema),
|
|
807
|
-
page: pageSchema.optional()
|
|
808
|
-
});
|
|
809
|
-
var syncOrderArgsSchema = z2.object({
|
|
810
|
-
order: orderSchema
|
|
811
|
-
});
|
|
812
|
-
var syncOrdersArgsSchema = z2.object({
|
|
813
|
-
orders: z2.array(orderSchema)
|
|
814
|
-
});
|
|
815
|
-
var getOrdersArgsSchema = z2.object({
|
|
816
|
-
input: z2.array(getOrdersInputSchema),
|
|
817
|
-
page: pageSchema.optional()
|
|
818
|
-
});
|
|
819
|
-
var getOrdersReturnSchema = z2.object({
|
|
820
|
-
orders: z2.array(orderSchema),
|
|
821
|
-
page: pageSchema.optional()
|
|
822
|
-
});
|
|
823
|
-
var collectionSchema = z2.object({
|
|
824
|
-
status: collectionStatusSchema,
|
|
825
|
-
chainId: z2.number(),
|
|
826
|
-
contractAddress: z2.string(),
|
|
827
|
-
contractType: contractTypeSchema,
|
|
828
|
-
tokenQuantityDecimals: z2.number(),
|
|
829
|
-
config: collectionConfigSchema,
|
|
830
|
-
createdAt: z2.string(),
|
|
831
|
-
updatedAt: z2.string(),
|
|
832
|
-
deletedAt: z2.string().optional()
|
|
833
|
-
});
|
|
834
|
-
var stepSchema = z2.object({
|
|
835
|
-
id: z2.nativeEnum(StepType),
|
|
836
|
-
data: z2.string().optional(),
|
|
837
|
-
to: z2.string().optional(),
|
|
838
|
-
value: z2.string().optional(),
|
|
839
|
-
price: z2.string().optional(),
|
|
840
|
-
signature: signatureSchema.optional(),
|
|
841
|
-
post: postRequestSchema.optional(),
|
|
842
|
-
method: z2.string().optional(),
|
|
843
|
-
endpoint: z2.string().optional()
|
|
844
|
-
});
|
|
845
|
-
var generateBuyTransactionReturnSchema = z2.object({
|
|
846
|
-
steps: z2.array(stepSchema)
|
|
847
|
-
});
|
|
848
|
-
var generateSellTransactionReturnSchema = z2.object({
|
|
849
|
-
steps: z2.array(stepSchema)
|
|
850
|
-
});
|
|
851
|
-
var generateListingTransactionReturnSchema = z2.object({
|
|
852
|
-
steps: z2.array(stepSchema)
|
|
853
|
-
});
|
|
854
|
-
var generateOfferTransactionReturnSchema = z2.object({
|
|
855
|
-
steps: z2.array(stepSchema)
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
// src/react/hooks/useCountOfCollectables.tsx
|
|
859
|
-
var BaseSchema = z3.object({
|
|
860
|
-
chainId: z3.number(),
|
|
861
|
-
collectionAddress: AddressSchema,
|
|
862
|
-
query: QueryArgSchema
|
|
863
|
-
});
|
|
864
|
-
var UseCountOfCollectableSchema = BaseSchema.extend({
|
|
865
|
-
filter: collectiblesFilterSchema,
|
|
866
|
-
side: z3.nativeEnum(OrderSide)
|
|
867
|
-
}).or(
|
|
868
|
-
BaseSchema.extend({
|
|
869
|
-
filter: z3.undefined(),
|
|
870
|
-
side: z3.undefined()
|
|
871
|
-
})
|
|
872
|
-
);
|
|
873
|
-
var fetchCountOfCollectables = async (args, config) => {
|
|
874
|
-
const parsedArgs = UseCountOfCollectableSchema.parse(args);
|
|
875
|
-
const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
|
|
876
|
-
if (parsedArgs.filter) {
|
|
877
|
-
return marketplaceClient.getCountOfFilteredCollectibles({
|
|
878
|
-
...parsedArgs,
|
|
879
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
880
|
-
// biome-ignore lint/style/noNonNullAssertion: safe to assert here, as it's validated
|
|
881
|
-
side: parsedArgs.side
|
|
882
|
-
}).then((resp) => resp.count);
|
|
883
|
-
}
|
|
884
|
-
return marketplaceClient.getCountOfAllCollectibles({
|
|
885
|
-
...parsedArgs,
|
|
886
|
-
contractAddress: parsedArgs.collectionAddress
|
|
887
|
-
}).then((resp) => resp.count);
|
|
888
|
-
};
|
|
889
|
-
var countOfCollectablesOptions = (args, config) => {
|
|
890
|
-
return queryOptions2({
|
|
891
|
-
...args.query,
|
|
892
|
-
queryKey: [...collectableKeys.counts, args],
|
|
893
|
-
queryFn: () => fetchCountOfCollectables(args, config)
|
|
894
|
-
});
|
|
895
|
-
};
|
|
896
|
-
var useCountOfCollectables = (args) => {
|
|
897
|
-
const config = useConfig();
|
|
898
|
-
return useQuery4(countOfCollectablesOptions(args, config));
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
// src/react/hooks/useCollectible.tsx
|
|
902
|
-
import { queryOptions as queryOptions3, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
903
|
-
import { z as z4 } from "zod";
|
|
904
|
-
var UseCollectibleSchema = z4.object({
|
|
905
|
-
chainId: z4.number(),
|
|
906
|
-
collectionAddress: AddressSchema,
|
|
907
|
-
collectibleId: z4.string().optional(),
|
|
908
|
-
query: QueryArgSchema
|
|
909
|
-
});
|
|
910
|
-
var fetchCollectible = async (args, config) => {
|
|
911
|
-
const parsedArgs = UseCollectibleSchema.parse(args);
|
|
912
|
-
const metadataClient = getMetadataClient(config);
|
|
913
|
-
const tokenIds = parsedArgs.collectibleId ? [parsedArgs.collectibleId] : [];
|
|
914
|
-
return metadataClient.getTokenMetadata({
|
|
915
|
-
chainID: parsedArgs.chainId.toString(),
|
|
916
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
917
|
-
tokenIDs: tokenIds
|
|
918
|
-
}).then((resp) => resp.tokenMetadata[0]);
|
|
919
|
-
};
|
|
920
|
-
var collectibleOptions = (args, config) => {
|
|
921
|
-
return queryOptions3({
|
|
922
|
-
...args.query,
|
|
923
|
-
queryKey: [...collectableKeys.details, args, config],
|
|
924
|
-
queryFn: () => fetchCollectible(args, config)
|
|
925
|
-
});
|
|
926
|
-
};
|
|
927
|
-
var useCollectible = (args) => {
|
|
928
|
-
const config = useConfig();
|
|
929
|
-
return useQuery5(collectibleOptions(args, config));
|
|
930
|
-
};
|
|
931
|
-
|
|
932
|
-
// src/react/hooks/useCollection.tsx
|
|
933
|
-
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
934
|
-
var useCollection = (args) => {
|
|
935
|
-
const config = useConfig();
|
|
936
|
-
return useQuery6(collectionOptions(args, config));
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
// src/react/hooks/useComparePrices.tsx
|
|
940
|
-
import { queryOptions as queryOptions6, useQuery as useQuery9 } from "@tanstack/react-query";
|
|
941
|
-
import { z as z7 } from "zod";
|
|
942
|
-
|
|
943
|
-
// src/react/hooks/useConvertPriceToUSD.tsx
|
|
944
|
-
import { queryOptions as queryOptions5, useQuery as useQuery8 } from "@tanstack/react-query";
|
|
945
|
-
import { formatUnits } from "viem";
|
|
946
|
-
import { z as z6 } from "zod";
|
|
947
|
-
|
|
948
|
-
// src/react/hooks/useCurrencies.tsx
|
|
949
|
-
import { queryOptions as queryOptions4, useQuery as useQuery7 } from "@tanstack/react-query";
|
|
950
|
-
import { zeroAddress as zeroAddress2 } from "viem";
|
|
951
|
-
import { z as z5 } from "zod";
|
|
952
|
-
var UseCurrenciesArgsSchema = z5.object({
|
|
953
|
-
chainId: z5.number(),
|
|
954
|
-
includeNativeCurrency: z5.boolean().optional().default(true),
|
|
955
|
-
collectionAddress: AddressSchema.optional(),
|
|
956
|
-
query: QueryArgSchema
|
|
957
|
-
});
|
|
958
|
-
var fetchCurrencies = async (args, config) => {
|
|
959
|
-
const parsedArgs = UseCurrenciesArgsSchema.parse(args);
|
|
960
|
-
const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
|
|
961
|
-
let currencies = await marketplaceClient.listCurrencies().then(
|
|
962
|
-
(resp) => resp.currencies.map((currency) => ({
|
|
963
|
-
...currency,
|
|
964
|
-
contractAddress: currency.contractAddress || zeroAddress2
|
|
965
|
-
}))
|
|
966
|
-
);
|
|
967
|
-
if (parsedArgs.collectionAddress) {
|
|
968
|
-
const queryClient = getQueryClient();
|
|
969
|
-
const marketplaceConfig = await queryClient.fetchQuery(
|
|
970
|
-
marketplaceConfigOptions(config)
|
|
971
|
-
);
|
|
972
|
-
const currenciesOptions2 = marketplaceConfig.collections.find(
|
|
973
|
-
(collection) => collection.address === args.collectionAddress
|
|
974
|
-
)?.currencyOptions;
|
|
975
|
-
if (currenciesOptions2) {
|
|
976
|
-
currencies = currencies.filter(
|
|
977
|
-
(currency) => currenciesOptions2.includes(currency.contractAddress)
|
|
978
|
-
);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
if (!parsedArgs.includeNativeCurrency) {
|
|
982
|
-
currencies = currencies.filter((currency) => !currency.nativeCurrency);
|
|
983
|
-
}
|
|
984
|
-
return currencies;
|
|
985
|
-
};
|
|
986
|
-
var currenciesOptions = (args, config) => {
|
|
987
|
-
return queryOptions4({
|
|
988
|
-
...args.query,
|
|
989
|
-
queryKey: [...currencyKeys.lists, args],
|
|
990
|
-
queryFn: () => fetchCurrencies(args, config),
|
|
991
|
-
enabled: args.query?.enabled
|
|
992
|
-
});
|
|
993
|
-
};
|
|
994
|
-
var useCurrencies = (args) => {
|
|
995
|
-
const config = useConfig();
|
|
996
|
-
return useQuery7(currenciesOptions(args, config));
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
// src/react/hooks/useConvertPriceToUSD.tsx
|
|
1000
|
-
var UseConvertPriceToUSDArgsSchema = z6.object({
|
|
1001
|
-
chainId: z6.number(),
|
|
1002
|
-
currencyAddress: AddressSchema,
|
|
1003
|
-
amountRaw: z6.string(),
|
|
1004
|
-
query: QueryArgSchema
|
|
1005
|
-
});
|
|
1006
|
-
var convertPriceToUSD = async (args, config) => {
|
|
1007
|
-
const parsedArgs = UseConvertPriceToUSDArgsSchema.parse(args);
|
|
1008
|
-
const queryClient = getQueryClient();
|
|
1009
|
-
const currencies = await queryClient.fetchQuery(
|
|
1010
|
-
currenciesOptions(
|
|
1011
|
-
{
|
|
1012
|
-
chainId: parsedArgs.chainId
|
|
1013
|
-
},
|
|
1014
|
-
config
|
|
1015
|
-
)
|
|
1016
|
-
);
|
|
1017
|
-
const currencyDetails = currencies.find(
|
|
1018
|
-
(c) => c.contractAddress.toLowerCase() === parsedArgs.currencyAddress.toLowerCase()
|
|
1019
|
-
);
|
|
1020
|
-
if (!currencyDetails) {
|
|
1021
|
-
throw new Error("Currency not found");
|
|
1022
|
-
}
|
|
1023
|
-
const amountDecimal = Number(
|
|
1024
|
-
formatUnits(BigInt(parsedArgs.amountRaw), currencyDetails.decimals)
|
|
1025
|
-
);
|
|
1026
|
-
const usdAmount = amountDecimal * currencyDetails.exchangeRate;
|
|
1027
|
-
return {
|
|
1028
|
-
usdAmount,
|
|
1029
|
-
usdAmountFormatted: usdAmount.toFixed(2)
|
|
1030
|
-
};
|
|
1031
|
-
};
|
|
1032
|
-
var convertPriceToUSDOptions = (args, config) => {
|
|
1033
|
-
return queryOptions5({
|
|
1034
|
-
...args.query,
|
|
1035
|
-
queryKey: [
|
|
1036
|
-
...currencyKeys.conversion,
|
|
1037
|
-
args.chainId,
|
|
1038
|
-
args.currencyAddress,
|
|
1039
|
-
args.amountRaw
|
|
1040
|
-
],
|
|
1041
|
-
queryFn: () => convertPriceToUSD(args, config)
|
|
1042
|
-
});
|
|
1043
|
-
};
|
|
1044
|
-
var useConvertPriceToUSD = (args) => {
|
|
1045
|
-
const config = useConfig();
|
|
1046
|
-
return useQuery8(convertPriceToUSDOptions(args, config));
|
|
1047
|
-
};
|
|
1048
|
-
|
|
1049
|
-
// src/react/hooks/useComparePrices.tsx
|
|
1050
|
-
var UseComparePricesArgsSchema = z7.object({
|
|
1051
|
-
chainId: z7.number(),
|
|
1052
|
-
// First price details
|
|
1053
|
-
priceAmountRaw: z7.string(),
|
|
1054
|
-
priceCurrencyAddress: AddressSchema,
|
|
1055
|
-
// Second price details (to compare against)
|
|
1056
|
-
compareToPriceAmountRaw: z7.string(),
|
|
1057
|
-
compareToPriceCurrencyAddress: AddressSchema,
|
|
1058
|
-
query: QueryArgSchema
|
|
1059
|
-
});
|
|
1060
|
-
var comparePrices = async (args, config) => {
|
|
1061
|
-
const parsedArgs = UseComparePricesArgsSchema.parse(args);
|
|
1062
|
-
const [priceUSD, compareToPriceUSD] = await Promise.all([
|
|
1063
|
-
convertPriceToUSD(
|
|
1064
|
-
{
|
|
1065
|
-
chainId: parsedArgs.chainId,
|
|
1066
|
-
currencyAddress: parsedArgs.priceCurrencyAddress,
|
|
1067
|
-
amountRaw: parsedArgs.priceAmountRaw,
|
|
1068
|
-
query: {}
|
|
1069
|
-
},
|
|
1070
|
-
config
|
|
1071
|
-
),
|
|
1072
|
-
convertPriceToUSD(
|
|
1073
|
-
{
|
|
1074
|
-
chainId: parsedArgs.chainId,
|
|
1075
|
-
currencyAddress: parsedArgs.compareToPriceCurrencyAddress,
|
|
1076
|
-
amountRaw: parsedArgs.compareToPriceAmountRaw,
|
|
1077
|
-
query: {}
|
|
1078
|
-
},
|
|
1079
|
-
config
|
|
1080
|
-
)
|
|
1081
|
-
]);
|
|
1082
|
-
const difference = priceUSD.usdAmount - compareToPriceUSD.usdAmount;
|
|
1083
|
-
if (compareToPriceUSD.usdAmount === 0) {
|
|
1084
|
-
throw new Error("Cannot compare to zero price");
|
|
1085
|
-
}
|
|
1086
|
-
const percentageDifference = difference / compareToPriceUSD.usdAmount * 100;
|
|
1087
|
-
const isAbove = percentageDifference > 0;
|
|
1088
|
-
const isSame = percentageDifference === 0;
|
|
1089
|
-
return {
|
|
1090
|
-
percentageDifference,
|
|
1091
|
-
percentageDifferenceFormatted: Math.abs(percentageDifference).toFixed(2),
|
|
1092
|
-
status: isAbove ? "above" : isSame ? "same" : "below"
|
|
1093
|
-
};
|
|
1094
|
-
};
|
|
1095
|
-
var comparePricesOptions = (args, config) => {
|
|
1096
|
-
return queryOptions6({
|
|
1097
|
-
...args.query,
|
|
1098
|
-
queryKey: [...currencyKeys.conversion, "compare", args],
|
|
1099
|
-
queryFn: () => comparePrices(args, config)
|
|
1100
|
-
});
|
|
1101
|
-
};
|
|
1102
|
-
var useComparePrices = (args) => {
|
|
1103
|
-
const config = useConfig();
|
|
1104
|
-
return useQuery9(comparePricesOptions(args, config));
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
// src/react/hooks/useCurrency.tsx
|
|
1108
|
-
import { queryOptions as queryOptions7, skipToken, useQuery as useQuery10 } from "@tanstack/react-query";
|
|
1109
|
-
import { z as z8 } from "zod";
|
|
1110
|
-
var UseCurrencyArgsSchema = z8.object({
|
|
1111
|
-
chainId: z8.number(),
|
|
1112
|
-
currencyAddress: AddressSchema.optional(),
|
|
1113
|
-
query: QueryArgSchema
|
|
1114
|
-
});
|
|
1115
|
-
var fetchCurrency = async (chainId, currencyAddress, config) => {
|
|
1116
|
-
const queryClient = getQueryClient();
|
|
1117
|
-
let currencies = queryClient.getQueryData([...currencyKeys.lists, chainId]);
|
|
1118
|
-
if (!currencies) {
|
|
1119
|
-
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
1120
|
-
currencies = await marketplaceClient.listCurrencies().then((resp) => resp.currencies);
|
|
1121
|
-
}
|
|
1122
|
-
if (!currencies?.length) {
|
|
1123
|
-
throw new Error("No currencies returned");
|
|
1124
|
-
}
|
|
1125
|
-
const currency = currencies.find(
|
|
1126
|
-
(currency2) => currency2.contractAddress.toLowerCase() === currencyAddress.toLowerCase()
|
|
1127
|
-
);
|
|
1128
|
-
if (!currency) {
|
|
1129
|
-
throw new Error("Currency not found");
|
|
1130
|
-
}
|
|
1131
|
-
return currency;
|
|
1132
|
-
};
|
|
1133
|
-
var currencyOptions = (args, config) => {
|
|
1134
|
-
const { chainId, currencyAddress } = args;
|
|
1135
|
-
return queryOptions7({
|
|
1136
|
-
...args.query,
|
|
1137
|
-
queryKey: [...currencyKeys.details, args.chainId, args.currencyAddress],
|
|
1138
|
-
queryFn: chainId && currencyAddress ? () => fetchCurrency(chainId, currencyAddress, config) : skipToken
|
|
1139
|
-
});
|
|
1140
|
-
};
|
|
1141
|
-
var useCurrency = (args) => {
|
|
1142
|
-
const config = useConfig();
|
|
1143
|
-
return useQuery10(currencyOptions(args, config));
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
// src/react/hooks/useFilters.tsx
|
|
1147
|
-
import { queryOptions as queryOptions8, useQuery as useQuery11 } from "@tanstack/react-query";
|
|
1148
|
-
import { z as z9 } from "zod";
|
|
1149
|
-
var UseFiltersSchema = z9.object({
|
|
1150
|
-
chainId: z9.number(),
|
|
1151
|
-
collectionAddress: AddressSchema,
|
|
1152
|
-
showAllFilters: z9.boolean().default(false).optional(),
|
|
1153
|
-
query: QueryArgSchema,
|
|
1154
|
-
excludePropertyValues: z9.boolean().default(false).optional()
|
|
1155
|
-
});
|
|
1156
|
-
var fetchFilters = async (args, config) => {
|
|
1157
|
-
const parsedArgs = UseFiltersSchema.parse(args);
|
|
1158
|
-
const metadataClient = getMetadataClient(config);
|
|
1159
|
-
const filters = await metadataClient.getTokenMetadataPropertyFilters({
|
|
1160
|
-
chainID: parsedArgs.chainId.toString(),
|
|
1161
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
1162
|
-
excludeProperties: [],
|
|
1163
|
-
// TODO: We can leverage this for some of the exclusion logic
|
|
1164
|
-
excludePropertyValues: parsedArgs.excludePropertyValues
|
|
1165
|
-
}).then((resp) => resp.filters);
|
|
1166
|
-
if (args.showAllFilters) return filters;
|
|
1167
|
-
const queryClient = getQueryClient();
|
|
1168
|
-
const marketplaceConfig = await queryClient.fetchQuery(
|
|
1169
|
-
marketplaceConfigOptions(config)
|
|
1170
|
-
);
|
|
1171
|
-
const collectionFilters = marketplaceConfig.collections.find(
|
|
1172
|
-
(c) => compareAddress(c.address, parsedArgs.collectionAddress)
|
|
1173
|
-
)?.filterSettings;
|
|
1174
|
-
if (!collectionFilters?.exclusions || collectionFilters.exclusions.length === 0 || !collectionFilters.filterOrder || collectionFilters.filterOrder.length === 0)
|
|
1175
|
-
return filters;
|
|
1176
|
-
const { filterOrder, exclusions } = collectionFilters;
|
|
1177
|
-
const sortedFilters = filters.toSorted((a, b) => {
|
|
1178
|
-
const aIndex = filterOrder.indexOf(a.name) > -1 ? filterOrder.indexOf(a.name) : filterOrder.length;
|
|
1179
|
-
const bIndex = filterOrder.indexOf(b.name) > -1 ? filterOrder.indexOf(b.name) : filterOrder.length;
|
|
1180
|
-
return aIndex - bIndex;
|
|
1181
|
-
});
|
|
1182
|
-
const filteredResults = sortedFilters.reduce(
|
|
1183
|
-
(acc, filter) => {
|
|
1184
|
-
const exclusionRule = exclusions.find((rule) => rule.key === filter.name);
|
|
1185
|
-
if (!exclusionRule) {
|
|
1186
|
-
acc.push(filter);
|
|
1187
|
-
return acc;
|
|
1188
|
-
}
|
|
1189
|
-
if (exclusionRule.condition === "ENTIRE_KEY" /* ENTIRE_KEY */) {
|
|
1190
|
-
return acc;
|
|
1191
|
-
}
|
|
1192
|
-
if (exclusionRule.condition === "SPECIFIC_VALUE" /* SPECIFIC_VALUE */ && exclusionRule.value) {
|
|
1193
|
-
const filteredValues = filter.values?.filter((value) => value !== exclusionRule.value) || [];
|
|
1194
|
-
if (filteredValues.length > 0) {
|
|
1195
|
-
acc.push({ ...filter, values: filteredValues });
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
return acc;
|
|
1199
|
-
},
|
|
1200
|
-
[]
|
|
1201
|
-
);
|
|
1202
|
-
return filteredResults;
|
|
1203
|
-
};
|
|
1204
|
-
var filtersOptions = (args, config) => {
|
|
1205
|
-
return queryOptions8({
|
|
1206
|
-
...args.query,
|
|
1207
|
-
queryKey: [...collectableKeys.filter, args, config],
|
|
1208
|
-
queryFn: () => fetchFilters(args, config)
|
|
1209
|
-
});
|
|
1210
|
-
};
|
|
1211
|
-
var useFilters = (args) => {
|
|
1212
|
-
const config = useConfig();
|
|
1213
|
-
return useQuery11(filtersOptions(args, config));
|
|
1214
|
-
};
|
|
1215
|
-
var useFiltersProgressive = (args) => {
|
|
1216
|
-
const config = useConfig();
|
|
1217
|
-
const namesQuery = useQuery11(
|
|
1218
|
-
filtersOptions({ ...args, excludePropertyValues: true }, config)
|
|
1219
|
-
);
|
|
1220
|
-
const fullQuery = useQuery11({
|
|
1221
|
-
...filtersOptions(args, config),
|
|
1222
|
-
placeholderData: namesQuery.data
|
|
1223
|
-
});
|
|
1224
|
-
const isLoadingNames = namesQuery.isLoading;
|
|
1225
|
-
const isFetchingValues = fullQuery.isPlaceholderData && fullQuery.isFetching;
|
|
1226
|
-
return {
|
|
1227
|
-
...fullQuery,
|
|
1228
|
-
isFetchingValues,
|
|
1229
|
-
isLoadingNames
|
|
1230
|
-
};
|
|
1231
|
-
};
|
|
1232
|
-
|
|
1233
|
-
// src/react/hooks/useFilterState.tsx
|
|
1234
|
-
import { useMemo } from "react";
|
|
1235
|
-
import {
|
|
1236
|
-
createSerializer,
|
|
1237
|
-
parseAsBoolean,
|
|
1238
|
-
parseAsJson,
|
|
1239
|
-
parseAsString,
|
|
1240
|
-
useQueryState
|
|
1241
|
-
} from "nuqs";
|
|
1242
|
-
var validateFilters = (value) => {
|
|
1243
|
-
if (!Array.isArray(value)) return [];
|
|
1244
|
-
return value.filter(
|
|
1245
|
-
(f) => typeof f === "object" && typeof f.name === "string" && Object.values(PropertyType).includes(f.type)
|
|
1246
|
-
);
|
|
1247
|
-
};
|
|
1248
|
-
var filtersParser = parseAsJson(validateFilters).withDefault([]);
|
|
1249
|
-
var searchParser = parseAsString.withDefault("");
|
|
1250
|
-
var listedOnlyParser = parseAsBoolean.withDefault(false);
|
|
1251
|
-
var serialize = createSerializer(
|
|
1252
|
-
{
|
|
1253
|
-
filters: filtersParser,
|
|
1254
|
-
search: searchParser,
|
|
1255
|
-
listedOnly: listedOnlyParser
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
urlKeys: {
|
|
1259
|
-
filters: "f",
|
|
1260
|
-
search: "q",
|
|
1261
|
-
listedOnly: "l"
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
);
|
|
1265
|
-
function useFilterState() {
|
|
1266
|
-
const [filterOptions, setFilterOptions] = useQueryState(
|
|
1267
|
-
"filters",
|
|
1268
|
-
filtersParser
|
|
1269
|
-
);
|
|
1270
|
-
const [searchText, setSearchText] = useQueryState("search", searchParser);
|
|
1271
|
-
const [showListedOnly, setShowListedOnly] = useQueryState(
|
|
1272
|
-
"listedOnly",
|
|
1273
|
-
listedOnlyParser
|
|
1274
|
-
);
|
|
1275
|
-
const helpers = useMemo(
|
|
1276
|
-
() => ({
|
|
1277
|
-
getFilter: (name) => {
|
|
1278
|
-
return filterOptions?.find((f) => f.name === name);
|
|
1279
|
-
},
|
|
1280
|
-
getFilterValues: (name) => {
|
|
1281
|
-
const filter = filterOptions?.find((f) => f.name === name);
|
|
1282
|
-
if (!filter) return void 0;
|
|
1283
|
-
if (filter.type === "INT" /* INT */) {
|
|
1284
|
-
return {
|
|
1285
|
-
type: "INT" /* INT */,
|
|
1286
|
-
min: filter.min ?? 0,
|
|
1287
|
-
max: filter.max ?? 0
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
return {
|
|
1291
|
-
type: "STRING" /* STRING */,
|
|
1292
|
-
values: filter.values ?? []
|
|
1293
|
-
};
|
|
1294
|
-
},
|
|
1295
|
-
isFilterActive: (name) => {
|
|
1296
|
-
return !!filterOptions?.find((f) => f.name === name);
|
|
1297
|
-
},
|
|
1298
|
-
isStringValueSelected: (name, value) => {
|
|
1299
|
-
const filter = filterOptions?.find((f) => f.name === name);
|
|
1300
|
-
if (!filter || filter.type !== "STRING" /* STRING */) return false;
|
|
1301
|
-
return filter.values?.includes(value) ?? false;
|
|
1302
|
-
},
|
|
1303
|
-
isIntFilterActive: (name) => {
|
|
1304
|
-
const filter = filterOptions?.find((f) => f.name === name);
|
|
1305
|
-
return !!filter && filter.type === "INT" /* INT */;
|
|
1306
|
-
},
|
|
1307
|
-
getIntFilterRange: (name) => {
|
|
1308
|
-
const filter = filterOptions?.find((f) => f.name === name);
|
|
1309
|
-
if (!filter || filter.type !== "INT" /* INT */) return void 0;
|
|
1310
|
-
return [filter.min ?? 0, filter.max ?? 0];
|
|
1311
|
-
},
|
|
1312
|
-
deleteFilter: (name) => {
|
|
1313
|
-
const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
|
|
1314
|
-
setFilterOptions(otherFilters);
|
|
1315
|
-
},
|
|
1316
|
-
toggleStringFilterValue: (name, value) => {
|
|
1317
|
-
const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
|
|
1318
|
-
const filter = filterOptions?.find((f) => f.name === name);
|
|
1319
|
-
const existingValues = filter?.type === "STRING" /* STRING */ ? filter.values ?? [] : [];
|
|
1320
|
-
if (existingValues.includes(value)) {
|
|
1321
|
-
const newValues = existingValues.filter((v) => v !== value);
|
|
1322
|
-
if (newValues.length === 0) {
|
|
1323
|
-
setFilterOptions(otherFilters);
|
|
1324
|
-
return;
|
|
1325
|
-
}
|
|
1326
|
-
setFilterOptions([
|
|
1327
|
-
...otherFilters,
|
|
1328
|
-
{ name, type: "STRING" /* STRING */, values: newValues }
|
|
1329
|
-
]);
|
|
1330
|
-
} else {
|
|
1331
|
-
setFilterOptions([
|
|
1332
|
-
...otherFilters,
|
|
1333
|
-
{
|
|
1334
|
-
name,
|
|
1335
|
-
type: "STRING" /* STRING */,
|
|
1336
|
-
values: [...existingValues, value]
|
|
1337
|
-
}
|
|
1338
|
-
]);
|
|
1339
|
-
}
|
|
1340
|
-
},
|
|
1341
|
-
setIntFilterValue: (name, min, max) => {
|
|
1342
|
-
if (min === max && min === 0) {
|
|
1343
|
-
const otherFilters2 = filterOptions?.filter((f) => !(f.name === name)) ?? [];
|
|
1344
|
-
setFilterOptions(otherFilters2);
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1347
|
-
const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
|
|
1348
|
-
setFilterOptions([
|
|
1349
|
-
...otherFilters,
|
|
1350
|
-
{ name, type: "INT" /* INT */, min, max }
|
|
1351
|
-
]);
|
|
1352
|
-
},
|
|
1353
|
-
clearAllFilters: () => {
|
|
1354
|
-
void setShowListedOnly(false);
|
|
1355
|
-
void setFilterOptions([]);
|
|
1356
|
-
void setSearchText("");
|
|
1357
|
-
}
|
|
1358
|
-
}),
|
|
1359
|
-
[filterOptions, setFilterOptions, setShowListedOnly, setSearchText]
|
|
1360
|
-
);
|
|
1361
|
-
return {
|
|
1362
|
-
filterOptions,
|
|
1363
|
-
searchText,
|
|
1364
|
-
showListedOnly,
|
|
1365
|
-
setFilterOptions,
|
|
1366
|
-
setSearchText,
|
|
1367
|
-
setShowListedOnly,
|
|
1368
|
-
...helpers,
|
|
1369
|
-
serialize
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
// src/react/hooks/useFloorOrder.tsx
|
|
1374
|
-
import { queryOptions as queryOptions9, useQuery as useQuery12 } from "@tanstack/react-query";
|
|
1375
|
-
import { z as z10 } from "zod";
|
|
1376
|
-
var UseFloorOrderSchema = z10.object({
|
|
1377
|
-
chainId: z10.number(),
|
|
1378
|
-
collectionAddress: AddressSchema,
|
|
1379
|
-
query: QueryArgSchema
|
|
1380
|
-
});
|
|
1381
|
-
var fetchFloorOrder = async (args, config) => {
|
|
1382
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1383
|
-
return marketplaceClient.getFloorOrder({ contractAddress: args.collectionAddress }).then((data) => data.collectible);
|
|
1384
|
-
};
|
|
1385
|
-
var floorOrderOptions = (args, config) => {
|
|
1386
|
-
return queryOptions9({
|
|
1387
|
-
queryKey: [...collectableKeys.floorOrders, args, config],
|
|
1388
|
-
queryFn: () => fetchFloorOrder(args, config)
|
|
1389
|
-
});
|
|
1390
|
-
};
|
|
1391
|
-
var useFloorOrder = (args) => {
|
|
1392
|
-
const config = useConfig();
|
|
1393
|
-
return useQuery12(floorOrderOptions(args, config));
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
// src/react/hooks/useHighestOffer.tsx
|
|
1397
|
-
import { useQuery as useQuery13 } from "@tanstack/react-query";
|
|
1398
|
-
function useHighestOffer(args) {
|
|
1399
|
-
const config = useConfig();
|
|
1400
|
-
return useQuery13(highestOfferOptions(args, config));
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
// src/react/hooks/useInventory.tsx
|
|
1404
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1405
|
-
function useInventory(args) {
|
|
1406
|
-
const config = useConfig();
|
|
1407
|
-
const marketplaceConfig = useMarketplaceConfig();
|
|
1408
|
-
const isLaos721 = marketplaceConfig.data?.collections.find(
|
|
1409
|
-
(c) => c.address === args.collectionAddress
|
|
1410
|
-
)?.isLAOSERC721 ?? false;
|
|
1411
|
-
return useInfiniteQuery(inventoryOptions({ ...args, isLaos721 }, config));
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
// src/react/hooks/useListBalances.tsx
|
|
1415
|
-
import { useInfiniteQuery as useInfiniteQuery2 } from "@tanstack/react-query";
|
|
1416
|
-
function useListBalances(args) {
|
|
1417
|
-
const config = useConfig();
|
|
1418
|
-
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
1419
|
-
const isLaos721 = marketplaceConfig?.collections.find(
|
|
1420
|
-
(collection) => collection.address === args.contractAddress
|
|
1421
|
-
)?.isLAOSERC721;
|
|
1422
|
-
if (isLaos721) {
|
|
1423
|
-
args.isLaos721 = true;
|
|
1424
|
-
}
|
|
1425
|
-
return useInfiniteQuery2(listBalancesOptions(args, config));
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
// src/react/hooks/useListCollectibleActivities.tsx
|
|
1429
|
-
import { queryOptions as queryOptions10, useQuery as useQuery14 } from "@tanstack/react-query";
|
|
1430
|
-
var fetchCollectibleActivities = async (args, config) => {
|
|
1431
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1432
|
-
return marketplaceClient.listCollectibleActivities({
|
|
1433
|
-
contractAddress: args.collectionAddress,
|
|
1434
|
-
tokenId: args.tokenId,
|
|
1435
|
-
page: args.query?.enabled ? {
|
|
1436
|
-
page: args.query.page ?? 1,
|
|
1437
|
-
pageSize: args.query.pageSize ?? 10,
|
|
1438
|
-
sort: args.query.sort
|
|
1439
|
-
} : void 0
|
|
1440
|
-
}).then((data) => ({
|
|
1441
|
-
activities: data.activities,
|
|
1442
|
-
page: data.page
|
|
1443
|
-
}));
|
|
1444
|
-
};
|
|
1445
|
-
var listCollectibleActivitiesOptions = (args, config) => {
|
|
1446
|
-
return queryOptions10({
|
|
1447
|
-
queryKey: [...collectableKeys.collectibleActivities, args, config],
|
|
1448
|
-
queryFn: () => fetchCollectibleActivities(args, config),
|
|
1449
|
-
enabled: args.query?.enabled ?? true
|
|
1450
|
-
});
|
|
1451
|
-
};
|
|
1452
|
-
var useListCollectibleActivities = (args) => {
|
|
1453
|
-
const config = useConfig();
|
|
1454
|
-
return useQuery14(listCollectibleActivitiesOptions(args, config));
|
|
1455
|
-
};
|
|
1456
|
-
|
|
1457
|
-
// src/react/hooks/useListCollectibles.tsx
|
|
1458
|
-
import { useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
|
|
1459
|
-
function useListCollectibles(args) {
|
|
1460
|
-
const config = useConfig();
|
|
1461
|
-
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
1462
|
-
const isLaos721 = marketplaceConfig?.collections.find(
|
|
1463
|
-
(collection) => collection.address === args.collectionAddress
|
|
1464
|
-
)?.isLAOSERC721;
|
|
1465
|
-
if (isLaos721) {
|
|
1466
|
-
args.isLaos721 = true;
|
|
1467
|
-
}
|
|
1468
|
-
return useInfiniteQuery3(listCollectiblesOptions(args, config));
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
// src/react/hooks/useListCollectiblesPaginated.tsx
|
|
1472
|
-
import { queryOptions as queryOptions11, useQuery as useQuery15 } from "@tanstack/react-query";
|
|
1473
|
-
import { z as z11 } from "zod";
|
|
1474
|
-
var UseListCollectiblesPaginatedArgsSchema = listCollectiblesArgsSchema.omit({
|
|
1475
|
-
contractAddress: true
|
|
1476
|
-
}).extend({
|
|
1477
|
-
collectionAddress: AddressSchema,
|
|
1478
|
-
chainId: z11.number(),
|
|
1479
|
-
query: z11.object({
|
|
1480
|
-
enabled: z11.boolean().optional(),
|
|
1481
|
-
page: z11.number().optional().default(1),
|
|
1482
|
-
pageSize: z11.number().optional().default(30)
|
|
1483
|
-
}).optional().default({})
|
|
1484
|
-
});
|
|
1485
|
-
var fetchCollectiblesPaginated = async (args, marketplaceClient) => {
|
|
1486
|
-
const parsedArgs = UseListCollectiblesPaginatedArgsSchema.parse(args);
|
|
1487
|
-
const page = {
|
|
1488
|
-
page: parsedArgs.query?.page ?? 1,
|
|
1489
|
-
pageSize: parsedArgs.query?.pageSize ?? 30
|
|
1490
|
-
};
|
|
1491
|
-
const arg = {
|
|
1492
|
-
...parsedArgs,
|
|
1493
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
1494
|
-
page
|
|
1495
|
-
};
|
|
1496
|
-
return marketplaceClient.listCollectibles(arg);
|
|
1497
|
-
};
|
|
1498
|
-
var listCollectiblesPaginatedOptions = (args, config) => {
|
|
1499
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1500
|
-
return queryOptions11({
|
|
1501
|
-
queryKey: [...collectableKeys.lists, "paginated", args],
|
|
1502
|
-
queryFn: () => fetchCollectiblesPaginated(args, marketplaceClient),
|
|
1503
|
-
enabled: args.query?.enabled ?? true
|
|
1504
|
-
});
|
|
1505
|
-
};
|
|
1506
|
-
var useListCollectiblesPaginated = (args) => {
|
|
1507
|
-
const config = useConfig();
|
|
1508
|
-
return useQuery15(listCollectiblesPaginatedOptions(args, config));
|
|
1509
|
-
};
|
|
1510
|
-
|
|
1511
|
-
// src/react/hooks/useListCollectionActivities.tsx
|
|
1512
|
-
import { queryOptions as queryOptions12, useQuery as useQuery16 } from "@tanstack/react-query";
|
|
1513
|
-
var fetchListCollectionActivities = async (args, config) => {
|
|
1514
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1515
|
-
return marketplaceClient.listCollectionActivities({
|
|
1516
|
-
contractAddress: args.collectionAddress,
|
|
1517
|
-
page: args.query?.enabled ? {
|
|
1518
|
-
page: args.query.page ?? 1,
|
|
1519
|
-
pageSize: args.query.pageSize ?? 10,
|
|
1520
|
-
sort: args.query.sort
|
|
1521
|
-
} : void 0
|
|
1522
|
-
}).then((data) => ({
|
|
1523
|
-
activities: data.activities,
|
|
1524
|
-
page: data.page
|
|
1525
|
-
}));
|
|
1526
|
-
};
|
|
1527
|
-
var listCollectionActivitiesOptions = (args, config) => {
|
|
1528
|
-
return queryOptions12({
|
|
1529
|
-
queryKey: [...collectionKeys.collectionActivities, args, config],
|
|
1530
|
-
queryFn: () => fetchListCollectionActivities(args, config),
|
|
1531
|
-
enabled: args.query?.enabled ?? true
|
|
1532
|
-
});
|
|
1533
|
-
};
|
|
1534
|
-
var useListCollectionActivities = (args) => {
|
|
1535
|
-
const config = useConfig();
|
|
1536
|
-
return useQuery16(listCollectionActivitiesOptions(args, config));
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
// src/react/hooks/useListOffersForCollectible.tsx
|
|
1540
|
-
import { queryOptions as queryOptions13, useQuery as useQuery17 } from "@tanstack/react-query";
|
|
1541
|
-
import { z as z12 } from "zod";
|
|
1542
|
-
var UseListOffersForCollectibleArgsSchema = listOffersForCollectibleArgsSchema.extend({
|
|
1543
|
-
chainId: z12.number(),
|
|
1544
|
-
collectionAddress: z12.string(),
|
|
1545
|
-
collectibleId: z12.string()
|
|
1546
|
-
}).omit({ contractAddress: true, tokenId: true });
|
|
1547
|
-
var fetchListOffersForCollectible = async (config, args) => {
|
|
1548
|
-
const arg = {
|
|
1549
|
-
contractAddress: args.collectionAddress,
|
|
1550
|
-
tokenId: args.collectibleId,
|
|
1551
|
-
filter: args.filter,
|
|
1552
|
-
page: args.page
|
|
1553
|
-
};
|
|
1554
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1555
|
-
return marketplaceClient.listCollectibleOffers(arg);
|
|
1556
|
-
};
|
|
1557
|
-
var listOffersForCollectibleOptions = (args, config) => {
|
|
1558
|
-
return queryOptions13({
|
|
1559
|
-
queryKey: [...collectableKeys.offers, args, config],
|
|
1560
|
-
queryFn: () => fetchListOffersForCollectible(config, args)
|
|
1561
|
-
});
|
|
1562
|
-
};
|
|
1563
|
-
var useListOffersForCollectible = (args) => {
|
|
1564
|
-
const config = useConfig();
|
|
1565
|
-
return useQuery17(listOffersForCollectibleOptions(args, config));
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
|
-
// src/react/hooks/useCountOffersForCollectible.tsx
|
|
1569
|
-
import { queryOptions as queryOptions14, useQuery as useQuery18 } from "@tanstack/react-query";
|
|
1570
|
-
import { z as z13 } from "zod";
|
|
1571
|
-
var UseCountOffersForCollectibleArgsSchema = countOffersForCollectibleArgsSchema.omit({
|
|
1572
|
-
contractAddress: true,
|
|
1573
|
-
tokenId: true
|
|
1574
|
-
}).extend({
|
|
1575
|
-
collectionAddress: AddressSchema,
|
|
1576
|
-
collectibleId: z13.string(),
|
|
1577
|
-
chainId: z13.number(),
|
|
1578
|
-
query: QueryArgSchema
|
|
1579
|
-
});
|
|
1580
|
-
var fetchCountOffersForCollectible = async (args, config) => {
|
|
1581
|
-
const parsedArgs = UseCountOffersForCollectibleArgsSchema.parse(args);
|
|
1582
|
-
const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
|
|
1583
|
-
return marketplaceClient.getCountOfOffersForCollectible({
|
|
1584
|
-
...parsedArgs,
|
|
1585
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
1586
|
-
tokenId: parsedArgs.collectibleId
|
|
1587
|
-
});
|
|
1588
|
-
};
|
|
1589
|
-
var countOffersForCollectibleOptions = (args, config) => {
|
|
1590
|
-
return queryOptions14({
|
|
1591
|
-
...args.query,
|
|
1592
|
-
queryKey: [...collectableKeys.offersCount, args, config],
|
|
1593
|
-
queryFn: () => fetchCountOffersForCollectible(args, config)
|
|
1594
|
-
});
|
|
1595
|
-
};
|
|
1596
|
-
var useCountOffersForCollectible = (args) => {
|
|
1597
|
-
const config = useConfig();
|
|
1598
|
-
return useQuery18(countOffersForCollectibleOptions(args, config));
|
|
1599
|
-
};
|
|
1600
|
-
|
|
1601
|
-
// src/react/hooks/useListListingsForCollectible.tsx
|
|
1602
|
-
import { queryOptions as queryOptions15, useQuery as useQuery19 } from "@tanstack/react-query";
|
|
1603
|
-
import { z as z14 } from "zod";
|
|
1604
|
-
var UseListListingsForCollectibleArgsSchema = listListingsForCollectibleArgsSchema.extend({
|
|
1605
|
-
chainId: z14.number(),
|
|
1606
|
-
collectionAddress: z14.string(),
|
|
1607
|
-
collectibleId: z14.string()
|
|
1608
|
-
}).omit({ contractAddress: true, tokenId: true });
|
|
1609
|
-
var fetchListListingsForCollectible = async (config, args) => {
|
|
1610
|
-
const arg = {
|
|
1611
|
-
contractAddress: args.collectionAddress,
|
|
1612
|
-
tokenId: args.collectibleId,
|
|
1613
|
-
filter: args.filter,
|
|
1614
|
-
page: args.page
|
|
1615
|
-
};
|
|
1616
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
1617
|
-
return marketplaceClient.listCollectibleListings(arg);
|
|
1618
|
-
};
|
|
1619
|
-
var listListingsForCollectibleOptions = (args, config) => {
|
|
1620
|
-
return queryOptions15({
|
|
1621
|
-
queryKey: [...collectableKeys.listings, args, config],
|
|
1622
|
-
queryFn: () => fetchListListingsForCollectible(config, args)
|
|
1623
|
-
});
|
|
1624
|
-
};
|
|
1625
|
-
var useListListingsForCollectible = (args) => {
|
|
1626
|
-
const config = useConfig();
|
|
1627
|
-
return useQuery19(listListingsForCollectibleOptions(args, config));
|
|
1628
|
-
};
|
|
1629
|
-
|
|
1630
|
-
// src/react/hooks/useCountListingsForCollectible.tsx
|
|
1631
|
-
import { queryOptions as queryOptions16, useQuery as useQuery20 } from "@tanstack/react-query";
|
|
1632
|
-
import { z as z15 } from "zod";
|
|
1633
|
-
var UseCountListingsForCollectibleArgsSchema = countListingsForCollectibleArgsSchema.omit({
|
|
1634
|
-
contractAddress: true,
|
|
1635
|
-
tokenId: true
|
|
1636
|
-
}).extend({
|
|
1637
|
-
collectionAddress: AddressSchema,
|
|
1638
|
-
collectibleId: z15.string(),
|
|
1639
|
-
chainId: z15.number(),
|
|
1640
|
-
query: QueryArgSchema
|
|
1641
|
-
});
|
|
1642
|
-
var fetchCountListingsForCollectible = async (args, config) => {
|
|
1643
|
-
const parsedArgs = UseCountListingsForCollectibleArgsSchema.parse(args);
|
|
1644
|
-
const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
|
|
1645
|
-
return marketplaceClient.getCountOfListingsForCollectible({
|
|
1646
|
-
...parsedArgs,
|
|
1647
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
1648
|
-
tokenId: parsedArgs.collectibleId
|
|
1649
|
-
});
|
|
1650
|
-
};
|
|
1651
|
-
var countListingsForCollectibleOptions = (args, config) => {
|
|
1652
|
-
return queryOptions16({
|
|
1653
|
-
...args.query,
|
|
1654
|
-
queryKey: [...collectableKeys.listingsCount, args, config],
|
|
1655
|
-
queryFn: () => fetchCountListingsForCollectible(args, config)
|
|
1656
|
-
});
|
|
1657
|
-
};
|
|
1658
|
-
var useCountListingsForCollectible = (args) => {
|
|
1659
|
-
const config = useConfig();
|
|
1660
|
-
return useQuery20(countListingsForCollectibleOptions(args, config));
|
|
1661
|
-
};
|
|
1662
|
-
|
|
1663
|
-
// src/react/hooks/useLowestListing.tsx
|
|
1664
|
-
import { useQuery as useQuery21 } from "@tanstack/react-query";
|
|
1665
|
-
function useLowestListing(args) {
|
|
1666
|
-
const config = useConfig();
|
|
1667
|
-
return useQuery21(lowestListingOptions(args, config));
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
// src/react/hooks/useRoyalty.tsx
|
|
1671
|
-
import { useReadContract } from "wagmi";
|
|
1672
|
-
import { z as z16 } from "zod";
|
|
1673
|
-
var UseRoyaltySchema = z16.object({
|
|
1674
|
-
chainId: z16.number(),
|
|
1675
|
-
collectionAddress: AddressSchema,
|
|
1676
|
-
collectibleId: z16.string(),
|
|
1677
|
-
query: QueryArgSchema.optional()
|
|
1678
|
-
});
|
|
1679
|
-
var useRoyalty = (args) => {
|
|
1680
|
-
const { chainId, collectionAddress, collectibleId, query } = args;
|
|
1681
|
-
const scopeKey = `${collectableKeys.royaltyPercentage.join(".")}-${chainId}-${collectionAddress}-${collectibleId}`;
|
|
1682
|
-
const contractResult = useReadContract({
|
|
1683
|
-
scopeKey,
|
|
1684
|
-
abi: EIP2981_ABI,
|
|
1685
|
-
address: collectionAddress,
|
|
1686
|
-
functionName: "royaltyInfo",
|
|
1687
|
-
args: [BigInt(collectibleId), BigInt(100)],
|
|
1688
|
-
chainId,
|
|
1689
|
-
query
|
|
1690
|
-
});
|
|
1691
|
-
const [recipient, percentage] = contractResult.data ?? [];
|
|
1692
|
-
const formattedData = recipient && percentage ? {
|
|
1693
|
-
percentage,
|
|
1694
|
-
recipient
|
|
1695
|
-
} : null;
|
|
1696
|
-
return {
|
|
1697
|
-
...contractResult,
|
|
1698
|
-
data: formattedData
|
|
1699
|
-
};
|
|
1700
|
-
};
|
|
1701
|
-
|
|
1702
|
-
// src/react/hooks/useGenerateListingTransaction.tsx
|
|
1703
|
-
import { useMutation } from "@tanstack/react-query";
|
|
1704
|
-
|
|
1705
|
-
// src/utils/date.ts
|
|
1706
|
-
var dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
|
|
1707
|
-
|
|
1708
|
-
// src/react/hooks/useGenerateListingTransaction.tsx
|
|
1709
|
-
var generateListingTransaction = async (params, config, chainId) => {
|
|
1710
|
-
const args = {
|
|
1711
|
-
...params,
|
|
1712
|
-
listing: {
|
|
1713
|
-
...params.listing,
|
|
1714
|
-
expiry: dateToUnixTime(params.listing.expiry)
|
|
1715
|
-
}
|
|
1716
|
-
};
|
|
1717
|
-
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
1718
|
-
return (await marketplaceClient.generateListingTransaction(args)).steps;
|
|
1719
|
-
};
|
|
1720
|
-
var useGenerateListingTransaction = (params) => {
|
|
1721
|
-
const config = useConfig();
|
|
1722
|
-
const { mutate, mutateAsync, ...result } = useMutation({
|
|
1723
|
-
onSuccess: params.onSuccess,
|
|
1724
|
-
mutationFn: (args) => generateListingTransaction(args, config, params.chainId)
|
|
1725
|
-
});
|
|
1726
|
-
return {
|
|
1727
|
-
...result,
|
|
1728
|
-
generateListingTransaction: mutate,
|
|
1729
|
-
generateListingTransactionAsync: mutateAsync
|
|
1730
|
-
};
|
|
1731
|
-
};
|
|
1732
|
-
|
|
1733
|
-
// src/react/hooks/useGenerateOfferTransaction.tsx
|
|
1734
|
-
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
1735
|
-
|
|
1736
|
-
// src/react/_internal/wallet/useWallet.ts
|
|
1737
|
-
import { skipToken as skipToken2, useQuery as useQuery22 } from "@tanstack/react-query";
|
|
1738
|
-
import {
|
|
1739
|
-
useAccount as useAccount2,
|
|
1740
|
-
useChainId,
|
|
1741
|
-
usePublicClient,
|
|
1742
|
-
useSwitchChain,
|
|
1743
|
-
useWalletClient
|
|
1744
|
-
} from "wagmi";
|
|
1745
|
-
|
|
1746
|
-
// src/react/_internal/wallet/wallet.ts
|
|
1747
|
-
import {
|
|
1748
|
-
BaseError as BaseError2,
|
|
1749
|
-
TransactionReceiptNotFoundError,
|
|
1750
|
-
UserRejectedRequestError as ViemUserRejectedRequestError,
|
|
1751
|
-
WaitForTransactionReceiptTimeoutError,
|
|
1752
|
-
custom,
|
|
1753
|
-
erc20Abi,
|
|
1754
|
-
erc721Abi,
|
|
1755
|
-
hexToBigInt,
|
|
1756
|
-
isHex
|
|
1757
|
-
} from "viem";
|
|
1758
|
-
|
|
1759
|
-
// src/react/_internal/logger.ts
|
|
1760
|
-
var TransactionLogger = class {
|
|
1761
|
-
constructor(context, enabled = true) {
|
|
1762
|
-
this.context = context;
|
|
1763
|
-
this.enabled = enabled;
|
|
1764
|
-
}
|
|
1765
|
-
formatData(data) {
|
|
1766
|
-
if (data instanceof Error) {
|
|
1767
|
-
return {
|
|
1768
|
-
name: data.name,
|
|
1769
|
-
message: data.message,
|
|
1770
|
-
cause: data.cause instanceof Error ? this.formatData(data.cause) : data.cause,
|
|
1771
|
-
stack: data.stack?.split("\n").slice(0, 3)
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
|
-
if (Array.isArray(data)) {
|
|
1775
|
-
return data.map((item) => this.formatData(item));
|
|
1776
|
-
}
|
|
1777
|
-
if (typeof data === "object" && data !== null) {
|
|
1778
|
-
return Object.fromEntries(
|
|
1779
|
-
Object.entries(data).map(([key, value]) => [
|
|
1780
|
-
key,
|
|
1781
|
-
this.formatData(value)
|
|
1782
|
-
])
|
|
1783
|
-
);
|
|
1784
|
-
}
|
|
1785
|
-
return data;
|
|
1786
|
-
}
|
|
1787
|
-
log(level, message, data) {
|
|
1788
|
-
if (!this.enabled) return;
|
|
1789
|
-
console[level](
|
|
1790
|
-
`[${this.context}] ${message}`,
|
|
1791
|
-
data ? this.formatData(data) : ""
|
|
1792
|
-
);
|
|
1793
|
-
}
|
|
1794
|
-
debug(message, data) {
|
|
1795
|
-
this.log("debug", message, data);
|
|
1796
|
-
}
|
|
1797
|
-
error(message, error) {
|
|
1798
|
-
this.log("error", message, error);
|
|
1799
|
-
}
|
|
1800
|
-
info(message, data) {
|
|
1801
|
-
this.log("info", message, data);
|
|
1802
|
-
}
|
|
1803
|
-
state(from, to) {
|
|
1804
|
-
this.info(`State transition: ${from} -> ${to}`);
|
|
1805
|
-
}
|
|
1806
|
-
};
|
|
1807
|
-
var createLogger = (context, enabled = true) => new TransactionLogger(context, enabled);
|
|
1808
|
-
|
|
1809
|
-
// src/react/_internal/wallet/wallet.ts
|
|
1810
|
-
var isSequenceWallet = (connector) => connector.id === "sequence" || connector.id === "sequence-waas";
|
|
1811
|
-
var wallet = ({
|
|
1812
|
-
wallet: wallet2,
|
|
1813
|
-
chains,
|
|
1814
|
-
connector,
|
|
1815
|
-
sdkConfig,
|
|
1816
|
-
publicClient
|
|
1817
|
-
}) => {
|
|
1818
|
-
const logger = createLogger("Wallet");
|
|
1819
|
-
const walletInstance = {
|
|
1820
|
-
transport: custom(wallet2.transport),
|
|
1821
|
-
isWaaS: connector.id.endsWith("waas"),
|
|
1822
|
-
walletKind: isSequenceWallet(connector) ? "sequence" /* sequence */ : "unknown" /* unknown */,
|
|
1823
|
-
getChainId: wallet2.getChainId,
|
|
1824
|
-
address: async () => {
|
|
1825
|
-
let address = wallet2.account?.address;
|
|
1826
|
-
if (!address) {
|
|
1827
|
-
[address] = await wallet2.getAddresses();
|
|
1828
|
-
}
|
|
1829
|
-
return address;
|
|
1830
|
-
},
|
|
1831
|
-
switchChain: async (chainId) => {
|
|
1832
|
-
logger.debug("Switching chain", { targetChainId: chainId });
|
|
1833
|
-
try {
|
|
1834
|
-
await wallet2.switchChain({
|
|
1835
|
-
id: chainId
|
|
1836
|
-
});
|
|
1837
|
-
logger.info("Chain switch successful", { chainId });
|
|
1838
|
-
return;
|
|
1839
|
-
} catch (e) {
|
|
1840
|
-
const error = e;
|
|
1841
|
-
logger.error("Chain switch failed", error);
|
|
1842
|
-
switch (error.name) {
|
|
1843
|
-
case "SwitchChainNotSupportedError":
|
|
1844
|
-
throw new ChainSwitchError(await wallet2.getChainId(), chainId);
|
|
1845
|
-
case "UserRejectedRequestError":
|
|
1846
|
-
throw new UserRejectedRequestError();
|
|
1847
|
-
case "ChainNotConfiguredError":
|
|
1848
|
-
return;
|
|
1849
|
-
default:
|
|
1850
|
-
throw new ChainSwitchError(await wallet2.getChainId(), chainId);
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
},
|
|
1854
|
-
handleSignMessageStep: async (stepItem) => {
|
|
1855
|
-
try {
|
|
1856
|
-
if (stepItem.id === "signEIP191" /* signEIP191 */) {
|
|
1857
|
-
logger.debug("Signing with EIP-191", { data: stepItem.data });
|
|
1858
|
-
const message = isHex(stepItem.data) ? { raw: stepItem.data } : stepItem.data;
|
|
1859
|
-
return await wallet2.signMessage({
|
|
1860
|
-
account: wallet2.account,
|
|
1861
|
-
message
|
|
1862
|
-
});
|
|
1863
|
-
} else if (stepItem.id === "signEIP712" /* signEIP712 */) {
|
|
1864
|
-
logger.debug("Signing with EIP-712", {
|
|
1865
|
-
domain: stepItem.domain,
|
|
1866
|
-
types: stepItem.signature?.types
|
|
1867
|
-
});
|
|
1868
|
-
return await wallet2.signTypedData({
|
|
1869
|
-
account: wallet2.account,
|
|
1870
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
1871
|
-
domain: stepItem.signature.domain,
|
|
1872
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
1873
|
-
types: stepItem.signature.types,
|
|
1874
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
1875
|
-
primaryType: stepItem.signature.primaryType,
|
|
1876
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
1877
|
-
message: stepItem.signature.value
|
|
1878
|
-
});
|
|
1879
|
-
}
|
|
1880
|
-
} catch (e) {
|
|
1881
|
-
const error = e;
|
|
1882
|
-
logger.error("Signature failed", error);
|
|
1883
|
-
if (error.cause instanceof BaseError2) {
|
|
1884
|
-
const viemError = error.cause;
|
|
1885
|
-
if (viemError instanceof ViemUserRejectedRequestError) {
|
|
1886
|
-
throw new UserRejectedRequestError();
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
throw new TransactionSignatureError(stepItem.id, error);
|
|
1890
|
-
}
|
|
1891
|
-
},
|
|
1892
|
-
handleSendTransactionStep: async (chainId, stepItem) => {
|
|
1893
|
-
logger.debug("Sending transaction", {
|
|
1894
|
-
chainId,
|
|
1895
|
-
to: stepItem.to,
|
|
1896
|
-
value: stepItem.value
|
|
1897
|
-
});
|
|
1898
|
-
const chain = chains.find((chain2) => chain2.id === chainId);
|
|
1899
|
-
try {
|
|
1900
|
-
return await wallet2.sendTransaction({
|
|
1901
|
-
chain,
|
|
1902
|
-
data: stepItem.data,
|
|
1903
|
-
account: wallet2.account,
|
|
1904
|
-
to: stepItem.to,
|
|
1905
|
-
value: hexToBigInt(stepItem.value || "0x0"),
|
|
1906
|
-
...stepItem.maxFeePerGas && {
|
|
1907
|
-
maxFeePerGas: hexToBigInt(stepItem.maxFeePerGas)
|
|
1908
|
-
},
|
|
1909
|
-
...stepItem.maxPriorityFeePerGas && {
|
|
1910
|
-
maxPriorityFeePerGas: hexToBigInt(stepItem.maxPriorityFeePerGas)
|
|
1911
|
-
},
|
|
1912
|
-
...stepItem.gas && {
|
|
1913
|
-
gas: hexToBigInt(stepItem.gas)
|
|
1914
|
-
}
|
|
1915
|
-
});
|
|
1916
|
-
} catch (e) {
|
|
1917
|
-
const error = e;
|
|
1918
|
-
logger.error("Transaction failed", error);
|
|
1919
|
-
if (error.cause instanceof BaseError2) {
|
|
1920
|
-
const viemError = error.cause;
|
|
1921
|
-
if (viemError instanceof ViemUserRejectedRequestError) {
|
|
1922
|
-
throw new UserRejectedRequestError();
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
throw new TransactionExecutionError(stepItem.id, error);
|
|
1926
|
-
}
|
|
1927
|
-
},
|
|
1928
|
-
handleConfirmTransactionStep: async (txHash, chainId) => {
|
|
1929
|
-
logger.debug("Confirming transaction", { txHash, chainId });
|
|
1930
|
-
try {
|
|
1931
|
-
const receipt = await awaitTransactionReceipt({
|
|
1932
|
-
txHash,
|
|
1933
|
-
chainId,
|
|
1934
|
-
sdkConfig
|
|
1935
|
-
});
|
|
1936
|
-
logger.info("Transaction confirmed", { txHash, receipt });
|
|
1937
|
-
return receipt;
|
|
1938
|
-
} catch (error) {
|
|
1939
|
-
logger.error("Transaction confirmation failed", error);
|
|
1940
|
-
throw new TransactionConfirmationError(txHash, error);
|
|
1941
|
-
}
|
|
1942
|
-
},
|
|
1943
|
-
hasTokenApproval: async ({
|
|
1944
|
-
tokenType,
|
|
1945
|
-
contractAddress,
|
|
1946
|
-
spender
|
|
1947
|
-
}) => {
|
|
1948
|
-
const walletAddress = await walletInstance.address();
|
|
1949
|
-
const spenderAddress = spender === "sequenceMarketV1" ? SEQUENCE_MARKET_V1_ADDRESS : spender === "sequenceMarketV2" ? SEQUENCE_MARKET_V2_ADDRESS : spender;
|
|
1950
|
-
switch (tokenType) {
|
|
1951
|
-
case "ERC20":
|
|
1952
|
-
return await publicClient.readContract({
|
|
1953
|
-
address: contractAddress,
|
|
1954
|
-
abi: erc20Abi,
|
|
1955
|
-
functionName: "allowance",
|
|
1956
|
-
args: [walletAddress, spenderAddress]
|
|
1957
|
-
});
|
|
1958
|
-
case "ERC721":
|
|
1959
|
-
return await publicClient.readContract({
|
|
1960
|
-
address: contractAddress,
|
|
1961
|
-
abi: erc721Abi,
|
|
1962
|
-
functionName: "isApprovedForAll",
|
|
1963
|
-
args: [walletAddress, spenderAddress]
|
|
1964
|
-
});
|
|
1965
|
-
case "ERC1155":
|
|
1966
|
-
return await publicClient.readContract({
|
|
1967
|
-
address: contractAddress,
|
|
1968
|
-
abi: ERC1155_ABI,
|
|
1969
|
-
functionName: "isApprovedForAll",
|
|
1970
|
-
args: [walletAddress, spenderAddress]
|
|
1971
|
-
});
|
|
1972
|
-
default:
|
|
1973
|
-
throw new Error("Unsupported contract type for approval checking");
|
|
1974
|
-
}
|
|
1975
|
-
},
|
|
1976
|
-
publicClient
|
|
1977
|
-
};
|
|
1978
|
-
return walletInstance;
|
|
1979
|
-
};
|
|
1980
|
-
var ONE_MIN = 60 * 1e3;
|
|
1981
|
-
var THREE_MIN = 3 * ONE_MIN;
|
|
1982
|
-
var awaitTransactionReceipt = async ({
|
|
1983
|
-
txHash,
|
|
1984
|
-
chainId,
|
|
1985
|
-
sdkConfig,
|
|
1986
|
-
timeout = THREE_MIN
|
|
1987
|
-
}) => {
|
|
1988
|
-
const indexer = getIndexerClient(chainId, sdkConfig);
|
|
1989
|
-
return Promise.race([
|
|
1990
|
-
new Promise((resolve, reject) => {
|
|
1991
|
-
indexer.subscribeReceipts(
|
|
1992
|
-
{
|
|
1993
|
-
filter: {
|
|
1994
|
-
txnHash: txHash
|
|
1995
|
-
}
|
|
1996
|
-
},
|
|
1997
|
-
{
|
|
1998
|
-
onMessage: ({ receipt }) => {
|
|
1999
|
-
resolve(receipt);
|
|
2000
|
-
},
|
|
2001
|
-
onError: () => {
|
|
2002
|
-
reject(TransactionReceiptNotFoundError);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
);
|
|
2006
|
-
}),
|
|
2007
|
-
new Promise((_, reject) => {
|
|
2008
|
-
setTimeout(() => {
|
|
2009
|
-
reject(WaitForTransactionReceiptTimeoutError);
|
|
2010
|
-
}, timeout);
|
|
2011
|
-
})
|
|
2012
|
-
]);
|
|
2013
|
-
};
|
|
2014
|
-
|
|
2015
|
-
// src/react/_internal/wallet/useWallet.ts
|
|
2016
|
-
var useWallet = () => {
|
|
2017
|
-
const { chains } = useSwitchChain();
|
|
2018
|
-
const {
|
|
2019
|
-
data: walletClient,
|
|
2020
|
-
isLoading: wagmiWalletIsLoading,
|
|
2021
|
-
isError: wagmiWalletIsError
|
|
2022
|
-
} = useWalletClient();
|
|
2023
|
-
const { connector, isConnected, isConnecting } = useAccount2();
|
|
2024
|
-
const sdkConfig = useConfig();
|
|
2025
|
-
const chainId = useChainId();
|
|
2026
|
-
const publicClient = usePublicClient();
|
|
2027
|
-
const { data, isLoading, isError } = useQuery22({
|
|
2028
|
-
queryKey: ["wallet", chainId, connector?.uid],
|
|
2029
|
-
queryFn: walletClient && connector && isConnected && publicClient ? () => {
|
|
2030
|
-
return wallet({
|
|
2031
|
-
wallet: walletClient,
|
|
2032
|
-
chains,
|
|
2033
|
-
connector,
|
|
2034
|
-
sdkConfig,
|
|
2035
|
-
publicClient
|
|
2036
|
-
});
|
|
2037
|
-
} : skipToken2,
|
|
2038
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
2039
|
-
});
|
|
2040
|
-
return {
|
|
2041
|
-
wallet: data,
|
|
2042
|
-
isLoading: isLoading || isConnecting || wagmiWalletIsLoading,
|
|
2043
|
-
isError: isError || wagmiWalletIsError
|
|
2044
|
-
};
|
|
2045
|
-
};
|
|
2046
|
-
|
|
2047
|
-
// src/react/hooks/useGenerateOfferTransaction.tsx
|
|
2048
|
-
var generateOfferTransaction = async (params, config, chainId, walletKind) => {
|
|
2049
|
-
const args = {
|
|
2050
|
-
...params,
|
|
2051
|
-
offer: { ...params.offer, expiry: dateToUnixTime(params.offer.expiry) },
|
|
2052
|
-
walletType: walletKind
|
|
2053
|
-
};
|
|
2054
|
-
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
2055
|
-
return (await marketplaceClient.generateOfferTransaction(args)).steps;
|
|
2056
|
-
};
|
|
2057
|
-
var useGenerateOfferTransaction = (params) => {
|
|
2058
|
-
const config = useConfig();
|
|
2059
|
-
const { wallet: wallet2 } = useWallet();
|
|
2060
|
-
const { mutate, mutateAsync, ...result } = useMutation2({
|
|
2061
|
-
onSuccess: params.onSuccess,
|
|
2062
|
-
mutationFn: (args) => generateOfferTransaction(
|
|
2063
|
-
args,
|
|
2064
|
-
config,
|
|
2065
|
-
params.chainId,
|
|
2066
|
-
wallet2?.walletKind
|
|
2067
|
-
)
|
|
2068
|
-
});
|
|
2069
|
-
return {
|
|
2070
|
-
...result,
|
|
2071
|
-
generateOfferTransaction: mutate,
|
|
2072
|
-
generateOfferTransactionAsync: mutateAsync
|
|
2073
|
-
};
|
|
2074
|
-
};
|
|
2075
|
-
|
|
2076
|
-
// src/react/hooks/useGenerateSellTransaction.tsx
|
|
2077
|
-
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
2078
|
-
import { z as z17 } from "zod";
|
|
2079
|
-
var UserGeneratSellTransactionArgsSchema = z17.object({
|
|
2080
|
-
chainId: z17.number(),
|
|
2081
|
-
onSuccess: z17.function().args(stepSchema.array().optional()).optional()
|
|
2082
|
-
});
|
|
2083
|
-
var generateSellTransaction = async (args, config, chainId) => {
|
|
2084
|
-
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
2085
|
-
return marketplaceClient.generateSellTransaction(args).then((data) => data.steps);
|
|
2086
|
-
};
|
|
2087
|
-
var useGenerateSellTransaction = (params) => {
|
|
2088
|
-
const config = useConfig();
|
|
2089
|
-
const { mutate, mutateAsync, ...result } = useMutation3({
|
|
2090
|
-
onSuccess: params.onSuccess,
|
|
2091
|
-
mutationFn: (args) => generateSellTransaction(args, config, params.chainId)
|
|
2092
|
-
});
|
|
2093
|
-
return {
|
|
2094
|
-
...result,
|
|
2095
|
-
generateSellTransaction: mutate,
|
|
2096
|
-
generateSellTransactionAsync: mutateAsync
|
|
2097
|
-
};
|
|
2098
|
-
};
|
|
2099
|
-
|
|
2100
|
-
// src/react/hooks/useGenerateCancelTransaction.tsx
|
|
2101
|
-
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
2102
|
-
import { z as z18 } from "zod";
|
|
2103
|
-
var UserGenerateCancelTransactionArgsSchema = z18.object({
|
|
2104
|
-
chainId: z18.number(),
|
|
2105
|
-
onSuccess: z18.function().args(stepSchema.array().optional()).optional()
|
|
2106
|
-
});
|
|
2107
|
-
var generateCancelTransaction = async (args, config, chainId) => {
|
|
2108
|
-
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
2109
|
-
return marketplaceClient.generateCancelTransaction(args).then((data) => data.steps);
|
|
2110
|
-
};
|
|
2111
|
-
var useGenerateCancelTransaction = (params) => {
|
|
2112
|
-
const config = useConfig();
|
|
2113
|
-
const { mutate, mutateAsync, ...result } = useMutation4({
|
|
2114
|
-
onSuccess: params.onSuccess,
|
|
2115
|
-
mutationFn: (args) => generateCancelTransaction(args, config, params.chainId)
|
|
2116
|
-
});
|
|
2117
|
-
return {
|
|
2118
|
-
...result,
|
|
2119
|
-
generateCancelTransaction: mutate,
|
|
2120
|
-
generateCancelTransactionAsync: mutateAsync
|
|
2121
|
-
};
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
// src/react/hooks/useTransferTokens.tsx
|
|
2125
|
-
import { erc721Abi as erc721Abi2 } from "viem";
|
|
2126
|
-
import { useAccount as useAccount3, useWriteContract } from "wagmi";
|
|
2127
|
-
var prepareTransferConfig = (params, accountAddress) => {
|
|
2128
|
-
if (params.contractType === "ERC721") {
|
|
2129
|
-
return {
|
|
2130
|
-
abi: erc721Abi2,
|
|
2131
|
-
address: params.collectionAddress,
|
|
2132
|
-
functionName: "safeTransferFrom",
|
|
2133
|
-
args: [
|
|
2134
|
-
accountAddress,
|
|
2135
|
-
params.receiverAddress,
|
|
2136
|
-
BigInt(params.tokenId)
|
|
2137
|
-
]
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
return {
|
|
2141
|
-
abi: ERC1155_ABI,
|
|
2142
|
-
address: params.collectionAddress,
|
|
2143
|
-
functionName: "safeTransferFrom",
|
|
2144
|
-
args: [
|
|
2145
|
-
accountAddress,
|
|
2146
|
-
params.receiverAddress,
|
|
2147
|
-
BigInt(params.tokenId),
|
|
2148
|
-
params.quantity,
|
|
2149
|
-
"0x"
|
|
2150
|
-
// data
|
|
2151
|
-
]
|
|
2152
|
-
};
|
|
2153
|
-
};
|
|
2154
|
-
var useTransferTokens = () => {
|
|
2155
|
-
const { address: accountAddress } = useAccount3();
|
|
2156
|
-
const {
|
|
2157
|
-
writeContractAsync,
|
|
2158
|
-
data: hash,
|
|
2159
|
-
isPending,
|
|
2160
|
-
isError,
|
|
2161
|
-
isSuccess
|
|
2162
|
-
} = useWriteContract();
|
|
2163
|
-
const transferTokensAsync = async (params) => {
|
|
2164
|
-
if (!accountAddress) {
|
|
2165
|
-
throw new NoWalletConnectedError();
|
|
2166
|
-
}
|
|
2167
|
-
const config = prepareTransferConfig(params, accountAddress);
|
|
2168
|
-
return await writeContractAsync(config);
|
|
2169
|
-
};
|
|
2170
|
-
return {
|
|
2171
|
-
transferTokensAsync,
|
|
2172
|
-
hash,
|
|
2173
|
-
transferring: isPending,
|
|
2174
|
-
transferFailed: isError,
|
|
2175
|
-
transferSuccess: isSuccess
|
|
2176
|
-
};
|
|
2177
|
-
};
|
|
2178
|
-
|
|
2179
|
-
// src/react/hooks/useCheckoutOptions.tsx
|
|
2180
|
-
import { queryOptions as queryOptions17, useQuery as useQuery23 } from "@tanstack/react-query";
|
|
2181
|
-
import { useAccount as useAccount4 } from "wagmi";
|
|
2182
|
-
import { z as z19 } from "zod";
|
|
2183
|
-
var UseCheckoutOptionsSchema = z19.object({
|
|
2184
|
-
chainId: z19.number(),
|
|
2185
|
-
orders: z19.array(
|
|
2186
|
-
z19.object({
|
|
2187
|
-
collectionAddress: AddressSchema,
|
|
2188
|
-
orderId: z19.string(),
|
|
2189
|
-
marketplace: z19.nativeEnum(MarketplaceKind)
|
|
2190
|
-
})
|
|
2191
|
-
),
|
|
2192
|
-
query: QueryArgSchema
|
|
2193
|
-
});
|
|
2194
|
-
var fetchCheckoutOptions = async (args, config) => {
|
|
2195
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
2196
|
-
return marketplaceClient.checkoutOptionsMarketplace({
|
|
2197
|
-
wallet: args.walletAddress,
|
|
2198
|
-
orders: args.orders.map((order) => ({
|
|
2199
|
-
contractAddress: order.collectionAddress,
|
|
2200
|
-
orderId: order.orderId,
|
|
2201
|
-
marketplace: order.marketplace
|
|
2202
|
-
})),
|
|
2203
|
-
additionalFee: 0
|
|
2204
|
-
//TODO: add additional fee
|
|
2205
|
-
});
|
|
2206
|
-
};
|
|
2207
|
-
var checkoutOptionsOptions = (args, config) => {
|
|
2208
|
-
return queryOptions17({
|
|
2209
|
-
queryKey: ["checkoutOptions", args],
|
|
2210
|
-
queryFn: () => fetchCheckoutOptions(args, config)
|
|
2211
|
-
});
|
|
2212
|
-
};
|
|
2213
|
-
var useCheckoutOptions = (args) => {
|
|
2214
|
-
const { address } = useAccount4();
|
|
2215
|
-
const config = useConfig();
|
|
2216
|
-
return useQuery23(
|
|
2217
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
2218
|
-
checkoutOptionsOptions({ walletAddress: address, ...args }, config)
|
|
2219
|
-
);
|
|
2220
|
-
};
|
|
2221
|
-
|
|
2222
|
-
// src/react/hooks/useListCollections.tsx
|
|
2223
|
-
import { queryOptions as queryOptions18, useQuery as useQuery24 } from "@tanstack/react-query";
|
|
2224
|
-
import { z as z20 } from "zod";
|
|
2225
|
-
var UseListCollectionsSchema = z20.object({
|
|
2226
|
-
query: QueryArgSchema.optional().default({})
|
|
2227
|
-
});
|
|
2228
|
-
var fetchListCollections = async ({ marketplaceConfig }, config) => {
|
|
2229
|
-
const metadataClient = getMetadataClient(config);
|
|
2230
|
-
if (!marketplaceConfig?.collections?.length) {
|
|
2231
|
-
return [];
|
|
2232
|
-
}
|
|
2233
|
-
const collectionsByChain = marketplaceConfig.collections.reduce((acc, curr) => {
|
|
2234
|
-
const { chainId, address } = curr;
|
|
2235
|
-
if (!acc[chainId]) {
|
|
2236
|
-
acc[chainId] = [];
|
|
2237
|
-
}
|
|
2238
|
-
acc[chainId].push(address);
|
|
2239
|
-
return acc;
|
|
2240
|
-
}, {});
|
|
2241
|
-
const promises = Object.entries(collectionsByChain).map(
|
|
2242
|
-
([chainId, addresses]) => metadataClient.getContractInfoBatch({
|
|
2243
|
-
chainID: chainId,
|
|
2244
|
-
contractAddresses: addresses
|
|
2245
|
-
}).then((resp) => Object.values(resp.contractInfoMap))
|
|
2246
|
-
);
|
|
2247
|
-
const results = await Promise.all(promises);
|
|
2248
|
-
return results.flat();
|
|
2249
|
-
};
|
|
2250
|
-
var listCollectionsOptions = (args, config) => {
|
|
2251
|
-
return queryOptions18({
|
|
2252
|
-
...args.query,
|
|
2253
|
-
queryKey: [...collectionKeys.list],
|
|
2254
|
-
queryFn: () => fetchListCollections(args, config)
|
|
2255
|
-
});
|
|
2256
|
-
};
|
|
2257
|
-
var useListCollections = (args = {}) => {
|
|
2258
|
-
const config = useConfig();
|
|
2259
|
-
const { data: marketplaceConfig, isLoading: isLoadingConfig } = useMarketplaceConfig();
|
|
2260
|
-
return useQuery24({
|
|
2261
|
-
...listCollectionsOptions(
|
|
2262
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
2263
|
-
{ marketplaceConfig, query: args.query },
|
|
2264
|
-
config
|
|
2265
|
-
),
|
|
2266
|
-
enabled: !isLoadingConfig && !!marketplaceConfig
|
|
2267
|
-
});
|
|
2268
|
-
};
|
|
2269
|
-
|
|
2270
|
-
// src/react/hooks/useCancelOrder.tsx
|
|
2271
|
-
import { useWaasFeeOptions } from "@0xsequence/connect";
|
|
2272
|
-
import { useEffect as useEffect2, useState } from "react";
|
|
2273
|
-
|
|
2274
|
-
// src/react/ui/modals/_internal/components/switchChainModal/index.tsx
|
|
2275
|
-
import { Button, Modal, Spinner, Text as Text2 } from "@0xsequence/design-system";
|
|
2276
|
-
import { observer } from "@legendapp/state/react";
|
|
2277
|
-
import { useSwitchChain as useSwitchChain2 } from "wagmi";
|
|
2278
|
-
|
|
2279
|
-
// src/react/ui/modals/_internal/components/alertMessage/index.tsx
|
|
2280
|
-
import { Text, WarningIcon } from "@0xsequence/design-system";
|
|
2281
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2282
|
-
function AlertMessage({ message, type }) {
|
|
2283
|
-
return /* @__PURE__ */ jsxs(
|
|
2284
|
-
"div",
|
|
2285
|
-
{
|
|
2286
|
-
className: `flex items-center justify-between gap-3 rounded-xl p-4 ${type === "warning" ? "bg-[hsla(39,71%,40%,0.3)]" : "bg-[hsla(247,100%,75%,0.3)]"}`,
|
|
2287
|
-
children: [
|
|
2288
|
-
/* @__PURE__ */ jsx2(Text, { className: "font-body text-sm", color: "white", fontWeight: "medium", children: message }),
|
|
2289
|
-
type === "warning" && /* @__PURE__ */ jsx2(WarningIcon, { size: "sm", color: "white" }),
|
|
2290
|
-
type === "info" && /* @__PURE__ */ jsx2(InfoIcon_default, { size: "sm", color: "white" })
|
|
2291
|
-
]
|
|
2292
|
-
}
|
|
2293
|
-
);
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
// src/react/ui/modals/_internal/components/consts.ts
|
|
2297
|
-
var MODAL_WIDTH = "360px";
|
|
2298
|
-
var MODAL_OVERLAY_PROPS = {
|
|
2299
|
-
style: {
|
|
2300
|
-
background: "hsla(0, 0%, 15%, 0.9)"
|
|
2301
|
-
}
|
|
2302
|
-
};
|
|
2303
|
-
var MODAL_CONTENT_PROPS = {
|
|
2304
|
-
style: {
|
|
2305
|
-
width: MODAL_WIDTH,
|
|
2306
|
-
height: "auto"
|
|
2307
|
-
}
|
|
2308
|
-
};
|
|
2309
|
-
|
|
2310
|
-
// src/react/ui/modals/_internal/components/switchChainModal/store.ts
|
|
2311
|
-
import { observable } from "@legendapp/state";
|
|
2312
|
-
var initialState = {
|
|
2313
|
-
isOpen: false,
|
|
2314
|
-
open: ({ chainIdToSwitchTo, onError, onSuccess, onClose }) => {
|
|
2315
|
-
switchChainModal$.state.set({
|
|
2316
|
-
...switchChainModal$.state.get(),
|
|
2317
|
-
chainIdToSwitchTo,
|
|
2318
|
-
onError,
|
|
2319
|
-
onSuccess,
|
|
2320
|
-
onClose
|
|
2321
|
-
});
|
|
2322
|
-
switchChainModal$.isOpen.set(true);
|
|
2323
|
-
},
|
|
2324
|
-
close: () => {
|
|
2325
|
-
switchChainModal$.isOpen.set(false);
|
|
2326
|
-
},
|
|
2327
|
-
state: {
|
|
2328
|
-
chainIdToSwitchTo: void 0,
|
|
2329
|
-
onError: void 0,
|
|
2330
|
-
onSuccess: void 0,
|
|
2331
|
-
onClose: void 0,
|
|
2332
|
-
isSwitching: false
|
|
2333
|
-
}
|
|
2334
|
-
};
|
|
2335
|
-
var switchChainModal$ = observable(initialState);
|
|
2336
|
-
|
|
2337
|
-
// src/react/ui/modals/_internal/components/switchChainModal/index.tsx
|
|
2338
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2339
|
-
var useSwitchChainModal = () => {
|
|
2340
|
-
return {
|
|
2341
|
-
show: (args) => switchChainModal$.open(args),
|
|
2342
|
-
close: () => switchChainModal$.delete(),
|
|
2343
|
-
isSwitching$: switchChainModal$.state.isSwitching
|
|
2344
|
-
};
|
|
2345
|
-
};
|
|
2346
|
-
var SwitchChainModal = observer(() => {
|
|
2347
|
-
const chainIdToSwitchTo = switchChainModal$.state.chainIdToSwitchTo.get();
|
|
2348
|
-
const isSwitching$ = switchChainModal$.state.isSwitching;
|
|
2349
|
-
const chainName = chainIdToSwitchTo ? getPresentableChainName(chainIdToSwitchTo) : "";
|
|
2350
|
-
const { switchChainAsync } = useSwitchChain2();
|
|
2351
|
-
async function handleSwitchChain() {
|
|
2352
|
-
isSwitching$.set(true);
|
|
2353
|
-
try {
|
|
2354
|
-
if (!chainIdToSwitchTo) return;
|
|
2355
|
-
await switchChainAsync({ chainId: Number(chainIdToSwitchTo) });
|
|
2356
|
-
if (switchChainModal$.state.onSuccess.get() && typeof switchChainModal$.state.onSuccess.get() === "function") {
|
|
2357
|
-
switchChainModal$.state.onSuccess();
|
|
2358
|
-
}
|
|
2359
|
-
switchChainModal$.delete();
|
|
2360
|
-
} catch (error) {
|
|
2361
|
-
if (error instanceof Error && switchChainModal$.state.onError.get() && typeof switchChainModal$.state.onError.get() === "function") {
|
|
2362
|
-
switchChainModal$.state.onError.get()?.(error);
|
|
2363
|
-
}
|
|
2364
|
-
} finally {
|
|
2365
|
-
isSwitching$.set(false);
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
const handleClose = () => {
|
|
2369
|
-
if (switchChainModal$.state.onClose && typeof switchChainModal$.state.onClose === "function") {
|
|
2370
|
-
switchChainModal$.state.onClose();
|
|
2371
|
-
}
|
|
2372
|
-
switchChainModal$.delete();
|
|
2373
|
-
};
|
|
2374
|
-
if (!chainIdToSwitchTo) return null;
|
|
2375
|
-
return /* @__PURE__ */ jsx3(
|
|
2376
|
-
Modal,
|
|
2377
|
-
{
|
|
2378
|
-
isDismissible: true,
|
|
2379
|
-
onClose: handleClose,
|
|
2380
|
-
disableAnimation: true,
|
|
2381
|
-
size: "sm",
|
|
2382
|
-
overlayProps: MODAL_OVERLAY_PROPS,
|
|
2383
|
-
children: /* @__PURE__ */ jsxs2("div", { className: "grid flex-col gap-6 p-7", children: [
|
|
2384
|
-
/* @__PURE__ */ jsx3(Text2, { className: "text-xl", fontWeight: "bold", color: "text100", children: "Wrong network" }),
|
|
2385
|
-
/* @__PURE__ */ jsx3(
|
|
2386
|
-
AlertMessage,
|
|
2387
|
-
{
|
|
2388
|
-
type: "warning",
|
|
2389
|
-
message: `You need to switch to ${chainName} network before completing the transaction`
|
|
2390
|
-
}
|
|
2391
|
-
),
|
|
2392
|
-
/* @__PURE__ */ jsx3(
|
|
2393
|
-
Button,
|
|
2394
|
-
{
|
|
2395
|
-
className: `${isSwitching$.get() ? "flex w-[147px] items-center justify-center [&>div]:justify-center" : "w-[147px]"} flex justify-self-end`,
|
|
2396
|
-
name: "switch-chain",
|
|
2397
|
-
id: "switch-chain-button",
|
|
2398
|
-
size: "sm",
|
|
2399
|
-
label: isSwitching$.get() ? /* @__PURE__ */ jsx3("div", { "data-testid": "switch-chain-spinner", children: /* @__PURE__ */ jsx3(Spinner, { className: "spinner" }) }) : "Switch Network",
|
|
2400
|
-
variant: "primary",
|
|
2401
|
-
pending: isSwitching$.get(),
|
|
2402
|
-
shape: "square",
|
|
2403
|
-
onClick: handleSwitchChain,
|
|
2404
|
-
"data-testid": "switch-chain-button"
|
|
2405
|
-
}
|
|
2406
|
-
)
|
|
2407
|
-
] })
|
|
2408
|
-
}
|
|
2409
|
-
);
|
|
2410
|
-
});
|
|
2411
|
-
var switchChainModal_default = SwitchChainModal;
|
|
2412
|
-
|
|
2413
|
-
// src/react/hooks/util/optimisticCancelUpdates.ts
|
|
2414
|
-
var SECOND = 1e3;
|
|
2415
|
-
var updateQueriesOnCancel = ({
|
|
2416
|
-
orderId,
|
|
2417
|
-
queryClient
|
|
2418
|
-
}) => {
|
|
2419
|
-
queryClient.setQueriesData(
|
|
2420
|
-
{ queryKey: collectableKeys.offersCount, exact: false },
|
|
2421
|
-
(oldData) => {
|
|
2422
|
-
if (!oldData) return { count: 0 };
|
|
2423
|
-
return { count: Math.max(0, oldData.count - 1) };
|
|
2424
|
-
}
|
|
2425
|
-
);
|
|
2426
|
-
console.log("query client ", queryClient, "orderId", orderId);
|
|
2427
|
-
queryClient.setQueriesData(
|
|
2428
|
-
{ queryKey: collectableKeys.offers, exact: false },
|
|
2429
|
-
(oldData) => {
|
|
2430
|
-
if (!oldData || !oldData.offers) return oldData;
|
|
2431
|
-
return {
|
|
2432
|
-
...oldData,
|
|
2433
|
-
offers: oldData.offers.filter((offer) => offer.orderId !== orderId)
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
);
|
|
2437
|
-
setTimeout(() => {
|
|
2438
|
-
queryClient.invalidateQueries({
|
|
2439
|
-
queryKey: collectableKeys.highestOffers,
|
|
2440
|
-
exact: false
|
|
2441
|
-
});
|
|
2442
|
-
}, 2 * SECOND);
|
|
2443
|
-
queryClient.setQueriesData(
|
|
2444
|
-
{ queryKey: collectableKeys.listingsCount, exact: false },
|
|
2445
|
-
(oldData) => {
|
|
2446
|
-
if (!oldData) return { count: 0 };
|
|
2447
|
-
return { count: Math.max(0, oldData.count - 1) };
|
|
2448
|
-
}
|
|
2449
|
-
);
|
|
2450
|
-
queryClient.setQueriesData(
|
|
2451
|
-
{ queryKey: collectableKeys.listings, exact: false },
|
|
2452
|
-
(oldData) => {
|
|
2453
|
-
if (!oldData || !oldData.listings) return oldData;
|
|
2454
|
-
return {
|
|
2455
|
-
...oldData,
|
|
2456
|
-
listings: oldData.listings.filter(
|
|
2457
|
-
(listing) => listing.orderId !== orderId
|
|
2458
|
-
)
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
);
|
|
2462
|
-
setTimeout(() => {
|
|
2463
|
-
queryClient.invalidateQueries({
|
|
2464
|
-
queryKey: collectableKeys.lowestListings,
|
|
2465
|
-
exact: false
|
|
2466
|
-
});
|
|
2467
|
-
}, 2 * SECOND);
|
|
2468
|
-
};
|
|
2469
|
-
var invalidateQueriesOnCancel = ({
|
|
2470
|
-
queryClient
|
|
2471
|
-
}) => {
|
|
2472
|
-
queryClient.invalidateQueries({
|
|
2473
|
-
queryKey: collectableKeys.offers,
|
|
2474
|
-
exact: false
|
|
2475
|
-
});
|
|
2476
|
-
queryClient.invalidateQueries({
|
|
2477
|
-
queryKey: collectableKeys.offersCount,
|
|
2478
|
-
exact: false
|
|
2479
|
-
});
|
|
2480
|
-
queryClient.invalidateQueries({
|
|
2481
|
-
queryKey: collectableKeys.listings,
|
|
2482
|
-
exact: false
|
|
2483
|
-
});
|
|
2484
|
-
queryClient.invalidateQueries({
|
|
2485
|
-
queryKey: collectableKeys.listingsCount,
|
|
2486
|
-
exact: false
|
|
2487
|
-
});
|
|
2488
|
-
queryClient.invalidateQueries({
|
|
2489
|
-
queryKey: collectableKeys.highestOffers,
|
|
2490
|
-
exact: false
|
|
2491
|
-
});
|
|
2492
|
-
queryClient.invalidateQueries({
|
|
2493
|
-
queryKey: collectableKeys.lowestListings,
|
|
2494
|
-
exact: false
|
|
2495
|
-
});
|
|
2496
|
-
};
|
|
2497
|
-
|
|
2498
|
-
// src/react/hooks/useCancelTransactionSteps.tsx
|
|
2499
|
-
var useCancelTransactionSteps = ({
|
|
2500
|
-
collectionAddress,
|
|
2501
|
-
chainId,
|
|
2502
|
-
callbacks,
|
|
2503
|
-
setSteps,
|
|
2504
|
-
onSuccess,
|
|
2505
|
-
onError
|
|
2506
|
-
}) => {
|
|
2507
|
-
const { show: showSwitchChainModal } = useSwitchChainModal();
|
|
2508
|
-
const { wallet: wallet2, isLoading, isError } = useWallet();
|
|
2509
|
-
const walletIsInitialized = wallet2 && !isLoading && !isError;
|
|
2510
|
-
const sdkConfig = useConfig();
|
|
2511
|
-
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
2512
|
-
const { generateCancelTransactionAsync } = useGenerateCancelTransaction({
|
|
2513
|
-
chainId
|
|
2514
|
-
});
|
|
2515
|
-
const getWalletChainId = async () => {
|
|
2516
|
-
return await wallet2?.getChainId();
|
|
2517
|
-
};
|
|
2518
|
-
const switchChain = async () => {
|
|
2519
|
-
await wallet2?.switchChain(Number(chainId));
|
|
2520
|
-
};
|
|
2521
|
-
const checkAndSwitchChain = async () => {
|
|
2522
|
-
const walletChainId = await getWalletChainId();
|
|
2523
|
-
const isWaaS = wallet2?.isWaaS;
|
|
2524
|
-
const chainIdMismatch = walletChainId !== Number(chainId);
|
|
2525
|
-
return new Promise((resolve, reject) => {
|
|
2526
|
-
if (chainIdMismatch) {
|
|
2527
|
-
if (isWaaS) {
|
|
2528
|
-
switchChain().then(resolve).catch(reject);
|
|
2529
|
-
} else {
|
|
2530
|
-
showSwitchChainModal({
|
|
2531
|
-
chainIdToSwitchTo: chainId,
|
|
2532
|
-
onSuccess: () => resolve({ chainId }),
|
|
2533
|
-
onError: (error) => reject(error),
|
|
2534
|
-
onClose: () => reject(new ChainSwitchUserRejectedError())
|
|
2535
|
-
});
|
|
2536
|
-
}
|
|
2537
|
-
} else {
|
|
2538
|
-
resolve({ chainId });
|
|
2539
|
-
}
|
|
2540
|
-
});
|
|
2541
|
-
};
|
|
2542
|
-
const getCancelSteps = async ({
|
|
2543
|
-
orderId,
|
|
2544
|
-
marketplace
|
|
2545
|
-
}) => {
|
|
2546
|
-
try {
|
|
2547
|
-
const address = await wallet2?.address();
|
|
2548
|
-
if (!address) {
|
|
2549
|
-
throw new Error("Wallet address not found");
|
|
2550
|
-
}
|
|
2551
|
-
const steps = await generateCancelTransactionAsync({
|
|
2552
|
-
collectionAddress,
|
|
2553
|
-
maker: address,
|
|
2554
|
-
marketplace,
|
|
2555
|
-
orderId
|
|
2556
|
-
});
|
|
2557
|
-
return steps;
|
|
2558
|
-
} catch (error) {
|
|
2559
|
-
if (callbacks?.onError) {
|
|
2560
|
-
callbacks.onError(error);
|
|
2561
|
-
} else {
|
|
2562
|
-
console.debug("onError callback not provided:", error);
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
};
|
|
2566
|
-
const cancelOrder = async ({
|
|
2567
|
-
orderId,
|
|
2568
|
-
marketplace
|
|
2569
|
-
}) => {
|
|
2570
|
-
const queryClient = getQueryClient();
|
|
2571
|
-
if (!walletIsInitialized) {
|
|
2572
|
-
throw new WalletInstanceNotFoundError();
|
|
2573
|
-
}
|
|
2574
|
-
try {
|
|
2575
|
-
await checkAndSwitchChain();
|
|
2576
|
-
setSteps((prev) => ({
|
|
2577
|
-
...prev,
|
|
2578
|
-
isExecuting: true
|
|
2579
|
-
}));
|
|
2580
|
-
const cancelSteps = await getCancelSteps({
|
|
2581
|
-
orderId,
|
|
2582
|
-
marketplace
|
|
2583
|
-
});
|
|
2584
|
-
const transactionStep = cancelSteps?.find(
|
|
2585
|
-
(step) => step.id === "cancel" /* cancel */
|
|
2586
|
-
);
|
|
2587
|
-
const signatureStep = cancelSteps?.find(
|
|
2588
|
-
(step) => step.id === "signEIP712" /* signEIP712 */
|
|
2589
|
-
);
|
|
2590
|
-
console.debug("transactionStep", transactionStep);
|
|
2591
|
-
console.debug("signatureStep", signatureStep);
|
|
2592
|
-
if (!transactionStep && !signatureStep) {
|
|
2593
|
-
throw new Error("No transaction or signature step found");
|
|
2594
|
-
}
|
|
2595
|
-
let hash;
|
|
2596
|
-
let reservoirOrderId;
|
|
2597
|
-
if (transactionStep && wallet2) {
|
|
2598
|
-
hash = await executeTransaction({ transactionStep });
|
|
2599
|
-
if (hash) {
|
|
2600
|
-
await wallet2.handleConfirmTransactionStep(hash, Number(chainId));
|
|
2601
|
-
if (onSuccess && typeof onSuccess === "function") {
|
|
2602
|
-
onSuccess({ hash });
|
|
2603
|
-
updateQueriesOnCancel({
|
|
2604
|
-
orderId,
|
|
2605
|
-
queryClient
|
|
2606
|
-
});
|
|
2607
|
-
}
|
|
2608
|
-
setSteps((prev) => ({
|
|
2609
|
-
...prev,
|
|
2610
|
-
isExecuting: false
|
|
2611
|
-
}));
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
if (signatureStep) {
|
|
2615
|
-
reservoirOrderId = await executeSignature({ signatureStep });
|
|
2616
|
-
if (onSuccess && typeof onSuccess === "function") {
|
|
2617
|
-
onSuccess({ orderId: reservoirOrderId });
|
|
2618
|
-
updateQueriesOnCancel({
|
|
2619
|
-
orderId: reservoirOrderId,
|
|
2620
|
-
queryClient
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
|
-
setSteps((prev) => ({
|
|
2624
|
-
...prev,
|
|
2625
|
-
isExecuting: false
|
|
2626
|
-
}));
|
|
2627
|
-
}
|
|
2628
|
-
} catch (error) {
|
|
2629
|
-
invalidateQueriesOnCancel({
|
|
2630
|
-
queryClient
|
|
2631
|
-
});
|
|
2632
|
-
setSteps((prev) => ({
|
|
2633
|
-
...prev,
|
|
2634
|
-
isExecuting: false
|
|
2635
|
-
}));
|
|
2636
|
-
if (onError && typeof onError === "function") {
|
|
2637
|
-
onError(error);
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
};
|
|
2641
|
-
const executeTransaction = async ({
|
|
2642
|
-
transactionStep
|
|
2643
|
-
}) => {
|
|
2644
|
-
const hash = await wallet2?.handleSendTransactionStep(
|
|
2645
|
-
Number(chainId),
|
|
2646
|
-
transactionStep
|
|
2647
|
-
);
|
|
2648
|
-
return hash;
|
|
2649
|
-
};
|
|
2650
|
-
const executeSignature = async ({
|
|
2651
|
-
signatureStep
|
|
2652
|
-
}) => {
|
|
2653
|
-
const signature = await wallet2?.handleSignMessageStep(
|
|
2654
|
-
signatureStep
|
|
2655
|
-
);
|
|
2656
|
-
const result = await marketplaceClient.execute({
|
|
2657
|
-
signature,
|
|
2658
|
-
method: signatureStep.post?.method,
|
|
2659
|
-
endpoint: signatureStep.post?.endpoint,
|
|
2660
|
-
body: signatureStep.post?.body
|
|
2661
|
-
});
|
|
2662
|
-
return result.orderId;
|
|
2663
|
-
};
|
|
2664
|
-
return {
|
|
2665
|
-
cancelOrder
|
|
2666
|
-
};
|
|
2667
|
-
};
|
|
2668
|
-
|
|
2669
|
-
// src/react/hooks/useCancelOrder.tsx
|
|
2670
|
-
var useCancelOrder = ({
|
|
2671
|
-
collectionAddress,
|
|
2672
|
-
chainId,
|
|
2673
|
-
onSuccess,
|
|
2674
|
-
onError
|
|
2675
|
-
}) => {
|
|
2676
|
-
const [steps, setSteps] = useState({
|
|
2677
|
-
exist: false,
|
|
2678
|
-
isExecuting: false,
|
|
2679
|
-
execute: () => Promise.resolve()
|
|
2680
|
-
});
|
|
2681
|
-
const [cancellingOrderId, setCancellingOrderId] = useState(
|
|
2682
|
-
null
|
|
2683
|
-
);
|
|
2684
|
-
const [pendingFeeOptionConfirmation, confirmPendingFeeOption] = useWaasFeeOptions();
|
|
2685
|
-
const autoSelectOptionPromise = useAutoSelectFeeOption({
|
|
2686
|
-
pendingFeeOptionConfirmation: pendingFeeOptionConfirmation ? {
|
|
2687
|
-
id: pendingFeeOptionConfirmation.id,
|
|
2688
|
-
options: pendingFeeOptionConfirmation.options?.map((opt) => ({
|
|
2689
|
-
...opt,
|
|
2690
|
-
token: {
|
|
2691
|
-
...opt.token,
|
|
2692
|
-
contractAddress: opt.token.contractAddress || null,
|
|
2693
|
-
decimals: opt.token.decimals || 0,
|
|
2694
|
-
tokenID: opt.token.tokenID || null
|
|
2695
|
-
}
|
|
2696
|
-
})),
|
|
2697
|
-
chainId
|
|
2698
|
-
} : {
|
|
2699
|
-
id: "",
|
|
2700
|
-
options: void 0,
|
|
2701
|
-
chainId
|
|
2702
|
-
},
|
|
2703
|
-
enabled: !!pendingFeeOptionConfirmation
|
|
2704
|
-
});
|
|
2705
|
-
useEffect2(() => {
|
|
2706
|
-
autoSelectOptionPromise.then((res) => {
|
|
2707
|
-
if (pendingFeeOptionConfirmation?.id && res.selectedOption) {
|
|
2708
|
-
confirmPendingFeeOption(
|
|
2709
|
-
pendingFeeOptionConfirmation.id,
|
|
2710
|
-
res.selectedOption.token.contractAddress
|
|
2711
|
-
);
|
|
2712
|
-
}
|
|
2713
|
-
});
|
|
2714
|
-
}, [
|
|
2715
|
-
autoSelectOptionPromise,
|
|
2716
|
-
confirmPendingFeeOption,
|
|
2717
|
-
pendingFeeOptionConfirmation
|
|
2718
|
-
]);
|
|
2719
|
-
const { cancelOrder: cancelOrderBase } = useCancelTransactionSteps({
|
|
2720
|
-
collectionAddress,
|
|
2721
|
-
chainId,
|
|
2722
|
-
onSuccess: (result) => {
|
|
2723
|
-
setCancellingOrderId(null);
|
|
2724
|
-
onSuccess?.(result);
|
|
2725
|
-
},
|
|
2726
|
-
onError: (error) => {
|
|
2727
|
-
setCancellingOrderId(null);
|
|
2728
|
-
onError?.(error);
|
|
2729
|
-
},
|
|
2730
|
-
setSteps
|
|
2731
|
-
});
|
|
2732
|
-
const cancelOrder = async (params) => {
|
|
2733
|
-
setCancellingOrderId(params.orderId);
|
|
2734
|
-
return cancelOrderBase(params);
|
|
2735
|
-
};
|
|
2736
|
-
return {
|
|
2737
|
-
cancelOrder,
|
|
2738
|
-
isExecuting: steps.isExecuting,
|
|
2739
|
-
cancellingOrderId
|
|
2740
|
-
};
|
|
2741
|
-
};
|
|
2742
|
-
|
|
2743
|
-
// src/react/hooks/useCollectionDetails.tsx
|
|
2744
|
-
import { queryOptions as queryOptions19, useQuery as useQuery25 } from "@tanstack/react-query";
|
|
2745
|
-
var fetchCollectionDetails = async (args, marketplaceClient) => {
|
|
2746
|
-
const { collection } = await marketplaceClient.getCollectionDetail({
|
|
2747
|
-
contractAddress: args.collectionAddress
|
|
2748
|
-
});
|
|
2749
|
-
return collection;
|
|
2750
|
-
};
|
|
2751
|
-
var collectionDetailsOptions = (args, config) => {
|
|
2752
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
2753
|
-
return queryOptions19({
|
|
2754
|
-
queryKey: ["collectionDetails", args],
|
|
2755
|
-
queryFn: () => fetchCollectionDetails(args, marketplaceClient)
|
|
2756
|
-
});
|
|
2757
|
-
};
|
|
2758
|
-
var useCollectionDetails = (args) => {
|
|
2759
|
-
const config = useConfig();
|
|
2760
|
-
return useQuery25(collectionDetailsOptions(args, config));
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
|
-
// src/react/hooks/useCollectionDetailsPolling.tsx
|
|
2764
|
-
import { queryOptions as queryOptions20, useQuery as useQuery26 } from "@tanstack/react-query";
|
|
2765
|
-
var INITIAL_POLLING_INTERVAL = 2e3;
|
|
2766
|
-
var MAX_POLLING_INTERVAL = 3e4;
|
|
2767
|
-
var MAX_ATTEMPTS = 30;
|
|
2768
|
-
var isTerminalState = (status) => {
|
|
2769
|
-
return [
|
|
2770
|
-
"active" /* active */,
|
|
2771
|
-
"failed" /* failed */,
|
|
2772
|
-
"inactive" /* inactive */,
|
|
2773
|
-
"incompatible_type" /* incompatible_type */
|
|
2774
|
-
].includes(status);
|
|
2775
|
-
};
|
|
2776
|
-
var collectionDetailsPollingOptions = (args, config) => {
|
|
2777
|
-
return queryOptions20({
|
|
2778
|
-
...collectionDetailsOptions(args, config),
|
|
2779
|
-
refetchInterval: (query) => {
|
|
2780
|
-
const data = query.state.data;
|
|
2781
|
-
if (data && isTerminalState(data.status)) {
|
|
2782
|
-
return false;
|
|
2783
|
-
}
|
|
2784
|
-
const currentAttempt = (query.state.dataUpdateCount || 0) + 1;
|
|
2785
|
-
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
2786
|
-
return false;
|
|
2787
|
-
}
|
|
2788
|
-
const interval = Math.min(
|
|
2789
|
-
INITIAL_POLLING_INTERVAL * 1.5 ** currentAttempt,
|
|
2790
|
-
MAX_POLLING_INTERVAL
|
|
2791
|
-
);
|
|
2792
|
-
return interval;
|
|
2793
|
-
},
|
|
2794
|
-
refetchOnWindowFocus: false,
|
|
2795
|
-
retry: false
|
|
2796
|
-
});
|
|
2797
|
-
};
|
|
2798
|
-
var useCollectionDetailsPolling = (args) => {
|
|
2799
|
-
const config = useConfig();
|
|
2800
|
-
return useQuery26(collectionDetailsPollingOptions(args, config));
|
|
2801
|
-
};
|
|
2802
|
-
|
|
2803
|
-
export {
|
|
2804
|
-
MarketplaceSdkContext,
|
|
2805
|
-
MarketplaceQueryClientProvider,
|
|
2806
|
-
MarketplaceProvider,
|
|
2807
|
-
useConfig,
|
|
2808
|
-
collectionBalanceDetailsOptions,
|
|
2809
|
-
useCollectionBalanceDetails,
|
|
2810
|
-
useAutoSelectFeeOption,
|
|
2811
|
-
useMarketplaceConfig,
|
|
2812
|
-
useBalanceOfCollectible,
|
|
2813
|
-
countOfCollectablesOptions,
|
|
2814
|
-
useCountOfCollectables,
|
|
2815
|
-
collectibleOptions,
|
|
2816
|
-
useCollectible,
|
|
2817
|
-
useCollection,
|
|
2818
|
-
currenciesOptions,
|
|
2819
|
-
useCurrencies,
|
|
2820
|
-
convertPriceToUSD,
|
|
2821
|
-
convertPriceToUSDOptions,
|
|
2822
|
-
useConvertPriceToUSD,
|
|
2823
|
-
comparePricesOptions,
|
|
2824
|
-
useComparePrices,
|
|
2825
|
-
currencyOptions,
|
|
2826
|
-
useCurrency,
|
|
2827
|
-
fetchFilters,
|
|
2828
|
-
filtersOptions,
|
|
2829
|
-
useFilters,
|
|
2830
|
-
useFiltersProgressive,
|
|
2831
|
-
useFilterState,
|
|
2832
|
-
floorOrderOptions,
|
|
2833
|
-
useFloorOrder,
|
|
2834
|
-
useHighestOffer,
|
|
2835
|
-
useInventory,
|
|
2836
|
-
useListBalances,
|
|
2837
|
-
listCollectibleActivitiesOptions,
|
|
2838
|
-
useListCollectibleActivities,
|
|
2839
|
-
useListCollectibles,
|
|
2840
|
-
listCollectiblesPaginatedOptions,
|
|
2841
|
-
useListCollectiblesPaginated,
|
|
2842
|
-
listCollectionActivitiesOptions,
|
|
2843
|
-
useListCollectionActivities,
|
|
2844
|
-
listOffersForCollectibleOptions,
|
|
2845
|
-
useListOffersForCollectible,
|
|
2846
|
-
countOffersForCollectibleOptions,
|
|
2847
|
-
useCountOffersForCollectible,
|
|
2848
|
-
listListingsForCollectibleOptions,
|
|
2849
|
-
useListListingsForCollectible,
|
|
2850
|
-
countListingsForCollectibleOptions,
|
|
2851
|
-
useCountListingsForCollectible,
|
|
2852
|
-
useLowestListing,
|
|
2853
|
-
useRoyalty,
|
|
2854
|
-
dateToUnixTime,
|
|
2855
|
-
generateListingTransaction,
|
|
2856
|
-
useGenerateListingTransaction,
|
|
2857
|
-
useWallet,
|
|
2858
|
-
generateOfferTransaction,
|
|
2859
|
-
useGenerateOfferTransaction,
|
|
2860
|
-
generateSellTransaction,
|
|
2861
|
-
useGenerateSellTransaction,
|
|
2862
|
-
generateCancelTransaction,
|
|
2863
|
-
useGenerateCancelTransaction,
|
|
2864
|
-
useTransferTokens,
|
|
2865
|
-
checkoutOptionsOptions,
|
|
2866
|
-
useCheckoutOptions,
|
|
2867
|
-
listCollectionsOptions,
|
|
2868
|
-
useListCollections,
|
|
2869
|
-
AlertMessage,
|
|
2870
|
-
MODAL_OVERLAY_PROPS,
|
|
2871
|
-
MODAL_CONTENT_PROPS,
|
|
2872
|
-
useSwitchChainModal,
|
|
2873
|
-
switchChainModal_default,
|
|
2874
|
-
useCancelOrder,
|
|
2875
|
-
collectionDetailsOptions,
|
|
2876
|
-
useCollectionDetails,
|
|
2877
|
-
collectionDetailsPollingOptions,
|
|
2878
|
-
useCollectionDetailsPolling
|
|
2879
|
-
};
|
|
2880
|
-
//# sourceMappingURL=chunk-G3447GIP.js.map
|