@0xsequence/marketplace-sdk 0.8.3 → 0.8.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 (97) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/{chunk-25CAMYCG.js → chunk-BB2PTJHI.js} +22 -20
  3. package/dist/chunk-BB2PTJHI.js.map +1 -0
  4. package/dist/{chunk-5ATGT5S4.js → chunk-EZFCQZHU.js} +14 -6
  5. package/dist/chunk-EZFCQZHU.js.map +1 -0
  6. package/dist/{chunk-DFI52A2E.js → chunk-KCLMSSPS.js} +364 -242
  7. package/dist/chunk-KCLMSSPS.js.map +1 -0
  8. package/dist/{chunk-XUNDLCEH.js → chunk-LDZZUYG7.js} +2 -2
  9. package/dist/{chunk-QTV77W42.js → chunk-SFSFIGHM.js} +45 -35
  10. package/dist/chunk-SFSFIGHM.js.map +1 -0
  11. package/dist/{chunk-FSJKN4YN.js → chunk-ZSCZLHKX.js} +194 -2
  12. package/dist/chunk-ZSCZLHKX.js.map +1 -0
  13. package/dist/{chunk-FH4TZRDV.js → chunk-ZVTG6US2.js} +2 -2
  14. package/dist/index.css +4 -4
  15. package/dist/index.css.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/{lowestListing-DUZ_nYml.d.ts → lowestListing-W7P4EkC3.d.ts} +34 -11
  18. package/dist/react/_internal/databeat/index.js +5 -5
  19. package/dist/react/_internal/index.d.ts +1 -1
  20. package/dist/react/_internal/index.js +3 -1
  21. package/dist/react/_internal/wagmi/index.d.ts +3 -2
  22. package/dist/react/_internal/wagmi/index.js +3 -1
  23. package/dist/react/hooks/index.d.ts +8 -5
  24. package/dist/react/hooks/index.js +6 -4
  25. package/dist/react/hooks/options/index.js +2 -2
  26. package/dist/react/index.d.ts +2 -2
  27. package/dist/react/index.js +9 -7
  28. package/dist/react/queries/index.d.ts +1 -1
  29. package/dist/react/queries/index.js +6 -2
  30. package/dist/react/ssr/index.js +1 -1
  31. package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
  32. package/dist/react/ui/components/collectible-card/index.js +7 -7
  33. package/dist/react/ui/icons/index.js +1 -1
  34. package/dist/react/ui/index.js +7 -7
  35. package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -5
  36. package/dist/types/index.js +1 -1
  37. package/dist/utils/index.js +1 -1
  38. package/package.json +19 -19
  39. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +35 -21
  40. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +1 -11
  41. package/src/react/_internal/wagmi/get-connectors.ts +27 -24
  42. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +4 -9
  43. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +5 -4
  44. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +14 -10
  45. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +115 -65
  46. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +10 -7
  47. package/src/react/hooks/__tests__/useInventory.test.tsx +294 -0
  48. package/src/react/hooks/index.ts +1 -0
  49. package/src/react/hooks/useAutoSelectFeeOption.tsx +10 -3
  50. package/src/react/hooks/useCancelOrder.tsx +1 -0
  51. package/src/react/hooks/useCancelTransactionSteps.tsx +18 -4
  52. package/src/react/hooks/useGenerateOfferTransaction.tsx +11 -1
  53. package/src/react/hooks/useInventory.tsx +15 -0
  54. package/src/react/hooks/util/optimisticCancelUpdates.ts +115 -0
  55. package/src/react/queries/index.ts +1 -0
  56. package/src/react/queries/inventory.ts +303 -0
  57. package/src/react/queries/listBalances.ts +1 -8
  58. package/src/react/queries/listCollectibles.ts +12 -3
  59. package/src/react/ui/components/_internals/action-button/__tests__/ActionButtonBody.test.tsx +27 -94
  60. package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +59 -0
  61. package/src/react/ui/components/_internals/action-button/__tests__/OwnerActions.test.tsx +73 -0
  62. package/src/react/ui/components/_internals/action-button/__tests__/useActionButtonLogic.test.tsx +77 -0
  63. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +3 -2
  64. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +4 -3
  65. package/src/react/ui/components/collectible-card/CollectibleAsset.tsx +1 -0
  66. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +18 -12
  67. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +200 -0
  68. package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +92 -123
  69. package/src/react/ui/components/collectible-card/__tests__/Footer.test.tsx +136 -0
  70. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +2 -8
  71. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +74 -104
  72. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +108 -78
  73. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +72 -135
  74. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +286 -0
  75. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +16 -4
  76. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +35 -132
  77. package/src/react/ui/modals/_internal/components/floorPriceText/__tests__/FloorPriceText.test.tsx +199 -0
  78. package/src/react/ui/modals/_internal/components/priceInput/__tests__/PriceInput.test.tsx +55 -0
  79. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +1 -1
  80. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/ActionButtons.test.tsx +72 -0
  81. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/BalanceIndicator.test.tsx +50 -0
  82. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +193 -0
  83. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
  84. package/test/const.ts +24 -0
  85. package/test/test-utils.tsx +85 -47
  86. package/.changeset/flat-parks-clean.md +0 -8
  87. package/.changeset/red-buckets-deny.md +0 -6
  88. package/.changeset/seven-doors-taste.md +0 -5
  89. package/dist/chunk-25CAMYCG.js.map +0 -1
  90. package/dist/chunk-5ATGT5S4.js.map +0 -1
  91. package/dist/chunk-DFI52A2E.js.map +0 -1
  92. package/dist/chunk-FSJKN4YN.js.map +0 -1
  93. package/dist/chunk-QTV77W42.js.map +0 -1
  94. package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +0 -107
  95. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +0 -164
  96. /package/dist/{chunk-XUNDLCEH.js.map → chunk-LDZZUYG7.js.map} +0 -0
  97. /package/dist/{chunk-FH4TZRDV.js.map → chunk-ZVTG6US2.js.map} +0 -0
