@0xsequence/marketplace-sdk 0.3.5 → 0.3.7

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 (61) hide show
  1. package/dist/{chunk-URTXTVOU.js → chunk-3LGNSRBR.js} +476 -417
  2. package/dist/chunk-3LGNSRBR.js.map +1 -0
  3. package/dist/{chunk-RZSZNVEH.js → chunk-L6GSYPCR.js} +5 -5
  4. package/dist/{chunk-RZSZNVEH.js.map → chunk-L6GSYPCR.js.map} +1 -1
  5. package/dist/{chunk-Q57TEA3Z.js → chunk-NMCGA2TB.js} +4 -2
  6. package/dist/chunk-NMCGA2TB.js.map +1 -0
  7. package/dist/{chunk-6LQST3KZ.js → chunk-QGELCUYG.js} +27 -15
  8. package/dist/chunk-QGELCUYG.js.map +1 -0
  9. package/dist/index.js +6 -6
  10. package/dist/react/hooks/index.d.ts +3 -1
  11. package/dist/react/hooks/index.js +3 -3
  12. package/dist/react/index.js +6 -6
  13. package/dist/react/ui/components/index.js +6 -6
  14. package/dist/react/ui/index.d.ts +4 -21
  15. package/dist/react/ui/index.js +6 -6
  16. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +1 -1
  17. package/dist/react/ui/modals/_internal/components/actionModal/index.js +1 -1
  18. package/dist/react/ui/styles/index.d.ts +1 -1
  19. package/dist/styles/index.d.ts +1 -1
  20. package/dist/styles/index.js +1 -1
  21. package/dist/utils/abi/index.js +5 -5
  22. package/dist/utils/index.js +5 -5
  23. package/package.json +1 -1
  24. package/src/react/_internal/transaction-machine/execute-transaction.ts +10 -3
  25. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +18 -5
  26. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
  27. package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +4 -4
  28. package/src/react/ui/modals/BuyModal/index.tsx +42 -10
  29. package/src/react/ui/modals/CreateListingModal/index.tsx +9 -16
  30. package/src/react/ui/modals/MakeOfferModal/_store.ts +1 -1
  31. package/src/react/ui/modals/MakeOfferModal/index.tsx +9 -12
  32. package/src/react/ui/modals/SellModal/index.tsx +10 -10
  33. package/src/react/ui/modals/TransferModal/_store.ts +12 -10
  34. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +2 -2
  35. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +16 -38
  36. package/src/react/ui/modals/TransferModal/index.tsx +7 -9
  37. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +4 -2
  38. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +15 -7
  39. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +9 -18
  40. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +1 -1
  41. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +25 -3
  42. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -0
  43. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +4 -4
  44. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +7 -4
  45. package/src/react/ui/modals/_internal/components/transactionPreview/consts.ts +10 -5
  46. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +27 -8
  47. package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +3 -5
  48. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +80 -62
  49. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +21 -29
  50. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts +23 -0
  51. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +29 -0
  52. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getTitle.ts +43 -0
  53. package/tsconfig.tsbuildinfo +1 -1
  54. package/dist/chunk-6LQST3KZ.js.map +0 -1
  55. package/dist/chunk-Q57TEA3Z.js.map +0 -1
  56. package/dist/chunk-URTXTVOU.js.map +0 -1
  57. package/src/react/ui/modals/CreateListingModal/_utils/getCreateListingTransactionTitleMessage.ts +0 -30
  58. package/src/react/ui/modals/MakeOfferModal/_utils/getMakeOfferTransactionTitleMessage.ts +0 -28
  59. package/src/react/ui/modals/SellModal/_utils/getSellTransactionTitleMessage.ts +0 -28
  60. package/src/react/ui/modals/TransferModal/_utils/getTransferTransactionTitleMessage.ts +0 -28
  61. package/src/types/callbacks.ts +0 -51
@@ -8,10 +8,10 @@ import {
8
8
  useSellModal,
9
9
  useSuccessfulPurchaseModal,
10
10
  useTransferModal
11
- } from "../chunk-URTXTVOU.js";
12
- import "../chunk-Q57TEA3Z.js";
11
+ } from "../chunk-3LGNSRBR.js";
12
+ import "../chunk-NMCGA2TB.js";
13
13
  import "../chunk-FFCNYF3S.js";
