@0xsequence/marketplace-sdk 0.1.0 → 0.2.0

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 (122) hide show
  1. package/.ctirc +32 -0
  2. package/dist/{chunk-TZGLKJRF.js → chunk-4E34HVSA.js} +2 -2
  3. package/dist/chunk-5EOVZAKT.js +1325 -0
  4. package/dist/chunk-5EOVZAKT.js.map +1 -0
  5. package/dist/{chunk-RNUHUVLC.js → chunk-6JWGELXL.js} +1 -1
  6. package/dist/chunk-6JWGELXL.js.map +1 -0
  7. package/dist/{chunk-SNOEEUPZ.js → chunk-CSN7YD5Q.js} +2 -2
  8. package/dist/chunk-CSN7YD5Q.js.map +1 -0
  9. package/dist/{chunk-G3YU4NQ2.js → chunk-FCQCNLFZ.js} +1 -1
  10. package/dist/chunk-FCQCNLFZ.js.map +1 -0
  11. package/dist/{chunk-HGBEC3WX.js → chunk-GZIA25G4.js} +1 -1
  12. package/dist/chunk-GZIA25G4.js.map +1 -0
  13. package/dist/{chunk-GNB736ZE.js → chunk-MD4JHPMH.js} +318 -261
  14. package/dist/chunk-MD4JHPMH.js.map +1 -0
  15. package/dist/{chunk-EDTC7UES.js → chunk-NII6JJGH.js} +9 -4
  16. package/dist/chunk-NII6JJGH.js.map +1 -0
  17. package/dist/{chunk-BBB3XUB4.js → chunk-PE2LLUTJ.js} +1 -1
  18. package/dist/chunk-PE2LLUTJ.js.map +1 -0
  19. package/dist/{chunk-7CL54NCX.js → chunk-Q2BVDQ3G.js} +1 -1
  20. package/dist/chunk-Q2BVDQ3G.js.map +1 -0
  21. package/dist/{chunk-3TYUQEFM.js → chunk-VEX7FDL6.js} +2 -2
  22. package/dist/chunk-VEX7FDL6.js.map +1 -0
  23. package/dist/index.js +4 -4
  24. package/dist/react/_internal/api/index.d.ts +1 -1
  25. package/dist/react/_internal/api/index.js +1 -1
  26. package/dist/react/_internal/index.d.ts +2 -2
  27. package/dist/react/_internal/index.js +8 -8
  28. package/dist/react/_internal/wagmi/index.d.ts +2 -2
  29. package/dist/react/_internal/wagmi/index.js +1 -1
  30. package/dist/react/hooks/index.d.ts +336 -10
  31. package/dist/react/hooks/index.js +26 -20
  32. package/dist/react/index.d.ts +5 -5
  33. package/dist/react/index.js +34 -28
  34. package/dist/react/ssr/index.d.ts +24 -24
  35. package/dist/react/ssr/index.js +11 -4
  36. package/dist/react/ssr/index.js.map +1 -1
  37. package/dist/react/ui/icons/index.js +2 -2
  38. package/dist/react/ui/index.d.ts +43 -38
  39. package/dist/react/ui/index.js +9 -9
  40. package/dist/react/ui/modals/_internal/components/actionModal/index.js +4 -4
  41. package/dist/{services-BIwQ1C1c.d.ts → services-Dei25J6_.d.ts} +1 -1
  42. package/dist/styles/index.js +1 -1
  43. package/dist/types/index.js +3 -3
  44. package/dist/utils/abi/clients/index.js +1 -1
  45. package/dist/utils/index.d.ts +1 -1
  46. package/dist/utils/index.js +1 -1
  47. package/package.json +18 -25
  48. package/src/react/_internal/api/marketplace.gen.ts +4 -1
  49. package/src/react/_internal/types.ts +1 -1
  50. package/src/react/_internal/wagmi/create-config.ts +9 -3
  51. package/src/react/_internal/wagmi/embedded.ts +1 -1
  52. package/src/react/_internal/wagmi/universal.ts +1 -1
  53. package/src/react/hooks/index.ts +2 -0
  54. package/src/react/hooks/options/marketplaceConfigOptions.ts +2 -2
  55. package/src/react/hooks/useBalanceOfCollectible.tsx +10 -9
  56. package/src/react/hooks/useCheckoutOptions.tsx +63 -0
  57. package/src/react/hooks/useCollectible.tsx +4 -4
  58. package/src/react/hooks/useCollection.tsx +30 -30
  59. package/src/react/hooks/useCountOfCollectables.tsx +52 -52
  60. package/src/react/hooks/useCurrencies.tsx +60 -60
  61. package/src/react/hooks/useFilters.tsx +4 -4
  62. package/src/react/hooks/useFloorOrder.tsx +4 -4
  63. package/src/react/hooks/useGenerateListingTransaction.tsx +8 -7
  64. package/src/react/hooks/useGenerateOfferTransaction.tsx +5 -5
  65. package/src/react/hooks/useGenerateSellTransaction.tsx +4 -4
  66. package/src/react/hooks/useHighestOffer.tsx +4 -4
  67. package/src/react/hooks/useListBalances.tsx +4 -4
  68. package/src/react/hooks/useListCollectibles.tsx +4 -4
  69. package/src/react/hooks/useListOffersForCollectible.tsx +5 -4
  70. package/src/react/hooks/useLowestListing.tsx +4 -4
  71. package/src/react/hooks/useRoyaltyPercentage.tsx +6 -6
  72. package/src/react/hooks/useTransferTokens.tsx +1 -1
  73. package/src/react/provider.tsx +1 -1
  74. package/src/react/ssr/create-ssr-client.ts +1 -1
  75. package/src/react/ui/modals/CreateListingModal/_store.ts +37 -38
  76. package/src/react/ui/modals/CreateListingModal/index.tsx +152 -131
  77. package/src/react/ui/modals/MakeOfferModal/_store.ts +35 -37
  78. package/src/react/ui/modals/MakeOfferModal/index.tsx +25 -4
  79. package/src/react/ui/modals/SellModal/_store.ts +48 -51
  80. package/src/react/ui/modals/SellModal/index.tsx +27 -6
  81. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
  82. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +14 -14
  83. package/src/react/ui/modals/TransferModal/_store.ts +11 -11
  84. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +92 -90
  85. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +114 -0
  86. package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +0 -96
  87. package/src/react/ui/modals/TransferModal/index.tsx +24 -3
  88. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -1
  89. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -3
  90. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +2 -2
  91. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +4 -4
  92. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +1 -1
  93. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +4 -4
  94. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +4 -4
  95. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
  96. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +5 -3
  97. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +3 -3
  98. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +35 -2
  99. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +10 -2
  100. package/src/types/api-types.ts +2 -2
  101. package/src/types/callbacks.ts +51 -0
  102. package/src/types/types.ts +1 -1
  103. package/src/utils/get-public-rpc-client.ts +1 -1
  104. package/tsconfig.json +24 -0
  105. package/tsconfig.tsbuildinfo +1 -0
  106. package/tsup.config.ts +35 -0
  107. package/README.md +0 -8
  108. package/dist/chunk-3TYUQEFM.js.map +0 -1
  109. package/dist/chunk-7CL54NCX.js.map +0 -1
  110. package/dist/chunk-BBB3XUB4.js.map +0 -1
  111. package/dist/chunk-EDTC7UES.js.map +0 -1
  112. package/dist/chunk-G3YU4NQ2.js.map +0 -1
  113. package/dist/chunk-GNB736ZE.js.map +0 -1
  114. package/dist/chunk-HGBEC3WX.js.map +0 -1
  115. package/dist/chunk-ITJEOCDV.js +0 -1006
  116. package/dist/chunk-ITJEOCDV.js.map +0 -1
  117. package/dist/chunk-M4MXVMAM.js +0 -271
  118. package/dist/chunk-M4MXVMAM.js.map +0 -1
  119. package/dist/chunk-RNUHUVLC.js.map +0 -1
  120. package/dist/chunk-SNOEEUPZ.js.map +0 -1
  121. package/dist/{chunk-TZGLKJRF.js.map → chunk-4E34HVSA.js.map} +0 -0
  122. package/dist/{create-config-Cto2ehcz.d.ts → create-config-CgtmCzvb.d.ts} +1 -1
