@0xsequence/marketplace-sdk 0.8.4 → 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.
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-25CAMYCG.js → chunk-BB2PTJHI.js} +22 -20
- package/dist/chunk-BB2PTJHI.js.map +1 -0
- package/dist/{chunk-VBRJ2OPM.js → chunk-EZFCQZHU.js} +2 -2
- package/dist/{chunk-VF3LWBQB.js → chunk-KCLMSSPS.js} +6 -6
- package/dist/{chunk-XUNDLCEH.js → chunk-LDZZUYG7.js} +2 -2
- package/dist/{chunk-HRL2TMXU.js → chunk-SFSFIGHM.js} +44 -34
- package/dist/{chunk-HRL2TMXU.js.map → chunk-SFSFIGHM.js.map} +1 -1
- package/dist/{chunk-44YGZVBS.js → chunk-ZVTG6US2.js} +2 -2
- package/dist/index.css +4 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +6 -6
- package/dist/react/_internal/databeat/index.js +5 -5
- package/dist/react/_internal/index.d.ts +1 -1
- package/dist/react/_internal/index.js +3 -1
- package/dist/react/_internal/wagmi/index.d.ts +3 -2
- package/dist/react/_internal/wagmi/index.js +3 -1
- package/dist/react/hooks/index.js +4 -4
- package/dist/react/hooks/options/index.js +2 -2
- package/dist/react/index.js +7 -7
- package/dist/react/queries/index.js +1 -1
- package/dist/react/ssr/index.js +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
- package/dist/react/ui/components/collectible-card/index.js +7 -7
- package/dist/react/ui/icons/index.js +2 -2
- package/dist/react/ui/index.js +7 -7
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -5
- package/dist/types/index.js +1 -1
- package/dist/utils/abi/index.js +5 -5
- package/dist/utils/index.js +6 -6
- package/package.json +19 -19
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +1 -11
- package/src/react/_internal/wagmi/get-connectors.ts +27 -24
- package/src/react/ui/components/_internals/action-button/__tests__/ActionButtonBody.test.tsx +27 -94
- package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +59 -0
- package/src/react/ui/components/_internals/action-button/__tests__/OwnerActions.test.tsx +73 -0
- package/src/react/ui/components/_internals/action-button/__tests__/useActionButtonLogic.test.tsx +77 -0
- package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +3 -2
- package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +4 -3
- package/src/react/ui/components/collectible-card/CollectibleAsset.tsx +1 -0
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +18 -12
- package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +200 -0
- package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +92 -123
- package/src/react/ui/components/collectible-card/__tests__/Footer.test.tsx +136 -0
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +2 -8
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +72 -135
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/ActionButtons.test.tsx +72 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/BalanceIndicator.test.tsx +50 -0
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +193 -0
- package/test/test-utils.tsx +12 -22
- package/dist/chunk-25CAMYCG.js.map +0 -1
- package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +0 -107
- /package/dist/{chunk-VBRJ2OPM.js.map → chunk-EZFCQZHU.js.map} +0 -0
- /package/dist/{chunk-VF3LWBQB.js.map → chunk-KCLMSSPS.js.map} +0 -0
- /package/dist/{chunk-XUNDLCEH.js.map → chunk-LDZZUYG7.js.map} +0 -0
- /package/dist/{chunk-44YGZVBS.js.map → chunk-ZVTG6US2.js.map} +0 -0
|
@@ -1,166 +1,103 @@
|
|
|
1
|
-
import { cleanup,
|
|
1
|
+
import { cleanup, render, renderHook, screen, waitFor } from '@test';
|
|
2
|
+
import { TEST_COLLECTIBLE } from '@test/const';
|
|
3
|
+
import { createMockWallet } from '@test/mocks/wallet';
|
|
2
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import {
|
|
5
|
+
import { useSellModal } from '..';
|
|
6
|
+
import { StepType, WalletKind } from '../../../../_internal';
|
|
7
|
+
import { createMockStep } from '../../../../_internal/api/__mocks__/marketplace.msw';
|
|
8
|
+
import { mockOrder } from '../../../../_internal/api/__mocks__/marketplace.msw';
|
|
9
|
+
import * as walletModule from '../../../../_internal/wallet/useWallet';
|
|
4
10
|
import { SellModal } from '../Modal';
|
|
5
|
-
import
|
|
11
|
+
import * as useGetTokenApprovalDataModule from '../hooks/useGetTokenApproval';
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { mockMarketplaceEndpoint } from '../../../../_internal/api/__mocks__/marketplace.msw';
|
|
12
|
-
import { useSell } from '../hooks/useSell';
|
|
13
|
-
|
|
14
|
-
// Test data
|
|
15
|
-
const mockOrder = {
|
|
16
|
-
orderId: '1',
|
|
17
|
-
priceAmount: '1000000000000000000',
|
|
18
|
-
priceCurrencyAddress: '0x0',
|
|
19
|
-
quantityRemaining: '1',
|
|
20
|
-
createdAt: new Date().toISOString(),
|
|
21
|
-
marketplace: MarketplaceKind.sequence_marketplace_v2,
|
|
22
|
-
} as Order;
|
|
23
|
-
|
|
24
|
-
const mockModalProps = {
|
|
25
|
-
collectionAddress: '0x123',
|
|
26
|
-
chainId: 1,
|
|
27
|
-
tokenId: '1',
|
|
13
|
+
const defaultArgs = {
|
|
14
|
+
collectionAddress: TEST_COLLECTIBLE.collectionAddress,
|
|
15
|
+
chainId: TEST_COLLECTIBLE.chainId,
|
|
16
|
+
tokenId: TEST_COLLECTIBLE.collectibleId,
|
|
28
17
|
order: mockOrder,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// TODO: remove when there is mocks for more endpoints
|
|
32
|
-
vi.mock(import('../../../../hooks'), async (importOriginal) => {
|
|
33
|
-
const mod = await importOriginal();
|
|
34
|
-
return {
|
|
35
|
-
...mod,
|
|
36
|
-
useCollection: vi.fn().mockImplementation(mod.useCollection),
|
|
37
|
-
useCurrency: vi.fn().mockImplementation(mod.useCurrency),
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
vi.mock('@0xsequence/kit', () => ({
|
|
42
|
-
useWaasFeeOptions: vi.fn().mockReturnValue([]),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
cleanup();
|
|
47
|
-
vi.clearAllMocks();
|
|
48
|
-
vi.mock('../hooks/useSell', () => ({
|
|
49
|
-
useSell: vi.fn().mockReturnValue({
|
|
50
|
-
isLoading: false,
|
|
51
|
-
executeApproval: vi.fn(),
|
|
52
|
-
sell: vi.fn(),
|
|
53
|
-
}),
|
|
54
|
-
}));
|
|
55
|
-
});
|
|
18
|
+
};
|
|
56
19
|
|
|
57
|
-
describe
|
|
58
|
-
|
|
59
|
-
render(<SellModal />);
|
|
60
|
-
expect(screen.queryByText('You have an offer')).toBeNull();
|
|
61
|
-
});
|
|
20
|
+
describe('MakeOfferModal', () => {
|
|
21
|
+
const mockWallet = createMockWallet();
|
|
62
22
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
sellModal$.open(mockModalProps);
|
|
71
|
-
render(<SellModal />);
|
|
72
|
-
const errorModal = await screen.findByTestId('error-modal');
|
|
73
|
-
expect(errorModal).toBeVisible();
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
cleanup();
|
|
25
|
+
// Reset all mocks
|
|
26
|
+
vi.clearAllMocks();
|
|
27
|
+
vi.resetAllMocks();
|
|
28
|
+
vi.restoreAllMocks();
|
|
74
29
|
});
|
|
75
30
|
|
|
76
|
-
it
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
31
|
+
it('should show main button if there is no approval step', async () => {
|
|
32
|
+
// Mock sequence wallet
|
|
33
|
+
const sequenceWallet = {
|
|
34
|
+
...mockWallet,
|
|
35
|
+
walletKind: WalletKind.sequence,
|
|
36
|
+
};
|
|
37
|
+
vi.spyOn(walletModule, 'useWallet').mockReturnValue({
|
|
38
|
+
wallet: sequenceWallet,
|
|
80
39
|
isLoading: false,
|
|
81
40
|
isError: false,
|
|
82
41
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
42
|
+
vi.spyOn(
|
|
43
|
+
useGetTokenApprovalDataModule,
|
|
44
|
+
'useGetTokenApprovalData',
|
|
45
|
+
).mockReturnValue({
|
|
46
|
+
data: {
|
|
47
|
+
step: null,
|
|
48
|
+
},
|
|
87
49
|
isLoading: false,
|
|
88
|
-
|
|
50
|
+
isSuccess: true,
|
|
89
51
|
});
|
|
90
52
|
|
|
91
|
-
|
|
53
|
+
// Render the modal
|
|
54
|
+
const { result } = renderHook(() => useSellModal());
|
|
55
|
+
result.current.show(defaultArgs);
|
|
56
|
+
|
|
92
57
|
render(<SellModal />);
|
|
93
|
-
|
|
94
|
-
|
|
58
|
+
|
|
59
|
+
// Wait for the component to update
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
// The Approve TOKEN button should not exist
|
|
62
|
+
expect(screen.queryByText('Approve TOKEN')).toBeNull();
|
|
63
|
+
|
|
64
|
+
// The Accept button should exist
|
|
65
|
+
expect(screen.getByRole('button', { name: 'Accept' })).toBeDefined();
|
|
66
|
+
});
|
|
95
67
|
});
|
|
96
|
-
});
|
|
97
68
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
69
|
+
it('(non-sequence wallets) should show approve token button if there is an approval step, disable main button', async () => {
|
|
70
|
+
const nonSequenceWallet = {
|
|
71
|
+
...mockWallet,
|
|
72
|
+
walletKind: 'unknown' as WalletKind,
|
|
73
|
+
};
|
|
74
|
+
vi.spyOn(walletModule, 'useWallet').mockReturnValue({
|
|
75
|
+
wallet: nonSequenceWallet,
|
|
106
76
|
isLoading: false,
|
|
107
77
|
isError: false,
|
|
108
78
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
79
|
+
vi.spyOn(
|
|
80
|
+
useGetTokenApprovalDataModule,
|
|
81
|
+
'useGetTokenApprovalData',
|
|
82
|
+
).mockReturnValue({
|
|
112
83
|
data: {
|
|
113
|
-
|
|
114
|
-
imageUrl: 'test-url',
|
|
84
|
+
step: createMockStep(StepType.tokenApproval),
|
|
115
85
|
},
|
|
116
86
|
isLoading: false,
|
|
117
|
-
|
|
87
|
+
isSuccess: true,
|
|
118
88
|
});
|
|
119
89
|
|
|
120
|
-
|
|
90
|
+
// Render the modal
|
|
91
|
+
const { result } = renderHook(() => useSellModal());
|
|
92
|
+
result.current.show(defaultArgs);
|
|
121
93
|
|
|
122
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
123
|
-
(useSell as any).mockReturnValue({
|
|
124
|
-
isLoading: false,
|
|
125
|
-
executeApproval: mockExecuteApproval,
|
|
126
|
-
sell: vi.fn(),
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
sellModal$.open({
|
|
130
|
-
...mockModalProps,
|
|
131
|
-
order: {
|
|
132
|
-
...mockOrder,
|
|
133
|
-
quantityRemaining: '1',
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
sellModal$.steps.approval.exist.set(true);
|
|
137
|
-
sellModal$.steps.approval.isExecuting.set(false);
|
|
138
|
-
sellModal$.steps.transaction.isExecuting.set(false);
|
|
139
94
|
render(<SellModal />);
|
|
140
95
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
fireEvent.click(approveButton);
|
|
144
|
-
expect(mockExecuteApproval).toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
expect(screen.getByText('Approve TOKEN')).toBeDefined();
|
|
147
98
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
(useSell as any).mockReturnValue({
|
|
152
|
-
isLoading: false,
|
|
153
|
-
executeApproval: vi.fn(),
|
|
154
|
-
sell: mockSell,
|
|
99
|
+
expect(screen.getByRole('button', { name: 'Accept' })).toBeDefined();
|
|
100
|
+
expect(screen.getByRole('button', { name: 'Accept' })).toBeDisabled();
|
|
101
|
+
});
|
|
155
102
|
});
|
|
156
|
-
|
|
157
|
-
sellModal$.open(mockModalProps);
|
|
158
|
-
sellModal$.steps.approval.exist.set(false);
|
|
159
|
-
sellModal$.steps.approval.isExecuting.set(false);
|
|
160
|
-
sellModal$.steps.transaction.isExecuting.set(false);
|
|
161
|
-
render(<SellModal />);
|
|
162
|
-
|
|
163
|
-
const acceptButton = screen.getByText('Accept');
|
|
164
|
-
fireEvent.click(acceptButton);
|
|
165
|
-
expect(mockSell).toHaveBeenCalled();
|
|
166
103
|
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@test';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import ActionButtons from '../_components/ActionButtons';
|
|
6
|
+
|
|
7
|
+
describe('ActionButtons', () => {
|
|
8
|
+
const mockOnCancel = vi.fn();
|
|
9
|
+
const mockOnConfirm = vi.fn();
|
|
10
|
+
|
|
11
|
+
const defaultProps = {
|
|
12
|
+
onCancel: mockOnCancel,
|
|
13
|
+
onConfirm: mockOnConfirm,
|
|
14
|
+
disabled: false,
|
|
15
|
+
loading: false,
|
|
16
|
+
confirmed: false,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should render both buttons', () => {
|
|
24
|
+
render(<ActionButtons {...defaultProps} />);
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
27
|
+
expect(screen.getByText('Continue with')).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should call onCancel when cancel button is clicked', () => {
|
|
31
|
+
render(<ActionButtons {...defaultProps} />);
|
|
32
|
+
|
|
33
|
+
const cancelButton = screen.getByText('Cancel');
|
|
34
|
+
fireEvent.click(cancelButton);
|
|
35
|
+
|
|
36
|
+
expect(mockOnCancel).toHaveBeenCalledTimes(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should call onConfirm when confirm button is clicked', () => {
|
|
40
|
+
render(<ActionButtons {...defaultProps} />);
|
|
41
|
+
|
|
42
|
+
const confirmButton = screen.getByText('Continue with');
|
|
43
|
+
fireEvent.click(confirmButton);
|
|
44
|
+
|
|
45
|
+
expect(mockOnConfirm).toHaveBeenCalledTimes(1);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should disable confirm button when disabled prop is true', () => {
|
|
49
|
+
render(<ActionButtons {...defaultProps} disabled={true} />);
|
|
50
|
+
|
|
51
|
+
const confirmButton = screen.getByText('Continue with').closest('button');
|
|
52
|
+
expect(confirmButton).toBeDisabled();
|
|
53
|
+
|
|
54
|
+
if (confirmButton) {
|
|
55
|
+
fireEvent.click(confirmButton);
|
|
56
|
+
}
|
|
57
|
+
expect(mockOnConfirm).not.toHaveBeenCalled();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should display token symbol when provided', () => {
|
|
61
|
+
render(<ActionButtons {...defaultProps} tokenSymbol="ETH" />);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByText('Continue with ETH')).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should show skeleton loading when tokenSymbol is not provided', () => {
|
|
67
|
+
render(<ActionButtons {...defaultProps} />);
|
|
68
|
+
|
|
69
|
+
expect(screen.getByText('Continue with')).toBeInTheDocument();
|
|
70
|
+
expect(document.querySelector('.animate-shimmer')).toBeInTheDocument();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@test';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import BalanceIndicator from '../_components/BalanceIndicator';
|
|
6
|
+
|
|
7
|
+
describe('BalanceIndicator', () => {
|
|
8
|
+
it('should render warning icon and negative text when insufficient balance', () => {
|
|
9
|
+
render(
|
|
10
|
+
<BalanceIndicator
|
|
11
|
+
insufficientBalance={true}
|
|
12
|
+
currencyBalance={{ formatted: '0.5' }}
|
|
13
|
+
selectedFeeOption={{ token: { symbol: 'ETH' } }}
|
|
14
|
+
/>,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(document.querySelector('.text-negative')).toBeInTheDocument();
|
|
18
|
+
expect(screen.getByText('You have 0.5 ETH')).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByText('You have 0.5 ETH').className).toContain(
|
|
20
|
+
'text-negative',
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should render checkmark icon and normal text when balance is sufficient', () => {
|
|
25
|
+
render(
|
|
26
|
+
<BalanceIndicator
|
|
27
|
+
insufficientBalance={false}
|
|
28
|
+
currencyBalance={{ formatted: '1.5' }}
|
|
29
|
+
selectedFeeOption={{ token: { symbol: 'ETH' } }}
|
|
30
|
+
/>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(document.querySelector('.text-positive')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('You have 1.5 ETH')).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByText('You have 1.5 ETH').className).not.toContain(
|
|
36
|
+
'text-negative',
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should handle undefined currencyBalance gracefully', () => {
|
|
41
|
+
render(
|
|
42
|
+
<BalanceIndicator
|
|
43
|
+
insufficientBalance={false}
|
|
44
|
+
selectedFeeOption={{ token: { symbol: 'ETH' } }}
|
|
45
|
+
/>,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(screen.getByText('You have 0 ETH')).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -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
|
+
});
|
package/test/test-utils.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { SequenceCheckoutProvider } from '@0xsequence/checkout';
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
SequenceConnectProvider,
|
|
4
3
|
createConfig as createSequenceConnectConfig,
|
|
5
4
|
} from '@0xsequence/connect';
|
|
6
5
|
import { ThemeProvider } from '@0xsequence/design-system';
|
|
@@ -140,10 +139,20 @@ function renderWithClient(ui: ReactElement, options?: Options) {
|
|
|
140
139
|
wagmiConfig;
|
|
141
140
|
}
|
|
142
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
|
+
});
|
|
149
|
+
|
|
143
150
|
const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
144
151
|
<WagmiProvider config={config}>
|
|
145
152
|
<QueryClientProvider client={testQueryClient}>
|
|
146
|
-
<
|
|
153
|
+
<SequenceConnectProvider config={sequenceConnectConfig.connectConfig}>
|
|
154
|
+
<ThemeProvider>{children}</ThemeProvider>
|
|
155
|
+
</SequenceConnectProvider>
|
|
147
156
|
</QueryClientProvider>
|
|
148
157
|
</WagmiProvider>
|
|
149
158
|
);
|
|
@@ -188,25 +197,6 @@ function renderHookWithClient<P, R>(
|
|
|
188
197
|
});
|
|
189
198
|
}
|
|
190
199
|
|
|
191
|
-
// TODO: move make this more configurable, maybe use our own hook to create the config
|
|
192
|
-
const sequenceConnectConfig = createSequenceConnectConfig('universal', {
|
|
193
|
-
projectAccessKey: 'test',
|
|
194
|
-
chainIds: [1, 137],
|
|
195
|
-
defaultChainId: 1,
|
|
196
|
-
appName: 'Demo Dapp',
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// The web sdk breaks the reloding of vitest, so we only use it when needed
|
|
200
|
-
function WebSdkWrapper({ children }: { children: ReactElement }) {
|
|
201
|
-
return (
|
|
202
|
-
<SequenceConnect config={sequenceConnectConfig}>
|
|
203
|
-
<SequenceCheckoutProvider>{children}</SequenceCheckoutProvider>
|
|
204
|
-
</SequenceConnect>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export { WebSdkWrapper };
|
|
209
|
-
|
|
210
200
|
export * from '@testing-library/react';
|
|
211
201
|
|
|
212
202
|
export { renderWithClient as render };
|
|
@@ -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;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