@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.
Files changed (123) hide show
  1. package/dist/{chunk-NII6JJGH.js → chunk-3CXEYH2I.js} +5 -3
  2. package/dist/chunk-3CXEYH2I.js.map +1 -0
  3. package/dist/{chunk-GJAKQ5Q3.js → chunk-53Q7BNZH.js} +8 -2
  4. package/dist/chunk-53Q7BNZH.js.map +1 -0
  5. package/dist/{chunk-RJK7PUJE.js → chunk-6LQST3KZ.js} +550 -288
  6. package/dist/chunk-6LQST3KZ.js.map +1 -0
  7. package/dist/{chunk-GZG2QO64.js → chunk-D3HRXVYJ.js} +72 -21
  8. package/dist/chunk-D3HRXVYJ.js.map +1 -0
  9. package/dist/{chunk-4YU2UPYH.js → chunk-FFCNYF3S.js} +61 -61
  10. package/dist/chunk-FFCNYF3S.js.map +1 -0
  11. package/dist/chunk-G2FYRJMK.js +38 -0
  12. package/dist/chunk-G2FYRJMK.js.map +1 -0
  13. package/dist/{chunk-SPW24Y7I.js → chunk-OUZ42I6B.js} +7 -2
  14. package/dist/chunk-OUZ42I6B.js.map +1 -0
  15. package/dist/chunk-T2AMWIKD.js +277 -0
  16. package/dist/chunk-T2AMWIKD.js.map +1 -0
  17. package/dist/{chunk-ZZMM3IVS.js → chunk-URTXTVOU.js} +990 -988
  18. package/dist/chunk-URTXTVOU.js.map +1 -0
  19. package/dist/{chunk-G33554LK.js → chunk-WQCWBXBM.js} +8 -16
  20. package/dist/chunk-WQCWBXBM.js.map +1 -0
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +4 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/{marketplace.gen-BLP7822q.d.ts → marketplace.gen-jdKqutnd.d.ts} +57 -18
  25. package/dist/react/_internal/api/index.d.ts +4 -2
  26. package/dist/react/_internal/api/index.js +8 -3
  27. package/dist/react/_internal/index.d.ts +3 -3
  28. package/dist/react/_internal/index.js +9 -4
  29. package/dist/react/_internal/wagmi/index.js +2 -1
  30. package/dist/react/hooks/index.d.ts +285 -12
  31. package/dist/react/hooks/index.js +13 -4
  32. package/dist/react/index.css +29 -29
  33. package/dist/react/index.css.map +1 -1
  34. package/dist/react/index.d.ts +4 -4
  35. package/dist/react/index.js +15 -6
  36. package/dist/react/ssr/index.js +55 -4
  37. package/dist/react/ssr/index.js.map +1 -1
  38. package/dist/react/ui/components/index.css +13 -13
  39. package/dist/react/ui/components/index.css.map +1 -1
  40. package/dist/react/ui/components/index.d.ts +2 -2
  41. package/dist/react/ui/components/index.js +7 -6
  42. package/dist/react/ui/icons/index.js +1 -1
  43. package/dist/react/ui/icons/index.js.map +1 -1
  44. package/dist/react/ui/index.css +29 -29
  45. package/dist/react/ui/index.css.map +1 -1
  46. package/dist/react/ui/index.d.ts +3 -3
  47. package/dist/react/ui/index.js +7 -6
  48. package/dist/react/ui/modals/_internal/components/actionModal/index.js +3 -2
  49. package/dist/react/ui/styles/index.d.ts +1 -1
  50. package/dist/{services-C9-lvWcC.d.ts → services-C2O-7p_M.d.ts} +2 -2
  51. package/dist/styles/index.d.ts +1 -1
  52. package/dist/types/index.d.ts +2 -2
  53. package/dist/types/index.js +3 -2
  54. package/dist/{types-QqXjNuUP.d.ts → types-BlDoGvJV.d.ts} +1 -1
  55. package/dist/utils/index.d.ts +2 -2
  56. package/dist/utils/index.js +2 -1
  57. package/package.json +14 -14
  58. package/src/react/_internal/api/marketplace.gen.ts +85 -20
  59. package/src/react/_internal/api/query-keys.ts +2 -0
  60. package/src/react/_internal/api/services.ts +4 -3
  61. package/src/react/_internal/api/zod-schema.ts +20 -0
  62. package/src/react/_internal/transaction-machine/execute-transaction.ts +307 -231
  63. package/src/react/_internal/transaction-machine/logger.ts +66 -0
  64. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +69 -19
  65. package/src/react/_internal/wagmi/embedded.ts +2 -2
  66. package/src/react/hooks/index.ts +2 -0
  67. package/src/react/hooks/options/marketplaceConfigOptions.ts +6 -2
  68. package/src/react/hooks/useBuyCollectable.tsx +14 -8
  69. package/src/react/hooks/useCancelOrder.tsx +4 -3
  70. package/src/react/hooks/useCheckoutOptions.tsx +2 -2
  71. package/src/react/hooks/useConfig.tsx +2 -3
  72. package/src/react/hooks/useCountListingsForCollectible.tsx +64 -0
  73. package/src/react/hooks/useCountOffersForCollectible.tsx +64 -0
  74. package/src/react/hooks/useCreateListing.tsx +13 -14
  75. package/src/react/hooks/useCurrencies.tsx +9 -8
  76. package/src/react/hooks/useCurrency.tsx +6 -6
  77. package/src/react/hooks/useGenerateBuyTransaction.tsx +3 -3
  78. package/src/react/hooks/useMakeOffer.tsx +14 -13
  79. package/src/react/hooks/useRoyaltyPercentage.tsx +1 -1
  80. package/src/react/hooks/useSell.tsx +12 -12
  81. package/src/react/hooks/useTransferTokens.tsx +2 -1
  82. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +3 -2
  83. package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +2 -2
  84. package/src/react/ui/icons/ArrowUp.tsx +1 -1
  85. package/src/react/ui/modals/BuyModal/_store.ts +5 -6
  86. package/src/react/ui/modals/BuyModal/index.tsx +70 -59
  87. package/src/react/ui/modals/CreateListingModal/_store.ts +1 -0
  88. package/src/react/ui/modals/CreateListingModal/index.tsx +24 -8
  89. package/src/react/ui/modals/MakeOfferModal/_store.ts +2 -0
  90. package/src/react/ui/modals/MakeOfferModal/index.tsx +12 -10
  91. package/src/react/ui/modals/SellModal/index.tsx +15 -15
  92. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
  93. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +1 -1
  94. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +10 -6
  95. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +2 -1
  96. package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +1 -1
  97. package/src/react/ui/modals/TransferModal/styles.css.ts +1 -1
  98. package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +1 -1
  99. package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +1 -1
  100. package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +7 -2
  101. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +1 -1
  102. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +42 -102
  103. package/src/react/ui/modals/_internal/components/switchChainModal/styles.css.ts +1 -1
  104. package/src/react/ui/modals/_internal/components/timeAgo/index.tsx +1 -1
  105. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
  106. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +3 -3
  107. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +2 -2
  108. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +1 -1
  109. package/src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts +1 -1
  110. package/src/react/ui/modals/modal-provider.tsx +3 -3
  111. package/src/utils/_internal/error/base.ts +32 -0
  112. package/src/utils/_internal/error/context.ts +13 -0
  113. package/src/utils/_internal/error/transaction.ts +369 -0
  114. package/src/utils/get-public-rpc-client.ts +4 -1
  115. package/tsconfig.tsbuildinfo +1 -1
  116. package/dist/chunk-4YU2UPYH.js.map +0 -1
  117. package/dist/chunk-G33554LK.js.map +0 -1
  118. package/dist/chunk-GJAKQ5Q3.js.map +0 -1
  119. package/dist/chunk-GZG2QO64.js.map +0 -1
  120. package/dist/chunk-NII6JJGH.js.map +0 -1
  121. package/dist/chunk-RJK7PUJE.js.map +0 -1
  122. package/dist/chunk-SPW24Y7I.js.map +0 -1
  123. 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