@@ -1,147 +1,168 @@
1
- import { Box } from '@0xsequence/design-system';
2
- import { ContractType } from '@internal';
3
- import { Show, observer } from '@legendapp/state/react';
4
- import type { Hex } from 'viem';
5
- import { useAccount } from 'wagmi';
6
- import type { Messages } from '../../../../types/messages';
1
+ import { Box } from "@0xsequence/design-system";
2
+ import { Show, observer } from "@legendapp/state/react";
3
+ import type { Hex } from "viem";
4
+ import { useAccount } from "wagmi";
7
5
  import {
8
- ActionModal,
9
- type ActionModalProps,
10
- } from '../_internal/components/actionModal/ActionModal';
11
- import ExpirationDateSelect from '../_internal/components/expirationDateSelect';
12
- import FloorPriceText from '../_internal/components/floorPriceText';
13
- import PriceInput from '../_internal/components/priceInput';
14
- import QuantityInput from '../_internal/components/quantityInput';
15
- import { useSwitchChainModal } from '../_internal/components/switchChainModal';
16
- import TokenPreview from '../_internal/components/tokenPreview';
17
- import TransactionDetails from '../_internal/components/transactionDetails';
18
- import { createListingModal$, useHydrate } from './_store';
6
+ ActionModal,
7
+ type ActionModalProps,
8
+ } from "../_internal/components/actionModal/ActionModal";
9
+ import ExpirationDateSelect from "../_internal/components/expirationDateSelect";
10
+ import FloorPriceText from "../_internal/components/floorPriceText";
11
+ import PriceInput from "../_internal/components/priceInput";
12
+ import QuantityInput from "../_internal/components/quantityInput";
13
+ import { useSwitchChainModal } from "../_internal/components/switchChainModal";
14
+ import TokenPreview from "../_internal/components/tokenPreview";
15
+ import TransactionDetails from "../_internal/components/transactionDetails";
16
+ import { createListingModal$, useHydrate } from "./_store";
17
+ import {
18
+ CreateListingErrorCallbacks,
19
+ CreateListingSuccessCallbacks,
20
+ } from "../../../../types/callbacks";
21
+ import { ContractType } from "../../../_internal";
19
22
 
