@0xsequence/marketplace-sdk 1.0.0 → 1.1.0
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/.storybook/main.ts +1 -1
- package/.storybook/preview.tsx +0 -1
- package/CHANGELOG.md +62 -13
- package/dist/BellIcon-IpHHEy8h.js +45 -0
- package/dist/BellIcon-IpHHEy8h.js.map +1 -0
- package/dist/{BellIcon-Cb9YEUzJ.js → CartIcon-C8zbor8H.js} +10 -49
- package/dist/CartIcon-C8zbor8H.js.map +1 -0
- package/dist/CollectibleCard-C2EWF0zo.d.ts +8 -0
- package/dist/{_internal-DslqcNC1.js → _internal-DkS2VUn5.js} +1 -1
- package/dist/{_internal-DslqcNC1.js.map → _internal-DkS2VUn5.js.map} +1 -1
- package/dist/{alien_swap-DJ98gZQp.js → alien_swap-BTJ7mSR-.js} +1 -1
- package/dist/{alien_swap-DJ98gZQp.js.map → alien_swap-BTJ7mSR-.js.map} +1 -1
- package/dist/{api-BmEQfSQa.js → api-DuLKn__v.js} +5 -3
- package/dist/api-DuLKn__v.js.map +1 -0
- package/dist/{aqua-xyz-n1PcCCZ0.js → aqua-xyz-BYJ9WSP_.js} +1 -1
- package/dist/{aqua-xyz-n1PcCCZ0.js.map → aqua-xyz-BYJ9WSP_.js.map} +1 -1
- package/dist/{aura-Bevk_YkS.js → aura-D7SUjgro.js} +1 -1
- package/dist/{aura-Bevk_YkS.js.map → aura-D7SUjgro.js.map} +1 -1
- package/dist/{blur-B5sHErx5.js → blur-BcnRFCaV.js} +1 -1
- package/dist/{blur-B5sHErx5.js.map → blur-BcnRFCaV.js.map} +1 -1
- package/dist/builder-api-BFuZNOaN.js.map +1 -1
- package/dist/builder.gen-B9wR2nvF.js.map +1 -1
- package/dist/{coinbase-D30W-lxA.js → coinbase-ChoX9Hw2.js} +1 -1
- package/dist/{coinbase-D30W-lxA.js.map → coinbase-ChoX9Hw2.js.map} +1 -1
- package/dist/components-CUv-wQr8.js +119 -0
- package/dist/components-CUv-wQr8.js.map +1 -0
- package/dist/{contracts-DPHFT2TA.js → contracts-D72LBOX3.js} +4 -5
- package/dist/{contracts-DPHFT2TA.js.map → contracts-D72LBOX3.js.map} +1 -1
- package/dist/{create-config-6uynwTeb.js → create-config-CIfejoCk.js} +6 -11
- package/dist/create-config-CIfejoCk.js.map +1 -0
- package/dist/{create-config-lLSrnkbb.d.ts → create-config-DV_dtaLt.d.ts} +24 -31
- package/dist/{element-C2NJexro.js → element-Dbcv5qya.js} +1 -1
- package/dist/{element-C2NJexro.js.map → element-Dbcv5qya.js.map} +1 -1
- package/dist/{filters-B8XS4tFH.d.ts → filters-zkMJaPey.d.ts} +6 -6
- package/dist/{foundation-QgY1lvUj.js → foundation-QPhUEUy8.js} +1 -1
- package/dist/{foundation-QgY1lvUj.js.map → foundation-QPhUEUy8.js.map} +1 -1
- package/dist/{index-ChSKFOMx.d.ts → index-B6aSbaw2.d.ts} +1 -1
- package/dist/{index-PSPpUxCE.d.ts → index-B8vaT3_s.d.ts} +4 -4
- package/dist/{index-DonXiSg2.d.ts → index-BaytncQc.d.ts} +100 -56
- package/dist/{index-CY5UEX4h.d.ts → index-BoNNplSx.d.ts} +2 -2
- package/dist/{index-QxxS6f9r.d.ts → index-Bv5XVLjH.d.ts} +1 -1
- package/dist/{index-CIkpYltz.d.ts → index-C768pAfu.d.ts} +3 -3
- package/dist/{index-DX0Vm8HY.d.ts → index-CM0ZTePs.d.ts} +1 -1
- package/dist/index-CMPUveNz.d.ts +64 -0
- package/dist/{index-ThUIs-Sy.d.ts → index-CQecU53t.d.ts} +28 -23
- package/dist/{index-CtF7EE2z.d.ts → index-CT8ZorFd.d.ts} +1 -1
- package/dist/{index-Dpyp7fQz.d.ts → index-CXscCUg7.d.ts} +12 -12
- package/dist/{index-ByW08-Z7.d.ts → index-D-UXGo5d.d.ts} +2 -2
- package/dist/{index-D71J5Ghd.d.ts → index-D6YMj82n.d.ts} +79 -79
- package/dist/{index-CQnGIGb5.d.ts → index-DJG0kiII.d.ts} +33 -33
- package/dist/{index-D2HohSwO.d.ts → index-DLUjc7Bx.d.ts} +52 -29
- package/dist/{index-C7xKVIr4.d.ts → index-DMBMM16q.d.ts} +37 -37
- package/dist/{index-DNU9xoGK.d.ts → index-DpeWm_vF.d.ts} +5 -5
- package/dist/{index-BuY_NKSX.d.ts → index-Yobo6icm.d.ts} +40 -28
- package/dist/{index-BGJXqdg6.d.ts → index-jGgfEHfQ.d.ts} +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +12 -11
- package/dist/{listCollectiblesPaginated--AgXjajA.d.ts → listCollectiblesPaginated-Bq0QSOjJ.d.ts} +28 -26
- package/dist/{listCollections-Bbzbz7qW.d.ts → listCollections-dTCq00l5.d.ts} +168 -123
- package/dist/{looks-rare-CMVPny4v.js → looks-rare-C7cQztTR.js} +1 -1
- package/dist/{looks-rare-CMVPny4v.js.map → looks-rare-C7cQztTR.js.map} +1 -1
- package/dist/{lowestListing-BQHfQpfg.d.ts → lowestListing-CB5Te-Q9.d.ts} +41 -17
- package/dist/{magic-eden-IrWp2ZXk.js → magic-eden-D3r7jiBG.js} +1 -1
- package/dist/{magic-eden-IrWp2ZXk.js.map → magic-eden-D3r7jiBG.js.map} +1 -1
- package/dist/{manifold-DeOE-p2G.js → manifold-DsX0CBP-.js} +1 -1
- package/dist/{manifold-DeOE-p2G.js.map → manifold-DsX0CBP-.js.map} +1 -1
- package/dist/{marketCurrencies-CmOMCCOr.d.ts → marketCurrencies-Bzj8X4TL.d.ts} +8 -8
- package/dist/{marketplace-B5Z8G03R.js → marketplace-BYY8OloA.js} +1 -1
- package/dist/{marketplace-B5Z8G03R.js.map → marketplace-BYY8OloA.js.map} +1 -1
- package/dist/{marketplace-logos-D8t86gsW.js → marketplace-logos-Csv2MBwf.js} +21 -21
- package/dist/marketplace-logos-Csv2MBwf.js.map +1 -0
- package/dist/{marketplace.gen-JzNYpM0U.js → marketplace.gen-w2YvbEEo.js} +2 -2
- package/dist/marketplace.gen-w2YvbEEo.js.map +1 -0
- package/dist/{marketplaceConfig-sNh-MA5M.js → marketplaceConfig-BTy75Mbf.js} +8 -9
- package/dist/marketplaceConfig-BTy75Mbf.js.map +1 -0
- package/dist/{mintify-DG3GrljJ.js → mintify-DiOoDmO1.js} +1 -1
- package/dist/{mintify-DG3GrljJ.js.map → mintify-DiOoDmO1.js.map} +1 -1
- package/dist/{network-DnBEe1Ur.js → network-DtmiMhcg.js} +2 -2
- package/dist/network-DtmiMhcg.js.map +1 -0
- package/dist/networkconfigToWagmiChain-DbUf6HiO.js +15 -0
- package/dist/networkconfigToWagmiChain-DbUf6HiO.js.map +1 -0
- package/dist/{nftx-B3LH-ZYM.js → nftx-CP82jNra.js} +1 -1
- package/dist/{nftx-B3LH-ZYM.js.map → nftx-CP82jNra.js.map} +1 -1
- package/dist/{okx-CRFLrT3Z.js → okx-p9-4xRjs.js} +1 -1
- package/dist/{okx-CRFLrT3Z.js.map → okx-p9-4xRjs.js.map} +1 -1
- package/dist/{open-sea-cOpfl366.js → open-sea-D2GwAmKS.js} +1 -1
- package/dist/{open-sea-cOpfl366.js.map → open-sea-D2GwAmKS.js.map} +1 -1
- package/dist/{primary-sale-CLjXRrDj.js → primary-sale-DOmNDq2P.js} +1 -1
- package/dist/{primary-sale-CLjXRrDj.js.map → primary-sale-DOmNDq2P.js.map} +1 -1
- package/dist/{queries-BYT4GJw3.js → queries-EMA5CcwY.js} +208 -287
- package/dist/queries-EMA5CcwY.js.map +1 -0
- package/dist/{query-BTe7Wkrs.d.ts → query-BG-MA1MB.d.ts} +1 -1
- package/dist/{rarible-guwUx4cn.js → rarible-DqiiW9ki.js} +1 -1
- package/dist/{rarible-guwUx4cn.js.map → rarible-DqiiW9ki.js.map} +1 -1
- package/dist/react/_internal/api/index.d.ts +1 -1
- package/dist/react/_internal/api/index.js +4 -4
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +24 -21
- package/dist/react/_internal/index.d.ts +1 -1
- package/dist/react/_internal/index.js +8 -7
- package/dist/react/_internal/wagmi/index.d.ts +1 -1
- package/dist/react/_internal/wagmi/index.js +4 -3
- package/dist/react/hooks/config/index.d.ts +8 -8
- package/dist/react/hooks/config/index.js +24 -21
- package/dist/react/hooks/contracts/index.d.ts +6 -6
- package/dist/react/hooks/contracts/index.js +13 -12
- package/dist/react/hooks/data/collectibles/index.d.ts +4 -4
- package/dist/react/hooks/data/collectibles/index.js +24 -21
- package/dist/react/hooks/data/collections/index.d.ts +10 -10
- package/dist/react/hooks/data/collections/index.js +24 -21
- package/dist/react/hooks/data/index.d.ts +29 -29
- package/dist/react/hooks/data/index.js +25 -22
- package/dist/react/hooks/data/inventory/index.d.ts +28 -28
- package/dist/react/hooks/data/inventory/index.js +24 -21
- package/dist/react/hooks/data/market/index.d.ts +5 -11
- package/dist/react/hooks/data/market/index.js +24 -21
- package/dist/react/hooks/data/orders/index.d.ts +5 -11
- package/dist/react/hooks/data/orders/index.js +25 -22
- package/dist/react/hooks/data/primary-sales/index.d.ts +28 -28
- package/dist/react/hooks/data/primary-sales/index.js +24 -21
- package/dist/react/hooks/data/tokens/index.d.ts +4 -4
- package/dist/react/hooks/data/tokens/index.js +24 -21
- package/dist/react/hooks/index.d.ts +29 -29
- package/dist/react/hooks/index.js +25 -22
- package/dist/react/hooks/transactions/index.d.ts +2 -2
- package/dist/react/hooks/transactions/index.js +24 -21
- package/dist/react/hooks/ui/index.d.ts +4 -4
- package/dist/react/hooks/ui/index.js +24 -21
- package/dist/react/hooks/utils/index.d.ts +29 -29
- package/dist/react/hooks/utils/index.js +25 -22
- package/dist/react/index.d.ts +29 -29
- package/dist/react/index.js +25 -22
- package/dist/react/queries/index.d.ts +16 -16
- package/dist/react/queries/index.js +18 -17
- package/dist/react/ssr/index.d.ts +7 -7
- package/dist/react/ssr/index.js +9 -8
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.d.ts +3 -0
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.js +22 -0
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.d.ts +54 -0
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.js +29 -0
- package/dist/react/ui/components/marketplace-collectible-card/index.d.ts +5 -5
- package/dist/react/ui/components/marketplace-collectible-card/index.js +24 -21
- package/dist/react/ui/components/marketplace-collectible-card/utils/index.d.ts +2 -2
- package/dist/react/ui/components/marketplace-collectible-card/utils/index.js +9 -8
- package/dist/react/ui/components/marketplace-logos/index.d.ts +21 -21
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +13 -11
- package/dist/react/ui/index.d.ts +5 -5
- package/dist/react/ui/index.js +24 -21
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +24 -21
- package/dist/react/utils/index.d.ts +1 -1
- package/dist/react/utils/index.js +5 -5
- package/dist/{react-Ceq8mamy.js → react-BLJ4DkPx.js} +723 -807
- package/dist/react-BLJ4DkPx.js.map +1 -0
- package/dist/{react-CbqXKOpt.css → react-F03jPjPk.css} +1 -1
- package/dist/{react-CbqXKOpt.css.map → react-F03jPjPk.css.map} +1 -1
- package/dist/{sequence-Dt2Xo7Fa.js → sequence-Bbb-TFKg.js} +1 -1
- package/dist/{sequence-Dt2Xo7Fa.js.map → sequence-Bbb-TFKg.js.map} +1 -1
- package/dist/styles/index.css +46 -24
- package/dist/{sudo-swap-CGoARONs.js → sudo-swap-CEPIM3Js.js} +1 -1
- package/dist/{sudo-swap-CGoARONs.js.map → sudo-swap-CEPIM3Js.js.map} +1 -1
- package/dist/{super-rare-NeQtZjcn.js → super-rare-CMEn9PoO.js} +1 -1
- package/dist/{super-rare-NeQtZjcn.js.map → super-rare-CMEn9PoO.js.map} +1 -1
- package/dist/{token-D9gZVqbX.js → token-CcyLz8Z8.js} +1 -1
- package/dist/{token-D9gZVqbX.js.map → token-CcyLz8Z8.js.map} +1 -1
- package/dist/{tokenSupplies-DXtkRYNO.d.ts → tokenSupplies-C470zTT0.d.ts} +23 -23
- package/dist/{transaction-CC2KxNF6.js → transaction-DZUW5RHu.js} +2 -8
- package/dist/transaction-DZUW5RHu.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/dist/{types-G2PWxiJR.js → types-B_-cnkcP.js} +1 -1
- package/dist/types-B_-cnkcP.js.map +1 -0
- package/dist/{types-BlCa0TVE.d.ts → types-D6LkVrF0.d.ts} +18 -10
- package/dist/utils/abi/index.d.ts +4 -4
- package/dist/utils/abi/index.js +4 -4
- package/dist/utils/abi/marketplace/index.d.ts +1 -1
- package/dist/utils/abi/marketplace/index.js +1 -1
- package/dist/utils/abi/primary-sale/index.d.ts +1 -1
- package/dist/utils/abi/primary-sale/index.js +1 -1
- package/dist/utils/abi/token/index.d.ts +1 -1
- package/dist/utils/abi/token/index.js +1 -1
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +11 -10
- package/dist/{utils-CKJd-CRf.js → utils-BZEkdqWK.js} +7 -24
- package/dist/utils-BZEkdqWK.js.map +1 -0
- package/dist/{utils-wquIhK6T.js → utils-oVZxdK0o.js} +2 -2
- package/dist/utils-oVZxdK0o.js.map +1 -0
- package/dist/{waitForTransactionReceipt-DZxAuR9N.js → waitForTransactionReceipt-B08YZiDY.js} +3 -4
- package/dist/{waitForTransactionReceipt-DZxAuR9N.js.map → waitForTransactionReceipt-B08YZiDY.js.map} +1 -1
- package/dist/{x2y2-CQdg24VP.js → x2y2-DNe6JgtG.js} +1 -1
- package/dist/{x2y2-CQdg24VP.js.map → x2y2-DNe6JgtG.js.map} +1 -1
- package/dist/{zora-DdEydy4L.js → zora-w0Zqxxs4.js} +1 -1
- package/dist/{zora-DdEydy4L.js.map → zora-w0Zqxxs4.js.map} +1 -1
- package/package.json +35 -35
- package/src/react/_internal/api/marketplace.gen.ts +1 -1
- package/src/react/_internal/api/query-keys.ts +2 -0
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +19 -8
- package/src/react/_internal/wagmi/create-config.ts +6 -17
- package/src/react/hooks/config/__snapshots__/useMarketplaceConfig.test.tsx.snap +4 -4
- package/src/react/hooks/data/collectibles/useBalanceOfCollectible.laos.test.tsx +2 -2
- package/src/react/hooks/data/collectibles/useTokenBalances.test.tsx +151 -0
- package/src/react/hooks/data/collectibles/useTokenBalances.tsx +47 -0
- package/src/react/hooks/data/collections/__snapshots__/useListCollections.test.tsx.snap +6 -6
- package/src/react/hooks/data/inventory/useInventory.test.tsx +3 -98
- package/src/react/hooks/data/inventory/useInventory.tsx +2 -2
- package/src/react/hooks/data/market/useListMarketCardData.tsx +1 -1
- package/src/react/hooks/data/orders/useListOffersForCollectible.tsx +70 -45
- package/src/react/hooks/data/primary-sales/useList1155ShopCardData.tsx +21 -37
- package/src/react/hooks/data/primary-sales/useList721ShopCardData.tsx +14 -3
- package/src/react/hooks/data/tokens/useSearchTokenMetadata.tsx +4 -1
- package/src/react/hooks/transactions/useCancelOrder.test.tsx +7 -4
- package/src/react/hooks/transactions/useCancelOrder.tsx +2 -1
- package/src/react/hooks/transactions/useCancelTransactionSteps.tsx +2 -2
- package/src/react/hooks/transactions/useProcessStep.test.tsx +2 -2
- package/src/react/hooks/utils/__tests__/useEnsureCorrectChain.test.tsx +75 -0
- package/src/react/hooks/utils/index.ts +0 -1
- package/src/react/hooks/utils/useEnsureCorrectChain.ts +31 -34
- package/src/react/providers/index.tsx +12 -14
- package/src/react/providers/modal-provider.tsx +2 -2
- package/src/react/queries/__tests__/balanceOfCollectible.laos.test.ts +3 -3
- package/src/react/queries/__tests__/inventory.laos.test.ts +6 -3
- package/src/react/queries/__tests__/tokenBalances.laos.test.ts +123 -0
- package/src/react/queries/balanceOfCollectible.ts +2 -1
- package/src/react/queries/filters.ts +23 -28
- package/src/react/queries/index.ts +1 -0
- package/src/react/queries/inventory.ts +63 -243
- package/src/react/queries/listCollectibles.ts +22 -48
- package/src/react/queries/listCollections.ts +10 -13
- package/src/react/queries/listOffersForCollectible.ts +101 -0
- package/src/react/queries/marketplaceConfig.ts +6 -2
- package/src/react/queries/tokenBalances.ts +85 -0
- package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +4 -4
- package/src/react/ui/components/_internals/action-button/ActionButton.stories.tsx +8 -8
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +6 -9
- package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +4 -4
- package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +6 -6
- package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +1 -1
- package/src/react/ui/components/marketplace-collectible-card/CollectibleCard.tsx +4 -3
- package/src/react/ui/components/marketplace-collectible-card/CollectibleCardSkeleton.tsx +13 -2
- package/src/react/ui/components/marketplace-collectible-card/components/ActionButtonWrapper.tsx +4 -7
- package/src/react/ui/components/marketplace-collectible-card/components/BaseCard.tsx +14 -5
- package/src/react/ui/components/marketplace-collectible-card/components/footer/Footer.tsx +179 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/components/FooterName.tsx +103 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/components/PriceDisplay.tsx +80 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/components/SaleDetailsPill.tsx +29 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/components/TokenTypeBalancePill.tsx +30 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/components/index.ts +4 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/index.ts +2 -0
- package/src/react/ui/components/marketplace-collectible-card/types.ts +18 -6
- package/src/react/ui/components/marketplace-collectible-card/variants/MarketCard.tsx +11 -23
- package/src/react/ui/components/marketplace-collectible-card/variants/NonTradableInventoryCard.tsx +42 -0
- package/src/react/ui/components/marketplace-collectible-card/variants/ShopCard.tsx +15 -12
- package/src/react/ui/modals/BuyModal/__tests__/BuyModalRouter.test.tsx +10 -10
- package/src/react/ui/modals/BuyModal/__tests__/ERC1155ShopModal.test.tsx +3 -3
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx.bak +3 -3
- package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +6 -6
- package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +3 -3
- package/src/react/ui/modals/BuyModal/components/BuyModalRouter.tsx +5 -5
- package/src/react/ui/modals/BuyModal/components/ERC1155BuyModal.tsx +2 -2
- package/src/react/ui/modals/BuyModal/components/ERC1155QuantityModal.tsx +8 -8
- package/src/react/ui/modals/BuyModal/components/ERC1155ShopModal.tsx +2 -2
- package/src/react/ui/modals/BuyModal/hooks/useERC1155Checkout.ts +13 -2
- package/src/react/ui/modals/BuyModal/store.ts +6 -6
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +2 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +87 -89
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +2 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +2 -1
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +2 -1
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +20 -9
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/switchChainErrorModal/__tests__/SwitchChainErrorModal.test.tsx +80 -0
- package/src/react/ui/modals/_internal/components/switchChainErrorModal/index.tsx +64 -0
- package/src/react/ui/modals/_internal/components/switchChainErrorModal/store.ts +42 -0
- package/src/react/ui/modals/_internal/types.ts +0 -1
- package/src/styles/styles.ts +46 -24
- package/src/types/new-marketplace-types.ts +9 -18
- package/src/types/types.ts +1 -1
- package/test/globalSetup.ts +1 -1
- package/test/test-utils.tsx +1 -0
- package/dist/BellIcon-Cb9YEUzJ.js.map +0 -1
- package/dist/CollectibleCard-CYyWzk6u.d.ts +0 -8
- package/dist/api-BmEQfSQa.js.map +0 -1
- package/dist/create-config-6uynwTeb.js.map +0 -1
- package/dist/marketplace-logos-D8t86gsW.js.map +0 -1
- package/dist/marketplace.gen-JzNYpM0U.js.map +0 -1
- package/dist/marketplaceConfig-sNh-MA5M.js.map +0 -1
- package/dist/network-DnBEe1Ur.js.map +0 -1
- package/dist/queries-BYT4GJw3.js.map +0 -1
- package/dist/react-Ceq8mamy.js.map +0 -1
- package/dist/transaction-CC2KxNF6.js.map +0 -1
- package/dist/types-G2PWxiJR.js.map +0 -1
- package/dist/utils-CKJd-CRf.js.map +0 -1
- package/dist/utils-wquIhK6T.js.map +0 -1
- package/src/react/hooks/utils/useSwitchChainWithModal.ts +0 -38
- package/src/react/ui/components/marketplace-collectible-card/Footer.tsx +0 -238
- package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +0 -117
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +0 -124
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +0 -71
- /package/dist/{abi-Wr_aTZFi.js → abi-DYsUABe6.js} +0 -0
- /package/dist/{index-q7f-WDBS.d.ts → index-Cg5cFzs-.d.ts} +0 -0
- /package/dist/{wagmi-BhP3mdhP.js → wagmi-Bseovd6Q.js} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/marketplace-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.css"
|
|
@@ -40,67 +40,67 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@databeat/tracker": "^0.9.3",
|
|
43
|
-
"@legendapp/state": "3.0.0-beta.
|
|
44
|
-
"@tailwindcss/cli": "^4.1.
|
|
45
|
-
"@xstate/store": "^3.
|
|
43
|
+
"@legendapp/state": "3.0.0-beta.32",
|
|
44
|
+
"@tailwindcss/cli": "^4.1.13",
|
|
45
|
+
"@xstate/store": "^3.9.2",
|
|
46
46
|
"class-variance-authority": "^0.7.1",
|
|
47
47
|
"clsx": "^2.1.1",
|
|
48
48
|
"date-fns": "^4.1.0",
|
|
49
49
|
"dnum": "^2.15.0",
|
|
50
|
-
"nuqs": "^2.
|
|
51
|
-
"react-day-picker": "^9.
|
|
50
|
+
"nuqs": "^2.6.0",
|
|
51
|
+
"react-day-picker": "^9.9.0",
|
|
52
52
|
"tailwind-merge": "^3.3.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"0xsequence": "^2.3.
|
|
56
|
-
"@0xsequence/api": "^2.3.
|
|
57
|
-
"@0xsequence/checkout": "^5.3.
|
|
58
|
-
"@0xsequence/connect": "^5.3.
|
|
59
|
-
"@0xsequence/design-system": "^2.
|
|
60
|
-
"@0xsequence/indexer": "^2.3.
|
|
61
|
-
"@0xsequence/metadata": "^2.3.
|
|
62
|
-
"@0xsequence/network": "^2.3.
|
|
55
|
+
"0xsequence": "^2.3.27",
|
|
56
|
+
"@0xsequence/api": "^2.3.27",
|
|
57
|
+
"@0xsequence/checkout": "^5.3.14",
|
|
58
|
+
"@0xsequence/connect": "^5.3.14",
|
|
59
|
+
"@0xsequence/design-system": "^2.2.2",
|
|
60
|
+
"@0xsequence/indexer": "^2.3.27",
|
|
61
|
+
"@0xsequence/metadata": "^2.3.27",
|
|
62
|
+
"@0xsequence/network": "^2.3.27",
|
|
63
63
|
"@google/model-viewer": "^4.1.0",
|
|
64
|
-
"@tanstack/react-query": "^5.
|
|
64
|
+
"@tanstack/react-query": "^5.87.1",
|
|
65
65
|
"react": "^19.1.1",
|
|
66
66
|
"react-dom": "^19.1.1",
|
|
67
|
-
"viem": "^2.
|
|
68
|
-
"wagmi": "^2.16.
|
|
67
|
+
"viem": "^2.37.4",
|
|
68
|
+
"wagmi": "^2.16.9"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@biomejs/biome": "^2.
|
|
72
|
-
"@changesets/cli": "^2.29.
|
|
73
|
-
"@eslint/js": "^9.
|
|
74
|
-
"@storybook/addon-docs": "^9.1.
|
|
75
|
-
"@storybook/addon-vitest": "^9.1.
|
|
76
|
-
"@storybook/react-vite": "^9.1.
|
|
71
|
+
"@biomejs/biome": "^2.2.3",
|
|
72
|
+
"@changesets/cli": "^2.29.6",
|
|
73
|
+
"@eslint/js": "^9.35.0",
|
|
74
|
+
"@storybook/addon-docs": "^9.1.5",
|
|
75
|
+
"@storybook/addon-vitest": "^9.1.5",
|
|
76
|
+
"@storybook/react-vite": "^9.1.5",
|
|
77
77
|
"@storybook/test-runner": "^0.23.0",
|
|
78
|
-
"@tailwindcss/postcss": "^4.1.
|
|
79
|
-
"@testing-library/jest-dom": "^6.
|
|
78
|
+
"@tailwindcss/postcss": "^4.1.13",
|
|
79
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
80
80
|
"@testing-library/react": "^16.3.0",
|
|
81
|
-
"@types/react": "^19.1.
|
|
82
|
-
"@types/react-dom": "^19.1.
|
|
81
|
+
"@types/react": "^19.1.12",
|
|
82
|
+
"@types/react-dom": "^19.1.9",
|
|
83
83
|
"@vitest/browser": "3.2.4",
|
|
84
84
|
"@vitest/coverage-v8": "^3.2.4",
|
|
85
|
-
"eslint": "^9.
|
|
85
|
+
"eslint": "^9.35.0",
|
|
86
86
|
"eslint-config-biome": "^2.1.3",
|
|
87
87
|
"eslint-plugin-react": "^7.37.5",
|
|
88
88
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
89
|
-
"eslint-plugin-storybook": "^9.1.
|
|
89
|
+
"eslint-plugin-storybook": "^9.1.5",
|
|
90
90
|
"globals": "^16.3.0",
|
|
91
91
|
"happy-dom": "^18.0.1",
|
|
92
92
|
"jsdom": "^26.1.0",
|
|
93
|
-
"msw": "^2.
|
|
93
|
+
"msw": "^2.11.1",
|
|
94
94
|
"msw-storybook-addon": "^2.0.5",
|
|
95
|
-
"playwright": "^1.
|
|
95
|
+
"playwright": "^1.55.0",
|
|
96
96
|
"postcss": "^8.5.6",
|
|
97
97
|
"prool": "^0.0.24",
|
|
98
98
|
"rollup-preserve-directives": "^1.1.3",
|
|
99
|
-
"storybook": "^9.1.
|
|
100
|
-
"tailwindcss": "^4.1.
|
|
101
|
-
"tsdown": "^0.
|
|
99
|
+
"storybook": "^9.1.5",
|
|
100
|
+
"tailwindcss": "^4.1.13",
|
|
101
|
+
"tsdown": "^0.14.2",
|
|
102
102
|
"typescript": "^5.9.2",
|
|
103
|
-
"typescript-eslint": "^8.
|
|
103
|
+
"typescript-eslint": "^8.43.0",
|
|
104
104
|
"vite-tsconfig-paths": "^5.1.4",
|
|
105
105
|
"vitest": "^3.2.4"
|
|
106
106
|
},
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export const WebrpcHeader = "Webrpc";
|
|
9
9
|
|
|
10
10
|
export const WebrpcHeaderValue =
|
|
11
|
-
"webrpc@v0.25.4;gen-typescript@v0.17.0;marketplace-api@v0.0.0-cf3a5fae407a732cd5a90e4fd68184ac5591b2c1;marketplace-sdk@
|
|
11
|
+
"webrpc@v0.25.4;gen-typescript@v0.17.0;marketplace-api@v0.0.0-cf3a5fae407a732cd5a90e4fd68184ac5591b2c1;marketplace-sdk@v1.1.0";
|
|
12
12
|
|
|
13
13
|
// WebRPC description and code-gen version
|
|
14
14
|
export const WebRPCVersion = "v1";
|
|
@@ -27,6 +27,7 @@ class CollectableKeys {
|
|
|
27
27
|
static offersCount = [...CollectableKeys.all, 'offersCount'] as const;
|
|
28
28
|
static listings = [...CollectableKeys.all, 'listings'] as const;
|
|
29
29
|
static listingsCount = [...CollectableKeys.all, 'listingsCount'] as const;
|
|
30
|
+
static listPrimarySaleItems = ['listPrimarySaleItems'] as const;
|
|
30
31
|
static filter = [...CollectableKeys.all, 'filter'] as const;
|
|
31
32
|
static counts = [...CollectableKeys.all, 'counts'] as const;
|
|
32
33
|
static collectibleActivities = [
|
|
@@ -54,6 +55,7 @@ class BalanceQueries {
|
|
|
54
55
|
...BalanceQueries.all,
|
|
55
56
|
'collectionBalanceDetails',
|
|
56
57
|
] as const;
|
|
58
|
+
static inventory = ['inventory'] as const;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
// biome-ignore lint/complexity/noStaticOnlyClass: static class provides better organization and type safety for query keys
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { allNetworks } from '@0xsequence/network';
|
|
1
2
|
import { polygon } from 'viem/chains';
|
|
2
3
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
4
|
import { type Config, cookieStorage } from 'wagmi';
|
|
@@ -13,6 +14,7 @@ import { createWagmiConfig } from '../create-config';
|
|
|
13
14
|
describe('createWagmiConfig', () => {
|
|
14
15
|
let baseMarketplace: MarketplaceConfig;
|
|
15
16
|
let baseSdkConfig: SdkConfig;
|
|
17
|
+
const expectedNetworkCount = Object.keys(allNetworks).length;
|
|
16
18
|
|
|
17
19
|
beforeEach(() => {
|
|
18
20
|
baseMarketplace = {
|
|
@@ -44,10 +46,11 @@ describe('createWagmiConfig', () => {
|
|
|
44
46
|
enabled: true,
|
|
45
47
|
bannerUrl: 'https://test.com/banner.jpg',
|
|
46
48
|
ogImage: '',
|
|
49
|
+
private: false,
|
|
47
50
|
collections: [
|
|
48
51
|
{
|
|
49
52
|
contractType: ContractType.ERC721,
|
|
50
|
-
|
|
53
|
+
cardType: 'market',
|
|
51
54
|
chainId: polygon.id,
|
|
52
55
|
bannerUrl: '',
|
|
53
56
|
itemsAddress: '0x1234567890123456789012345678901234567890',
|
|
@@ -58,6 +61,7 @@ describe('createWagmiConfig', () => {
|
|
|
58
61
|
feePercentage: 0,
|
|
59
62
|
destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
|
|
60
63
|
currencyOptions: [],
|
|
64
|
+
private: false,
|
|
61
65
|
} as MarketCollection,
|
|
62
66
|
],
|
|
63
67
|
},
|
|
@@ -66,6 +70,7 @@ describe('createWagmiConfig', () => {
|
|
|
66
70
|
bannerUrl: '',
|
|
67
71
|
ogImage: '',
|
|
68
72
|
collections: [],
|
|
73
|
+
private: false,
|
|
69
74
|
},
|
|
70
75
|
};
|
|
71
76
|
|
|
@@ -87,9 +92,15 @@ describe('createWagmiConfig', () => {
|
|
|
87
92
|
);
|
|
88
93
|
expect(configWithEmptyCollections.chains).toBeDefined();
|
|
89
94
|
expect(Array.isArray(configWithEmptyCollections.chains)).toBe(true);
|
|
90
|
-
expect(configWithEmptyCollections.chains).toHaveLength(
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
expect(configWithEmptyCollections.chains).toHaveLength(
|
|
96
|
+
expectedNetworkCount,
|
|
97
|
+
);
|
|
98
|
+
// All networks from allNetworks are now included
|
|
99
|
+
expect(
|
|
100
|
+
configWithEmptyCollections.chains.find(
|
|
101
|
+
(chain) => chain.id === polygon.id,
|
|
102
|
+
),
|
|
103
|
+
).toBeDefined();
|
|
93
104
|
});
|
|
94
105
|
|
|
95
106
|
it('should create config with universal wallet setup', () => {
|
|
@@ -113,7 +124,7 @@ describe('createWagmiConfig', () => {
|
|
|
113
124
|
|
|
114
125
|
const config = createWagmiConfig(marketplaceConfig, sdkConfig);
|
|
115
126
|
expect(config.connectors).toBeDefined();
|
|
116
|
-
expect(config.chains).toHaveLength(
|
|
127
|
+
expect(config.chains).toHaveLength(expectedNetworkCount);
|
|
117
128
|
});
|
|
118
129
|
|
|
119
130
|
it('should create config with embedded wallet setup', () => {
|
|
@@ -144,7 +155,7 @@ describe('createWagmiConfig', () => {
|
|
|
144
155
|
|
|
145
156
|
const config = createWagmiConfig(marketplaceConfig, sdkConfig);
|
|
146
157
|
expect(config.connectors).toBeDefined();
|
|
147
|
-
expect(config.chains).toHaveLength(
|
|
158
|
+
expect(config.chains).toHaveLength(expectedNetworkCount);
|
|
148
159
|
});
|
|
149
160
|
|
|
150
161
|
it('should respect EIP6963 wallet inclusion setting', () => {
|
|
@@ -163,7 +174,7 @@ describe('createWagmiConfig', () => {
|
|
|
163
174
|
|
|
164
175
|
const config = createWagmiConfig(marketplaceConfig, baseSdkConfig);
|
|
165
176
|
expect(config.connectors).toBeDefined();
|
|
166
|
-
expect(config.chains).toHaveLength(
|
|
177
|
+
expect(config.chains).toHaveLength(expectedNetworkCount);
|
|
167
178
|
});
|
|
168
179
|
|
|
169
180
|
it('should create SSR compatible config when ssr flag is true', async () => {
|
|
@@ -203,7 +214,7 @@ describe('createWagmiConfig', () => {
|
|
|
203
214
|
|
|
204
215
|
const config = createWagmiConfig(marketplaceConfig, baseSdkConfig);
|
|
205
216
|
expect(config.connectors).toBeDefined();
|
|
206
|
-
expect(config.chains).toHaveLength(
|
|
217
|
+
expect(config.chains).toHaveLength(expectedNetworkCount);
|
|
207
218
|
});
|
|
208
219
|
});
|
|
209
220
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { getDefaultChains } from '@0xsequence/connect';
|
|
2
1
|
import { allNetworks, findNetworkConfig } from '@0xsequence/network';
|
|
3
2
|
import type { Chain, Transport } from 'viem';
|
|
4
3
|
import { cookieStorage, createConfig, createStorage, http } from 'wagmi';
|
|
5
4
|
import type { Env, SdkConfig } from '../../../types/index';
|
|
6
5
|
import type { MarketplaceConfig } from '../../../types/new-marketplace-types';
|
|
7
|
-
import {
|
|
6
|
+
import { networkToWagmiChain } from '../../../utils/networkconfigToWagmiChain';
|
|
8
7
|
import { getConnectors } from './get-connectors';
|
|
9
8
|
|
|
10
9
|
export const createWagmiConfig = (
|
|
@@ -66,22 +65,12 @@ export function getWagmiChainsAndTransports({
|
|
|
66
65
|
return { chains, transports };
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function getChainConfigs(marketConfig: MarketplaceConfig): [Chain, ...Chain[]] {
|
|
74
|
-
const supportedChainIds = new Set(
|
|
75
|
-
getAllCollections(marketConfig).map((c) => c.chainId),
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
if (supportedChainIds.size === 0) {
|
|
79
|
-
supportedChainIds.add(DEFAULT_NETWORK);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const chains = getDefaultChains([...supportedChainIds]);
|
|
68
|
+
function getChainConfigs(
|
|
69
|
+
_marketConfig: MarketplaceConfig,
|
|
70
|
+
): [Chain, ...Chain[]] {
|
|
71
|
+
const chains = Object.values(allNetworks).map(networkToWagmiChain);
|
|
83
72
|
|
|
84
|
-
return chains;
|
|
73
|
+
return chains as [Chain, ...Chain[]];
|
|
85
74
|
}
|
|
86
75
|
|
|
87
76
|
function getTransportConfigs(
|
|
@@ -7,6 +7,7 @@ exports[`useMarketplaceConfig > should fetch marketplace config and styles succe
|
|
|
7
7
|
"collections": [
|
|
8
8
|
{
|
|
9
9
|
"bannerUrl": "https://example.com/market-banner.png",
|
|
10
|
+
"cardType": "market",
|
|
10
11
|
"chainId": 1,
|
|
11
12
|
"contractType": "ERC721",
|
|
12
13
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
@@ -31,13 +32,13 @@ exports[`useMarketplaceConfig > should fetch marketplace config and styles succe
|
|
|
31
32
|
},
|
|
32
33
|
"id": 1,
|
|
33
34
|
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
34
|
-
"marketplaceType": "market",
|
|
35
35
|
"private": false,
|
|
36
36
|
"projectId": 1,
|
|
37
37
|
"updatedAt": "2025-03-16T13:04:16.098Z",
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"bannerUrl": "https://example.com/collection-banner.png",
|
|
41
|
+
"cardType": "market",
|
|
41
42
|
"chainId": 137,
|
|
42
43
|
"contractType": "ERC1155",
|
|
43
44
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
@@ -66,7 +67,6 @@ exports[`useMarketplaceConfig > should fetch marketplace config and styles succe
|
|
|
66
67
|
},
|
|
67
68
|
"id": 2,
|
|
68
69
|
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
69
|
-
"marketplaceType": "market",
|
|
70
70
|
"private": false,
|
|
71
71
|
"projectId": 1,
|
|
72
72
|
"updatedAt": "2025-03-16T13:04:16.098Z",
|
|
@@ -105,12 +105,12 @@ exports[`useMarketplaceConfig > should fetch marketplace config and styles succe
|
|
|
105
105
|
"collections": [
|
|
106
106
|
{
|
|
107
107
|
"bannerUrl": "https://example.com/shop-banner.png",
|
|
108
|
+
"cardType": "shop",
|
|
108
109
|
"chainId": 1,
|
|
109
110
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
110
111
|
"customTokenIds": [],
|
|
111
112
|
"id": 1,
|
|
112
113
|
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
113
|
-
"marketplaceType": "shop",
|
|
114
114
|
"name": "Mock Shop Collection",
|
|
115
115
|
"private": false,
|
|
116
116
|
"projectId": 1,
|
|
@@ -125,12 +125,12 @@ exports[`useMarketplaceConfig > should fetch marketplace config and styles succe
|
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
"bannerUrl": "https://example.com/polygon-shop-banner.png",
|
|
128
|
+
"cardType": "shop",
|
|
128
129
|
"chainId": 137,
|
|
129
130
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
130
131
|
"customTokenIds": [],
|
|
131
132
|
"id": 2,
|
|
132
133
|
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
133
|
-
"marketplaceType": "shop",
|
|
134
134
|
"name": "Polygon Shop Collection",
|
|
135
135
|
"private": false,
|
|
136
136
|
"projectId": 1,
|
|
@@ -112,7 +112,7 @@ describe('useBalanceOfCollectible with LAOS', () => {
|
|
|
112
112
|
expect(result.current.isSuccess).toBe(true);
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
// Should return LAOS API response (
|
|
115
|
+
// Should return LAOS API response (array of balances)
|
|
116
116
|
expect(result.current.data).toEqual(mockTokenBalancesResponse.balances[0]);
|
|
117
117
|
expect(result.current.data?.balance).toBe('5');
|
|
118
118
|
expect(result.current.data?.contractInfo?.type).toBe('LAOS-ERC-721');
|
|
@@ -195,7 +195,7 @@ describe('useBalanceOfCollectible with LAOS', () => {
|
|
|
195
195
|
expect(result.current.isSuccess).toBe(true);
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
expect(result.current.data).
|
|
198
|
+
expect(result.current.data).toEqual(null);
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
it('should auto-detect LAOS from marketplace config', async () => {
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { renderHook, server, waitFor } from '@test';
|
|
2
|
+
import { HttpResponse, http } from 'msw';
|
|
3
|
+
import { zeroAddress } from 'viem';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
mockIndexerEndpoint,
|
|
7
|
+
mockTokenBalance,
|
|
8
|
+
} from '../../../_internal/api/__mocks__/indexer.msw';
|
|
9
|
+
import { useTokenBalances } from './useTokenBalances';
|
|
10
|
+
|
|
11
|
+
describe('useTokenBalances', () => {
|
|
12
|
+
const defaultArgs = {
|
|
13
|
+
collectionAddress: zeroAddress,
|
|
14
|
+
userAddress: '0x1234567890123456789012345678901234567890' as `0x${string}`,
|
|
15
|
+
chainId: 1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
it('should fetch balances successfully', async () => {
|
|
19
|
+
// Override the handler specifically for this test
|
|
20
|
+
server.use(
|
|
21
|
+
http.post(mockIndexerEndpoint('GetTokenBalances'), () => {
|
|
22
|
+
return HttpResponse.json({
|
|
23
|
+
page: { page: 1, pageSize: 10, more: false },
|
|
24
|
+
balances: [mockTokenBalance, { ...mockTokenBalance, tokenID: '2' }],
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const { result } = renderHook(() => useTokenBalances(defaultArgs));
|
|
30
|
+
|
|
31
|
+
// Initially loading
|
|
32
|
+
expect(result.current.isLoading).toBe(true);
|
|
33
|
+
|
|
34
|
+
// Wait for the query to complete
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(result.current.isSuccess).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Check the returned data matches mock
|
|
40
|
+
expect(result.current.data).toHaveLength(2);
|
|
41
|
+
expect(result.current.data?.[0]).toEqual(mockTokenBalance);
|
|
42
|
+
expect(result.current.data?.[1].tokenID).toBe('2');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return empty array when userAddress is undefined', () => {
|
|
46
|
+
const { result } = renderHook(() =>
|
|
47
|
+
useTokenBalances({
|
|
48
|
+
...defaultArgs,
|
|
49
|
+
userAddress: undefined,
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(result.current.data).toBeUndefined();
|
|
54
|
+
expect(result.current.isLoading).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should respect enabled option in query config', () => {
|
|
58
|
+
const { result } = renderHook(() =>
|
|
59
|
+
useTokenBalances({
|
|
60
|
+
...defaultArgs,
|
|
61
|
+
query: {
|
|
62
|
+
enabled: false,
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
expect(result.current.isLoading).toBe(false);
|
|
68
|
+
expect(result.current.data).toBeUndefined();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should handle error states', async () => {
|
|
72
|
+
// Override the handler to return an error
|
|
73
|
+
server.use(
|
|
74
|
+
http.post(mockIndexerEndpoint('GetTokenBalances'), () => {
|
|
75
|
+
return HttpResponse.json(
|
|
76
|
+
{ error: { message: 'Invalid address format' } },
|
|
77
|
+
{ status: 400 },
|
|
78
|
+
);
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const invalidArgs = {
|
|
83
|
+
...defaultArgs,
|
|
84
|
+
collectionAddress: '0xinvalid' as `0x${string}`, // Invalid address format
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const { result } = renderHook(() => useTokenBalances(invalidArgs));
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(result.current.isError).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should return all token balances for a collection', async () => {
|
|
95
|
+
const specificCollection = {
|
|
96
|
+
collectionAddress:
|
|
97
|
+
'0x1234567890123456789012345678901234567890' as `0x${string}`,
|
|
98
|
+
userAddress:
|
|
99
|
+
'0xabcdef1234567890abcdef1234567890abcdef12' as `0x${string}`,
|
|
100
|
+
chainId: 1,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const balances = [
|
|
104
|
+
{
|
|
105
|
+
...mockTokenBalance,
|
|
106
|
+
contractAddress: specificCollection.collectionAddress,
|
|
107
|
+
accountAddress: specificCollection.userAddress,
|
|
108
|
+
tokenID: '1',
|
|
109
|
+
balance: '2',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
...mockTokenBalance,
|
|
113
|
+
contractAddress: specificCollection.collectionAddress,
|
|
114
|
+
accountAddress: specificCollection.userAddress,
|
|
115
|
+
tokenID: '2',
|
|
116
|
+
balance: '1',
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
server.use(
|
|
121
|
+
http.post(mockIndexerEndpoint('GetTokenBalances'), () => {
|
|
122
|
+
return HttpResponse.json({
|
|
123
|
+
page: { page: 1, pageSize: 10, more: false },
|
|
124
|
+
balances,
|
|
125
|
+
});
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const { result } = renderHook(() => useTokenBalances(specificCollection));
|
|
130
|
+
|
|
131
|
+
await waitFor(() => {
|
|
132
|
+
expect(result.current.isSuccess).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Verify all token balances
|
|
136
|
+
expect(result.current.data).toEqual(balances);
|
|
137
|
+
expect(result.current.data).toHaveLength(2);
|
|
138
|
+
expect(result.current.data?.[0].balance).toBe('2');
|
|
139
|
+
expect(result.current.data?.[1].balance).toBe('1');
|
|
140
|
+
expect(
|
|
141
|
+
result.current.data?.every(
|
|
142
|
+
(b) => b.contractAddress === specificCollection.collectionAddress,
|
|
143
|
+
),
|
|
144
|
+
).toBe(true);
|
|
145
|
+
expect(
|
|
146
|
+
result.current.data?.every(
|
|
147
|
+
(b) => b.accountAddress === specificCollection.userAddress,
|
|
148
|
+
),
|
|
149
|
+
).toBe(true);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { ContractType } from '../../../_internal';
|
|
3
|
+
import {
|
|
4
|
+
tokenBalancesOptions,
|
|
5
|
+
type UseTokenBalancesArgs,
|
|
6
|
+
} from '../../../queries/tokenBalances';
|
|
7
|
+
import { useConfig } from '../../config/useConfig';
|
|
8
|
+
import { useMarketplaceConfig } from '../../config/useMarketplaceConfig';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to fetch all token balances for a user in a collection
|
|
12
|
+
*
|
|
13
|
+
* @param args - The arguments for fetching the balances
|
|
14
|
+
* @returns Query result containing the balances data
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const { data, isLoading, error } = useTokenBalances({
|
|
19
|
+
* collectionAddress: '0x123...',
|
|
20
|
+
* userAddress: '0x456...',
|
|
21
|
+
* chainId: 1,
|
|
22
|
+
* query: {
|
|
23
|
+
* enabled: true,
|
|
24
|
+
* refetchInterval: 10000,
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function useTokenBalances(args: UseTokenBalancesArgs) {
|
|
30
|
+
const config = useConfig();
|
|
31
|
+
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
32
|
+
|
|
33
|
+
const collection = marketplaceConfig?.market.collections.find(
|
|
34
|
+
(collection) => collection.itemsAddress === args.collectionAddress,
|
|
35
|
+
);
|
|
36
|
+
const isLaos721 = collection?.contractType === ContractType.LAOS_ERC_721;
|
|
37
|
+
|
|
38
|
+
return useQuery(
|
|
39
|
+
tokenBalancesOptions(
|
|
40
|
+
{
|
|
41
|
+
...args,
|
|
42
|
+
isLaos721,
|
|
43
|
+
},
|
|
44
|
+
config,
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -6,6 +6,7 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
6
6
|
"address": "0x0000000000000000000000000000000000000000",
|
|
7
7
|
"bannerUrl": "https://example.com/market-banner.png",
|
|
8
8
|
"bytecodeHash": "0x1234567890",
|
|
9
|
+
"cardType": "market",
|
|
9
10
|
"chainId": 1,
|
|
10
11
|
"contractType": "ERC721",
|
|
11
12
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
@@ -48,7 +49,6 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
48
49
|
"id": 1,
|
|
49
50
|
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
50
51
|
"logoURI": "https://example.com/logo.png",
|
|
51
|
-
"marketplaceType": "market",
|
|
52
52
|
"name": "Mock Collection",
|
|
53
53
|
"private": false,
|
|
54
54
|
"projectId": 1,
|
|
@@ -62,6 +62,7 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
62
62
|
"address": "0x1234567890123456789012345678901234567890",
|
|
63
63
|
"bannerUrl": "https://example.com/collection-banner.png",
|
|
64
64
|
"bytecodeHash": "0x1234567890",
|
|
65
|
+
"cardType": "market",
|
|
65
66
|
"chainId": 137,
|
|
66
67
|
"contractType": "ERC1155",
|
|
67
68
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
@@ -108,7 +109,6 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
108
109
|
"id": 2,
|
|
109
110
|
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
110
111
|
"logoURI": "https://example.com/logo.png",
|
|
111
|
-
"marketplaceType": "market",
|
|
112
112
|
"name": "Mock Collection",
|
|
113
113
|
"private": false,
|
|
114
114
|
"projectId": 1,
|
|
@@ -122,6 +122,7 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
122
122
|
"address": "0x0000000000000000000000000000000000000000",
|
|
123
123
|
"bannerUrl": "https://example.com/shop-banner.png",
|
|
124
124
|
"bytecodeHash": "0x1234567890",
|
|
125
|
+
"cardType": "shop",
|
|
125
126
|
"chainId": 1,
|
|
126
127
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
127
128
|
"customTokenIds": [],
|
|
@@ -145,7 +146,6 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
145
146
|
"id": 1,
|
|
146
147
|
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
147
148
|
"logoURI": "https://example.com/logo.png",
|
|
148
|
-
"marketplaceType": "shop",
|
|
149
149
|
"name": "Mock Collection",
|
|
150
150
|
"private": false,
|
|
151
151
|
"projectId": 1,
|
|
@@ -166,6 +166,7 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
166
166
|
"address": "0x1234567890123456789012345678901234567890",
|
|
167
167
|
"bannerUrl": "https://example.com/polygon-shop-banner.png",
|
|
168
168
|
"bytecodeHash": "0x1234567890",
|
|
169
|
+
"cardType": "shop",
|
|
169
170
|
"chainId": 137,
|
|
170
171
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
171
172
|
"customTokenIds": [],
|
|
@@ -189,7 +190,6 @@ exports[`useListCollections > should fetch collections successfully 1`] = `
|
|
|
189
190
|
"id": 2,
|
|
190
191
|
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
191
192
|
"logoURI": "https://example.com/logo.png",
|
|
192
|
-
"marketplaceType": "shop",
|
|
193
193
|
"name": "Mock Collection",
|
|
194
194
|
"private": false,
|
|
195
195
|
"projectId": 1,
|
|
@@ -215,6 +215,7 @@ exports[`useListCollections > should handle empty collections 1`] = `
|
|
|
215
215
|
"address": "0x0000000000000000000000000000000000000000",
|
|
216
216
|
"bannerUrl": "https://example.com/shop-banner.png",
|
|
217
217
|
"bytecodeHash": "0x1234567890",
|
|
218
|
+
"cardType": "shop",
|
|
218
219
|
"chainId": 1,
|
|
219
220
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
220
221
|
"customTokenIds": [],
|
|
@@ -238,7 +239,6 @@ exports[`useListCollections > should handle empty collections 1`] = `
|
|
|
238
239
|
"id": 1,
|
|
239
240
|
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
240
241
|
"logoURI": "https://example.com/logo.png",
|
|
241
|
-
"marketplaceType": "shop",
|
|
242
242
|
"name": "Mock Collection",
|
|
243
243
|
"private": false,
|
|
244
244
|
"projectId": 1,
|
|
@@ -259,6 +259,7 @@ exports[`useListCollections > should handle empty collections 1`] = `
|
|
|
259
259
|
"address": "0x1234567890123456789012345678901234567890",
|
|
260
260
|
"bannerUrl": "https://example.com/polygon-shop-banner.png",
|
|
261
261
|
"bytecodeHash": "0x1234567890",
|
|
262
|
+
"cardType": "shop",
|
|
262
263
|
"chainId": 137,
|
|
263
264
|
"createdAt": "2025-03-16T13:04:16.098Z",
|
|
264
265
|
"customTokenIds": [],
|
|
@@ -282,7 +283,6 @@ exports[`useListCollections > should handle empty collections 1`] = `
|
|
|
282
283
|
"id": 2,
|
|
283
284
|
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
284
285
|
"logoURI": "https://example.com/logo.png",
|
|
285
|
-
"marketplaceType": "shop",
|
|
286
286
|
"name": "Mock Collection",
|
|
287
287
|
"private": false,
|
|
288
288
|
"projectId": 1,
|