@@ -174,16 +174,6 @@ describe('createWagmiConfig', () => {
174
174
 
175
175
  describe('failure cases', () => {
176
176
  it('should throw error when trying to use embedded wallet without waasConfigKey', () => {
177
- const marketplaceConfig: MarketplaceConfig = {
178
- ...baseMarketplaceConfig,
179
- walletOptions: {
180
- connectors: ['walletconnect'],
181
- includeEIP6963Wallets: false,
182
- walletType: MarketplaceWallet.EMBEDDED,
183
- oidcIssuers: {},
184
- },
185
- };
186
-
187
177
  const sdkConfig: SdkConfig = {
188
178
  ...baseSdkConfig,
189
179
  wallet: {
@@ -197,7 +187,7 @@ describe('createWagmiConfig', () => {
197
187
  };
198
188
 
199
189
  expect(() =>
200
- getWaasConnectors(marketplaceConfig, {
190
+ getWaasConnectors({
201
191
  ...sdkConfig,
202
192
  wallet: {
203
193
  ...sdkConfig.wallet,
@@ -39,8 +39,12 @@ export function getConnectors({
39
39
 
40
40
  if (walletType === MarketplaceWallet.UNIVERSAL) {
41
41
  connectors.push(...getUniversalWalletConfigs(sdkConfig, marketplaceConfig));
42
+ } else if (walletType === MarketplaceWallet.EMBEDDED) {
43
+ connectors.push(...getWaasConnectors(sdkConfig));
44
+ } else if (walletType === MarketplaceWallet.ECOSYSTEM) {
45
+ connectors.push(getEcosystemConnector(marketplaceConfig, sdkConfig));
42
46
  } else {
43
- connectors.push(...getWaasConnectors(marketplaceConfig, sdkConfig));
47
+ throw new Error('Invalid wallet type');
44
48
  }
45
49
 
46
50
  return getConnectWallets(sdkConfig.projectAccessKey, connectors);
@@ -106,10 +110,7 @@ function getUniversalWalletConfigs(
106
110
  ] as const;
107
111
  }
108
112
 
109
- export function getWaasConnectors(
110
- marketplaceConfig: MarketplaceConfig,
111
- sdkConfig: SdkConfig,
112
- ): Wallet[] {
113
+ export function getWaasConnectors(sdkConfig: SdkConfig): Wallet[] {
113
114
  const { projectAccessKey } = sdkConfig;
114
115
 
115
116
  const waasConfigKey = sdkConfig.wallet?.embedded?.waasConfigKey;
@@ -150,33 +151,35 @@ export function getWaasConnectors(
150
151
  );
151
152
  }
152
153
 
153
- const walletType = marketplaceConfig.walletOptions.walletType;
154
- if (walletType === MarketplaceWallet.ECOSYSTEM) {
155
- const ecosystemOptions = marketplaceConfig.walletOptions.ecosystem;
156
- if (!ecosystemOptions) throw new MissingConfigError('ecosystem');
157
- const { walletAppName, walletUrl, logoDarkUrl, logoLightUrl } =
158
- ecosystemOptions;
159
- wallets.push(
160
- ecosystemWallet({
161
- projectAccessKey: sdkConfig.projectAccessKey,
162
- walletUrl,
163
- name: walletAppName,
164
- defaultNetwork: DEFAULT_NETWORK,
165
- logoDark: getEcosystemLogo(logoDarkUrl, walletAppName),
166
- logoLight: getEcosystemLogo(logoLightUrl, walletAppName),
167
- }),
168
- );
169
- }
170
-
171
154
  return wallets;
172
155
  }
173
156
 
157
+ export function getEcosystemConnector(
158
+ marketplaceConfig: MarketplaceConfig,
159
+ sdkConfig: SdkConfig,
160
+ ): Wallet {
161
+ const ecosystemOptions = marketplaceConfig.walletOptions.ecosystem;
162
+ if (!ecosystemOptions) throw new MissingConfigError('ecosystem');
163
+ const { walletAppName, walletUrl, logoDarkUrl, logoLightUrl } =
164
+ ecosystemOptions;
165
+
166
+ return ecosystemWallet({
167
+ projectAccessKey: sdkConfig.projectAccessKey,
168
+ walletUrl,
169
+ name: walletAppName,
170
+ defaultNetwork: DEFAULT_NETWORK,
171
+ logoDark: getEcosystemLogo(logoDarkUrl, walletAppName),
172
+ logoLight: getEcosystemLogo(logoLightUrl, walletAppName),
173
+ });
174
+ }
175
+
174
176
  function getEcosystemLogo(
175
177
  url: string | undefined,
176
178
  name: string,
177
179
  ): FunctionComponent {
178
180
  if (!url) return () => null;
179
- const Logo = () => React.createElement('img', { src: url, alt: name });
181
+ const Logo = () =>
182
+ React.createElement('img', { src: url, alt: name, width: 32, height: 32 });
180
183
  Logo.displayName = 'EcosystemLogo';
181
184
  return Logo;
182
185
  }
@@ -12,8 +12,9 @@ import {
12
12
  WalletInstanceNotFoundError,
13
13
  } from '../../../utils/_internal/error/transaction';
14
14
  import {
15
+ createMockStep,
16
+ createMockSteps,
15
17
  mockMarketplaceEndpoint,
16
- mockSteps,
17
18
  } from '../../_internal/api/__mocks__/marketplace.msw';
18
19
  import { MarketplaceKind, StepType } from '../../_internal/api/marketplace.gen';
19
20
  import { useWallet } from '../../_internal/wallet/useWallet';
@@ -66,12 +67,7 @@ describe('useCancelTransactionSteps', () => {
66
67
  server.use(
67
68
  http.post(mockMarketplaceEndpoint('GenerateCancelTransaction'), () => {
68
69
  return HttpResponse.json({
69
- steps: [
70
- {
71
- ...mockSteps[0],
72
- id: StepType.cancel,
73
- },
74
- ],
70
+ steps: createMockSteps([StepType.cancel]),
75
71
  });
76
72
  }),
77
73
  );
@@ -106,8 +102,7 @@ describe('useCancelTransactionSteps', () => {
106
102
  return HttpResponse.json({
107
103
  steps: [
108
104
  {
109
- ...mockSteps[0],
110
- id: StepType.signEIP712,
105
+ ...createMockStep(StepType.signEIP712),
111
106
  },
112
107
  ],
113
108
  });
@@ -3,10 +3,11 @@ import { http, HttpResponse } from 'msw';
3
3
  import { zeroAddress } from 'viem';
4
4
  import { describe, expect, it, vi } from 'vitest';
5
5
  import {
6
+ createMockStep,
7
+ createMockSteps,
6
8
  mockMarketplaceEndpoint,
7
- mockSteps,
8
9
  } from '../../_internal/api/__mocks__/marketplace.msw';
9
- import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
10
+ import { MarketplaceKind, StepType } from '../../_internal/api/marketplace.gen';
10
11
  import { useGenerateCancelTransaction } from '../useGenerateCancelTransaction';
11
12
 
12
13
  const defaultArgs = {
@@ -28,7 +29,7 @@ describe('useGenerateCancelTransaction', () => {
28
29
  });
29
30
 
30
31
  await waitFor(() => {
31
- expect(result.current.data).toEqual(mockSteps);
32
+ expect(result.current.data).toEqual(createMockSteps([StepType.cancel]));
32
33
  });
33
34
  expect(result.current.error).toBeNull();
34
35
  });
@@ -123,7 +124,7 @@ describe('useGenerateCancelTransaction', () => {
123
124
 
124
125
  await waitFor(() => {
125
126
  expect(onSuccess).toHaveBeenCalledWith(
126
- [mockSteps[0]],
127
+ [createMockStep(StepType.cancel)],
127
128
  defaultArgs,
128
129
  undefined,
129
130
  );
@@ -51,11 +51,13 @@ describe('useGenerateListingTransaction', () => {
51
51
  {
52
52
  "data": "0x...",
53
53
  "id": "tokenApproval",
54
- "post": {
55
- "body": {},
56
- "endpoint": "/api/order",
57
- "method": "POST",
58
- },
54
+ "price": "0",
55
+ "to": "0x1234567890123456789012345678901234567890",
56
+ "value": "0",
57
+ },
58
+ {
59
+ "data": "0x...",
60
+ "id": "createListing",
59
61
  "price": "0",
60
62
  "to": "0x1234567890123456789012345678901234567890",
61
63
  "value": "0",
@@ -96,11 +98,13 @@ describe('useGenerateListingTransaction', () => {
96
98
  {
97
99
  "data": "0x...",
98
100
  "id": "tokenApproval",
99
- "post": {
100
- "body": {},
101
- "endpoint": "/api/order",
102
- "method": "POST",
103
- },
101
+ "price": "0",
102
+ "to": "0x1234567890123456789012345678901234567890",
103
+ "value": "0",
104
+ },
105
+ {
106
+ "data": "0x...",
107
+ "id": "createListing",
104
108
  "price": "0",
105
109
  "to": "0x1234567890123456789012345678901234567890",
106
110
  "value": "0",
@@ -1,12 +1,19 @@
1
1
  import { renderHook, server, waitFor } from '@test';
2
+ import { createMockWallet } from '@test/mocks/wallet';
2
3
  import { http, HttpResponse } from 'msw';
3
4
  import { zeroAddress } from 'viem';
4
5
  import { beforeEach, describe, expect, it, vi } from 'vitest';
5
- import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
6
+ import {
7
+ createMockSteps,
8
+ mockMarketplaceEndpoint,
9
+ } from '../../_internal/api/__mocks__/marketplace.msw';
6
10
  import {
7
11
  ContractType,
8
12
  OrderbookKind,
13
+ StepType,
14
+ WalletKind,
9
15
  } from '../../_internal/api/marketplace.gen';
16
+ import * as walletModule from '../../_internal/wallet/useWallet';
10
17
  import { useGenerateOfferTransaction } from '../useGenerateOfferTransaction';
11
18
 
12
19
  describe('useGenerateOfferTransaction', () => {
@@ -44,38 +51,9 @@ describe('useGenerateOfferTransaction', () => {
44
51
 
45
52
  await result.current.generateOfferTransactionAsync(mockTransactionProps);
46
53
 
47
- expect(mockOnSuccess.mock.lastCall).toMatchInlineSnapshot(`
48
- [
49
- [
50
- {
51
- "data": "0x...",
52
- "id": "tokenApproval",
53
- "post": {
54
- "body": {},
55
- "endpoint": "/api/order",
56
- "method": "POST",
57
- },
58
- "price": "0",
59
- "to": "0x1234567890123456789012345678901234567890",
60
- "value": "0",
61
- },
62
- ],
63
- {
64
- "collectionAddress": "0x0000000000000000000000000000000000000000",
65
- "contractType": "ERC721",
66
- "maker": "0x0000000000000000000000000000000000000000",
67
- "offer": {
68
- "currencyAddress": "0x0000000000000000000000000000000000000000",
69
- "expiry": 2024-12-31T00:00:00.000Z,
70
- "pricePerToken": "1000000000000000000",
71
- "quantity": "1",
72
- "tokenId": "1",
73
- },
74
- "orderbook": "sequence_marketplace_v2",
75
- },
76
- undefined,
77
- ]
78
- `);
54
+ expect(mockOnSuccess).toHaveBeenCalled();
55
+ const steps = mockOnSuccess.mock.calls[0]?.[0];
56
+ expect(steps.length).toBeGreaterThan(0);
79
57
  });
80
58
 
81
59
  it('should handle non-async generation with callback', async () => {
@@ -88,38 +66,9 @@ describe('useGenerateOfferTransaction', () => {
88
66
  await waitFor(() => {
89
67
  expect(mockOnSuccess).toHaveBeenCalled();
90
68
  });
91
- expect(mockOnSuccess.mock.lastCall).toMatchInlineSnapshot(`
92
- [
93
- [
94
- {
95
- "data": "0x...",
96
- "id": "tokenApproval",
97
- "post": {
98
- "body": {},
99
- "endpoint": "/api/order",
100
- "method": "POST",
101
- },
102
- "price": "0",
103
- "to": "0x1234567890123456789012345678901234567890",
104
- "value": "0",
105
- },
106
- ],
107
- {
108
- "collectionAddress": "0x0000000000000000000000000000000000000000",
109
- "contractType": "ERC721",
110
- "maker": "0x0000000000000000000000000000000000000000",
111
- "offer": {
112
- "currencyAddress": "0x0000000000000000000000000000000000000000",
113
- "expiry": 2024-12-31T00:00:00.000Z,
114
- "pricePerToken": "1000000000000000000",
115
- "quantity": "1",
116
- "tokenId": "1",
117
- },
118
- "orderbook": "sequence_marketplace_v2",
119
- },
120
- undefined,
121
- ]
122
- `);
69
+
70
+ const steps = mockOnSuccess.mock.calls[0]?.[0];
71
+ expect(steps.length).toBeGreaterThan(0);
123
72
  });
124
73
 
125
74
  it('should handle API errors', async () => {
@@ -166,4 +115,105 @@ describe('useGenerateOfferTransaction', () => {
166
115
 
167
116
  expect(mockOnSuccess).not.toHaveBeenCalled();
168
117
  });
118
+
119
+ describe('wallet-specific behavior', () => {
120
+ // Create mock wallets for different types
121
+ const mockSequenceWallet = createMockWallet({
122
+ walletKind: WalletKind.sequence,
123
+ });
124
+
125
+ const mockNonSequenceWallet = createMockWallet({
126
+ walletKind: WalletKind.unknown,
127
+ });
128
+
129
+ it('should not include tokenApproval step for Sequence wallet', async () => {
130
+ // Mock useWallet to return a Sequence wallet
131
+ const useWalletSpy = vi.spyOn(walletModule, 'useWallet');
132
+ useWalletSpy.mockReturnValue({
133
+ wallet: mockSequenceWallet,
134
+ isLoading: false,
135
+ isError: false,
136
+ });
137
+
138
+ // Override the default handler to include walletKind in the response
139
+ server.use(
140
+ http.post(
141
+ mockMarketplaceEndpoint('GenerateOfferTransaction'),
142
+ async ({ request }) => {
143
+ // Add wallet type to the request payload
144
+ const reqBody = (await request.json()) as Record<string, unknown>;
145
+ reqBody.walletType = WalletKind.sequence;
146
+
147
+ // For Sequence wallet - only return createOffer step
148
+ return HttpResponse.json({
149
+ steps: createMockSteps([StepType.createOffer]),
150
+ });
151
+ },
152
+ ),
153
+ );
154
+
155
+ const { result } = renderHook(() =>
156
+ useGenerateOfferTransaction(defaultArgs),
157
+ );
158
+
159
+ await result.current.generateOfferTransactionAsync(mockTransactionProps);
160
+
161
+ expect(mockOnSuccess).toHaveBeenCalled();
162
+ const steps = mockOnSuccess.mock.calls[0]?.[0];
163
+
164
+ // Verify there is only one step: createOffer (no tokenApproval)
165
+ expect(steps).toHaveLength(1);
166
+ expect(steps[0].id).toBe('createOffer');
167
+
168
+ // Restore the original useWallet implementation
169
+ useWalletSpy.mockRestore();
170
+ });
171
+
172
+ it('should include tokenApproval step for non-Sequence wallet', async () => {
173
+ // Mock useWallet to return a non-Sequence wallet
174
+ const useWalletSpy = vi.spyOn(walletModule, 'useWallet');
175
+ useWalletSpy.mockReturnValue({
176
+ wallet: mockNonSequenceWallet,
177
+ isLoading: false,
178
+ isError: false,
179
+ });
180
+
181
+ // Override the default handler to include walletKind in the response
182
+ server.use(
183
+ http.post(
184
+ mockMarketplaceEndpoint('GenerateOfferTransaction'),
185
+ async ({ request }) => {
186
+ // Add wallet type to the request payload
187
+ const reqBody = (await request.json()) as Record<string, unknown>;
188
+ reqBody.walletType = WalletKind.unknown;
189
+
190
+ // For non-Sequence wallet - return tokenApproval and createOffer steps
191
+ return HttpResponse.json({
192
+ steps: createMockSteps([
193
+ StepType.tokenApproval,
194
+ StepType.createOffer,
195
+ ]),
196
+ });
197
+ },
198
+ ),
199
+ );
200
+
201
+ const { result } = renderHook(() =>
202
+ useGenerateOfferTransaction(defaultArgs),
203
+ );
204
+
205
+ await result.current.generateOfferTransactionAsync(mockTransactionProps);
206
+
207
+ expect(mockOnSuccess).toHaveBeenCalled();
208
+ const steps = mockOnSuccess.mock.calls[0]?.[0];
209
+
210
+ // Verify there are two steps: tokenApproval and createOffer
211
+ expect(steps).toHaveLength(2);
212
+ expect(steps[0].id).toBe('tokenApproval');
213
+ expect(steps[1].id).toBe('createOffer');
214
+
215
+ // Restore the original useWallet implementation
216
+ useWalletSpy.mockRestore();
217
+ });
218
+ });
169
219
  });
@@ -3,13 +3,14 @@ import { http, HttpResponse } from 'msw';
3
3
  import { zeroAddress } from 'viem';
4
4
  import { beforeEach, describe, expect, it, vi } from 'vitest';
5
5
  import {
6
+ createMockSteps,
6
7
  mockMarketplaceEndpoint,
7
- mockSteps,
8
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
9
9
  import {
10
10
  ContractType,
11
11
  MarketplaceKind,
12
12
  OrderbookKind,
13
+ StepType,
13
14
  } from '../../_internal/api/marketplace.gen';
14
15
  import { useGenerateSellTransaction } from '../useGenerateSellTransaction';
15
16
 
@@ -53,11 +54,13 @@ describe('useGenerateSellTransaction', () => {
53
54
  {
54
55
  "data": "0x...",
55
56
  "id": "tokenApproval",
56
- "post": {
57
- "body": {},
58
- "endpoint": "/api/order",
59
- "method": "POST",
60
- },
57
+ "price": "0",
58
+ "to": "0x1234567890123456789012345678901234567890",
59
+ "value": "0",
60
+ },
61
+ {
62
+ "data": "0x...",
63
+ "id": "sell",
61
64
  "price": "0",
62
65
  "to": "0x1234567890123456789012345678901234567890",
63
66
  "value": "0",
@@ -91,7 +94,7 @@ describe('useGenerateSellTransaction', () => {
91
94
 
92
95
  await waitFor(() => {
93
96
  expect(mockOnSuccess).toHaveBeenCalledWith(
94
- mockSteps,
97
+ createMockSteps([StepType.tokenApproval, StepType.sell]),
95
98
  mockTransactionProps,
96
99
  undefined,
97
100
  );