20
23
  export type ShowCreateListingModalArgs = {
21
- collectionAddress: Hex;
22
- chainId: string;
23
- collectibleId: string;
24
- messages?: Messages;
24
+ collectionAddress: Hex;
25
+ chainId: string;
26
+ collectibleId: string;
25
27
  };
26
28
 
27
29
  export const useCreateListingModal = () => {
28
- const { chainId: accountChainId } = useAccount();
29
- const { show: showSwitchNetworkModal } = useSwitchChainModal();
30
-
31
- const openModal = (args: ShowCreateListingModalArgs) => {
32
- createListingModal$.open(args);
33
- };
34
-
35
- const handleShowModal = (args: ShowCreateListingModalArgs) => {
36
- const isSameChain = accountChainId === Number(args.chainId);
37
-
38
- if (!isSameChain) {
39
- showSwitchNetworkModal({
40
- chainIdToSwitchTo: Number(args.chainId),
41
- onSwitchChain: () => openModal(args),
42
- messages: args.messages?.switchChain,
43
- });
44
- return;
45
- }
46
-
47
- openModal(args);
48
- };
49
-
50
- return {
51
- show: handleShowModal,
52
- close: () => createListingModal$.close(),
53
- };
30
+ const { chainId: accountChainId } = useAccount();
31
+ const { show: showSwitchNetworkModal } = useSwitchChainModal();
32
+ const { errorCallbacks, successCallbacks } = createListingModal$.state.get();
33
+
34
+ const openModal = (args: ShowCreateListingModalArgs) => {
35
+ createListingModal$.open(args);
36
+ };
37
+
38
+ const handleShowModal = (args: ShowCreateListingModalArgs) => {
39
+ const isSameChain = accountChainId === Number(args.chainId);
40
+
41
+ if (!isSameChain) {
42
+ showSwitchNetworkModal({
43
+ chainIdToSwitchTo: Number(args.chainId),
44
+ onSwitchChain: () => openModal(args),
45
+ callbacks: {
46
+ onSuccess: successCallbacks?.onSwitchChainSuccess,
47
+ onUnknownError: errorCallbacks?.onSwitchChainError,
48
+ onSwitchingNotSupported: errorCallbacks?.onSwitchingNotSupportedError,
49
+ onUserRejectedRequest:
50
+ errorCallbacks?.onUserRejectedSwitchingChainRequestError,
51
+ },
52
+ });
53
+ return;
54
+ }
55
+
56
+ openModal(args);
57
+ };
58
+
59
+ return {
60
+ show: handleShowModal,
61
+ close: () => createListingModal$.close(),
62
+ onError: (callbacks: CreateListingErrorCallbacks) => {
63
+ createListingModal$.state.set({
64
+ ...createListingModal$.state.get(),
65
+ errorCallbacks: callbacks,
66
+ });
67
+ },
68
+ onSuccess: (callbacks: CreateListingSuccessCallbacks) => {
69
+ createListingModal$.state.set({
70
+ ...createListingModal$.state.get(),
71
+ successCallbacks: callbacks,
72
+ });
73
+ },
74
+ };
54
75
  };