14
- import "../chunk-RZSZNVEH.js";
14
+ import "../chunk-L6GSYPCR.js";
15
15
  import "../chunk-O642NH7U.js";
16
16
  import {
17
17
  MarketplaceProvider,
@@ -74,16 +74,16 @@ import {
74
74
  useMarketplaceConfig,
75
75
  useRoyaltyPercentage,
76
76
  useTransferTokens
77
- } from "../chunk-6LQST3KZ.js";
77
+ } from "../chunk-QGELCUYG.js";
78
78
  import "../chunk-Y7YO5TLE.js";
79
79
  import "../chunk-7NJETFMF.js";
80
80
  import "../chunk-SBVLWSRZ.js";
81
81
  import "../chunk-NJ2GXOPW.js";
82
+ import "../chunk-MJ4YU7RW.js";
82
83
  import "../chunk-OUZ42I6B.js";
83
84
  import "../chunk-MCI3KOSQ.js";
84
- import "../chunk-3OHM45R3.js";
85
85
  import "../chunk-WFE6OCYF.js";
86
- import "../chunk-MJ4YU7RW.js";
86
+ import "../chunk-3OHM45R3.js";
87
87
  import "../chunk-Q2BVDQ3G.js";
88
88
  import {
89
89
  getQueryClient
@@ -1,21 +1,21 @@
1
1
  "use client"
2
2
  import {
3
3
  CollectibleCard
4
- } from "../../../chunk-URTXTVOU.js";
5
- import "../../../chunk-Q57TEA3Z.js";
4
+ } from "../../../chunk-3LGNSRBR.js";
5
+ import "../../../chunk-NMCGA2TB.js";
6
6
  import "../../../chunk-FFCNYF3S.js";
7
- import "../../../chunk-RZSZNVEH.js";
7
+ import "../../../chunk-L6GSYPCR.js";
8
8
  import "../../../chunk-O642NH7U.js";
9
- import "../../../chunk-6LQST3KZ.js";
9
+ import "../../../chunk-QGELCUYG.js";
10
10
  import "../../../chunk-Y7YO5TLE.js";
11
11
  import "../../../chunk-7NJETFMF.js";
12
12
  import "../../../chunk-SBVLWSRZ.js";
13
13
  import "../../../chunk-NJ2GXOPW.js";
14
+ import "../../../chunk-MJ4YU7RW.js";
14
15
  import "../../../chunk-OUZ42I6B.js";
15
16
  import "../../../chunk-MCI3KOSQ.js";
16
- import "../../../chunk-3OHM45R3.js";
17
17
  import "../../../chunk-WFE6OCYF.js";
18
- import "../../../chunk-MJ4YU7RW.js";
18
+ import "../../../chunk-3OHM45R3.js";
19
19
  import "../../../chunk-Q2BVDQ3G.js";
20
20
  import "../../../chunk-D3HRXVYJ.js";
21
21
  import "../../../chunk-3CXEYH2I.js";
@@ -10,24 +10,6 @@ import 'zod';
10
10
 
11
11
  declare const ModalProvider: () => react_jsx_runtime.JSX.Element;
12
12
 
