@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
@@ -0,0 +1,193 @@
1
+ import { TokenType } from '@0xsequence/api';
2
+ import * as useNetworkModule from '@0xsequence/connect';
3
+ import * as useWaasFeeOptionsModule from '@0xsequence/connect';
4
+ import { NetworkType } from '@0xsequence/network';
5
+ import { observable } from '@legendapp/state';
6
+ import { render, screen } from '@test';
7
+ import { TEST_CURRENCY } from '@test/const';
8
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
9
+ import SelectWaasFeeOptions from '..';
10
+ import type {
11
+ FeeOption,
12
+ FeeOptionExtended,
13
+ WaasFeeOptionConfirmation,
14
+ } from '../../../../../../../types/waas-types';
15
+ import { selectWaasFeeOptions$ } from '../store';
16
+ import * as useWaasFeeOptionManagerModule from '../useWaasFeeOptionManager';
17
+
18
+ const mockFeeOption: FeeOptionExtended = {
19
+ gasLimit: 21000,
20
+ to: '0x123',
21
+ value: '1000000000000000',
22
+ token: {
23
+ chainId: 1,
24
+ contractAddress: TEST_CURRENCY.contractAddress,
25
+ decimals: TEST_CURRENCY.decimals,
26
+ logoURL: TEST_CURRENCY.imageUrl,
27
+ name: TEST_CURRENCY.name,
28
+ symbol: TEST_CURRENCY.symbol,
29
+ tokenID: null,
30
+ type: TokenType.ERC20,
31
+ },
32
+ balance: '1000000000000000',
33
+ balanceFormatted: '1',
34
+ hasEnoughBalanceForFee: true,
35
+ };
36
+
37
+ const mockPendingFeeOptionConfirmation: WaasFeeOptionConfirmation = {
38
+ id: 'fee-confirmation-id',
39
+ options: [mockFeeOption],
40
+ chainId: 1,
41
+ };
42
+
43
+ // Mock currency balance with formatted value
44
+ const mockCurrencyBalance = {
45
+ value: 2000000000000000n,
46
+ formatted: '0.002',
47
+ };
48
+
49
+ describe('SelectWaasFeeOptions', () => {
50
+ const mockOnCancel = vi.fn();
51
+ const mockHandleConfirmFeeOption = vi.fn();
52
+
53
+ beforeEach(() => {
54
+ vi.resetAllMocks();
55
+ vi.resetModules();
56
+
57
+ selectWaasFeeOptions$.isVisible.set(true);
58
+ selectWaasFeeOptions$.selectedFeeOption.set(undefined);
59
+ selectWaasFeeOptions$.pendingFeeOptionConfirmation.set(undefined);
60
+ });
61
+
62
+ it('should not render when isVisible is false', () => {
63
+ vi.spyOn(useWaasFeeOptionManagerModule, 'default').mockReturnValue({
64
+ selectedFeeOption$: observable<FeeOptionExtended | undefined>(
65
+ mockFeeOption,
66
+ ),
67
+ selectedFeeOption: mockFeeOption,
68
+ // @ts-expect-error - types are not compatible
69
+ pendingFeeOptionConfirmation: mockPendingFeeOptionConfirmation,
70
+ currencyBalance: mockCurrencyBalance,
71
+ currencyBalanceLoading: false,
72
+ insufficientBalance: false,
73
+ feeOptionsConfirmed: false,
74
+ handleConfirmFeeOption: mockHandleConfirmFeeOption,
75
+ });
76
+
77
+ // Set isVisible to false
78
+ selectWaasFeeOptions$.isVisible.set(false);
79
+
80
+ const { container } = render(
81
+ <SelectWaasFeeOptions chainId={1} onCancel={mockOnCancel} />,
82
+ );
83
+
84
+ expect(container.firstChild).toBeNull();
85
+ });
86
+
87
+ it('should not render on testnet', () => {
88
+ vi.spyOn(useWaasFeeOptionManagerModule, 'default').mockReturnValue({
89
+ selectedFeeOption$: observable<FeeOption | undefined>(mockFeeOption),
90
+ selectedFeeOption: mockFeeOption,
91
+ // @ts-expect-error - types are not compatible
92
+ pendingFeeOptionConfirmation: mockPendingFeeOptionConfirmation,
93
+ currencyBalance: mockCurrencyBalance,
94
+ currencyBalanceLoading: false,
95
+ insufficientBalance: false,
96
+ feeOptionsConfirmed: false,
97
+ handleConfirmFeeOption: mockHandleConfirmFeeOption,
98
+ });
99
+
100
+ vi.spyOn(useNetworkModule, 'getNetwork').mockReturnValue({
101
+ type: NetworkType.TESTNET,
102
+ chainId: 1,
103
+ name: 'Testnet',
104
+ nativeToken: TEST_CURRENCY,
105
+ });
106
+ vi.spyOn(useWaasFeeOptionsModule, 'useWaasFeeOptions').mockReturnValue([
107
+ // @ts-expect-error - types are not compatible
108
+ mockPendingFeeOptionConfirmation,
109
+ vi.fn(),
110
+ ]);
111
+
112
+ const { container } = render(
113
+ <SelectWaasFeeOptions chainId={1} onCancel={mockOnCancel} />,
114
+ );
115
+
116
+ expect(container.firstChild).toBeNull();
117
+ });
118
+
119
+ it('should render loading skeleton when fee options are loading', () => {
120
+ // Mock the hook with loading state
121
+ vi.spyOn(useWaasFeeOptionManagerModule, 'default').mockReturnValue({
122
+ selectedFeeOption$: observable<FeeOption | undefined>(undefined),
123
+ selectedFeeOption: mockFeeOption,
124
+ pendingFeeOptionConfirmation: undefined,
125
+ currencyBalance: undefined,
126
+ currencyBalanceLoading: true,
127
+ insufficientBalance: false,
128
+ feeOptionsConfirmed: false,
129
+ handleConfirmFeeOption: mockHandleConfirmFeeOption,
130
+ });
131
+ vi.spyOn(useWaasFeeOptionsModule, 'useWaasFeeOptions').mockReturnValue([
132
+ // @ts-expect-error - types are not compatible
133
+ mockPendingFeeOptionConfirmation,
134
+ vi.fn(),
135
+ ]);
136
+ vi.spyOn(useNetworkModule, 'getNetwork').mockReturnValue({
137
+ type: NetworkType.MAINNET,
138
+ chainId: 1,
139
+ name: 'Mainnet',
140
+ nativeToken: TEST_CURRENCY,
141
+ });
142
+
143
+ render(<SelectWaasFeeOptions chainId={1} onCancel={mockOnCancel} />);
144
+
145
+ expect(screen.getByText('Select a fee option')).toBeInTheDocument();
146
+
147
+ // Should render skeleton
148
+ const skeleton = document.querySelector('.h-\\[52px\\]');
149
+ expect(skeleton).toBeInTheDocument();
150
+ expect(skeleton).toHaveClass('animate-shimmer');
151
+ });
152
+
153
+ it('should render fee options when loaded', () => {
154
+ selectWaasFeeOptions$.pendingFeeOptionConfirmation.set(
155
+ mockPendingFeeOptionConfirmation,
156
+ );
157
+ selectWaasFeeOptions$.selectedFeeOption.set(mockFeeOption);
158
+
159
+ vi.spyOn(useWaasFeeOptionManagerModule, 'default').mockReturnValue({
160
+ selectedFeeOption$: selectWaasFeeOptions$.selectedFeeOption,
161
+ selectedFeeOption: mockFeeOption,
162
+ // @ts-expect-error - types are not compatible
163
+ pendingFeeOptionConfirmation: mockPendingFeeOptionConfirmation,
164
+ currencyBalance: mockCurrencyBalance,
165
+ currencyBalanceLoading: false,
166
+ insufficientBalance: false,
167
+ feeOptionsConfirmed: false,
168
+ handleConfirmFeeOption: mockHandleConfirmFeeOption,
169
+ });
170
+ vi.spyOn(useWaasFeeOptionsModule, 'useWaasFeeOptions').mockReturnValue([
171
+ // @ts-expect-error - types are not compatible
172
+ mockPendingFeeOptionConfirmation,
173
+ vi.fn(),
174
+ ]);
175
+ vi.spyOn(useNetworkModule, 'getNetwork').mockReturnValue({
176
+ type: NetworkType.MAINNET,
177
+ chainId: 1,
178
+ name: 'Mainnet',
179
+ nativeToken: TEST_CURRENCY,
180
+ });
181
+
182
+ render(
183
+ <SelectWaasFeeOptions
184
+ chainId={1}
185
+ onCancel={mockOnCancel}
186
+ titleOnConfirm="Confirm fee option"
187
+ />,
188
+ );
189
+
190
+ expect(screen.getByText('Select a fee option')).toBeInTheDocument();
191
+ expect(screen.queryByText('Confirm fee option')).not.toBeInTheDocument();
192
+ });
193
+ });
@@ -40,8 +40,8 @@ const SwitchChainModal = observer(() => {
40
40
  await switchChainAsync({ chainId: Number(chainIdToSwitchTo) });
41
41
 
42
42
  if (
43
- switchChainModal$.state.onSuccess &&
44
- typeof switchChainModal$.state.onSuccess === 'function'
43
+ switchChainModal$.state.onSuccess.get() &&
44
+ typeof switchChainModal$.state.onSuccess.get() === 'function'
45
45
  ) {
46
46
  switchChainModal$.state.onSuccess();
47
47
  }
package/test/const.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { anvil } from 'viem/chains';
2
+ import type { Currency } from '../src';
3
+ import { CurrencyStatus } from '../src/react/_internal';
2
4
 
3
5
  export const TEST_CHAIN = {
4
6
  ...anvil,
@@ -43,3 +45,25 @@ export const TEST_COLLECTIBLE = {
43
45
  chainId: 1,
44
46
  collectibleId: '7602',
45
47
  } as const;
48
+
49
+ export const TEST_CURRENCY: Currency = {
50
+ chainId: 1,
51
+ contractAddress: USDC_ADDRESS,
52
+ status: CurrencyStatus.active,
53
+ name: 'Test Token',
54
+ symbol: 'TEST',
55
+ decimals: 18,
56
+ imageUrl: 'https://example.com/test.png',
57
+ exchangeRate: 1,
58
+ defaultChainCurrency: false,
59
+ nativeCurrency: false,
60
+ createdAt: '2021-01-01T00:00:00.000Z',
61
+ updatedAt: '2021-01-01T00:00:00.000Z',
62
+ };
63
+
64
+ export const TEST_CURRENCY_2: Currency = {
65
+ ...TEST_CURRENCY,
66
+ symbol: 'TEST2',
67
+ };
68
+
69
+ export const TEST_CURRENCIES = [TEST_CURRENCY, TEST_CURRENCY_2];
@@ -1,6 +1,5 @@
1
- import { SequenceCheckoutProvider } from '@0xsequence/checkout';
2
1
  import {
3
- SequenceConnect,
2
+ SequenceConnectProvider,
4
3
  createConfig as createSequenceConnectConfig,
5
4
  } from '@0xsequence/connect';
6
5
  import { ThemeProvider } from '@0xsequence/design-system';
@@ -71,65 +70,123 @@ const polygon = {
71
70
  rpcUrls: { default: { http: ['http://127.0.0.1:8545/1'] } },
72
71
  };
73
72
 
74
- export const wagmiConfig = createConfig({
73
+ const mockConnector = mock({
74
+ accounts: [TEST_ACCOUNTS[0]],
75
+ features: {
76
+ defaultConnected: true,
77
+ reconnect: true,
78
+ },
79
+ });
80
+
81
+ const wagmiConfigObj = {
75
82
  chains: [mainnet, polygon],
76
- connectors: [
77
- mock({
78
- accounts: [TEST_ACCOUNTS[0]],
79
- features: {
80
- defaultConnected: true,
81
- reconnect: true,
82
- },
83
- }),
84
- ],
83
+ connectors: [mockConnector],
85
84
  transports: {
86
85
  [mainnet.id]: http(),
87
86
  [polygon.id]: http(),
88
87
  },
89
88
  multiInjectedProviderDiscovery: false,
89
+ } as const;
90
+
91
+ export const wagmiConfig = createConfig(wagmiConfigObj);
92
+
93
+ function mockWaas() {
94
+ return new Proxy(mockConnector, {
95
+ apply(target, thisArg, args) {
96
+ const connector = Reflect.apply(target, thisArg, args);
97
+ connector.id = 'waas';
98
+ return connector;
99
+ },
100
+ });
101
+ }
102
+
103
+ function mockSequenceConnector() {
104
+ return new Proxy(mockConnector, {
105
+ apply(target, thisArg, args) {
106
+ const connector = Reflect.apply(target, thisArg, args);
107
+ connector.id = 'sequence';
108
+ },
109
+ });
110
+ }
111
+
112
+ const wagmiConfigEmbedded = createConfig({
113
+ ...wagmiConfigObj,
114
+ connectors: [mockWaas()],
115
+ });
116
+
117
+ const wagmiConfigSequence = createConfig({
118
+ ...wagmiConfigObj,
119
+ connectors: [mockSequenceConnector()],
90
120
  });
91
121
 
92
122
  type Options = Omit<RenderOptions, 'wrapper'> & {
93
123
  wagmiConfig?: Config;
124
+ useEmbeddedWallet?: boolean;
125
+ useSequenceConnector?: boolean;
94
126
  };
95
127
 
96
128
  function renderWithClient(ui: ReactElement, options?: Options) {
97
129
  const testQueryClient = createTestQueryClient();
130
+ let config = options?.wagmiConfig;
131
+ if (!config) {
132
+ // if testing waas, use the embedded wallet config
133
+ config = options?.useEmbeddedWallet
134
+ ? wagmiConfigEmbedded
135
+ : // if testing sequence universal connector, use the sequence connector config
136
+ options?.useSequenceConnector
137
+ ? wagmiConfigSequence
138
+ : // if testing non-sequence connector, use the default config
139
+ wagmiConfig;
140
+ }
141
+
142
+ // TODO: move make this more configurable, maybe use our own hook to create the config
143
+ const sequenceConnectConfig = createSequenceConnectConfig('universal', {
144
+ projectAccessKey: 'test',
145
+ chainIds: [1, 137],
146
+ defaultChainId: 1,
147
+ appName: 'Demo Dapp',
148
+ });
98
149
 
99
- const { rerender, ...result } = rtlRender(ui, {
100
- wrapper: ({ children }) => (
101
- <WagmiProvider config={options?.wagmiConfig ?? wagmiConfig}>
102
- <QueryClientProvider client={testQueryClient}>
150
+ const Wrapper = ({ children }: { children: React.ReactNode }) => (
151
+ <WagmiProvider config={config}>
152
+ <QueryClientProvider client={testQueryClient}>
153
+ <SequenceConnectProvider config={sequenceConnectConfig.connectConfig}>
103
154
  <ThemeProvider>{children}</ThemeProvider>
104
- </QueryClientProvider>
105
- </WagmiProvider>
106
- ),
155
+ </SequenceConnectProvider>
156
+ </QueryClientProvider>
157
+ </WagmiProvider>
158
+ );
159
+
160
+ const { rerender, ...result } = rtlRender(ui, {
161
+ wrapper: Wrapper,
107
162
  ...options,
108
163
  });
109
164
 
110
165
  return {
111
166
  ...result,
112
167
  rerender: (rerenderUi: ReactElement) =>
113
- rerender(
114
- <WagmiProvider config={wagmiConfig}>
115
- <QueryClientProvider client={testQueryClient}>
116
- <ThemeProvider>{rerenderUi}</ThemeProvider>
117
- </QueryClientProvider>
118
- </WagmiProvider>,
119
- ),
168
+ rerender(<Wrapper>{rerenderUi}</Wrapper>),
120
169
  };
121
170
  }
122
171
 
123
172
  function renderHookWithClient<P, R>(
124
173
  callback: (props: P) => R,
125
- options?: Omit<RenderOptions, 'queries'>,
174
+ options?: Omit<RenderOptions, 'queries'> & {
175
+ wagmiConfig?: Config;
176
+ useEmbeddedWallet?: boolean;
177
+ },
126
178
  ) {
127
179
  const testQueryClient = createTestQueryClient();
128
180
 
181
+ let config = options?.wagmiConfig;
182
+ if (!config) {
183
+ config = options?.useEmbeddedWallet ? wagmiConfigEmbedded : wagmiConfig;
184
+ }
185
+
129
186
  return renderHook(callback, {
130
187
  wrapper: ({ children }) => {
131
188
  return (
132
- <WagmiProvider config={wagmiConfig}>
189
+ <WagmiProvider config={config}>
133
190
  <QueryClientProvider client={testQueryClient}>
134
191
  <ThemeProvider>{children}</ThemeProvider>
135
192
  </QueryClientProvider>
@@ -140,25 +197,6 @@ function renderHookWithClient<P, R>(
140
197
  });
141
198
  }
142
199
 
143
- // TODO: move make this more configurable, maybe use our own hook to create the config
144
- const sequenceConnectConfig = createSequenceConnectConfig('universal', {
145
- projectAccessKey: 'test',
146
- chainIds: [1, 137],
147
- defaultChainId: 1,
148
- appName: 'Demo Dapp',
149
- });
150
-
151
- // The web sdk breaks the reloding of vitest, so we only use it when needed
152
- function WebSdkWrapper({ children }: { children: ReactElement }) {
153
- return (
154
- <SequenceConnect config={sequenceConnectConfig}>
155
- <SequenceCheckoutProvider>{children}</SequenceCheckoutProvider>
156
- </SequenceConnect>
157
- );
158
- }
159
-
160
- export { WebSdkWrapper };
161
-
162
200
  export * from '@testing-library/react';
163
201
 
164
202
  export { renderWithClient as render };
@@ -1,8 +0,0 @@
1
- ---
2
- "@0xsequence/marketplace-sdk": patch
3
- ---
4
-
5
- - Unified order type and new query for lowest listing [#278](https://github.com/0xsequence/marketplace-sdk/pull/278)
6
- - Fixed earnings calculation and improved number formatting in transaction details [#281](https://github.com/0xsequence/marketplace-sdk/pull/281)
7
- - Fixed incorrect native currency decimals in QuantetyModal [#280](https://github.com/0xsequence/marketplace-sdk/pull/280)
8
- - Fixed React state updates during render in BuyModal [#277](https://github.com/0xsequence/marketplace-sdk/pull/277)
@@ -1,6 +0,0 @@
1
- ---
2
- "@0xsequence/marketplace-sdk": patch
3
- ---
4
-
5
- - Updated marketplace API client
6
- - Fixed issue with off-chain cancellation failing on some chains, (Removed ExecuteType enum and replaced with new payload for execute endpoint)
@@ -1,5 +0,0 @@
1
- ---
2
- "@0xsequence/marketplace-sdk": patch
3
- ---
4
-
5
- Add skipNativeBalanceCheck flag
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/_internal/wagmi/create-config.ts","../src/react/_internal/consts.ts","../src/react/_internal/get-provider.ts","../src/react/_internal/types.ts","../src/types/builder-types.ts","../src/react/_internal/wagmi/get-connectors.ts"],"sourcesContent":["import { getDefaultChains } from '@0xsequence/connect';\nimport { allNetworks, findNetworkConfig } from '@0xsequence/network';\nimport type { Chain, Transport } from 'viem';\nimport { http, cookieStorage, createConfig, createStorage } from 'wagmi';\nimport {\n\ttype Env,\n\ttype MarketplaceConfig,\n\tMarketplaceWallet,\n\ttype SdkConfig,\n} from '../../../types';\nimport { DEFAULT_NETWORK } from '../consts';\nimport { getConnectors } from './get-connectors';\n\nexport const createWagmiConfig = (\n\tmarketplaceConfig: MarketplaceConfig,\n\tsdkConfig: SdkConfig,\n\tssr?: boolean,\n) => {\n\tconst chains = getChainConfigs(marketplaceConfig);\n\tconst nodeGatewayEnv = sdkConfig._internal?.nodeGatewayEnv ?? 'production';\n\tconst transports = getTransportConfigs(\n\t\tchains,\n\t\tsdkConfig.projectAccessKey,\n\t\tnodeGatewayEnv,\n\t);\n\n\tlet walletType = marketplaceConfig.walletOptions.walletType;\n\n\t// TODO: This will bring issues.. But we relay on the waasConfigKey to detect if the boilerplates should use\n\t// waas or universal.. we need to find a better way to do this..\n\tif (\n\t\tsdkConfig.wallet?.embedded?.waasConfigKey &&\n\t\twalletType !== MarketplaceWallet.ECOSYSTEM\n\t) {\n\t\twalletType = MarketplaceWallet.EMBEDDED;\n\t}\n\n\tconst connectors = getConnectors({\n\t\tmarketplaceConfig,\n\t\tsdkConfig,\n\t\twalletType,\n\t});\n\n\tconst multiInjectedProviderDiscovery =\n\t\tmarketplaceConfig.walletOptions.includeEIP6963Wallets;\n\n\treturn createConfig({\n\t\tconnectors,\n\t\tchains,\n\t\tssr,\n\t\tmultiInjectedProviderDiscovery,\n\t\tstorage: ssr\n\t\t\t? createStorage({\n\t\t\t\t\tstorage: cookieStorage,\n\t\t\t\t})\n\t\t\t: undefined,\n\t\ttransports,\n\t});\n};\n\nfunction getChainConfigs(marketConfig: MarketplaceConfig): [Chain, ...Chain[]] {\n\tconst supportedChainIds = new Set(\n\t\tmarketConfig.collections.map((c) => c.chainId),\n\t);\n\n\tif (supportedChainIds.size === 0) {\n\t\tsupportedChainIds.add(DEFAULT_NETWORK);\n\t}\n\n\tconst chains = getDefaultChains([...supportedChainIds]);\n\n\treturn chains;\n}\n\nfunction getTransportConfigs(\n\tchains: [Chain, ...Chain[]],\n\tprojectAccessKey: string,\n\tnodeGatewayEnv: Env,\n): Record<number, Transport> {\n\treturn chains.reduce(\n\t\t(acc, chain) => {\n\t\t\tconst network = findNetworkConfig(allNetworks, chain.id);\n\t\t\tif (network) {\n\t\t\t\tlet rpcUrl = network.rpcUrl;\n\t\t\t\tif (nodeGatewayEnv === 'development') {\n\t\t\t\t\trpcUrl = rpcUrl.replace('nodes.', 'dev-nodes.');\n\t\t\t\t}\n\t\t\t\tif (!network.rpcUrl.endsWith(projectAccessKey))\n\t\t\t\t\trpcUrl = `${rpcUrl}/${projectAccessKey}`;\n\t\t\t\tacc[chain.id] = http(rpcUrl);\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<number, Transport>,\n\t);\n}\n","export const DEFAULT_NETWORK = 137;\n","export const PROVIDER_ID = 'sdk-provider';\n\nexport function getProviderEl() {\n\tif (!globalThis.document) return null;\n\treturn document.getElementById(PROVIDER_ID);\n}\n","import type { Address } from 'viem';\nimport type { Chain } from 'viem';\nimport { z } from 'zod';\nimport type { ContractType, CreateReq } from '../../types';\nimport type { MarketplaceConfig, SdkConfig } from '../../types';\nimport type { MarketplaceKind, OrderbookKind } from './api';\n\nexport const QueryArgSchema = z\n\t.object({\n\t\tenabled: z.boolean().optional(),\n\t})\n\t.optional();\n\nexport type QueryArg = z.infer<typeof QueryArgSchema>;\n\nexport const CollectableIdSchema = z.string().or(z.number());\n\nexport const AddressSchema = z.string().transform((val, ctx) => {\n\tconst regex = /^0x[a-fA-F0-9]{40}$/;\n\n\tif (!regex.test(val)) {\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid Address ${val}`,\n\t\t});\n\t}\n\n\treturn val as Address;\n});\n\nexport type CollectionType = ContractType.ERC1155 | ContractType.ERC721;\n\ntype TransactionStep = {\n\texist: boolean;\n\tisExecuting: boolean;\n\texecute: () => Promise<void>;\n};\n\nexport type TransactionSteps = {\n\tapproval: TransactionStep;\n\ttransaction: TransactionStep;\n};\n\nexport enum TransactionType {\n\tBUY = 'BUY',\n\tSELL = 'SELL',\n\tLISTING = 'LISTING',\n\tOFFER = 'OFFER',\n\tTRANSFER = 'TRANSFER',\n\tCANCEL = 'CANCEL',\n}\n\nexport interface TransactionConfig {\n\ttype: TransactionType;\n\tchainId: number;\n\tchains: readonly Chain[];\n\tcollectionAddress: string;\n\tsdkConfig: SdkConfig;\n\tmarketplaceConfig: MarketplaceConfig;\n\torderbookKind?: OrderbookKind;\n}\n\nexport interface BuyInput {\n\torderId: string;\n\tcollectableDecimals: number;\n\tmarketplace: MarketplaceKind;\n\tquantity: string;\n}\n\nexport interface SellInput {\n\torderId: string;\n\tmarketplace: MarketplaceKind;\n\tquantity?: string;\n}\n\nexport interface ListingInput {\n\tcontractType: ContractType;\n\tlisting: CreateReq;\n}\n\nexport interface OfferInput {\n\tcontractType: ContractType;\n\toffer: CreateReq;\n}\n\nexport interface CancelInput {\n\torderId: string;\n\tmarketplace: MarketplaceKind;\n}\n","import type { OrderbookKind } from '../react/_internal/api/marketplace.gen';\n\n// Manual copy of the types from builder\nexport enum MarketplaceWallet {\n\tUNIVERSAL = 'UNIVERSAL',\n\tEMBEDDED = 'EMBEDDED',\n\tECOSYSTEM = 'ECOSYSTEM',\n}\n\nexport enum FilterCondition {\n\tENTIRE_KEY = 'ENTIRE_KEY',\n\tSPECIFIC_VALUE = 'SPECIFIC_VALUE',\n}\n\nexport enum MarketplaceType { // This is only used for marketplace v1\n\tAMM = 'AMM',\n\tP2P = 'P2P',\n\tSEQUENCE = 'SEQUENCE',\n\tORDERBOOK = 'ORDERBOOK',\n}\n\nexport interface EcosystemWalletSettings {\n\twalletUrl: string;\n\twalletAppName: string;\n\tlogoLightUrl?: string;\n\tlogoDarkUrl?: string;\n}\nexport interface MarketplaceWalletOptions {\n\twalletType: MarketplaceWallet;\n\toidcIssuers: { [key: string]: string };\n\tconnectors: Array<string>;\n\tincludeEIP6963Wallets: boolean;\n\tecosystem?: EcosystemWalletSettings;\n}\n\nexport interface MetadataFilterRule {\n\tkey: string;\n\tcondition: FilterCondition;\n\tvalue?: string;\n}\n\nexport interface CollectionFilterSettings {\n\tfilterOrder: Array<string>;\n\texclusions: Array<MetadataFilterRule>;\n}\n\nexport interface MarketplaceCollection {\n\tmarketplaceType: MarketplaceType;\n\tchainId: number;\n\taddress: string;\n\texchanges: Array<string>;\n\tbannerUrl: string;\n\tfeePercentage: number;\n\tcurrencyOptions: Array<string>;\n\tdestinationMarketplace: OrderbookKind;\n\tfilterSettings?: CollectionFilterSettings;\n\tisLAOSERC721?: boolean;\n}\n\nexport interface MarketplaceSocials {\n\ttwitter: string;\n\tdiscord: string;\n\twebsite: string;\n\ttiktok: string;\n\tinstagram: string;\n\tyoutube: string;\n}\n\nexport interface MarketplaceSettings {\n\tpublisherId: string;\n\ttitle: string;\n\tshortDescription: string;\n\tsocials: MarketplaceSocials;\n\tfaviconUrl: string;\n\tlandingBannerUrl: string;\n\tcollections: Array<MarketplaceCollection>;\n\twalletOptions: MarketplaceWalletOptions;\n\tlandingPageLayout: string;\n\tlogoUrl: string;\n\tbannerUrl: string;\n\tfontUrl?: string;\n\togImage?: string;\n}\n\nexport interface MarketplaceConfig extends MarketplaceSettings {\n\tcssString: string;\n\tmanifestUrl: string;\n}\n","import {\n\ttype SequenceOptions,\n\ttype Wallet,\n\tapple,\n\tappleWaas,\n\tcoinbaseWallet,\n\tecosystemWallet,\n\temail,\n\temailWaas,\n\tfacebook,\n\tgetConnectWallets,\n\tgoogle,\n\tgoogleWaas,\n\tsequence,\n\ttwitch,\n\twalletConnect,\n} from '@0xsequence/connect';\nimport React, { type FunctionComponent } from 'react';\nimport type { CreateConnectorFn } from 'wagmi';\nimport {\n\ttype Env,\n\ttype MarketplaceConfig,\n\tMarketplaceWallet,\n\ttype SdkConfig,\n} from '../../../types';\nimport { MissingConfigError } from '../../../utils/_internal/error/transaction';\nimport { DEFAULT_NETWORK } from '../consts';\n\nexport function getConnectors({\n\tmarketplaceConfig,\n\tsdkConfig,\n\twalletType,\n}: {\n\tmarketplaceConfig: MarketplaceConfig;\n\tsdkConfig: SdkConfig;\n\twalletType: MarketplaceWallet;\n}): CreateConnectorFn[] {\n\tconst connectors = commonConnectors(marketplaceConfig, sdkConfig);\n\n\tif (walletType === MarketplaceWallet.UNIVERSAL) {\n\t\tconnectors.push(...getUniversalWalletConfigs(sdkConfig, marketplaceConfig));\n\t} else {\n\t\tconnectors.push(...getWaasConnectors(marketplaceConfig, sdkConfig));\n\t}\n\n\treturn getConnectWallets(sdkConfig.projectAccessKey, connectors);\n}\n\nfunction commonConnectors(\n\tmarketplaceConfig: MarketplaceConfig,\n\tsdkConfig: SdkConfig,\n) {\n\tconst wallets = [];\n\tconst { title: appName } = marketplaceConfig;\n\tconst walletOptions = marketplaceConfig.walletOptions;\n\tconst walletConnectProjectId = sdkConfig.wallet?.walletConnectProjectId;\n\n\tif (walletOptions.connectors.includes('coinbase')) {\n\t\twallets.push(\n\t\t\tcoinbaseWallet({\n\t\t\t\tappName,\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (\n\t\twalletConnectProjectId &&\n\t\twalletOptions.connectors.includes('walletconnect')\n\t) {\n\t\twallets.push(\n\t\t\twalletConnect({\n\t\t\t\tprojectId: walletConnectProjectId,\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn wallets;\n}\n\nfunction getUniversalWalletConfigs(\n\tconfig: SdkConfig,\n\tmarketplaceConfig: MarketplaceConfig,\n): Wallet[] {\n\tconst { projectAccessKey } = config;\n\tconst sequenceWalletEnv = config._internal?.sequenceWalletEnv || 'production';\n\n\tconst sequenceWalletOptions = {\n\t\twalletAppURL: getSequenceWalletURL(sequenceWalletEnv),\n\t\tdefaultNetwork: DEFAULT_NETWORK,\n\t\tconnect: {\n\t\t\tprojectAccessKey,\n\t\t\tapp: marketplaceConfig.title,\n\t\t\tsettings: {\n\t\t\t\tbannerUrl: marketplaceConfig.ogImage,\n\t\t\t},\n\t\t},\n\t} satisfies SequenceOptions;\n\n\treturn [\n\t\tsequence(sequenceWalletOptions),\n\t\temail(sequenceWalletOptions),\n\t\tfacebook(sequenceWalletOptions),\n\t\tgoogle(sequenceWalletOptions),\n\t\tapple(sequenceWalletOptions),\n\t\ttwitch(sequenceWalletOptions),\n\t] as const;\n}\n\nexport function getWaasConnectors(\n\tmarketplaceConfig: MarketplaceConfig,\n\tsdkConfig: SdkConfig,\n): Wallet[] {\n\tconst { projectAccessKey } = sdkConfig;\n\n\tconst waasConfigKey = sdkConfig.wallet?.embedded?.waasConfigKey;\n\n\tif (!waasConfigKey) throw new MissingConfigError('waasConfigKey');\n\n\tconst { googleClientId, appleClientId, appleRedirectURI } =\n\t\tsdkConfig.wallet?.embedded || {};\n\n\tconst wallets: Wallet[] = [\n\t\temailWaas({\n\t\t\tprojectAccessKey,\n\t\t\twaasConfigKey,\n\t\t\tnetwork: DEFAULT_NETWORK,\n\t\t}),\n\t];\n\n\tif (googleClientId) {\n\t\twallets.push(\n\t\t\tgoogleWaas({\n\t\t\t\tprojectAccessKey,\n\t\t\t\tgoogleClientId,\n\t\t\t\twaasConfigKey,\n\t\t\t\tnetwork: DEFAULT_NETWORK,\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (appleClientId) {\n\t\twallets.push(\n\t\t\tappleWaas({\n\t\t\t\tprojectAccessKey,\n\t\t\t\tappleClientId,\n\t\t\t\tappleRedirectURI,\n\t\t\t\twaasConfigKey,\n\t\t\t\tnetwork: DEFAULT_NETWORK,\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst walletType = marketplaceConfig.walletOptions.walletType;\n\tif (walletType === MarketplaceWallet.ECOSYSTEM) {\n\t\tconst ecosystemOptions = marketplaceConfig.walletOptions.ecosystem;\n\t\tif (!ecosystemOptions) throw new MissingConfigError('ecosystem');\n\t\tconst { walletAppName, walletUrl, logoDarkUrl, logoLightUrl } =\n\t\t\tecosystemOptions;\n\t\twallets.push(\n\t\t\tecosystemWallet({\n\t\t\t\tprojectAccessKey: sdkConfig.projectAccessKey,\n\t\t\t\twalletUrl,\n\t\t\t\tname: walletAppName,\n\t\t\t\tdefaultNetwork: DEFAULT_NETWORK,\n\t\t\t\tlogoDark: getEcosystemLogo(logoDarkUrl, walletAppName),\n\t\t\t\tlogoLight: getEcosystemLogo(logoLightUrl, walletAppName),\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn wallets;\n}\n\nfunction getEcosystemLogo(\n\turl: string | undefined,\n\tname: string,\n): FunctionComponent {\n\tif (!url) return () => null;\n\tconst Logo = () => React.createElement('img', { src: url, alt: name });\n\tLogo.displayName = 'EcosystemLogo';\n\treturn Logo;\n}\n\nfunction getSequenceWalletURL(env: Env) {\n\tswitch (env) {\n\t\tcase 'development':\n\t\t\treturn 'https://dev.sequence.app';\n\t\tcase 'production':\n\t\t\treturn 'https://sequence.app';\n\t\tcase 'next':\n\t\t\treturn 'https://next.sequence.app';\n\t}\n}\n"],"mappings":";;;;;AAAA,SAAS,wBAAwB;AACjC,SAAS,aAAa,yBAAyB;AAE/C,SAAS,MAAM,eAAe,cAAc,qBAAqB;;;ACH1D,IAAM,kBAAkB;;;ACAxB,IAAM,cAAc;AAEpB,SAAS,gBAAgB;AAC/B,MAAI,CAAC,WAAW,SAAU,QAAO;AACjC,SAAO,SAAS,eAAe,WAAW;AAC3C;;;ACHA,SAAS,SAAS;AAKX,IAAM,iBAAiB,EAC5B,OAAO;AAAA,EACP,SAAS,EAAE,QAAQ,EAAE,SAAS;AAC/B,CAAC,EACA,SAAS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,IAAI,KAAK,MAAM;AAAA,MAC5B;AACA,aAAO;AAAA,IACR;AAAA,IACA,CAAC;AAAA,EACF;AACD;","names":["TransactionType","MarketplaceWallet","FilterCondition","MarketplaceType"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx","../src/react/ui/modals/_internal/components/actionModal/store.ts"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport type { ComponentProps } from 'react';\n\nimport { Button, Modal, Spinner, Text } from '@0xsequence/design-system';\nimport { observer } from '@legendapp/state/react';\nimport { useWallet } from '../../../../../_internal/wallet/useWallet';\nimport { MODAL_OVERLAY_PROPS } from '../consts';\nimport { MODAL_CONTENT_PROPS } from '../consts';\nimport { useSwitchChainModal } from '../switchChainModal';\n\nexport interface ActionModalProps {\n\tisOpen: boolean;\n\tonClose: () => void;\n\ttitle: string;\n\tchildren: React.ReactNode;\n\tctas: {\n\t\tlabel: React.ReactNode;\n\t\tonClick: (() => Promise<void>) | (() => void);\n\t\tpending?: boolean;\n\t\tdisabled?: boolean;\n\t\thidden?: boolean;\n\t\tvariant?: ComponentProps<typeof Button>['variant'];\n\t\ttestid?: string;\n\t}[];\n\tchainId: number;\n\tmodalLoading?: boolean;\n\tspinnerContainerClassname?: string;\n\tdisableAnimation?: boolean;\n\thideCtas?: boolean;\n}\n\nexport const ActionModal = observer(\n\t({\n\t\tisOpen,\n\t\tonClose,\n\t\ttitle,\n\t\tchildren,\n\t\tctas,\n\t\tchainId,\n\t\tdisableAnimation,\n\t\tmodalLoading,\n\t\tspinnerContainerClassname,\n\t\thideCtas,\n\t}: ActionModalProps) => {\n\t\tconst { show: showSwitchChainModal } = useSwitchChainModal();\n\t\tconst { wallet, isLoading, isError } = useWallet();\n\n\t\tconst checkChain = async ({ onSuccess }: { onSuccess: () => void }) => {\n\t\t\tconst walletChainId = await wallet?.getChainId();\n\t\t\tconst chainMismatch = walletChainId !== Number(chainId);\n\t\t\tif (chainMismatch) {\n\t\t\t\tshowSwitchChainModal({\n\t\t\t\t\tchainIdToSwitchTo: Number(chainId),\n\t\t\t\t\tonSuccess,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tonSuccess();\n\t\t\t}\n\t\t};\n\n\t\tif (wallet?.isWaaS) {\n\t\t\twallet.switchChain(Number(chainId));\n\t\t}\n\n\t\tif (!isOpen || !chainId) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<Modal\n\t\t\t\tisDismissible={true}\n\t\t\t\tonClose={onClose}\n\t\t\t\toverlayProps={MODAL_OVERLAY_PROPS}\n\t\t\t\tcontentProps={MODAL_CONTENT_PROPS}\n\t\t\t\tdisableAnimation={disableAnimation}\n\t\t\t>\n\t\t\t\t<div className=\"relative flex grow flex-col items-center gap-4 p-6\">\n\t\t\t\t\t<Text className=\"w-full text-center font-body font-bold text-large text-text-100\">\n\t\t\t\t\t\t{title}\n\t\t\t\t\t</Text>\n\n\t\t\t\t\t{modalLoading || isLoading || isError ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={`flex ${spinnerContainerClassname} w-full items-center justify-center`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{isError && (\n\t\t\t\t\t\t\t\t<Text className=\"text-center font-body text-error100 text-small\">\n\t\t\t\t\t\t\t\t\tError loading modal\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{isLoading && <Spinner size=\"lg\" />}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tchildren\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!hideCtas && !isLoading && !isError && (\n\t\t\t\t\t\t<div className=\"flex w-full flex-col gap-2\">\n\t\t\t\t\t\t\t{ctas.map(\n\t\t\t\t\t\t\t\t(cta) =>\n\t\t\t\t\t\t\t\t\t!cta.hidden && (\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"w-full rounded-[12px] [&>div]:justify-center\"\n\t\t\t\t\t\t\t\t\t\t\tkey={cta.onClick.toString()}\n\t\t\t\t\t\t\t\t\t\t\tonClick={async () => {\n\t\t\t\t\t\t\t\t\t\t\t\tawait checkChain({\n\t\t\t\t\t\t\t\t\t\t\t\t\tonSuccess: () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcta.onClick();\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\tvariant={cta.variant || 'primary'}\n\t\t\t\t\t\t\t\t\t\t\tpending={cta.pending}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={cta.disabled}\n\t\t\t\t\t\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\t\t\t\t\t\tdata-testid={cta.testid}\n\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"flex items-center justify-center gap-2\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{cta.pending && <Spinner size=\"sm\" />}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t{cta.label}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Modal>\n\t\t);\n\t},\n);\n","import { type Observable, observable } from '@legendapp/state';\nimport type { Address } from 'viem';\n\nexport interface ActionModalState {\n\tisOpen: boolean;\n\tchainId: number | null;\n\tcollectionAddress: Address | null;\n}\n\nexport function createActionModalStore() {\n\treturn observable<ActionModalState>({\n\t\tisOpen: false,\n\t\tchainId: null,\n\t\tcollectionAddress: null,\n\t});\n}\n\nexport function openModal(store: Observable<ActionModalState>) {\n\tstore.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