55
76
 
56
77
  export const CreateListingModal = () => {
57
- return (
58
- <Show if={createListingModal$.isOpen}>
59
- <Modal />
60
- </Show>
61
- );
78
+ return (
79
+ <Show if={createListingModal$.isOpen}>
80
+ <Modal />
81
+ </Show>
82
+ );
62
83
  };
63
84
 
64
85
  const Modal = () => {
65
- useHydrate();
66
- return <ModalContent />;
86
+ useHydrate();
87
+ return <ModalContent />;
67
88
  };
68
89
 
69
90
  const ModalContent = observer(() => {
70
- const {
71
- chainId,
72
- collectionAddress,
73
- collectibleId,
74
- collectionName,
75
- collectionType,
76
- listingPrice,
77
- } = createListingModal$.state.get();
78
-
79
- const { steps } = createListingModal$.get();
80
-
81
- const ctas = [
82
- {
83
- label: 'Approve TOKEN',
84
- onClick: steps.tokenApproval.execute,
85
- hidden: !steps.tokenApproval.isNeeded(),
86
- pending: steps.tokenApproval.pending,
87
- variant: 'glass' as const,
88
- },
89
- {
90
- label: 'List item for sale',
91
- onClick: steps.createListing.execute,
92
- pending: steps.createListing.pending,
93
- disabled:
94
- steps.tokenApproval.isNeeded() || listingPrice.amountRaw === '0',
95
- },
96
- ] satisfies ActionModalProps['ctas'];
97
-
98
- return (
99
- <ActionModal
100
- store={createListingModal$}
101
- onClose={() => createListingModal$.close()}
102
- title="List item for sale"
103
- ctas={ctas}
104
- >
105
- <TokenPreview
106
- collectionName={collectionName}
107
- collectionAddress={collectionAddress}
108
- collectibleId={collectibleId}
109
- chainId={chainId}
110
- />
111
-
112
- <Box display="flex" flexDirection="column" width="full" gap="1">
113
- <PriceInput
114
- chainId={chainId}
115
- collectionAddress={collectionAddress}
116
- $listingPrice={createListingModal$.state.listingPrice}
117
- />
118
- {!!listingPrice && (
119
- <FloorPriceText
120
- tokenId={collectibleId}
121
- chainId={chainId}
122
- collectionAddress={collectionAddress}
123
- price={listingPrice}
124
- />
125
- )}
126
- </Box>
127
-
128
- {collectionType === ContractType.ERC1155 && (
129
- <QuantityInput
130
- chainId={chainId}
131
- collectionAddress={collectionAddress}
132
- collectibleId={collectibleId}
133
- $quantity={createListingModal$.state.quantity}
134
- />
135
- )}
136
-
137
- <ExpirationDateSelect $date={createListingModal$.state.expiry} />
138
-
139
- <TransactionDetails
140
- collectibleId={collectibleId}
141
- collectionAddress={collectionAddress}
142
- chainId={chainId}
143
- price={createListingModal$.state.listingPrice.get()}
144
- />
145
- </ActionModal>
146
- );
91
+ const {
92
+ chainId,
93
+ collectionAddress,
94
+ collectibleId,
95
+ collectionName,
96
+ collectionType,
97
+ listingPrice,
98
+ } = createListingModal$.state.get();
99
+
100
+ const { steps } = createListingModal$.get();
101
+
102
+ const ctas = [
103
+ {
104
+ label: "Approve TOKEN",
105
+ onClick: steps.tokenApproval.execute,
106
+ hidden: !steps.tokenApproval.isNeeded(),
107
+ pending: steps.tokenApproval.pending,
108
+ variant: "glass" as const,
109
+ },
110
+ {
111
+ label: "List item for sale",
112
+ onClick: steps.createListing.execute,
113
+ pending: steps.createListing.pending,
114
+ disabled:
115
+ steps.tokenApproval.isNeeded() || listingPrice.amountRaw === "0",
116
+ },
117
+ ] satisfies ActionModalProps["ctas"];
118
+
119
+ return (
120
+ <ActionModal
121
+ store={createListingModal$}
122
+ onClose={() => createListingModal$.close()}
123
+ title="List item for sale"
124
+ ctas={ctas}
125
+ >
126
+ <TokenPreview
127
+ collectionName={collectionName}
128
+ collectionAddress={collectionAddress}
129
+ collectibleId={collectibleId}
130
+ chainId={chainId}
131
+ />
132
+
133
+ <Box display="flex" flexDirection="column" width="full" gap="1">
134
+ <PriceInput
135
+ chainId={chainId}
136
+ collectionAddress={collectionAddress}
137
+ $listingPrice={createListingModal$.state.listingPrice}
138
+ />
139
+ {!!listingPrice && (
140
+ <FloorPriceText
141
+ tokenId={collectibleId}
142
+ chainId={chainId}
143
+ collectionAddress={collectionAddress}
144
+ price={listingPrice}
145
+ />
146
+ )}
147
+ </Box>
148
+
149
+ {collectionType === ContractType.ERC1155 && (
150
+ <QuantityInput
151
+ chainId={chainId}
152
+ collectionAddress={collectionAddress}
153
+ collectibleId={collectibleId}
154
+ $quantity={createListingModal$.state.quantity}
155
+ />
156
+ )}
157
+
158
+ <ExpirationDateSelect $date={createListingModal$.state.expiry} />
159
+
160
+ <TransactionDetails
161
+ collectibleId={collectibleId}
162
+ collectionAddress={collectionAddress}
163
+ chainId={chainId}
164
+ price={createListingModal$.state.listingPrice.get()}
165
+ />
166
+ </ActionModal>
167
+ );
147
168
  });