- chainId={chainId}
75
- collectionAddress={collectionAddress}
76
- collectibleId={tokenId}
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={!isWalletAddressValid || insufficientBalance}
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 Error('Invalid contract type');
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 color="white" fontSize="normal" fontWeight="medium" fontFamily="body">
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
- chainId: string;
12
- collectionAddress: Hex;
13
- collectibleId: string;
9
+ $invalidQuantity: Observable<boolean>;
10
+ decimals: number;
11
+ maxQuantity: string;
14
12
  };
15
13
 
16
14
  export default function QuantityInput({
17
15
  $quantity,
18
- chainId,
19
- collectionAddress,
20
- collectibleId,
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
- if (formattedValue !== null) {
36
- $quantity.set(formattedValue);
37
- }
22
+ $quantity.set(formattedValue);
23
+ validateQuantity(formattedValue);
38
24
  }
39
25
 
40
- function handleIncrement() {
41
- if (!isValidInput()) return;
42
-
43
- const newQuantity = incrementQuantity();
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 newQuantity = decrementQuantity();
53
- if (newQuantity !== null) {
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): string | null {
67
- if (quantityDecimals === 0 && value.includes('.')) {
68
- return null;
36
+ function formatQuantity(value: string) {
37
+ if (!value || isNaN(Number(value))) {
38
+ return '0';
69
39
  }
70
-
71
- if (quantityDecimals && quantityDecimals > 0) {
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
- const quantity = $quantity.get();
85
-
86
- function incrementQuantity(): string | null {
87
- if (!isValidInput()) return null;
88
-
89
- if (!quantity) {
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 getPlaceholder(decimals: number) {
119
- if (decimals === 0) {
120
- return '0';
121
- } else {
122
- return '0.' + '0'.repeat(decimals);
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
- if (collectableLoading) {
127
- return null;
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={quantityDecimals || 0}
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.parseFloat(quantity) === 0 || !quantity}
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={$quantity.get()}
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,6 +1,6 @@
1
1
  import { Box, Text } from '@0xsequence/design-system';
2
2
  import { formatDistanceToNow } from 'date-fns';
3
- import { useState, useEffect } from 'react';
3
+ import { useEffect, useState } from 'react';
4
4
 
5
5
  type TimeAgoProps = {
6
6
  date: Date;
@@ -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
+ }