@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,140 +0,0 @@
|
|
|
1
|
-
import { useSelectPaymentModal } from '@0xsequence/kit-checkout';
|
|
2
|
-
import type { Hash } from 'viem';
|
|
3
|
-
import { useAccount, useSwitchChain } from 'wagmi';
|
|
4
|
-
import {
|
|
5
|
-
NoMarketplaceConfigError,
|
|
6
|
-
NoWalletConnectedError,
|
|
7
|
-
TransactionError,
|
|
8
|
-
} from '../../../utils/_internal/error/transaction';
|
|
9
|
-
import { useConfig, useMarketplaceConfig } from '../../hooks';
|
|
10
|
-
import { useSwitchChainModal } from '../../ui/modals/_internal/components/switchChainModal';
|
|
11
|
-
import {
|
|
12
|
-
type Input,
|
|
13
|
-
type TransactionConfig,
|
|
14
|
-
TransactionMachine,
|
|
15
|
-
} from './execute-transaction';
|
|
16
|
-
|
|
17
|
-
import { useWallet } from './useWallet';
|
|
18
|
-
export type UseTransactionMachineConfig = Omit<
|
|
19
|
-
TransactionConfig,
|
|
20
|
-
'sdkConfig' | 'marketplaceConfig' | 'walletKind' | 'chains'
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export const useTransactionMachine = ({
|
|
24
|
-
config,
|
|
25
|
-
enabled,
|
|
26
|
-
onSuccess,
|
|
27
|
-
onError,
|
|
28
|
-
onTransactionSent,
|
|
29
|
-
onApprovalSuccess,
|
|
30
|
-
onPaymentModalLoaded,
|
|
31
|
-
}: {
|
|
32
|
-
config: UseTransactionMachineConfig;
|
|
33
|
-
enabled: boolean;
|
|
34
|
-
onSuccess?: (hash: Hash) => void;
|
|
35
|
-
onError?: (error: TransactionError) => void;
|
|
36
|
-
onTransactionSent?: (
|
|
37
|
-
hash?: Hash,
|
|
38
|
-
orderId?: string,
|
|
39
|
-
isApproval?: boolean,
|
|
40
|
-
) => void;
|
|
41
|
-
onApprovalSuccess?: (hash: Hash) => void;
|
|
42
|
-
onPaymentModalLoaded?: () => void;
|
|
43
|
-
}) => {
|
|
44
|
-
const { show: showSwitchChainModal } = useSwitchChainModal();
|
|
45
|
-
const sdkConfig = useConfig();
|
|
46
|
-
const {
|
|
47
|
-
data: marketplaceConfig,
|
|
48
|
-
error: marketplaceError,
|
|
49
|
-
isLoading: marketplaceConfigIsLoading,
|
|
50
|
-
} = useMarketplaceConfig();
|
|
51
|
-
const { openSelectPaymentModal } = useSelectPaymentModal();
|
|
52
|
-
const { chains } = useSwitchChain();
|
|
53
|
-
|
|
54
|
-
const { isConnected } = useAccount();
|
|
55
|
-
const {
|
|
56
|
-
wallet: walletInstance,
|
|
57
|
-
isLoading: walletClientIsLoading,
|
|
58
|
-
isError: walletClientIsError,
|
|
59
|
-
} = useWallet();
|
|
60
|
-
|
|
61
|
-
if (!enabled) return { machine: null, error: null, isLoading: false };
|
|
62
|
-
|
|
63
|
-
if (!isConnected) {
|
|
64
|
-
// No wallet connected, TODO: add some sort of state for this
|
|
65
|
-
return { machine: null, error: null, isLoading: false };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (walletClientIsLoading || marketplaceConfigIsLoading) {
|
|
69
|
-
return { machine: null, error: null, isLoading: true };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (marketplaceError) {
|
|
73
|
-
const error = new TransactionError('Marketplace config error', {
|
|
74
|
-
cause: marketplaceError,
|
|
75
|
-
});
|
|
76
|
-
onError?.(error);
|
|
77
|
-
return { machine: null, error };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (walletClientIsError) {
|
|
81
|
-
const error = new NoWalletConnectedError();
|
|
82
|
-
onError?.(error);
|
|
83
|
-
return { machine: null, error };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!marketplaceConfig) {
|
|
87
|
-
const error = new NoMarketplaceConfigError();
|
|
88
|
-
onError?.(error);
|
|
89
|
-
return { machine: null, error };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const machine = new TransactionMachine(
|
|
93
|
-
{
|
|
94
|
-
config: {
|
|
95
|
-
sdkConfig,
|
|
96
|
-
marketplaceConfig,
|
|
97
|
-
chains,
|
|
98
|
-
...config,
|
|
99
|
-
},
|
|
100
|
-
onSuccess,
|
|
101
|
-
onTransactionSent,
|
|
102
|
-
onApprovalSuccess,
|
|
103
|
-
},
|
|
104
|
-
walletInstance,
|
|
105
|
-
openSelectPaymentModal,
|
|
106
|
-
async () =>
|
|
107
|
-
new Promise((resolve, reject) => {
|
|
108
|
-
showSwitchChainModal({
|
|
109
|
-
chainIdToSwitchTo: Number(config.chainId),
|
|
110
|
-
onSuccess: resolve,
|
|
111
|
-
onError: reject,
|
|
112
|
-
onClose: reject,
|
|
113
|
-
});
|
|
114
|
-
}),
|
|
115
|
-
onPaymentModalLoaded,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
machine: {
|
|
120
|
-
getTransactionSteps: async (props: Input) => {
|
|
121
|
-
try {
|
|
122
|
-
return await machine.getTransactionSteps(props);
|
|
123
|
-
} catch (e) {
|
|
124
|
-
const error = e as TransactionError;
|
|
125
|
-
onError?.(error);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
start: async (props: Input) => {
|
|
129
|
-
try {
|
|
130
|
-
await machine.start(props);
|
|
131
|
-
} catch (e) {
|
|
132
|
-
const error = e as TransactionError;
|
|
133
|
-
onError?.(error);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
error: null,
|
|
138
|
-
isLoading: false,
|
|
139
|
-
};
|
|
140
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Hash, Hex } from 'viem';
|
|
2
|
-
import type { TransactionErrorTypes } from '../../utils/_internal/error/transaction';
|
|
3
|
-
import {
|
|
4
|
-
type BuyInput,
|
|
5
|
-
TransactionType,
|
|
6
|
-
} from '../_internal/transaction-machine/execute-transaction';
|
|
7
|
-
import {
|
|
8
|
-
type UseTransactionMachineConfig,
|
|
9
|
-
useTransactionMachine,
|
|
10
|
-
} from '../_internal/transaction-machine/useTransactionMachine';
|
|
11
|
-
import { useCallback } from 'react';
|
|
12
|
-
|
|
13
|
-
type UseBuyOrderError = TransactionErrorTypes;
|
|
14
|
-
|
|
15
|
-
interface UseBuyOrderArgs
|
|
16
|
-
extends Omit<UseTransactionMachineConfig, 'type' | 'orderbookKind'> {
|
|
17
|
-
onSuccess?: (hash: Hash) => void;
|
|
18
|
-
onError?: (error: UseBuyOrderError) => void;
|
|
19
|
-
onTransactionSent?: (hash?: Hex) => void;
|
|
20
|
-
setPaymentLoadingModalOpen: (value: boolean) => void;
|
|
21
|
-
onPaymentModalLoaded: () => void;
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const useBuyCollectable = ({
|
|
26
|
-
onSuccess,
|
|
27
|
-
onError,
|
|
28
|
-
onTransactionSent,
|
|
29
|
-
setPaymentLoadingModalOpen,
|
|
30
|
-
onPaymentModalLoaded,
|
|
31
|
-
enabled,
|
|
32
|
-
...config
|
|
33
|
-
}: UseBuyOrderArgs) => {
|
|
34
|
-
const machineConfig = {
|
|
35
|
-
...config,
|
|
36
|
-
type: TransactionType.BUY,
|
|
37
|
-
};
|
|
38
|
-
const { machine, error, isLoading } = useTransactionMachine({
|
|
39
|
-
config: machineConfig,
|
|
40
|
-
enabled,
|
|
41
|
-
onSuccess,
|
|
42
|
-
onError,
|
|
43
|
-
onTransactionSent,
|
|
44
|
-
onPaymentModalLoaded,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const buy = useCallback(
|
|
48
|
-
(props: BuyInput) => {
|
|
49
|
-
if (!machine || isLoading) return;
|
|
50
|
-
setPaymentLoadingModalOpen(true);
|
|
51
|
-
machine.start(props);
|
|
52
|
-
},
|
|
53
|
-
[setPaymentLoadingModalOpen, machine],
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
buy,
|
|
58
|
-
isLoading,
|
|
59
|
-
error,
|
|
60
|
-
};
|
|
61
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|