@@ -1,22 +1,29 @@
1
- import type { CollectionType } from '@internal';
2
1
  import { observable, when } from '@legendapp/state';
3
2
  import { useMount, useSelector } from '@legendapp/state/react';
4
- import { useCollectible } from '@react-hooks/useCollectible';
5
- import { useCollection } from '@react-hooks/useCollection';
6
- import { useGenerateOfferTransaction } from '@react-hooks/useGenerateOfferTransaction';
3
+ import type { QueryKey } from '@tanstack/react-query';
4
+ import { addDays } from 'date-fns/addDays';
5
+ import type { Hex } from 'viem';
6
+ import { useAccount, useSendTransaction } from 'wagmi';
7
+ import type { ShowMakeOfferModalArgs } from '.';
8
+ import type { Price } from '../../../../types';
9
+ import type {
10
+ MakeOfferErrorCallbacks,
11
+ MakeOfferSuccessCallbacks,
12
+ } from '../../../../types/callbacks';
7
13
  import {
14
+ type CollectionType,
8
15
  type Currency,
9
16
  OrderbookKind,
10
- type Price,
11
17
  type Step,
12
18
  StepType,
13
19
  type WalletKind,
14
- } from '@types';
15
- import { addDays } from 'date-fns/addDays';
16
- import { type Hex } from 'viem';
17
- import { useAccount, useSendTransaction } from 'wagmi';
18
- import type { ShowMakeOfferModalArgs } from '.';
19
- import type { Messages } from '../../../../types/messages';
20
+ collectableKeys,
21
+ } from '../../../_internal';
22
+ import {
23
+ useCollectible,
24
+ useCollection,
25
+ useGenerateOfferTransaction,
26
+ } from '../../../hooks';
20
27
  import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
