@0xsequence/marketplace-sdk 1.1.0 → 1.2.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/CHANGELOG.md +58 -5
- package/dist/{BellIcon-IpHHEy8h.js → BellIcon-DMKEumAz.js} +2 -2
- package/dist/BellIcon-DMKEumAz.js.map +1 -0
- package/dist/{CartIcon-C8zbor8H.js → CartIcon-UyB4NYKt.js} +3 -3
- package/dist/CartIcon-UyB4NYKt.js.map +1 -0
- package/dist/CollectibleCard-z05qWzKE.d.ts +8 -0
- package/dist/_internal-DkS2VUn5.js.map +1 -1
- package/dist/abi-fa-o9gH3.js +134 -0
- package/dist/abi-fa-o9gH3.js.map +1 -0
- package/dist/{alien_swap-BTJ7mSR-.js → alien_swap-Cq8LuElo.js} +1 -1
- package/dist/{alien_swap-BTJ7mSR-.js.map → alien_swap-Cq8LuElo.js.map} +1 -1
- package/dist/{api-DuLKn__v.js → api-GwTR0dBA.js} +13 -49
- package/dist/api-GwTR0dBA.js.map +1 -0
- package/dist/{aqua-xyz-BYJ9WSP_.js → aqua-xyz-0yye_c-Z.js} +1 -1
- package/dist/{aqua-xyz-BYJ9WSP_.js.map → aqua-xyz-0yye_c-Z.js.map} +1 -1
- package/dist/{aura-D7SUjgro.js → aura-TaxFvTFQ.js} +1 -1
- package/dist/{aura-D7SUjgro.js.map → aura-TaxFvTFQ.js.map} +1 -1
- package/dist/{blur-BcnRFCaV.js → blur-BupOTobO.js} +1 -1
- package/dist/{blur-BcnRFCaV.js.map → blur-BupOTobO.js.map} +1 -1
- package/dist/{builder-api-BFuZNOaN.js → builder-api-m4JAA6ee.js} +3 -3
- package/dist/builder-api-m4JAA6ee.js.map +1 -0
- package/dist/{builder.gen-B9wR2nvF.js → builder.gen--XD71cNL.js} +2 -2
- package/dist/builder.gen--XD71cNL.js.map +1 -0
- package/dist/{coinbase-ChoX9Hw2.js → coinbase-DTgZ4wDT.js} +1 -1
- package/dist/{coinbase-ChoX9Hw2.js.map → coinbase-DTgZ4wDT.js.map} +1 -1
- package/dist/collectibles-CZ6i8sXK.js +324 -0
- package/dist/collectibles-CZ6i8sXK.js.map +1 -0
- package/dist/collections-5NcU-7ZR.js +331 -0
- package/dist/collections-5NcU-7ZR.js.map +1 -0
- package/dist/{components-CUv-wQr8.js → components-CY8kx2kb.js} +13 -9
- package/dist/components-CY8kx2kb.js.map +1 -0
- package/dist/{contracts-D72LBOX3.js → contracts-DRJHF89h.js} +5 -4
- package/dist/{contracts-D72LBOX3.js.map → contracts-DRJHF89h.js.map} +1 -1
- package/dist/{create-config-CIfejoCk.js → create-config-BxyfYCEk.js} +6 -5
- package/dist/create-config-BxyfYCEk.js.map +1 -0
- package/dist/{create-config-DV_dtaLt.d.ts → create-config-CFBeD8CB.d.ts} +149 -57
- package/dist/{element-Dbcv5qya.js → element-D4dDznlu.js} +1 -1
- package/dist/{element-Dbcv5qya.js.map → element-D4dDznlu.js.map} +1 -1
- package/dist/filters-B5niI_fX.d.ts +60 -0
- package/dist/{foundation-QPhUEUy8.js → foundation-GHZOKAzN.js} +1 -1
- package/dist/{foundation-QPhUEUy8.js.map → foundation-GHZOKAzN.js.map} +1 -1
- package/dist/index-8scPf0CS.d.ts +55 -0
- package/dist/index-9qsplZ8r.d.ts +18 -0
- package/dist/index-BIuYTMc2.d.ts +122 -0
- package/dist/{index-BoNNplSx.d.ts → index-BNrz99xy.d.ts} +3 -3
- package/dist/{index-BaytncQc.d.ts → index-BYQOPS8e.d.ts} +108 -51
- package/dist/{index-CXscCUg7.d.ts → index-BkZ7SPLc.d.ts} +19 -29
- package/dist/{index-D6YMj82n.d.ts → index-BnUku_aF.d.ts} +109 -114
- package/dist/index-BtDAHMW_.d.ts +50 -0
- package/dist/index-C-c_M_sE.d.ts +107 -0
- package/dist/index-CKefEBrI.d.ts +1 -0
- package/dist/{index-CMPUveNz.d.ts → index-CNIiC8Z_.d.ts} +11 -8
- package/dist/{index-DLUjc7Bx.d.ts → index-CbERNN3s.d.ts} +201 -12
- package/dist/{index-C768pAfu.d.ts → index-CsfxsN0t.d.ts} +4 -4
- package/dist/{index-CQecU53t.d.ts → index-DASjaiJL.d.ts} +119 -24
- package/dist/{index-CT8ZorFd.d.ts → index-DD7Vc4cE.d.ts} +2 -2
- package/dist/{index-DpeWm_vF.d.ts → index-DIc8OqWV.d.ts} +7 -6
- package/dist/index-DVI_vggD.d.ts +171 -0
- package/dist/index-DgsCqh_P.d.ts +1 -0
- package/dist/{index-DMBMM16q.d.ts → index-DqxQeYT2.d.ts} +39 -36
- package/dist/{index-D-UXGo5d.d.ts → index-Dsf9FRtr.d.ts} +19 -3
- package/dist/{index-DJG0kiII.d.ts → index-DxAReMEO.d.ts} +45 -34
- package/dist/index-UXRoZmd_.d.ts +70 -0
- package/dist/{index-CM0ZTePs.d.ts → index-isFvc5gd.d.ts} +2 -2
- package/dist/{index-jGgfEHfQ.d.ts → index-j3nuJWyJ.d.ts} +18 -10
- package/dist/{index-B6aSbaw2.d.ts → index-nVb7o0hc.d.ts} +2 -2
- package/dist/{index-Bv5XVLjH.d.ts → index-pbE88Tt7.d.ts} +2 -2
- package/dist/index-xpO4AQyS.d.ts +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +13 -13
- package/dist/inventory--t6Zu55O.js +75 -0
- package/dist/inventory--t6Zu55O.js.map +1 -0
- package/dist/listCollectiblesPaginated-BlE5mSzh.d.ts +327 -0
- package/dist/listCollections-DWyqFSQ3.d.ts +828 -0
- package/dist/{looks-rare-C7cQztTR.js → looks-rare-2HBhMpOf.js} +1 -1
- package/dist/{looks-rare-C7cQztTR.js.map → looks-rare-2HBhMpOf.js.map} +1 -1
- package/dist/lowestListing-DsunDO1c.d.ts +475 -0
- package/dist/{magic-eden-D3r7jiBG.js → magic-eden-BYdTp-uk.js} +1 -1
- package/dist/{magic-eden-D3r7jiBG.js.map → magic-eden-BYdTp-uk.js.map} +1 -1
- package/dist/{manifold-DsX0CBP-.js → manifold-yE0x6ZmO.js} +1 -1
- package/dist/{manifold-DsX0CBP-.js.map → manifold-yE0x6ZmO.js.map} +1 -1
- package/dist/market-DuBpFsDg.js +219 -0
- package/dist/market-DuBpFsDg.js.map +1 -0
- package/dist/{marketCurrencies-Bzj8X4TL.d.ts → marketCurrencies-BgwmbGFk.d.ts} +57 -15
- package/dist/marketCurrencies-Bolonndy.js +59 -0
- package/dist/marketCurrencies-Bolonndy.js.map +1 -0
- package/dist/{marketplace-BYY8OloA.js → marketplace-NQB-sEQL.js} +1 -1
- package/dist/{marketplace-BYY8OloA.js.map → marketplace-NQB-sEQL.js.map} +1 -1
- package/dist/{marketplace-logos-Csv2MBwf.js → marketplace-logos-Cz9RrtQo.js} +21 -21
- package/dist/marketplace-logos-Cz9RrtQo.js.map +1 -0
- package/dist/{marketplace.gen-w2YvbEEo.js → marketplace.gen-906FrJQJ.js} +75 -5
- package/dist/marketplace.gen-906FrJQJ.js.map +1 -0
- package/dist/{marketplaceConfig-BTy75Mbf.js → marketplaceConfig-Bqjo7NYO.js} +9 -5
- package/dist/marketplaceConfig-Bqjo7NYO.js.map +1 -0
- package/dist/{mintify-DiOoDmO1.js → mintify-BXQx3mZB.js} +1 -1
- package/dist/{mintify-DiOoDmO1.js.map → mintify-BXQx3mZB.js.map} +1 -1
- package/dist/{network-DtmiMhcg.js → network-DwdZ_5-7.js} +2 -2
- package/dist/network-DwdZ_5-7.js.map +1 -0
- package/dist/{networkconfigToWagmiChain-DbUf6HiO.js → networkconfigToWagmiChain-Ct-hGq8M.js} +4 -3
- package/dist/networkconfigToWagmiChain-Ct-hGq8M.js.map +1 -0
- package/dist/{nftx-CP82jNra.js → nftx-B929_3Ce.js} +1 -1
- package/dist/{nftx-CP82jNra.js.map → nftx-B929_3Ce.js.map} +1 -1
- package/dist/{okx-p9-4xRjs.js → okx-sZ0-Udny.js} +1 -1
- package/dist/{okx-p9-4xRjs.js.map → okx-sZ0-Udny.js.map} +1 -1
- package/dist/{open-sea-D2GwAmKS.js → open-sea-DO9PhTrz.js} +1 -1
- package/dist/{open-sea-D2GwAmKS.js.map → open-sea-DO9PhTrz.js.map} +1 -1
- package/dist/orders-DH76ym2e.js +469 -0
- package/dist/orders-DH76ym2e.js.map +1 -0
- package/dist/{primary-sale-DOmNDq2P.js → primary-sale-1u4QlPdA.js} +1 -1
- package/dist/{primary-sale-DOmNDq2P.js.map → primary-sale-1u4QlPdA.js.map} +1 -1
- package/dist/primary-sales-CECrqatg.js +156 -0
- package/dist/primary-sales-CECrqatg.js.map +1 -0
- package/dist/{query-BG-MA1MB.d.ts → query-brXxOcH0.d.ts} +1 -1
- package/dist/{rarible-DqiiW9ki.js → rarible-Ccb2hs7y.js} +1 -1
- package/dist/{rarible-DqiiW9ki.js.map → rarible-Ccb2hs7y.js.map} +1 -1
- package/dist/react/_internal/api/index.d.ts +2 -2
- package/dist/react/_internal/api/index.js +6 -6
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +32 -22
- package/dist/react/_internal/index.d.ts +2 -2
- package/dist/react/_internal/index.js +8 -8
- package/dist/react/_internal/wagmi/index.d.ts +1 -1
- package/dist/react/_internal/wagmi/index.js +3 -3
- package/dist/react/hooks/config/index.d.ts +8 -8
- package/dist/react/hooks/config/index.js +32 -22
- package/dist/react/hooks/contracts/index.d.ts +6 -6
- package/dist/react/hooks/contracts/index.js +12 -12
- package/dist/react/hooks/data/collectibles/index.d.ts +10 -4
- package/dist/react/hooks/data/collectibles/index.js +32 -22
- package/dist/react/hooks/data/collections/index.d.ts +11 -11
- package/dist/react/hooks/data/collections/index.js +33 -23
- package/dist/react/hooks/data/index.d.ts +37 -29
- package/dist/react/hooks/data/index.js +33 -23
- package/dist/react/hooks/data/inventory/index.d.ts +36 -28
- package/dist/react/hooks/data/inventory/index.js +32 -22
- package/dist/react/hooks/data/market/index.d.ts +11 -5
- package/dist/react/hooks/data/market/index.js +32 -22
- package/dist/react/hooks/data/orders/index.d.ts +11 -5
- package/dist/react/hooks/data/orders/index.js +33 -23
- package/dist/react/hooks/data/primary-sales/index.d.ts +37 -29
- package/dist/react/hooks/data/primary-sales/index.js +33 -23
- package/dist/react/hooks/data/tokens/index.d.ts +4 -4
- package/dist/react/hooks/data/tokens/index.js +32 -22
- package/dist/react/hooks/index.d.ts +37 -29
- package/dist/react/hooks/index.js +33 -23
- package/dist/react/hooks/transactions/index.d.ts +2 -2
- package/dist/react/hooks/transactions/index.js +32 -22
- package/dist/react/hooks/ui/index.d.ts +4 -4
- package/dist/react/hooks/ui/index.js +32 -22
- package/dist/react/hooks/utils/index.d.ts +36 -28
- package/dist/react/hooks/utils/index.js +32 -22
- package/dist/react/index.d.ts +37 -29
- package/dist/react/index.js +33 -23
- package/dist/react/queries/collectibles/index.d.ts +11 -0
- package/dist/react/queries/collectibles/index.js +22 -0
- package/dist/react/queries/collections/index.d.ts +11 -0
- package/dist/react/queries/collections/index.js +20 -0
- package/dist/react/queries/index.d.ts +24 -16
- package/dist/react/queries/index.js +26 -16
- package/dist/react/queries/inventory/index.d.ts +3 -0
- package/dist/react/queries/inventory/index.js +22 -0
- package/dist/react/queries/market/index.d.ts +6 -0
- package/dist/react/queries/market/index.js +22 -0
- package/dist/react/queries/orders/index.d.ts +11 -0
- package/dist/react/queries/orders/index.js +13 -0
- package/dist/react/queries/primary-sales/index.d.ts +4 -0
- package/dist/react/queries/primary-sales/index.js +13 -0
- package/dist/react/queries/tokens/index.d.ts +5 -0
- package/dist/react/queries/tokens/index.js +13 -0
- package/dist/react/queries/utils/index.d.ts +4 -0
- package/dist/react/queries/utils/index.js +22 -0
- package/dist/react/ssr/index.d.ts +7 -7
- package/dist/react/ssr/index.js +8 -8
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.d.ts +2 -2
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.js +16 -16
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.d.ts +7 -10
- package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.js +32 -22
- package/dist/react/ui/components/marketplace-collectible-card/index.d.ts +4 -4
- package/dist/react/ui/components/marketplace-collectible-card/index.js +32 -22
- 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 +8 -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 +12 -12
- package/dist/react/ui/index.d.ts +4 -4
- package/dist/react/ui/index.js +32 -22
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +32 -22
- package/dist/react/utils/index.d.ts +3 -3
- package/dist/react/utils/index.js +6 -6
- package/dist/{react-BLJ4DkPx.js → react-CBsgOdVP.js} +1540 -474
- package/dist/react-CBsgOdVP.js.map +1 -0
- package/dist/{sequence-Bbb-TFKg.js → sequence-CRdb1yEs.js} +1 -1
- package/dist/{sequence-Bbb-TFKg.js.map → sequence-CRdb1yEs.js.map} +1 -1
- package/dist/styles/index.css +155 -1
- package/dist/{sudo-swap-CEPIM3Js.js → sudo-swap-BIklG2gq.js} +1 -1
- package/dist/{sudo-swap-CEPIM3Js.js.map → sudo-swap-BIklG2gq.js.map} +1 -1
- package/dist/{super-rare-CMEn9PoO.js → super-rare-h8645_5E.js} +1 -1
- package/dist/{super-rare-CMEn9PoO.js.map → super-rare-h8645_5E.js.map} +1 -1
- package/dist/{token-CcyLz8Z8.js → token-Cv7l2ZaL.js} +1 -1
- package/dist/{token-CcyLz8Z8.js.map → token-Cv7l2ZaL.js.map} +1 -1
- package/dist/tokenBalances-CouzNX4j.js +57 -0
- package/dist/tokenBalances-CouzNX4j.js.map +1 -0
- package/dist/tokenSupplies-C3zJll0M.d.ts +265 -0
- package/dist/tokens-BvIRUCGG.js +225 -0
- package/dist/tokens-BvIRUCGG.js.map +1 -0
- package/dist/transaction-DZUW5RHu.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types-B_-cnkcP.js.map +1 -1
- package/dist/{types-D6LkVrF0.d.ts → types-CMDwfhfR.d.ts} +6 -5
- package/dist/utils/abi/index.d.ts +5 -5
- package/dist/utils/abi/index.js +5 -5
- 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 +7 -7
- package/dist/utils/index.js +11 -11
- package/dist/{utils-BZEkdqWK.js → utils-9ToOvt-c.js} +50 -7
- package/dist/utils-9ToOvt-c.js.map +1 -0
- package/dist/{utils-oVZxdK0o.js → utils-B6di6O-C.js} +2 -2
- package/dist/utils-B6di6O-C.js.map +1 -0
- package/dist/utils-BCYTEOvy.js +122 -0
- package/dist/utils-BCYTEOvy.js.map +1 -0
- package/dist/waitForTransactionReceipt-CbSeUSXe.js +26 -0
- package/dist/waitForTransactionReceipt-CbSeUSXe.js.map +1 -0
- package/dist/{x2y2-DNe6JgtG.js → x2y2-OvF__ugj.js} +1 -1
- package/dist/{x2y2-DNe6JgtG.js.map → x2y2-OvF__ugj.js.map} +1 -1
- package/dist/{zora-w0Zqxxs4.js → zora-DzCeu-eE.js} +1 -1
- package/dist/{zora-w0Zqxxs4.js.map → zora-DzCeu-eE.js.map} +1 -1
- package/package.json +46 -41
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +15 -0
- package/src/react/_internal/api/index.ts +0 -1
- package/src/react/_internal/api/marketplace.gen.ts +1774 -2383
- package/src/react/_internal/api/query-keys.ts +23 -0
- package/src/react/_internal/api/services.ts +1 -1
- package/src/react/_internal/databeat/types.ts +1 -0
- package/src/react/_internal/types.ts +14 -0
- package/src/react/_internal/utils.ts +3 -0
- package/src/react/hooks/config/useMarketplaceConfig.tsx +1 -1
- package/src/react/hooks/data/collectibles/useBalanceOfCollectible.tsx +1 -10
- package/src/react/hooks/data/collectibles/useCollectible.tsx +1 -1
- package/src/react/hooks/data/collectibles/useCountOfCollectables.tsx +1 -1
- package/src/react/hooks/data/collectibles/useListCollectibleActivities.tsx +1 -1
- package/src/react/hooks/data/collectibles/useListCollectibles.tsx +2 -17
- package/src/react/hooks/data/collectibles/useListCollectiblesPaginated.tsx +1 -1
- package/src/react/hooks/data/collectibles/useTokenBalances.tsx +1 -10
- package/src/react/hooks/data/collections/index.ts +2 -0
- package/src/react/hooks/data/collections/useCollection.tsx +1 -1
- package/src/react/hooks/data/collections/useCollectionActiveListingsCurrencies.test.tsx +112 -0
- package/src/react/hooks/data/collections/useCollectionActiveListingsCurrencies.tsx +74 -0
- package/src/react/hooks/data/collections/useCollectionActiveOffersCurrencies.test.tsx +110 -0
- package/src/react/hooks/data/collections/useCollectionActiveOffersCurrencies.tsx +74 -0
- package/src/react/hooks/data/collections/useCollectionBalanceDetails.tsx +1 -1
- package/src/react/hooks/data/collections/useCollectionDetails.ts +1 -1
- package/src/react/hooks/data/collections/useListCollectionActivities.tsx +1 -1
- package/src/react/hooks/data/collections/useListCollections.tsx +1 -1
- package/src/react/hooks/data/inventory/useInventory.tsx +2 -11
- package/src/react/hooks/data/market/useCurrency.tsx +1 -1
- package/src/react/hooks/data/market/useListMarketCardData.tsx +7 -0
- package/src/react/hooks/data/market/useMarketCurrencies.test.tsx +31 -2
- package/src/react/hooks/data/market/useMarketCurrencies.tsx +1 -1
- package/src/react/hooks/data/orders/index.ts +4 -0
- package/src/react/hooks/data/orders/useCountItemsOrdersForCollection.tsx +90 -0
- package/src/react/hooks/data/orders/useCountListingsForCollectible.tsx +1 -1
- package/src/react/hooks/data/orders/useCountOffersForCollectible.tsx +1 -1
- package/src/react/hooks/data/orders/useFloorOrder.tsx +1 -1
- package/src/react/hooks/data/orders/useGetCountOfFilteredOrders.tsx +39 -0
- package/src/react/hooks/data/orders/useHighestOffer.tsx +1 -1
- package/src/react/hooks/data/orders/useListItemsOrdersForCollection.tsx +93 -0
- package/src/react/hooks/data/orders/useListItemsOrdersForCollectionPaginated.tsx +108 -0
- package/src/react/hooks/data/orders/useListListingsForCollectible.tsx +1 -1
- package/src/react/hooks/data/orders/useListOffersForCollectible.tsx +1 -1
- package/src/react/hooks/data/orders/useLowestListing.tsx +1 -1
- package/src/react/hooks/data/primary-sales/index.ts +1 -0
- package/src/react/hooks/data/primary-sales/useGetCountOfPrimarySaleItems.tsx +2 -2
- package/src/react/hooks/data/primary-sales/useListPrimarySaleItems.tsx +1 -1
- package/src/react/hooks/data/primary-sales/usePrimarySaleItem.tsx +71 -0
- package/src/react/hooks/data/tokens/useGetTokenRanges.tsx +2 -2
- package/src/react/hooks/data/tokens/useListBalances.tsx +3 -12
- package/src/react/hooks/data/tokens/useListTokenMetadata.tsx +1 -1
- package/src/react/hooks/data/tokens/useSearchTokenMetadata.tsx +1 -1
- package/src/react/hooks/data/tokens/useTokenSupplies.ts +2 -14
- package/src/react/hooks/transactions/useGenerateCancelTransaction.test.tsx +1 -0
- package/src/react/hooks/transactions/useGenerateListingTransaction.test.tsx +13 -0
- package/src/react/hooks/transactions/useGenerateOfferTransaction.test.tsx +3 -0
- package/src/react/hooks/transactions/useGenerateSellTransaction.test.tsx +6 -0
- package/src/react/hooks/transactions/useProcessStep.test.tsx +8 -6
- package/src/react/hooks/transactions/useProcessStep.ts +8 -6
- package/src/react/hooks/ui/useFilterState.tsx +72 -2
- package/src/react/hooks/ui/useFilters.tsx +1 -1
- package/src/react/hooks/utils/useCheckoutOptions.tsx +2 -2
- package/src/react/hooks/utils/useCheckoutOptionsSalesContract.tsx +1 -1
- package/src/react/hooks/utils/useComparePrices.test.tsx +1 -1
- package/src/react/hooks/utils/useComparePrices.tsx +1 -1
- package/src/react/hooks/utils/useConvertPriceToUSD.tsx +1 -1
- package/src/react/providers/analytics-provider.tsx +45 -0
- package/src/react/providers/index.tsx +30 -41
- package/src/react/providers/modal-provider.tsx +14 -2
- package/src/react/queries/{balanceOfCollectible.ts → collectibles/balanceOfCollectible.ts} +23 -16
- package/src/react/queries/{collectible.ts → collectibles/collectible.ts} +20 -5
- package/src/react/queries/{countOfCollectables.ts → collectibles/countOfCollectables.ts} +32 -6
- package/src/react/queries/collectibles/index.ts +7 -0
- package/src/react/queries/{listCollectibleActivities.ts → collectibles/listCollectibleActivities.ts} +29 -5
- package/src/react/queries/{listCollectibles.ts → collectibles/listCollectibles.ts} +22 -56
- package/src/react/queries/{listCollectiblesPaginated.ts → collectibles/listCollectiblesPaginated.ts} +22 -5
- package/src/react/queries/{tokenBalances.ts → collectibles/tokenBalances.ts} +20 -16
- package/src/react/queries/collections/activeListingsCurrencies.ts +84 -0
- package/src/react/queries/collections/activeOffersCurrencies.ts +84 -0
- package/src/react/queries/{collection.ts → collections/collection.ts} +19 -5
- package/src/react/queries/{collectionBalanceDetails.ts → collections/collectionBalanceDetails.ts} +19 -4
- package/src/react/queries/{collectionDetails.ts → collections/collectionDetails.ts} +21 -6
- package/src/react/queries/collections/index.ts +7 -0
- package/src/react/queries/{listCollectionActivities.ts → collections/listCollectionActivities.ts} +28 -6
- package/src/react/queries/{listCollections.ts → collections/listCollections.ts} +17 -6
- package/src/react/queries/index.ts +7 -34
- package/src/react/queries/inventory/index.ts +1 -0
- package/src/react/queries/{inventory.ts → inventory/inventory.ts} +13 -14
- package/src/react/queries/{checkoutOptions.ts → market/checkoutOptions.ts} +28 -6
- package/src/react/queries/{checkoutOptionsSalesContract.ts → market/checkoutOptionsSalesContract.ts} +24 -5
- package/src/react/queries/{currency.ts → market/currency.ts} +13 -4
- package/src/react/queries/{filters.ts → market/filters.ts} +25 -6
- package/src/react/queries/market/index.ts +6 -0
- package/src/react/queries/{marketCurrencies.ts → market/marketCurrencies.ts} +32 -6
- package/src/react/queries/{marketplaceConfig.ts → market/marketplaceConfig.ts} +5 -5
- package/src/react/queries/orders/countItemsOrdersForCollection.ts +86 -0
- package/src/react/queries/{countListingsForCollectible.ts → orders/countListingsForCollectible.ts} +23 -6
- package/src/react/queries/{countOffersForCollectible.ts → orders/countOffersForCollectible.ts} +23 -6
- package/src/react/queries/{floorOrder.ts → orders/floorOrder.ts} +15 -4
- package/src/react/queries/orders/getCountOfFilteredOrders.ts +88 -0
- package/src/react/queries/{highestOffer.ts → orders/highestOffer.ts} +16 -4
- package/src/react/queries/orders/index.ts +11 -0
- package/src/react/queries/orders/listItemsOrdersForCollection.ts +90 -0
- package/src/react/queries/orders/listItemsOrdersForCollectionPaginated.ts +90 -0
- package/src/react/queries/{listListingsForCollectible.ts → orders/listListingsForCollectible.ts} +20 -5
- package/src/react/queries/{listOffersForCollectible.ts → orders/listOffersForCollectible.ts} +20 -5
- package/src/react/queries/{lowestListing.ts → orders/lowestListing.ts} +16 -4
- package/src/react/queries/{countOfPrimarySaleItems.ts → primary-sales/countOfPrimarySaleItems.ts} +17 -3
- package/src/react/queries/primary-sales/index.ts +4 -0
- package/src/react/queries/primary-sales/primarySaleItem.ts +80 -0
- package/src/react/queries/{primarySaleItems.ts → primary-sales/primarySaleItems.ts} +18 -4
- package/src/react/queries/{primarySaleItemsCount.ts → primary-sales/primarySaleItemsCount.ts} +19 -4
- package/src/react/queries/{getTokenRanges.ts → tokens/getTokenRanges.ts} +17 -4
- package/src/react/queries/tokens/index.ts +5 -0
- package/src/react/queries/{listBalances.ts → tokens/listBalances.ts} +17 -22
- package/src/react/queries/{listTokenMetadata.ts → tokens/listTokenMetadata.ts} +18 -4
- package/src/react/queries/{searchTokenMetadata.ts → tokens/searchTokenMetadata.ts} +18 -4
- package/src/react/queries/{tokenSupplies.ts → tokens/tokenSupplies.ts} +17 -34
- package/src/react/queries/{comparePrices.ts → utils/comparePrices.ts} +29 -5
- package/src/react/queries/{convertPriceToUSD.ts → utils/convertPriceToUSD.ts} +18 -5
- package/src/react/queries/utils/index.ts +2 -0
- package/src/react/ssr/create-ssr-client.ts +1 -1
- package/src/react/ui/components/_internals/ErrorLogBox.tsx +85 -0
- package/src/react/ui/components/_internals/action-button/ActionButton.stories.tsx +2 -0
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +4 -0
- package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -0
- package/src/react/ui/components/marketplace-collectible-card/components/ActionButtonWrapper.tsx +3 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/Footer.tsx +4 -18
- package/src/react/ui/components/marketplace-collectible-card/types.ts +1 -0
- package/src/react/ui/components/marketplace-collectible-card/variants/MarketCard.tsx +5 -2
- package/src/react/ui/components/marketplace-collectible-card/variants/ShopCard.tsx +2 -2
- package/src/react/ui/modals/BuyModal/__tests__/BuyModalRouter.test.tsx +3 -0
- package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +1 -0
- package/src/react/ui/modals/BuyModal/components/ERC1155BuyModal.tsx +65 -3
- package/src/react/ui/modals/BuyModal/components/ERC721BuyModal.tsx +31 -0
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useERC721SalePaymentParams.test.tsx +20 -1
- package/src/react/ui/modals/BuyModal/hooks/useERC1155Checkout.ts +7 -2
- package/src/react/ui/modals/BuyModal/hooks/useERC721SalePaymentParams.ts +12 -3
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +11 -25
- package/src/react/ui/modals/BuyModal/store.ts +3 -0
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +63 -24
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +4 -0
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +18 -12
- package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +4 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +1 -0
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +77 -10
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +12 -0
- package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +6 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +15 -26
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +3 -0
- package/src/react/ui/modals/SellModal/Modal.tsx +21 -3
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +2 -0
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +3 -1
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +13 -7
- package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +9 -0
- package/src/react/ui/modals/_internal/components/calendarDropdown/TimeSelector.tsx +105 -0
- package/src/react/ui/modals/_internal/components/calendarDropdown/index.tsx +45 -12
- package/src/react/ui/modals/_internal/components/calendarDropdown/overrides.css +39 -0
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +34 -10
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +18 -9
- package/src/react/ui/modals/_internal/components/floorPriceText/__tests__/FloorPriceText.test.tsx +2 -0
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +198 -11
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +58 -10
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +2 -0
- package/src/react/utils/waitForTransactionReceipt.ts +26 -32
- package/src/styles/index.css +1 -0
- package/src/styles/styles.ts +156 -2
- package/src/types/index.ts +1 -1
- package/src/utils/abi/index.ts +1 -0
- package/src/utils/abi/mainModule.ts +158 -0
- package/src/utils/networkconfigToWagmiChain.ts +7 -0
- package/src/utils/price.ts +58 -0
- package/test/const.ts +2 -0
- package/test/server-setup.ts +0 -2
- package/dist/BellIcon-IpHHEy8h.js.map +0 -1
- package/dist/CartIcon-C8zbor8H.js.map +0 -1
- package/dist/CollectibleCard-C2EWF0zo.d.ts +0 -8
- package/dist/api-DuLKn__v.js.map +0 -1
- package/dist/builder-api-BFuZNOaN.js.map +0 -1
- package/dist/builder.gen-B9wR2nvF.js.map +0 -1
- package/dist/components-CUv-wQr8.js.map +0 -1
- package/dist/create-config-CIfejoCk.js.map +0 -1
- package/dist/filters-zkMJaPey.d.ts +0 -31
- package/dist/index-B8vaT3_s.d.ts +0 -18
- package/dist/index-Yobo6icm.d.ts +0 -234
- package/dist/listCollectiblesPaginated-Bq0QSOjJ.d.ts +0 -168
- package/dist/listCollections-dTCq00l5.d.ts +0 -669
- package/dist/lowestListing-CB5Te-Q9.d.ts +0 -168
- package/dist/marketplace-logos-Csv2MBwf.js.map +0 -1
- package/dist/marketplace.gen-w2YvbEEo.js.map +0 -1
- package/dist/marketplaceConfig-BTy75Mbf.js.map +0 -1
- package/dist/network-DtmiMhcg.js.map +0 -1
- package/dist/networkconfigToWagmiChain-DbUf6HiO.js.map +0 -1
- package/dist/queries-EMA5CcwY.js +0 -1399
- package/dist/queries-EMA5CcwY.js.map +0 -1
- package/dist/react-BLJ4DkPx.js.map +0 -1
- package/dist/react-F03jPjPk.css +0 -80
- package/dist/react-F03jPjPk.css.map +0 -1
- package/dist/tokenSupplies-C470zTT0.d.ts +0 -147
- package/dist/utils-BZEkdqWK.js.map +0 -1
- package/dist/utils-oVZxdK0o.js.map +0 -1
- package/dist/waitForTransactionReceipt-B08YZiDY.js +0 -26
- package/dist/waitForTransactionReceipt-B08YZiDY.js.map +0 -1
- package/src/react/_internal/api/__mocks__/laos.msw.ts +0 -387
- package/src/react/_internal/api/__tests__/laos-api.test.ts +0 -756
- package/src/react/_internal/api/laos-api.ts +0 -106
- package/src/react/hooks/data/collectibles/useBalanceOfCollectible.laos.test.tsx +0 -367
- package/src/react/queries/__tests__/balanceOfCollectible.laos.test.ts +0 -123
- package/src/react/queries/__tests__/inventory.laos.test.ts +0 -499
- package/src/react/queries/__tests__/tokenBalances.laos.test.ts +0 -123
- /package/dist/{index-Cg5cFzs-.d.ts → index-CCggO_hw.d.ts} +0 -0
- /package/dist/{abi-DYsUABe6.js → queries-CyajGg_O.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CardType, CollectibleCardAction, CollectibleOrder, ContractType, Order, OrderbookKind, TokenMetadata
|
|
2
|
-
import { TokenMetadata } from "@0xsequence/metadata";
|
|
1
|
+
import { CardType, CollectibleCardAction$1 as CollectibleCardAction, CollectibleOrder, ContractType, Order, OrderbookKind, TokenMetadata } from "./create-config-CFBeD8CB.js";
|
|
2
|
+
import { TokenMetadata as TokenMetadata$1 } from "@0xsequence/metadata";
|
|
3
3
|
import { Address } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/react/ui/components/marketplace-collectible-card/types.d.ts
|
|
@@ -11,10 +11,11 @@ type MarketplaceCardBaseProps = {
|
|
|
11
11
|
assetSrcPrefixUrl?: string;
|
|
12
12
|
cardLoading: boolean;
|
|
13
13
|
cardType?: CardType;
|
|
14
|
+
hideQuantitySelector?: boolean;
|
|
14
15
|
};
|
|
15
16
|
type ShopCardSpecificProps = {
|
|
16
17
|
salesContractAddress: Address;
|
|
17
|
-
tokenMetadata: TokenMetadata
|
|
18
|
+
tokenMetadata: TokenMetadata | TokenMetadata$1;
|
|
18
19
|
salePrice: {
|
|
19
20
|
amount: string;
|
|
20
21
|
currencyAddress: Address;
|
|
@@ -59,7 +60,7 @@ type MarketCardSpecificProps = {
|
|
|
59
60
|
type NonTradableInventoryCardSpecificProps = {
|
|
60
61
|
balance: string;
|
|
61
62
|
balanceIsLoading: boolean;
|
|
62
|
-
collectibleMetadata: TokenMetadata
|
|
63
|
+
collectibleMetadata: TokenMetadata | TokenMetadata$1;
|
|
63
64
|
};
|
|
64
65
|
type MarketplaceCollectibleCardProps = MarketplaceCardBaseProps & Partial<MarketCardSpecificProps & ShopCardSpecificProps>;
|
|
65
66
|
type ShopCollectibleCardProps = MarketplaceCardBaseProps & ShopCardSpecificProps & {
|
|
@@ -74,4 +75,4 @@ type NonTradableInventoryCardProps = MarketplaceCardBaseProps & NonTradableInven
|
|
|
74
75
|
type CollectibleCardProps = ShopCollectibleCardProps | MarketCollectibleCardProps | NonTradableInventoryCardProps;
|
|
75
76
|
//#endregion
|
|
76
77
|
export { type CollectibleCardProps, type MarketCardSpecificProps, type MarketCollectibleCardProps, type MarketplaceCardBaseProps, type MarketplaceCollectibleCardProps, type NonTradableInventoryCardProps, type ShopCardSpecificProps, type ShopCollectibleCardProps };
|
|
77
|
-
//# sourceMappingURL=types-
|
|
78
|
+
//# sourceMappingURL=types-CMDwfhfR.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "../../index-
|
|
5
|
-
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
1
|
+
import { MAIN_MODULE_ABI$1 as MAIN_MODULE_ABI } from "../../index-8scPf0CS.js";
|
|
2
|
+
import { EIP2981_ABI$1 as EIP2981_ABI, SequenceMarketplaceV1_ABI$1 as SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI$1 as SequenceMarketplaceV2_ABI } from "../../index-DD7Vc4cE.js";
|
|
3
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0$1 as ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1$1 as ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0$1 as ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1$1 as ERC721_SALE_ABI_V1 } from "../../index-isFvc5gd.js";
|
|
4
|
+
import { ERC1155_ABI$1 as ERC1155_ABI, ERC20_ABI$1 as ERC20_ABI, ERC721_ABI$1 as ERC721_ABI, SEQUENCE_1155_ITEMS_ABI$1 as SEQUENCE_1155_ITEMS_ABI } from "../../index-pbE88Tt7.js";
|
|
5
|
+
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, MAIN_MODULE_ABI, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
package/dist/utils/abi/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "../../
|
|
1
|
+
import { MAIN_MODULE_ABI } from "../../abi-fa-o9gH3.js";
|
|
2
|
+
import { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI } from "../../marketplace-NQB-sEQL.js";
|
|
3
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 } from "../../primary-sale-1u4QlPdA.js";
|
|
4
|
+
import { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI } from "../../token-Cv7l2ZaL.js";
|
|
5
5
|
|
|
6
|
-
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
6
|
+
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, MAIN_MODULE_ABI, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI } from "../../../index-
|
|
1
|
+
import { EIP2981_ABI$1 as EIP2981_ABI, SequenceMarketplaceV1_ABI$1 as SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI$1 as SequenceMarketplaceV2_ABI } from "../../../index-DD7Vc4cE.js";
|
|
2
2
|
export { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI } from "../../../marketplace-
|
|
1
|
+
import { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI } from "../../../marketplace-NQB-sEQL.js";
|
|
2
2
|
|
|
3
3
|
export { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 } from "../../../index-
|
|
1
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0$1 as ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1$1 as ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0$1 as ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1$1 as ERC721_SALE_ABI_V1 } from "../../../index-isFvc5gd.js";
|
|
2
2
|
export { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 } from "../../../primary-sale-
|
|
1
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 } from "../../../primary-sale-1u4QlPdA.js";
|
|
2
2
|
|
|
3
3
|
export { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI } from "../../../index-
|
|
1
|
+
import { ERC1155_ABI$1 as ERC1155_ABI, ERC20_ABI$1 as ERC20_ABI, ERC721_ABI$1 as ERC721_ABI, SEQUENCE_1155_ITEMS_ABI$1 as SEQUENCE_1155_ITEMS_ABI } from "../../../index-pbE88Tt7.js";
|
|
2
2
|
export { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI } from "../../../token-
|
|
1
|
+
import { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI } from "../../../token-Cv7l2ZaL.js";
|
|
2
2
|
|
|
3
3
|
export { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../create-config-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "../index-
|
|
6
|
-
import { calculateEarningsAfterFees, calculatePriceDifferencePercentage, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle } from "../index-
|
|
7
|
-
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI, calculateEarningsAfterFees, calculatePriceDifferencePercentage, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle };
|
|
1
|
+
import "../create-config-CFBeD8CB.js";
|
|
2
|
+
import { MAIN_MODULE_ABI$1 as MAIN_MODULE_ABI } from "../index-8scPf0CS.js";
|
|
3
|
+
import { EIP2981_ABI$1 as EIP2981_ABI, SequenceMarketplaceV1_ABI$1 as SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI$1 as SequenceMarketplaceV2_ABI } from "../index-DD7Vc4cE.js";
|
|
4
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0$1 as ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1$1 as ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0$1 as ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1$1 as ERC721_SALE_ABI_V1 } from "../index-isFvc5gd.js";
|
|
5
|
+
import { ERC1155_ABI$1 as ERC1155_ABI, ERC20_ABI$1 as ERC20_ABI, ERC721_ABI$1 as ERC721_ABI, SEQUENCE_1155_ITEMS_ABI$1 as SEQUENCE_1155_ITEMS_ABI } from "../index-pbE88Tt7.js";
|
|
6
|
+
import { calculateEarningsAfterFees$1 as calculateEarningsAfterFees, calculatePriceDifferencePercentage$1 as calculatePriceDifferencePercentage, calculateTotalOfferCost$1 as calculateTotalOfferCost, cn$1 as cn, compareAddress$1 as compareAddress, formatPrice$3 as formatPrice, formatPriceWithFee$1 as formatPriceWithFee, getMarketplaceDetails$1 as getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd$1 as truncateEnd, truncateMiddle$1 as truncateMiddle, validateOpenseaOfferDecimals$1 as validateOpenseaOfferDecimals } from "../index-Dsf9FRtr.js";
|
|
7
|
+
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, MAIN_MODULE_ABI, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI, calculateEarningsAfterFees, calculatePriceDifferencePercentage, calculateTotalOfferCost, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle, validateOpenseaOfferDecimals };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import "../builder.gen
|
|
2
|
-
import { networkToWagmiChain } from "../networkconfigToWagmiChain-
|
|
1
|
+
import "../builder.gen--XD71cNL.js";
|
|
2
|
+
import { networkToWagmiChain$1 as networkToWagmiChain } from "../networkconfigToWagmiChain-Ct-hGq8M.js";
|
|
3
3
|
import "../transaction-DZUW5RHu.js";
|
|
4
|
-
import "../marketplace.gen-
|
|
5
|
-
import { getNetwork, getPresentableChainName } from "../network-
|
|
4
|
+
import "../marketplace.gen-906FrJQJ.js";
|
|
5
|
+
import { getNetwork$1 as getNetwork, getPresentableChainName$1 as getPresentableChainName } from "../network-DwdZ_5-7.js";
|
|
6
6
|
import "../types-B_-cnkcP.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import "../
|
|
11
|
-
import { calculateEarningsAfterFees, calculatePriceDifferencePercentage, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, truncateEnd, truncateMiddle } from "../utils-
|
|
12
|
-
import "../marketplace-logos-
|
|
7
|
+
import { MAIN_MODULE_ABI } from "../abi-fa-o9gH3.js";
|
|
8
|
+
import { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI } from "../marketplace-NQB-sEQL.js";
|
|
9
|
+
import { ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1 } from "../primary-sale-1u4QlPdA.js";
|
|
10
|
+
import { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI } from "../token-Cv7l2ZaL.js";
|
|
11
|
+
import { calculateEarningsAfterFees, calculatePriceDifferencePercentage, calculateTotalOfferCost, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, truncateEnd, truncateMiddle, validateOpenseaOfferDecimals } from "../utils-9ToOvt-c.js";
|
|
12
|
+
import "../marketplace-logos-Cz9RrtQo.js";
|
|
13
13
|
|
|
14
|
-
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI, calculateEarningsAfterFees, calculatePriceDifferencePercentage, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle };
|
|
14
|
+
export { EIP2981_ABI, ERC1155_ABI, ERC1155_SALES_CONTRACT_ABI_V0, ERC1155_SALES_CONTRACT_ABI_V1, ERC20_ABI, ERC721_ABI, ERC721_SALE_ABI_V0, ERC721_SALE_ABI_V1, MAIN_MODULE_ABI, SEQUENCE_1155_ITEMS_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI, calculateEarningsAfterFees, calculatePriceDifferencePercentage, calculateTotalOfferCost, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle, validateOpenseaOfferDecimals };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MarketplaceKind } from "./marketplace.gen-
|
|
2
|
-
import { AlienSwapLogo, BlurLogo, LooksRareLogo, MagicEdenLogo, MintifyLogo, OpenSeaLogo, SequenceLogo, X2y2Logo } from "./marketplace-logos-
|
|
1
|
+
import { MarketplaceKind$1 as MarketplaceKind } from "./marketplace.gen-906FrJQJ.js";
|
|
2
|
+
import { AlienSwapLogo, BlurLogo, LooksRareLogo, MagicEdenLogo, MintifyLogo, OpenSeaLogo, SequenceLogo, X2y2Logo } from "./marketplace-logos-Cz9RrtQo.js";
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
5
|
import * as dn from "dnum";
|
|
@@ -85,7 +85,8 @@ function getMarketplaceDetails({ originName, kind }) {
|
|
|
85
85
|
if (KIND_TO_MARKETPLACE[kind]) return MARKETPLACES[KIND_TO_MARKETPLACE[kind]];
|
|
86
86
|
}
|
|
87
87
|
function getRootDomain(url) {
|
|
88
|
-
const
|
|
88
|
+
const domain = url.replace(/^(https?:\/\/)?(www\.)?/, "");
|
|
89
|
+
const parts = domain.split(".");
|
|
89
90
|
return parts[parts.length - 2] || parts[0];
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -107,7 +108,9 @@ function getRootDomain(url) {
|
|
|
107
108
|
const calculatePriceDifferencePercentage = ({ inputPriceRaw, basePriceRaw, decimals }) => {
|
|
108
109
|
const inputPrice = Number(formatUnits(inputPriceRaw, decimals));
|
|
109
110
|
const basePrice = Number(formatUnits(basePriceRaw, decimals));
|
|
110
|
-
|
|
111
|
+
const difference = inputPrice - basePrice;
|
|
112
|
+
const percentageDifference = difference / basePrice * 100;
|
|
113
|
+
return percentageDifference.toFixed(2);
|
|
111
114
|
};
|
|
112
115
|
/**
|
|
113
116
|
* Formats a raw price amount with the specified number of decimal places
|
|
@@ -120,7 +123,8 @@ const calculatePriceDifferencePercentage = ({ inputPriceRaw, basePriceRaw, decim
|
|
|
120
123
|
* ```
|
|
121
124
|
*/
|
|
122
125
|
const formatPrice = (amount, decimals) => {
|
|
123
|
-
|
|
126
|
+
const formattedUnits = Number(formatUnits(amount, decimals));
|
|
127
|
+
return formattedUnits.toLocaleString("en-US", {
|
|
124
128
|
minimumFractionDigits: 0,
|
|
125
129
|
maximumFractionDigits: decimals
|
|
126
130
|
});
|
|
@@ -186,7 +190,46 @@ const formatPriceWithFee = (amount, decimals, feePercentage) => {
|
|
|
186
190
|
return "0";
|
|
187
191
|
}
|
|
188
192
|
};
|
|
193
|
+
const calculateTotalOfferCost = (offerAmountRaw, decimals, royaltyPercentage = 0) => {
|
|
194
|
+
try {
|
|
195
|
+
const dnumAmount = [offerAmountRaw, decimals];
|
|
196
|
+
let totalCost = dn.from(dnumAmount);
|
|
197
|
+
if (royaltyPercentage > 0) {
|
|
198
|
+
const royaltyFee = dn.multiply(totalCost, dn.from((royaltyPercentage / 100).toString(), decimals));
|
|
199
|
+
totalCost = dn.add(totalCost, royaltyFee);
|
|
200
|
+
}
|
|
201
|
+
const totalCostString = dn.format(totalCost, {
|
|
202
|
+
digits: decimals,
|
|
203
|
+
trailingZeros: true
|
|
204
|
+
});
|
|
205
|
+
const cleanAmount = totalCostString.replace(/,/g, "");
|
|
206
|
+
return BigInt(Math.round(Number(cleanAmount) * 10 ** decimals));
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error("Error calculating total offer cost:", error);
|
|
209
|
+
return offerAmountRaw;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Validates if a price value meets OpenSea's decimal constraints for offers
|
|
214
|
+
* OpenSea allows maximum 4 decimal places for offers and minimum 0.0001
|
|
215
|
+
* @param value - The price value as a string
|
|
216
|
+
* @returns Object containing validation result and error message
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const result = validateOpenseaOfferDecimals('0.12345');
|
|
220
|
+
* // Returns { isValid: false, errorMessage: "Offer amount must be at least 0.0001" }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
const validateOpenseaOfferDecimals = (value) => {
|
|
224
|
+
if (!value || value === "0") return { isValid: true };
|
|
225
|
+
const [_, decimals = ""] = value.split(".");
|
|
226
|
+
if (decimals.length > 4) return {
|
|
227
|
+
isValid: false,
|
|
228
|
+
errorMessage: "Offer amount must be at least 0.0001"
|
|
229
|
+
};
|
|
230
|
+
return { isValid: true };
|
|
231
|
+
};
|
|
189
232
|
|
|
190
233
|
//#endregion
|
|
191
|
-
export { calculateEarningsAfterFees, calculatePriceDifferencePercentage, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, truncateEnd, truncateMiddle };
|
|
192
|
-
//# sourceMappingURL=utils-
|
|
234
|
+
export { calculateEarningsAfterFees, calculatePriceDifferencePercentage, calculateTotalOfferCost, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, truncateEnd, truncateMiddle, validateOpenseaOfferDecimals };
|
|
235
|
+
//# sourceMappingURL=utils-9ToOvt-c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-9ToOvt-c.js","names":["address: string","text: string | undefined","truncateAt: number","MARKETPLACES: Record<string, Marketplace>","KIND_TO_MARKETPLACE: Partial<\n\tRecord<MarketplaceKind, keyof typeof MARKETPLACES>\n>","url: string","amount: bigint","decimals: number","fees: number[]","feePercentage: number","offerAmountRaw: bigint","value: string"],"sources":["../src/utils/address.ts","../src/utils/cn.ts","../src/utils/getMarketplaceDetails.ts","../src/utils/price.ts"],"sourcesContent":["export const truncateMiddle = (\n\taddress: string,\n\tminPrefix = 20,\n\tminSuffix = 3,\n): string => {\n\tif (minPrefix + minSuffix >= 40) {\n\t\treturn address;\n\t}\n\treturn `${address.substring(0, 2 + minPrefix)}…${address.substring(address.length - minSuffix)}`;\n};\n\nexport const truncateEnd = (text: string | undefined, truncateAt: number) => {\n\tif (!text) return '';\n\n\tlet finalText = text;\n\n\tif (text.length >= truncateAt) {\n\t\tfinalText = `${text.slice(0, truncateAt)}...`;\n\t}\n\n\treturn finalText;\n};\n\nexport const compareAddress = (a = '', b = '') => {\n\treturn a.toLowerCase() === b.toLowerCase();\n};\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","import type { Image } from '@0xsequence/design-system';\nimport type { ComponentType } from 'react';\nimport {\n\tAlienSwapLogo,\n\tBlurLogo,\n\tLooksRareLogo,\n\tMagicEdenLogo,\n\tMintifyLogo,\n\tOpenSeaLogo,\n\tSequenceLogo,\n\tX2y2Logo,\n} from '../react/ui/components/marketplace-logos';\nimport { MarketplaceKind } from '../types';\n\ninterface Marketplace {\n\tlogo: ComponentType<React.ComponentProps<typeof Image>>;\n\tdisplayName: string;\n}\n\nconst MARKETPLACES: Record<string, Marketplace> = {\n\tsequence: {\n\t\tlogo: SequenceLogo,\n\t\tdisplayName: 'Sequence',\n\t},\n\topensea: {\n\t\tlogo: OpenSeaLogo,\n\t\tdisplayName: 'OpenSea',\n\t},\n\tmagiceden: {\n\t\tlogo: MagicEdenLogo,\n\t\tdisplayName: 'Magic Eden',\n\t},\n\tmintify: {\n\t\tlogo: MintifyLogo,\n\t\tdisplayName: 'Mintify',\n\t},\n\tlooksrare: {\n\t\tlogo: LooksRareLogo,\n\t\tdisplayName: 'Looks Rare',\n\t},\n\tx2y2: {\n\t\tlogo: X2y2Logo,\n\t\tdisplayName: 'X2Y2',\n\t},\n\tblur: {\n\t\tlogo: BlurLogo,\n\t\tdisplayName: 'Blur',\n\t},\n\talienswap: {\n\t\tlogo: AlienSwapLogo,\n\t\tdisplayName: 'AlienSwap',\n\t},\n} as const;\n\nconst KIND_TO_MARKETPLACE: Partial<\n\tRecord<MarketplaceKind, keyof typeof MARKETPLACES>\n> = {\n\t[MarketplaceKind.sequence_marketplace_v1]: 'sequence',\n\t[MarketplaceKind.sequence_marketplace_v2]: 'sequence',\n\t[MarketplaceKind.opensea]: 'opensea',\n\t[MarketplaceKind.mintify]: 'mintify',\n\t[MarketplaceKind.looks_rare]: 'looksrare',\n\t[MarketplaceKind.x2y2]: 'x2y2',\n\t[MarketplaceKind.blur]: 'blur',\n\t[MarketplaceKind.magic_eden]: 'magiceden',\n};\n\ntype MarketplaceDetailsProp = {\n\toriginName: string;\n\tkind: MarketplaceKind;\n};\n\n// TODO: add support for more marketplaces and improve detection of marketplace\nexport function getMarketplaceDetails({\n\toriginName,\n\tkind,\n}: MarketplaceDetailsProp) {\n\tif (\n\t\tkind === MarketplaceKind.sequence_marketplace_v1 ||\n\t\tkind === MarketplaceKind.sequence_marketplace_v2\n\t) {\n\t\treturn MARKETPLACES.sequence;\n\t}\n\n\tlet name = originName.toLowerCase();\n\n\ttry {\n\t\t//Check if the name can be parsed as a url\n\t\tnew URL(name);\n\t\t// if it can we are naively trying to extract the root domain\n\t\tname = getRootDomain(name) || name;\n\t} catch {}\n\n\tname = name.replace(/ /g, '');\n\n\tconst details = MARKETPLACES[name];\n\n\tif (details) {\n\t\treturn details;\n\t}\n\n\tif (KIND_TO_MARKETPLACE[kind]) {\n\t\treturn MARKETPLACES[KIND_TO_MARKETPLACE[kind]];\n\t}\n}\n\nfunction getRootDomain(url: string) {\n\tconst domain = url.replace(/^(https?:\\/\\/)?(www\\.)?/, '');\n\tconst parts = domain.split('.');\n\treturn parts[parts.length - 2] || parts[0];\n}\n","import * as dn from 'dnum';\nimport { formatUnits } from 'viem';\n\ntype CalculatePriceDifferencePercentageArgs = {\n\tinputPriceRaw: bigint;\n\tbasePriceRaw: bigint;\n\tdecimals: number;\n};\n\n/**\n * Calculates the percentage difference between two prices\n * @param args - Object containing input price, base price, and decimals\n * @returns The percentage difference as a string with 2 decimal places\n * @example\n * ```ts\n * const diff = calculatePriceDifferencePercentage({\n * inputPriceRaw: 1000000n,\n * basePriceRaw: 900000n,\n * decimals: 6\n * }); // Returns \"11.11\"\n * ```\n */\nexport const calculatePriceDifferencePercentage = ({\n\tinputPriceRaw,\n\tbasePriceRaw,\n\tdecimals,\n}: CalculatePriceDifferencePercentageArgs) => {\n\tconst inputPrice = Number(formatUnits(inputPriceRaw, decimals));\n\tconst basePrice = Number(formatUnits(basePriceRaw, decimals));\n\tconst difference = inputPrice - basePrice;\n\tconst percentageDifference = (difference / basePrice) * 100;\n\n\treturn percentageDifference.toFixed(2);\n};\n\n/**\n * Formats a raw price amount with the specified number of decimal places\n * @param amount - The raw price amount as a bigint\n * @param decimals - Number of decimal places to format to\n * @returns Formatted price string with proper decimal and thousands separators\n * @example\n * ```ts\n * const formatted = formatPrice(1000000n, 6); // Returns \"1.000000\"\n * ```\n */\nexport const formatPrice = (amount: bigint, decimals: number): string => {\n\tconst formattedUnits = Number(formatUnits(amount, decimals));\n\treturn formattedUnits.toLocaleString('en-US', {\n\t\tminimumFractionDigits: 0,\n\t\tmaximumFractionDigits: decimals,\n\t});\n};\n\n/**\n * Calculates the final earnings amount after applying multiple fee percentages\n * @param amount - The raw amount as a bigint (e.g., from a blockchain transaction)\n * @param decimals - The number of decimal places for the currency (e.g., 18 for ETH, 6 for USDC)\n * @param fees - Array of fee percentages to apply (e.g., [2.5, 1.0] for 2.5% and 1% fees)\n * @returns Formatted string representing the final earnings after all fees are applied\n * @throws Will return '0' if there's an error in calculation\n * @example\n * ```ts\n * const earnings = calculateEarningsAfterFees(\n * 1000000000000000000n, // 1 ETH\n * 18, // ETH decimals\n * [2.5, 1.0] // 2.5% and 1% fees\n * ); // Returns \"0.96525\" (1 ETH after 2.5% and 1% fees)\n * ```\n */\nexport const calculateEarningsAfterFees = (\n\tamount: bigint,\n\tdecimals: number,\n\tfees: number[],\n): string => {\n\ttry {\n\t\tconst decimalAmount = Number(formatUnits(amount, decimals));\n\t\tlet earnings = dn.from(decimalAmount.toString(), decimals);\n\n\t\tfor (const fee of fees) {\n\t\t\tif (fee > 0) {\n\t\t\t\tconst feeMultiplier = dn.from((1 - fee / 100).toString(), decimals);\n\t\t\t\tearnings = dn.multiply(earnings, feeMultiplier);\n\t\t\t}\n\t\t}\n\n\t\treturn dn.format(earnings, {\n\t\t\tdigits: decimals,\n\t\t\ttrailingZeros: false,\n\t\t\tlocale: 'en-US',\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('Error calculating earnings after fees:', error);\n\t\treturn '0';\n\t}\n};\n\n/**\n * Formats a price amount with fee applied\n * @param amount - The raw price amount as a bigint\n * @param decimals - Number of decimal places for the currency\n * @param feePercentage - Fee percentage to apply (e.g., 3.5 for 3.5%)\n * @returns Formatted price string with fee applied and proper decimal/thousands separators\n * @example\n * ```ts\n * const priceWithFee = formatPriceWithFee(1000000n, 6, 3.5); // Returns \"1.035\"\n * ```\n */\nexport const formatPriceWithFee = (\n\tamount: bigint,\n\tdecimals: number,\n\tfeePercentage: number,\n): string => {\n\ttry {\n\t\tconst decimalAmount = Number(formatUnits(amount, decimals));\n\t\tconst price = dn.from(decimalAmount.toString(), decimals);\n\t\tconst feeMultiplier = dn.from(\n\t\t\t(1 + feePercentage / 100).toString(),\n\t\t\tdecimals,\n\t\t);\n\t\tconst totalPrice = dn.multiply(price, feeMultiplier);\n\n\t\treturn dn.format(totalPrice, {\n\t\t\tdigits: decimals,\n\t\t\ttrailingZeros: false,\n\t\t\tlocale: 'en-US',\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('Error formatting price with fee:', error);\n\t\treturn '0';\n\t}\n};\n\nexport const calculateTotalOfferCost = (\n\tofferAmountRaw: bigint,\n\tdecimals: number,\n\troyaltyPercentage = 0,\n): bigint => {\n\ttry {\n\t\tconst dnumAmount = [offerAmountRaw, decimals] as dn.Dnum;\n\t\tlet totalCost = dn.from(dnumAmount);\n\n\t\tif (royaltyPercentage > 0) {\n\t\t\tconst royaltyFee = dn.multiply(\n\t\t\t\ttotalCost,\n\t\t\t\tdn.from((royaltyPercentage / 100).toString(), decimals),\n\t\t\t);\n\t\t\ttotalCost = dn.add(totalCost, royaltyFee);\n\t\t}\n\n\t\tconst totalCostString = dn.format(totalCost, {\n\t\t\tdigits: decimals,\n\t\t\ttrailingZeros: true,\n\t\t});\n\n\t\tconst cleanAmount = totalCostString.replace(/,/g, '');\n\n\t\treturn BigInt(Math.round(Number(cleanAmount) * 10 ** decimals));\n\t} catch (error) {\n\t\tconsole.error('Error calculating total offer cost:', error);\n\t\treturn offerAmountRaw;\n\t}\n};\n\n/**\n * Validates if a price value meets OpenSea's decimal constraints for offers\n * OpenSea allows maximum 4 decimal places for offers and minimum 0.0001\n * @param value - The price value as a string\n * @returns Object containing validation result and error message\n * @example\n * ```ts\n * const result = validateOpenseaOfferDecimals('0.12345');\n * // Returns { isValid: false, errorMessage: \"Offer amount must be at least 0.0001\" }\n * ```\n */\nexport const validateOpenseaOfferDecimals = (\n\tvalue: string,\n): { isValid: boolean; errorMessage?: string } => {\n\tif (!value || value === '0') return { isValid: true };\n\n\tconst [_, decimals = ''] = value.split('.');\n\tif (decimals.length > 4) {\n\t\treturn {\n\t\t\tisValid: false,\n\t\t\terrorMessage: 'Offer amount must be at least 0.0001',\n\t\t};\n\t}\n\n\treturn { isValid: true };\n};\n"],"mappings":";;;;;;;;AAAA,MAAa,iBAAiB,CAC7BA,SACA,YAAY,IACZ,YAAY,MACA;AACZ,KAAI,YAAY,aAAa,GAC5B,QAAO;AAER,SAAQ,EAAE,QAAQ,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,QAAQ,UAAU,QAAQ,SAAS,UAAU,CAAC;AAC/F;AAED,MAAa,cAAc,CAACC,MAA0BC,eAAuB;AAC5E,MAAK,KAAM,QAAO;CAElB,IAAI,YAAY;AAEhB,KAAI,KAAK,UAAU,WAClB,cAAa,EAAE,KAAK,MAAM,GAAG,WAAW,CAAC;AAG1C,QAAO;AACP;AAED,MAAa,iBAAiB,CAAC,IAAI,IAAI,IAAI,OAAO;AACjD,QAAO,EAAE,aAAa,KAAK,EAAE,aAAa;AAC1C;;;;ACtBD,SAAgB,GAAG,GAAG,QAAsB;AAC3C,QAAO,QAAQ,KAAK,OAAO,CAAC;AAC5B;;;;ACcD,MAAMC,eAA4C;CACjD,UAAU;EACT,MAAM;EACN,aAAa;CACb;CACD,SAAS;EACR,MAAM;EACN,aAAa;CACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;CACb;CACD,SAAS;EACR,MAAM;EACN,aAAa;CACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;CACb;CACD,MAAM;EACL,MAAM;EACN,aAAa;CACb;CACD,MAAM;EACL,MAAM;EACN,aAAa;CACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;CACb;AACD;AAED,MAAMC,sBAEF;EACF,gBAAgB,0BAA0B;EAC1C,gBAAgB,0BAA0B;EAC1C,gBAAgB,UAAU;EAC1B,gBAAgB,UAAU;EAC1B,gBAAgB,aAAa;EAC7B,gBAAgB,OAAO;EACvB,gBAAgB,OAAO;EACvB,gBAAgB,aAAa;AAC9B;AAQD,SAAgB,sBAAsB,EACrC,YACA,MACwB,EAAE;AAC1B,KACC,SAAS,gBAAgB,2BACzB,SAAS,gBAAgB,wBAEzB,QAAO,aAAa;CAGrB,IAAI,OAAO,WAAW,aAAa;AAEnC,KAAI;AAEH,MAAI,IAAI;AAER,SAAO,cAAc,KAAK,IAAI;CAC9B,QAAO,CAAE;AAEV,QAAO,KAAK,QAAQ,MAAM,GAAG;CAE7B,MAAM,UAAU,aAAa;AAE7B,KAAI,QACH,QAAO;AAGR,KAAI,oBAAoB,MACvB,QAAO,aAAa,oBAAoB;AAEzC;AAED,SAAS,cAAcC,KAAa;CACnC,MAAM,SAAS,IAAI,QAAQ,2BAA2B,GAAG;CACzD,MAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,QAAO,MAAM,MAAM,SAAS,MAAM,MAAM;AACxC;;;;;;;;;;;;;;;;;ACxFD,MAAa,qCAAqC,CAAC,EAClD,eACA,cACA,UACwC,KAAK;CAC7C,MAAM,aAAa,OAAO,YAAY,eAAe,SAAS,CAAC;CAC/D,MAAM,YAAY,OAAO,YAAY,cAAc,SAAS,CAAC;CAC7D,MAAM,aAAa,aAAa;CAChC,MAAM,uBAAwB,aAAa,YAAa;AAExD,QAAO,qBAAqB,QAAQ,EAAE;AACtC;;;;;;;;;;;AAYD,MAAa,cAAc,CAACC,QAAgBC,aAA6B;CACxE,MAAM,iBAAiB,OAAO,YAAY,QAAQ,SAAS,CAAC;AAC5D,QAAO,eAAe,eAAe,SAAS;EAC7C,uBAAuB;EACvB,uBAAuB;CACvB,EAAC;AACF;;;;;;;;;;;;;;;;;AAkBD,MAAa,6BAA6B,CACzCD,QACAC,UACAC,SACY;AACZ,KAAI;EACH,MAAM,gBAAgB,OAAO,YAAY,QAAQ,SAAS,CAAC;EAC3D,IAAI,WAAW,GAAG,KAAK,cAAc,UAAU,EAAE,SAAS;AAE1D,OAAK,MAAM,OAAO,KACjB,KAAI,MAAM,GAAG;GACZ,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,UAAU,EAAE,SAAS;AACnE,cAAW,GAAG,SAAS,UAAU,cAAc;EAC/C;AAGF,SAAO,GAAG,OAAO,UAAU;GAC1B,QAAQ;GACR,eAAe;GACf,QAAQ;EACR,EAAC;CACF,SAAQ,OAAO;AACf,UAAQ,MAAM,0CAA0C,MAAM;AAC9D,SAAO;CACP;AACD;;;;;;;;;;;;AAaD,MAAa,qBAAqB,CACjCF,QACAC,UACAE,kBACY;AACZ,KAAI;EACH,MAAM,gBAAgB,OAAO,YAAY,QAAQ,SAAS,CAAC;EAC3D,MAAM,QAAQ,GAAG,KAAK,cAAc,UAAU,EAAE,SAAS;EACzD,MAAM,gBAAgB,GAAG,KACxB,CAAC,IAAI,gBAAgB,KAAK,UAAU,EACpC,SACA;EACD,MAAM,aAAa,GAAG,SAAS,OAAO,cAAc;AAEpD,SAAO,GAAG,OAAO,YAAY;GAC5B,QAAQ;GACR,eAAe;GACf,QAAQ;EACR,EAAC;CACF,SAAQ,OAAO;AACf,UAAQ,MAAM,oCAAoC,MAAM;AACxD,SAAO;CACP;AACD;AAED,MAAa,0BAA0B,CACtCC,gBACAH,UACA,oBAAoB,MACR;AACZ,KAAI;EACH,MAAM,aAAa,CAAC,gBAAgB,QAAS;EAC7C,IAAI,YAAY,GAAG,KAAK,WAAW;AAEnC,MAAI,oBAAoB,GAAG;GAC1B,MAAM,aAAa,GAAG,SACrB,WACA,GAAG,KAAK,CAAC,oBAAoB,KAAK,UAAU,EAAE,SAAS,CACvD;AACD,eAAY,GAAG,IAAI,WAAW,WAAW;EACzC;EAED,MAAM,kBAAkB,GAAG,OAAO,WAAW;GAC5C,QAAQ;GACR,eAAe;EACf,EAAC;EAEF,MAAM,cAAc,gBAAgB,QAAQ,MAAM,GAAG;AAErD,SAAO,OAAO,KAAK,MAAM,OAAO,YAAY,GAAG,MAAM,SAAS,CAAC;CAC/D,SAAQ,OAAO;AACf,UAAQ,MAAM,uCAAuC,MAAM;AAC3D,SAAO;CACP;AACD;;;;;;;;;;;;AAaD,MAAa,+BAA+B,CAC3CI,UACiD;AACjD,MAAK,SAAS,UAAU,IAAK,QAAO,EAAE,SAAS,KAAM;CAErD,MAAM,CAAC,GAAG,WAAW,GAAG,GAAG,MAAM,MAAM,IAAI;AAC3C,KAAI,SAAS,SAAS,EACrB,QAAO;EACN,SAAS;EACT,cAAc;CACd;AAGF,QAAO,EAAE,SAAS,KAAM;AACxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractType } from "./marketplace.gen-
|
|
1
|
+
import { ContractType$1 as ContractType } from "./marketplace.gen-906FrJQJ.js";
|
|
2
2
|
import { formatUnits } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/react/ui/components/marketplace-collectible-card/utils/formatPrice.ts
|
|
@@ -40,4 +40,4 @@ const getSupplyStatusText = ({ quantityRemaining, collectionType, unlimitedSuppl
|
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
42
|
export { OVERFLOW_PRICE, UNDERFLOW_PRICE, formatPriceNumber, getSupplyStatusText };
|
|
43
|
-
//# sourceMappingURL=utils-
|
|
43
|
+
//# sourceMappingURL=utils-B6di6O-C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-B6di6O-C.js","names":["amount: string","decimals: number"],"sources":["../src/react/ui/components/marketplace-collectible-card/utils/formatPrice.ts","../src/react/ui/components/marketplace-collectible-card/utils/supplyStatus.ts"],"sourcesContent":["import { formatUnits } from 'viem';\n\nexport const OVERFLOW_PRICE = 100000000;\nexport const UNDERFLOW_PRICE = 0.0001;\n\nexport const formatPriceNumber = (\n\tamount: string,\n\tdecimals: number,\n): {\n\tformattedNumber: string;\n\tisUnderflow: boolean;\n\tisOverflow: boolean;\n} => {\n\tconst formattedPrice = formatUnits(BigInt(amount), decimals);\n\tconst numericPrice = Number.parseFloat(formattedPrice);\n\n\tif (numericPrice < UNDERFLOW_PRICE) {\n\t\treturn {\n\t\t\tformattedNumber: UNDERFLOW_PRICE.toString(),\n\t\t\tisUnderflow: true,\n\t\t\tisOverflow: false,\n\t\t};\n\t}\n\n\tif (numericPrice > OVERFLOW_PRICE) {\n\t\treturn {\n\t\t\tformattedNumber: OVERFLOW_PRICE.toLocaleString('en-US', {\n\t\t\t\tmaximumFractionDigits: 2,\n\t\t\t}),\n\t\t\tisUnderflow: false,\n\t\t\tisOverflow: true,\n\t\t};\n\t}\n\n\tconst maxDecimals = numericPrice < 0.01 ? 6 : 4;\n\n\treturn {\n\t\tformattedNumber: numericPrice.toLocaleString('en-US', {\n\t\t\tminimumFractionDigits: 0,\n\t\t\tmaximumFractionDigits: maxDecimals,\n\t\t}),\n\t\tisUnderflow: false,\n\t\tisOverflow: false,\n\t};\n};\n","import { ContractType } from '../../../../_internal';\n\nexport const getSupplyStatusText = ({\n\tquantityRemaining,\n\tcollectionType,\n\tunlimitedSupply,\n}: {\n\tquantityRemaining: string | undefined;\n\tcollectionType: ContractType;\n\tunlimitedSupply?: boolean;\n}): string => {\n\tif (unlimitedSupply) {\n\t\treturn 'Unlimited Supply';\n\t}\n\n\tif (\n\t\tcollectionType === ContractType.ERC721 &&\n\t\tquantityRemaining === undefined\n\t) {\n\t\treturn 'Out of stock';\n\t}\n\n\tif (\n\t\tcollectionType === ContractType.ERC1155 &&\n\t\t!unlimitedSupply &&\n\t\tquantityRemaining === '0'\n\t) {\n\t\treturn 'Out of stock';\n\t}\n\n\tif (quantityRemaining && Number(quantityRemaining) > 0) {\n\t\treturn `Supply: ${quantityRemaining}`;\n\t}\n\n\treturn 'Out of stock';\n};\n"],"mappings":";;;;AAEA,MAAa,iBAAiB;AAC9B,MAAa,kBAAkB;AAE/B,MAAa,oBAAoB,CAChCA,QACAC,aAKI;CACJ,MAAM,iBAAiB,YAAY,OAAO,OAAO,EAAE,SAAS;CAC5D,MAAM,eAAe,OAAO,WAAW,eAAe;AAEtD,KAAI,eAAe,gBAClB,QAAO;EACN,iBAAiB,gBAAgB,UAAU;EAC3C,aAAa;EACb,YAAY;CACZ;AAGF,KAAI,eAAe,eAClB,QAAO;EACN,iBAAiB,eAAe,eAAe,SAAS,EACvD,uBAAuB,EACvB,EAAC;EACF,aAAa;EACb,YAAY;CACZ;CAGF,MAAM,cAAc,eAAe,MAAO,IAAI;AAE9C,QAAO;EACN,iBAAiB,aAAa,eAAe,SAAS;GACrD,uBAAuB;GACvB,uBAAuB;EACvB,EAAC;EACF,aAAa;EACb,YAAY;CACZ;AACD;;;;AC1CD,MAAa,sBAAsB,CAAC,EACnC,mBACA,gBACA,iBAKA,KAAa;AACb,KAAI,gBACH,QAAO;AAGR,KACC,mBAAmB,aAAa,UAChC,6BAEA,QAAO;AAGR,KACC,mBAAmB,aAAa,YAC/B,mBACD,sBAAsB,IAEtB,QAAO;AAGR,KAAI,qBAAqB,OAAO,kBAAkB,GAAG,EACpD,SAAQ,UAAU,kBAAkB;AAGrC,QAAO;AACP"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { currencyKeys, getQueryClient } from "./api-GwTR0dBA.js";
|
|
2
|
+
import { marketCurrenciesQueryOptions } from "./marketCurrencies-Bolonndy.js";
|
|
3
|
+
import { queryOptions } from "@tanstack/react-query";
|
|
4
|
+
import * as dn from "dnum";
|
|
5
|
+
import { formatUnits } from "viem";
|
|
6
|
+
|
|
7
|
+
//#region src/react/queries/utils/convertPriceToUSD.ts
|
|
8
|
+
/**
|
|
9
|
+
* Converts a price amount from a specific currency to USD using exchange rates
|
|
10
|
+
*/
|
|
11
|
+
async function fetchConvertPriceToUSD(params) {
|
|
12
|
+
const { chainId, currencyAddress, amountRaw, config } = params;
|
|
13
|
+
const queryClient = getQueryClient();
|
|
14
|
+
const currencies = await queryClient.fetchQuery(marketCurrenciesQueryOptions({
|
|
15
|
+
chainId,
|
|
16
|
+
config
|
|
17
|
+
}));
|
|
18
|
+
const currencyDetails = currencies.find((c) => c.contractAddress.toLowerCase() === currencyAddress.toLowerCase());
|
|
19
|
+
if (!currencyDetails) throw new Error("Currency not found");
|
|
20
|
+
const amountDecimal = Number(formatUnits(BigInt(amountRaw), currencyDetails.decimals));
|
|
21
|
+
const usdAmount = amountDecimal * currencyDetails.exchangeRate;
|
|
22
|
+
return {
|
|
23
|
+
usdAmount,
|
|
24
|
+
usdAmountFormatted: usdAmount.toFixed(2)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function getConvertPriceToUSDQueryKey(params) {
|
|
28
|
+
const apiArgs = {
|
|
29
|
+
chainId: params.chainId,
|
|
30
|
+
currencyAddress: params.currencyAddress,
|
|
31
|
+
amountRaw: params.amountRaw
|
|
32
|
+
};
|
|
33
|
+
return [
|
|
34
|
+
...currencyKeys.conversion,
|
|
35
|
+
"usd",
|
|
36
|
+
apiArgs
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function convertPriceToUSDQueryOptions(params) {
|
|
40
|
+
const enabled = Boolean(params.chainId && params.currencyAddress && params.amountRaw && params.config && (params.query?.enabled ?? true));
|
|
41
|
+
return queryOptions({
|
|
42
|
+
queryKey: getConvertPriceToUSDQueryKey(params),
|
|
43
|
+
queryFn: () => fetchConvertPriceToUSD({
|
|
44
|
+
chainId: params.chainId,
|
|
45
|
+
currencyAddress: params.currencyAddress,
|
|
46
|
+
amountRaw: params.amountRaw,
|
|
47
|
+
config: params.config
|
|
48
|
+
}),
|
|
49
|
+
...params.query,
|
|
50
|
+
enabled
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/react/queries/utils/comparePrices.ts
|
|
56
|
+
/**
|
|
57
|
+
* Compares prices between different currencies by converting both to USD
|
|
58
|
+
*/
|
|
59
|
+
async function fetchComparePrices(params) {
|
|
60
|
+
const { chainId, priceAmountRaw, priceCurrencyAddress, compareToPriceAmountRaw, compareToPriceCurrencyAddress, config } = params;
|
|
61
|
+
const [priceUSD, compareToPriceUSD] = await Promise.all([fetchConvertPriceToUSD({
|
|
62
|
+
chainId,
|
|
63
|
+
currencyAddress: priceCurrencyAddress,
|
|
64
|
+
amountRaw: priceAmountRaw,
|
|
65
|
+
config
|
|
66
|
+
}), fetchConvertPriceToUSD({
|
|
67
|
+
chainId,
|
|
68
|
+
currencyAddress: compareToPriceCurrencyAddress,
|
|
69
|
+
amountRaw: compareToPriceAmountRaw,
|
|
70
|
+
config
|
|
71
|
+
})]);
|
|
72
|
+
const difference = priceUSD.usdAmount - compareToPriceUSD.usdAmount;
|
|
73
|
+
if (compareToPriceUSD.usdAmount === 0) throw new Error("Cannot compare to zero price");
|
|
74
|
+
const percentageDifference = difference / compareToPriceUSD.usdAmount * 100;
|
|
75
|
+
const isAbove = percentageDifference > 0;
|
|
76
|
+
const isSame = percentageDifference === 0;
|
|
77
|
+
const absPercentage = Math.abs(percentageDifference);
|
|
78
|
+
const formattedPercentage = dn.format([BigInt(Math.round(absPercentage * 100)), 2], {
|
|
79
|
+
digits: 2,
|
|
80
|
+
trailingZeros: true,
|
|
81
|
+
locale: "en-US"
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
percentageDifference,
|
|
85
|
+
percentageDifferenceFormatted: formattedPercentage,
|
|
86
|
+
status: isAbove ? "above" : isSame ? "same" : "below"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function getComparePricesQueryKey(params) {
|
|
90
|
+
const apiArgs = {
|
|
91
|
+
chainId: params.chainId,
|
|
92
|
+
priceAmountRaw: params.priceAmountRaw,
|
|
93
|
+
priceCurrencyAddress: params.priceCurrencyAddress,
|
|
94
|
+
compareToPriceAmountRaw: params.compareToPriceAmountRaw,
|
|
95
|
+
compareToPriceCurrencyAddress: params.compareToPriceCurrencyAddress
|
|
96
|
+
};
|
|
97
|
+
return [
|
|
98
|
+
...currencyKeys.conversion,
|
|
99
|
+
"compare",
|
|
100
|
+
apiArgs
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
function comparePricesQueryOptions(params) {
|
|
104
|
+
const enabled = Boolean(params.chainId && params.priceAmountRaw && params.priceCurrencyAddress && params.compareToPriceAmountRaw && params.compareToPriceCurrencyAddress && params.config && (params.query?.enabled ?? true));
|
|
105
|
+
return queryOptions({
|
|
106
|
+
queryKey: getComparePricesQueryKey(params),
|
|
107
|
+
queryFn: () => fetchComparePrices({
|
|
108
|
+
chainId: params.chainId,
|
|
109
|
+
priceAmountRaw: params.priceAmountRaw,
|
|
110
|
+
priceCurrencyAddress: params.priceCurrencyAddress,
|
|
111
|
+
compareToPriceAmountRaw: params.compareToPriceAmountRaw,
|
|
112
|
+
compareToPriceCurrencyAddress: params.compareToPriceCurrencyAddress,
|
|
113
|
+
config: params.config
|
|
114
|
+
}),
|
|
115
|
+
...params.query,
|
|
116
|
+
enabled
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { comparePricesQueryOptions, convertPriceToUSDQueryOptions, fetchComparePrices, fetchConvertPriceToUSD, getComparePricesQueryKey, getConvertPriceToUSDQueryKey };
|
|
122
|
+
//# sourceMappingURL=utils-BCYTEOvy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-BCYTEOvy.js","names":["params: FetchConvertPriceToUSDParams","c: Currency","params: ConvertPriceToUSDQueryOptions","params: FetchComparePricesParams","params: ComparePricesQueryOptions"],"sources":["../src/react/queries/utils/convertPriceToUSD.ts","../src/react/queries/utils/comparePrices.ts"],"sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { type Address, formatUnits } from 'viem';\nimport type { SdkConfig } from '../../../types';\nimport {\n\ttype Currency,\n\tcurrencyKeys,\n\tgetQueryClient,\n\ttype ValuesOptional,\n} from '../../_internal';\nimport type { StandardQueryOptions } from '../../types/query';\nimport { marketCurrenciesQueryOptions } from '../market/marketCurrencies';\n\nexport interface FetchConvertPriceToUSDParams {\n\tchainId: number;\n\tcurrencyAddress: Address;\n\tamountRaw: string;\n\tconfig: SdkConfig;\n}\n\nexport interface ConvertPriceToUSDReturn {\n\tusdAmount: number;\n\tusdAmountFormatted: string;\n}\n\n/**\n * Converts a price amount from a specific currency to USD using exchange rates\n */\nexport async function fetchConvertPriceToUSD(\n\tparams: FetchConvertPriceToUSDParams,\n): Promise<ConvertPriceToUSDReturn> {\n\tconst { chainId, currencyAddress, amountRaw, config } = params;\n\n\tconst queryClient = getQueryClient();\n\tconst currencies = (await queryClient.fetchQuery(\n\t\tmarketCurrenciesQueryOptions({\n\t\t\tchainId,\n\t\t\tconfig,\n\t\t}),\n\t)) as Currency[];\n\n\tconst currencyDetails = currencies.find(\n\t\t(c: Currency) =>\n\t\t\tc.contractAddress.toLowerCase() === currencyAddress.toLowerCase(),\n\t);\n\n\tif (!currencyDetails) {\n\t\tthrow new Error('Currency not found');\n\t}\n\n\tconst amountDecimal = Number(\n\t\tformatUnits(BigInt(amountRaw), currencyDetails.decimals),\n\t);\n\tconst usdAmount = amountDecimal * currencyDetails.exchangeRate;\n\n\treturn {\n\t\tusdAmount,\n\t\tusdAmountFormatted: usdAmount.toFixed(2),\n\t};\n}\n\nexport type ConvertPriceToUSDQueryOptions =\n\tValuesOptional<FetchConvertPriceToUSDParams> & {\n\t\tquery?: StandardQueryOptions;\n\t};\n\nexport function getConvertPriceToUSDQueryKey(\n\tparams: ConvertPriceToUSDQueryOptions,\n) {\n\tconst apiArgs = {\n\t\tchainId: params.chainId!,\n\t\tcurrencyAddress: params.currencyAddress!,\n\t\tamountRaw: params.amountRaw!,\n\t};\n\n\treturn [...currencyKeys.conversion, 'usd', apiArgs] as const;\n}\n\nexport function convertPriceToUSDQueryOptions(\n\tparams: ConvertPriceToUSDQueryOptions,\n) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.currencyAddress &&\n\t\t\tparams.amountRaw &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\treturn queryOptions({\n\t\tqueryKey: getConvertPriceToUSDQueryKey(params),\n\t\tqueryFn: () =>\n\t\t\tfetchConvertPriceToUSD({\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tchainId: params.chainId!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tcurrencyAddress: params.currencyAddress!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tamountRaw: params.amountRaw!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tconfig: params.config!,\n\t\t\t}),\n\t\t...params.query,\n\t\tenabled,\n\t});\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport * as dn from 'dnum';\nimport type { Address } from 'viem';\nimport type { SdkConfig } from '../../../types';\nimport { currencyKeys, type ValuesOptional } from '../../_internal';\nimport type { StandardQueryOptions } from '../../types/query';\nimport { fetchConvertPriceToUSD } from './convertPriceToUSD';\n\nexport interface FetchComparePricesParams {\n\tchainId: number;\n\t// First price details\n\tpriceAmountRaw: string;\n\tpriceCurrencyAddress: Address;\n\t// Second price details (to compare against)\n\tcompareToPriceAmountRaw: string;\n\tcompareToPriceCurrencyAddress: Address;\n\tconfig: SdkConfig;\n}\n\nexport type ComparePricesReturn = {\n\tpercentageDifference: number;\n\tpercentageDifferenceFormatted: string;\n\tstatus: 'above' | 'same' | 'below';\n};\n\n/**\n * Compares prices between different currencies by converting both to USD\n */\nexport async function fetchComparePrices(\n\tparams: FetchComparePricesParams,\n): Promise<ComparePricesReturn> {\n\tconst {\n\t\tchainId,\n\t\tpriceAmountRaw,\n\t\tpriceCurrencyAddress,\n\t\tcompareToPriceAmountRaw,\n\t\tcompareToPriceCurrencyAddress,\n\t\tconfig,\n\t} = params;\n\n\tconst [priceUSD, compareToPriceUSD] = await Promise.all([\n\t\tfetchConvertPriceToUSD({\n\t\t\tchainId,\n\t\t\tcurrencyAddress: priceCurrencyAddress,\n\t\t\tamountRaw: priceAmountRaw,\n\t\t\tconfig,\n\t\t}),\n\t\tfetchConvertPriceToUSD({\n\t\t\tchainId,\n\t\t\tcurrencyAddress: compareToPriceCurrencyAddress,\n\t\t\tamountRaw: compareToPriceAmountRaw,\n\t\t\tconfig,\n\t\t}),\n\t]);\n\n\tconst difference = priceUSD.usdAmount - compareToPriceUSD.usdAmount;\n\n\tif (compareToPriceUSD.usdAmount === 0) {\n\t\tthrow new Error('Cannot compare to zero price');\n\t}\n\n\tconst percentageDifference = (difference / compareToPriceUSD.usdAmount) * 100;\n\tconst isAbove = percentageDifference > 0;\n\tconst isSame = percentageDifference === 0;\n\n\t// proper comma separators\n\tconst absPercentage = Math.abs(percentageDifference);\n\tconst formattedPercentage = dn.format(\n\t\t[BigInt(Math.round(absPercentage * 100)), 2],\n\t\t{\n\t\t\tdigits: 2,\n\t\t\ttrailingZeros: true,\n\t\t\tlocale: 'en-US',\n\t\t},\n\t);\n\n\treturn {\n\t\tpercentageDifference,\n\t\tpercentageDifferenceFormatted: formattedPercentage,\n\t\tstatus: isAbove ? 'above' : isSame ? 'same' : 'below',\n\t};\n}\n\nexport type ComparePricesQueryOptions =\n\tValuesOptional<FetchComparePricesParams> & {\n\t\tquery?: StandardQueryOptions;\n\t};\n\nexport function getComparePricesQueryKey(params: ComparePricesQueryOptions) {\n\tconst apiArgs = {\n\t\tchainId: params.chainId!,\n\t\tpriceAmountRaw: params.priceAmountRaw!,\n\t\tpriceCurrencyAddress: params.priceCurrencyAddress!,\n\t\tcompareToPriceAmountRaw: params.compareToPriceAmountRaw!,\n\t\tcompareToPriceCurrencyAddress: params.compareToPriceCurrencyAddress!,\n\t};\n\n\treturn [...currencyKeys.conversion, 'compare', apiArgs] as const;\n}\n\nexport function comparePricesQueryOptions(params: ComparePricesQueryOptions) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.priceAmountRaw &&\n\t\t\tparams.priceCurrencyAddress &&\n\t\t\tparams.compareToPriceAmountRaw &&\n\t\t\tparams.compareToPriceCurrencyAddress &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\treturn queryOptions({\n\t\tqueryKey: getComparePricesQueryKey(params),\n\t\tqueryFn: () =>\n\t\t\tfetchComparePrices({\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tchainId: params.chainId!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tpriceAmountRaw: params.priceAmountRaw!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tpriceCurrencyAddress: params.priceCurrencyAddress!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tcompareToPriceAmountRaw: params.compareToPriceAmountRaw!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tcompareToPriceCurrencyAddress: params.compareToPriceCurrencyAddress!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tconfig: params.config!,\n\t\t\t}),\n\t\t...params.query,\n\t\tenabled,\n\t});\n}\n"],"mappings":";;;;;;;;;;AA2BA,eAAsB,uBACrBA,QACmC;CACnC,MAAM,EAAE,SAAS,iBAAiB,WAAW,QAAQ,GAAG;CAExD,MAAM,cAAc,gBAAgB;CACpC,MAAM,aAAc,MAAM,YAAY,WACrC,6BAA6B;EAC5B;EACA;CACA,EAAC,CACF;CAED,MAAM,kBAAkB,WAAW,KAClC,CAACC,MACA,EAAE,gBAAgB,aAAa,KAAK,gBAAgB,aAAa,CAClE;AAED,MAAK,gBACJ,OAAM,IAAI,MAAM;CAGjB,MAAM,gBAAgB,OACrB,YAAY,OAAO,UAAU,EAAE,gBAAgB,SAAS,CACxD;CACD,MAAM,YAAY,gBAAgB,gBAAgB;AAElD,QAAO;EACN;EACA,oBAAoB,UAAU,QAAQ,EAAE;CACxC;AACD;AAOD,SAAgB,6BACfC,QACC;CACD,MAAM,UAAU;EACf,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,WAAW,OAAO;CAClB;AAED,QAAO;EAAC,GAAG,aAAa;EAAY;EAAO;CAAQ;AACnD;AAED,SAAgB,8BACfA,QACC;CACD,MAAM,UAAU,QACf,OAAO,WACN,OAAO,mBACP,OAAO,aACP,OAAO,WACN,OAAO,OAAO,WAAW,MAC3B;AAED,QAAO,aAAa;EACnB,UAAU,6BAA6B,OAAO;EAC9C,SAAS,MACR,uBAAuB;GAEtB,SAAS,OAAO;GAEhB,iBAAiB,OAAO;GAExB,WAAW,OAAO;GAElB,QAAQ,OAAO;EACf,EAAC;EACH,GAAG,OAAO;EACV;CACA,EAAC;AACF;;;;;;;AC5ED,eAAsB,mBACrBC,QAC+B;CAC/B,MAAM,EACL,SACA,gBACA,sBACA,yBACA,+BACA,QACA,GAAG;CAEJ,MAAM,CAAC,UAAU,kBAAkB,GAAG,MAAM,QAAQ,IAAI,CACvD,uBAAuB;EACtB;EACA,iBAAiB;EACjB,WAAW;EACX;CACA,EAAC,EACF,uBAAuB;EACtB;EACA,iBAAiB;EACjB,WAAW;EACX;CACA,EAAC,AACF,EAAC;CAEF,MAAM,aAAa,SAAS,YAAY,kBAAkB;AAE1D,KAAI,kBAAkB,cAAc,EACnC,OAAM,IAAI,MAAM;CAGjB,MAAM,uBAAwB,aAAa,kBAAkB,YAAa;CAC1E,MAAM,UAAU,uBAAuB;CACvC,MAAM,SAAS,yBAAyB;CAGxC,MAAM,gBAAgB,KAAK,IAAI,qBAAqB;CACpD,MAAM,sBAAsB,GAAG,OAC9B,CAAC,OAAO,KAAK,MAAM,gBAAgB,IAAI,CAAC,EAAE,CAAE,GAC5C;EACC,QAAQ;EACR,eAAe;EACf,QAAQ;CACR,EACD;AAED,QAAO;EACN;EACA,+BAA+B;EAC/B,QAAQ,UAAU,UAAU,SAAS,SAAS;CAC9C;AACD;AAOD,SAAgB,yBAAyBC,QAAmC;CAC3E,MAAM,UAAU;EACf,SAAS,OAAO;EAChB,gBAAgB,OAAO;EACvB,sBAAsB,OAAO;EAC7B,yBAAyB,OAAO;EAChC,+BAA+B,OAAO;CACtC;AAED,QAAO;EAAC,GAAG,aAAa;EAAY;EAAW;CAAQ;AACvD;AAED,SAAgB,0BAA0BA,QAAmC;CAC5E,MAAM,UAAU,QACf,OAAO,WACN,OAAO,kBACP,OAAO,wBACP,OAAO,2BACP,OAAO,iCACP,OAAO,WACN,OAAO,OAAO,WAAW,MAC3B;AAED,QAAO,aAAa;EACnB,UAAU,yBAAyB,OAAO;EAC1C,SAAS,MACR,mBAAmB;GAElB,SAAS,OAAO;GAEhB,gBAAgB,OAAO;GAEvB,sBAAsB,OAAO;GAE7B,yBAAyB,OAAO;GAEhC,+BAA+B,OAAO;GAEtC,QAAQ,OAAO;EACf,EAAC;EACH,GAAG,OAAO;EACV;CACA,EAAC;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getIndexerClient } from "./api-GwTR0dBA.js";
|
|
2
|
+
import { TransactionReceiptNotFoundError } from "viem";
|
|
3
|
+
|
|
4
|
+
//#region src/react/utils/waitForTransactionReceipt.ts
|
|
5
|
+
const MAX_RETRIES = 3;
|
|
6
|
+
const MAX_BLOCK_WAIT = 30;
|
|
7
|
+
const waitForTransactionReceipt = async ({ txHash, chainId, sdkConfig, maxBlockWait = MAX_BLOCK_WAIT }) => {
|
|
8
|
+
const indexer = getIndexerClient(chainId, sdkConfig);
|
|
9
|
+
let retries = 0;
|
|
10
|
+
while (retries < MAX_RETRIES) try {
|
|
11
|
+
const result = await indexer.fetchTransactionReceipt({
|
|
12
|
+
txnHash: txHash,
|
|
13
|
+
maxBlockWait
|
|
14
|
+
});
|
|
15
|
+
return result.receipt;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
retries++;
|
|
18
|
+
console.error(`Failed to fetch transaction receipt (attempt ${retries}/${MAX_RETRIES}):`, error);
|
|
19
|
+
if (retries >= MAX_RETRIES) throw TransactionReceiptNotFoundError;
|
|
20
|
+
}
|
|
21
|
+
throw TransactionReceiptNotFoundError;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { waitForTransactionReceipt };
|
|
26
|
+
//# sourceMappingURL=waitForTransactionReceipt-CbSeUSXe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt-CbSeUSXe.js","names":[],"sources":["../src/react/utils/waitForTransactionReceipt.ts"],"sourcesContent":["import type { TransactionReceipt } from '@0xsequence/indexer';\nimport { type Hex, TransactionReceiptNotFoundError } from 'viem';\nimport type { SdkConfig } from '../../types';\nimport { getIndexerClient } from '../_internal/api';\n\nconst MAX_RETRIES = 3;\nconst MAX_BLOCK_WAIT = 30;\n\nexport const waitForTransactionReceipt = async ({\n\ttxHash,\n\tchainId,\n\tsdkConfig,\n\tmaxBlockWait = MAX_BLOCK_WAIT,\n}: {\n\ttxHash: Hex;\n\tchainId: number;\n\tsdkConfig: SdkConfig;\n\tmaxBlockWait?: number;\n}): Promise<TransactionReceipt> => {\n\tconst indexer = getIndexerClient(chainId, sdkConfig);\n\tlet retries = 0;\n\n\twhile (retries < MAX_RETRIES) {\n\t\ttry {\n\t\t\tconst result = await indexer.fetchTransactionReceipt({\n\t\t\t\ttxnHash: txHash,\n\t\t\t\tmaxBlockWait,\n\t\t\t});\n\t\t\treturn result.receipt;\n\t\t} catch (error) {\n\t\t\tretries++;\n\t\t\tconsole.error(\n\t\t\t\t`Failed to fetch transaction receipt (attempt ${retries}/${MAX_RETRIES}):`,\n\t\t\t\terror,\n\t\t\t);\n\t\t\tif (retries >= MAX_RETRIES) {\n\t\t\t\tthrow TransactionReceiptNotFoundError;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow TransactionReceiptNotFoundError;\n};\n"],"mappings":";;;;AAKA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,MAAa,4BAA4B,OAAO,EAC/C,QACA,SACA,WACA,eAAe,gBAMf,KAAkC;CAClC,MAAM,UAAU,iBAAiB,SAAS,UAAU;CACpD,IAAI,UAAU;AAEd,QAAO,UAAU,YAChB,KAAI;EACH,MAAM,SAAS,MAAM,QAAQ,wBAAwB;GACpD,SAAS;GACT;EACA,EAAC;AACF,SAAO,OAAO;CACd,SAAQ,OAAO;AACf;AACA,UAAQ,OACN,+CAA+C,QAAQ,GAAG,YAAY,KACvE,MACA;AACD,MAAI,WAAW,YACd,OAAM;CAEP;AAGF,OAAM;AACN"}
|