@0xsequence/marketplace-sdk 0.3.11 → 0.4.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 (53) hide show
  1. package/dist/{chunk-B3LFJJVS.js → chunk-6AYHE7ZA.js} +15 -11
  2. package/dist/chunk-6AYHE7ZA.js.map +1 -0
  3. package/dist/{chunk-IRN77TJW.js → chunk-6HEMV2OR.js} +48 -36
  4. package/dist/chunk-6HEMV2OR.js.map +1 -0
  5. package/dist/{chunk-KRMV6FJE.js → chunk-AY2MZHZN.js} +2 -2
  6. package/dist/{chunk-Z7NLKEXF.js → chunk-EK5ZSW4M.js} +2 -2
  7. package/dist/{chunk-N5F6IEAK.js → chunk-GVDLVCR5.js} +1 -1
  8. package/dist/chunk-GVDLVCR5.js.map +1 -0
  9. package/dist/{chunk-3LOJQCTV.js → chunk-P3EQRM7K.js} +2 -2
  10. package/dist/{chunk-4FC3IG7C.js → chunk-PAHT6PTD.js} +2 -2
  11. package/dist/{chunk-E3ZFT6WR.js → chunk-QTQH5I2E.js} +11 -1
  12. package/dist/chunk-QTQH5I2E.js.map +1 -0
  13. package/dist/index.js +5 -5
  14. package/dist/react/_internal/api/index.js +2 -2
  15. package/dist/react/_internal/index.js +3 -3
  16. package/dist/react/_internal/wagmi/index.js +2 -2
  17. package/dist/react/hooks/index.d.ts +3 -3
  18. package/dist/react/hooks/index.js +6 -6
  19. package/dist/react/index.js +7 -7
  20. package/dist/react/ssr/index.js.map +1 -1
  21. package/dist/react/ui/components/index.js +7 -7
  22. package/dist/react/ui/index.js +7 -7
  23. package/dist/react/ui/modals/_internal/components/actionModal/index.js +3 -3
  24. package/dist/types/index.js +3 -3
  25. package/dist/utils/index.js +2 -2
  26. package/package.json +1 -1
  27. package/src/react/_internal/transaction-machine/execute-transaction.ts +13 -7
  28. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +1 -1
  29. package/src/react/hooks/useBuyCollectable.tsx +2 -2
  30. package/src/react/hooks/useCancelOrder.tsx +2 -1
  31. package/src/react/hooks/useCreateListing.tsx +1 -1
  32. package/src/react/hooks/useCurrencies.tsx +0 -1
  33. package/src/react/hooks/useMakeOffer.tsx +1 -1
  34. package/src/react/hooks/useSell.tsx +1 -1
  35. package/src/react/ui/modals/CreateListingModal/index.tsx +4 -2
  36. package/src/react/ui/modals/MakeOfferModal/index.tsx +4 -2
  37. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +0 -6
  38. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +7 -5
  39. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +3 -0
  40. package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +8 -10
  41. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +11 -4
  42. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +4 -0
  43. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +6 -0
  44. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getTitle.ts +6 -0
  45. package/src/utils/_internal/error/transaction.ts +10 -0
  46. package/dist/chunk-B3LFJJVS.js.map +0 -1
  47. package/dist/chunk-E3ZFT6WR.js.map +0 -1
  48. package/dist/chunk-IRN77TJW.js.map +0 -1
  49. package/dist/chunk-N5F6IEAK.js.map +0 -1
  50. /package/dist/{chunk-KRMV6FJE.js.map → chunk-AY2MZHZN.js.map} +0 -0
  51. /package/dist/{chunk-Z7NLKEXF.js.map → chunk-EK5ZSW4M.js.map} +0 -0
  52. /package/dist/{chunk-3LOJQCTV.js.map → chunk-P3EQRM7K.js.map} +0 -0
  53. /package/dist/{chunk-4FC3IG7C.js.map → chunk-PAHT6PTD.js.map} +0 -0
