@0xsequence/marketplace-sdk 0.8.7 → 0.8.8
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 +26 -0
- package/dist/chunk-2PSNAIAT.js +1 -0
- package/dist/chunk-2PSNAIAT.js.map +1 -0
- package/dist/{chunk-7FVZD2LL.js → chunk-4XLXOEXQ.js} +2 -2
- package/dist/{chunk-Y6AOCO3Q.js → chunk-7IYKUVC3.js} +312 -145
- package/dist/chunk-7IYKUVC3.js.map +1 -0
- package/dist/{chunk-5HEZNTSU.js → chunk-D7RVSZAQ.js} +131 -83
- package/dist/chunk-D7RVSZAQ.js.map +1 -0
- package/dist/chunk-DWTLVJAW.js +42 -0
- package/dist/chunk-DWTLVJAW.js.map +1 -0
- package/dist/{chunk-YAUZLETY.js → chunk-G3447GIP.js} +37 -18
- package/dist/chunk-G3447GIP.js.map +1 -0
- package/dist/{chunk-O6GWM7C3.js → chunk-HHYNOPPI.js} +2 -2
- package/dist/{chunk-KTT27YUN.js → chunk-KGM2WLSP.js} +12 -156
- package/dist/chunk-KGM2WLSP.js.map +1 -0
- package/dist/chunk-MAD64DLJ.js +81 -0
- package/dist/chunk-MAD64DLJ.js.map +1 -0
- package/dist/chunk-N7BPFK46.js +1 -0
- package/dist/chunk-N7BPFK46.js.map +1 -0
- package/dist/chunk-NX52D7NX.js +135 -0
- package/dist/chunk-NX52D7NX.js.map +1 -0
- package/dist/chunk-O34GCB47.js +32 -0
- package/dist/chunk-O34GCB47.js.map +1 -0
- package/dist/{chunk-Q2DA477S.js → chunk-YALXP2PW.js} +3 -3
- package/dist/{chunk-A6V7XDY4.js → chunk-YBOFRP65.js} +2 -2
- package/dist/{create-config-CdooE7aU.d.ts → create-config-DwrnzwpM.d.ts} +2 -2
- package/dist/{index-ClKHzm0B.d.ts → index-DGsVBflk.d.ts} +3 -12
- package/dist/index.css +7 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.js +13 -5
- package/dist/{lowestListing-kFyrUGha.d.ts → lowestListing-BQHIuvNF.d.ts} +2 -2
- package/dist/{marketplace.gen-BU6T6f0m.d.ts → marketplace.gen-DQzWciwC.d.ts} +1 -1
- package/dist/marketplaceConfig-B4Fdsmxu.d.ts +17 -0
- package/dist/react/_internal/api/index.d.ts +3 -3
- package/dist/react/_internal/api/index.js +4 -3
- package/dist/react/_internal/databeat/index.d.ts +2 -1
- package/dist/react/_internal/databeat/index.js +11 -7
- package/dist/react/_internal/index.d.ts +6 -6
- package/dist/react/_internal/index.js +13 -10
- package/dist/react/_internal/wagmi/index.d.ts +6 -5
- package/dist/react/_internal/wagmi/index.js +2 -2
- package/dist/react/hooks/index.d.ts +9 -8
- package/dist/react/hooks/index.js +10 -6
- package/dist/react/hooks/options/index.d.ts +4 -4
- package/dist/react/hooks/options/index.js +7 -4
- package/dist/react/index.css +2650 -0
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +8 -8
- package/dist/react/index.js +16 -11
- package/dist/react/queries/index.d.ts +3 -3
- package/dist/react/queries/index.js +6 -3
- package/dist/react/ssr/index.d.ts +3 -3
- package/dist/react/ssr/index.js +6 -3
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +2650 -0
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +1 -1
- package/dist/react/ui/components/collectible-card/index.js +14 -9
- package/dist/react/ui/icons/index.js +5 -2
- package/dist/react/ui/index.css +2650 -0
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +2 -1
- package/dist/react/ui/index.js +14 -9
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +11 -7
- package/dist/sdk-config-txlivEKe.d.ts +133 -0
- package/dist/{services-9ApY0U-o.d.ts → services-BI_w8Eq4.d.ts} +4 -4
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +9 -6
- package/dist/{types-DsTwmKG-.d.ts → types-isjvwapz.d.ts} +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +5 -2
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/react/{hooks/options/__mocks__/marketplaceConfig.msw.ts → _internal/api/__mocks__/builder.msw.ts} +70 -63
- package/src/react/_internal/api/__mocks__/metadata.msw.ts +30 -10
- package/src/react/_internal/api/builder-api.ts +32 -0
- package/src/react/_internal/api/builder.gen.ts +215 -0
- package/src/react/_internal/api/services.ts +9 -2
- package/src/react/_internal/databeat/types.ts +1 -0
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +16 -41
- package/src/react/_internal/wagmi/create-config.ts +3 -16
- package/src/react/_internal/wagmi/get-connectors.ts +31 -21
- package/src/react/_internal/wallet/__tests__/wallet.test.ts +30 -0
- package/src/react/_internal/wallet/wallet.ts +25 -2
- package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +96 -0
- package/src/react/hooks/__tests__/useCollection.test.tsx +4 -5
- package/src/react/hooks/__tests__/useCurrencies.test.tsx +1 -1
- package/src/react/hooks/__tests__/useInventory.test.tsx +15 -16
- package/src/react/hooks/__tests__/useListCollections.test.tsx +18 -163
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +10 -11
- package/src/react/hooks/options/index.ts +1 -1
- package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -0
- package/src/react/hooks/useMarketplaceConfig.tsx +2 -2
- package/src/react/queries/marketplaceConfig.ts +101 -0
- package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +1 -0
- package/src/react/ssr/create-ssr-client.ts +1 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
- package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +72 -42
- package/src/react/ui/components/collectible-card/{CollectibleAsset.tsx → collectible-asset/CollectibleAsset.tsx} +44 -44
- package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAssetSkeleton.tsx +14 -0
- package/src/react/ui/components/collectible-card/collectible-asset/utils.ts +36 -0
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +6 -1
- package/src/react/ui/modals/BuyModal/store.ts +1 -0
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +20 -2
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +17 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +4 -0
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +7 -1
- package/src/types/index.ts +7 -1
- package/src/types/sdk-config.ts +4 -9
- package/src/utils/fetchContentType.ts +101 -0
- package/src/utils/getSequenceMarketRequestId.ts +32 -0
- package/test/mocks/wallet.ts +3 -1
- package/test/test-utils.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/builder-types-D5HgAUWR.d.ts +0 -82
- package/dist/chunk-5HEZNTSU.js.map +0 -1
- package/dist/chunk-KTT27YUN.js.map +0 -1
- package/dist/chunk-N7E37ENQ.js +0 -58
- package/dist/chunk-N7E37ENQ.js.map +0 -1
- package/dist/chunk-Y6AOCO3Q.js.map +0 -1
- package/dist/chunk-YAUZLETY.js.map +0 -1
- package/dist/sdk-config-DIzJk_tI.d.ts +0 -26
- package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +0 -134
- package/src/react/hooks/options/marketplaceConfigOptions.ts +0 -71
- package/src/types/builder-types.ts +0 -88
- /package/dist/{chunk-7FVZD2LL.js.map → chunk-4XLXOEXQ.js.map} +0 -0
- /package/dist/{chunk-O6GWM7C3.js.map → chunk-HHYNOPPI.js.map} +0 -0
- /package/dist/{chunk-Q2DA477S.js.map → chunk-YALXP2PW.js.map} +0 -0
- /package/dist/{chunk-A6V7XDY4.js.map → chunk-YBOFRP65.js.map} +0 -0
|
@@ -2,15 +2,64 @@ import { http, HttpResponse } from 'msw';
|
|
|
2
2
|
import { zeroAddress } from 'viem';
|
|
3
3
|
import {
|
|
4
4
|
FilterCondition,
|
|
5
|
+
type LookupMarketplaceConfigReturn,
|
|
5
6
|
type MarketplaceConfig,
|
|
6
7
|
MarketplaceType,
|
|
7
8
|
MarketplaceWallet,
|
|
8
9
|
OrderbookKind,
|
|
9
10
|
} from '../../../../types';
|
|
10
|
-
import { mockCurrencies } from '
|
|
11
|
+
import { mockCurrencies } from './marketplace.msw';
|
|
12
|
+
|
|
13
|
+
export const mockCollections = [
|
|
14
|
+
{
|
|
15
|
+
address: zeroAddress,
|
|
16
|
+
chainId: 1,
|
|
17
|
+
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
18
|
+
currencyOptions: mockCurrencies.map((c) => c.contractAddress),
|
|
19
|
+
exchanges: [],
|
|
20
|
+
bannerUrl: '',
|
|
21
|
+
feePercentage: 3.5,
|
|
22
|
+
destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
|
|
23
|
+
filterSettings: {
|
|
24
|
+
filterOrder: ['Type', 'Rarity'],
|
|
25
|
+
exclusions: [
|
|
26
|
+
{
|
|
27
|
+
key: 'Type',
|
|
28
|
+
condition: FilterCondition.SPECIFIC_VALUE,
|
|
29
|
+
value: 'Sample',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
address: '0x1234567890123456789012345678901234567890',
|
|
36
|
+
chainId: 137,
|
|
37
|
+
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
38
|
+
currencyOptions: [mockCurrencies[0].contractAddress],
|
|
39
|
+
exchanges: [],
|
|
40
|
+
bannerUrl: 'https://example.com/collection-banner.png',
|
|
41
|
+
feePercentage: 2.5,
|
|
42
|
+
destinationMarketplace: OrderbookKind.opensea,
|
|
43
|
+
filterSettings: {
|
|
44
|
+
filterOrder: ['Category', 'Level', 'Element'],
|
|
45
|
+
exclusions: [
|
|
46
|
+
{
|
|
47
|
+
key: 'Category',
|
|
48
|
+
condition: FilterCondition.ENTIRE_KEY,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'Level',
|
|
52
|
+
condition: FilterCondition.SPECIFIC_VALUE,
|
|
53
|
+
value: 'Legendary',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
11
59
|
|
|
12
60
|
// Mock data
|
|
13
61
|
export const mockConfig: MarketplaceConfig = {
|
|
62
|
+
projectId: 1,
|
|
14
63
|
publisherId: 'test-publisher',
|
|
15
64
|
title: 'Test Marketplace',
|
|
16
65
|
shortDescription: 'A test marketplace',
|
|
@@ -31,52 +80,7 @@ export const mockConfig: MarketplaceConfig = {
|
|
|
31
80
|
connectors: ['coinbase', 'walletconnect'],
|
|
32
81
|
includeEIP6963Wallets: true,
|
|
33
82
|
},
|
|
34
|
-
collections:
|
|
35
|
-
{
|
|
36
|
-
address: zeroAddress,
|
|
37
|
-
chainId: 1,
|
|
38
|
-
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
39
|
-
currencyOptions: mockCurrencies.map((c) => c.contractAddress),
|
|
40
|
-
exchanges: [],
|
|
41
|
-
bannerUrl: '',
|
|
42
|
-
feePercentage: 3.5,
|
|
43
|
-
destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
|
|
44
|
-
filterSettings: {
|
|
45
|
-
filterOrder: ['Type', 'Rarity'],
|
|
46
|
-
exclusions: [
|
|
47
|
-
{
|
|
48
|
-
key: 'Type',
|
|
49
|
-
condition: FilterCondition.SPECIFIC_VALUE,
|
|
50
|
-
value: 'Sample',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
address: '0x1234567890123456789012345678901234567890',
|
|
57
|
-
chainId: 137,
|
|
58
|
-
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
59
|
-
currencyOptions: [mockCurrencies[0].contractAddress],
|
|
60
|
-
exchanges: [],
|
|
61
|
-
bannerUrl: 'https://example.com/collection-banner.png',
|
|
62
|
-
feePercentage: 2.5,
|
|
63
|
-
destinationMarketplace: OrderbookKind.opensea,
|
|
64
|
-
filterSettings: {
|
|
65
|
-
filterOrder: ['Category', 'Level', 'Element'],
|
|
66
|
-
exclusions: [
|
|
67
|
-
{
|
|
68
|
-
key: 'Category',
|
|
69
|
-
condition: FilterCondition.ENTIRE_KEY,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
key: 'Level',
|
|
73
|
-
condition: FilterCondition.SPECIFIC_VALUE,
|
|
74
|
-
value: 'Legendary',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
83
|
+
collections: mockCollections,
|
|
80
84
|
landingPageLayout: 'default',
|
|
81
85
|
cssString: '',
|
|
82
86
|
manifestUrl: '',
|
|
@@ -108,12 +112,23 @@ const debugLog = (endpoint: string, request: Request, response: Response) => {
|
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
export const mockLookupMarketplaceConfigError = () => {
|
|
116
|
+
return HttpResponse.json(
|
|
117
|
+
{ code: 3000, msg: 'Project not found' },
|
|
118
|
+
{ status: 404 },
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const createLookupMarketplaceConfigHandler = (config = mockConfig) =>
|
|
123
|
+
http.post('*/rpc/Builder/LookupMarketplaceConfig', () => {
|
|
124
|
+
return HttpResponse.json({
|
|
125
|
+
settings: config,
|
|
126
|
+
} satisfies LookupMarketplaceConfigReturn);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export const createLookupMarketplaceConfigErrorHandler = () =>
|
|
130
|
+
http.post('*/rpc/Builder/LookupMarketplaceConfig', () => {
|
|
131
|
+
return mockLookupMarketplaceConfigError();
|
|
117
132
|
});
|
|
118
133
|
|
|
119
134
|
export const createStylesHandler = (styles = mockStyles) =>
|
|
@@ -125,14 +140,6 @@ export const createStylesHandler = (styles = mockStyles) =>
|
|
|
125
140
|
return response;
|
|
126
141
|
});
|
|
127
142
|
|
|
128
|
-
export const createErrorHandler = () =>
|
|
129
|
-
http.get('*/marketplace/*/settings.json', () => {
|
|
130
|
-
return HttpResponse.json(
|
|
131
|
-
{ code: 3000, msg: 'Project not found' },
|
|
132
|
-
{ status: 404 },
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
143
|
export const createStylesErrorHandler = () =>
|
|
137
144
|
http.get('*/marketplace/*/styles.css', () => {
|
|
138
145
|
return new HttpResponse('', { status: 500 });
|
|
@@ -140,8 +147,8 @@ export const createStylesErrorHandler = () =>
|
|
|
140
147
|
|
|
141
148
|
// Default handlers
|
|
142
149
|
export const handlers = [
|
|
143
|
-
|
|
150
|
+
createLookupMarketplaceConfigHandler(),
|
|
151
|
+
createLookupMarketplaceConfigErrorHandler(),
|
|
144
152
|
createStylesHandler(),
|
|
145
|
-
createErrorHandler(),
|
|
146
153
|
createStylesErrorHandler(),
|
|
147
154
|
];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ContractInfo,
|
|
3
|
+
type GetContractInfoBatchArgs,
|
|
3
4
|
type Metadata,
|
|
4
5
|
type PropertyFilter,
|
|
5
6
|
PropertyType,
|
|
@@ -28,8 +29,7 @@ const debugLog = (endpoint: string, request: unknown, response: unknown) => {
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
export const mockContractInfo: ContractInfo = {
|
|
32
|
+
export const mockEthCollection: ContractInfo = {
|
|
33
33
|
address: zeroAddress,
|
|
34
34
|
chainId: 1,
|
|
35
35
|
name: 'Mock Collection',
|
|
@@ -38,7 +38,7 @@ export const mockContractInfo: ContractInfo = {
|
|
|
38
38
|
status: ResourceStatus.AVAILABLE,
|
|
39
39
|
type: 'ERC721',
|
|
40
40
|
deployed: true,
|
|
41
|
-
updatedAt: new Date().toISOString(),
|
|
41
|
+
updatedAt: new Date('2025-05-01T04:39:56.936Z').toISOString(),
|
|
42
42
|
bytecodeHash: '0x1234567890',
|
|
43
43
|
extensions: {
|
|
44
44
|
description: 'A mock collection for testing',
|
|
@@ -57,6 +57,14 @@ export const mockContractInfo: ContractInfo = {
|
|
|
57
57
|
logoURI: 'https://example.com/logo.png',
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
export const mockPolCollection: ContractInfo = {
|
|
61
|
+
...mockEthCollection,
|
|
62
|
+
address: '0x1234567890123456789012345678901234567890',
|
|
63
|
+
chainId: 137,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const mockCollections = [mockEthCollection, mockPolCollection];
|
|
67
|
+
|
|
60
68
|
export const mockTokenMetadata: TokenMetadata = {
|
|
61
69
|
tokenId: '1',
|
|
62
70
|
name: 'Mock NFT #1',
|
|
@@ -77,7 +85,7 @@ export const mockTokenMetadata: TokenMetadata = {
|
|
|
77
85
|
background_color: '#ffffff',
|
|
78
86
|
animation_url: 'https://example.com/nft/1/animation',
|
|
79
87
|
decimals: 0,
|
|
80
|
-
updatedAt: new Date().toISOString(),
|
|
88
|
+
updatedAt: new Date('2025-05-01T04:39:56.936Z').toISOString(),
|
|
81
89
|
assets: [
|
|
82
90
|
{
|
|
83
91
|
id: 1,
|
|
@@ -90,7 +98,7 @@ export const mockTokenMetadata: TokenMetadata = {
|
|
|
90
98
|
mimeType: 'image/png',
|
|
91
99
|
width: 1000,
|
|
92
100
|
height: 1000,
|
|
93
|
-
updatedAt: new Date().toISOString(),
|
|
101
|
+
updatedAt: new Date('2025-05-01T04:39:56.936Z').toISOString(),
|
|
94
102
|
},
|
|
95
103
|
],
|
|
96
104
|
source: '',
|
|
@@ -145,7 +153,7 @@ export const mockMetadataHandler = <E extends Endpoint>(
|
|
|
145
153
|
// MSW handlers
|
|
146
154
|
export const handlers = [
|
|
147
155
|
mockMetadataHandler('GetContractInfo', {
|
|
148
|
-
contractInfo:
|
|
156
|
+
contractInfo: mockEthCollection,
|
|
149
157
|
}),
|
|
150
158
|
|
|
151
159
|
mockMetadataHandler('GetTokenMetadata', {
|
|
@@ -156,9 +164,21 @@ export const handlers = [
|
|
|
156
164
|
filters: mockPropertyFilters,
|
|
157
165
|
}),
|
|
158
166
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
http.post(mockMetadataEndpoint('GetContractInfoBatch'), async (request) => {
|
|
168
|
+
const body = (await request.request.json()) as GetContractInfoBatchArgs;
|
|
169
|
+
const chainId = Number(body.chainID);
|
|
170
|
+
const contractAddresses = body.contractAddresses;
|
|
171
|
+
|
|
172
|
+
const response = {
|
|
173
|
+
contractInfoMap: mockCollections.filter((collection) => {
|
|
174
|
+
return (
|
|
175
|
+
collection.chainId === chainId &&
|
|
176
|
+
contractAddresses.includes(collection.address)
|
|
177
|
+
);
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
debugLog('GetContractInfoBatch', request, response);
|
|
182
|
+
return HttpResponse.json(response);
|
|
163
183
|
}),
|
|
164
184
|
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { API } from './builder.gen';
|
|
2
|
+
|
|
3
|
+
export class BuilderAPI extends API {
|
|
4
|
+
constructor(
|
|
5
|
+
hostname: string,
|
|
6
|
+
public projectAccessKey?: string,
|
|
7
|
+
public jwtAuth?: string,
|
|
8
|
+
) {
|
|
9
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
10
|
+
this.fetch = this._fetch;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
14
|
+
const headers: Record<string, string> = {};
|
|
15
|
+
|
|
16
|
+
const jwtAuth = this.jwtAuth;
|
|
17
|
+
const projectAccessKey = this.projectAccessKey;
|
|
18
|
+
|
|
19
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
20
|
+
headers.Authorization = `BEARER ${jwtAuth}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
24
|
+
headers['X-Access-Key'] = projectAccessKey;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const requestInit = init || {};
|
|
28
|
+
requestInit.headers = { ...init?.headers, ...headers };
|
|
29
|
+
|
|
30
|
+
return fetch(input, requestInit);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// Importing OrderbookKind from marketplace.gen, to avoid multiple enums
|
|
2
|
+
import { OrderbookKind } from "./marketplace.gen";
|
|
3
|
+
|
|
4
|
+
// Extracted from builder webrpc
|
|
5
|
+
|
|
6
|
+
export interface LookupMarketplaceConfigArgs {
|
|
7
|
+
projectId?: number;
|
|
8
|
+
hostname?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface LookupMarketplaceConfigReturn {
|
|
12
|
+
settings: MarketplaceSettings;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MarketplaceSettings {
|
|
16
|
+
projectId: number;
|
|
17
|
+
publisherId: string;
|
|
18
|
+
title: string;
|
|
19
|
+
shortDescription: string;
|
|
20
|
+
socials: MarketplaceSocials;
|
|
21
|
+
faviconUrl: string;
|
|
22
|
+
landingBannerUrl: string;
|
|
23
|
+
collections: Array<MarketplaceCollection>;
|
|
24
|
+
walletOptions: MarketplaceWalletOptions;
|
|
25
|
+
landingPageLayout: string;
|
|
26
|
+
logoUrl: string;
|
|
27
|
+
bannerUrl: string;
|
|
28
|
+
fontUrl?: string;
|
|
29
|
+
ogImage?: string;
|
|
30
|
+
accessKey?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MarketplaceSocials {
|
|
34
|
+
twitter: string;
|
|
35
|
+
discord: string;
|
|
36
|
+
website: string;
|
|
37
|
+
tiktok: string;
|
|
38
|
+
instagram: string;
|
|
39
|
+
youtube: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MarketplaceCollection {
|
|
43
|
+
marketplaceType: MarketplaceType;
|
|
44
|
+
chainId: number;
|
|
45
|
+
address: string;
|
|
46
|
+
exchanges: Array<string>;
|
|
47
|
+
bannerUrl: string;
|
|
48
|
+
feePercentage: number;
|
|
49
|
+
currencyOptions: Array<string>;
|
|
50
|
+
destinationMarketplace: OrderbookKind;
|
|
51
|
+
filterSettings?: CollectionFilterSettings;
|
|
52
|
+
isLAOSERC721?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface CollectionFilterSettings {
|
|
56
|
+
filterOrder: Array<string>;
|
|
57
|
+
exclusions: Array<MetadataFilterRule>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface OpenIdProvider {
|
|
61
|
+
iss: string;
|
|
62
|
+
aud: Array<string>;
|
|
63
|
+
}
|
|
64
|
+
export interface MetadataFilterRule {
|
|
65
|
+
key: string;
|
|
66
|
+
condition: FilterCondition;
|
|
67
|
+
value?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface MarketplaceWalletWaasSettings {
|
|
71
|
+
tenantKey: string;
|
|
72
|
+
emailEnabled: boolean;
|
|
73
|
+
providers: Array<OpenIdProvider>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface MarketplaceWalletOptions {
|
|
77
|
+
walletType: MarketplaceWallet;
|
|
78
|
+
oidcIssuers: { [key: string]: string };
|
|
79
|
+
connectors: Array<string>;
|
|
80
|
+
includeEIP6963Wallets: boolean;
|
|
81
|
+
ecosystem?: EcosystemWalletSettings;
|
|
82
|
+
waas?: MarketplaceWalletWaasSettings;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface EcosystemWalletSettings {
|
|
86
|
+
walletUrl: string;
|
|
87
|
+
walletAppName: string;
|
|
88
|
+
logoLightUrl?: string;
|
|
89
|
+
logoDarkUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export enum MarketplaceWallet {
|
|
93
|
+
UNIVERSAL = "UNIVERSAL",
|
|
94
|
+
EMBEDDED = "EMBEDDED",
|
|
95
|
+
ECOSYSTEM = "ECOSYSTEM",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export enum MarketplaceType {
|
|
99
|
+
AMM = "AMM",
|
|
100
|
+
P2P = "P2P",
|
|
101
|
+
SEQUENCE = "SEQUENCE",
|
|
102
|
+
ORDERBOOK = "ORDERBOOK",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export enum FilterCondition {
|
|
106
|
+
ENTIRE_KEY = "ENTIRE_KEY",
|
|
107
|
+
SPECIFIC_VALUE = "SPECIFIC_VALUE",
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type Fetch = (
|
|
111
|
+
input: RequestInfo,
|
|
112
|
+
init?: RequestInit
|
|
113
|
+
) => Promise<Response>;
|
|
114
|
+
|
|
115
|
+
export class WebrpcRequestFailedError extends Error {
|
|
116
|
+
name: string;
|
|
117
|
+
code: number;
|
|
118
|
+
message: string;
|
|
119
|
+
status: number;
|
|
120
|
+
cause?: string;
|
|
121
|
+
|
|
122
|
+
constructor(
|
|
123
|
+
name = "WebrpcRequestFailed",
|
|
124
|
+
code = -1,
|
|
125
|
+
message = `request failed`,
|
|
126
|
+
status = 0,
|
|
127
|
+
cause?: string
|
|
128
|
+
) {
|
|
129
|
+
super(message);
|
|
130
|
+
this.name = name;
|
|
131
|
+
this.code = code;
|
|
132
|
+
this.message = message;
|
|
133
|
+
this.status = status;
|
|
134
|
+
this.cause = cause;
|
|
135
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
139
|
+
static new(payload: any): WebrpcRequestFailedError {
|
|
140
|
+
return new WebrpcRequestFailedError(
|
|
141
|
+
payload.name,
|
|
142
|
+
payload.code,
|
|
143
|
+
payload.msg || payload.message,
|
|
144
|
+
payload.status,
|
|
145
|
+
payload.cause
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const createHTTPRequest = (
|
|
151
|
+
body: object = {},
|
|
152
|
+
headers: object = {},
|
|
153
|
+
signal: AbortSignal | null = null
|
|
154
|
+
): object => {
|
|
155
|
+
return {
|
|
156
|
+
method: "POST",
|
|
157
|
+
headers: {
|
|
158
|
+
Accept: "application/json",
|
|
159
|
+
"Content-Type": "application/json",
|
|
160
|
+
...headers,
|
|
161
|
+
},
|
|
162
|
+
body: JSON.stringify(body || {}),
|
|
163
|
+
mode: "cors",
|
|
164
|
+
signal: signal || null,
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const buildResponse = (res: Response): Promise<any> => {
|
|
169
|
+
if (!res.ok) {
|
|
170
|
+
return res.json().then((errData) => {
|
|
171
|
+
throw WebrpcRequestFailedError.new(errData);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return res.json();
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export class API {
|
|
178
|
+
protected hostname: string;
|
|
179
|
+
protected fetch: Fetch;
|
|
180
|
+
protected path = "/rpc/Builder/";
|
|
181
|
+
|
|
182
|
+
constructor(hostname: string, fetch: Fetch) {
|
|
183
|
+
this.hostname = hostname;
|
|
184
|
+
this.fetch = fetch;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private url(name: string): string {
|
|
188
|
+
return this.hostname + this.path + name;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
lookupMarketplaceConfig = (
|
|
192
|
+
args: LookupMarketplaceConfigArgs,
|
|
193
|
+
headers?: object,
|
|
194
|
+
signal?: AbortSignal
|
|
195
|
+
): Promise<LookupMarketplaceConfigReturn> => {
|
|
196
|
+
return this.fetch(
|
|
197
|
+
this.url("LookupMarketplaceConfig"),
|
|
198
|
+
createHTTPRequest(args, headers, signal)
|
|
199
|
+
).then(
|
|
200
|
+
(res) => {
|
|
201
|
+
return buildResponse(res).then((_data) => {
|
|
202
|
+
return {
|
|
203
|
+
projectId: <number>_data.projectId,
|
|
204
|
+
settings: <MarketplaceSettings>_data.settings,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
(error) => {
|
|
209
|
+
throw WebrpcRequestFailedError.new({
|
|
210
|
+
cause: `fetch(): ${error.message || ""}`,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -10,7 +10,8 @@ const SERVICES = {
|
|
|
10
10
|
metadata: 'https://${prefix}metadata.sequence.app',
|
|
11
11
|
indexer: 'https://${prefix}${network}-indexer.sequence.app',
|
|
12
12
|
marketplaceApi: 'https://${prefix}marketplace-api.sequence.app/${network}',
|
|
13
|
-
|
|
13
|
+
builderRpcApi: 'https://${prefix}api.sequence.build',
|
|
14
|
+
//Used for fetching css and manifest
|
|
14
15
|
builderMarketplaceApi:
|
|
15
16
|
'https://${prefix}api.sequence.build/marketplace/${projectId}',
|
|
16
17
|
};
|
|
@@ -29,7 +30,6 @@ const getNetwork = (nameOrId: ChainNameOrId) => {
|
|
|
29
30
|
throw new MissingConfigError(`Network configuration for chain ${nameOrId}`);
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export const imageProxy = stringTemplate(SERVICES.imageProxy, {});
|
|
33
33
|
const metadataURL = (env: Env = 'production') => {
|
|
34
34
|
const prefix = getPrefix(env);
|
|
35
35
|
return stringTemplate(SERVICES.metadata, { prefix });
|
|
@@ -39,11 +39,18 @@ const indexerURL = (chain: ChainNameOrId, env: Env = 'production') => {
|
|
|
39
39
|
const network = getNetwork(chain).name;
|
|
40
40
|
return stringTemplate(SERVICES.indexer, { network: network, prefix });
|
|
41
41
|
};
|
|
42
|
+
|
|
42
43
|
const marketplaceApiURL = (chain: ChainNameOrId, env: Env = 'production') => {
|
|
43
44
|
const prefix = getPrefix(env);
|
|
44
45
|
const network = getNetwork(chain).name;
|
|
45
46
|
return stringTemplate(SERVICES.marketplaceApi, { network: network, prefix });
|
|
46
47
|
};
|
|
48
|
+
|
|
49
|
+
export const builderRpcApi = (env: Env = 'production') => {
|
|
50
|
+
const prefix = getPrefix(env);
|
|
51
|
+
return stringTemplate(SERVICES.builderRpcApi, { prefix });
|
|
52
|
+
};
|
|
53
|
+
|
|
47
54
|
export const builderMarketplaceApi = (
|
|
48
55
|
projectId: string,
|
|
49
56
|
env: Env = 'production',
|
|
@@ -8,9 +8,7 @@ import {
|
|
|
8
8
|
OrderbookKind,
|
|
9
9
|
type SdkConfig,
|
|
10
10
|
} from '../../../../types';
|
|
11
|
-
import { MissingConfigError } from '../../../../utils/_internal/error/transaction';
|
|
12
11
|
import { createWagmiConfig } from '../create-config';
|
|
13
|
-
import { getWaasConnectors } from '../get-connectors';
|
|
14
12
|
|
|
15
13
|
describe('createWagmiConfig', () => {
|
|
16
14
|
let baseMarketplaceConfig: MarketplaceConfig;
|
|
@@ -18,6 +16,7 @@ describe('createWagmiConfig', () => {
|
|
|
18
16
|
|
|
19
17
|
beforeEach(() => {
|
|
20
18
|
baseMarketplaceConfig = {
|
|
19
|
+
projectId: 1,
|
|
21
20
|
cssString: '',
|
|
22
21
|
manifestUrl: '',
|
|
23
22
|
publisherId: 'test-publisher',
|
|
@@ -97,9 +96,7 @@ describe('createWagmiConfig', () => {
|
|
|
97
96
|
|
|
98
97
|
const sdkConfig: SdkConfig = {
|
|
99
98
|
...baseSdkConfig,
|
|
100
|
-
|
|
101
|
-
walletConnectProjectId: 'test-wc-project-id',
|
|
102
|
-
},
|
|
99
|
+
walletConnectProjectId: 'test-wc-project-id',
|
|
103
100
|
};
|
|
104
101
|
|
|
105
102
|
const config = createWagmiConfig(marketplaceConfig, sdkConfig);
|
|
@@ -108,6 +105,14 @@ describe('createWagmiConfig', () => {
|
|
|
108
105
|
});
|
|
109
106
|
|
|
110
107
|
it('should create config with embedded wallet setup', () => {
|
|
108
|
+
// Valid waas tenant key format - base64 encoded JSON string containing the actual key
|
|
109
|
+
const waasTenantKey = btoa(
|
|
110
|
+
JSON.stringify({
|
|
111
|
+
key: 'valid-waas-tenant-key',
|
|
112
|
+
projectId: 'test-project-id',
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
111
116
|
const marketplaceConfig: MarketplaceConfig = {
|
|
112
117
|
...baseMarketplaceConfig,
|
|
113
118
|
walletOptions: {
|
|
@@ -115,20 +120,17 @@ describe('createWagmiConfig', () => {
|
|
|
115
120
|
includeEIP6963Wallets: false,
|
|
116
121
|
walletType: MarketplaceWallet.EMBEDDED,
|
|
117
122
|
oidcIssuers: {},
|
|
123
|
+
waas: {
|
|
124
|
+
tenantKey: waasTenantKey,
|
|
125
|
+
emailEnabled: false,
|
|
126
|
+
providers: [],
|
|
127
|
+
},
|
|
118
128
|
},
|
|
119
129
|
};
|
|
120
130
|
|
|
121
131
|
const sdkConfig: SdkConfig = {
|
|
122
132
|
...baseSdkConfig,
|
|
123
|
-
|
|
124
|
-
embedded: {
|
|
125
|
-
waasConfigKey:
|
|
126
|
-
'eyJwcm9qZWN0SWQiOjEzNjM5LCJycGNTZXJ2ZXIiOiJodHRwczovL3dhYXMuc2VxdWVuY2UuYXBwIn0',
|
|
127
|
-
googleClientId: 'test-google-id',
|
|
128
|
-
appleClientId: 'test-apple-id',
|
|
129
|
-
appleRedirectURI: 'https://test.com/redirect',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
133
|
+
walletConnectProjectId: 'test-wc-project-id',
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
const config = createWagmiConfig(marketplaceConfig, sdkConfig);
|
|
@@ -173,33 +175,6 @@ describe('createWagmiConfig', () => {
|
|
|
173
175
|
});
|
|
174
176
|
|
|
175
177
|
describe('failure cases', () => {
|
|
176
|
-
it('should throw error when trying to use embedded wallet without waasConfigKey', () => {
|
|
177
|
-
const sdkConfig: SdkConfig = {
|
|
178
|
-
...baseSdkConfig,
|
|
179
|
-
wallet: {
|
|
180
|
-
embedded: {
|
|
181
|
-
waasConfigKey: '',
|
|
182
|
-
googleClientId: 'test-google-id',
|
|
183
|
-
appleClientId: 'test-apple-id',
|
|
184
|
-
appleRedirectURI: 'https://test.com/redirect',
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
expect(() =>
|
|
190
|
-
getWaasConnectors({
|
|
191
|
-
...sdkConfig,
|
|
192
|
-
wallet: {
|
|
193
|
-
...sdkConfig.wallet,
|
|
194
|
-
embedded: {
|
|
195
|
-
...sdkConfig.wallet?.embedded,
|
|
196
|
-
waasConfigKey: '', // Empty waasConfigKey should trigger the error
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
}),
|
|
200
|
-
).toThrow(MissingConfigError);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
178
|
it('should still create config when walletConnectProjectId is missing', () => {
|
|
204
179
|
const marketplaceConfig: MarketplaceConfig = {
|
|
205
180
|
...baseMarketplaceConfig,
|
|
@@ -2,12 +2,8 @@ import { getDefaultChains } from '@0xsequence/connect';
|
|
|
2
2
|
import { allNetworks, findNetworkConfig } from '@0xsequence/network';
|
|
3
3
|
import type { Chain, Transport } from 'viem';
|
|
4
4
|
import { http, cookieStorage, createConfig, createStorage } from 'wagmi';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
type MarketplaceConfig,
|
|
8
|
-
MarketplaceWallet,
|
|
9
|
-
type SdkConfig,
|
|
10
|
-
} from '../../../types';
|
|
5
|
+
import type { Env, SdkConfig } from '../../../types';
|
|
6
|
+
import type { MarketplaceConfig } from '../../queries/marketplaceConfig';
|
|
11
7
|
import { DEFAULT_NETWORK } from '../consts';
|
|
12
8
|
import { getConnectors } from './get-connectors';
|
|
13
9
|
|
|
@@ -24,16 +20,7 @@ export const createWagmiConfig = (
|
|
|
24
20
|
nodeGatewayEnv,
|
|
25
21
|
);
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// TODO: This will bring issues.. But we relay on the waasConfigKey to detect if the boilerplates should use
|
|
30
|
-
// waas or universal.. we need to find a better way to do this..
|
|
31
|
-
if (
|
|
32
|
-
sdkConfig.wallet?.embedded?.waasConfigKey &&
|
|
33
|
-
walletType !== MarketplaceWallet.ECOSYSTEM
|
|
34
|
-
) {
|
|
35
|
-
walletType = MarketplaceWallet.EMBEDDED;
|
|
36
|
-
}
|
|
23
|
+
const walletType = marketplaceConfig.walletOptions.walletType;
|
|
37
24
|
|
|
38
25
|
const connectors = getConnectors({
|
|
39
26
|
marketplaceConfig,
|