@0xsequence/marketplace-sdk 0.7.0 → 0.8.1
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/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.changeset/seven-doors-taste.md +5 -0
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-MPBN3E54.js → chunk-2VHHJNXY.js} +3 -3
- package/dist/{chunk-FBUMNJQ4.js → chunk-3II5GLHE.js} +2 -2
- package/dist/chunk-3JU7SQVE.js +182 -0
- package/dist/chunk-3JU7SQVE.js.map +1 -0
- package/dist/{chunk-XTGMMNV5.js → chunk-A5ACY5YV.js} +2 -2
- package/dist/chunk-ABSYNRT5.js +128 -0
- package/dist/chunk-ABSYNRT5.js.map +1 -0
- package/dist/{chunk-XNA64MZQ.js → chunk-BCO4CYE4.js} +2 -2
- package/dist/{chunk-HTFORA4Q.js → chunk-BN36GABQ.js} +1883 -1010
- package/dist/chunk-BN36GABQ.js.map +1 -0
- package/dist/{chunk-4XK7XNJ7.js → chunk-BNAUZXPV.js} +73 -2
- package/dist/chunk-BNAUZXPV.js.map +1 -0
- package/dist/{chunk-Q5URKSC4.js → chunk-FMEEJFAF.js} +1 -1
- package/dist/{chunk-BBASZVT3.js → chunk-GBQVYNCD.js} +5 -6
- package/dist/chunk-GBQVYNCD.js.map +1 -0
- package/dist/{chunk-3AKOPSON.js → chunk-IZ44XPBH.js} +2 -9
- package/dist/chunk-IZ44XPBH.js.map +1 -0
- package/dist/{chunk-EAJ5K7QV.js → chunk-Q5RKAMYF.js} +3 -4
- package/dist/chunk-Q5RKAMYF.js.map +1 -0
- package/dist/{chunk-RBEPPVLT.js → chunk-X3QNSQER.js} +145 -355
- package/dist/chunk-X3QNSQER.js.map +1 -0
- package/dist/{index-CzTANLaA.d.ts → index-CnaFSNE9.d.ts} +6 -7
- package/dist/index.css +113 -31
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +4 -4
- package/dist/listCollectibles-B0tbqnRd.d.ts +155 -0
- package/dist/react/_internal/api/index.d.ts +28 -2
- package/dist/react/_internal/api/index.js +3 -1
- package/dist/react/_internal/databeat/index.js +10 -9
- package/dist/react/_internal/index.d.ts +2 -3
- package/dist/react/_internal/index.js +4 -4
- package/dist/react/_internal/wagmi/index.js +2 -2
- package/dist/react/hooks/index.d.ts +259 -674
- package/dist/react/hooks/index.js +11 -20
- package/dist/react/hooks/options/index.d.ts +1 -2
- package/dist/react/hooks/options/index.js +4 -4
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +15 -24
- package/dist/react/queries/index.d.ts +25 -0
- package/dist/react/queries/index.js +48 -0
- package/dist/react/queries/index.js.map +1 -0
- package/dist/react/ssr/index.js +3 -3
- package/dist/react/ui/components/collectible-card/index.d.ts +1 -6
- package/dist/react/ui/components/collectible-card/index.js +13 -12
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +6 -6
- package/dist/react/ui/index.d.ts +18 -22
- package/dist/react/ui/index.js +13 -12
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +6 -11
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +10 -9
- package/dist/types/index.js +2 -2
- package/dist/{types-Ct1uCT3M.d.ts → types-o_pKUpQG.d.ts} +2 -5
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/index.js +4 -4
- package/package.json +22 -16
- package/src/react/_internal/api/__mocks__/indexer.msw.ts +3 -1
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +1 -1
- package/src/react/_internal/api/__mocks__/metadata.msw.ts +14 -12
- package/src/react/_internal/api/index.ts +1 -0
- package/src/react/_internal/api/laos-api.ts +103 -0
- package/src/react/_internal/api/zod-schema.ts +3 -3
- package/src/react/_internal/types.ts +1 -10
- package/src/react/_internal/wallet/__tests__/wallet.test.ts +43 -0
- package/src/react/_internal/wallet/useWallet.ts +6 -3
- package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCancelOrder.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCollectible.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCollection.test.tsx +2 -2
- package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -1
- package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCurrencies.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCurrency.test.tsx +2 -2
- package/src/react/hooks/__tests__/useFilters.test.tsx +2 -2
- package/src/react/hooks/__tests__/useFloorOrder.test.tsx +2 -2
- package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -2
- package/src/react/hooks/__tests__/useListCollectibles.test.tsx +3 -2
- package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useLowestListing.test.tsx +1 -1
- package/src/react/hooks/__tests__/useRoyalty.test.tsx +1 -2
- package/src/react/hooks/index.ts +0 -1
- package/src/react/hooks/options/collectionOptions.ts +2 -3
- package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -1
- package/src/react/hooks/useCancelOrder.tsx +3 -3
- package/src/react/hooks/useCancelTransactionSteps.tsx +1 -1
- package/src/react/hooks/useCheckoutOptions.tsx +1 -2
- package/src/react/hooks/useCollectible.tsx +2 -3
- package/src/react/hooks/useCollectionBalanceDetails.tsx +1 -2
- package/src/react/hooks/useComparePrices.tsx +2 -9
- package/src/react/hooks/useConvertPriceToUSD.tsx +1 -4
- package/src/react/hooks/useCountListingsForCollectible.tsx +1 -2
- package/src/react/hooks/useCountOfCollectables.tsx +1 -2
- package/src/react/hooks/useCountOffersForCollectible.tsx +1 -2
- package/src/react/hooks/useCurrencies.tsx +1 -4
- package/src/react/hooks/useCurrency.tsx +3 -8
- package/src/react/hooks/useFilters.tsx +5 -4
- package/src/react/hooks/useFloorOrder.tsx +1 -2
- package/src/react/hooks/useGenerateCancelTransaction.tsx +3 -6
- package/src/react/hooks/useGenerateListingTransaction.tsx +2 -3
- package/src/react/hooks/useGenerateOfferTransaction.tsx +2 -3
- package/src/react/hooks/useGenerateSellTransaction.tsx +3 -6
- package/src/react/hooks/useHighestOffer.tsx +1 -1
- package/src/react/hooks/useListCollectibles.tsx +33 -61
- package/src/react/hooks/useListCollectiblesPaginated.tsx +2 -6
- package/src/react/hooks/useListListingsForCollectible.tsx +1 -2
- package/src/react/hooks/useListOffersForCollectible.tsx +1 -2
- package/src/react/hooks/useLowestListing.tsx +1 -2
- package/src/react/hooks/useRoyalty.tsx +3 -8
- package/src/react/hooks/useTransferTokens.tsx +2 -2
- package/src/react/queries/balanceOfCollectible.ts +9 -32
- package/src/react/queries/getTokenSupplies.ts +38 -0
- package/src/react/queries/index.ts +5 -0
- package/src/react/queries/listCollectibles.ts +96 -0
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
- package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +1 -1
- package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -3
- package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +1 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -3
- package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +1 -1
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +127 -0
- package/src/react/ui/modals/BuyModal/Modal.tsx +70 -85
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +85 -226
- package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +140 -0
- package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +67 -76
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +1 -60
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +1 -1
- package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +29 -13
- package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +26 -21
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +200 -0
- package/src/react/ui/modals/BuyModal/index.tsx +4 -14
- package/src/react/ui/modals/BuyModal/store.ts +71 -76
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +71 -7
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +2 -2
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +1 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +9 -5
- package/src/react/ui/modals/CreateListingModal/store.ts +7 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +103 -6
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +8 -4
- package/src/react/ui/modals/MakeOfferModal/store.ts +5 -3
- package/src/react/ui/modals/SellModal/Modal.tsx +76 -4
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +16 -8
- package/src/react/ui/modals/SellModal/store.ts +5 -3
- package/src/react/ui/modals/TransferModal/_store.ts +15 -3
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +58 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx +56 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +50 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +94 -66
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +22 -14
- package/src/react/ui/modals/TransferModal/index.tsx +72 -38
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +43 -42
- package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +9 -1
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +27 -12
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -1
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +19 -3
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx +60 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx +30 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +126 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts +25 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +74 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +1 -2
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -2
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +4 -7
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +6 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +2 -2
- package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +10 -31
- package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +53 -0
- package/src/react/ui/modals/_internal/types.ts +2 -1
- package/src/types/waas-types.ts +38 -0
- package/src/utils/network.ts +2 -4
- package/test/const.ts +1 -1
- package/test/setup.ts +10 -0
- package/test/test-utils.tsx +31 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-3AKOPSON.js.map +0 -1
- package/dist/chunk-4XK7XNJ7.js.map +0 -1
- package/dist/chunk-BBASZVT3.js.map +0 -1
- package/dist/chunk-EAJ5K7QV.js.map +0 -1
- package/dist/chunk-HTFORA4Q.js.map +0 -1
- package/dist/chunk-OFY7OFTL.js +0 -458
- package/dist/chunk-OFY7OFTL.js.map +0 -1
- package/dist/chunk-RBEPPVLT.js.map +0 -1
- package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +0 -172
- package/src/react/hooks/useGenerateBuyTransaction.tsx +0 -80
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +0 -349
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +0 -185
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +0 -170
- package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +0 -47
- package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +0 -140
- package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +0 -162
- package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +0 -327
- package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/index.tsx +0 -124
- package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/store.ts +0 -12
- /package/dist/{chunk-MPBN3E54.js.map → chunk-2VHHJNXY.js.map} +0 -0
- /package/dist/{chunk-FBUMNJQ4.js.map → chunk-3II5GLHE.js.map} +0 -0
- /package/dist/{chunk-XTGMMNV5.js.map → chunk-A5ACY5YV.js.map} +0 -0
- /package/dist/{chunk-XNA64MZQ.js.map → chunk-BCO4CYE4.js.map} +0 -0
- /package/dist/{chunk-Q5URKSC4.js.map → chunk-FMEEJFAF.js.map} +0 -0
|
@@ -2,7 +2,6 @@ import { useMutation } from '@tanstack/react-query';
|
|
|
2
2
|
import type { SdkConfig } from '../../types';
|
|
3
3
|
import { dateToUnixTime } from '../../utils/date';
|
|
4
4
|
import {
|
|
5
|
-
type ChainId,
|
|
6
5
|
type CreateReq,
|
|
7
6
|
type GenerateOfferTransactionArgs,
|
|
8
7
|
type Step,
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
import { useConfig } from './useConfig';
|
|
12
11
|
|
|
13
12
|
export type UseGenerateOfferTransactionArgs = {
|
|
14
|
-
chainId:
|
|
13
|
+
chainId: number;
|
|
15
14
|
onSuccess?: (data?: Step[]) => void;
|
|
16
15
|
};
|
|
17
16
|
|
|
@@ -29,7 +28,7 @@ export type GenerateOfferTransactionProps = Omit<
|
|
|
29
28
|
export const generateOfferTransaction = async (
|
|
30
29
|
params: GenerateOfferTransactionProps,
|
|
31
30
|
config: SdkConfig,
|
|
32
|
-
chainId:
|
|
31
|
+
chainId: number,
|
|
33
32
|
) => {
|
|
34
33
|
const args = {
|
|
35
34
|
...params,
|
|
@@ -2,8 +2,6 @@ import { useMutation } from '@tanstack/react-query';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { SdkConfig } from '../../types';
|
|
4
4
|
import {
|
|
5
|
-
type ChainId,
|
|
6
|
-
ChainIdSchema,
|
|
7
5
|
type GenerateSellTransactionArgs,
|
|
8
6
|
getMarketplaceClient,
|
|
9
7
|
} from '../_internal';
|
|
@@ -11,7 +9,7 @@ import { stepSchema } from '../_internal/api/zod-schema';
|
|
|
11
9
|
import { useConfig } from './useConfig';
|
|
12
10
|
|
|
13
11
|
const UserGeneratSellTransactionArgsSchema = z.object({
|
|
14
|
-
chainId:
|
|
12
|
+
chainId: z.number(),
|
|
15
13
|
onSuccess: z.function().args(stepSchema.array().optional()).optional(),
|
|
16
14
|
});
|
|
17
15
|
|
|
@@ -22,10 +20,9 @@ type UseGenerateSellTransactionArgs = z.infer<
|
|
|
22
20
|
export const generateSellTransaction = async (
|
|
23
21
|
args: GenerateSellTransactionArgs,
|
|
24
22
|
config: SdkConfig,
|
|
25
|
-
chainId:
|
|
23
|
+
chainId: number,
|
|
26
24
|
) => {
|
|
27
|
-
const
|
|
28
|
-
const marketplaceClient = getMarketplaceClient(parsedChainId, config);
|
|
25
|
+
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
29
26
|
return marketplaceClient
|
|
30
27
|
.generateSellTransaction(args)
|
|
31
28
|
.then((data) => data.steps);
|
|
@@ -1,67 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
AddressSchema,
|
|
6
|
-
ChainIdSchema,
|
|
7
|
-
type ListCollectiblesArgs,
|
|
8
|
-
QueryArgSchema,
|
|
9
|
-
collectableKeys,
|
|
10
|
-
getMarketplaceClient,
|
|
11
|
-
} from '../_internal';
|
|
12
|
-
import { listCollectiblesArgsSchema } from '../_internal/api/zod-schema';
|
|
1
|
+
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { listCollectiblesOptions } from '../queries/listCollectibles';
|
|
3
|
+
import type { UseListCollectiblesArgs } from '../queries/listCollectibles';
|
|
13
4
|
import { useConfig } from './useConfig';
|
|
5
|
+
import { useMarketplaceConfig } from './useMarketplaceConfig';
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
) => {
|
|
38
|
-
const parsedArgs = UseListCollectiblesArgsSchema.parse(args);
|
|
39
|
-
const arg = {
|
|
40
|
-
...parsedArgs,
|
|
41
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
42
|
-
page: page,
|
|
43
|
-
} satisfies ListCollectiblesArgs;
|
|
7
|
+
/**
|
|
8
|
+
* Hook to fetch a list of collectibles with pagination support
|
|
9
|
+
*
|
|
10
|
+
* @param args - The arguments for fetching the collectibles
|
|
11
|
+
* @returns Infinite query result containing the collectibles data including orders
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { data, isLoading, error, fetchNextPage } = useListCollectibles({
|
|
16
|
+
* chainId: 1,
|
|
17
|
+
* collectionAddress: '0x123...',
|
|
18
|
+
* includeMetadata: true,
|
|
19
|
+
* query: {
|
|
20
|
+
* enabled: true,
|
|
21
|
+
* refetchInterval: 10000,
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function useListCollectibles(args: UseListCollectiblesArgs) {
|
|
27
|
+
const config = useConfig();
|
|
28
|
+
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
const isLaos721 = marketplaceConfig?.collections.find(
|
|
31
|
+
(collection) => collection.address === args.collectionAddress,
|
|
32
|
+
)?.isLAOSERC721;
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
) => {
|
|
52
|
-
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
53
|
-
return infiniteQueryOptions({
|
|
54
|
-
queryKey: [...collectableKeys.lists, args],
|
|
55
|
-
queryFn: ({ pageParam }) =>
|
|
56
|
-
fetchCollectibles(args, marketplaceClient, pageParam),
|
|
57
|
-
initialPageParam: { page: 1, pageSize: 30 },
|
|
58
|
-
getNextPageParam: (lastPage) =>
|
|
59
|
-
lastPage.page?.more ? lastPage.page : undefined,
|
|
60
|
-
enabled: args.query?.enabled ?? true,
|
|
61
|
-
});
|
|
62
|
-
};
|
|
34
|
+
if (isLaos721) {
|
|
35
|
+
args.isLaos721 = true;
|
|
36
|
+
}
|
|
63
37
|
|
|
64
|
-
export const useListCollectibles = (args: UseListCollectiblesArgs) => {
|
|
65
|
-
const config = useConfig();
|
|
66
38
|
return useInfiniteQuery(listCollectiblesOptions(args, config));
|
|
67
|
-
}
|
|
39
|
+
}
|
|
@@ -3,7 +3,6 @@ import { z } from 'zod';
|
|
|
3
3
|
import type { Page, SdkConfig } from '../../types';
|
|
4
4
|
import {
|
|
5
5
|
AddressSchema,
|
|
6
|
-
ChainIdSchema,
|
|
7
6
|
type ListCollectiblesArgs,
|
|
8
7
|
collectableKeys,
|
|
9
8
|
getMarketplaceClient,
|
|
@@ -17,7 +16,7 @@ const UseListCollectiblesPaginatedArgsSchema = listCollectiblesArgsSchema
|
|
|
17
16
|
})
|
|
18
17
|
.extend({
|
|
19
18
|
collectionAddress: AddressSchema,
|
|
20
|
-
chainId:
|
|
19
|
+
chainId: z.number(),
|
|
21
20
|
query: z
|
|
22
21
|
.object({
|
|
23
22
|
enabled: z.boolean().optional(),
|
|
@@ -59,10 +58,7 @@ export const listCollectiblesPaginatedOptions = (
|
|
|
59
58
|
args: UseListCollectiblesPaginatedArgs,
|
|
60
59
|
config: SdkConfig,
|
|
61
60
|
) => {
|
|
62
|
-
const marketplaceClient = getMarketplaceClient(
|
|
63
|
-
args.chainId as string,
|
|
64
|
-
config,
|
|
65
|
-
);
|
|
61
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
66
62
|
return queryOptions({
|
|
67
63
|
queryKey: [...collectableKeys.lists, 'paginated', args],
|
|
68
64
|
queryFn: () => fetchCollectiblesPaginated(args, marketplaceClient),
|
|
@@ -2,7 +2,6 @@ import { queryOptions, useQuery } from '@tanstack/react-query';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { SdkConfig } from '../../types';
|
|
4
4
|
import {
|
|
5
|
-
ChainIdSchema,
|
|
6
5
|
type ListListingsForCollectibleArgs,
|
|
7
6
|
collectableKeys,
|
|
8
7
|
getMarketplaceClient,
|
|
@@ -13,7 +12,7 @@ import { useConfig } from './useConfig';
|
|
|
13
12
|
const UseListListingsForCollectibleArgsSchema =
|
|
14
13
|
listListingsForCollectibleArgsSchema
|
|
15
14
|
.extend({
|
|
16
|
-
chainId:
|
|
15
|
+
chainId: z.number(),
|
|
17
16
|
collectionAddress: z.string(),
|
|
18
17
|
collectibleId: z.string(),
|
|
19
18
|
})
|
|
@@ -2,7 +2,6 @@ import { queryOptions, useQuery } from '@tanstack/react-query';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { SdkConfig } from '../../types';
|
|
4
4
|
import {
|
|
5
|
-
ChainIdSchema,
|
|
6
5
|
type ListOffersForCollectibleArgs,
|
|
7
6
|
collectableKeys,
|
|
8
7
|
getMarketplaceClient,
|
|
@@ -12,7 +11,7 @@ import { useConfig } from './useConfig';
|
|
|
12
11
|
|
|
13
12
|
const UseListOffersForCollectibleArgsSchema = listOffersForCollectibleArgsSchema
|
|
14
13
|
.extend({
|
|
15
|
-
chainId:
|
|
14
|
+
chainId: z.number(),
|
|
16
15
|
collectionAddress: z.string(),
|
|
17
16
|
collectibleId: z.string(),
|
|
18
17
|
})
|
|
@@ -3,7 +3,6 @@ import { z } from 'zod';
|
|
|
3
3
|
import type { SdkConfig } from '../../types';
|
|
4
4
|
import {
|
|
5
5
|
AddressSchema,
|
|
6
|
-
ChainIdSchema,
|
|
7
6
|
QueryArgSchema,
|
|
8
7
|
collectableKeys,
|
|
9
8
|
getMarketplaceClient,
|
|
@@ -17,7 +16,7 @@ const UseLowestListingSchema = getCollectibleLowestListingArgsSchema
|
|
|
17
16
|
})
|
|
18
17
|
.extend({
|
|
19
18
|
collectionAddress: AddressSchema,
|
|
20
|
-
chainId:
|
|
19
|
+
chainId: z.number(),
|
|
21
20
|
query: QueryArgSchema,
|
|
22
21
|
});
|
|
23
22
|
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { useReadContract } from 'wagmi';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { EIP2981_ABI } from '../../utils';
|
|
4
|
-
import {
|
|
5
|
-
AddressSchema,
|
|
6
|
-
ChainIdSchema,
|
|
7
|
-
QueryArgSchema,
|
|
8
|
-
collectableKeys,
|
|
9
|
-
} from '../_internal';
|
|
4
|
+
import { AddressSchema, QueryArgSchema, collectableKeys } from '../_internal';
|
|
10
5
|
|
|
11
6
|
const UseRoyaltySchema = z.object({
|
|
12
|
-
chainId:
|
|
7
|
+
chainId: z.number(),
|
|
13
8
|
collectionAddress: AddressSchema,
|
|
14
9
|
collectibleId: z.string(),
|
|
15
10
|
query: QueryArgSchema.optional(),
|
|
@@ -27,7 +22,7 @@ export const useRoyalty = (args: UseRoyaltyArgs) => {
|
|
|
27
22
|
address: collectionAddress,
|
|
28
23
|
functionName: 'royaltyInfo',
|
|
29
24
|
args: [BigInt(collectibleId), BigInt(100)],
|
|
30
|
-
chainId
|
|
25
|
+
chainId,
|
|
31
26
|
query: query,
|
|
32
27
|
});
|
|
33
28
|
|
|
@@ -2,10 +2,10 @@ import { type Abi, type Address, type Hex, erc721Abi } from 'viem';
|
|
|
2
2
|
import { useAccount, useWriteContract } from 'wagmi';
|
|
3
3
|
import { ERC1155_ABI } from '../../utils';
|
|
4
4
|
import { NoWalletConnectedError } from '../../utils/_internal/error/transaction';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ContractType } from '../_internal';
|
|
6
6
|
|
|
7
7
|
interface BaseTransferParams {
|
|
8
|
-
chainId:
|
|
8
|
+
chainId: number;
|
|
9
9
|
collectionAddress: Hex;
|
|
10
10
|
tokenId: string;
|
|
11
11
|
receiverAddress: Address;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { GetTokenBalancesReturn } from '@0xsequence/indexer';
|
|
2
1
|
import { queryOptions, skipToken } from '@tanstack/react-query';
|
|
3
2
|
import type { Hex } from 'viem';
|
|
4
3
|
import type { UseQueryParameters } from 'wagmi/query';
|
|
5
4
|
import type { SdkConfig } from '../../types';
|
|
6
|
-
import { collectableKeys, getIndexerClient } from '../_internal';
|
|
5
|
+
import { LaosAPI, collectableKeys, getIndexerClient } from '../_internal';
|
|
7
6
|
|
|
8
7
|
export type UseBalanceOfCollectibleArgs = {
|
|
9
8
|
collectionAddress: Hex;
|
|
@@ -22,40 +21,18 @@ export type UseBalanceOfCollectibleArgs = {
|
|
|
22
21
|
* @returns The balance data
|
|
23
22
|
*/
|
|
24
23
|
export async function fetchBalanceOfCollectible(
|
|
25
|
-
args: UseBalanceOfCollectibleArgs,
|
|
24
|
+
args: Omit<UseBalanceOfCollectibleArgs, 'userAddress'> & { userAddress: Hex },
|
|
26
25
|
config: SdkConfig,
|
|
27
26
|
) {
|
|
28
27
|
if (args.isLaos721) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
chainId: args.chainId.toString(),
|
|
38
|
-
accountAddress: args.userAddress,
|
|
39
|
-
includeMetadata: true,
|
|
40
|
-
page: {
|
|
41
|
-
sort: [
|
|
42
|
-
{
|
|
43
|
-
column: 'CREATED_AT',
|
|
44
|
-
order: 'DESC',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw new Error(`Laos API request failed with status ${response.status}`);
|
|
54
|
-
}
|
|
28
|
+
const laosApi = new LaosAPI();
|
|
29
|
+
const response = await laosApi.getTokenBalances({
|
|
30
|
+
chainId: args.chainId.toString(),
|
|
31
|
+
accountAddress: args.userAddress,
|
|
32
|
+
includeMetadata: true,
|
|
33
|
+
});
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
const data = (await response.json()) as GetTokenBalancesReturn;
|
|
58
|
-
return data.balances[0] || null;
|
|
35
|
+
return response.balances[0] || null;
|
|
59
36
|
}
|
|
60
37
|
|
|
61
38
|
const indexerClient = getIndexerClient(args.chainId, config);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { SdkConfig } from '../../types';
|
|
3
|
+
//TODO: This is not complete, there is no hook for this,
|
|
4
|
+
// add it if we need it in the future
|
|
5
|
+
import { LaosAPI, getIndexerClient } from '../_internal';
|
|
6
|
+
|
|
7
|
+
export type UseGetTokenSuppliesArgs = {
|
|
8
|
+
chainId: number;
|
|
9
|
+
contractAddress: string;
|
|
10
|
+
tokenId: string;
|
|
11
|
+
isLaos721?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function getTokenSupplies(
|
|
15
|
+
args: UseGetTokenSuppliesArgs,
|
|
16
|
+
config: SdkConfig,
|
|
17
|
+
) {
|
|
18
|
+
if (args.isLaos721) {
|
|
19
|
+
const laosApi = new LaosAPI();
|
|
20
|
+
return laosApi.getTokenSupplies({
|
|
21
|
+
chainId: args.chainId.toString(),
|
|
22
|
+
contractAddress: args.contractAddress,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const indexerClient = getIndexerClient(args.chainId, config);
|
|
27
|
+
return await indexerClient.getTokenSupplies(args);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getTokenSuppliesOptions(
|
|
31
|
+
args: UseGetTokenSuppliesArgs,
|
|
32
|
+
config: SdkConfig,
|
|
33
|
+
) {
|
|
34
|
+
return queryOptions({
|
|
35
|
+
queryKey: ['getTokenSupplies', args],
|
|
36
|
+
queryFn: () => getTokenSupplies(args, config),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { infiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { Hex } from 'viem';
|
|
3
|
+
import type { Page, SdkConfig } from '../../types';
|
|
4
|
+
import type {
|
|
5
|
+
CollectibleOrder,
|
|
6
|
+
CollectiblesFilter,
|
|
7
|
+
ListCollectiblesArgs,
|
|
8
|
+
ListCollectiblesReturn,
|
|
9
|
+
} from '../_internal';
|
|
10
|
+
import { OrderSide, collectableKeys, getMarketplaceClient } from '../_internal';
|
|
11
|
+
import { fetchBalances } from './listBalances';
|
|
12
|
+
export type UseListCollectiblesArgs = {
|
|
13
|
+
collectionAddress: Hex;
|
|
14
|
+
chainId: number;
|
|
15
|
+
side: OrderSide;
|
|
16
|
+
filter?: CollectiblesFilter;
|
|
17
|
+
isLaos721?: boolean;
|
|
18
|
+
query?: {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fetches a list of collectibles with pagination support
|
|
25
|
+
*
|
|
26
|
+
* @param args - Arguments for the API call
|
|
27
|
+
* @param config - SDK configuration
|
|
28
|
+
* @param page - Page parameters for pagination
|
|
29
|
+
* @returns The collectibles data
|
|
30
|
+
*/
|
|
31
|
+
export async function fetchCollectibles(
|
|
32
|
+
args: UseListCollectiblesArgs,
|
|
33
|
+
config: SdkConfig,
|
|
34
|
+
page: Page,
|
|
35
|
+
): Promise<ListCollectiblesReturn> {
|
|
36
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
37
|
+
const parsedArgs = {
|
|
38
|
+
...args,
|
|
39
|
+
contractAddress: args.collectionAddress,
|
|
40
|
+
page: page,
|
|
41
|
+
side: args.side,
|
|
42
|
+
} satisfies ListCollectiblesArgs;
|
|
43
|
+
|
|
44
|
+
if (args.isLaos721 && args.side === OrderSide.listing) {
|
|
45
|
+
try {
|
|
46
|
+
const balances = await fetchBalances(args, config, page);
|
|
47
|
+
const collectibles: CollectibleOrder[] = balances.balances.map(
|
|
48
|
+
(balance) => {
|
|
49
|
+
if (!balance.tokenMetadata)
|
|
50
|
+
throw new Error('Token metadata not found');
|
|
51
|
+
return {
|
|
52
|
+
metadata: {
|
|
53
|
+
tokenId: balance.tokenID ?? '',
|
|
54
|
+
attributes: balance.tokenMetadata.attributes,
|
|
55
|
+
image: balance.tokenMetadata.image,
|
|
56
|
+
name: balance.tokenMetadata.name,
|
|
57
|
+
description: balance.tokenMetadata.description,
|
|
58
|
+
video: balance.tokenMetadata.video,
|
|
59
|
+
audio: balance.tokenMetadata.audio,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
return {
|
|
65
|
+
collectibles: collectibles,
|
|
66
|
+
//@ts-expect-error
|
|
67
|
+
page: balances.page,
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
// If the request fails, ignore the error and return the collectibles from our indexer
|
|
71
|
+
console.error(error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return await marketplaceClient.listCollectibles(parsedArgs);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a tanstack infinite query options object for the collectibles query
|
|
79
|
+
*
|
|
80
|
+
* @param args - The query arguments
|
|
81
|
+
* @param config - SDK configuration
|
|
82
|
+
* @returns Query options configuration
|
|
83
|
+
*/
|
|
84
|
+
export function listCollectiblesOptions(
|
|
85
|
+
args: UseListCollectiblesArgs,
|
|
86
|
+
config: SdkConfig,
|
|
87
|
+
) {
|
|
88
|
+
return infiniteQueryOptions({
|
|
89
|
+
...args.query,
|
|
90
|
+
queryKey: [...collectableKeys.lists, args, config],
|
|
91
|
+
queryFn: ({ pageParam }) => fetchCollectibles(args, config, pageParam),
|
|
92
|
+
initialPageParam: { page: 1, pageSize: 30 } as Page,
|
|
93
|
+
getNextPageParam: (lastPage) =>
|
|
94
|
+
lastPage.page?.more ? lastPage.page : undefined,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -9,7 +9,7 @@ import { useActionButtonLogic } from './hooks/useActionButtonLogic';
|
|
|
9
9
|
import type { CollectibleCardAction } from './types';
|
|
10
10
|
|
|
11
11
|
type ActionButtonProps = {
|
|
12
|
-
chainId:
|
|
12
|
+
chainId: number;
|
|
13
13
|
collectionAddress: Hex;
|
|
14
14
|
tokenId: string;
|
|
15
15
|
orderbookKind?: OrderbookKind;
|
|
@@ -13,7 +13,7 @@ type NonOwnerActionsProps = {
|
|
|
13
13
|
action: CollectibleCardAction;
|
|
14
14
|
tokenId: string;
|
|
15
15
|
collectionAddress: Hex;
|
|
16
|
-
chainId:
|
|
16
|
+
chainId: number;
|
|
17
17
|
orderbookKind?: OrderbookKind;
|
|
18
18
|
lowestListing?: Order;
|
|
19
19
|
};
|
|
@@ -43,8 +43,9 @@ export function NonOwnerActions({
|
|
|
43
43
|
showBuyModal({
|
|
44
44
|
collectionAddress,
|
|
45
45
|
chainId,
|
|
46
|
-
tokenId,
|
|
47
|
-
|
|
46
|
+
collectibleId: tokenId,
|
|
47
|
+
orderId: lowestListing.orderId,
|
|
48
|
+
marketplace: lowestListing.marketplace,
|
|
48
49
|
})
|
|
49
50
|
}
|
|
50
51
|
icon={SvgCartIcon}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { Skeleton } from '@0xsequence/design-system';
|
|
4
4
|
import type { Hex } from 'viem';
|
|
5
5
|
import type {
|
|
6
|
-
ChainId,
|
|
7
6
|
CollectibleOrder,
|
|
8
7
|
ContractType,
|
|
9
8
|
Order,
|
|
@@ -37,7 +36,7 @@ function CollectibleSkeleton() {
|
|
|
37
36
|
|
|
38
37
|
type CollectibleCardProps = {
|
|
39
38
|
collectibleId: string;
|
|
40
|
-
chainId:
|
|
39
|
+
chainId: number;
|
|
41
40
|
collectionAddress: Hex;
|
|
42
41
|
orderbookKind?: OrderbookKind;
|
|
43
42
|
collectionType?: ContractType;
|
|
@@ -142,7 +141,7 @@ export function CollectibleCard({
|
|
|
142
141
|
{(highestOffer || lowestListing) && (
|
|
143
142
|
<div className="-bottom-action-offset absolute flex w-full items-center justify-center bg-overlay-light p-2 backdrop-blur transition-transform duration-200 ease-in-out group-hover:translate-y-[-44px]">
|
|
144
143
|
<ActionButton
|
|
145
|
-
chainId={
|
|
144
|
+
chainId={chainId}
|
|
146
145
|
collectionAddress={collectionAddress}
|
|
147
146
|
tokenId={collectibleId}
|
|
148
147
|
orderbookKind={orderbookKind}
|
|
@@ -37,7 +37,7 @@ describe.skip('CollectibleCard', () => {
|
|
|
37
37
|
// };
|
|
38
38
|
// const defaultProps = {
|
|
39
39
|
// collectibleId: '123',
|
|
40
|
-
// chainId:
|
|
40
|
+
// chainId: 1,
|
|
41
41
|
// collectionAddress:
|
|
42
42
|
// '0x1234567890123456789012345678901234567890' as `0x${string}`,
|
|
43
43
|
// lowestListing: {
|