21
28
  import {
22
29
  getMakeOfferTransactionMessage,
@@ -36,7 +43,8 @@ export interface MakeOfferModalState {
36
43
  chainId: string;
37
44
  collectibleId: string;
38
45
  expiry: Date;
39
- messages?: Messages;
46
+ errorCallbacks?: MakeOfferErrorCallbacks;
47
+ successCallbacks?: MakeOfferSuccessCallbacks;
40
48
  };
41
49
  steps: {
42
50
  isLoading: () => boolean;
@@ -62,14 +70,12 @@ export const initialState: MakeOfferModalState = {
62
70
  collectionAddress,
63
71
  chainId,
64
72
  collectibleId,
65
- messages,
66
73
  }: ShowMakeOfferModalArgs) => {
67
74
  makeOfferModal$.state.set({
68
75
  ...makeOfferModal$.state.get(),
69
76
  collectionAddress,
70
77
  chainId,
71
78
  collectibleId,
72
- messages,
73
79
  });
74
80
  makeOfferModal$.isOpen.set(true);
75
81
  },
@@ -164,11 +170,10 @@ export const useHydrate = () => {
164
170
 
165
171
  const useTokenApprovalHandler = (chainId: string) => {
166
172
  const { sendTransactionAsync, isPending, isSuccess } = useSendTransaction();
167
- const {
168
- onUnknownError,
169
- onSuccess,
170
- }: { onUnknownError?: Function; onSuccess?: Function } =
171
- makeOfferModal$.state.get().messages?.approveToken || {};
173
+ const onError =
174
+ makeOfferModal$.state.get().errorCallbacks?.onApproveTokenError;
175
+ const onSuccess: (() => void) | undefined =
176
+ makeOfferModal$.state.get().successCallbacks?.onApproveTokenSuccess;
172
177
 
173
178
  makeOfferModal$.steps.tokenApproval.set({
174
179
  isNeeded: () => !!makeOfferModal$.steps.tokenApproval.getStep(),
@@ -192,7 +197,7 @@ const useTokenApprovalHandler = (chainId: string) => {
192
197
 
193
198
  onSuccess && onSuccess();
194
199
  } catch (error) {
195
- onUnknownError && onUnknownError(error);
200
+ onError && onError(error);
196
201
  }
197
202
  },
198
203
  });
@@ -206,12 +211,12 @@ const useTokenApprovalHandler = (chainId: string) => {
206
211
  };
207
212
 
208
213
  const useCreateOfferHandler = (chainId: string) => {
209
- const { collectibleId, collectionAddress } = makeOfferModal$.state.get();
214
+ const { collectibleId, collectionAddress, errorCallbacks, successCallbacks } =
215
+ makeOfferModal$.state.get();
210
216
  const { connector, address } = useAccount();
211
217
  const {
212
218
  generateOfferTransactionAsync,
213
219
  isPending: generateOfferTransactionPending,
214
- error: generateOfferTransactionError,
215
220
  } = useGenerateOfferTransaction({ chainId });
216
221
  const { data: collectible } = useCollectible({
217
222
  chainId,
@@ -219,12 +224,6 @@ const useCreateOfferHandler = (chainId: string) => {
219
224
  collectibleId,
220
225
  });
221
226
 
222
- const {
223
- onUnknownError,
224
- onSuccess,
225
- }: { onUnknownError?: Function; onSuccess?: Function } =
226
- makeOfferModal$.state.get().messages?.sellCollectible || {};
227
-
228
227
  const { sendTransactionAsync, isPending: sendTransactionPending } =
229
228
  useSendTransaction();
230
229
 
@@ -265,6 +264,8 @@ const useCreateOfferHandler = (chainId: string) => {
265
264
 
266
265
  makeOfferModal$.steps._currentStep.set(null);
267
266
 
267
+ makeOfferModal$.close();
268
+
268
269
  showTransactionStatusModal({
269
270
  hash: hash!,
270
271
  price: makeOfferModal$.state.offerPrice.get(),
@@ -275,19 +276,16 @@ const useCreateOfferHandler = (chainId: string) => {
275
276
  getMessage: (params) =>
276
277
  getMakeOfferTransactionMessage(params, collectible?.name || ''),
277
278
  type: StepType.createOffer,
279
+ callbacks: {
280
+ onSuccess: successCallbacks?.onMakeOfferSuccess,
281
+ onUnknownError: errorCallbacks?.onMakeOfferError,
282
+ },
283
+ queriesToInvalidate: collectableKeys.all as unknown as QueryKey[],
278
284
  });
279
-
280
- makeOfferModal$.close();
281
-
282
- onSuccess && onSuccess();
283
285
  })
284
286
  .catch((error) => {
285
- onUnknownError && onUnknownError(error);
287
+ errorCallbacks?.onMakeOfferError?.(error);
286
288
  });
287
289
  },
288
290
  });
289
-
290
- if (generateOfferTransactionError) {
291
- onUnknownError && onUnknownError(generateOfferTransactionError);
292
- }
293
291
  };
