@0xsequence/marketplace-sdk 0.4.4 → 0.4.6
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/dist/{chunk-6XUCLBZC.js → chunk-2FOUCP2R.js} +275 -210
- package/dist/chunk-2FOUCP2R.js.map +1 -0
- package/dist/{chunk-GLOIEUWC.js → chunk-36NGHJH5.js} +51 -611
- package/dist/chunk-36NGHJH5.js.map +1 -0
- package/dist/{chunk-LHN6EBLM.js → chunk-3C2MT5TM.js} +9 -10
- package/dist/chunk-3C2MT5TM.js.map +1 -0
- package/dist/{chunk-PAZ4MQXZ.js → chunk-5D3ARFFZ.js} +1 -1
- package/dist/chunk-5D3ARFFZ.js.map +1 -0
- package/dist/{chunk-ZEKRTFBU.js → chunk-DNVERQ5J.js} +12 -2
- package/dist/chunk-DNVERQ5J.js.map +1 -0
- package/dist/{chunk-4VS5NKDD.js → chunk-LTHX6RXH.js} +2 -2
- package/dist/{chunk-URX7ZHX4.js → chunk-QVOUL555.js} +2 -2
- package/dist/{chunk-J4TRSLTB.js → chunk-RD7HPANB.js} +4 -4
- package/dist/chunk-RD7HPANB.js.map +1 -0
- package/dist/chunk-WM4RGBFQ.js +155 -0
- package/dist/{chunk-DNDPYQKV.js.map → chunk-WM4RGBFQ.js.map} +1 -1
- package/dist/{chunk-IQXJZBMR.js → chunk-ZEH4JI2U.js} +2 -2
- package/dist/{create-config-8sffBvlt.d.ts → create-config-BBTTSJyp.d.ts} +2 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +6 -6
- package/dist/{marketplace-config-Bbxl-uKX.d.ts → marketplace-config-vioKvBQe.d.ts} +2 -0
- package/dist/react/_internal/api/index.d.ts +2 -3
- package/dist/react/_internal/api/index.js +2 -2
- package/dist/react/_internal/index.d.ts +6 -7
- package/dist/react/_internal/index.js +6 -4
- package/dist/react/_internal/wagmi/index.d.ts +3 -3
- package/dist/react/_internal/wagmi/index.js +2 -2
- package/dist/react/hooks/index.d.ts +106 -307
- package/dist/react/hooks/index.js +7 -10
- package/dist/react/index.d.ts +10 -8
- package/dist/react/index.js +12 -12
- package/dist/react/ssr/index.d.ts +14 -0
- package/dist/react/ssr/index.js +10 -32
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/index.d.ts +4 -3
- package/dist/react/ui/components/index.js +10 -10
- package/dist/react/ui/index.d.ts +5 -4
- package/dist/react/ui/index.js +10 -10
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +3 -2
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -7
- package/dist/react/ui/styles/index.d.ts +1 -1
- package/dist/{marketplace.gen-jdKqutnd.d.ts → sdk-config-CasNGLz4.d.ts} +24 -1
- package/dist/{services-C2O-7p_M.d.ts → services-CbsurKYr.d.ts} +1 -2
- package/dist/styles/index.d.ts +1 -1
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.js +4 -4
- package/dist/types-rupsBCjv.d.ts +70 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/src/react/_internal/types.ts +51 -1
- package/src/react/_internal/{transaction-machine/utils.ts → utils.ts} +1 -1
- package/src/react/_internal/{transaction-machine → wallet}/wallet.ts +2 -2
- package/src/react/hooks/index.ts +0 -1
- package/src/react/hooks/useCancelOrder.tsx +22 -3
- package/src/react/hooks/useCancelTransactionSteps.tsx +9 -8
- package/src/react/hooks/useCurrencies.tsx +16 -18
- package/src/react/hooks/useCurrency.tsx +1 -1
- package/src/react/provider.tsx +18 -3
- package/src/react/ssr/create-ssr-client.ts +9 -5
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +1 -1
- package/src/react/ui/modals/BuyModal/Modal.tsx +4 -0
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +33 -7
- package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +1 -1
- package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +12 -3
- package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +8 -3
- package/src/react/ui/modals/BuyModal/store.ts +14 -0
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +30 -5
- package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +35 -29
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +27 -35
- package/src/react/ui/modals/CreateListingModal/store.ts +3 -3
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +17 -24
- package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +36 -30
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +22 -6
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +33 -33
- package/src/react/ui/modals/MakeOfferModal/store.ts +4 -4
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +1 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +10 -23
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +39 -55
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -1
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +3 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +4 -0
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +11 -1
- package/src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts +3 -3
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +3 -0
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +2 -1
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +16 -7
- package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +12 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getTitle.ts +1 -1
- package/src/types/marketplace-config.ts +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-6XUCLBZC.js.map +0 -1
- package/dist/chunk-DNDPYQKV.js +0 -307
- package/dist/chunk-GLOIEUWC.js.map +0 -1
- package/dist/chunk-J4TRSLTB.js.map +0 -1
- package/dist/chunk-LHN6EBLM.js.map +0 -1
- package/dist/chunk-PAZ4MQXZ.js.map +0 -1
- package/dist/chunk-ZEKRTFBU.js.map +0 -1
- package/dist/sdk-config-xWkdBdrL.d.ts +0 -24
- package/dist/types-DZb7GsfL.d.ts +0 -28
- package/src/react/_internal/transaction-machine/execute-transaction.ts +0 -676
- package/src/react/_internal/transaction-machine/useTransactionMachine.ts +0 -140
- package/src/react/hooks/useBuyCollectable.tsx +0 -61
- /package/dist/{chunk-4VS5NKDD.js.map → chunk-LTHX6RXH.js.map} +0 -0
- /package/dist/{chunk-URX7ZHX4.js.map → chunk-QVOUL555.js.map} +0 -0
- /package/dist/{chunk-IQXJZBMR.js.map → chunk-ZEH4JI2U.js.map} +0 -0
- /package/src/react/_internal/{transaction-machine/logger.ts → logger.ts} +0 -0
- /package/src/react/_internal/{transaction-machine → wallet}/useWallet.ts +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import {
|
|
3
|
-
createLogger,
|
|
4
3
|
useSwitchChainModal,
|
|
5
4
|
useWallet
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3C2MT5TM.js";
|
|
7
6
|
import {
|
|
8
7
|
getPublicRpcClient
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LTHX6RXH.js";
|
|
10
9
|
import {
|
|
11
10
|
EIP2981_ABI
|
|
12
11
|
} from "./chunk-3OHM45R3.js";
|
|
@@ -19,7 +18,7 @@ import {
|
|
|
19
18
|
CollectableIdSchema,
|
|
20
19
|
PROVIDER_ID,
|
|
21
20
|
QueryArgSchema
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-DNVERQ5J.js";
|
|
23
22
|
import {
|
|
24
23
|
CollectibleStatus,
|
|
25
24
|
CollectionStatus,
|
|
@@ -39,7 +38,6 @@ import {
|
|
|
39
38
|
TransactionOnRampProvider,
|
|
40
39
|
TransactionSwapProvider,
|
|
41
40
|
WalletKind,
|
|
42
|
-
WebrpcError,
|
|
43
41
|
balanceQueries,
|
|
44
42
|
builderMarketplaceApi,
|
|
45
43
|
collectableKeys,
|
|
@@ -50,33 +48,15 @@ import {
|
|
|
50
48
|
getMarketplaceClient,
|
|
51
49
|
getMetadataClient,
|
|
52
50
|
getQueryClient
|
|
53
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-QVOUL555.js";
|
|
54
52
|
import {
|
|
55
53
|
BaseError,
|
|
56
|
-
ChainSwitchError,
|
|
57
54
|
ChainSwitchUserRejectedError,
|
|
58
|
-
CheckoutOptionsError,
|
|
59
|
-
InvalidCurrencyOptionsError,
|
|
60
55
|
MarketplaceConfigFetchError,
|
|
61
|
-
MissingSignatureDataError,
|
|
62
|
-
MissingStepDataError,
|
|
63
|
-
NoExecutionStepError,
|
|
64
|
-
NoMarketplaceConfigError,
|
|
65
|
-
NoStepsFoundError,
|
|
66
56
|
NoWalletConnectedError,
|
|
67
|
-
OrderNotFoundError,
|
|
68
|
-
OrdersFetchError,
|
|
69
|
-
PaymentModalError,
|
|
70
|
-
PaymentModalTransactionError,
|
|
71
57
|
ProjectNotFoundError,
|
|
72
|
-
StepExecutionError,
|
|
73
|
-
StepGenerationError,
|
|
74
|
-
TransactionError,
|
|
75
|
-
TransactionReceiptError,
|
|
76
|
-
UnexpectedStepsError,
|
|
77
|
-
UnknownTransactionTypeError,
|
|
78
58
|
WalletInstanceNotFoundError
|
|
79
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-WM4RGBFQ.js";
|
|
80
60
|
|
|
81
61
|
// src/react/hooks/useBalanceOfCollectible.tsx
|
|
82
62
|
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
@@ -94,15 +74,22 @@ var MarketplaceSdkProviderNotFoundError = class extends BaseError {
|
|
|
94
74
|
};
|
|
95
75
|
|
|
96
76
|
// src/react/provider.tsx
|
|
77
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
97
78
|
import { createContext } from "react";
|
|
98
79
|
import "@0xsequence/design-system/styles.css";
|
|
99
80
|
import { jsx } from "react/jsx-runtime";
|
|
100
81
|
var MarketplaceSdkContext = createContext({});
|
|
82
|
+
function MarketplaceQueryClientProvider({
|
|
83
|
+
children
|
|
84
|
+
}) {
|
|
85
|
+
const queryClient = getQueryClient();
|
|
86
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
|
|
87
|
+
}
|
|
101
88
|
function MarketplaceProvider({
|
|
102
89
|
config,
|
|
103
90
|
children
|
|
104
91
|
}) {
|
|
105
|
-
return /* @__PURE__ */ jsx(MarketplaceSdkContext.Provider, { value: config, children: /* @__PURE__ */ jsx("div", { id: PROVIDER_ID, children }) });
|
|
92
|
+
return /* @__PURE__ */ jsx(MarketplaceQueryClientProvider, { children: /* @__PURE__ */ jsx(MarketplaceSdkContext.Provider, { value: config, children: /* @__PURE__ */ jsx("div", { id: PROVIDER_ID, children }) }) });
|
|
106
93
|
}
|
|
107
94
|
|
|
108
95
|
// src/react/hooks/useConfig.tsx
|
|
@@ -787,7 +774,7 @@ var useCollection = (args) => {
|
|
|
787
774
|
|
|
788
775
|
// src/react/hooks/useCurrencies.tsx
|
|
789
776
|
import { queryOptions as queryOptions5, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
790
|
-
import {
|
|
777
|
+
import { zeroAddress } from "viem";
|
|
791
778
|
import { z as z6 } from "zod";
|
|
792
779
|
var ChainIdCoerce = ChainIdSchema.transform((val) => val.toString());
|
|
793
780
|
var UseCurrenciesArgsSchema = z6.object({
|
|
@@ -809,19 +796,21 @@ var fetchCurrencies = async (chainId, config) => {
|
|
|
809
796
|
};
|
|
810
797
|
var selectCurrencies = (data, args) => {
|
|
811
798
|
const argsParsed = UseCurrenciesArgsSchema.parse(args);
|
|
799
|
+
let filteredData = data;
|
|
800
|
+
if (!argsParsed.includeNativeCurrency) {
|
|
801
|
+
filteredData = filteredData.filter((currency) => !currency.nativeCurrency);
|
|
802
|
+
}
|
|
812
803
|
if (argsParsed.currencyOptions) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
(currency) =>
|
|
818
|
-
|
|
804
|
+
const lowerCaseCurrencyOptions = argsParsed.currencyOptions.map(
|
|
805
|
+
(option) => option.toLowerCase()
|
|
806
|
+
);
|
|
807
|
+
filteredData = filteredData.filter(
|
|
808
|
+
(currency) => lowerCaseCurrencyOptions.includes(
|
|
809
|
+
currency.contractAddress.toLowerCase()
|
|
810
|
+
)
|
|
819
811
|
);
|
|
820
812
|
}
|
|
821
|
-
|
|
822
|
-
return data;
|
|
823
|
-
}
|
|
824
|
-
return data.filter((currency) => !currency.nativeCurrency);
|
|
813
|
+
return filteredData;
|
|
825
814
|
};
|
|
826
815
|
var currenciesOptions = (args, config) => {
|
|
827
816
|
return queryOptions5({
|
|
@@ -1597,28 +1586,6 @@ var useGenerateBuyTransaction = (args) => {
|
|
|
1597
1586
|
// src/react/hooks/useCancelOrder.tsx
|
|
1598
1587
|
import { useState } from "react";
|
|
1599
1588
|
|
|
1600
|
-
// src/react/hooks/useGetReceiptFromHash.tsx
|
|
1601
|
-
import { usePublicClient } from "wagmi";
|
|
1602
|
-
import { useCallback } from "react";
|
|
1603
|
-
var useGetReceiptFromHash = () => {
|
|
1604
|
-
const publicClient = usePublicClient();
|
|
1605
|
-
const waitForReceipt = useCallback(
|
|
1606
|
-
async (transactionHash) => {
|
|
1607
|
-
if (!publicClient) {
|
|
1608
|
-
throw new Error("Public client not found");
|
|
1609
|
-
}
|
|
1610
|
-
const receipt = await publicClient.waitForTransactionReceipt({
|
|
1611
|
-
hash: transactionHash
|
|
1612
|
-
});
|
|
1613
|
-
return receipt;
|
|
1614
|
-
},
|
|
1615
|
-
[publicClient]
|
|
1616
|
-
);
|
|
1617
|
-
return {
|
|
1618
|
-
waitForReceipt
|
|
1619
|
-
};
|
|
1620
|
-
};
|
|
1621
|
-
|
|
1622
1589
|
// src/react/hooks/useCancelTransactionSteps.tsx
|
|
1623
1590
|
var useCancelTransactionSteps = ({
|
|
1624
1591
|
collectionAddress,
|
|
@@ -1633,7 +1600,6 @@ var useCancelTransactionSteps = ({
|
|
|
1633
1600
|
const walletIsInitialized = wallet && !isLoading && !isError;
|
|
1634
1601
|
const sdkConfig = useConfig();
|
|
1635
1602
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
1636
|
-
const { waitForReceipt } = useGetReceiptFromHash();
|
|
1637
1603
|
const { generateCancelTransactionAsync } = useGenerateCancelTransaction({
|
|
1638
1604
|
chainId
|
|
1639
1605
|
});
|
|
@@ -1683,13 +1649,13 @@ var useCancelTransactionSteps = ({
|
|
|
1683
1649
|
} else {
|
|
1684
1650
|
console.debug("onError callback not provided:", error);
|
|
1685
1651
|
}
|
|
1686
|
-
throw error;
|
|
1687
1652
|
}
|
|
1688
1653
|
};
|
|
1689
1654
|
const cancelOrder = async ({
|
|
1690
1655
|
orderId,
|
|
1691
1656
|
marketplace
|
|
1692
1657
|
}) => {
|
|
1658
|
+
const queryClient = getQueryClient();
|
|
1693
1659
|
if (!walletIsInitialized) {
|
|
1694
1660
|
throw new WalletInstanceNotFoundError();
|
|
1695
1661
|
}
|
|
@@ -1718,10 +1684,11 @@ var useCancelTransactionSteps = ({
|
|
|
1718
1684
|
if (transactionStep && wallet) {
|
|
1719
1685
|
hash = await executeTransaction({ transactionStep });
|
|
1720
1686
|
if (hash) {
|
|
1721
|
-
await
|
|
1687
|
+
await wallet.handleConfirmTransactionStep(hash, Number(chainId));
|
|
1722
1688
|
if (onSuccess && typeof onSuccess === "function") {
|
|
1723
1689
|
onSuccess({ hash });
|
|
1724
1690
|
}
|
|
1691
|
+
queryClient.invalidateQueries();
|
|
1725
1692
|
setSteps((prev) => ({
|
|
1726
1693
|
...prev,
|
|
1727
1694
|
isExecuting: false
|
|
@@ -1733,6 +1700,7 @@ var useCancelTransactionSteps = ({
|
|
|
1733
1700
|
if (onSuccess && typeof onSuccess === "function") {
|
|
1734
1701
|
onSuccess({ orderId: reservoirOrderId });
|
|
1735
1702
|
}
|
|
1703
|
+
queryClient.invalidateQueries();
|
|
1736
1704
|
setSteps((prev) => ({
|
|
1737
1705
|
...prev,
|
|
1738
1706
|
isExecuting: false
|
|
@@ -1746,7 +1714,6 @@ var useCancelTransactionSteps = ({
|
|
|
1746
1714
|
if (onError && typeof onError === "function") {
|
|
1747
1715
|
onError(error);
|
|
1748
1716
|
}
|
|
1749
|
-
throw error;
|
|
1750
1717
|
}
|
|
1751
1718
|
};
|
|
1752
1719
|
const executeTransaction = async ({
|
|
@@ -1788,561 +1755,36 @@ var useCancelOrder = ({
|
|
|
1788
1755
|
isExecuting: false,
|
|
1789
1756
|
execute: () => Promise.resolve()
|
|
1790
1757
|
});
|
|
1791
|
-
const
|
|
1758
|
+
const [cancellingOrderId, setCancellingOrderId] = useState(
|
|
1759
|
+
null
|
|
1760
|
+
);
|
|
1761
|
+
const { cancelOrder: cancelOrderBase } = useCancelTransactionSteps({
|
|
1792
1762
|
collectionAddress,
|
|
1793
1763
|
chainId,
|
|
1794
|
-
onSuccess
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
});
|
|
1798
|
-
return {
|
|
1799
|
-
cancelOrder,
|
|
1800
|
-
isExecuting: steps.isExecuting
|
|
1801
|
-
};
|
|
1802
|
-
};
|
|
1803
|
-
|
|
1804
|
-
// src/react/_internal/transaction-machine/execute-transaction.ts
|
|
1805
|
-
import { avalanche, optimism } from "viem/chains";
|
|
1806
|
-
var TransactionMachine = class {
|
|
1807
|
-
constructor(config, wallet, openSelectPaymentModal, switchChainFn, onPaymentModalLoaded) {
|
|
1808
|
-
this.config = config;
|
|
1809
|
-
this.wallet = wallet;
|
|
1810
|
-
this.openSelectPaymentModal = openSelectPaymentModal;
|
|
1811
|
-
this.switchChainFn = switchChainFn;
|
|
1812
|
-
this.onPaymentModalLoaded = onPaymentModalLoaded;
|
|
1813
|
-
this.currentState = "IDLE" /* IDLE */;
|
|
1814
|
-
this.logger = createLogger("TransactionMachine");
|
|
1815
|
-
this.marketplaceClient = getMarketplaceClient(
|
|
1816
|
-
config.config.chainId,
|
|
1817
|
-
config.config.sdkConfig
|
|
1818
|
-
);
|
|
1819
|
-
this.onPaymentModalLoaded = onPaymentModalLoaded;
|
|
1820
|
-
}
|
|
1821
|
-
currentState;
|
|
1822
|
-
logger;
|
|
1823
|
-
marketplaceClient;
|
|
1824
|
-
memoizedSteps = null;
|
|
1825
|
-
lastProps = null;
|
|
1826
|
-
getMarketplaceFee(collectionAddress) {
|
|
1827
|
-
const defaultFee = 2.5;
|
|
1828
|
-
const defaultPlatformFeeRecipient = "0x858dB1cbF6D09D447C96A11603189b49B2D1C219";
|
|
1829
|
-
const avalancheAndOptimismPlatformFeeRecipient = "0x400cdab4676c17aec07e8ec748a5fc3b674bca41";
|
|
1830
|
-
const chainId = Number(this.config.config.chainId);
|
|
1831
|
-
const collection = this.config.config.marketplaceConfig.collections.find(
|
|
1832
|
-
(collection2) => collection2.collectionAddress.toLowerCase() === collectionAddress.toLowerCase() && chainId === Number(collection2.chainId)
|
|
1833
|
-
);
|
|
1834
|
-
const avalancheOrOptimism = chainId === avalanche.id || chainId === optimism.id;
|
|
1835
|
-
const receiver = avalancheOrOptimism ? avalancheAndOptimismPlatformFeeRecipient : defaultPlatformFeeRecipient;
|
|
1836
|
-
const percentageToBPS = (percentage) => Number(percentage) * 1e4 / 100;
|
|
1837
|
-
return {
|
|
1838
|
-
amount: percentageToBPS(
|
|
1839
|
-
collection?.marketplaceFeePercentage || defaultFee
|
|
1840
|
-
).toString(),
|
|
1841
|
-
receiver
|
|
1842
|
-
};
|
|
1843
|
-
}
|
|
1844
|
-
async generateSteps({
|
|
1845
|
-
type,
|
|
1846
|
-
props
|
|
1847
|
-
}) {
|
|
1848
|
-
this.logger.debug("Generating steps", { type, props });
|
|
1849
|
-
const { collectionAddress } = this.config.config;
|
|
1850
|
-
const address = await this.wallet.address();
|
|
1851
|
-
try {
|
|
1852
|
-
switch (type) {
|
|
1853
|
-
case "BUY" /* BUY */:
|
|
1854
|
-
return await this.marketplaceClient.generateBuyTransaction({
|
|
1855
|
-
collectionAddress,
|
|
1856
|
-
buyer: address,
|
|
1857
|
-
walletType: this.wallet.walletKind,
|
|
1858
|
-
marketplace: props.marketplace,
|
|
1859
|
-
ordersData: [
|
|
1860
|
-
{
|
|
1861
|
-
orderId: props.orderId,
|
|
1862
|
-
quantity: props.quantity || "1"
|
|
1863
|
-
}
|
|
1864
|
-
],
|
|
1865
|
-
additionalFees: [this.getMarketplaceFee(collectionAddress)]
|
|
1866
|
-
}).then((resp) => resp.steps);
|
|
1867
|
-
case "SELL" /* SELL */:
|
|
1868
|
-
return await this.marketplaceClient.generateSellTransaction({
|
|
1869
|
-
collectionAddress,
|
|
1870
|
-
seller: address,
|
|
1871
|
-
walletType: this.wallet.walletKind,
|
|
1872
|
-
marketplace: props.marketplace,
|
|
1873
|
-
ordersData: [
|
|
1874
|
-
{
|
|
1875
|
-
orderId: props.orderId,
|
|
1876
|
-
quantity: props.quantity || "1"
|
|
1877
|
-
}
|
|
1878
|
-
],
|
|
1879
|
-
additionalFees: [this.getMarketplaceFee(collectionAddress)]
|
|
1880
|
-
}).then((resp) => resp.steps);
|
|
1881
|
-
case "LISTING" /* LISTING */:
|
|
1882
|
-
if (!this.config.config.orderbookKind) {
|
|
1883
|
-
this.config.config.orderbookKind = "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
|
|
1884
|
-
}
|
|
1885
|
-
return await this.marketplaceClient.generateListingTransaction({
|
|
1886
|
-
collectionAddress,
|
|
1887
|
-
owner: address,
|
|
1888
|
-
walletType: this.wallet.walletKind,
|
|
1889
|
-
contractType: props.contractType,
|
|
1890
|
-
orderbook: this.config.config.orderbookKind,
|
|
1891
|
-
listing: props.listing
|
|
1892
|
-
}).then((resp) => resp.steps);
|
|
1893
|
-
case "OFFER" /* OFFER */:
|
|
1894
|
-
if (!this.config.config.orderbookKind) {
|
|
1895
|
-
this.config.config.orderbookKind = "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
|
|
1896
|
-
}
|
|
1897
|
-
return await this.marketplaceClient.generateOfferTransaction({
|
|
1898
|
-
collectionAddress,
|
|
1899
|
-
maker: address,
|
|
1900
|
-
walletType: this.wallet.walletKind,
|
|
1901
|
-
contractType: props.contractType,
|
|
1902
|
-
orderbook: this.config.config.orderbookKind,
|
|
1903
|
-
offer: props.offer
|
|
1904
|
-
}).then((resp) => resp.steps);
|
|
1905
|
-
case "CANCEL" /* CANCEL */:
|
|
1906
|
-
return await this.marketplaceClient.generateCancelTransaction({
|
|
1907
|
-
collectionAddress,
|
|
1908
|
-
maker: address,
|
|
1909
|
-
marketplace: props.marketplace,
|
|
1910
|
-
orderId: props.orderId
|
|
1911
|
-
}).then((resp) => resp.steps);
|
|
1912
|
-
default:
|
|
1913
|
-
throw new UnknownTransactionTypeError(type);
|
|
1914
|
-
}
|
|
1915
|
-
} catch (error) {
|
|
1916
|
-
if (error instanceof WebrpcError) {
|
|
1917
|
-
throw new StepGenerationError(type, error);
|
|
1918
|
-
}
|
|
1919
|
-
throw error;
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
clearMemoizedSteps() {
|
|
1923
|
-
this.logger.debug("Clearing memoized steps");
|
|
1924
|
-
this.memoizedSteps = null;
|
|
1925
|
-
this.lastProps = null;
|
|
1926
|
-
}
|
|
1927
|
-
async transition(newState) {
|
|
1928
|
-
this.logger.state(this.currentState, newState);
|
|
1929
|
-
this.currentState = newState;
|
|
1930
|
-
this.clearMemoizedSteps();
|
|
1931
|
-
}
|
|
1932
|
-
async switchChain() {
|
|
1933
|
-
this.logger.debug("Checking chain", {
|
|
1934
|
-
currentChain: await this.wallet.getChainId(),
|
|
1935
|
-
targetChain: Number(this.config.config.chainId)
|
|
1936
|
-
});
|
|
1937
|
-
const correctChain = await this.isOnCorrectChain();
|
|
1938
|
-
if (!correctChain) {
|
|
1939
|
-
const currentChain = await this.wallet.getChainId();
|
|
1940
|
-
const targetChain = Number(this.config.config.chainId);
|
|
1941
|
-
await this.transition("SWITCH_CHAIN" /* SWITCH_CHAIN */);
|
|
1942
|
-
try {
|
|
1943
|
-
if (this.wallet.isWaaS) {
|
|
1944
|
-
await this.wallet.switchChain(targetChain);
|
|
1945
|
-
} else {
|
|
1946
|
-
await this.switchChainFn(this.config.config.chainId);
|
|
1947
|
-
}
|
|
1948
|
-
if (!this.isOnCorrectChain()) {
|
|
1949
|
-
throw new Error("Chain switch verification failed");
|
|
1950
|
-
}
|
|
1951
|
-
this.logger.debug("Switched chain successfully");
|
|
1952
|
-
} catch (error) {
|
|
1953
|
-
this.logger.debug("Chain switch failed", error);
|
|
1954
|
-
throw new ChainSwitchError(currentChain, targetChain);
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
async isOnCorrectChain() {
|
|
1959
|
-
return await this.wallet.getChainId() === Number(this.config.config.chainId);
|
|
1960
|
-
}
|
|
1961
|
-
async start(props) {
|
|
1962
|
-
this.logger.debug("Starting transaction", props);
|
|
1963
|
-
await this.transition("CHECKING_STEPS" /* CHECKING_STEPS */);
|
|
1964
|
-
const { type } = this.config.config;
|
|
1965
|
-
const steps = await this.generateSteps({
|
|
1966
|
-
type,
|
|
1967
|
-
props
|
|
1968
|
-
});
|
|
1969
|
-
for (const step of steps) {
|
|
1970
|
-
await this.executeStep({ step, props });
|
|
1971
|
-
}
|
|
1972
|
-
await this.transition("SUCCESS" /* SUCCESS */);
|
|
1973
|
-
}
|
|
1974
|
-
async handleTransactionSuccess(hash, isApproval, orderId) {
|
|
1975
|
-
if (!hash) {
|
|
1976
|
-
await this.transition("SUCCESS" /* SUCCESS */);
|
|
1977
|
-
this.config.onTransactionSent?.(void 0, orderId);
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1980
|
-
await this.transition("CONFIRMING" /* CONFIRMING */);
|
|
1981
|
-
if (!isApproval) {
|
|
1982
|
-
this.config.onTransactionSent?.(hash);
|
|
1983
|
-
}
|
|
1984
|
-
try {
|
|
1985
|
-
const receipt = await this.wallet.handleConfirmTransactionStep(
|
|
1986
|
-
hash,
|
|
1987
|
-
await this.wallet.getChainId()
|
|
1988
|
-
);
|
|
1989
|
-
this.logger.debug("Transaction confirmed", receipt);
|
|
1990
|
-
await this.transition("SUCCESS" /* SUCCESS */);
|
|
1991
|
-
if (isApproval) {
|
|
1992
|
-
this.config.onApprovalSuccess?.(hash);
|
|
1993
|
-
} else {
|
|
1994
|
-
console.log("onSuccess", hash);
|
|
1995
|
-
this.config.onSuccess?.(hash);
|
|
1996
|
-
}
|
|
1997
|
-
} catch (error) {
|
|
1998
|
-
throw new TransactionReceiptError(hash, error);
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
async executeTransaction(step) {
|
|
2002
|
-
try {
|
|
2003
|
-
await this.switchChain();
|
|
2004
|
-
if (step.id === "tokenApproval" /* tokenApproval */) {
|
|
2005
|
-
await this.transition("TOKEN_APPROVAL" /* TOKEN_APPROVAL */);
|
|
2006
|
-
}
|
|
2007
|
-
this.logger.debug("Executing transaction", step);
|
|
2008
|
-
const hash = await this.wallet.handleSendTransactionStep(
|
|
2009
|
-
Number(this.config.config.chainId),
|
|
2010
|
-
step
|
|
2011
|
-
);
|
|
2012
|
-
this.logger.debug("Transaction submitted", { hash });
|
|
2013
|
-
await this.handleTransactionSuccess(
|
|
2014
|
-
hash,
|
|
2015
|
-
step.id === "tokenApproval" /* tokenApproval */
|
|
2016
|
-
);
|
|
2017
|
-
return hash;
|
|
2018
|
-
} catch (error) {
|
|
2019
|
-
throw new StepExecutionError(step.id, error);
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
async executeSignature(step) {
|
|
2023
|
-
await this.switchChain();
|
|
2024
|
-
if (!step.signature) {
|
|
2025
|
-
throw new MissingSignatureDataError();
|
|
2026
|
-
}
|
|
2027
|
-
try {
|
|
2028
|
-
const signature = await this.wallet.handleSignMessageStep(
|
|
2029
|
-
step
|
|
2030
|
-
);
|
|
2031
|
-
const result = await this.marketplaceClient.execute({
|
|
2032
|
-
signature,
|
|
2033
|
-
executeType: "order" /* order */,
|
|
2034
|
-
body: step.post?.body
|
|
2035
|
-
});
|
|
2036
|
-
await this.handleTransactionSuccess(void 0, false, result.orderId);
|
|
2037
|
-
} catch (error) {
|
|
2038
|
-
this.logger.error("Signature execution failed", { error });
|
|
2039
|
-
throw new StepExecutionError(step.id, error);
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
openPaymentModalWithPromise(settings) {
|
|
2043
|
-
return new Promise((resolve, reject) => {
|
|
2044
|
-
this.openSelectPaymentModal({
|
|
2045
|
-
...settings,
|
|
2046
|
-
onSuccess: async (hash) => {
|
|
2047
|
-
try {
|
|
2048
|
-
await this.handleTransactionSuccess(hash);
|
|
2049
|
-
resolve();
|
|
2050
|
-
} catch (error) {
|
|
2051
|
-
reject(error);
|
|
2052
|
-
}
|
|
2053
|
-
},
|
|
2054
|
-
onError: (error) => {
|
|
2055
|
-
reject(new PaymentModalError(error));
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
});
|
|
2059
|
-
}
|
|
2060
|
-
async executeBuyStep({
|
|
2061
|
-
step,
|
|
2062
|
-
props
|
|
2063
|
-
}) {
|
|
2064
|
-
try {
|
|
2065
|
-
await this.transition("EXECUTING_TRANSACTION" /* EXECUTING_TRANSACTION */);
|
|
2066
|
-
try {
|
|
2067
|
-
const [checkoutOptions, orders] = await Promise.all([
|
|
2068
|
-
this.marketplaceClient.checkoutOptionsMarketplace({
|
|
2069
|
-
wallet: await this.wallet.address(),
|
|
2070
|
-
orders: [
|
|
2071
|
-
{
|
|
2072
|
-
contractAddress: this.config.config.collectionAddress,
|
|
2073
|
-
orderId: props.orderId,
|
|
2074
|
-
marketplace: props.marketplace
|
|
2075
|
-
}
|
|
2076
|
-
],
|
|
2077
|
-
additionalFee: Number(
|
|
2078
|
-
this.getMarketplaceFee(this.config.config.collectionAddress).amount
|
|
2079
|
-
)
|
|
2080
|
-
}).catch((error) => {
|
|
2081
|
-
throw new CheckoutOptionsError(error);
|
|
2082
|
-
}),
|
|
2083
|
-
this.marketplaceClient.getOrders({
|
|
2084
|
-
input: [
|
|
2085
|
-
{
|
|
2086
|
-
orderId: props.orderId,
|
|
2087
|
-
marketplace: props.marketplace,
|
|
2088
|
-
contractAddress: this.config.config.collectionAddress
|
|
2089
|
-
}
|
|
2090
|
-
]
|
|
2091
|
-
}).catch((error) => {
|
|
2092
|
-
throw new OrdersFetchError(props.orderId, error);
|
|
2093
|
-
})
|
|
2094
|
-
]);
|
|
2095
|
-
const order = orders.orders[0];
|
|
2096
|
-
if (!order) {
|
|
2097
|
-
throw new OrderNotFoundError(props.orderId);
|
|
2098
|
-
}
|
|
2099
|
-
const paymentModalProps = {
|
|
2100
|
-
chain: this.config.config.chainId,
|
|
2101
|
-
collectibles: [
|
|
2102
|
-
{
|
|
2103
|
-
tokenId: order.tokenId,
|
|
2104
|
-
quantity: props.quantity,
|
|
2105
|
-
decimals: props.collectableDecimals
|
|
2106
|
-
}
|
|
2107
|
-
],
|
|
2108
|
-
currencyAddress: order.priceCurrencyAddress,
|
|
2109
|
-
price: step.value,
|
|
2110
|
-
targetContractAddress: step.to,
|
|
2111
|
-
txData: step.data,
|
|
2112
|
-
collectionAddress: this.config.config.collectionAddress,
|
|
2113
|
-
recipientAddress: await this.wallet.address(),
|
|
2114
|
-
enableMainCurrencyPayment: true,
|
|
2115
|
-
enableSwapPayments: !!checkoutOptions.options?.swap?.includes(
|
|
2116
|
-
"zerox" /* zerox */
|
|
2117
|
-
),
|
|
2118
|
-
creditCardProviders: checkoutOptions?.options.nftCheckout || []
|
|
2119
|
-
};
|
|
2120
|
-
this.logger.debug("Opening payment modal", paymentModalProps);
|
|
2121
|
-
this.onPaymentModalLoaded?.();
|
|
2122
|
-
await this.openPaymentModalWithPromise(paymentModalProps);
|
|
2123
|
-
} catch (error) {
|
|
2124
|
-
if (error instanceof TransactionError) {
|
|
2125
|
-
throw error;
|
|
2126
|
-
}
|
|
2127
|
-
throw new PaymentModalTransactionError(step.id, error);
|
|
2128
|
-
}
|
|
2129
|
-
} catch (error) {
|
|
2130
|
-
if (error instanceof TransactionError) {
|
|
2131
|
-
throw error;
|
|
2132
|
-
}
|
|
2133
|
-
throw new StepExecutionError(step.id, error);
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2136
|
-
async executeStep({
|
|
2137
|
-
step,
|
|
2138
|
-
props
|
|
2139
|
-
}) {
|
|
2140
|
-
try {
|
|
2141
|
-
this.logger.debug("Executing step", { stepId: step.id });
|
|
2142
|
-
if (!step.to && !step.signature) {
|
|
2143
|
-
throw new MissingStepDataError();
|
|
2144
|
-
}
|
|
2145
|
-
if (step.id === "buy" /* buy */) {
|
|
2146
|
-
await this.executeBuyStep({ step, props });
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
if (step.signature) {
|
|
2150
|
-
await this.executeSignature(step);
|
|
2151
|
-
return;
|
|
2152
|
-
}
|
|
2153
|
-
const hash = await this.executeTransaction(step);
|
|
2154
|
-
return { hash };
|
|
2155
|
-
} catch (error) {
|
|
2156
|
-
if (error instanceof TransactionError) {
|
|
2157
|
-
throw error;
|
|
2158
|
-
}
|
|
2159
|
-
throw new StepExecutionError(step.id, error);
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
async getTransactionSteps(props) {
|
|
2163
|
-
this.logger.debug("Getting transaction steps", props);
|
|
2164
|
-
if (this.memoizedSteps && this.lastProps && JSON.stringify(props) === JSON.stringify(this.lastProps)) {
|
|
2165
|
-
this.logger.debug("Returning memoized steps");
|
|
2166
|
-
return this.memoizedSteps;
|
|
2167
|
-
}
|
|
2168
|
-
const type = this.config.config.type;
|
|
2169
|
-
const steps = await this.generateSteps({
|
|
2170
|
-
type,
|
|
2171
|
-
props
|
|
2172
|
-
});
|
|
2173
|
-
const executionStep = steps.pop();
|
|
2174
|
-
if (!executionStep) {
|
|
2175
|
-
throw new NoStepsFoundError();
|
|
2176
|
-
}
|
|
2177
|
-
if (executionStep.id === "tokenApproval" /* tokenApproval */) {
|
|
2178
|
-
throw new NoExecutionStepError();
|
|
2179
|
-
}
|
|
2180
|
-
const approvalStep = steps.pop();
|
|
2181
|
-
if (steps.length > 0) {
|
|
2182
|
-
throw new UnexpectedStepsError();
|
|
2183
|
-
}
|
|
2184
|
-
this.lastProps = props;
|
|
2185
|
-
this.memoizedSteps = {
|
|
2186
|
-
switchChain: {
|
|
2187
|
-
isPending: !this.isOnCorrectChain(),
|
|
2188
|
-
isExecuting: this.currentState === "SWITCH_CHAIN" /* SWITCH_CHAIN */,
|
|
2189
|
-
execute: () => this.switchChain()
|
|
2190
|
-
},
|
|
2191
|
-
approval: {
|
|
2192
|
-
isPending: Boolean(approvalStep),
|
|
2193
|
-
isExecuting: this.currentState === "TOKEN_APPROVAL" /* TOKEN_APPROVAL */,
|
|
2194
|
-
execute: () => approvalStep && this.executeStep({ step: approvalStep, props })
|
|
2195
|
-
},
|
|
2196
|
-
transaction: {
|
|
2197
|
-
isPending: Boolean(executionStep),
|
|
2198
|
-
isExecuting: this.currentState === "EXECUTING_TRANSACTION" /* EXECUTING_TRANSACTION */,
|
|
2199
|
-
execute: () => this.executeStep({ step: executionStep, props })
|
|
2200
|
-
}
|
|
2201
|
-
};
|
|
2202
|
-
this.logger.debug("Generated new transaction steps", this.memoizedSteps);
|
|
2203
|
-
return this.memoizedSteps;
|
|
2204
|
-
}
|
|
2205
|
-
};
|
|
2206
|
-
|
|
2207
|
-
// src/react/_internal/transaction-machine/useTransactionMachine.ts
|
|
2208
|
-
import { useSelectPaymentModal } from "@0xsequence/kit-checkout";
|
|
2209
|
-
import { useAccount as useAccount4, useSwitchChain } from "wagmi";
|
|
2210
|
-
var useTransactionMachine = ({
|
|
2211
|
-
config,
|
|
2212
|
-
enabled,
|
|
2213
|
-
onSuccess,
|
|
2214
|
-
onError,
|
|
2215
|
-
onTransactionSent,
|
|
2216
|
-
onApprovalSuccess,
|
|
2217
|
-
onPaymentModalLoaded
|
|
2218
|
-
}) => {
|
|
2219
|
-
const { show: showSwitchChainModal } = useSwitchChainModal();
|
|
2220
|
-
const sdkConfig = useConfig();
|
|
2221
|
-
const {
|
|
2222
|
-
data: marketplaceConfig,
|
|
2223
|
-
error: marketplaceError,
|
|
2224
|
-
isLoading: marketplaceConfigIsLoading
|
|
2225
|
-
} = useMarketplaceConfig();
|
|
2226
|
-
const { openSelectPaymentModal } = useSelectPaymentModal();
|
|
2227
|
-
const { chains } = useSwitchChain();
|
|
2228
|
-
const { isConnected } = useAccount4();
|
|
2229
|
-
const {
|
|
2230
|
-
wallet: walletInstance,
|
|
2231
|
-
isLoading: walletClientIsLoading,
|
|
2232
|
-
isError: walletClientIsError
|
|
2233
|
-
} = useWallet();
|
|
2234
|
-
if (!enabled) return { machine: null, error: null, isLoading: false };
|
|
2235
|
-
if (!isConnected) {
|
|
2236
|
-
return { machine: null, error: null, isLoading: false };
|
|
2237
|
-
}
|
|
2238
|
-
if (walletClientIsLoading || marketplaceConfigIsLoading) {
|
|
2239
|
-
return { machine: null, error: null, isLoading: true };
|
|
2240
|
-
}
|
|
2241
|
-
if (marketplaceError) {
|
|
2242
|
-
const error = new TransactionError("Marketplace config error", {
|
|
2243
|
-
cause: marketplaceError
|
|
2244
|
-
});
|
|
2245
|
-
onError?.(error);
|
|
2246
|
-
return { machine: null, error };
|
|
2247
|
-
}
|
|
2248
|
-
if (walletClientIsError) {
|
|
2249
|
-
const error = new NoWalletConnectedError();
|
|
2250
|
-
onError?.(error);
|
|
2251
|
-
return { machine: null, error };
|
|
2252
|
-
}
|
|
2253
|
-
if (!marketplaceConfig) {
|
|
2254
|
-
const error = new NoMarketplaceConfigError();
|
|
2255
|
-
onError?.(error);
|
|
2256
|
-
return { machine: null, error };
|
|
2257
|
-
}
|
|
2258
|
-
const machine = new TransactionMachine(
|
|
2259
|
-
{
|
|
2260
|
-
config: {
|
|
2261
|
-
sdkConfig,
|
|
2262
|
-
marketplaceConfig,
|
|
2263
|
-
chains,
|
|
2264
|
-
...config
|
|
2265
|
-
},
|
|
2266
|
-
onSuccess,
|
|
2267
|
-
onTransactionSent,
|
|
2268
|
-
onApprovalSuccess
|
|
1764
|
+
onSuccess: (result) => {
|
|
1765
|
+
setCancellingOrderId(null);
|
|
1766
|
+
onSuccess?.(result);
|
|
2269
1767
|
},
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
showSwitchChainModal({
|
|
2274
|
-
chainIdToSwitchTo: Number(config.chainId),
|
|
2275
|
-
onSuccess: resolve,
|
|
2276
|
-
onError: reject,
|
|
2277
|
-
onClose: reject
|
|
2278
|
-
});
|
|
2279
|
-
}),
|
|
2280
|
-
onPaymentModalLoaded
|
|
2281
|
-
);
|
|
2282
|
-
return {
|
|
2283
|
-
machine: {
|
|
2284
|
-
getTransactionSteps: async (props) => {
|
|
2285
|
-
try {
|
|
2286
|
-
return await machine.getTransactionSteps(props);
|
|
2287
|
-
} catch (e) {
|
|
2288
|
-
const error = e;
|
|
2289
|
-
onError?.(error);
|
|
2290
|
-
}
|
|
2291
|
-
},
|
|
2292
|
-
start: async (props) => {
|
|
2293
|
-
try {
|
|
2294
|
-
await machine.start(props);
|
|
2295
|
-
} catch (e) {
|
|
2296
|
-
const error = e;
|
|
2297
|
-
onError?.(error);
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
1768
|
+
onError: (error) => {
|
|
1769
|
+
setCancellingOrderId(null);
|
|
1770
|
+
onError?.(error);
|
|
2300
1771
|
},
|
|
2301
|
-
|
|
2302
|
-
isLoading: false
|
|
2303
|
-
};
|
|
2304
|
-
};
|
|
2305
|
-
|
|
2306
|
-
// src/react/hooks/useBuyCollectable.tsx
|
|
2307
|
-
import { useCallback as useCallback2 } from "react";
|
|
2308
|
-
var useBuyCollectable = ({
|
|
2309
|
-
onSuccess,
|
|
2310
|
-
onError,
|
|
2311
|
-
onTransactionSent,
|
|
2312
|
-
setPaymentLoadingModalOpen,
|
|
2313
|
-
onPaymentModalLoaded,
|
|
2314
|
-
enabled,
|
|
2315
|
-
...config
|
|
2316
|
-
}) => {
|
|
2317
|
-
const machineConfig = {
|
|
2318
|
-
...config,
|
|
2319
|
-
type: "BUY" /* BUY */
|
|
2320
|
-
};
|
|
2321
|
-
const { machine, error, isLoading } = useTransactionMachine({
|
|
2322
|
-
config: machineConfig,
|
|
2323
|
-
enabled,
|
|
2324
|
-
onSuccess,
|
|
2325
|
-
onError,
|
|
2326
|
-
onTransactionSent,
|
|
2327
|
-
onPaymentModalLoaded
|
|
1772
|
+
setSteps
|
|
2328
1773
|
});
|
|
2329
|
-
const
|
|
2330
|
-
(
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
machine.start(props);
|
|
2334
|
-
},
|
|
2335
|
-
[setPaymentLoadingModalOpen, machine]
|
|
2336
|
-
);
|
|
1774
|
+
const cancelOrder = async (params) => {
|
|
1775
|
+
setCancellingOrderId(params.orderId);
|
|
1776
|
+
return cancelOrderBase(params);
|
|
1777
|
+
};
|
|
2337
1778
|
return {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
1779
|
+
cancelOrder,
|
|
1780
|
+
isExecuting: steps.isExecuting,
|
|
1781
|
+
cancellingOrderId
|
|
2341
1782
|
};
|
|
2342
1783
|
};
|
|
2343
1784
|
|
|
2344
1785
|
export {
|
|
2345
1786
|
MarketplaceSdkContext,
|
|
1787
|
+
MarketplaceQueryClientProvider,
|
|
2346
1788
|
MarketplaceProvider,
|
|
2347
1789
|
useConfig,
|
|
2348
1790
|
balanceOfCollectibleOptions,
|
|
@@ -2402,8 +1844,6 @@ export {
|
|
|
2402
1844
|
fetchGenerateBuyTransaction,
|
|
2403
1845
|
generateBuyTransactionOptions,
|
|
2404
1846
|
useGenerateBuyTransaction,
|
|
2405
|
-
|
|
2406
|
-
useCancelOrder,
|
|
2407
|
-
useBuyCollectable
|
|
1847
|
+
useCancelOrder
|
|
2408
1848
|
};
|
|
2409
|
-
//# sourceMappingURL=chunk-
|
|
1849
|
+
//# sourceMappingURL=chunk-36NGHJH5.js.map
|