@@ -25,7 +25,7 @@ export const useTransactionMachine = (
25
25
  config: UseTransactionMachineConfig,
26
26
  onSuccess?: (hash: Hash) => void,
27
27
  onError?: (error: TransactionError) => void,
28
- onTransactionSent?: (hash: Hash) => void,
28
+ onTransactionSent?: (hash?: Hash, orderId?: string) => void,
29
29
  ) => {
30
30
  const { data: walletClient, isLoading: walletClientIsLoading } =
31
31
  useWalletClient();
@@ -1,4 +1,4 @@
1
- import type { Hash } from 'viem';
1
+ import type { Hash, Hex } from 'viem';
2
2
  import type { TransactionErrorTypes } from '../../utils/_internal/error/transaction';
3
3
  import {
4
4
  type BuyInput,
@@ -15,7 +15,7 @@ interface UseBuyOrderArgs
15
15
  extends Omit<UseTransactionMachineConfig, 'type' | 'orderbookKind'> {
16
16
  onSuccess?: (hash: Hash) => void;
17
17
  onError?: (error: UseBuyOrderError) => void;
18
- onTransactionSent?: (hash: string) => void;
18
+ onTransactionSent?: (hash?: Hex) => void;
19
19
  }
20
20
 
21
21
  export const useBuyCollectable = ({
@@ -1,3 +1,4 @@
1
+ import { Hex } from 'viem';
1
2
  import {
2
3
  type CancelInput,
3
4
  TransactionType,
@@ -11,7 +12,7 @@ interface UseCancelOrderArgs
11
12
  extends Omit<UseTransactionMachineConfig, 'type' | 'orderbookKind'> {
12
13
  onSuccess?: (hash: string) => void;
13
14
  onError?: (error: Error) => void;
14
- onTransactionSent?: (hash: string) => void;
15
+ onTransactionSent?: (hash?: Hex) => void;
15
16
  }
16
17
 
17
18
  export const useCancelOrder = ({
@@ -15,7 +15,7 @@ interface UseCreateListingArgs
15
15
  extends Omit<UseTransactionMachineConfig, 'type'> {
16
16
  onSuccess?: (hash: Hash) => void;
17
17
  onError?: (error: TransactionError) => void;
18
- onTransactionSent?: (hash: Hash) => void;
18
+ onTransactionSent?: (hash?: Hash, orderId?: string) => void;
19
19
  }
20
20
 
21
21
  export const useCreateListing = ({
@@ -40,7 +40,6 @@ const fetchCurrencies = async (chainId: ChainId, config: SdkConfig) => {
40
40
  };
41
41
 
42
42
  const selectCurrencies = (data: Currency[], args: UseCurrenciesArgs) => {
43
- console.debug('[selectCurrencies]: Select Currencies Input:', { data, args });
44
43
  const argsParsed = UseCurrenciesArgsSchema.parse(args);
45
44
  // if collectionAddress is passed, filter currencies based on collection currency options
46
45
  if (argsParsed.currencyOptions) {
@@ -14,7 +14,7 @@ import {
14
14
  interface UseMakeOfferArgs extends Omit<UseTransactionMachineConfig, 'type'> {
15
15
  onSuccess?: (hash: Hash) => void;
16
16
  onError?: (error: TransactionError) => void;
17
- onTransactionSent?: (hash: Hash) => void;
17
+ onTransactionSent?: (hash?: Hash, orderId?: string) => void;
18
18
  }
19
19
 
20
20
  export const useMakeOffer = ({
@@ -14,7 +14,7 @@ interface UseSellArgs
14
14
  extends Omit<UseTransactionMachineConfig, 'type' | 'orderbookKind'> {
15
15
  onSuccess?: (hash: Hash) => void;
16
16
  onError?: (error: Error) => void;
17
- onTransactionSent?: (hash: Hash) => void;
17
+ onTransactionSent?: (hash?: Hash) => void;
18
18
  }
19
19
 
20
20
  export const useSell = ({
@@ -107,10 +107,12 @@ export const Modal = observer(
107
107
  orderbookKind,
108
108
  chainId,
109
109
  collectionAddress,
110
- onTransactionSent: (hash) => {
111
- if (!hash) return;
110
+ onTransactionSent: (hash, orderId) => {
111
+ if (!hash && !orderId) return;
112
+
112
113
  showTransactionStatusModal({
113
114
  hash,
115
+ orderId,
114
116
  collectionAddress,
115
117
  chainId,
116
118
  price: createListingModal$.listingPrice.get(),
@@ -93,10 +93,12 @@ const ModalContent = observer(
93
93
  chainId,
94
94
  collectionAddress,
95
95
  orderbookKind,
96
- onTransactionSent: (hash) => {
97
- if (!hash) return;
96
+ onTransactionSent: (hash, orderId) => {
97
+ if (!hash && !orderId) return;
98
+
98
99
  showTransactionStatusModal({
99
100
  hash,
101
+ orderId,
100
102
  price: makeOfferModal$.offerPrice.get(),
101
103
  collectionAddress,
102
104
  chainId,
@@ -39,16 +39,10 @@ const CurrencyOptionsSelect = observer(function CurrencyOptionsSelect({
39
39
  currencies.length > 0 &&
40
40
  !selectedCurrency$.get()?.contractAddress
41
41
  ) {
42
- console.debug('Setting default currency', currencies[0]);
43
42
  selectedCurrency$.set(currencies[0]);
44
43
  }
45
44
  }, [currencies]);
46
45
 
47
- console.debug('CurrencyOptionsSelect', {
48
- currencies,
49
- currenciesLoading,
50
- currency,
51
- });
52
46
  if (!currencies || currenciesLoading || !currency.symbol) {
53
47
  return <Skeleton borderRadius="lg" width="20" height="7" marginRight="3" />;
54
48
  }
@@ -5,7 +5,8 @@ import { Box, Spinner, Text } from '@0xsequence/design-system';
5
5
  import type { Hex } from 'viem';
6
6
 
7
7
  type TransactionFooterProps = {
8
- transactionHash: Hex;
8
+ transactionHash: Hex | undefined;
9
+ orderId?: string;
9
10
  isConfirming: boolean;
10
11
  isConfirmed: boolean;
11
12
  isFailed: boolean;
@@ -15,6 +16,7 @@ type TransactionFooterProps = {
15
16
 
16
17
  export default function TransactionFooter({
17
18
  transactionHash,
19
+ orderId,
18
20
  isConfirming,
19
21
  isConfirmed,
20
22
  isFailed,
@@ -22,12 +24,12 @@ export default function TransactionFooter({
22
24
  chainId,
23
25
  }: TransactionFooterProps) {
24
26
  const icon =
25
- (isConfirming && <Spinner size="md" />) ||
26
- (isConfirmed && <SvgPositiveCircleIcon size="md" />);
27
+ ((isConfirmed || orderId) && <SvgPositiveCircleIcon size="md" />) ||
28
+ (isConfirming && <Spinner size="md" />);
27
29
 
28
30
  const title =
31
+ ((isConfirmed || orderId) && 'Transaction complete') ||
29
32
  (isConfirming && 'Processing transaction') ||
30
- (isConfirmed && 'Transaction complete') ||
31
33
  (isFailed && 'Transaction failed') ||
32
34
  (isTimeout && 'Transaction took longer than expected');
33
35
 
@@ -64,7 +66,7 @@ export default function TransactionFooter({
64
66
  fontWeight="medium"
65
67
  fontFamily="body"
66
68
  >
67
- {truncateMiddle(transactionHash, 4, 4)}
69
+ {transactionHash && truncateMiddle(transactionHash, 4, 4)}
68
70
  </Text>
69
71
  </Box>
70
72
  </Box>
@@ -16,6 +16,7 @@ import type { TokenMetadata } from '@0xsequence/metadata';
16
16
  import ChessTileImage from '../../../../images/chess-tile.png';
17
17
 
18
18
  type TransactionPreviewProps = {
19
+ orderId?: string;
19
20
  price?: Price;
20
21
  collectionAddress: Hex;
21
22
  chainId: string;
@@ -30,6 +31,7 @@ type TransactionPreviewProps = {
30
31
 
31
32
  const TransactionPreview = observer(
32
33
  ({
34
+ orderId,
33
35
  price,
34
36
  collectionAddress,
35
37
  chainId,
@@ -43,6 +45,7 @@ const TransactionPreview = observer(
43
45
  }: TransactionPreviewProps) => {
44
46
  const { type } = transactionStatusModal$.state.get();
45
47
  const title = useTransactionPreviewTitle(
48
+ orderId,
46
49
  { isConfirmed, isConfirming, isFailed, isTimeout },
47
50
  type,
48
51
  );
@@ -1,22 +1,20 @@
1
- import { useMemo } from 'react';
2
1
  import type { ConfirmationStatus } from '../transactionStatusModal/store';
3
2
  import { TRANSACTION_TITLES } from './consts';
4
3
  import { TransactionType } from '../../../../../_internal/transaction-machine/execute-transaction';
5
4
 
6
5
  export function useTransactionPreviewTitle(
6
+ orderId: string | undefined,
7
7
  status: ConfirmationStatus,
8
8
  type?: TransactionType | undefined,
9
9
  ): string {
10
- return useMemo(() => {
11
- if (!type) return '';
10
+ if (!type) return '';
12
11
 
13
- const { isConfirming, isConfirmed, isFailed } = status;
14
- const titles = TRANSACTION_TITLES[type];
12
+ const { isConfirming, isConfirmed, isFailed } = status;
13
+ const titles = TRANSACTION_TITLES[type];
15
14
 
16
- if (isConfirming) return titles.confirming;
17
- if (isConfirmed) return titles.confirmed;
18
- if (isFailed) return titles.failed;
15
+ if (isConfirmed || orderId) return titles.confirmed;
16
+ if (isConfirming) return titles.confirming;
17
+ if (isFailed) return titles.failed;
19
18
 
20
- return '';
21
- }, [status, type]);
19
+ return '';
22
20
  }
@@ -29,7 +29,8 @@ import { getTransactionStatusModalTitle } from './util/getTitle';
29
29
  import { getTransactionStatusModalMessage } from './util/getMessage';
30
30
 
31
31
  export type ShowTransactionStatusModalArgs = {
32
- hash: Hex;
32
+ hash?: Hex;
33
+ orderId?: string;
33
34
  price?: Price;
34
35
  collectionAddress: Hex;
35
36
  chainId: string;
@@ -56,6 +57,7 @@ const TransactionStatusModal = observer(() => {
56
57
  const {
57
58
  type,
58
59
  hash,
60
+ orderId,
59
61
  price,
60
62
  collectionAddress,
61
63
  chainId,
@@ -69,16 +71,19 @@ const TransactionStatusModal = observer(() => {
69
71
  chainId,
70
72
  collectibleId,
71
73
  });
72
- const [transactionStatus, setTransactionStatus] =
73
- useState<TransactionStatus>('PENDING');
74
+ const [transactionStatus, setTransactionStatus] = useState<TransactionStatus>(
75
+ orderId ? 'SUCCESS' : 'PENDING',
76
+ );
74
77
  const title = getTransactionStatusModalTitle({
75
78
  transactionStatus,
76
79
  transactionType: type!,
80
+ orderId,
77
81
  });
78
82
  const message = getTransactionStatusModalMessage({
79
83
  transactionStatus,
80
84
  transactionType: type!,
81
85
  collectibleName: collectible?.name || '',
86
+ orderId,
82
87
  });
83
88
  const { onError, onSuccess }: ModalCallbacks = callbacks || {};
84
89
  const queryClient = getQueryClient();
@@ -146,6 +151,7 @@ const TransactionStatusModal = observer(() => {
146
151
  )}
147
152
 
148
153
  <TransactionPreview
154
+ orderId={orderId}
149
155
  price={price}
150
156
  collectionAddress={collectionAddress}
151
157
  chainId={chainId}
@@ -159,7 +165,8 @@ const TransactionStatusModal = observer(() => {
159
165
  />
160
166
 
161
167
  <TransactionFooter
162
- transactionHash={hash!}
168
+ transactionHash={hash}
169
+ orderId={orderId}
163
170
  isConfirming={transactionStatus === 'PENDING'}
164
171
  isConfirmed={transactionStatus === 'SUCCESS'}
165
172
  isFailed={transactionStatus === 'FAILED'}
@@ -21,6 +21,7 @@ export interface TransactionStatusModalState {
21
21
  close: () => void;
22
22
  state: {
23
23
  hash: Hex | undefined;
24
+ orderId: string | undefined;
24
25
  status: TransactionStatus;
25
26
  type: TransactionType | undefined;
26
27
  price: Price | undefined;
@@ -38,6 +39,7 @@ export const initialState: TransactionStatusModalState = {
38
39
  isOpen: false,
39
40
  open: ({
40
41
  hash,
42
+ orderId,
41
43
  price,
42
44
  collectionAddress,
43
45
  chainId,
@@ -51,6 +53,7 @@ export const initialState: TransactionStatusModalState = {
51
53
  transactionStatusModal$.state.set({
52
54
  ...transactionStatusModal$.state.get(),
53
55
  hash,
56
+ orderId,
54
57
  price,
55
58
  collectionAddress,
56
59
  chainId,
@@ -71,6 +74,7 @@ export const initialState: TransactionStatusModalState = {
71
74
  },
72
75
  state: {
73
76
  hash: undefined,
77
+ orderId: undefined,
74
78
  status: 'PENDING',
75
79
  price: undefined,
76
80
  collectionAddress: '' as Hex,
@@ -6,14 +6,20 @@ export function getTransactionStatusModalMessage({
6
6
  transactionStatus,
7
7
  transactionType,
8
8
  collectibleName,
9
+ orderId,
9
10
  }: {
10
11
  transactionStatus: TransactionStatus;
11
12
  transactionType: TransactionType;
12
13
  collectibleName: string;
14
+ orderId?: string;
13
15
  }): string {
14
16
  // without this, the text will be "Your cancellation CollectibleXXX has failed." which sounds weird
15
17
  const hideCollectibleName = transactionType === 'CANCEL';
16
18
 
19
+ if (orderId) {
20
+ return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ''}. It's been confirmed on the blockchain!`;
21
+ }
22
+
17
23
  switch (transactionStatus) {
18
24
  case 'PENDING':
19
25
  return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ''}. It should be confirmed on the blockchain shortly.`;
@@ -5,10 +5,16 @@ import { getFormattedType } from './getFormattedType';
5
5
  export function getTransactionStatusModalTitle({
6
6
  transactionStatus,
7
7
  transactionType,
8
+ orderId,
8
9
  }: {
9
10
  transactionStatus: TransactionStatus;
10
11
  transactionType: TransactionType;
12
+ orderId?: string;
11
13
  }): string {
14
+ if (orderId) {
15
+ return `Your ${getFormattedType(transactionType)} has processed`;
16
+ }
17
+
12
18
  switch (transactionStatus) {
13
19
  case 'PENDING':
14
20
  return `Your ${getFormattedType(transactionType)} is processing`;
@@ -84,6 +84,16 @@ export class InsufficientFundsError extends TransactionError {
84
84
  }
85
85
  }
86
86
 
87
+ export class SignatureExecutionError extends TransactionError {
88
+ override name = 'SignatureExecutionError';
89
+ constructor(signature: string, cause?: Error) {
90
+ super(`Failed to execute signature: ${signature}`, {
91
+ details: cause?.message || 'The execution of the signature failed.',
92
+ cause,
93
+ });
94
+ }
95
+ }
96
+
87
97
  export class StepExecutionError extends TransactionError {
88
98
  override name = 'StepExecutionError';
89
99
  constructor(stepId: string, cause?: Error) {