@0xsequence/marketplace-sdk 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -3
- package/dist/{BellIcon-ByhygxBO.js → BellIcon.js} +4 -4
- package/dist/BellIcon.js.map +1 -0
- package/dist/{CartIcon-Bt3rQYGk.js → CartIcon.js} +7 -7
- package/dist/CartIcon.js.map +1 -0
- package/dist/CollectibleCard.d.ts +8 -0
- package/dist/{_internal-DkS2VUn5.js → _internal.js} +2 -2
- package/dist/_internal.js.map +1 -0
- package/dist/{abi-fa-o9gH3.js → abi.js} +2 -2
- package/dist/abi.js.map +1 -0
- package/dist/{alien_swap-DoY6XfMA.js → alien_swap.js} +1 -1
- package/dist/alien_swap.js.map +1 -0
- package/dist/{api-BoO0V5aJ.js → api.js} +13 -64
- package/dist/api.js.map +1 -0
- package/dist/{aqua-xyz-BBDxnG14.js → aqua-xyz.js} +1 -1
- package/dist/aqua-xyz.js.map +1 -0
- package/dist/{aura-DGx2zwvF.js → aura.js} +1 -1
- package/dist/aura.js.map +1 -0
- package/dist/{blur-D8GKrRrq.js → blur.js} +1 -1
- package/dist/blur.js.map +1 -0
- package/dist/{builder-api-BFuZNOaN.js → builder-api.js} +3 -3
- package/dist/builder-api.js.map +1 -0
- package/dist/{builder.gen-B9wR2nvF.js → builder.gen.js} +3 -6
- package/dist/builder.gen.js.map +1 -0
- package/dist/{coinbase-DOry4PXY.js → coinbase.js} +1 -1
- package/dist/coinbase.js.map +1 -0
- package/dist/{collectibles-C_H8jMGH.js → collectibles.js} +9 -48
- package/dist/collectibles.js.map +1 -0
- package/dist/{collections-CKummc-R.js → collections.js} +79 -8
- package/dist/collections.js.map +1 -0
- package/dist/{components-CosnX7F9.js → components.js} +12 -14
- package/dist/components.js.map +1 -0
- package/dist/{contracts-BP_0vX48.js → contracts.js} +4 -4
- package/dist/contracts.js.map +1 -0
- package/dist/{create-config-ZOB7i4ZJ.d.ts → create-config.d.ts} +47 -60
- package/dist/{create-config-CIfejoCk.js → create-config.js} +10 -13
- package/dist/create-config.js.map +1 -0
- package/dist/{element-ciybd_VF.js → element.js} +1 -1
- package/dist/element.js.map +1 -0
- package/dist/{filters-V-V8Dn8f.d.ts → filters.d.ts} +7 -7
- package/dist/{foundation-Bq4lRz4x.js → foundation.js} +1 -1
- package/dist/foundation.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +16 -16
- package/dist/{index-DUXfvhxs.d.ts → index10.d.ts} +14 -29
- package/dist/{index-CxA34wP1.d.ts → index11.d.ts} +101 -23
- package/dist/{index-BtWMBHeP.d.ts → index12.d.ts} +11 -9
- package/dist/{index-DmudgrsN.d.ts → index13.d.ts} +16 -16
- package/dist/{index-U-zp70of.d.ts → index14.d.ts} +9 -13
- package/dist/{index-Stm5u0I0.d.ts → index16.d.ts} +7 -10
- package/dist/{index-BZIJTQT0.d.ts → index17.d.ts} +9 -9
- package/dist/{index-CnEbXm_t.d.ts → index19.d.ts} +50 -12
- package/dist/{index-C-745li7.d.ts → index2.d.ts} +2 -2
- package/dist/{index-BOiHR01C.d.ts → index21.d.ts} +9 -9
- package/dist/{index-Bsx6XsC2.d.ts → index23.d.ts} +100 -59
- package/dist/{index-CPzvNmq9.d.ts → index24.d.ts} +36 -36
- package/dist/{index-DFEnA6Wa.d.ts → index25.d.ts} +18 -18
- package/dist/{index-DqXd1EeB.d.ts → index26.d.ts} +14 -7
- package/dist/{index-NlPMNcqh.d.ts → index27.d.ts} +102 -114
- package/dist/{index-DWt6yrIG.d.ts → index28.d.ts} +8 -8
- package/dist/{index-C4MUKshG.d.ts → index29.d.ts} +3 -3
- package/dist/{index-BeRV-7AX.d.ts → index3.d.ts} +2 -2
- package/dist/{index-Bxzjy0d1.d.ts → index4.d.ts} +2 -2
- package/dist/{index-DwKr18CI.d.ts → index5.d.ts} +2 -2
- package/dist/{index-D9LPlmbC.d.ts → index6.d.ts} +2 -2
- package/dist/{index-CS65jqOq.d.ts → index7.d.ts} +19 -3
- package/dist/index8.d.ts +18 -0
- package/dist/{index-CxpFwGvR.d.ts → index9.d.ts} +4 -4
- package/dist/{inventory-Dd7TazvZ.js → inventory.js} +11 -15
- package/dist/inventory.js.map +1 -0
- package/dist/{listCollectiblesPaginated-Cy2_qEZA.d.ts → listCollectiblesPaginated.d.ts} +24 -29
- package/dist/{listCollections-BB9FxKj2.d.ts → listCollections.d.ts} +170 -100
- package/dist/{looks-rare-6H--x3AM.js → looks-rare.js} +1 -1
- package/dist/looks-rare.js.map +1 -0
- package/dist/{lowestListing-Cbsi6M1K.d.ts → lowestListing.d.ts} +28 -28
- package/dist/{magic-eden-BoxEQ1Li.js → magic-eden.js} +1 -1
- package/dist/magic-eden.js.map +1 -0
- package/dist/{manifold-DycKsljb.js → manifold.js} +1 -1
- package/dist/manifold.js.map +1 -0
- package/dist/{market-C3HV-awQ.js → market.js} +7 -9
- package/dist/market.js.map +1 -0
- package/dist/{marketCurrencies-Bpw1bIO0.d.ts → marketCurrencies.d.ts} +19 -9
- package/dist/{marketCurrencies-sKrTX0og.js → marketCurrencies.js} +10 -7
- package/dist/marketCurrencies.js.map +1 -0
- package/dist/{marketplace-logos-D4dS1Foy.js → marketplace-logos.js} +23 -23
- package/dist/marketplace-logos.js.map +1 -0
- package/dist/{marketplace.gen-ksUafDqS.js → marketplace.gen.js} +25 -9
- package/dist/marketplace.gen.js.map +1 -0
- package/dist/{marketplace-NQB-sEQL.js → marketplace.js} +2 -2
- package/dist/marketplace.js.map +1 -0
- package/dist/{marketplaceConfig-UHQMM9fq.js → marketplaceConfig.js} +3 -3
- package/dist/marketplaceConfig.js.map +1 -0
- package/dist/{mintify-Dyqyo8jQ.js → mintify.js} +1 -1
- package/dist/mintify.js.map +1 -0
- package/dist/{network-DtmiMhcg.js → network.js} +3 -3
- package/dist/network.js.map +1 -0
- package/dist/{networkconfigToWagmiChain-DbUf6HiO.js → networkconfigToWagmiChain.js} +4 -3
- package/dist/networkconfigToWagmiChain.js.map +1 -0
- package/dist/{nftx-2LbFjj9Q.js → nftx.js} +1 -1
- package/dist/nftx.js.map +1 -0
- package/dist/{okx-CBEWJNsR.js → okx.js} +1 -1
- package/dist/okx.js.map +1 -0
- package/dist/{open-sea-Dxntz_PA.js → open-sea.js} +1 -1
- package/dist/open-sea.js.map +1 -0
- package/dist/{orders-DnFfZAXV.js → orders.js} +10 -10
- package/dist/orders.js.map +1 -0
- package/dist/{primary-sale-1u4QlPdA.js → primary-sale.js} +2 -2
- package/dist/primary-sale.js.map +1 -0
- package/dist/{primary-sales-Dmsi6bqj.js → primary-sales.js} +41 -3
- package/dist/primary-sales.js.map +1 -0
- package/dist/{query-BWbCsXLY.d.ts → query.d.ts} +2 -2
- package/dist/{rarible-CS0SupHr.js → rarible.js} +1 -1
- package/dist/rarible.js.map +1 -0
- package/dist/react/_internal/api/index.d.ts +2 -2
- package/dist/react/_internal/api/index.js +7 -7
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +37 -38
- package/dist/react/_internal/index.d.ts +2 -2
- package/dist/react/_internal/index.js +11 -11
- package/dist/react/_internal/wagmi/index.d.ts +1 -1
- package/dist/react/_internal/wagmi/index.js +5 -5
- package/dist/react/hooks/config/index.d.ts +8 -8
- package/dist/react/hooks/config/index.js +37 -38
- package/dist/react/hooks/contracts/index.d.ts +6 -6
- package/dist/react/hooks/contracts/index.js +15 -15
- package/dist/react/hooks/data/collectibles/index.d.ts +4 -10
- package/dist/react/hooks/data/collectibles/index.js +37 -38
- package/dist/react/hooks/data/collections/index.d.ts +11 -11
- package/dist/react/hooks/data/collections/index.js +38 -39
- package/dist/react/hooks/data/index.d.ts +37 -37
- package/dist/react/hooks/data/index.js +38 -39
- package/dist/react/hooks/data/inventory/index.d.ts +36 -36
- package/dist/react/hooks/data/inventory/index.js +37 -38
- package/dist/react/hooks/data/market/index.d.ts +5 -11
- package/dist/react/hooks/data/market/index.js +37 -38
- package/dist/react/hooks/data/orders/index.d.ts +4 -10
- package/dist/react/hooks/data/orders/index.js +37 -38
- package/dist/react/hooks/data/primary-sales/index.d.ts +37 -37
- package/dist/react/hooks/data/primary-sales/index.js +38 -39
- package/dist/react/hooks/data/tokens/index.d.ts +4 -4
- package/dist/react/hooks/data/tokens/index.js +37 -38
- package/dist/react/hooks/index.d.ts +37 -37
- package/dist/react/hooks/index.js +38 -39
- package/dist/react/hooks/transactions/index.d.ts +2 -2
- package/dist/react/hooks/transactions/index.js +37 -38
- package/dist/react/hooks/ui/index.d.ts +4 -4
- package/dist/react/hooks/ui/index.js +37 -38
- package/dist/react/hooks/utils/index.d.ts +36 -36
- package/dist/react/hooks/utils/index.js +37 -38
- package/dist/react/index.d.ts +37 -37
- package/dist/react/index.js +38 -39
- package/dist/react/queries/collectibles/index.d.ts +4 -10
- package/dist/react/queries/collectibles/index.js +20 -21
- package/dist/react/queries/collections/index.d.ts +11 -11
- package/dist/react/queries/collections/index.js +19 -19
- package/dist/react/queries/index.d.ts +24 -24
- package/dist/react/queries/index.js +30 -31
- package/dist/react/queries/inventory/index.d.ts +2 -2
- package/dist/react/queries/inventory/index.js +20 -20
- package/dist/react/queries/market/index.d.ts +5 -5
- package/dist/react/queries/market/index.js +20 -20
- package/dist/react/queries/orders/index.d.ts +4 -10
- package/dist/react/queries/orders/index.js +11 -11
- package/dist/react/queries/primary-sales/index.d.ts +4 -4
- package/dist/react/queries/primary-sales/index.js +12 -12
- package/dist/react/queries/tokens/index.d.ts +4 -4
- package/dist/react/queries/tokens/index.js +11 -12
- package/dist/react/queries/utils/index.d.ts +3 -3
- package/dist/react/queries/utils/index.js +20 -20
- package/dist/react/ssr/index.d.ts +7 -7
- package/dist/react/ssr/index.js +13 -16
- 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 +20 -20
- 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 +37 -38
- package/dist/react/ui/components/marketplace-collectible-card/index.d.ts +4 -4
- package/dist/react/ui/components/marketplace-collectible-card/index.js +37 -38
- 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 +11 -11
- 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 +14 -14
- package/dist/react/ui/index.d.ts +4 -4
- package/dist/react/ui/index.js +37 -38
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +37 -38
- package/dist/react/utils/index.d.ts +1 -1
- package/dist/react/utils/index.js +7 -7
- package/dist/{react-DE852KeT.js → react.js} +720 -926
- package/dist/react.js.map +1 -0
- package/dist/{sequence-paCCener.js → sequence.js} +1 -1
- package/dist/sequence.js.map +1 -0
- package/dist/{src-Dz2CfBL0.js → src.js} +2 -2
- package/dist/src.js.map +1 -0
- package/dist/styles/index.css +1 -1
- package/dist/{sudo-swap-9rH2EgfT.js → sudo-swap.js} +1 -1
- package/dist/sudo-swap.js.map +1 -0
- package/dist/{super-rare-DHIuWtRw.js → super-rare.js} +1 -1
- package/dist/super-rare.js.map +1 -0
- package/dist/{token-Cv7l2ZaL.js → token.js} +2 -2
- package/dist/token.js.map +1 -0
- package/dist/{tokenBalances-ibDerNmM.js → tokenBalances.js} +4 -11
- package/dist/tokenBalances.js.map +1 -0
- package/dist/{tokenSupplies-Bfe8RHzI.d.ts → tokenSupplies.d.ts} +19 -30
- package/dist/{tokens-cGxMadd8.js → tokens.js} +47 -22
- package/dist/tokens.js.map +1 -0
- package/dist/{transaction-DZUW5RHu.js → transaction.js} +2 -2
- package/dist/transaction.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +3 -3
- package/dist/{types-D2TJ1dwv.d.ts → types.d.ts} +3 -3
- package/dist/{types-B_-cnkcP.js → types.js} +2 -2
- package/dist/types.js.map +1 -0
- 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 +7 -7
- package/dist/utils/index.js +13 -13
- package/dist/{utils-BfpDVibN.js → utils.js} +42 -4
- package/dist/utils.js.map +1 -0
- package/dist/{utils-BCgNhBFR.js → utils2.js} +11 -5
- package/dist/utils2.js.map +1 -0
- package/dist/{utils-BqxcalL2.js → utils3.js} +3 -3
- package/dist/utils3.js.map +1 -0
- package/dist/{waitForTransactionReceipt-DieAnV52.js → waitForTransactionReceipt.js} +3 -3
- package/dist/waitForTransactionReceipt.js.map +1 -0
- package/dist/{x2y2-45WDooeh.js → x2y2.js} +1 -1
- package/dist/x2y2.js.map +1 -0
- package/dist/{zora-CbeBoLvQ.js → zora.js} +1 -1
- package/dist/zora.js.map +1 -0
- package/package.json +42 -42
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +13 -0
- package/src/react/_internal/api/index.ts +0 -1
- package/src/react/_internal/api/marketplace.gen.ts +70 -26
- package/src/react/_internal/api/query-keys.ts +9 -0
- package/src/react/_internal/wagmi/get-connectors.ts +12 -1
- package/src/react/hooks/data/collectibles/useBalanceOfCollectible.tsx +0 -9
- package/src/react/hooks/data/collectibles/useListCollectibles.tsx +1 -16
- package/src/react/hooks/data/collectibles/useTokenBalances.tsx +0 -9
- package/src/react/hooks/data/collections/index.ts +2 -0
- 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/inventory/useInventory.tsx +1 -10
- package/src/react/hooks/data/market/useMarketCurrencies.test.tsx +31 -2
- package/src/react/hooks/data/primary-sales/index.ts +1 -0
- package/src/react/hooks/data/primary-sales/usePrimarySaleItem.tsx +71 -0
- package/src/react/hooks/data/tokens/useListBalances.tsx +1 -10
- package/src/react/hooks/data/tokens/useTokenSupplies.ts +1 -13
- package/src/react/hooks/transactions/useGenerateOfferTransaction.test.tsx +2 -0
- package/src/react/hooks/transactions/useProcessStep.test.tsx +8 -6
- package/src/react/hooks/transactions/useProcessStep.ts +8 -6
- package/src/react/hooks/utils/useComparePrices.test.tsx +1 -1
- package/src/react/providers/modal-provider.tsx +2 -1
- package/src/react/queries/collectibles/balanceOfCollectible.ts +1 -15
- package/src/react/queries/collectibles/listCollectibles.ts +1 -54
- package/src/react/queries/collectibles/tokenBalances.ts +1 -15
- package/src/react/queries/collections/activeListingsCurrencies.ts +84 -0
- package/src/react/queries/collections/activeOffersCurrencies.ts +84 -0
- package/src/react/queries/collections/index.ts +2 -0
- package/src/react/queries/inventory/inventory.ts +2 -9
- package/src/react/queries/market/marketCurrencies.ts +8 -1
- package/src/react/queries/primary-sales/index.ts +1 -0
- package/src/react/queries/primary-sales/primarySaleItem.ts +80 -0
- package/src/react/queries/tokens/listBalances.ts +1 -21
- package/src/react/queries/tokens/tokenSupplies.ts +2 -31
- package/src/react/queries/utils/comparePrices.ts +13 -1
- package/src/react/ui/components/_internals/action-button/ActionButton.stories.tsx +2 -0
- package/src/react/ui/components/marketplace-collectible-card/components/footer/Footer.tsx +4 -18
- package/src/react/ui/components/marketplace-collectible-card/variants/MarketCard.tsx +2 -2
- package/src/react/ui/components/marketplace-collectible-card/variants/ShopCard.tsx +0 -2
- package/src/react/ui/modals/BuyModal/__tests__/BuyModalRouter.test.tsx +3 -0
- package/src/react/ui/modals/BuyModal/__tests__/ERC1155ShopModal.test.tsx +152 -141
- package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +1 -0
- package/src/react/ui/modals/BuyModal/components/ERC1155ShopModal.tsx +44 -60
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useERC1155SalePaymentParams.test.tsx +381 -0
- package/src/react/ui/modals/BuyModal/hooks/useERC1155SalePaymentParams.ts +257 -0
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +0 -23
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +22 -2
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +2 -0
- package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +2 -0
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +2 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +1 -1
- package/src/react/ui/modals/TransferModal/index.tsx +24 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +15 -12
- 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 +148 -11
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +2 -0
- package/src/styles/styles.ts +2 -2
- 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/tsdown.config.ts +1 -0
- package/.changeset/honest-peas-arrive.md +0 -5
- package/.changeset/real-tips-stick.md +0 -8
- package/.changeset/tall-pandas-wear.md +0 -8
- package/dist/BellIcon-ByhygxBO.js.map +0 -1
- package/dist/CartIcon-Bt3rQYGk.js.map +0 -1
- package/dist/CollectibleCard-CVpdgXA8.d.ts +0 -8
- package/dist/_internal-DkS2VUn5.js.map +0 -1
- package/dist/abi-fa-o9gH3.js.map +0 -1
- package/dist/alien_swap-DoY6XfMA.js.map +0 -1
- package/dist/api-BoO0V5aJ.js.map +0 -1
- package/dist/aqua-xyz-BBDxnG14.js.map +0 -1
- package/dist/aura-DGx2zwvF.js.map +0 -1
- package/dist/blur-D8GKrRrq.js.map +0 -1
- package/dist/builder-api-BFuZNOaN.js.map +0 -1
- package/dist/builder.gen-B9wR2nvF.js.map +0 -1
- package/dist/coinbase-DOry4PXY.js.map +0 -1
- package/dist/collectibles-C_H8jMGH.js.map +0 -1
- package/dist/collections-CKummc-R.js.map +0 -1
- package/dist/components-CosnX7F9.js.map +0 -1
- package/dist/contracts-BP_0vX48.js.map +0 -1
- package/dist/create-config-CIfejoCk.js.map +0 -1
- package/dist/element-ciybd_VF.js.map +0 -1
- package/dist/foundation-Bq4lRz4x.js.map +0 -1
- package/dist/index-DNNUeZEq.d.ts +0 -18
- package/dist/inventory-Dd7TazvZ.js.map +0 -1
- package/dist/listBalances-BxpxBCvn.js +0 -57
- package/dist/listBalances-BxpxBCvn.js.map +0 -1
- package/dist/looks-rare-6H--x3AM.js.map +0 -1
- package/dist/magic-eden-BoxEQ1Li.js.map +0 -1
- package/dist/manifold-DycKsljb.js.map +0 -1
- package/dist/market-C3HV-awQ.js.map +0 -1
- package/dist/marketCurrencies-sKrTX0og.js.map +0 -1
- package/dist/marketplace-NQB-sEQL.js.map +0 -1
- package/dist/marketplace-logos-D4dS1Foy.js.map +0 -1
- package/dist/marketplace.gen-ksUafDqS.js.map +0 -1
- package/dist/marketplaceConfig-UHQMM9fq.js.map +0 -1
- package/dist/mintify-Dyqyo8jQ.js.map +0 -1
- package/dist/network-DtmiMhcg.js.map +0 -1
- package/dist/networkconfigToWagmiChain-DbUf6HiO.js.map +0 -1
- package/dist/nftx-2LbFjj9Q.js.map +0 -1
- package/dist/okx-CBEWJNsR.js.map +0 -1
- package/dist/open-sea-Dxntz_PA.js.map +0 -1
- package/dist/orders-DnFfZAXV.js.map +0 -1
- package/dist/primary-sale-1u4QlPdA.js.map +0 -1
- package/dist/primary-sales-Dmsi6bqj.js.map +0 -1
- package/dist/rarible-CS0SupHr.js.map +0 -1
- package/dist/react-DE852KeT.js.map +0 -1
- package/dist/sequence-paCCener.js.map +0 -1
- package/dist/src-Dz2CfBL0.js.map +0 -1
- package/dist/sudo-swap-9rH2EgfT.js.map +0 -1
- package/dist/super-rare-DHIuWtRw.js.map +0 -1
- package/dist/token-Cv7l2ZaL.js.map +0 -1
- package/dist/tokenBalances-ibDerNmM.js.map +0 -1
- package/dist/tokens-cGxMadd8.js.map +0 -1
- package/dist/transaction-DZUW5RHu.js.map +0 -1
- package/dist/types-B_-cnkcP.js.map +0 -1
- package/dist/utils-BCgNhBFR.js.map +0 -1
- package/dist/utils-BfpDVibN.js.map +0 -1
- package/dist/utils-BqxcalL2.js.map +0 -1
- package/dist/waitForTransactionReceipt-DieAnV52.js.map +0 -1
- package/dist/x2y2-45WDooeh.js.map +0 -1
- package/dist/zora-CbeBoLvQ.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/collectibles/__tests__/balanceOfCollectible.laos.test.ts +0 -123
- package/src/react/queries/collectibles/__tests__/tokenBalances.laos.test.ts +0 -123
- package/src/react/queries/inventory/__tests__/inventory.laos.test.ts +0 -499
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useERC1155Checkout.test.tsx +0 -395
- package/src/react/ui/modals/BuyModal/hooks/useERC1155Checkout.ts +0 -103
- package/src/react/ui/modals/_internal/constants/opensea-currencies.ts +0 -481
- /package/dist/{index-6wsMChsg.d.ts → index15.d.ts} +0 -0
- /package/dist/{index-CZUtOTjh.d.ts → index18.d.ts} +0 -0
- /package/dist/{index-DW3njUfb.d.ts → index20.d.ts} +0 -0
- /package/dist/{index-DewGsFz5.d.ts → index22.d.ts} +0 -0
- /package/dist/{queries-KOcILNJO.js → queries.js} +0 -0
- /package/dist/{wagmi-Bseovd6Q.js → wagmi.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as balanceQueries, i as getMetadataClient, m as tokenKeys, n as getIndexerClient } from "./api.js";
|
|
2
2
|
import { infiniteQueryOptions, queryOptions } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
//#region src/react/queries/tokens/getTokenRanges.ts
|
|
@@ -32,6 +32,47 @@ function getTokenRangesQueryOptions(params) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/react/queries/tokens/listBalances.ts
|
|
37
|
+
async function fetchBalances(args, config, page) {
|
|
38
|
+
return getIndexerClient(args.chainId, config).getTokenBalances({
|
|
39
|
+
...args,
|
|
40
|
+
tokenID: args.tokenId,
|
|
41
|
+
page
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function getListBalancesQueryKey(args) {
|
|
45
|
+
const apiArgs = {
|
|
46
|
+
chainId: args.chainId,
|
|
47
|
+
accountAddress: args.accountAddress,
|
|
48
|
+
contractAddress: args.contractAddress,
|
|
49
|
+
tokenID: args.tokenId,
|
|
50
|
+
includeMetadata: args.includeMetadata,
|
|
51
|
+
metadataOptions: args.metadataOptions,
|
|
52
|
+
includeCollectionTokens: args.includeCollectionTokens
|
|
53
|
+
};
|
|
54
|
+
return [...balanceQueries.lists, apiArgs];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a tanstack infinite query options object for the balances query
|
|
58
|
+
*
|
|
59
|
+
* @param args - The query arguments
|
|
60
|
+
* @param config - SDK configuration
|
|
61
|
+
* @returns Query options configuration
|
|
62
|
+
*/
|
|
63
|
+
function listBalancesOptions(args, config) {
|
|
64
|
+
return infiniteQueryOptions({
|
|
65
|
+
...args.query,
|
|
66
|
+
queryKey: getListBalancesQueryKey(args),
|
|
67
|
+
queryFn: ({ pageParam }) => fetchBalances(args, config, pageParam),
|
|
68
|
+
initialPageParam: {
|
|
69
|
+
page: 1,
|
|
70
|
+
pageSize: 30
|
|
71
|
+
},
|
|
72
|
+
getNextPageParam: (lastPage) => lastPage.page.after
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
35
76
|
//#endregion
|
|
36
77
|
//#region src/react/queries/tokens/listTokenMetadata.ts
|
|
37
78
|
/**
|
|
@@ -129,24 +170,10 @@ function searchTokenMetadataQueryOptions(params) {
|
|
|
129
170
|
//#endregion
|
|
130
171
|
//#region src/react/queries/tokens/tokenSupplies.ts
|
|
131
172
|
/**
|
|
132
|
-
* Fetches token supplies with support for
|
|
133
|
-
* Uses the more efficient single-contract APIs from both services
|
|
173
|
+
* Fetches token supplies with support for indexer API
|
|
134
174
|
*/
|
|
135
175
|
async function fetchTokenSupplies(params) {
|
|
136
|
-
const { chainId, collectionAddress, config,
|
|
137
|
-
if (isLaos721) {
|
|
138
|
-
const laosApi = new LaosAPI();
|
|
139
|
-
const laosPage = rest.page ? { sort: rest.page.sort?.map((sortBy) => ({
|
|
140
|
-
column: sortBy.column,
|
|
141
|
-
order: sortBy.order
|
|
142
|
-
})) || [] } : void 0;
|
|
143
|
-
return await laosApi.getTokenSupplies({
|
|
144
|
-
chainId: chainId.toString(),
|
|
145
|
-
contractAddress: collectionAddress,
|
|
146
|
-
includeMetadata: rest.includeMetadata,
|
|
147
|
-
page: laosPage
|
|
148
|
-
});
|
|
149
|
-
}
|
|
176
|
+
const { chainId, collectionAddress, config, ...rest } = params;
|
|
150
177
|
const indexerClient = getIndexerClient(chainId, config);
|
|
151
178
|
const apiArgs = {
|
|
152
179
|
contractAddress: collectionAddress,
|
|
@@ -159,8 +186,7 @@ function getTokenSuppliesQueryKey(params) {
|
|
|
159
186
|
chainId: params.chainId,
|
|
160
187
|
contractAddress: params.collectionAddress,
|
|
161
188
|
includeMetadata: params.includeMetadata,
|
|
162
|
-
metadataOptions: params.metadataOptions
|
|
163
|
-
isLaos721: params.isLaos721
|
|
189
|
+
metadataOptions: params.metadataOptions
|
|
164
190
|
};
|
|
165
191
|
return [...tokenKeys.supplies, apiArgs];
|
|
166
192
|
}
|
|
@@ -174,7 +200,6 @@ function tokenSuppliesQueryOptions(params) {
|
|
|
174
200
|
chainId: params.chainId,
|
|
175
201
|
collectionAddress: params.collectionAddress,
|
|
176
202
|
config: params.config,
|
|
177
|
-
isLaos721: params.isLaos721,
|
|
178
203
|
includeMetadata: params.includeMetadata,
|
|
179
204
|
metadataOptions: params.metadataOptions,
|
|
180
205
|
page: pageParam
|
|
@@ -190,5 +215,5 @@ function tokenSuppliesQueryOptions(params) {
|
|
|
190
215
|
}
|
|
191
216
|
|
|
192
217
|
//#endregion
|
|
193
|
-
export {
|
|
194
|
-
//# sourceMappingURL=tokens
|
|
218
|
+
export { getSearchTokenMetadataQueryKey as a, getListTokenMetadataQueryKey as c, getListBalancesQueryKey as d, listBalancesOptions as f, getTokenRangesQueryOptions as h, fetchSearchTokenMetadata as i, listTokenMetadataQueryOptions as l, getTokenRangesQueryKey as m, getTokenSuppliesQueryKey as n, searchTokenMetadataQueryOptions as o, fetchGetTokenRanges as p, tokenSuppliesQueryOptions as r, fetchListTokenMetadata as s, fetchTokenSupplies as t, fetchBalances as u };
|
|
219
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","names":["apiArgs: GetTokenSuppliesArgs"],"sources":["../src/react/queries/tokens/getTokenRanges.ts","../src/react/queries/tokens/listBalances.ts","../src/react/queries/tokens/listTokenMetadata.ts","../src/react/queries/tokens/searchTokenMetadata.ts","../src/react/queries/tokens/tokenSupplies.ts"],"sourcesContent":["import type { GetTokenIDRangesReturn } from '@0xsequence/indexer';\nimport { queryOptions } from '@tanstack/react-query';\nimport type { Address } from 'viem';\nimport type { SdkConfig } from '../../../types';\nimport {\n\tgetIndexerClient,\n\ttokenKeys,\n\ttype ValuesOptional,\n} from '../../_internal';\nimport type { StandardQueryOptions } from '../../types/query';\n\nexport interface FetchGetTokenRangesParams {\n\tchainId: number;\n\tcollectionAddress: Address;\n\tconfig: SdkConfig;\n}\n\n/**\n * Fetches token ID ranges for a collection from the Indexer API\n */\nexport async function fetchGetTokenRanges(\n\tparams: FetchGetTokenRangesParams,\n): Promise<GetTokenIDRangesReturn> {\n\tconst { chainId, collectionAddress, config } = params;\n\n\tconst indexerClient = getIndexerClient(chainId, config);\n\n\tconst response = await indexerClient.getTokenIDRanges({\n\t\tcontractAddress: collectionAddress,\n\t});\n\n\tif (!response) {\n\t\tthrow new Error('Failed to fetch token ranges');\n\t}\n\n\treturn response;\n}\n\nexport type GetTokenRangesQueryOptions =\n\tValuesOptional<FetchGetTokenRangesParams> & {\n\t\tquery?: StandardQueryOptions;\n\t};\n\nexport function getTokenRangesQueryKey(params: GetTokenRangesQueryOptions) {\n\tconst apiArgs = {\n\t\tchainId: params.chainId!,\n\t\tcontractAddress: params.collectionAddress!,\n\t};\n\n\treturn [...tokenKeys.ranges, apiArgs] as const;\n}\n\nexport function getTokenRangesQueryOptions(params: GetTokenRangesQueryOptions) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.collectionAddress &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\treturn queryOptions({\n\t\tqueryKey: getTokenRangesQueryKey(params),\n\t\tqueryFn: () =>\n\t\t\tfetchGetTokenRanges({\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\tcollectionAddress: params.collectionAddress!,\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 type { GetTokenBalancesReturn, Page } from '@0xsequence/indexer';\nimport { infiniteQueryOptions } from '@tanstack/react-query';\nimport type { Address, Hex } from 'viem';\nimport type { SdkConfig } from '../../../types';\nimport { balanceQueries, getIndexerClient } from '../../_internal';\n\nexport type UseListBalancesArgs = {\n\tchainId: number;\n\taccountAddress?: Address;\n\tcontractAddress?: Address;\n\ttokenId?: string;\n\tincludeMetadata?: boolean;\n\tmetadataOptions?: {\n\t\tverifiedOnly?: boolean;\n\t\tunverifiedOnly?: boolean;\n\t\tincludeContracts?: Hex[];\n\t};\n\tincludeCollectionTokens?: boolean;\n\tpage?: Page;\n\t//TODO: More options\n\tquery?: {\n\t\tenabled?: boolean;\n\t};\n};\n\nexport async function fetchBalances(\n\targs: UseListBalancesArgs,\n\tconfig: SdkConfig,\n\tpage: Page,\n): Promise<GetTokenBalancesReturn> {\n\tconst indexerClient = getIndexerClient(args.chainId, config);\n\treturn indexerClient.getTokenBalances({\n\t\t...args,\n\t\ttokenID: args.tokenId,\n\t\tpage: page,\n\t});\n}\n\nexport function getListBalancesQueryKey(args: UseListBalancesArgs) {\n\tconst apiArgs = {\n\t\tchainId: args.chainId,\n\t\taccountAddress: args.accountAddress,\n\t\tcontractAddress: args.contractAddress,\n\t\ttokenID: args.tokenId,\n\t\tincludeMetadata: args.includeMetadata,\n\t\tmetadataOptions: args.metadataOptions,\n\t\tincludeCollectionTokens: args.includeCollectionTokens,\n\t};\n\n\treturn [...balanceQueries.lists, apiArgs] as const;\n}\n\n/**\n * Creates a tanstack infinite query options object for the balances query\n *\n * @param args - The query arguments\n * @param config - SDK configuration\n * @returns Query options configuration\n */\nexport function listBalancesOptions(\n\targs: UseListBalancesArgs,\n\tconfig: SdkConfig,\n) {\n\treturn infiniteQueryOptions({\n\t\t...args.query,\n\t\tqueryKey: getListBalancesQueryKey(args),\n\t\tqueryFn: ({ pageParam }) => fetchBalances(args, config, pageParam),\n\t\tinitialPageParam: { page: 1, pageSize: 30 } as Page,\n\t\tgetNextPageParam: (lastPage) => lastPage.page.after,\n\t});\n}\n","import type { GetTokenMetadataArgs } from '@0xsequence/metadata';\nimport { queryOptions } from '@tanstack/react-query';\nimport type { SdkConfig } from '../../../types';\nimport {\n\tgetMetadataClient,\n\ttype QueryKeyArgs,\n\ttokenKeys,\n\ttype ValuesOptional,\n} from '../../_internal';\nimport type { StandardQueryOptions } from '../../types/query';\n\nexport interface FetchListTokenMetadataParams {\n\tchainId: number;\n\tcontractAddress: string;\n\ttokenIds: string[];\n\tconfig: SdkConfig;\n}\n\n/**\n * Fetches token metadata from the metadata API\n */\nexport async function fetchListTokenMetadata(\n\tparams: FetchListTokenMetadataParams,\n) {\n\tconst { chainId, contractAddress, tokenIds, config } = params;\n\tconst metadataClient = getMetadataClient(config);\n\n\tconst response = await metadataClient.getTokenMetadata({\n\t\tchainID: chainId.toString(),\n\t\tcontractAddress: contractAddress,\n\t\ttokenIDs: tokenIds,\n\t});\n\n\treturn response.tokenMetadata;\n}\n\nexport type ListTokenMetadataQueryOptions =\n\tValuesOptional<FetchListTokenMetadataParams> & {\n\t\tquery?: StandardQueryOptions;\n\t};\n\nexport function getListTokenMetadataQueryKey(\n\tparams: ListTokenMetadataQueryOptions,\n) {\n\tconst apiArgs = {\n\t\tchainID: String(params.chainId),\n\t\tcontractAddress: params.contractAddress,\n\t\ttokenIDs: params.tokenIds,\n\t} satisfies QueryKeyArgs<GetTokenMetadataArgs>;\n\n\treturn [...tokenKeys.metadata, apiArgs] as const;\n}\n\nexport function listTokenMetadataQueryOptions(\n\tparams: ListTokenMetadataQueryOptions,\n) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.contractAddress &&\n\t\t\tparams.tokenIds?.length &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\treturn queryOptions({\n\t\tqueryKey: getListTokenMetadataQueryKey(params),\n\t\tqueryFn: () =>\n\t\t\tfetchListTokenMetadata({\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\tcontractAddress: params.contractAddress!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\ttokenIds: params.tokenIds!,\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 type {\n\tFilter,\n\tPage,\n\tSearchTokenMetadataArgs,\n\tSearchTokenMetadataReturn,\n} from '@0xsequence/metadata';\nimport { infiniteQueryOptions } from '@tanstack/react-query';\nimport type { SdkConfig } from '../../../types';\nimport {\n\tgetMetadataClient,\n\ttype QueryKeyArgs,\n\ttokenKeys,\n\ttype ValuesOptional,\n} from '../../_internal';\nimport type { StandardQueryOptions } from '../../types/query';\n\nexport interface FetchSearchTokenMetadataParams {\n\tchainId: number;\n\tcollectionAddress: string;\n\tfilter?: Filter;\n\tpage?: Page;\n\tconfig: SdkConfig;\n}\n\n/**\n * Fetches token metadata from the metadata API using search filters\n */\nexport async function fetchSearchTokenMetadata(\n\tparams: FetchSearchTokenMetadataParams,\n): Promise<SearchTokenMetadataReturn> {\n\tconst { chainId, collectionAddress, filter, page, config } = params;\n\tconst metadataClient = getMetadataClient(config);\n\n\tconst response = await metadataClient.searchTokenMetadata({\n\t\tchainID: chainId.toString(),\n\t\tcontractAddress: collectionAddress,\n\t\tfilter: filter ?? {},\n\t\tpage,\n\t});\n\n\treturn {\n\t\ttokenMetadata: response.tokenMetadata,\n\t\tpage: response.page,\n\t};\n}\n\nexport type SearchTokenMetadataQueryOptions =\n\tValuesOptional<FetchSearchTokenMetadataParams> & {\n\t\tquery?: StandardQueryOptions;\n\t};\n\nexport function getSearchTokenMetadataQueryKey(\n\tparams: SearchTokenMetadataQueryOptions,\n) {\n\tconst apiArgs = {\n\t\tchainID: String(params.chainId!),\n\t\tcontractAddress: params.collectionAddress!,\n\t\tfilter: params.filter,\n\t} satisfies QueryKeyArgs<Omit<SearchTokenMetadataArgs, 'page'>>;\n\n\treturn [...tokenKeys.metadata, 'search', apiArgs] as const;\n}\n\nexport function searchTokenMetadataQueryOptions(\n\tparams: SearchTokenMetadataQueryOptions,\n) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.collectionAddress &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\tconst initialPageParam = { page: 1, pageSize: 30 };\n\n\treturn infiniteQueryOptions({\n\t\tqueryKey: getSearchTokenMetadataQueryKey(params),\n\t\tqueryFn: ({ pageParam = initialPageParam }) =>\n\t\t\tfetchSearchTokenMetadata({\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\tcollectionAddress: params.collectionAddress!,\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\t\tfilter: params.filter!,\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\tpage: pageParam,\n\t\t\t}),\n\t\tinitialPageParam,\n\t\tgetNextPageParam: (lastPage) => {\n\t\t\tif (!lastPage.page?.more) return undefined;\n\t\t\treturn {\n\t\t\t\tpage: (lastPage.page.page || 1) + 1,\n\t\t\t\tpageSize: lastPage.page.pageSize || 20,\n\t\t\t};\n\t\t},\n\t\t...params.query,\n\t\tenabled,\n\t});\n}\n","import type { GetTokenSuppliesArgs, Page } from '@0xsequence/indexer';\nimport { infiniteQueryOptions } from '@tanstack/react-query';\nimport type { SdkConfig } from '../../../types';\nimport {\n\tgetIndexerClient,\n\ttokenKeys,\n\ttype ValuesOptional,\n} from '../../_internal';\nimport type { StandardInfiniteQueryOptions } from '../../types/query';\n\nexport interface FetchTokenSuppliesParams\n\textends Omit<GetTokenSuppliesArgs, 'contractAddress'> {\n\tchainId: number;\n\tcollectionAddress: string;\n\tconfig: SdkConfig;\n\tpage?: Page;\n}\n\n/**\n * Fetches token supplies with support for indexer API\n */\nexport async function fetchTokenSupplies(params: FetchTokenSuppliesParams) {\n\tconst { chainId, collectionAddress, config, ...rest } = params;\n\n\tconst indexerClient = getIndexerClient(chainId, config);\n\n\tconst apiArgs: GetTokenSuppliesArgs = {\n\t\tcontractAddress: collectionAddress,\n\t\t...rest,\n\t};\n\n\tconst result = await indexerClient.getTokenSupplies(apiArgs);\n\treturn result;\n}\n\nexport type TokenSuppliesQueryOptions =\n\tValuesOptional<FetchTokenSuppliesParams> & {\n\t\tquery?: StandardInfiniteQueryOptions;\n\t};\n\nexport function getTokenSuppliesQueryKey(params: TokenSuppliesQueryOptions) {\n\tconst apiArgs = {\n\t\tchainId: params.chainId!,\n\t\tcontractAddress: params.collectionAddress!,\n\t\tincludeMetadata: params.includeMetadata,\n\t\tmetadataOptions: params.metadataOptions,\n\t};\n\n\treturn [...tokenKeys.supplies, apiArgs] as const;\n}\n\nexport function tokenSuppliesQueryOptions(params: TokenSuppliesQueryOptions) {\n\tconst enabled = Boolean(\n\t\tparams.chainId &&\n\t\t\tparams.collectionAddress &&\n\t\t\tparams.config &&\n\t\t\t(params.query?.enabled ?? true),\n\t);\n\n\tconst initialPageParam = { page: 1, pageSize: 30 } as Page;\n\n\tconst queryFn = async ({ pageParam = initialPageParam }) =>\n\t\tfetchTokenSupplies({\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\tchainId: params.chainId!,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\tcollectionAddress: params.collectionAddress!,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: The enabled check above ensures these are not undefined\n\t\t\tconfig: params.config!,\n\t\t\tincludeMetadata: params.includeMetadata,\n\t\t\tmetadataOptions: params.metadataOptions,\n\t\t\tpage: pageParam,\n\t\t});\n\n\treturn infiniteQueryOptions({\n\t\tqueryKey: getTokenSuppliesQueryKey(params),\n\t\tqueryFn,\n\t\tinitialPageParam,\n\t\tgetNextPageParam: (lastPage) =>\n\t\t\tlastPage.page?.more ? lastPage.page : undefined,\n\t\t...params.query,\n\t\tenabled,\n\t});\n}\n"],"mappings":"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"}
|
|
@@ -72,5 +72,5 @@ var MissingConfigError = class extends TransactionError {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
|
-
export {
|
|
76
|
-
//# sourceMappingURL=transaction
|
|
75
|
+
export { TransactionExecutionError as a, BaseError as c, NoWalletConnectedError as i, InvalidContractTypeError as n, TransactionSignatureError as o, MissingConfigError as r, UserRejectedRequestError as s, ChainSwitchError as t };
|
|
76
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","names":[],"sources":["../src/utils/_internal/error/base.ts","../src/utils/_internal/error/transaction.ts"],"sourcesContent":["export type ErrorType<name extends string = 'Error'> = Error & { name: name };\n\nexport type Compute<type> = { [key in keyof type]: type[key] } & unknown;\n\ntype BaseErrorOptions = Compute<\n\t{ details?: string | undefined } | { cause: BaseError | Error }\n>;\n\nexport class BaseError extends Error {\n\tdetails: string;\n\tshortMessage: string;\n\n\tname = 'MarketplaceSdkBaseError';\n\n\tconstructor(shortMessage: string, options: BaseErrorOptions = {}) {\n\t\tsuper();\n\n\t\tconst details = 'details' in options ? options.details : '';\n\t\tthis.message = [\n\t\t\tshortMessage || 'An error occurred.',\n\t\t\t'',\n\t\t\t...(details ? [`Details: ${details}`] : []),\n\t\t].join('\\n');\n\n\t\tif ('cause' in options && options.cause) {\n\t\t\tthis.cause = options.cause;\n\t\t}\n\n\t\tthis.details = details || '';\n\t\tthis.shortMessage = shortMessage;\n\t}\n}\n","import type { Address } from 'viem';\nimport { BaseError } from './base';\n\nexport type TransactionErrorType<name extends string = 'TransactionError'> =\n\tBaseError & { name: name };\n\nexport class TransactionError extends BaseError {\n\toverride name = 'TransactionError';\n}\n\nexport class ChainSwitchError extends TransactionError {\n\toverride name = 'ChainSwitchError';\n\tconstructor(currentChainId: number, targetChainId: number) {\n\t\tsuper(\n\t\t\t`Failed to switch network from ${currentChainId} to ${targetChainId}`,\n\t\t\t{\n\t\t\t\tdetails:\n\t\t\t\t\t'The user may have rejected the network switch or there might be a network connectivity issue.',\n\t\t\t},\n\t\t);\n\t}\n}\n\nexport class ChainSwitchUserRejectedError extends TransactionError {\n\toverride name = 'ChainSwitchUserRejectedError';\n\tconstructor() {\n\t\tsuper('User rejected chain switch', {\n\t\t\tdetails: 'The user rejected the chain switch request.',\n\t\t});\n\t}\n}\n\nexport class TransactionExecutionError extends TransactionError {\n\toverride name = 'TransactionExecutionError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to execute transaction step: ${stepId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction may have been rejected or failed during execution.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class TransactionSignatureError extends TransactionError {\n\toverride name = 'TransactionSignatureError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to sign transaction step: ${stepId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The signature request may have been rejected by the user.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class NoWalletConnectedError extends TransactionError {\n\toverride name = 'NoWalletConnectedError';\n\tconstructor() {\n\t\tsuper('No wallet connected', {\n\t\t\tdetails: 'Please connect your wallet before attempting this transaction.',\n\t\t});\n\t}\n}\n\nexport class NoMarketplaceConfigError extends TransactionError {\n\toverride name = 'NoMarketplaceConfigError';\n\tconstructor() {\n\t\tsuper('Marketplace configuration not found', {\n\t\t\tdetails:\n\t\t\t\t'The marketplace configuration is missing or invalid. This could be due to an initialization error.',\n\t\t});\n\t}\n}\n\nexport class UserRejectedRequestError extends TransactionError {\n\toverride name = 'UserRejectedRequestError';\n\tconstructor() {\n\t\tsuper('User rejected the request', {\n\t\t\tdetails: 'The user cancelled or rejected the transaction request.',\n\t\t});\n\t}\n}\n\nexport class InsufficientFundsError extends TransactionError {\n\toverride name = 'InsufficientFundsError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Insufficient funds for transaction', {\n\t\t\tdetails:\n\t\t\t\t'The wallet does not have enough funds to complete this transaction.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class SignatureExecutionError extends TransactionError {\n\toverride name = 'SignatureExecutionError';\n\tconstructor(signature: string, cause?: Error) {\n\t\tsuper(`Failed to execute signature: ${signature}`, {\n\t\t\tdetails: cause?.message || 'The execution of the signature failed.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class StepExecutionError extends TransactionError {\n\toverride name = 'StepExecutionError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to execute step ${stepId})`, {\n\t\t\tdetails: cause?.message || 'The step execution failed unexpectedly.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class StepGenerationError extends TransactionError {\n\toverride name = 'StepGenerationError';\n\tconstructor(transactionType: string, cause?: Error) {\n\t\tsuper(`Failed to generate steps for ${transactionType}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message || 'Could not generate the required transaction steps.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class PaymentModalError extends TransactionError {\n\toverride name = 'PaymentModalError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Payment modal operation failed', {\n\t\t\tdetails:\n\t\t\t\tcause?.message || 'The payment modal operation was unsuccessful.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class InvalidStepError extends TransactionError {\n\toverride name = 'InvalidStepError';\n\tconstructor(stepId: string, reason: string) {\n\t\tsuper(`Invalid step configuration for ${stepId}`, {\n\t\t\tdetails: reason,\n\t\t});\n\t}\n}\n\nexport class TransactionConfirmationError extends TransactionError {\n\toverride name = 'TransactionConfirmationError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Failed to confirm transaction ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction could not be confirmed on the network.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class OrderNotFoundError extends TransactionError {\n\toverride name = 'OrderNotFoundError';\n\tconstructor(orderId: string) {\n\t\tsuper(`Order ${orderId} not found`, {\n\t\t\tdetails: 'The requested order could not be found in the marketplace.',\n\t\t});\n\t}\n}\n\nexport class MissingStepDataError extends TransactionError {\n\toverride name = 'MissingStepDataError';\n\tconstructor() {\n\t\tsuper('Step is missing required data', {\n\t\t\tdetails:\n\t\t\t\t'The transaction step is missing required \"to\" or \"signature\" data.',\n\t\t});\n\t}\n}\n\nexport class MissingSignatureDataError extends TransactionError {\n\toverride name = 'MissingSignatureDataError';\n\tconstructor() {\n\t\tsuper('Step is missing signature data', {\n\t\t\tdetails:\n\t\t\t\t'The signature step is missing required signature data configuration.',\n\t\t});\n\t}\n}\n\nexport class InvalidSignatureStepError extends TransactionError {\n\toverride name = 'InvalidSignatureStepError';\n\tconstructor(stepId: string) {\n\t\tsuper(`Invalid signature step type: ${stepId}`, {\n\t\t\tdetails: 'The signature step type is not supported.',\n\t\t});\n\t}\n}\n\nexport class MissingPostStepError extends TransactionError {\n\toverride name = 'MissingPostStepError';\n\tconstructor() {\n\t\tsuper('Missing post step configuration', {\n\t\t\tdetails:\n\t\t\t\t'The signature step is missing required post-step configuration.',\n\t\t});\n\t}\n}\n\nexport class UnexpectedStepsError extends TransactionError {\n\toverride name = 'UnexpectedStepsError';\n\tconstructor() {\n\t\tsuper('Unexpected steps found', {\n\t\t\tdetails: 'The transaction contains more steps than expected.',\n\t\t});\n\t}\n}\n\nexport class NoExecutionStepError extends TransactionError {\n\toverride name = 'NoExecutionStepError';\n\tconstructor() {\n\t\tsuper('No execution step found', {\n\t\t\tdetails: 'The transaction is missing the required execution step.',\n\t\t});\n\t}\n}\n\nexport class NoStepsFoundError extends TransactionError {\n\toverride name = 'NoStepsFoundError';\n\tconstructor() {\n\t\tsuper('No steps found', {\n\t\t\tdetails: 'The transaction contains no steps to execute.',\n\t\t});\n\t}\n}\n\nexport class UnknownTransactionTypeError extends TransactionError {\n\toverride name = 'UnknownTransactionTypeError';\n\tconstructor(type: string) {\n\t\tsuper(`Unknown transaction type: ${type}`, {\n\t\t\tdetails: 'The specified transaction type is not supported.',\n\t\t});\n\t}\n}\n\nexport class InvalidContractTypeError extends TransactionError {\n\toverride name = 'InvalidContractTypeError';\n\tconstructor(contractType: string | undefined) {\n\t\tsuper(`Invalid contract type: ${contractType}`, {\n\t\t\tdetails: 'The contract type must be either ERC721 or ERC1155.',\n\t\t});\n\t}\n}\n\nexport class CollectionNotFoundError extends TransactionError {\n\toverride name = 'CollectionNotFoundError';\n\tconstructor(collectionAddress: string) {\n\t\tsuper(`Collection not found: ${collectionAddress}`, {\n\t\t\tdetails:\n\t\t\t\t'The specified collection address could not be found in the marketplace configuration.',\n\t\t});\n\t}\n}\n\nexport class InvalidCurrencyOptionsError extends TransactionError {\n\toverride name = 'InvalidCurrencyOptionsError';\n\tconstructor(currencyOptions: Address[]) {\n\t\tsuper(`Invalid currency options: ${currencyOptions}`, {\n\t\t\tdetails:\n\t\t\t\t'The currency options must be an array of valid currency contract addresses.',\n\t\t});\n\t}\n}\n\nexport class ProjectNotFoundError extends TransactionError {\n\toverride name = 'ProjectNotFoundError';\n\tconstructor(projectId: string, url: string) {\n\t\tsuper('Project not found', {\n\t\t\tdetails: `Project id: ${projectId} not found at ${url}`,\n\t\t});\n\t}\n}\n\nexport class MarketplaceConfigFetchError extends TransactionError {\n\toverride name = 'MarketplaceConfigFetchError';\n\tconstructor(message: string) {\n\t\tsuper('Failed to fetch marketplace config', {\n\t\t\tdetails: message,\n\t\t});\n\t}\n}\n\nexport class MissingConfigError extends TransactionError {\n\toverride name = 'MissingConfigError';\n\tconstructor(configName: string) {\n\t\tsuper(`Missing required config: ${configName}`, {\n\t\t\tdetails: 'A required configuration parameter is missing.',\n\t\t});\n\t}\n}\n\nexport class TransactionValidationError extends TransactionError {\n\toverride name = 'TransactionValidationError';\n\tconstructor(reason: string) {\n\t\tsuper('Transaction validation failed', {\n\t\t\tdetails: reason,\n\t\t});\n\t}\n}\n\nexport class ChainIdUnavailableError extends TransactionError {\n\toverride name = 'ChainIdUnavailableError';\n\tconstructor() {\n\t\tsuper('Chain ID is not available', {\n\t\t\tdetails: 'Could not determine the current chain ID from the wallet.',\n\t\t});\n\t}\n}\n\nexport class TransactionReceiptError extends TransactionError {\n\toverride name = 'TransactionReceiptError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Failed to get transaction receipt for ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the transaction receipt from the network.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class PaymentModalTransactionError extends TransactionError {\n\toverride name = 'PaymentModalTransactionError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Payment modal transaction failed for ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction initiated from the payment modal failed.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class CheckoutOptionsError extends TransactionError {\n\toverride name = 'CheckoutOptionsError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Failed to get checkout options', {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the checkout options from the marketplace.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class OrdersFetchError extends TransactionError {\n\toverride name = 'OrdersFetchError';\n\tconstructor(orderId: string, cause?: Error) {\n\t\tsuper(`Failed to fetch order ${orderId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the order details from the marketplace.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class SalesContractError extends TransactionError {\n\toverride name = 'SalesContractError';\n\tconstructor(contractAddress: string, method?: string, cause?: Error) {\n\t\tsuper(`Sales contract operation failed: ${contractAddress}`, {\n\t\t\tdetails: `Failed to interact with sales contract${\n\t\t\t\tmethod ? ` on method: ${method}` : ''\n\t\t\t}. ${cause?.message || 'Contract may be paused or misconfigured.'}`,\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class QuantityValidationError extends TransactionError {\n\toverride name = 'QuantityValidationError';\n\tconstructor(provided: number, available: number, tokenId?: string) {\n\t\tsuper(`Invalid quantity: ${provided}`, {\n\t\t\tdetails: `Requested quantity (${provided}) exceeds available supply (${available})${\n\t\t\t\ttokenId ? ` for token ${tokenId}` : ''\n\t\t\t}.`,\n\t\t});\n\t}\n}\n\nexport class ShopDataValidationError extends TransactionError {\n\toverride name = 'ShopDataValidationError';\n\tconstructor(missingField: string) {\n\t\tsuper(`Invalid shop configuration: missing ${missingField}`, {\n\t\t\tdetails: `The shop is missing required field: ${missingField}. Check your marketplace configuration.`,\n\t\t});\n\t}\n}\n\nexport type TransactionErrorTypes =\n\t| ChainIdUnavailableError\n\t| TransactionReceiptError\n\t| PaymentModalTransactionError\n\t| CheckoutOptionsError\n\t| OrdersFetchError\n\t| TransactionConfirmationError\n\t| TransactionValidationError\n\t| MissingConfigError\n\t| MarketplaceConfigFetchError\n\t| ProjectNotFoundError\n\t| CollectionNotFoundError\n\t| InvalidCurrencyOptionsError\n\t| InvalidContractTypeError\n\t| UnknownTransactionTypeError\n\t| NoStepsFoundError\n\t| NoExecutionStepError\n\t| UnexpectedStepsError\n\t| MissingPostStepError\n\t| InvalidSignatureStepError\n\t| MissingSignatureDataError\n\t| MissingStepDataError\n\t| OrderNotFoundError\n\t| TransactionConfirmationError\n\t| InvalidStepError\n\t| PaymentModalError\n\t| StepGenerationError\n\t| StepExecutionError\n\t| UserRejectedRequestError\n\t| NoMarketplaceConfigError\n\t| InsufficientFundsError\n\t| ChainSwitchUserRejectedError\n\t| ChainSwitchError\n\t| TransactionSignatureError\n\t| TransactionExecutionError\n\t| NoWalletConnectedError\n\t| TransactionError\n\t| SalesContractError\n\t| QuantityValidationError\n\t| ShopDataValidationError;\n"],"mappings":";AAQA,IAAa,YAAb,cAA+B,MAAM;CACpC;CACA;CAEA,OAAO;CAEP,YAAY,cAAsB,UAA4B,EAAE,EAAE;AACjE,SAAO;EAEP,MAAM,UAAU,aAAa,UAAU,QAAQ,UAAU;AACzD,OAAK,UAAU;GACd,gBAAgB;GAChB;GACA,GAAI,UAAU,CAAC,YAAY,UAAU,GAAG,EAAE;GAC1C,CAAC,KAAK,KAAK;AAEZ,MAAI,WAAW,WAAW,QAAQ,MACjC,MAAK,QAAQ,QAAQ;AAGtB,OAAK,UAAU,WAAW;AAC1B,OAAK,eAAe;;;;;;ACvBtB,IAAa,mBAAb,cAAsC,UAAU;CAC/C,AAAS,OAAO;;AAGjB,IAAa,mBAAb,cAAsC,iBAAiB;CACtD,AAAS,OAAO;CAChB,YAAY,gBAAwB,eAAuB;AAC1D,QACC,iCAAiC,eAAe,MAAM,iBACtD,EACC,SACC,iGACD,CACD;;;AAaH,IAAa,4BAAb,cAA+C,iBAAiB;CAC/D,AAAS,OAAO;CAChB,YAAY,QAAgB,OAAe;AAC1C,QAAM,uCAAuC,UAAU;GACtD,SACC,OAAO,WACP;GACD;GACA,CAAC;;;AAIJ,IAAa,4BAAb,cAA+C,iBAAiB;CAC/D,AAAS,OAAO;CAChB,YAAY,QAAgB,OAAe;AAC1C,QAAM,oCAAoC,UAAU;GACnD,SACC,OAAO,WACP;GACD;GACA,CAAC;;;AAIJ,IAAa,yBAAb,cAA4C,iBAAiB;CAC5D,AAAS,OAAO;CAChB,cAAc;AACb,QAAM,uBAAuB,EAC5B,SAAS,kEACT,CAAC;;;AAcJ,IAAa,2BAAb,cAA8C,iBAAiB;CAC9D,AAAS,OAAO;CAChB,cAAc;AACb,QAAM,6BAA6B,EAClC,SAAS,2DACT,CAAC;;;AAkKJ,IAAa,2BAAb,cAA8C,iBAAiB;CAC9D,AAAS,OAAO;CAChB,YAAY,cAAkC;AAC7C,QAAM,0BAA0B,gBAAgB,EAC/C,SAAS,uDACT,CAAC;;;AA0CJ,IAAa,qBAAb,cAAwC,iBAAiB;CACxD,AAAS,OAAO;CAChB,YAAY,YAAoB;AAC/B,QAAM,4BAA4B,cAAc,EAC/C,SAAS,kDACT,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as Order, At as CollectibleStatus, Ci as Signature, Di as Step, Dt as CollectibleOrder, Ei as SourceKind, Et as Collectible, G as SdkConfig, H as ApiConfig, It as CollectionStatus, J as MarketCollection, K as CardType, Kt as CreateReq, Lt as ContractType, Mt as Collection, Nt as CollectionConfig, Oi as StepType, Pt as CollectionLastSynced, Ri as TokenMetadata, St as CheckoutOptionsMarketplaceOrder, Ti as SortOrder, U as Env, W as MarketplaceSdkContext, X as ShopCollection, Xi as WalletKind, Y as Price, a as CollectionFilterSettings, ba as MarketplaceWallet, bi as PropertyFilter, bt as CheckoutOptionsItem, c as MarketplaceConfig, ci as PostRequest, cn as Filter, cr as GetOrdersInput, d as MarketplaceWalletWaasSettings, ei as OrderData, f as MetadataFilterRule, ft as Activity, gi as Project, gt as AdditionalFee, i as marketplaceConfigOptions, ii as OrderbookKind, jt as CollectiblesFilter, l as MarketplaceSocials, ni as OrderSide, o as EcosystemWalletSettings, oi as Page, on as FeeBreakdown, p as ShopPage, q as CollectibleCardAction, qr as MarketplaceKind, qt as Currency, r as fetchMarketplaceConfig, ri as OrderStatus, s as MarketPage, ti as OrderFilter, tn as Domain, u as MarketplaceWalletOptions, vt as Asset, wi as SortBy, xi as PropertyType, ya as FilterCondition, yi as ProjectStatus, yt as CheckoutOptions, zi as TransactionCrypto } from "../create-config.js";
|
|
2
2
|
export { Activity, AdditionalFee, ApiConfig, Asset, CardType, CheckoutOptions, CheckoutOptionsItem, CheckoutOptionsMarketplaceOrder, Collectible, CollectibleCardAction, CollectibleOrder, CollectibleStatus, CollectiblesFilter, Collection, CollectionConfig, CollectionFilterSettings, CollectionLastSynced, CollectionStatus, ContractType, CreateReq, Currency, Domain, EcosystemWalletSettings, Env, FeeBreakdown, Filter, FilterCondition, GetOrdersInput, MarketCollection, MarketPage, MarketplaceConfig, MarketplaceKind, MarketplaceSdkContext, MarketplaceSocials, MarketplaceWallet, MarketplaceWalletOptions, MarketplaceWalletWaasSettings, MetadataFilterRule, Order, OrderData, OrderFilter, OrderSide, OrderStatus, OrderbookKind, Page, PostRequest, Price, Project, ProjectStatus, PropertyFilter, PropertyType, SdkConfig, ShopCollection, ShopPage, Signature, SortBy, SortOrder, SourceKind, Step, StepType, TokenMetadata, TransactionCrypto, WalletKind, fetchMarketplaceConfig, marketplaceConfigOptions };
|
package/dist/types/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FilterCondition } from "../builder.gen
|
|
2
|
-
import {
|
|
3
|
-
import { CollectibleCardAction } from "../types
|
|
1
|
+
import { t as FilterCondition } from "../builder.gen.js";
|
|
2
|
+
import { A as PropertyType, I as TransactionCrypto, M as SortOrder, N as SourceKind, P as StepType, S as OrderbookKind, U as WalletKind, b as OrderSide, i as CollectibleStatus, k as ProjectStatus, m as MarketplaceKind, o as CollectionStatus, s as ContractType, x as OrderStatus } from "../marketplace.gen.js";
|
|
3
|
+
import { t as CollectibleCardAction } from "../types.js";
|
|
4
4
|
|
|
5
5
|
export { CollectibleCardAction, CollectibleStatus, CollectionStatus, ContractType, FilterCondition, MarketplaceKind, OrderSide, OrderStatus, OrderbookKind, ProjectStatus, PropertyType, SortOrder, SourceKind, StepType, TransactionCrypto, WalletKind };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as Order, Dt as CollectibleOrder, K as CardType, Lt as ContractType, Ri as TokenMetadata$1, ii as OrderbookKind, q as CollectibleCardAction } from "./create-config.js";
|
|
2
2
|
import { TokenMetadata } from "@0xsequence/metadata";
|
|
3
3
|
import { Address } from "viem";
|
|
4
4
|
|
|
@@ -74,5 +74,5 @@ type NonTradableInventoryCardProps = MarketplaceCardBaseProps & NonTradableInven
|
|
|
74
74
|
};
|
|
75
75
|
type CollectibleCardProps = ShopCollectibleCardProps | MarketCollectibleCardProps | NonTradableInventoryCardProps;
|
|
76
76
|
//#endregion
|
|
77
|
-
export {
|
|
78
|
-
//# sourceMappingURL=types
|
|
77
|
+
export { MarketplaceCollectibleCardProps as a, ShopCollectibleCardProps as c, MarketplaceCardBaseProps as i, MarketCardSpecificProps as n, NonTradableInventoryCardProps as o, MarketCollectibleCardProps as r, ShopCardSpecificProps as s, CollectibleCardProps as t };
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -9,5 +9,5 @@ let CollectibleCardAction = /* @__PURE__ */ function(CollectibleCardAction$1) {
|
|
|
9
9
|
}({});
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
|
-
export { CollectibleCardAction };
|
|
13
|
-
//# sourceMappingURL=types
|
|
12
|
+
export { CollectibleCardAction as t };
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types/types.ts"],"sourcesContent":["import type { Currency } from './api-types';\nimport type { MarketplaceConfig } from './new-marketplace-types';\n\nexport * from './new-marketplace-types';\n\nexport type Price = {\n\tamountRaw: string;\n\tcurrency: Currency;\n};\n\nexport type CardType = 'market' | 'shop' | 'inventory-non-tradable';\n\nexport enum CollectibleCardAction {\n\tBUY = 'Buy',\n\tSELL = 'Sell',\n\tLIST = 'Create listing',\n\tOFFER = 'Make an offer',\n\tTRANSFER = 'Transfer',\n}\n\nexport type MarketCollection =\n\tMarketplaceConfig['market']['collections'][number];\n\nexport type ShopCollection = MarketplaceConfig['shop']['collections'][number];\n\n// export type Order = Omit<APIOrder, 'priceAmount' | 'priceAmountNet'> & {\n// \tpriceAmount: bigint;\n// \tpriceAmountNet: bigint;\n// };\n"],"mappings":";AAYA,IAAY,0EAAL;AACN;AACA;AACA;AACA;AACA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MAIN_MODULE_ABI } from "../../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as MAIN_MODULE_ABI } from "../../index3.js";
|
|
2
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../../index4.js";
|
|
3
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../../index5.js";
|
|
4
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../../index6.js";
|
|
5
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 { MAIN_MODULE_ABI } from "../../abi
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as MAIN_MODULE_ABI } from "../../abi.js";
|
|
2
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../../marketplace.js";
|
|
3
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../../primary-sale.js";
|
|
4
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../../token.js";
|
|
5
5
|
|
|
6
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 {
|
|
1
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../../../index4.js";
|
|
2
2
|
export { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../../../marketplace.js";
|
|
2
2
|
|
|
3
3
|
export { EIP2981_ABI, SequenceMarketplaceV1_ABI, SequenceMarketplaceV2_ABI };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../../../index5.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 {
|
|
1
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../../../primary-sale.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 {
|
|
1
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../../../index6.js";
|
|
2
2
|
export { ERC1155_ABI, ERC20_ABI, ERC721_ABI, SEQUENCE_1155_ITEMS_ABI };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../../../token.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 { MAIN_MODULE_ABI } from "../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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, cn, compareAddress, formatPrice, formatPriceWithFee, getMarketplaceDetails, getNetwork, getPresentableChainName, networkToWagmiChain, truncateEnd, truncateMiddle };
|
|
1
|
+
import "../create-config.js";
|
|
2
|
+
import { t as MAIN_MODULE_ABI } from "../index3.js";
|
|
3
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../index4.js";
|
|
4
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../index5.js";
|
|
5
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../index6.js";
|
|
6
|
+
import { a as formatPriceWithFee, c as getNetwork, d as cn, f as compareAddress, i as formatPrice, l as getPresentableChainName, m as truncateMiddle, n as calculatePriceDifferencePercentage, o as validateOpenseaOfferDecimals, p as truncateEnd, r as calculateTotalOfferCost, s as networkToWagmiChain, t as calculateEarningsAfterFees, u as getMarketplaceDetails } from "../index7.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
|
|
3
|
-
import "../transaction
|
|
4
|
-
import "../marketplace.gen
|
|
5
|
-
import {
|
|
6
|
-
import "../types
|
|
7
|
-
import { MAIN_MODULE_ABI } from "../abi
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import "../marketplace-logos
|
|
1
|
+
import "../builder.gen.js";
|
|
2
|
+
import { t as networkToWagmiChain } from "../networkconfigToWagmiChain.js";
|
|
3
|
+
import "../transaction.js";
|
|
4
|
+
import "../marketplace.gen.js";
|
|
5
|
+
import { n as getPresentableChainName, t as getNetwork } from "../network.js";
|
|
6
|
+
import "../types.js";
|
|
7
|
+
import { t as MAIN_MODULE_ABI } from "../abi.js";
|
|
8
|
+
import { n as SequenceMarketplaceV1_ABI, r as EIP2981_ABI, t as SequenceMarketplaceV2_ABI } from "../marketplace.js";
|
|
9
|
+
import { i as ERC721_SALE_ABI_V0, n as ERC1155_SALES_CONTRACT_ABI_V0, r as ERC721_SALE_ABI_V1, t as ERC1155_SALES_CONTRACT_ABI_V1 } from "../primary-sale.js";
|
|
10
|
+
import { i as ERC20_ABI, n as ERC1155_ABI, r as ERC721_ABI, t as SEQUENCE_1155_ITEMS_ABI } from "../token.js";
|
|
11
|
+
import { a as formatPriceWithFee, c as cn, d as truncateMiddle, i as formatPrice, l as compareAddress, n as calculatePriceDifferencePercentage, o as validateOpenseaOfferDecimals, r as calculateTotalOfferCost, s as getMarketplaceDetails, t as calculateEarningsAfterFees, u as truncateEnd } from "../utils.js";
|
|
12
|
+
import "../marketplace-logos.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, MAIN_MODULE_ABI, 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 {
|
|
1
|
+
import { m as MarketplaceKind } from "./marketplace.gen.js";
|
|
2
|
+
import { c as LooksRareLogo, d as MintifyLogo, g as SequenceLogo, i as BlurLogo, l as MagicEdenLogo, m as OpenSeaLogo, t as AlienSwapLogo, y as X2y2Logo } from "./marketplace-logos.js";
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
5
|
import * as dn from "dnum";
|
|
@@ -186,7 +186,45 @@ const formatPriceWithFee = (amount, decimals, feePercentage) => {
|
|
|
186
186
|
return "0";
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
|
+
const calculateTotalOfferCost = (offerAmountRaw, decimals, royaltyPercentage = 0) => {
|
|
190
|
+
try {
|
|
191
|
+
const dnumAmount = [offerAmountRaw, decimals];
|
|
192
|
+
let totalCost = dn.from(dnumAmount);
|
|
193
|
+
if (royaltyPercentage > 0) {
|
|
194
|
+
const royaltyFee = dn.multiply(totalCost, dn.from((royaltyPercentage / 100).toString(), decimals));
|
|
195
|
+
totalCost = dn.add(totalCost, royaltyFee);
|
|
196
|
+
}
|
|
197
|
+
const cleanAmount = dn.format(totalCost, {
|
|
198
|
+
digits: decimals,
|
|
199
|
+
trailingZeros: true
|
|
200
|
+
}).replace(/,/g, "");
|
|
201
|
+
return BigInt(Math.round(Number(cleanAmount) * 10 ** decimals));
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.error("Error calculating total offer cost:", error);
|
|
204
|
+
return offerAmountRaw;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Validates if a price value meets OpenSea's decimal constraints for offers
|
|
209
|
+
* OpenSea allows maximum 4 decimal places for offers and minimum 0.0001
|
|
210
|
+
* @param value - The price value as a string
|
|
211
|
+
* @returns Object containing validation result and error message
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const result = validateOpenseaOfferDecimals('0.12345');
|
|
215
|
+
* // Returns { isValid: false, errorMessage: "Offer amount must be at least 0.0001" }
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
const validateOpenseaOfferDecimals = (value) => {
|
|
219
|
+
if (!value || value === "0") return { isValid: true };
|
|
220
|
+
const [_, decimals = ""] = value.split(".");
|
|
221
|
+
if (decimals.length > 4) return {
|
|
222
|
+
isValid: false,
|
|
223
|
+
errorMessage: "Offer amount must be at least 0.0001"
|
|
224
|
+
};
|
|
225
|
+
return { isValid: true };
|
|
226
|
+
};
|
|
189
227
|
|
|
190
228
|
//#endregion
|
|
191
|
-
export {
|
|
192
|
-
//# sourceMappingURL=utils
|
|
229
|
+
export { formatPriceWithFee as a, cn as c, truncateMiddle as d, formatPrice as i, compareAddress as l, calculatePriceDifferencePercentage as n, validateOpenseaOfferDecimals as o, calculateTotalOfferCost as r, getMarketplaceDetails as s, calculateEarningsAfterFees as t, truncateEnd as u };
|
|
230
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["MARKETPLACES: Record<string, Marketplace>","KIND_TO_MARKETPLACE: Partial<\n\tRecord<MarketplaceKind, keyof typeof MARKETPLACES>\n>"],"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,kBACZ,SACA,YAAY,IACZ,YAAY,MACA;AACZ,KAAI,YAAY,aAAa,GAC5B,QAAO;AAER,QAAO,GAAG,QAAQ,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,QAAQ,UAAU,QAAQ,SAAS,UAAU;;AAG/F,MAAa,eAAe,MAA0B,eAAuB;AAC5E,KAAI,CAAC,KAAM,QAAO;CAElB,IAAI,YAAY;AAEhB,KAAI,KAAK,UAAU,WAClB,aAAY,GAAG,KAAK,MAAM,GAAG,WAAW,CAAC;AAG1C,QAAO;;AAGR,MAAa,kBAAkB,IAAI,IAAI,IAAI,OAAO;AACjD,QAAO,EAAE,aAAa,KAAK,EAAE,aAAa;;;;;ACrB3C,SAAgB,GAAG,GAAG,QAAsB;AAC3C,QAAO,QAAQ,KAAK,OAAO,CAAC;;;;;ACe7B,MAAMA,eAA4C;CACjD,UAAU;EACT,MAAM;EACN,aAAa;EACb;CACD,SAAS;EACR,MAAM;EACN,aAAa;EACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;EACb;CACD,SAAS;EACR,MAAM;EACN,aAAa;EACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;EACb;CACD,MAAM;EACL,MAAM;EACN,aAAa;EACb;CACD,MAAM;EACL,MAAM;EACN,aAAa;EACb;CACD,WAAW;EACV,MAAM;EACN,aAAa;EACb;CACD;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;CAC9B;AAQD,SAAgB,sBAAsB,EACrC,YACA,QAC0B;AAC1B,KACC,SAAS,gBAAgB,2BACzB,SAAS,gBAAgB,wBAEzB,QAAO,aAAa;CAGrB,IAAI,OAAO,WAAW,aAAa;AAEnC,KAAI;AAEH,MAAI,IAAI,KAAK;AAEb,SAAO,cAAc,KAAK,IAAI;SACvB;AAER,QAAO,KAAK,QAAQ,MAAM,GAAG;CAE7B,MAAM,UAAU,aAAa;AAE7B,KAAI,QACH,QAAO;AAGR,KAAI,oBAAoB,MACvB,QAAO,aAAa,oBAAoB;;AAI1C,SAAS,cAAc,KAAa;CAEnC,MAAM,QADS,IAAI,QAAQ,2BAA2B,GAAG,CACpC,MAAM,IAAI;AAC/B,QAAO,MAAM,MAAM,SAAS,MAAM,MAAM;;;;;;;;;;;;;;;;;;ACvFzC,MAAa,sCAAsC,EAClD,eACA,cACA,eAC6C;CAC7C,MAAM,aAAa,OAAO,YAAY,eAAe,SAAS,CAAC;CAC/D,MAAM,YAAY,OAAO,YAAY,cAAc,SAAS,CAAC;AAI7D,UAHmB,aAAa,aACW,YAAa,KAE5B,QAAQ,EAAE;;;;;;;;;;;;AAavC,MAAa,eAAe,QAAgB,aAA6B;AAExE,QADuB,OAAO,YAAY,QAAQ,SAAS,CAAC,CACtC,eAAe,SAAS;EAC7C,uBAAuB;EACvB,uBAAuB;EACvB,CAAC;;;;;;;;;;;;;;;;;;AAmBH,MAAa,8BACZ,QACA,UACA,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,MAAM,IAAI,MAAM,KAAK,UAAU,EAAE,SAAS;AACnE,cAAW,GAAG,SAAS,UAAU,cAAc;;AAIjD,SAAO,GAAG,OAAO,UAAU;GAC1B,QAAQ;GACR,eAAe;GACf,QAAQ;GACR,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,0CAA0C,MAAM;AAC9D,SAAO;;;;;;;;;;;;;;AAeT,MAAa,sBACZ,QACA,UACA,kBACY;AACZ,KAAI;EACH,MAAM,gBAAgB,OAAO,YAAY,QAAQ,SAAS,CAAC;EAC3D,MAAM,QAAQ,GAAG,KAAK,cAAc,UAAU,EAAE,SAAS;EACzD,MAAM,gBAAgB,GAAG,MACvB,IAAI,gBAAgB,KAAK,UAAU,EACpC,SACA;EACD,MAAM,aAAa,GAAG,SAAS,OAAO,cAAc;AAEpD,SAAO,GAAG,OAAO,YAAY;GAC5B,QAAQ;GACR,eAAe;GACf,QAAQ;GACR,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,oCAAoC,MAAM;AACxD,SAAO;;;AAIT,MAAa,2BACZ,gBACA,UACA,oBAAoB,MACR;AACZ,KAAI;EACH,MAAM,aAAa,CAAC,gBAAgB,SAAS;EAC7C,IAAI,YAAY,GAAG,KAAK,WAAW;AAEnC,MAAI,oBAAoB,GAAG;GAC1B,MAAM,aAAa,GAAG,SACrB,WACA,GAAG,MAAM,oBAAoB,KAAK,UAAU,EAAE,SAAS,CACvD;AACD,eAAY,GAAG,IAAI,WAAW,WAAW;;EAQ1C,MAAM,cALkB,GAAG,OAAO,WAAW;GAC5C,QAAQ;GACR,eAAe;GACf,CAAC,CAEkC,QAAQ,MAAM,GAAG;AAErD,SAAO,OAAO,KAAK,MAAM,OAAO,YAAY,GAAG,MAAM,SAAS,CAAC;UACvD,OAAO;AACf,UAAQ,MAAM,uCAAuC,MAAM;AAC3D,SAAO;;;;;;;;;;;;;;AAeT,MAAa,gCACZ,UACiD;AACjD,KAAI,CAAC,SAAS,UAAU,IAAK,QAAO,EAAE,SAAS,MAAM;CAErD,MAAM,CAAC,GAAG,WAAW,MAAM,MAAM,MAAM,IAAI;AAC3C,KAAI,SAAS,SAAS,EACrB,QAAO;EACN,SAAS;EACT,cAAc;EACd;AAGF,QAAO,EAAE,SAAS,MAAM"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { marketCurrenciesQueryOptions } from "./marketCurrencies
|
|
1
|
+
import { _ as getQueryClient, p as currencyKeys } from "./api.js";
|
|
2
|
+
import { r as marketCurrenciesQueryOptions } from "./marketCurrencies.js";
|
|
3
3
|
import { queryOptions } from "@tanstack/react-query";
|
|
4
|
+
import * as dn from "dnum";
|
|
4
5
|
import { formatUnits } from "viem";
|
|
5
6
|
|
|
6
7
|
//#region src/react/queries/utils/convertPriceToUSD.ts
|
|
@@ -70,9 +71,14 @@ async function fetchComparePrices(params) {
|
|
|
70
71
|
const percentageDifference = difference / compareToPriceUSD.usdAmount * 100;
|
|
71
72
|
const isAbove = percentageDifference > 0;
|
|
72
73
|
const isSame = percentageDifference === 0;
|
|
74
|
+
const absPercentage = Math.abs(percentageDifference);
|
|
73
75
|
return {
|
|
74
76
|
percentageDifference,
|
|
75
|
-
percentageDifferenceFormatted:
|
|
77
|
+
percentageDifferenceFormatted: dn.format([BigInt(Math.round(absPercentage * 100)), 2], {
|
|
78
|
+
digits: 2,
|
|
79
|
+
trailingZeros: true,
|
|
80
|
+
locale: "en-US"
|
|
81
|
+
}),
|
|
76
82
|
status: isAbove ? "above" : isSame ? "same" : "below"
|
|
77
83
|
};
|
|
78
84
|
}
|
|
@@ -108,5 +114,5 @@ function comparePricesQueryOptions(params) {
|
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
//#endregion
|
|
111
|
-
export {
|
|
112
|
-
//# sourceMappingURL=
|
|
117
|
+
export { fetchConvertPriceToUSD as a, convertPriceToUSDQueryOptions as i, fetchComparePrices as n, getConvertPriceToUSDQueryKey as o, getComparePricesQueryKey as r, comparePricesQueryOptions as t };
|
|
118
|
+
//# sourceMappingURL=utils2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils2.js","names":[],"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,uBACrB,QACmC;CACnC,MAAM,EAAE,SAAS,iBAAiB,WAAW,WAAW;CAUxD,MAAM,mBAPc,MADA,gBAAgB,CACE,WACrC,6BAA6B;EAC5B;EACA;EACA,CAAC,CACF,EAEkC,MACjC,MACA,EAAE,gBAAgB,aAAa,KAAK,gBAAgB,aAAa,CAClE;AAED,KAAI,CAAC,gBACJ,OAAM,IAAI,MAAM,qBAAqB;CAMtC,MAAM,YAHgB,OACrB,YAAY,OAAO,UAAU,EAAE,gBAAgB,SAAS,CACxD,GACiC,gBAAgB;AAElD,QAAO;EACN;EACA,oBAAoB,UAAU,QAAQ,EAAE;EACxC;;AAQF,SAAgB,6BACf,QACC;CACD,MAAM,UAAU;EACf,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,WAAW,OAAO;EAClB;AAED,QAAO;EAAC,GAAG,aAAa;EAAY;EAAO;EAAQ;;AAGpD,SAAgB,8BACf,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,eACC,uBAAuB;GAEtB,SAAS,OAAO;GAEhB,iBAAiB,OAAO;GAExB,WAAW,OAAO;GAElB,QAAQ,OAAO;GACf,CAAC;EACH,GAAG,OAAO;EACV;EACA,CAAC;;;;;;;;AC3EH,eAAsB,mBACrB,QAC+B;CAC/B,MAAM,EACL,SACA,gBACA,sBACA,yBACA,+BACA,WACG;CAEJ,MAAM,CAAC,UAAU,qBAAqB,MAAM,QAAQ,IAAI,CACvD,uBAAuB;EACtB;EACA,iBAAiB;EACjB,WAAW;EACX;EACA,CAAC,EACF,uBAAuB;EACtB;EACA,iBAAiB;EACjB,WAAW;EACX;EACA,CAAC,CACF,CAAC;CAEF,MAAM,aAAa,SAAS,YAAY,kBAAkB;AAE1D,KAAI,kBAAkB,cAAc,EACnC,OAAM,IAAI,MAAM,+BAA+B;CAGhD,MAAM,uBAAwB,aAAa,kBAAkB,YAAa;CAC1E,MAAM,UAAU,uBAAuB;CACvC,MAAM,SAAS,yBAAyB;CAGxC,MAAM,gBAAgB,KAAK,IAAI,qBAAqB;AAUpD,QAAO;EACN;EACA,+BAX2B,GAAG,OAC9B,CAAC,OAAO,KAAK,MAAM,gBAAgB,IAAI,CAAC,EAAE,EAAE,EAC5C;GACC,QAAQ;GACR,eAAe;GACf,QAAQ;GACR,CACD;EAKA,QAAQ,UAAU,UAAU,SAAS,SAAS;EAC9C;;AAQF,SAAgB,yBAAyB,QAAmC;CAC3E,MAAM,UAAU;EACf,SAAS,OAAO;EAChB,gBAAgB,OAAO;EACvB,sBAAsB,OAAO;EAC7B,yBAAyB,OAAO;EAChC,+BAA+B,OAAO;EACtC;AAED,QAAO;EAAC,GAAG,aAAa;EAAY;EAAW;EAAQ;;AAGxD,SAAgB,0BAA0B,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,eACC,mBAAmB;GAElB,SAAS,OAAO;GAEhB,gBAAgB,OAAO;GAEvB,sBAAsB,OAAO;GAE7B,yBAAyB,OAAO;GAEhC,+BAA+B,OAAO;GAEtC,QAAQ,OAAO;GACf,CAAC;EACH,GAAG,OAAO;EACV;EACA,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractType } from "./marketplace.gen
|
|
1
|
+
import { s as ContractType } from "./marketplace.gen.js";
|
|
2
2
|
import { formatUnits } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/react/ui/components/marketplace-collectible-card/utils/formatPrice.ts
|
|
@@ -39,5 +39,5 @@ const getSupplyStatusText = ({ quantityRemaining, collectionType, unlimitedSuppl
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
|
-
export { OVERFLOW_PRICE, UNDERFLOW_PRICE
|
|
43
|
-
//# sourceMappingURL=
|
|
42
|
+
export { formatPriceNumber as i, OVERFLOW_PRICE as n, UNDERFLOW_PRICE as r, getSupplyStatusText as t };
|
|
43
|
+
//# sourceMappingURL=utils3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils3.js","names":[],"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,qBACZ,QACA,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;EACZ;AAGF,KAAI,eAAe,eAClB,QAAO;EACN,iBAAiB,eAAe,eAAe,SAAS,EACvD,uBAAuB,GACvB,CAAC;EACF,aAAa;EACb,YAAY;EACZ;CAGF,MAAM,cAAc,eAAe,MAAO,IAAI;AAE9C,QAAO;EACN,iBAAiB,aAAa,eAAe,SAAS;GACrD,uBAAuB;GACvB,uBAAuB;GACvB,CAAC;EACF,aAAa;EACb,YAAY;EACZ;;;;;ACzCF,MAAa,uBAAuB,EACnC,mBACA,gBACA,sBAKa;AACb,KAAI,gBACH,QAAO;AAGR,KACC,mBAAmB,aAAa,UAChC,sBAAsB,OAEtB,QAAO;AAGR,KACC,mBAAmB,aAAa,WAChC,CAAC,mBACD,sBAAsB,IAEtB,QAAO;AAGR,KAAI,qBAAqB,OAAO,kBAAkB,GAAG,EACpD,QAAO,WAAW;AAGnB,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIndexerClient } from "./api
|
|
1
|
+
import { n as getIndexerClient } from "./api.js";
|
|
2
2
|
import { TransactionReceiptNotFoundError } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/react/utils/waitForTransactionReceipt.ts
|
|
@@ -21,5 +21,5 @@ const waitForTransactionReceipt = async ({ txHash, chainId, sdkConfig, maxBlockW
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
export { waitForTransactionReceipt };
|
|
25
|
-
//# sourceMappingURL=waitForTransactionReceipt
|
|
24
|
+
export { waitForTransactionReceipt as t };
|
|
25
|
+
//# sourceMappingURL=waitForTransactionReceipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.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,qBAMmB;CAClC,MAAM,UAAU,iBAAiB,SAAS,UAAU;CACpD,IAAI,UAAU;AAEd,QAAO,UAAU,YAChB,KAAI;AAKH,UAJe,MAAM,QAAQ,wBAAwB;GACpD,SAAS;GACT;GACA,CAAC,EACY;UACN,OAAO;AACf;AACA,UAAQ,MACP,gDAAgD,QAAQ,GAAG,YAAY,KACvE,MACA;AACD,MAAI,WAAW,YACd,OAAM;;AAKT,OAAM"}
|