@0xsequence/marketplace-sdk 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.changeset/seven-doors-taste.md +5 -0
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-MPBN3E54.js → chunk-2VHHJNXY.js} +3 -3
- package/dist/{chunk-FBUMNJQ4.js → chunk-3II5GLHE.js} +2 -2
- package/dist/chunk-3JU7SQVE.js +182 -0
- package/dist/chunk-3JU7SQVE.js.map +1 -0
- package/dist/{chunk-XTGMMNV5.js → chunk-A5ACY5YV.js} +2 -2
- package/dist/chunk-ABSYNRT5.js +128 -0
- package/dist/chunk-ABSYNRT5.js.map +1 -0
- package/dist/{chunk-XNA64MZQ.js → chunk-BCO4CYE4.js} +2 -2
- package/dist/{chunk-HTFORA4Q.js → chunk-BN36GABQ.js} +1883 -1010
- package/dist/chunk-BN36GABQ.js.map +1 -0
- package/dist/{chunk-4XK7XNJ7.js → chunk-BNAUZXPV.js} +73 -2
- package/dist/chunk-BNAUZXPV.js.map +1 -0
- package/dist/{chunk-Q5URKSC4.js → chunk-FMEEJFAF.js} +1 -1
- package/dist/{chunk-BBASZVT3.js → chunk-GBQVYNCD.js} +5 -6
- package/dist/chunk-GBQVYNCD.js.map +1 -0
- package/dist/{chunk-3AKOPSON.js → chunk-IZ44XPBH.js} +2 -9
- package/dist/chunk-IZ44XPBH.js.map +1 -0
- package/dist/{chunk-EAJ5K7QV.js → chunk-Q5RKAMYF.js} +3 -4
- package/dist/chunk-Q5RKAMYF.js.map +1 -0
- package/dist/{chunk-RBEPPVLT.js → chunk-X3QNSQER.js} +145 -355
- package/dist/chunk-X3QNSQER.js.map +1 -0
- package/dist/{index-CzTANLaA.d.ts → index-CnaFSNE9.d.ts} +6 -7
- package/dist/index.css +113 -31
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +4 -4
- package/dist/listCollectibles-B0tbqnRd.d.ts +155 -0
- package/dist/react/_internal/api/index.d.ts +28 -2
- package/dist/react/_internal/api/index.js +3 -1
- package/dist/react/_internal/databeat/index.js +10 -9
- package/dist/react/_internal/index.d.ts +2 -3
- package/dist/react/_internal/index.js +4 -4
- package/dist/react/_internal/wagmi/index.js +2 -2
- package/dist/react/hooks/index.d.ts +259 -674
- package/dist/react/hooks/index.js +11 -20
- package/dist/react/hooks/options/index.d.ts +1 -2
- package/dist/react/hooks/options/index.js +4 -4
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +15 -24
- package/dist/react/queries/index.d.ts +25 -0
- package/dist/react/queries/index.js +48 -0
- package/dist/react/queries/index.js.map +1 -0
- package/dist/react/ssr/index.js +3 -3
- package/dist/react/ui/components/collectible-card/index.d.ts +1 -6
- package/dist/react/ui/components/collectible-card/index.js +13 -12
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +6 -6
- package/dist/react/ui/index.d.ts +18 -22
- package/dist/react/ui/index.js +13 -12
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +6 -11
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +10 -9
- package/dist/types/index.js +2 -2
- package/dist/{types-Ct1uCT3M.d.ts → types-o_pKUpQG.d.ts} +2 -5
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/index.js +4 -4
- package/package.json +22 -16
- package/src/react/_internal/api/__mocks__/indexer.msw.ts +3 -1
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +1 -1
- package/src/react/_internal/api/__mocks__/metadata.msw.ts +14 -12
- package/src/react/_internal/api/index.ts +1 -0
- package/src/react/_internal/api/laos-api.ts +103 -0
- package/src/react/_internal/api/zod-schema.ts +3 -3
- package/src/react/_internal/types.ts +1 -10
- package/src/react/_internal/wallet/__tests__/wallet.test.ts +43 -0
- package/src/react/_internal/wallet/useWallet.ts +6 -3
- package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCancelOrder.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCollectible.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCollection.test.tsx +2 -2
- package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -1
- package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useCurrencies.test.tsx +2 -2
- package/src/react/hooks/__tests__/useCurrency.test.tsx +2 -2
- package/src/react/hooks/__tests__/useFilters.test.tsx +2 -2
- package/src/react/hooks/__tests__/useFloorOrder.test.tsx +2 -2
- package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -2
- package/src/react/hooks/__tests__/useListCollectibles.test.tsx +3 -2
- package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +1 -1
- package/src/react/hooks/__tests__/useLowestListing.test.tsx +1 -1
- package/src/react/hooks/__tests__/useRoyalty.test.tsx +1 -2
- package/src/react/hooks/index.ts +0 -1
- package/src/react/hooks/options/collectionOptions.ts +2 -3
- package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -1
- package/src/react/hooks/useCancelOrder.tsx +3 -3
- package/src/react/hooks/useCancelTransactionSteps.tsx +1 -1
- package/src/react/hooks/useCheckoutOptions.tsx +1 -2
- package/src/react/hooks/useCollectible.tsx +2 -3
- package/src/react/hooks/useCollectionBalanceDetails.tsx +1 -2
- package/src/react/hooks/useComparePrices.tsx +2 -9
- package/src/react/hooks/useConvertPriceToUSD.tsx +1 -4
- package/src/react/hooks/useCountListingsForCollectible.tsx +1 -2
- package/src/react/hooks/useCountOfCollectables.tsx +1 -2
- package/src/react/hooks/useCountOffersForCollectible.tsx +1 -2
- package/src/react/hooks/useCurrencies.tsx +1 -4
- package/src/react/hooks/useCurrency.tsx +3 -8
- package/src/react/hooks/useFilters.tsx +5 -4
- package/src/react/hooks/useFloorOrder.tsx +1 -2
- package/src/react/hooks/useGenerateCancelTransaction.tsx +3 -6
- package/src/react/hooks/useGenerateListingTransaction.tsx +2 -3
- package/src/react/hooks/useGenerateOfferTransaction.tsx +2 -3
- package/src/react/hooks/useGenerateSellTransaction.tsx +3 -6
- package/src/react/hooks/useHighestOffer.tsx +1 -1
- package/src/react/hooks/useListCollectibles.tsx +33 -61
- package/src/react/hooks/useListCollectiblesPaginated.tsx +2 -6
- package/src/react/hooks/useListListingsForCollectible.tsx +1 -2
- package/src/react/hooks/useListOffersForCollectible.tsx +1 -2
- package/src/react/hooks/useLowestListing.tsx +1 -2
- package/src/react/hooks/useRoyalty.tsx +3 -8
- package/src/react/hooks/useTransferTokens.tsx +2 -2
- package/src/react/queries/balanceOfCollectible.ts +9 -32
- package/src/react/queries/getTokenSupplies.ts +38 -0
- package/src/react/queries/index.ts +5 -0
- package/src/react/queries/listCollectibles.ts +96 -0
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
- package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +1 -1
- package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -3
- package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +1 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -3
- package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +1 -1
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +127 -0
- package/src/react/ui/modals/BuyModal/Modal.tsx +70 -85
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +85 -226
- package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +140 -0
- package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +67 -76
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +1 -60
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +1 -1
- package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +29 -13
- package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +26 -21
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +200 -0
- package/src/react/ui/modals/BuyModal/index.tsx +4 -14
- package/src/react/ui/modals/BuyModal/store.ts +71 -76
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +71 -7
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +2 -2
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +1 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +9 -5
- package/src/react/ui/modals/CreateListingModal/store.ts +7 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +103 -6
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +8 -4
- package/src/react/ui/modals/MakeOfferModal/store.ts +5 -3
- package/src/react/ui/modals/SellModal/Modal.tsx +76 -4
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +16 -8
- package/src/react/ui/modals/SellModal/store.ts +5 -3
- package/src/react/ui/modals/TransferModal/_store.ts +15 -3
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +58 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx +56 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +50 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +94 -66
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +22 -14
- package/src/react/ui/modals/TransferModal/index.tsx +72 -38
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +43 -42
- package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +9 -1
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +27 -12
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -1
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +19 -3
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx +60 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx +30 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +126 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts +25 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +74 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +1 -2
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -2
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +4 -7
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +6 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +2 -2
- package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +10 -31
- package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +53 -0
- package/src/react/ui/modals/_internal/types.ts +2 -1
- package/src/types/waas-types.ts +38 -0
- package/src/utils/network.ts +2 -4
- package/test/const.ts +1 -1
- package/test/setup.ts +10 -0
- package/test/test-utils.tsx +31 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-3AKOPSON.js.map +0 -1
- package/dist/chunk-4XK7XNJ7.js.map +0 -1
- package/dist/chunk-BBASZVT3.js.map +0 -1
- package/dist/chunk-EAJ5K7QV.js.map +0 -1
- package/dist/chunk-HTFORA4Q.js.map +0 -1
- package/dist/chunk-OFY7OFTL.js +0 -458
- package/dist/chunk-OFY7OFTL.js.map +0 -1
- package/dist/chunk-RBEPPVLT.js.map +0 -1
- package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +0 -172
- package/src/react/hooks/useGenerateBuyTransaction.tsx +0 -80
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +0 -349
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +0 -185
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +0 -170
- package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +0 -47
- package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +0 -140
- package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +0 -162
- package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +0 -327
- package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/index.tsx +0 -124
- package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/store.ts +0 -12
- /package/dist/{chunk-MPBN3E54.js.map → chunk-2VHHJNXY.js.map} +0 -0
- /package/dist/{chunk-FBUMNJQ4.js.map → chunk-3II5GLHE.js.map} +0 -0
- /package/dist/{chunk-XTGMMNV5.js.map → chunk-A5ACY5YV.js.map} +0 -0
- /package/dist/{chunk-XNA64MZQ.js.map → chunk-BCO4CYE4.js.map} +0 -0
- /package/dist/{chunk-Q5URKSC4.js.map → chunk-FMEEJFAF.js.map} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
+
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
+
|
|
7
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "public",
|
|
8
|
+
"baseBranch": "master",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": ["sequence-marketplace-sdk-playground-next"]
|
|
11
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
iconVariants
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BCO4CYE4.js";
|
|
6
6
|
import {
|
|
7
7
|
cn
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Q5RKAMYF.js";
|
|
9
9
|
|
|
10
10
|
// src/react/ui/icons/CalendarIcon.tsx
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -151,4 +151,4 @@ export {
|
|
|
151
151
|
CartIcon_default,
|
|
152
152
|
BellIcon_default
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-2VHHJNXY.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ProjectNotFoundError2 as ProjectNotFoundError,
|
|
4
4
|
builderMarketplaceApi,
|
|
5
5
|
configKeys
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BNAUZXPV.js";
|
|
7
7
|
|
|
8
8
|
// src/react/hooks/options/marketplaceConfigOptions.ts
|
|
9
9
|
import { queryOptions } from "@tanstack/react-query";
|
|
@@ -55,4 +55,4 @@ var marketplaceConfigOptions = (config) => {
|
|
|
55
55
|
export {
|
|
56
56
|
marketplaceConfigOptions
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-3II5GLHE.js.map
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LaosAPI,
|
|
3
|
+
balanceQueries,
|
|
4
|
+
collectableKeys,
|
|
5
|
+
getIndexerClient,
|
|
6
|
+
getMarketplaceClient
|
|
7
|
+
} from "./chunk-BNAUZXPV.js";
|
|
8
|
+
|
|
9
|
+
// src/react/queries/balanceOfCollectible.ts
|
|
10
|
+
import { queryOptions, skipToken } from "@tanstack/react-query";
|
|
11
|
+
async function fetchBalanceOfCollectible(args, config) {
|
|
12
|
+
if (args.isLaos721) {
|
|
13
|
+
const laosApi = new LaosAPI();
|
|
14
|
+
const response = await laosApi.getTokenBalances({
|
|
15
|
+
chainId: args.chainId.toString(),
|
|
16
|
+
accountAddress: args.userAddress,
|
|
17
|
+
includeMetadata: true
|
|
18
|
+
});
|
|
19
|
+
return response.balances[0] || null;
|
|
20
|
+
}
|
|
21
|
+
const indexerClient = getIndexerClient(args.chainId, config);
|
|
22
|
+
return indexerClient.getTokenBalances({
|
|
23
|
+
accountAddress: args.userAddress,
|
|
24
|
+
contractAddress: args.collectionAddress,
|
|
25
|
+
tokenID: args.collectableId,
|
|
26
|
+
includeMetadata: false,
|
|
27
|
+
metadataOptions: {
|
|
28
|
+
verifiedOnly: true,
|
|
29
|
+
includeContracts: [args.collectionAddress]
|
|
30
|
+
}
|
|
31
|
+
}).then((res) => res.balances[0] || null);
|
|
32
|
+
}
|
|
33
|
+
function balanceOfCollectibleOptions(args, config) {
|
|
34
|
+
const enabled = !!args.userAddress && (args.query?.enabled ?? true);
|
|
35
|
+
return queryOptions({
|
|
36
|
+
queryKey: [...collectableKeys.userBalances, args],
|
|
37
|
+
queryFn: enabled ? () => fetchBalanceOfCollectible(
|
|
38
|
+
{
|
|
39
|
+
...args,
|
|
40
|
+
// biome-ignore lint/style/noNonNullAssertion: this is guaranteed by the userAddress check above
|
|
41
|
+
userAddress: args.userAddress
|
|
42
|
+
},
|
|
43
|
+
config
|
|
44
|
+
) : skipToken
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/react/queries/highestOffer.ts
|
|
49
|
+
import { queryOptions as queryOptions2 } from "@tanstack/react-query";
|
|
50
|
+
async function fetchHighestOffer(args, config) {
|
|
51
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
52
|
+
const data = await marketplaceClient.getCollectibleHighestOffer({
|
|
53
|
+
contractAddress: args.collectionAddress,
|
|
54
|
+
tokenId: args.tokenId
|
|
55
|
+
});
|
|
56
|
+
let order;
|
|
57
|
+
if (data.order) {
|
|
58
|
+
order = {
|
|
59
|
+
...data.order,
|
|
60
|
+
priceAmount: BigInt(data.order.priceAmount),
|
|
61
|
+
priceAmountNet: BigInt(data.order.priceAmountNet)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return order ?? null;
|
|
65
|
+
}
|
|
66
|
+
function highestOfferOptions(args, config) {
|
|
67
|
+
return queryOptions2({
|
|
68
|
+
queryKey: [...collectableKeys.highestOffers, args],
|
|
69
|
+
queryFn: () => fetchHighestOffer(args, config)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/react/queries/listBalances.ts
|
|
74
|
+
import { infiniteQueryOptions } from "@tanstack/react-query";
|
|
75
|
+
async function fetchBalances(args, config, page) {
|
|
76
|
+
if (args.isLaos721) {
|
|
77
|
+
const response = await fetch(
|
|
78
|
+
"https://extensions.api.laosnetwork.io/token/GetTokenBalances",
|
|
79
|
+
{
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: {
|
|
82
|
+
"Content-Type": "application/json"
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
chainId: args.chainId.toString(),
|
|
86
|
+
accountAddress: args.accountAddress,
|
|
87
|
+
includeMetadata: args.includeMetadata ?? true,
|
|
88
|
+
page: {
|
|
89
|
+
sort: [
|
|
90
|
+
{
|
|
91
|
+
column: "CREATED_AT",
|
|
92
|
+
order: "DESC"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
throw new Error(`Laos API request failed with status ${response.status}`);
|
|
101
|
+
}
|
|
102
|
+
return response.json();
|
|
103
|
+
}
|
|
104
|
+
const indexerClient = getIndexerClient(args.chainId, config);
|
|
105
|
+
return indexerClient.getTokenBalances({
|
|
106
|
+
...args,
|
|
107
|
+
tokenID: args.tokenId,
|
|
108
|
+
page
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function listBalancesOptions(args, config) {
|
|
112
|
+
return infiniteQueryOptions({
|
|
113
|
+
...args.query,
|
|
114
|
+
queryKey: [...balanceQueries.lists, args, config],
|
|
115
|
+
queryFn: ({ pageParam }) => fetchBalances(args, config, pageParam),
|
|
116
|
+
initialPageParam: { page: 1, pageSize: 30 },
|
|
117
|
+
getNextPageParam: (lastPage) => lastPage.page.after
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/react/queries/listCollectibles.ts
|
|
122
|
+
import { infiniteQueryOptions as infiniteQueryOptions2 } from "@tanstack/react-query";
|
|
123
|
+
async function fetchCollectibles(args, config, page) {
|
|
124
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
125
|
+
const parsedArgs = {
|
|
126
|
+
...args,
|
|
127
|
+
contractAddress: args.collectionAddress,
|
|
128
|
+
page,
|
|
129
|
+
side: args.side
|
|
130
|
+
};
|
|
131
|
+
if (args.isLaos721 && args.side === "listing" /* listing */) {
|
|
132
|
+
try {
|
|
133
|
+
const balances = await fetchBalances(args, config, page);
|
|
134
|
+
const collectibles = balances.balances.map(
|
|
135
|
+
(balance) => {
|
|
136
|
+
if (!balance.tokenMetadata)
|
|
137
|
+
throw new Error("Token metadata not found");
|
|
138
|
+
return {
|
|
139
|
+
metadata: {
|
|
140
|
+
tokenId: balance.tokenID ?? "",
|
|
141
|
+
attributes: balance.tokenMetadata.attributes,
|
|
142
|
+
image: balance.tokenMetadata.image,
|
|
143
|
+
name: balance.tokenMetadata.name,
|
|
144
|
+
description: balance.tokenMetadata.description,
|
|
145
|
+
video: balance.tokenMetadata.video,
|
|
146
|
+
audio: balance.tokenMetadata.audio
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
return {
|
|
152
|
+
collectibles,
|
|
153
|
+
//@ts-expect-error
|
|
154
|
+
page: balances.page
|
|
155
|
+
};
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error(error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return await marketplaceClient.listCollectibles(parsedArgs);
|
|
161
|
+
}
|
|
162
|
+
function listCollectiblesOptions(args, config) {
|
|
163
|
+
return infiniteQueryOptions2({
|
|
164
|
+
...args.query,
|
|
165
|
+
queryKey: [...collectableKeys.lists, args, config],
|
|
166
|
+
queryFn: ({ pageParam }) => fetchCollectibles(args, config, pageParam),
|
|
167
|
+
initialPageParam: { page: 1, pageSize: 30 },
|
|
168
|
+
getNextPageParam: (lastPage) => lastPage.page?.more ? lastPage.page : void 0
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
fetchBalanceOfCollectible,
|
|
174
|
+
balanceOfCollectibleOptions,
|
|
175
|
+
fetchHighestOffer,
|
|
176
|
+
highestOfferOptions,
|
|
177
|
+
fetchBalances,
|
|
178
|
+
listBalancesOptions,
|
|
179
|
+
fetchCollectibles,
|
|
180
|
+
listCollectiblesOptions
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=chunk-3JU7SQVE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react/queries/balanceOfCollectible.ts","../src/react/queries/highestOffer.ts","../src/react/queries/listBalances.ts","../src/react/queries/listCollectibles.ts"],"sourcesContent":["import { queryOptions, skipToken } from '@tanstack/react-query';\nimport type { Hex } from 'viem';\nimport type { UseQueryParameters } from 'wagmi/query';\nimport type { SdkConfig } from '../../types';\nimport { LaosAPI, collectableKeys, getIndexerClient } from '../_internal';\n\nexport type UseBalanceOfCollectibleArgs = {\n\tcollectionAddress: Hex;\n\tcollectableId: string;\n\tuserAddress: Hex | undefined;\n\tchainId: number;\n\tisLaos721?: boolean;\n\tquery?: UseQueryParameters;\n};\n\n/**\n * Fetches the balance of a specific collectible for a user\n *\n * @param args - Arguments for the API call\n * @param config - SDK configuration\n * @returns The balance data\n */\nexport async function fetchBalanceOfCollectible(\n\targs: Omit<UseBalanceOfCollectibleArgs, 'userAddress'> & { userAddress: Hex },\n\tconfig: SdkConfig,\n) {\n\tif (args.isLaos721) {\n\t\tconst laosApi = new LaosAPI();\n\t\tconst response = await laosApi.getTokenBalances({\n\t\t\tchainId: args.chainId.toString(),\n\t\t\taccountAddress: args.userAddress,\n\t\t\tincludeMetadata: true,\n\t\t});\n\n\t\treturn response.balances[0] || null;\n\t}\n\n\tconst indexerClient = getIndexerClient(args.chainId, config);\n\treturn indexerClient\n\t\t.getTokenBalances({\n\t\t\taccountAddress: args.userAddress,\n\t\t\tcontractAddress: args.collectionAddress,\n\t\t\ttokenID: args.collectableId,\n\t\t\tincludeMetadata: false,\n\t\t\tmetadataOptions: {\n\t\t\t\tverifiedOnly: true,\n\t\t\t\tincludeContracts: [args.collectionAddress],\n\t\t\t},\n\t\t})\n\t\t.then((res) => res.balances[0] || null);\n}\n\n/**\n * Creates a tanstack query options object for the balance query\n *\n * @param args - The query arguments\n * @param config - SDK configuration\n * @returns Query options configuration\n */\nexport function balanceOfCollectibleOptions(\n\targs: UseBalanceOfCollectibleArgs,\n\tconfig: SdkConfig,\n) {\n\tconst enabled = !!args.userAddress && (args.query?.enabled ?? true);\n\treturn queryOptions({\n\t\tqueryKey: [...collectableKeys.userBalances, args],\n\t\tqueryFn: enabled\n\t\t\t? () =>\n\t\t\t\t\tfetchBalanceOfCollectible(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...args,\n\t\t\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: this is guaranteed by the userAddress check above\n\t\t\t\t\t\t\tuserAddress: args.userAddress!,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t)\n\t\t\t: skipToken,\n\t});\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport type { UseQueryParameters } from 'wagmi/query';\nimport type { Order as APIOrder, SdkConfig } from '../../types';\nimport { collectableKeys, getMarketplaceClient } from '../_internal';\n\nexport type UseHighestOfferArgs = {\n\tcollectionAddress: string;\n\ttokenId: string;\n\tchainId: number;\n\tquery?: UseQueryParameters;\n};\n\nexport type Order = Omit<APIOrder, 'priceAmount' | 'priceAmountNet'> & {\n\tpriceAmount: bigint;\n\tpriceAmountNet: bigint;\n};\n\n/**\n * Fetches the highest offer for a specific collectible\n *\n * @param args - Arguments for the API call\n * @param config - SDK configuration\n * @returns The highest offer data\n */\nexport async function fetchHighestOffer(\n\targs: UseHighestOfferArgs,\n\tconfig: SdkConfig,\n) {\n\tconst marketplaceClient = getMarketplaceClient(args.chainId, config);\n\n\tconst data = await marketplaceClient.getCollectibleHighestOffer({\n\t\tcontractAddress: args.collectionAddress,\n\t\ttokenId: args.tokenId,\n\t});\n\n\tlet order: Order | undefined;\n\tif (data.order) {\n\t\torder = {\n\t\t\t...data.order,\n\t\t\tpriceAmount: BigInt(data.order.priceAmount),\n\t\t\tpriceAmountNet: BigInt(data.order.priceAmountNet),\n\t\t};\n\t}\n\n\treturn order ?? null;\n}\n\n/**\n * Creates a tanstack query options object for the highest offer query\n *\n * @param args - The query arguments\n * @param config - SDK configuration\n * @returns Query options configuration\n */\nexport function highestOfferOptions(\n\targs: UseHighestOfferArgs,\n\tconfig: SdkConfig,\n) {\n\treturn queryOptions({\n\t\tqueryKey: [...collectableKeys.highestOffers, args],\n\t\tqueryFn: () => fetchHighestOffer(args, config),\n\t});\n}\n","import type { GetTokenBalancesReturn, Page } from '@0xsequence/indexer';\nimport { infiniteQueryOptions } from '@tanstack/react-query';\nimport type { Hex } from 'viem';\nimport type { SdkConfig } from '../../types';\nimport { balanceQueries, getIndexerClient } from '../_internal';\n\nexport type UseListBalancesArgs = {\n\tchainId: number;\n\taccountAddress?: Hex;\n\tcontractAddress?: Hex;\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\tisLaos721?: boolean;\n\t//TODO: More options\n\tquery?: {\n\t\tenabled?: boolean;\n\t};\n};\n\n/**\n * Fetches a list of token balances with pagination support\n *\n * @param args - Arguments for the API call\n * @param config - SDK configuration\n * @param page - Page parameters for pagination\n * @returns The token balances data\n */\nexport async function fetchBalances(\n\targs: UseListBalancesArgs,\n\tconfig: SdkConfig,\n\tpage: Page,\n): Promise<GetTokenBalancesReturn> {\n\tif (args.isLaos721) {\n\t\tconst response = await fetch(\n\t\t\t'https://extensions.api.laosnetwork.io/token/GetTokenBalances',\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tchainId: args.chainId.toString(),\n\t\t\t\t\taccountAddress: args.accountAddress,\n\t\t\t\t\tincludeMetadata: args.includeMetadata ?? true,\n\t\t\t\t\tpage: {\n\t\t\t\t\t\tsort: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcolumn: 'CREATED_AT',\n\t\t\t\t\t\t\t\torder: 'DESC',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Laos API request failed with status ${response.status}`);\n\t\t}\n\n\t\t// TODO: This is pretty unsafe, we should validate the response\n\t\treturn response.json() as Promise<GetTokenBalancesReturn>;\n\t}\n\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\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: [...balanceQueries.lists, args, config],\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 { infiniteQueryOptions } from '@tanstack/react-query';\nimport type { Hex } from 'viem';\nimport type { Page, SdkConfig } from '../../types';\nimport type {\n\tCollectibleOrder,\n\tCollectiblesFilter,\n\tListCollectiblesArgs,\n\tListCollectiblesReturn,\n} from '../_internal';\nimport { OrderSide, collectableKeys, getMarketplaceClient } from '../_internal';\nimport { fetchBalances } from './listBalances';\nexport type UseListCollectiblesArgs = {\n\tcollectionAddress: Hex;\n\tchainId: number;\n\tside: OrderSide;\n\tfilter?: CollectiblesFilter;\n\tisLaos721?: boolean;\n\tquery?: {\n\t\tenabled?: boolean;\n\t};\n};\n\n/**\n * Fetches a list of collectibles with pagination support\n *\n * @param args - Arguments for the API call\n * @param config - SDK configuration\n * @param page - Page parameters for pagination\n * @returns The collectibles data\n */\nexport async function fetchCollectibles(\n\targs: UseListCollectiblesArgs,\n\tconfig: SdkConfig,\n\tpage: Page,\n): Promise<ListCollectiblesReturn> {\n\tconst marketplaceClient = getMarketplaceClient(args.chainId, config);\n\tconst parsedArgs = {\n\t\t...args,\n\t\tcontractAddress: args.collectionAddress,\n\t\tpage: page,\n\t\tside: args.side,\n\t} satisfies ListCollectiblesArgs;\n\n\tif (args.isLaos721 && args.side === OrderSide.listing) {\n\t\ttry {\n\t\t\tconst balances = await fetchBalances(args, config, page);\n\t\t\tconst collectibles: CollectibleOrder[] = balances.balances.map(\n\t\t\t\t(balance) => {\n\t\t\t\t\tif (!balance.tokenMetadata)\n\t\t\t\t\t\tthrow new Error('Token metadata not found');\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\ttokenId: balance.tokenID ?? '',\n\t\t\t\t\t\t\tattributes: balance.tokenMetadata.attributes,\n\t\t\t\t\t\t\timage: balance.tokenMetadata.image,\n\t\t\t\t\t\t\tname: balance.tokenMetadata.name,\n\t\t\t\t\t\t\tdescription: balance.tokenMetadata.description,\n\t\t\t\t\t\t\tvideo: balance.tokenMetadata.video,\n\t\t\t\t\t\t\taudio: balance.tokenMetadata.audio,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcollectibles: collectibles,\n\t\t\t\t//@ts-expect-error\n\t\t\t\tpage: balances.page,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\t// If the request fails, ignore the error and return the collectibles from our indexer\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\treturn await marketplaceClient.listCollectibles(parsedArgs);\n}\n\n/**\n * Creates a tanstack infinite query options object for the collectibles query\n *\n * @param args - The query arguments\n * @param config - SDK configuration\n * @returns Query options configuration\n */\nexport function listCollectiblesOptions(\n\targs: UseListCollectiblesArgs,\n\tconfig: SdkConfig,\n) {\n\treturn infiniteQueryOptions({\n\t\t...args.query,\n\t\tqueryKey: [...collectableKeys.lists, args, config],\n\t\tqueryFn: ({ pageParam }) => fetchCollectibles(args, config, pageParam),\n\t\tinitialPageParam: { page: 1, pageSize: 30 } as Page,\n\t\tgetNextPageParam: (lastPage) =>\n\t\t\tlastPage.page?.more ? lastPage.page : undefined,\n\t});\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,cAAc,iBAAiB;AAsBxC,eAAsB,0BACrB,MACA,QACC;AACD,MAAI,KAAK,WAAW;AACnB,UAAM,UAAU,IAAI,QAAQ;AAC5B,UAAM,WAAW,MAAM,QAAQ,iBAAiB;AAAA,MAC/C,SAAS,KAAK,QAAQ,SAAS;AAAA,MAC/B,gBAAgB,KAAK;AAAA,MACrB,iB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 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X3QNSQER.js";
|
|
4
4
|
|
|
5
5
|
// src/react/_internal/databeat/index.ts
|
|
6
6
|
import { Databeat } from "@databeat/tracker";
|
|
@@ -50,4 +50,4 @@ export {
|
|
|
50
50
|
DatabeatAnalytics,
|
|
51
51
|
useAnalytics
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-A5ACY5YV.js.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MODAL_CONTENT_PROPS,
|
|
5
|
+
MODAL_OVERLAY_PROPS,
|
|
6
|
+
useSwitchChainModal,
|
|
7
|
+
useWallet
|
|
8
|
+
} from "./chunk-X3QNSQER.js";
|
|
9
|
+
|
|
10
|
+
// src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx
|
|
11
|
+
import { Button, Modal, Spinner, Text } from "@0xsequence/design-system";
|
|
12
|
+
import { observer } from "@legendapp/state/react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var ActionModal = observer(
|
|
15
|
+
({
|
|
16
|
+
isOpen,
|
|
17
|
+
onClose,
|
|
18
|
+
title,
|
|
19
|
+
children,
|
|
20
|
+
ctas,
|
|
21
|
+
chainId,
|
|
22
|
+
disableAnimation,
|
|
23
|
+
modalLoading,
|
|
24
|
+
spinnerContainerClassname,
|
|
25
|
+
hideCtas
|
|
26
|
+
}) => {
|
|
27
|
+
const { show: showSwitchChainModal } = useSwitchChainModal();
|
|
28
|
+
const { wallet, isLoading, isError } = useWallet();
|
|
29
|
+
const checkChain = async ({ onSuccess }) => {
|
|
30
|
+
const walletChainId = await wallet?.getChainId();
|
|
31
|
+
const chainMismatch = walletChainId !== Number(chainId);
|
|
32
|
+
if (chainMismatch) {
|
|
33
|
+
showSwitchChainModal({
|
|
34
|
+
chainIdToSwitchTo: Number(chainId),
|
|
35
|
+
onSuccess
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
onSuccess();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (wallet?.isWaaS) {
|
|
42
|
+
wallet.switchChain(Number(chainId));
|
|
43
|
+
}
|
|
44
|
+
if (!isOpen || !chainId) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Modal,
|
|
49
|
+
{
|
|
50
|
+
isDismissible: true,
|
|
51
|
+
onClose,
|
|
52
|
+
overlayProps: MODAL_OVERLAY_PROPS,
|
|
53
|
+
contentProps: MODAL_CONTENT_PROPS,
|
|
54
|
+
disableAnimation,
|
|
55
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative flex grow flex-col items-center gap-4 p-6", children: [
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
Text,
|
|
58
|
+
{
|
|
59
|
+
className: "w-full text-center font-body text-large",
|
|
60
|
+
fontWeight: "bold",
|
|
61
|
+
color: "text100",
|
|
62
|
+
children: title
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
modalLoading || isLoading || isError ? /* @__PURE__ */ jsxs(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: `flex ${spinnerContainerClassname} w-full items-center justify-center`,
|
|
69
|
+
children: [
|
|
70
|
+
isError && /* @__PURE__ */ jsx(Text, { className: "text-center font-body text-error100 text-small", children: "Error loading modal" }),
|
|
71
|
+
isLoading && /* @__PURE__ */ jsx(Spinner, { size: "lg" })
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
) : children,
|
|
75
|
+
!hideCtas && !isLoading && !isError && /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-2", children: ctas.map(
|
|
76
|
+
(cta) => !cta.hidden && /* @__PURE__ */ jsx(
|
|
77
|
+
Button,
|
|
78
|
+
{
|
|
79
|
+
className: "w-full rounded-[12px] [&>div]:justify-center",
|
|
80
|
+
onClick: async () => {
|
|
81
|
+
await checkChain({
|
|
82
|
+
onSuccess: () => {
|
|
83
|
+
cta.onClick();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
variant: cta.variant || "primary",
|
|
88
|
+
pending: cta.pending,
|
|
89
|
+
disabled: cta.disabled,
|
|
90
|
+
size: "lg",
|
|
91
|
+
"data-testid": cta.testid,
|
|
92
|
+
label: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2", children: [
|
|
93
|
+
cta.pending && /* @__PURE__ */ jsx(Spinner, { size: "sm" }),
|
|
94
|
+
cta.label
|
|
95
|
+
] })
|
|
96
|
+
},
|
|
97
|
+
cta.onClick.toString()
|
|
98
|
+
)
|
|
99
|
+
) })
|
|
100
|
+
] })
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// src/react/ui/modals/_internal/components/actionModal/store.ts
|
|
107
|
+
import { observable } from "@legendapp/state";
|
|
108
|
+
function createActionModalStore() {
|
|
109
|
+
return observable({
|
|
110
|
+
isOpen: false,
|
|
111
|
+
chainId: null,
|
|
112
|
+
collectionAddress: null
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function openModal(store) {
|
|
116
|
+
store.isOpen.set(true);
|
|
117
|
+
}
|
|
118
|
+
function closeModal(store) {
|
|
119
|
+
store.isOpen.set(false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
ActionModal,
|
|
124
|
+
createActionModalStore,
|
|
125
|
+
openModal,
|
|
126
|
+
closeModal
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-ABSYNRT5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx","../src/react/ui/modals/_internal/components/actionModal/store.ts"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport type { ComponentProps } from 'react';\n\nimport { Button, Modal, Spinner, Text } from '@0xsequence/design-system';\nimport { observer } from '@legendapp/state/react';\nimport { useWallet } from '../../../../../_internal/wallet/useWallet';\nimport { MODAL_OVERLAY_PROPS } from '../consts';\nimport { MODAL_CONTENT_PROPS } from '../consts';\nimport { useSwitchChainModal } from '../switchChainModal';\n\nexport interface ActionModalProps {\n\tisOpen: boolean;\n\tonClose: () => void;\n\ttitle: string;\n\tchildren: React.ReactNode;\n\tctas: {\n\t\tlabel: React.ReactNode;\n\t\tonClick: (() => Promise<void>) | (() => void);\n\t\tpending?: boolean;\n\t\tdisabled?: boolean;\n\t\thidden?: boolean;\n\t\tvariant?: ComponentProps<typeof Button>['variant'];\n\t\ttestid?: string;\n\t}[];\n\tchainId: number;\n\tmodalLoading?: boolean;\n\tspinnerContainerClassname?: string;\n\tdisableAnimation?: boolean;\n\thideCtas?: boolean;\n}\n\nexport const ActionModal = observer(\n\t({\n\t\tisOpen,\n\t\tonClose,\n\t\ttitle,\n\t\tchildren,\n\t\tctas,\n\t\tchainId,\n\t\tdisableAnimation,\n\t\tmodalLoading,\n\t\tspinnerContainerClassname,\n\t\thideCtas,\n\t}: ActionModalProps) => {\n\t\tconst { show: showSwitchChainModal } = useSwitchChainModal();\n\t\tconst { wallet, isLoading, isError } = useWallet();\n\n\t\tconst checkChain = async ({ onSuccess }: { onSuccess: () => void }) => {\n\t\t\tconst walletChainId = await wallet?.getChainId();\n\t\t\tconst chainMismatch = walletChainId !== Number(chainId);\n\t\t\tif (chainMismatch) {\n\t\t\t\tshowSwitchChainModal({\n\t\t\t\t\tchainIdToSwitchTo: Number(chainId),\n\t\t\t\t\tonSuccess,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tonSuccess();\n\t\t\t}\n\t\t};\n\n\t\tif (wallet?.isWaaS) {\n\t\t\twallet.switchChain(Number(chainId));\n\t\t}\n\n\t\tif (!isOpen || !chainId) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<Modal\n\t\t\t\tisDismissible={true}\n\t\t\t\tonClose={onClose}\n\t\t\t\toverlayProps={MODAL_OVERLAY_PROPS}\n\t\t\t\tcontentProps={MODAL_CONTENT_PROPS}\n\t\t\t\tdisableAnimation={disableAnimation}\n\t\t\t>\n\t\t\t\t<div className=\"relative flex grow flex-col items-center gap-4 p-6\">\n\t\t\t\t\t<Text\n\t\t\t\t\t\tclassName=\"w-full text-center font-body text-large\"\n\t\t\t\t\t\tfontWeight=\"bold\"\n\t\t\t\t\t\tcolor=\"text100\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{title}\n\t\t\t\t\t</Text>\n\n\t\t\t\t\t{modalLoading || isLoading || isError ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={`flex ${spinnerContainerClassname} w-full items-center justify-center`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{isError && (\n\t\t\t\t\t\t\t\t<Text className=\"text-center font-body text-error100 text-small\">\n\t\t\t\t\t\t\t\t\tError loading modal\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{isLoading && <Spinner size=\"lg\" />}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tchildren\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!hideCtas && !isLoading && !isError && (\n\t\t\t\t\t\t<div className=\"flex w-full flex-col gap-2\">\n\t\t\t\t\t\t\t{ctas.map(\n\t\t\t\t\t\t\t\t(cta) =>\n\t\t\t\t\t\t\t\t\t!cta.hidden && (\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"w-full rounded-[12px] [&>div]:justify-center\"\n\t\t\t\t\t\t\t\t\t\t\tkey={cta.onClick.toString()}\n\t\t\t\t\t\t\t\t\t\t\tonClick={async () => {\n\t\t\t\t\t\t\t\t\t\t\t\tawait checkChain({\n\t\t\t\t\t\t\t\t\t\t\t\t\tonSuccess: () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcta.onClick();\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\tvariant={cta.variant || 'primary'}\n\t\t\t\t\t\t\t\t\t\t\tpending={cta.pending}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={cta.disabled}\n\t\t\t\t\t\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\t\t\t\t\t\tdata-testid={cta.testid}\n\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"flex items-center justify-center gap-2\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{cta.pending && <Spinner size=\"sm\" />}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t{cta.label}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Modal>\n\t\t);\n\t},\n);\n","import { type Observable, observable } from '@legendapp/state';\nimport type { Address } from 'viem';\n\nexport interface ActionModalState {\n\tisOpen: boolean;\n\tchainId: number | null;\n\tcollectionAddress: Address | null;\n}\n\nexport function createActionModalStore() {\n\treturn observable<ActionModalState>({\n\t\tisOpen: false,\n\t\tchainId: null,\n\t\tcollectionAddress: null,\n\t});\n}\n\nexport function openModal(store: Observable<ActionModalState>) {\n\tstore.isOpen.set(true);\n}\n\nexport function closeModal(store: Observable<ActionModalState>) {\n\tstore.isOpen.set(false);\n}\n"],"mappings":";;;;;;;;AAKA,SAAS,QAAQ,OAAO,SAAS,YAAY;AAC7C,SAAS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,eAAK;AAAA,YACL,CAAC,QACA,CAAC,IAAI,UACJ;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBAEV,SAAS,YAAY;AACpB,wBAAM,WAAW;AAAA,oBAChB,WAAW,MAAM;AAChB,0BAAI,QAAQ;AAAA,oBACb;AAAA,kBACD,CAAC;AAAA,gBACF;AAAA,gBACA,SAAS,IAAI,WAAW;AAAA,gBACxB,SAAS,IAAI;AAAA,gBACb,UAAU,IAAI;AAAA,gBACd,MAAK;AAAA,gBACL,eAAa,IAAI;AAAA,gBACjB,OACC,qBAAC,SAAI,WAAU,0CACb;AAAA,sBAAI,WAAW,oBAAC,WAAQ,MAAK,MAAK;AAAA,kBAElC,IAAI;AAAA,mBACN;AAAA;AAAA,cAlBI,IAAI,QAAQ,SAAS;AAAA,YAoB3B;AAAA,UAEH,GACD;AAAA,WAEF;AAAA;AAAA,IACD;AAAA,EAEF;AACD;;;AC1IA,SAA0B,kBAAkB;AASrC,SAAS,yBAAyB;AACxC,SAAO,WAA6B;AAAA,IACnC,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,mBAAmB;AAAA,EACpB,CAAC;AACF;AAEO,SAAS,UAAU,OAAqC;AAC9D,QAAM,OAAO,IAAI,IAAI;AACtB;AAEO,SAAS,WAAW,OAAqC;AAC/D,QAAM,OAAO,IAAI,KAAK;AACvB;","names":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
cn
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q5RKAMYF.js";
|
|
6
6
|
|
|
7
7
|
// src/react/ui/icons/iconVariants.ts
|
|
8
8
|
import { cva } from "class-variance-authority";
|
|
@@ -73,4 +73,4 @@ export {
|
|
|
73
73
|
iconVariants,
|
|
74
74
|
InfoIcon_default
|
|
75
75
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-BCO4CYE4.js.map
|