@@ -1,9 +1,12 @@
1
- import { ContractType } from '@internal';
2
1
  import { Show, observer } from '@legendapp/state/react';
3
2
  import { useState } from 'react';
4
3
  import type { Hex } from 'viem';
5
4
  import { useAccount } from 'wagmi';
6
- import type { Messages } from '../../../../types/messages';
5
+ import type {
6
+ MakeOfferErrorCallbacks,
7
+ MakeOfferSuccessCallbacks,
8
+ } from '../../../../types/callbacks';
9
+ import { ContractType } from '../../../_internal';
7
10
  import {
8
11
  ActionModal,
9
12
  type ActionModalProps,
@@ -20,12 +23,12 @@ export type ShowMakeOfferModalArgs = {
20
23
  collectionAddress: Hex;
21
24
  chainId: string;
22
25
  collectibleId: string;
23
- messages?: Messages;
24
26
  };
25
27
 
26
28
  export const useMakeOfferModal = () => {
27
29
  const { chainId: accountChainId } = useAccount();
28
30
  const { show: showSwitchNetworkModal } = useSwitchChainModal();
31
+ const { errorCallbacks, successCallbacks } = makeOfferModal$.state.get();
29
32
 
30
33
  const openModal = (args: ShowMakeOfferModalArgs) => {
31
34
  makeOfferModal$.open(args);
@@ -38,7 +41,13 @@ export const useMakeOfferModal = () => {
38
41
  showSwitchNetworkModal({
39
42
  chainIdToSwitchTo: Number(args.chainId),
40
43
  onSwitchChain: () => openModal(args),
41
- messages: args.messages?.switchChain,
44
+ callbacks: {
45
+ onSuccess: successCallbacks?.onSwitchChainSuccess,
46
+ onUnknownError: errorCallbacks?.onSwitchChainError,
47
+ onSwitchingNotSupported: errorCallbacks?.onSwitchingNotSupportedError,
48
+ onUserRejectedRequest:
49
+ errorCallbacks?.onUserRejectedSwitchingChainRequestError,
50
+ },
42
51
  });
43
52
  return;
44
53
  }
@@ -49,6 +58,18 @@ export const useMakeOfferModal = () => {
49
58
  return {
50
59
  show: handleShowModal,
51
60
  close: () => makeOfferModal$.close(),
61
+ onError: (callbacks: MakeOfferErrorCallbacks) => {
62
+ makeOfferModal$.state.set({
63
+ ...makeOfferModal$.state.get(),
64
+ errorCallbacks: callbacks,
65
+ });
66
+ },
67
+ onSuccess: (callbacks: MakeOfferSuccessCallbacks) => {
68
+ makeOfferModal$.state.set({
69
+ ...makeOfferModal$.state.get(),
70
+ successCallbacks: callbacks,
71
+ });
72
+ },
52
73
  };
53
74
  };
54
75