@0xsequence/marketplace-sdk 0.3.3 → 0.3.5
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-NII6JJGH.js → chunk-3CXEYH2I.js} +5 -3
- package/dist/chunk-3CXEYH2I.js.map +1 -0
- package/dist/{chunk-GJAKQ5Q3.js → chunk-53Q7BNZH.js} +8 -2
- package/dist/chunk-53Q7BNZH.js.map +1 -0
- package/dist/{chunk-RJK7PUJE.js → chunk-6LQST3KZ.js} +550 -288
- package/dist/chunk-6LQST3KZ.js.map +1 -0
- package/dist/{chunk-GZG2QO64.js → chunk-D3HRXVYJ.js} +72 -21
- package/dist/chunk-D3HRXVYJ.js.map +1 -0
- package/dist/{chunk-4YU2UPYH.js → chunk-FFCNYF3S.js} +61 -61
- package/dist/chunk-FFCNYF3S.js.map +1 -0
- package/dist/chunk-G2FYRJMK.js +38 -0
- package/dist/chunk-G2FYRJMK.js.map +1 -0
- package/dist/{chunk-SPW24Y7I.js → chunk-OUZ42I6B.js} +7 -2
- package/dist/chunk-OUZ42I6B.js.map +1 -0
- package/dist/chunk-T2AMWIKD.js +277 -0
- package/dist/chunk-T2AMWIKD.js.map +1 -0
- package/dist/{chunk-ZZMM3IVS.js → chunk-URTXTVOU.js} +990 -988
- package/dist/chunk-URTXTVOU.js.map +1 -0
- package/dist/{chunk-G33554LK.js → chunk-WQCWBXBM.js} +8 -16
- package/dist/chunk-WQCWBXBM.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/{marketplace.gen-BLP7822q.d.ts → marketplace.gen-jdKqutnd.d.ts} +57 -18
- package/dist/react/_internal/api/index.d.ts +4 -2
- package/dist/react/_internal/api/index.js +8 -3
- package/dist/react/_internal/index.d.ts +3 -3
- package/dist/react/_internal/index.js +9 -4
- package/dist/react/_internal/wagmi/index.js +2 -1
- package/dist/react/hooks/index.d.ts +285 -12
- package/dist/react/hooks/index.js +13 -4
- package/dist/react/index.css +29 -29
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +15 -6
- package/dist/react/ssr/index.js +55 -4
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/index.css +13 -13
- package/dist/react/ui/components/index.css.map +1 -1
- package/dist/react/ui/components/index.d.ts +2 -2
- package/dist/react/ui/components/index.js +7 -6
- package/dist/react/ui/icons/index.js +1 -1
- package/dist/react/ui/icons/index.js.map +1 -1
- package/dist/react/ui/index.css +29 -29
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +3 -3
- package/dist/react/ui/index.js +7 -6
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +3 -2
- package/dist/react/ui/styles/index.d.ts +1 -1
- package/dist/{services-C9-lvWcC.d.ts → services-C2O-7p_M.d.ts} +2 -2
- package/dist/styles/index.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -2
- package/dist/{types-QqXjNuUP.d.ts → types-BlDoGvJV.d.ts} +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -1
- package/package.json +14 -14
- package/src/react/_internal/api/marketplace.gen.ts +85 -20
- package/src/react/_internal/api/query-keys.ts +2 -0
- package/src/react/_internal/api/services.ts +4 -3
- package/src/react/_internal/api/zod-schema.ts +20 -0
- package/src/react/_internal/transaction-machine/execute-transaction.ts +307 -231
- package/src/react/_internal/transaction-machine/logger.ts +66 -0
- package/src/react/_internal/transaction-machine/useTransactionMachine.ts +69 -19
- package/src/react/_internal/wagmi/embedded.ts +2 -2
- package/src/react/hooks/index.ts +2 -0
- package/src/react/hooks/options/marketplaceConfigOptions.ts +6 -2
- package/src/react/hooks/useBuyCollectable.tsx +14 -8
- package/src/react/hooks/useCancelOrder.tsx +4 -3
- package/src/react/hooks/useCheckoutOptions.tsx +2 -2
- package/src/react/hooks/useConfig.tsx +2 -3
- package/src/react/hooks/useCountListingsForCollectible.tsx +64 -0
- package/src/react/hooks/useCountOffersForCollectible.tsx +64 -0
- package/src/react/hooks/useCreateListing.tsx +13 -14
- package/src/react/hooks/useCurrencies.tsx +9 -8
- package/src/react/hooks/useCurrency.tsx +6 -6
- package/src/react/hooks/useGenerateBuyTransaction.tsx +3 -3
- package/src/react/hooks/useMakeOffer.tsx +14 -13
- package/src/react/hooks/useRoyaltyPercentage.tsx +1 -1
- package/src/react/hooks/useSell.tsx +12 -12
- package/src/react/hooks/useTransferTokens.tsx +2 -1
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +3 -2
- package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +2 -2
- package/src/react/ui/icons/ArrowUp.tsx +1 -1
- package/src/react/ui/modals/BuyModal/_store.ts +5 -6
- package/src/react/ui/modals/BuyModal/index.tsx +70 -59
- package/src/react/ui/modals/CreateListingModal/_store.ts +1 -0
- package/src/react/ui/modals/CreateListingModal/index.tsx +24 -8
- package/src/react/ui/modals/MakeOfferModal/_store.ts +2 -0
- package/src/react/ui/modals/MakeOfferModal/index.tsx +12 -10
- package/src/react/ui/modals/SellModal/index.tsx +15 -15
- package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
- package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +1 -1
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +10 -6
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +2 -1
- package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +1 -1
- package/src/react/ui/modals/TransferModal/styles.css.ts +1 -1
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +1 -1
- package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +1 -1
- package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +7 -2
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +42 -102
- package/src/react/ui/modals/_internal/components/switchChainModal/styles.css.ts +1 -1
- package/src/react/ui/modals/_internal/components/timeAgo/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +3 -3
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts +1 -1
- package/src/react/ui/modals/modal-provider.tsx +3 -3
- package/src/utils/_internal/error/base.ts +32 -0
- package/src/utils/_internal/error/context.ts +13 -0
- package/src/utils/_internal/error/transaction.ts +369 -0
- package/src/utils/get-public-rpc-client.ts +4 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-4YU2UPYH.js.map +0 -1
- package/dist/chunk-G33554LK.js.map +0 -1
- package/dist/chunk-GJAKQ5Q3.js.map +0 -1
- package/dist/chunk-GZG2QO64.js.map +0 -1
- package/dist/chunk-NII6JJGH.js.map +0 -1
- package/dist/chunk-RJK7PUJE.js.map +0 -1
- package/dist/chunk-SPW24Y7I.js.map +0 -1
- package/dist/chunk-ZZMM3IVS.js.map +0 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { observer } from '@legendapp/state/react';
|
|
13
13
|
import { Close, Content, Overlay, Portal, Root } from '@radix-ui/react-dialog';
|
|
14
14
|
import type { TokenMetadata } from '../../../_internal';
|
|
15
|
+
import type { ModalCallbacks } from '../_internal/types';
|
|
15
16
|
import {
|
|
16
17
|
type SuccessfulPurchaseModalState,
|
|
17
18
|
successfulPurchaseModal$,
|
|
@@ -25,7 +26,6 @@ import {
|
|
|
25
26
|
dialogContent,
|
|
26
27
|
dialogOverlay,
|
|
27
28
|
} from './styles.css';
|
|
28
|
-
import type { ModalCallbacks } from '../_internal/types';
|
|
29
29
|
|
|
30
30
|
export const useSuccessfulPurchaseModal = (callbacks?: ModalCallbacks) => {
|
|
31
31
|
return {
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Box, Button, Text, TextInput } from '@0xsequence/design-system';
|
|
2
|
+
import { observable } from '@legendapp/state';
|
|
2
3
|
import { isAddress } from 'viem';
|
|
3
4
|
import { useAccount } from 'wagmi';
|
|
5
|
+
import { useCollection, useListBalances } from '../../../../..';
|
|
6
|
+
import { type CollectionType, ContractType } from '../../../../../_internal';
|
|
4
7
|
import AlertMessage from '../../../_internal/components/alertMessage';
|
|
5
8
|
import QuantityInput from '../../../_internal/components/quantityInput';
|
|
6
9
|
import { transferModal$ } from '../../_store';
|
|
7
10
|
import getMessage from '../../messages';
|
|
8
11
|
import useHandleTransfer from './useHandleTransfer';
|
|
9
|
-
import { useCollection, useListBalances } from '../../../../..';
|
|
10
|
-
import { type CollectionType, ContractType } from '../../../../../_internal';
|
|
11
12
|
|
|
12
13
|
const EnterWalletAddressView = () => {
|
|
13
14
|
const { address } = useAccount();
|
|
14
15
|
const { collectionAddress, tokenId, chainId, collectionType } =
|
|
15
16
|
transferModal$.state.get();
|
|
16
17
|
const $quantity = transferModal$.state.quantity;
|
|
18
|
+
const $invalidQuantity = observable(false);
|
|
17
19
|
const isWalletAddressValid = isAddress(
|
|
18
20
|
transferModal$.state.receiverAddress.get(),
|
|
19
21
|
);
|
|
@@ -71,9 +73,9 @@ const EnterWalletAddressView = () => {
|
|
|
71
73
|
<>
|
|
72
74
|
<QuantityInput
|
|
73
75
|
$quantity={$quantity}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
$invalidQuantity={$invalidQuantity}
|
|
77
|
+
decimals={collection?.decimals || 0}
|
|
78
|
+
maxQuantity={balanceAmount}
|
|
77
79
|
/>
|
|
78
80
|
|
|
79
81
|
<Text
|
|
@@ -90,7 +92,9 @@ const EnterWalletAddressView = () => {
|
|
|
90
92
|
|
|
91
93
|
<Button
|
|
92
94
|
onClick={handleChangeView}
|
|
93
|
-
disabled={
|
|
95
|
+
disabled={
|
|
96
|
+
!isWalletAddressValid || insufficientBalance || !$quantity.get()
|
|
97
|
+
}
|
|
94
98
|
title="Transfer"
|
|
95
99
|
label="Transfer"
|
|
96
100
|
variant="primary"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { QueryKey } from '@tanstack/react-query';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
3
|
import { ContractType } from '../../../../../../types';
|
|
4
|
+
import { InvalidContractTypeError } from '../../../../../../utils/_internal/error/transaction';
|
|
4
5
|
import { balanceQueries } from '../../../../../_internal';
|
|
5
6
|
import { useCollectible, useTransferTokens } from '../../../../../hooks';
|
|
6
7
|
import { useTransactionStatusModal } from '../../../_internal/components/transactionStatusModal';
|
|
@@ -34,7 +35,7 @@ const useHandleTransfer = () => {
|
|
|
34
35
|
collectionType !== ContractType.ERC721 &&
|
|
35
36
|
collectionType !== ContractType.ERC1155
|
|
36
37
|
) {
|
|
37
|
-
throw new
|
|
38
|
+
throw new InvalidContractTypeError(collectionType);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
if (collectionType === ContractType.ERC721) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Box, Button, Text } from '@0xsequence/design-system';
|
|
1
2
|
import { observer } from '@legendapp/state/react';
|
|
2
3
|
import AlertMessage from '../../../_internal/components/alertMessage';
|
|
3
4
|
import getMessage from '../../messages';
|
|
4
|
-
import { Box, Button, Text } from '@0xsequence/design-system';
|
|
5
5
|
|
|
6
6
|
const FollowWalletInstructionsView = observer(() => {
|
|
7
7
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dialogContent } from '../../styles/index';
|
|
2
1
|
import { atoms } from '@0xsequence/design-system';
|
|
3
2
|
import { style } from '@vanilla-extract/css';
|
|
3
|
+
import { dialogContent } from '../../styles/index';
|
|
4
4
|
|
|
5
5
|
export { closeButton, dialogOverlay } from '../../styles/modal.css';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box } from '@0xsequence/design-system';
|
|
2
2
|
import type { Observable } from '@legendapp/state';
|
|
3
|
-
import type { ActionModalState } from './store';
|
|
4
3
|
import { ActionModal } from './ActionModal';
|
|
4
|
+
import type { ActionModalState } from './store';
|
|
5
5
|
|
|
6
6
|
interface ErrorModalProps {
|
|
7
7
|
store: Observable<ActionModalState>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box, Spinner } from '@0xsequence/design-system';
|
|
2
2
|
import type { Observable } from '@legendapp/state';
|
|
3
|
-
import type { ActionModalState } from './store';
|
|
4
3
|
import { ActionModal } from './ActionModal';
|
|
4
|
+
import type { ActionModalState } from './store';
|
|
5
5
|
|
|
6
6
|
interface LoadingModalProps {
|
|
7
7
|
store: Observable<ActionModalState>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Box, Text, WarningIcon } from '@0xsequence/design-system';
|
|
1
2
|
import SvgInfoIcon from '../../../../icons/InfoIcon';
|
|
2
3
|
import { alertMessageBox, alertMessageBoxVariants } from './styles.css';
|
|
3
|
-
import { Box, Text, WarningIcon } from '@0xsequence/design-system';
|
|
4
4
|
|
|
5
5
|
type AlertMessageProps = {
|
|
6
6
|
message: string;
|
|
@@ -10,7 +10,12 @@ type AlertMessageProps = {
|
|
|
10
10
|
export default function AlertMessage({ message, type }: AlertMessageProps) {
|
|
11
11
|
return (
|
|
12
12
|
<Box className={`${alertMessageBox} ${alertMessageBoxVariants[type]}`}>
|
|
13
|
-
<Text
|
|
13
|
+
<Text
|
|
14
|
+
color="white"
|
|
15
|
+
fontSize="normal"
|
|
16
|
+
fontWeight="medium"
|
|
17
|
+
fontFamily="body"
|
|
18
|
+
>
|
|
14
19
|
{message}
|
|
15
20
|
</Text>
|
|
16
21
|
|
|
@@ -4,8 +4,8 @@ import { Box, Text } from '@0xsequence/design-system';
|
|
|
4
4
|
import type { Observable } from '@legendapp/state';
|
|
5
5
|
import { observer } from '@legendapp/state/react';
|
|
6
6
|
import { addDays, isSameDay } from 'date-fns';
|
|
7
|
-
import CalendarPopover from '../calendarPopover';
|
|
8
7
|
import { CustomSelect } from '../../../../components/_internals/custom-select/CustomSelect';
|
|
8
|
+
import CalendarPopover from '../calendarPopover';
|
|
9
9
|
|
|
10
10
|
export const PRESET_RANGES = {
|
|
11
11
|
TODAY: {
|
|
@@ -1,141 +1,76 @@
|
|
|
1
1
|
import { Box, IconButton, NumericInput } from '@0xsequence/design-system';
|
|
2
2
|
import type { Observable } from '@legendapp/state';
|
|
3
|
-
import type { Hex } from 'viem';
|
|
4
|
-
import { useCollectible } from '../../../../../hooks';
|
|
5
3
|
import SvgMinusIcon from '../../../../icons/MinusIcon';
|
|
6
4
|
import SvgPlusIcon from '../../../../icons/PlusIcon';
|
|
7
5
|
import { quantityInputWrapper } from './styles.css';
|
|
8
6
|
|
|
9
7
|
type QuantityInputProps = {
|
|
10
8
|
$quantity: Observable<string>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
$invalidQuantity: Observable<boolean>;
|
|
10
|
+
decimals: number;
|
|
11
|
+
maxQuantity: string;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export default function QuantityInput({
|
|
17
15
|
$quantity,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
$invalidQuantity,
|
|
17
|
+
decimals,
|
|
18
|
+
maxQuantity,
|
|
21
19
|
}: QuantityInputProps) {
|
|
22
|
-
const { data: collectable, isLoading: collectableLoading } = useCollectible({
|
|
23
|
-
chainId,
|
|
24
|
-
collectionAddress,
|
|
25
|
-
collectibleId,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const quantityDecimals =
|
|
29
|
-
collectable && ((collectable.decimals || 0) as number | undefined);
|
|
30
|
-
|
|
31
20
|
function handleChangeQuantity(value: string) {
|
|
32
|
-
if (!isValidInput(value)) return;
|
|
33
|
-
|
|
34
21
|
const formattedValue = formatQuantity(value);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
22
|
+
$quantity.set(formattedValue);
|
|
23
|
+
validateQuantity(formattedValue);
|
|
38
24
|
}
|
|
39
25
|
|
|
40
|
-
function
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (newQuantity !== null) {
|
|
45
|
-
$quantity.set(newQuantity);
|
|
26
|
+
function validateQuantity(value: string) {
|
|
27
|
+
if (!value || value.trim() === '' || isNaN(Number(value))) {
|
|
28
|
+
$invalidQuantity.set(true);
|
|
29
|
+
return;
|
|
46
30
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function handleDecrement() {
|
|
50
|
-
if (!isValidInput()) return;
|
|
51
31
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
$quantity.set(newQuantity);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function isValidInput(value?: string): boolean {
|
|
59
|
-
return (
|
|
60
|
-
collectable !== undefined &&
|
|
61
|
-
quantityDecimals !== undefined &&
|
|
62
|
-
(value === undefined || value !== '')
|
|
63
|
-
);
|
|
32
|
+
const numValue = Number(value);
|
|
33
|
+
$invalidQuantity.set(numValue <= 0 || numValue > Number(maxQuantity));
|
|
64
34
|
}
|
|
65
35
|
|
|
66
|
-
function formatQuantity(value: string)
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
36
|
+
function formatQuantity(value: string) {
|
|
37
|
+
if (!value || isNaN(Number(value))) {
|
|
38
|
+
return '0';
|
|
69
39
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const decimalIndex = value.indexOf('.');
|
|
73
|
-
if (
|
|
74
|
-
decimalIndex !== -1 &&
|
|
75
|
-
value.length - decimalIndex > quantityDecimals + 1
|
|
76
|
-
) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
40
|
+
if (Number(value) > Number(maxQuantity)) {
|
|
41
|
+
return maxQuantity;
|
|
79
42
|
}
|
|
80
|
-
|
|
81
43
|
return value;
|
|
82
44
|
}
|
|
83
45
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return quantityDecimals === 0
|
|
91
|
-
? '1'
|
|
92
|
-
: `1.${'0'.repeat(quantityDecimals!)}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const newValue =
|
|
96
|
-
quantityDecimals === 0
|
|
97
|
-
? (Number.parseInt(quantity) + 1).toString()
|
|
98
|
-
: (Number.parseFloat(quantity) + 1).toFixed(quantityDecimals);
|
|
99
|
-
|
|
100
|
-
return newValue;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function decrementQuantity(): string | null {
|
|
104
|
-
if (!quantity) {
|
|
105
|
-
return '1';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const newValue = Number.parseFloat(quantity) - 1;
|
|
109
|
-
if (newValue < 0) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return quantityDecimals === 0
|
|
114
|
-
? newValue.toString()
|
|
115
|
-
: newValue.toFixed(quantityDecimals);
|
|
46
|
+
function handleIncrement() {
|
|
47
|
+
const currentValue = Number(quantity) || 0;
|
|
48
|
+
const maxValue = Number(maxQuantity);
|
|
49
|
+
const newValue = Math.min(currentValue + 1, maxValue);
|
|
50
|
+
handleChangeQuantity(newValue.toString());
|
|
51
|
+
return newValue.toString();
|
|
116
52
|
}
|
|
117
53
|
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
54
|
+
function handleDecrement() {
|
|
55
|
+
const minValue = decimals ? Number(`0.${'0'.repeat(decimals - 1)}1`) : 1;
|
|
56
|
+
const currentValue = Number(quantity) || 0;
|
|
57
|
+
const newValue = Math.max(currentValue - 1, minValue);
|
|
58
|
+
const stringValue = newValue.toString();
|
|
59
|
+
handleChangeQuantity(stringValue);
|
|
60
|
+
return stringValue;
|
|
124
61
|
}
|
|
125
62
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
63
|
+
const quantity = $quantity.get();
|
|
64
|
+
const invalidQuantity = $invalidQuantity.get();
|
|
129
65
|
|
|
130
66
|
return (
|
|
131
67
|
<Box className={quantityInputWrapper}>
|
|
132
68
|
<NumericInput
|
|
133
69
|
name={'quantity'}
|
|
134
|
-
decimals={
|
|
70
|
+
decimals={decimals || 0}
|
|
135
71
|
paddingLeft={'1'}
|
|
136
72
|
label={'Enter quantity'}
|
|
137
73
|
labelLocation="top"
|
|
138
|
-
placeholder={getPlaceholder(quantityDecimals || 0)}
|
|
139
74
|
controls={
|
|
140
75
|
<Box
|
|
141
76
|
display={'flex'}
|
|
@@ -144,7 +79,7 @@ export default function QuantityInput({
|
|
|
144
79
|
marginRight={'2'}
|
|
145
80
|
>
|
|
146
81
|
<IconButton
|
|
147
|
-
disabled={Number
|
|
82
|
+
disabled={!quantity || Number(quantity) <= 0}
|
|
148
83
|
onClick={handleDecrement}
|
|
149
84
|
background={'buttonGlass'}
|
|
150
85
|
size="xs"
|
|
@@ -160,10 +95,15 @@ export default function QuantityInput({
|
|
|
160
95
|
</Box>
|
|
161
96
|
}
|
|
162
97
|
numeric={true}
|
|
163
|
-
value={
|
|
98
|
+
value={quantity}
|
|
164
99
|
onChange={(e) => handleChangeQuantity(e.target.value)}
|
|
165
100
|
width={'full'}
|
|
166
101
|
/>
|
|
102
|
+
{invalidQuantity && (
|
|
103
|
+
<Box color="negative" fontSize="small">
|
|
104
|
+
{invalidQuantity}
|
|
105
|
+
</Box>
|
|
106
|
+
)}
|
|
167
107
|
</Box>
|
|
168
108
|
);
|
|
169
109
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { dialogContent } from '../../../../styles/index';
|
|
2
1
|
import { atoms } from '@0xsequence/design-system';
|
|
3
2
|
import { style } from '@vanilla-extract/css';
|
|
4
3
|
import { styleVariants } from '@vanilla-extract/css';
|
|
5
4
|
import { globalStyle } from '@vanilla-extract/css';
|
|
5
|
+
import { dialogContent } from '../../../../styles/index';
|
|
6
6
|
|
|
7
7
|
export { closeButton, dialogOverlay } from '../../../../styles/modal.css';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Box, Image, Skeleton, Text } from '@0xsequence/design-system';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
3
|
import { useCollectible } from '../../../../../hooks';
|
|
4
|
-
import { tokenPreview } from './styles.css';
|
|
5
4
|
import ChessTileImage from '../../../../images/chess-tile.png';
|
|
5
|
+
import { tokenPreview } from './styles.css';
|
|
6
6
|
|
|
7
7
|
type TokenPreviewProps = {
|
|
8
8
|
collectionName?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChainId, networks } from '@0xsequence/network';
|
|
2
|
-
import { truncateMiddle } from '../../../../../../utils';
|
|
3
|
-
import SvgPositiveCircleIcon from '../../../../icons/PositiveCircleIcon';
|
|
4
1
|
import { Box, Spinner, Text } from '@0xsequence/design-system';
|
|
2
|
+
import { type ChainId, networks } from '@0xsequence/network';
|
|
5
3
|
import type { Hex } from 'viem';
|
|
4
|
+
import { truncateMiddle } from '../../../../../../utils';
|
|
5
|
+
import SvgPositiveCircleIcon from '../../../../icons/PositiveCircleIcon';
|
|
6
6
|
|
|
7
7
|
type TransactionFooterProps = {
|
|
8
8
|
transactionHash: Hex;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Box, Image, NetworkImage, Text } from '@0xsequence/design-system';
|
|
2
|
+
import type { TokenMetadata } from '@0xsequence/metadata';
|
|
2
3
|
import { observer } from '@legendapp/state/react';
|
|
3
4
|
import { type Hex, formatUnits } from 'viem';
|
|
4
5
|
import type { Price } from '../../../../../../types';
|
|
5
6
|
import { useCollection } from '../../../../../hooks';
|
|
7
|
+
import ChessTileImage from '../../../../images/chess-tile.png';
|
|
6
8
|
import TimeAgo from '../timeAgo';
|
|
7
9
|
import { transactionStatusModal$ } from '../transactionStatusModal/store';
|
|
8
10
|
import { useTransactionPreviewTitle } from './useTransactionPreviewTitle';
|
|
9
|
-
import type { TokenMetadata } from '@0xsequence/metadata';
|
|
10
|
-
import ChessTileImage from '../../../../images/chess-tile.png';
|
|
11
11
|
|
|
12
12
|
type TransactionPreviewProps = {
|
|
13
13
|
price?: Price;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Skeleton,
|
|
5
5
|
Text,
|
|
6
6
|
} from '@0xsequence/design-system';
|
|
7
|
+
import type { ChainId } from '@0xsequence/network';
|
|
7
8
|
import { observer } from '@legendapp/state/react';
|
|
8
9
|
import { Close, Content, Overlay, Portal, Root } from '@radix-ui/react-dialog';
|
|
9
10
|
import type { QueryKey } from '@tanstack/react-query';
|
|
@@ -26,7 +27,6 @@ import {
|
|
|
26
27
|
dialogOverlay,
|
|
27
28
|
transactionStatusModalContent,
|
|
28
29
|
} from './styles.css';
|
|
29
|
-
import { ChainId } from '@0xsequence/network';
|
|
30
30
|
|
|
31
31
|
export type ShowTransactionStatusModalArgs = {
|
|
32
32
|
hash: Hex;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { atoms } from '@0xsequence/design-system';
|
|
2
|
-
import { dialogContent } from '../../../../styles/index';
|
|
3
2
|
import { style } from '@vanilla-extract/css';
|
|
3
|
+
import { dialogContent } from '../../../../styles/index';
|
|
4
4
|
|
|
5
5
|
export { closeButton, dialogOverlay } from '../../../../styles/modal.css';
|
|
6
6
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { observer } from '@legendapp/state/react';
|
|
2
|
-
import SwitchChainModal from './_internal/components/switchChainModal';
|
|
3
|
-
import TransactionStatusModal from './_internal/components/transactionStatusModal';
|
|
4
2
|
import { AccountModal } from './Account';
|
|
3
|
+
import { BuyModal } from './BuyModal';
|
|
5
4
|
import { CreateListingModal } from './CreateListingModal';
|
|
6
5
|
import { MakeOfferModal } from './MakeOfferModal';
|
|
7
6
|
import { SellModal } from './SellModal';
|
|
8
7
|
import SuccessfulPurchaseModal from './SuccessfulPurchaseModal';
|
|
9
8
|
import { TransferModal } from './TransferModal';
|
|
9
|
+
import SwitchChainModal from './_internal/components/switchChainModal';
|
|
10
|
+
import TransactionStatusModal from './_internal/components/transactionStatusModal';
|
|
10
11
|
import { _accountModalOpen$ } from './_internal/stores/accountModal';
|
|
11
|
-
import { BuyModal } from './BuyModal';
|
|
12
12
|
|
|
13
13
|
export const ModalProvider = observer(() => {
|
|
14
14
|
return (
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type ErrorType<name extends string = 'Error'> = Error & { name: name };
|
|
2
|
+
|
|
3
|
+
export type Compute<type> = { [key in keyof type]: type[key] } & unknown;
|
|
4
|
+
|
|
5
|
+
type BaseErrorOptions = Compute<
|
|
6
|
+
{ details?: string | undefined } | { cause: BaseError | Error }
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export class BaseError extends Error {
|
|
10
|
+
details: string;
|
|
11
|
+
shortMessage: string;
|
|
12
|
+
|
|
13
|
+
name = 'MarketplaceSdkBaseError';
|
|
14
|
+
|
|
15
|
+
constructor(shortMessage: string, options: BaseErrorOptions = {}) {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
const details = 'details' in options ? options.details : '';
|
|
19
|
+
this.message = [
|
|
20
|
+
shortMessage || 'An error occurred.',
|
|
21
|
+
'',
|
|
22
|
+
...(details ? [`Details: ${details}`] : []),
|
|
23
|
+
].join('\n');
|
|
24
|
+
|
|
25
|
+
if ('cause' in options && options.cause) {
|
|
26
|
+
this.cause = options.cause;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.details = details || '';
|
|
30
|
+
this.shortMessage = shortMessage;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseError } from './base';
|
|
2
|
+
|
|
3
|
+
export type MarketplaceSdkProviderNotFoundErrorType =
|
|
4
|
+
MarketplaceSdkProviderNotFoundError & {
|
|
5
|
+
name: 'MarketplaceSDKProviderNotFoundError';
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class MarketplaceSdkProviderNotFoundError extends BaseError {
|
|
9
|
+
override name = 'MarketplaceSDKProviderNotFoundError';
|
|
10
|
+
constructor() {
|
|
11
|
+
super('`useConfig` must be used within `MarketplaceSdkProvider`.');
|
|
12
|
+
}
|
|
13
|
+
}
|