13
- type OnApproveTokenError = (error: Error | unknown) => void;
14
- type BaseErrorCallbacks = {
15
- onApproveTokenError?: OnApproveTokenError;
16
- onSwitchingNotSupportedError?: () => void;
17
- onUserRejectedSwitchingChainRequestError?: () => void;
18
- onSwitchChainError?: (error: Error | unknown) => void;
19
- };
20
- type BaseSuccessCallbacks = {
21
- onApproveTokenSuccess?: () => void;
22
- onSwitchChainSuccess?: () => void;
23
- };
24
- type TransferErrorCallbacks = BaseErrorCallbacks & {
25
- onTransferError?: (error: Error | unknown) => void;
26
- };
27
- type TransferSuccessCallbacks = BaseSuccessCallbacks & {
28
- onTransferSuccess?: () => void;
29
- };
30
-
31
13
  type ModalCallbacks = {
32
14
  onSuccess?: (hash: Hash) => void;
33
15
  onError?: (error: Error) => void;
@@ -83,14 +65,15 @@ declare const useSuccessfulPurchaseModal: (callbacks?: ModalCallbacks) => {
83
65
 
84
66
  type ShowTransferModalArgs = {
85
67
  collectionAddress: Hex;
86
- tokenId: string;
68
+ collectibleId: string;
87
69
  chainId: string;
70
+ callbacks?: ModalCallbacks;
88
71
  };
89
72
  declare const useTransferModal: () => {
90
73
  show: (args: ShowTransferModalArgs) => void;
91
74
  close: () => void;
92
- onError: (callbacks: TransferErrorCallbacks) => void;
93
- onSuccess: (callbacks: TransferSuccessCallbacks) => void;
75
+ onError: (callbacks: ModalCallbacks) => void;
76
+ onSuccess: (callbacks: ModalCallbacks) => void;
94
77
  };
95
78
 
96
79
  type ShowSellModalArgs = {
@@ -8,21 +8,21 @@ import {
8
8
  useSellModal,
9
9
  useSuccessfulPurchaseModal,
10
10
  useTransferModal
11
- } from "../../chunk-URTXTVOU.js";
12
- import "../../chunk-Q57TEA3Z.js";
11
+ } from "../../chunk-3LGNSRBR.js";
12
+ import "../../chunk-NMCGA2TB.js";
13
13
  import "../../chunk-FFCNYF3S.js";
14
- import "../../chunk-RZSZNVEH.js";
14
+ import "../../chunk-L6GSYPCR.js";
15
15
  import "../../chunk-O642NH7U.js";
16
- import "../../chunk-6LQST3KZ.js";
16
+ import "../../chunk-QGELCUYG.js";
17
17
  import "../../chunk-Y7YO5TLE.js";
18
18
  import "../../chunk-7NJETFMF.js";
19
19
  import "../../chunk-SBVLWSRZ.js";
20
20
  import "../../chunk-NJ2GXOPW.js";
21
+ import "../../chunk-MJ4YU7RW.js";
21
22
  import "../../chunk-OUZ42I6B.js";
22
23
  import "../../chunk-MCI3KOSQ.js";
23
- import "../../chunk-3OHM45R3.js";
24
24
  import "../../chunk-WFE6OCYF.js";
25
- import "../../chunk-MJ4YU7RW.js";
25
+ import "../../chunk-3OHM45R3.js";
26
26
  import "../../chunk-Q2BVDQ3G.js";
27
27
  import "../../chunk-D3HRXVYJ.js";
28
28
  import "../../chunk-3CXEYH2I.js";
@@ -19,7 +19,7 @@ interface ActionModalProps {
19
19
  children: react__default.ReactNode;
20
20
  ctas: {
21
21
  label: string;
22
- onClick: () => void;
22
+ onClick: (() => Promise<void>) | (() => void);
23
23
  pending?: boolean;
24
24
  disabled?: boolean;
25
25
  hidden?: boolean;
@@ -4,7 +4,7 @@ import {
4
4
  closeModal,
5
5
  createActionModalStore,
6
6
  openModal
7
- } from "../../../../../../chunk-Q57TEA3Z.js";
7
+ } from "../../../../../../chunk-NMCGA2TB.js";
8
8
  import {
9
9
  closeButton,
10
10
  cta,
@@ -1,5 +1,5 @@
1
1
  declare const dialogOverlay: string;
2
- declare const dialogContent: Record<"narrow" | "wide", string>;
2
+ declare const dialogContent: Record<"wide" | "narrow", string>;
3
3
  declare const closeButton: string;
4
4
 
5
5
  export { closeButton, dialogContent, dialogOverlay };
@@ -43,7 +43,7 @@ declare const alertMessageBox: string;
43
43
  declare const alertMessageBoxVariants: Record<"info" | "warning", string>;
44
44
 
45
45
  declare const switchChainModalContent: string;
46
- declare const switchChainCta: Record<"default" | "pending", string>;
46
+ declare const switchChainCta: Record<"pending" | "default", string>;
47
47
 
48
48
  declare const collectiblesGrid: string;
49
49
  declare const collectiblesGridItem: string;
@@ -18,7 +18,7 @@ import {
18
18
  quantityInputWrapper,
19
19
  tokenPreview,
20
20
  transferModalContent
21
- } from "../chunk-RZSZNVEH.js";
21
+ } from "../chunk-L6GSYPCR.js";
22
22
  import {
23
23
  cta
24
24
  } from "../chunk-O642NH7U.js";
@@ -1,15 +1,15 @@
1
1
  "use client"
2
2
  import "../../chunk-MCI3KOSQ.js";
3
- import {
4
- EIP2981_ABI,
5
- SequenceMarketplaceV1_ABI,
6
- SequenceMarketplaceV2_ABI
7
- } from "../../chunk-3OHM45R3.js";
8
3
  import {
9
4
  ERC1155_ABI,
10
5
  ERC20_ABI,
11
6
  ERC721_ABI
12
7
  } from "../../chunk-WFE6OCYF.js";
8
+ import {
9
+ EIP2981_ABI,
10
+ SequenceMarketplaceV1_ABI,
11
+ SequenceMarketplaceV2_ABI
12
+ } from "../../chunk-3OHM45R3.js";
13
13
  export {
14
14
  EIP2981_ABI,
15
15
  ERC1155_ABI,
@@ -8,16 +8,16 @@ import {
8
8
  truncateMiddle
9
9
  } from "../chunk-OUZ42I6B.js";
10
10
  import "../chunk-MCI3KOSQ.js";
11
- import {
12
- EIP2981_ABI,
13
- SequenceMarketplaceV1_ABI,
14
- SequenceMarketplaceV2_ABI
15
- } from "../chunk-3OHM45R3.js";
16
11
  import {
17
12
  ERC1155_ABI,
18
13
  ERC20_ABI,
19
14
  ERC721_ABI
20
15
  } from "../chunk-WFE6OCYF.js";
16
+ import {
17
+ EIP2981_ABI,
18
+ SequenceMarketplaceV1_ABI,
19
+ SequenceMarketplaceV2_ABI
20
+ } from "../chunk-3OHM45R3.js";
21
21
  import "../chunk-T2AMWIKD.js";
22
22
  export {
23
23
  EIP2981_ABI,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@0xsequence/marketplace-sdk",
3
3
  "private": false,
4
- "version": "0.3.5",
4
+ "version": "0.3.7",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -67,6 +67,7 @@ export enum TransactionType {
67
67
  SELL = 'SELL',
68
68
  LISTING = 'LISTING',
69
69
  OFFER = 'OFFER',
70
+ TRANSFER = 'TRANSFER',
70
71
  CANCEL = 'CANCEL',
71
72
  }
72
73
 
@@ -78,6 +79,7 @@ export interface TransactionConfig {
78
79
  collectionAddress: string;
79
80
  sdkConfig: SdkConfig;
80
81
  marketplaceConfig: MarketplaceConfig;
82
+ isWaaS: boolean;
81
83
  }
82
84
 
83
85
  interface StateConfig {
@@ -360,7 +362,10 @@ export class TransactionMachine {
360
362
 
361
363
  await this.transition(TransactionState.SWITCH_CHAIN);
362
364
  try {
363
- await this.switchChainFn(this.config.config.chainId);
365
+ if (!this.config.config.isWaaS) {
366
+ await this.switchChainFn(this.config.config.chainId);
367
+ }
368
+
364
369
  await this.walletClient.switchChain({
365
370
  id: Number(this.config.config.chainId),
366
371
  });
@@ -413,6 +418,8 @@ export class TransactionMachine {
413
418
 
414
419
  private async executeTransaction(step: Step): Promise<Hash> {
415
420
  try {
421
+ await this.switchChain();
422
+
416
423
  const transactionData = {
417
424
  account: this.getAccount(),
418
425
  chain: this.getChainForTransaction(),
@@ -438,6 +445,8 @@ export class TransactionMachine {
438
445
  throw new MissingPostStepError();
439
446
  }
440
447
 
448
+ await this.switchChain();
449
+
441
450
  let signature: Hex;
442
451
  if (!step.signature) {
443
452
  throw new MissingSignatureDataError();
@@ -594,8 +603,6 @@ export class TransactionMachine {
594
603
  throw new MissingStepDataError();
595
604
  }
596
605
 
597
- await this.switchChain();
598
-
599
606
  if (step.id === StepType.buy) {
600
607
  await this.executeBuyStep({ step, props: props as BuyInput });
601
608
  return;
@@ -18,7 +18,7 @@ import {
18
18
 
19
19
  export type UseTransactionMachineConfig = Omit<
20
20
  TransactionConfig,
21
- 'sdkConfig' | 'marketplaceConfig' | 'walletKind' | 'chains'
21
+ 'sdkConfig' | 'marketplaceConfig' | 'walletKind' | 'chains' | 'isWaaS'
22
22
  >;
23
23
 
24
24
  export const useTransactionMachine = (
@@ -41,7 +41,12 @@ export const useTransactionMachine = (
41
41
 
42
42
  const { connector, isConnected } = useAccount();
43
43
  const walletKind =
44
- connector?.id === 'sequence' ? WalletKind.sequence : WalletKind.unknown;
44
+ connector?.id === 'sequence'
45
+ ? WalletKind.sequence
46
+ : WalletKind.unknown;
47
+
48
+ // TODO: remove this once we have a better way to check if the wallet is a WAAS wallet
49
+ const isWaaS = connector?.id.endsWith('waas') || false;
45
50
 
46
51
  if (!isConnected) {
47
52
  // No wallet connected, TODO: add some sort of state for this
@@ -74,19 +79,27 @@ export const useTransactionMachine = (
74
79
 
75
80
  const machine = new TransactionMachine(
76
81
  {
77
- config: { sdkConfig, marketplaceConfig, walletKind, chains, ...config },
82
+ config: {
83
+ sdkConfig,
84
+ marketplaceConfig,
85
+ walletKind,
86
+ chains,
87
+ ...config,
88
+ isWaaS
89
+ },
78
90
  onSuccess,
79
91
  onTransactionSent,
80
92
  },
81
93
  walletClient,
82
94
  getPublicRpcClient(config.chainId),
83
95
  openSelectPaymentModal,
84
- async (chainId) =>
96
+ async () =>
85
97
  new Promise((resolve, reject) => {
86
98
  showSwitchChainModal({
87
- chainIdToSwitchTo: Number(chainId),
99
+ chainIdToSwitchTo: Number(config.chainId),
88
100
  onSuccess: resolve,
89
101
  onError: reject,
102
+ onClose: reject,
90
103
  });
91
104
  }),
92
105
  );
@@ -121,7 +121,7 @@ export const ActionButton = observer(
121
121
  showTransferModal({
122
122
  collectionAddress: collectionAddress as Hex,
123
123
  chainId: chainId,
124
- tokenId,
124
+ collectibleId: tokenId,
125
125
  })
126
126
  }
127
127
  />
@@ -9,7 +9,7 @@ interface CustomSelectProps {
9
9
  label: string;
10
10
  disabled?: boolean;
11
11
  }>;
12
- placeholder?: string;
12
+ value: string;
13
13
  onValueChange?: (value: string) => void;
14
14
  defaultValue?: string;
15
15
  }
@@ -30,14 +30,14 @@ const CustomSelectItem = React.forwardRef<
30
30
 
31
31
  export const CustomSelect: React.FC<CustomSelectProps> = ({
32
32
  items,
33
- placeholder = 'Select an item...',
33
+ value,
34
34
  onValueChange,
35
35
  defaultValue,
36
36
  }) => {
37
37
  return (
38
38
  <Select.Root onValueChange={onValueChange} defaultValue={defaultValue}>
39
- <Select.Trigger className={trigger}>
40
- <Select.Value placeholder={placeholder} />
39
+ <Select.Trigger className={trigger} value={value}>
40
+ <Select.Value />
41
41
  <Select.Icon>
42
42
  <ChevronDownIcon size="xs" />
43
43
  </Select.Icon>
@@ -1,4 +1,5 @@
1
1
  import type { TokenMetadata } from '@0xsequence/indexer';
2
+ import { Box, Text, TokenImage } from '@0xsequence/design-system';
2
3
  import { Show, observer, useSelector } from '@legendapp/state/react';
3
4
  import { useEffect } from 'react';
4
5
  import type { Hex } from 'viem';
@@ -10,6 +11,8 @@ import QuantityInput from '..//_internal/components/quantityInput';
10
11
  import { ActionModal } from '../_internal/components/actionModal';
11
12
  import type { ModalCallbacks } from '../_internal/types';
12
13
  import { buyModal$ } from './_store';
14
+ import { formatUnits, parseUnits } from 'viem';
15
+ import { useCurrencies } from '../../../hooks';
13
16
 
14
17
  export type ShowBuyModalArgs = {
15
18
  chainId: string;
@@ -103,7 +106,7 @@ function CheckoutModal({
103
106
  buy({
104
107
  orderId: order.orderId,
105
108
  collectableDecimals: collectable.decimals || 0,
106
- quantity: '1',
109
+ quantity: parseUnits('1', collectable.decimals || 0).toString(),
107
110
  marketplace: order.marketplace,
108
111
  });
109
112
  };
@@ -123,9 +126,22 @@ interface ERC1155QuantityModalProps extends CheckoutModalProps {
123
126
  const ERC1155QuantityModal = observer(
124
127
  ({ buy, collectable, order }: ERC1155QuantityModalProps) => {
125
128
  buyModal$.state.quantity.set(
126
- Math.max(Number(order.quantityRemaining), 1).toString(),
129
+ Math.min(Number(order.quantityRemaining), 1).toString(),
127
130
  );
128
131
 
132
+ const { data: currencies } = useCurrencies({
133
+ chainId: order.chainId,
134
+ collectionAddress: order.collectionContractAddress,
135
+ });
136
+
137
+ const currency = currencies?.find(
138
+ (currency) => currency.contractAddress === order.priceCurrencyAddress,
139
+ );
140
+
141
+ const quantity = Number(buyModal$.state.quantity.get());
142
+ const pricePerToken = order.priceAmount;
143
+ const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
144
+
129
145
  return (
130
146
  <ActionModal
131
147
  store={buyModal$}
@@ -133,10 +149,13 @@ const ERC1155QuantityModal = observer(
133
149
  title="Select Quantity"
134
150
  ctas={[
135
151
  {
136
- label: 'Select Quantity',
152
+ label: 'Buy now',
137
153
  onClick: () => {
138
154
  buy({
139
- quantity: buyModal$.state.quantity.get(),
155
+ quantity: parseUnits(
156
+ buyModal$.state.quantity.get(),
157
+ collectable.decimals || 0,
158
+ ).toString(),
140
159
  orderId: order.orderId,
141
160
  collectableDecimals: collectable.decimals || 0,
142
161
  marketplace: order.marketplace,
@@ -146,12 +165,25 @@ const ERC1155QuantityModal = observer(
146
165
  },
147
166
  ]}
148
167
  >
149
- <QuantityInput
150
- $quantity={buyModal$.state.quantity}
151
- $invalidQuantity={buyModal$.state.invalidQuantity}
152
- decimals={order.quantityDecimals}
153
- maxQuantity={order.quantityRemaining}
154
- />
168
+ <Box display="flex" flexDirection="column" gap="4">
169
+ <QuantityInput
170
+ $quantity={buyModal$.state.quantity}
171
+ $invalidQuantity={buyModal$.state.invalidQuantity}
172
+ decimals={order.quantityDecimals}
173
+ maxQuantity={order.quantityRemaining}
174
+ />
175
+ <Box display="flex" justifyContent="space-between">
176
+ <Text color="text50" fontSize="small">
177
+ Total Price
178
+ </Text>
179
+ <Box display="flex" alignItems="center" gap="2">
180
+ <TokenImage src={currency?.imageUrl} size="xs" />
181
+ <Text color="text100" fontSize="small" fontWeight="bold">
182
+ {formatUnits(BigInt(totalPrice), currency?.decimals || 0)}
183
+ </Text>
184
+ </Box>
185
+ </Box>
186
+ </Box>
155
187
  </ActionModal>
156
188
  );
157
189
  },
@@ -2,12 +2,9 @@ import { Box } from '@0xsequence/design-system';
2
2
  import { Show, observer } from '@legendapp/state/react';
3
3
  import type { QueryKey } from '@tanstack/react-query';
4
4
  import type { Hash, Hex } from 'viem';
5
+ import { parseUnits } from 'viem';
5
6
  import { useAccount } from 'wagmi';
6
- import {
7
- type ContractType,
8
- StepType,
9
- collectableKeys,
10
- } from '../../../_internal';
7
+ import { type ContractType, collectableKeys } from '../../../_internal';
11
8
  import {
12
9
  useBalanceOfCollectible,
13
10
  useCollectible,
@@ -29,10 +26,7 @@ import TransactionDetails from '../_internal/components/transactionDetails';
29
26
  import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
30
27
  import type { ModalCallbacks } from '../_internal/types';
31
28
  import { createListingModal$ } from './_store';
32
- import {
33
- getCreateListingTransactionMessage,
34
- getCreateListingTransactionTitle,
35
- } from './_utils/getCreateListingTransactionTitleMessage';
29
+ import { TransactionType } from '../../../_internal/transaction-machine/execute-transaction';
36
30
 
37
31
  export type ShowCreateListingModalArgs = {
38
32
  collectionAddress: Hex;
@@ -108,11 +102,8 @@ export const Modal = observer(
108
102
  collectionAddress,
109
103
  chainId,
110
104
  price: createListingModal$.listingPrice.get(),
111
- tokenId: collectibleId,
112
- getTitle: getCreateListingTransactionTitle,
113
- getMessage: (params) =>
114
- getCreateListingTransactionMessage(params, collectible?.name || ''),
115
- type: StepType.createListing,
105
+ collectibleId,
106
+ type: TransactionType.LISTING,
116
107
  queriesToInvalidate: collectableKeys.all as unknown as QueryKey[],
117
108
  });
118
109
  createListingModal$.close();
@@ -161,11 +152,13 @@ export const Modal = observer(
161
152
  Math.floor(date.getTime() / 1000).toString();
162
153
 
163
154
  const { isLoading, steps, refreshSteps } = getListingSteps({
164
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
165
155
  contractType: collection!.type as ContractType,
166
156
  listing: {
167
157
  tokenId: collectibleId,
168
- quantity: createListingModal$.quantity.get(),
158
+ quantity: parseUnits(
159
+ createListingModal$.quantity.get(),
160
+ collectible?.decimals || 0,
161
+ ).toString(),
169
162
  expiry: dateToUnixTime(createListingModal$.expiry.get()),
170
163
  currencyAddress: listingPrice.currency.contractAddress,
171
164
  pricePerToken: listingPrice.amountRaw,
@@ -27,7 +27,7 @@ const initialState: MakeOfferModalState & {
27
27
  collectibleId: '',
28
28
  callbacks: undefined,
29
29
  offerPrice: {
30
- amountRaw: '0',
30
+ amountRaw: '1',
31
31
  currency: {} as Currency,
32
32
  },
33
33
  quantity: '1',
@@ -1,8 +1,8 @@
1
1
  import { Show, observer } from '@legendapp/state/react';
2
2
  import type { QueryKey } from '@tanstack/react-query';
3
3
  import { useEffect, useState } from 'react';
4
- import type { Hex } from 'viem';
5
- import { ContractType, StepType, collectableKeys } from '../../../_internal';
4
+ import { parseUnits, type Hex } from 'viem';
5
+ import { ContractType, collectableKeys } from '../../../_internal';
6
6
  import { useCollectible, useCollection, useCurrencies } from '../../../hooks';
7
7
  import { useMakeOffer } from '../../../hooks/useMakeOffer';
8
8
  import { ActionModal } from '../_internal/components/actionModal/ActionModal';
@@ -16,10 +16,7 @@ import TokenPreview from '../_internal/components/tokenPreview';
16
16
  import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
17
17
  import type { ModalCallbacks } from '../_internal/types';
18
18
  import { makeOfferModal$ } from './_store';
19
- import {
20
- getMakeOfferTransactionMessage,
21
- getMakeOfferTransactionTitle,
22
- } from './_utils/getMakeOfferTransactionTitleMessage';
19
+ import { TransactionType } from '../../../_internal/transaction-machine/execute-transaction';
23
20
 
24
21
  export type ShowMakeOfferModalArgs = {
25
22
  collectionAddress: Hex;
@@ -90,11 +87,8 @@ const ModalContent = observer(
90
87
  price: makeOfferModal$.offerPrice.get(),
91
88
  collectionAddress,
92
89
  chainId,
93
- tokenId: collectibleId,
94
- getTitle: getMakeOfferTransactionTitle,
95
- getMessage: (params) =>
96
- getMakeOfferTransactionMessage(params, collectible?.name || ''),
97
- type: StepType.createOffer,
90
+ collectibleId,
91
+ type: TransactionType.OFFER,
98
92
  queriesToInvalidate: collectableKeys.all as unknown as QueryKey[],
99
93
  });
100
94
  makeOfferModal$.close();
@@ -124,7 +118,10 @@ const ModalContent = observer(
124
118
  contractType: collection!.type as ContractType,
125
119
  offer: {
126
120
  tokenId: collectibleId,
127
- quantity: makeOfferModal$.quantity.get(),
121
+ quantity: parseUnits(
122
+ makeOfferModal$.quantity.get(),
123
+ collectible?.decimals || 0,
124
+ ).toString(),
128
125
  expiry: dateToUnixTime(makeOfferModal$.expiry.get()),
129
126
  currencyAddress,
130
127
  pricePerToken: offerPrice.amountRaw,
@@ -1,9 +1,9 @@
1
1
  import { Show, observer } from '@legendapp/state/react';
2
2
  import type { QueryKey } from '@tanstack/react-query';
3
3
  import type { Hex } from 'viem';
4
+ import { parseUnits } from 'viem';
4
5
  import {
5
6
  type Order,
6
- StepType,
7
7
  balanceQueries,
8
8
  collectableKeys,
9
9
  } from '../../../_internal';
@@ -18,10 +18,7 @@ import TransactionDetails from '../_internal/components/transactionDetails';
18
18
  import TransactionHeader from '../_internal/components/transactionHeader';
19
19
  import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
20
20
  import { sellModal$ } from './_store';
21
- import {
22
- getSellTransactionMessage,
23
- getSellTransactionTitle,
24
- } from './_utils/getSellTransactionTitleMessage';
21
+ import { TransactionType } from '../../../_internal/transaction-machine/execute-transaction';
25
22
 
26
23
  export type ShowSellModalArgs = {
27
24
  chainId: string;
@@ -77,11 +74,8 @@ const ModalContent = observer(
77
74
  },
78
75
  collectionAddress,
79
76
  chainId,
80
- tokenId,
81
- getTitle: getSellTransactionTitle,
82
- getMessage: (params) =>
83
- getSellTransactionMessage(params, collectible?.name || ''),
84
- type: StepType.sell,
77
+ collectibleId: tokenId,
78
+ type: TransactionType.SELL,
85
79
  queriesToInvalidate: [
86
80
  ...collectableKeys.all,
87
81
  balanceQueries.all,
@@ -155,6 +149,12 @@ const ModalContent = observer(
155
149
  sell({
156
150
  orderId: order?.orderId,
157
151
  marketplace: order?.marketplace,
152
+ quantity: order?.quantityRemaining
153
+ ? parseUnits(
154
+ order.quantityRemaining,
155
+ collectible?.decimals || 0,
156
+ ).toString()
157
+ : '1',
158
158
  }),
159
159
  },
160
160
  ]}