@0xsequence/marketplace-sdk 0.8.6 → 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 +32 -0
- package/dist/chunk-2PSNAIAT.js +1 -0
- package/dist/chunk-2PSNAIAT.js.map +1 -0
- package/dist/{chunk-WXKV5N4T.js → chunk-35WWD5V6.js} +3 -3
- package/dist/{chunk-ZSCZLHKX.js → chunk-4XLXOEXQ.js} +2 -2
- package/dist/{chunk-TGFX3TMV.js → chunk-7IYKUVC3.js} +314 -147
- package/dist/chunk-7IYKUVC3.js.map +1 -0
- package/dist/{chunk-BB2PTJHI.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-SJU6QZHM.js → chunk-EODKQL6Y.js} +2 -2
- package/dist/{chunk-6SEJI7YS.js → chunk-G3447GIP.js} +39 -20
- package/dist/chunk-G3447GIP.js.map +1 -0
- package/dist/{chunk-QMWMJVTX.js → chunk-HHYNOPPI.js} +2 -2
- package/dist/{chunk-ALICO7NG.js → chunk-KGM2WLSP.js} +15 -158
- 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-LDZZUYG7.js → chunk-YALXP2PW.js} +3 -3
- package/dist/{chunk-V3NVAVHV.js → chunk-YBOFRP65.js} +2 -2
- package/dist/{chunk-BGY4WXER.js → chunk-YEGD7PWE.js} +3 -2
- package/dist/{chunk-BGY4WXER.js.map → chunk-YEGD7PWE.js.map} +1 -1
- package/dist/{create-config-qDML4ZNn.d.ts → create-config-DwrnzwpM.d.ts} +2 -2
- package/dist/{index-DtWR0b_l.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 +14 -6
- package/dist/{lowestListing-W7P4EkC3.d.ts → lowestListing-BQHIuvNF.d.ts} +2 -2
- package/dist/{marketplace.gen-DS-MmGEB.d.ts → marketplace.gen-DQzWciwC.d.ts} +5 -4
- 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 +13 -9
- 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 +12 -8
- 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 +19 -14
- 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 +17 -12
- package/dist/react/ui/icons/index.js +8 -5
- 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 +17 -12
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +13 -9
- package/dist/sdk-config-txlivEKe.d.ts +133 -0
- package/dist/{services-BOX67E7W.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-CJLhc2VZ.d.ts → types-isjvwapz.d.ts} +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +6 -3
- 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/marketplace.gen.ts +6 -6
- 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/getMarketplaceDetails.ts +2 -1
- 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-BY6eD6vD.d.ts +0 -82
- package/dist/chunk-6SEJI7YS.js.map +0 -1
- package/dist/chunk-ALICO7NG.js.map +0 -1
- package/dist/chunk-BB2PTJHI.js.map +0 -1
- package/dist/chunk-HGKWWZWY.js +0 -58
- package/dist/chunk-HGKWWZWY.js.map +0 -1
- package/dist/chunk-TGFX3TMV.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-WXKV5N4T.js.map → chunk-35WWD5V6.js.map} +0 -0
- /package/dist/{chunk-ZSCZLHKX.js.map → chunk-4XLXOEXQ.js.map} +0 -0
- /package/dist/{chunk-SJU6QZHM.js.map → chunk-EODKQL6Y.js.map} +0 -0
- /package/dist/{chunk-QMWMJVTX.js.map → chunk-HHYNOPPI.js.map} +0 -0
- /package/dist/{chunk-LDZZUYG7.js.map → chunk-YALXP2PW.js.map} +0 -0
- /package/dist/{chunk-V3NVAVHV.js.map → chunk-YBOFRP65.js.map} +0 -0
|
@@ -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,
|
|
@@ -17,13 +17,10 @@ import {
|
|
|
17
17
|
} from '@0xsequence/connect';
|
|
18
18
|
import React, { type FunctionComponent } from 'react';
|
|
19
19
|
import type { CreateConnectorFn } from 'wagmi';
|
|
20
|
-
import {
|
|
21
|
-
type Env,
|
|
22
|
-
type MarketplaceConfig,
|
|
23
|
-
MarketplaceWallet,
|
|
24
|
-
type SdkConfig,
|
|
25
|
-
} from '../../../types';
|
|
20
|
+
import type { Env, SdkConfig } from '../../../types';
|
|
26
21
|
import { MissingConfigError } from '../../../utils/_internal/error/transaction';
|
|
22
|
+
import type { MarketplaceConfig } from '../../queries/marketplaceConfig';
|
|
23
|
+
import { MarketplaceWallet } from '../api/builder.gen';
|
|
27
24
|
import { DEFAULT_NETWORK } from '../consts';
|
|
28
25
|
|
|
29
26
|
export function getConnectors({
|
|
@@ -40,7 +37,7 @@ export function getConnectors({
|
|
|
40
37
|
if (walletType === MarketplaceWallet.UNIVERSAL) {
|
|
41
38
|
connectors.push(...getUniversalWalletConfigs(sdkConfig, marketplaceConfig));
|
|
42
39
|
} else if (walletType === MarketplaceWallet.EMBEDDED) {
|
|
43
|
-
connectors.push(...getWaasConnectors(sdkConfig));
|
|
40
|
+
connectors.push(...getWaasConnectors(sdkConfig, marketplaceConfig));
|
|
44
41
|
} else if (walletType === MarketplaceWallet.ECOSYSTEM) {
|
|
45
42
|
connectors.push(getEcosystemConnector(marketplaceConfig, sdkConfig));
|
|
46
43
|
} else {
|
|
@@ -57,7 +54,7 @@ function commonConnectors(
|
|
|
57
54
|
const wallets = [];
|
|
58
55
|
const { title: appName } = marketplaceConfig;
|
|
59
56
|
const walletOptions = marketplaceConfig.walletOptions;
|
|
60
|
-
const walletConnectProjectId = sdkConfig.
|
|
57
|
+
const walletConnectProjectId = sdkConfig.walletConnectProjectId;
|
|
61
58
|
|
|
62
59
|
if (walletOptions.connectors.includes('coinbase')) {
|
|
63
60
|
wallets.push(
|
|
@@ -110,23 +107,36 @@ function getUniversalWalletConfigs(
|
|
|
110
107
|
] as const;
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
export function getWaasConnectors(
|
|
114
|
-
|
|
110
|
+
export function getWaasConnectors(
|
|
111
|
+
config: SdkConfig,
|
|
112
|
+
marketplaceConfig: MarketplaceConfig,
|
|
113
|
+
): Wallet[] {
|
|
114
|
+
const { projectAccessKey } = config;
|
|
115
115
|
|
|
116
|
-
const waasConfigKey =
|
|
116
|
+
const waasConfigKey = marketplaceConfig.walletOptions.waas?.tenantKey;
|
|
117
117
|
|
|
118
|
-
if (!waasConfigKey)
|
|
118
|
+
if (!waasConfigKey)
|
|
119
|
+
throw new MissingConfigError(
|
|
120
|
+
'Embedded wallet config is missing, please check your access key',
|
|
121
|
+
);
|
|
119
122
|
|
|
120
|
-
const
|
|
121
|
-
|
|
123
|
+
const waasOptions = marketplaceConfig.walletOptions.oidcIssuers;
|
|
124
|
+
const googleClientId = waasOptions.google;
|
|
125
|
+
const appleClientId = waasOptions.apple;
|
|
126
|
+
const appleRedirectURI = globalThis.window
|
|
127
|
+
? `https://${globalThis.window?.location?.origin}${globalThis.window?.location?.pathname}`
|
|
128
|
+
: undefined;
|
|
122
129
|
|
|
123
|
-
const wallets: Wallet[] = [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
const wallets: Wallet[] = [];
|
|
131
|
+
|
|
132
|
+
if (marketplaceConfig.walletOptions.waas?.emailEnabled) {
|
|
133
|
+
wallets.push(
|
|
134
|
+
emailWaas({
|
|
135
|
+
projectAccessKey,
|
|
136
|
+
waasConfigKey,
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
130
140
|
|
|
131
141
|
if (googleClientId) {
|
|
132
142
|
wallets.push(
|
|
@@ -3,8 +3,10 @@ import { server } from '@test';
|
|
|
3
3
|
import {
|
|
4
4
|
type Account,
|
|
5
5
|
type Address,
|
|
6
|
+
BaseError,
|
|
6
7
|
type Chain,
|
|
7
8
|
type PublicClient,
|
|
9
|
+
UserRejectedRequestError as ViemUserRejectedRequestError,
|
|
8
10
|
type WalletClient,
|
|
9
11
|
hexToBigInt,
|
|
10
12
|
} from 'viem';
|
|
@@ -264,6 +266,21 @@ describe('wallet', () => {
|
|
|
264
266
|
walletInstance.handleSignMessageStep(mockSignatureStep),
|
|
265
267
|
).rejects.toThrow(TransactionSignatureError);
|
|
266
268
|
});
|
|
269
|
+
|
|
270
|
+
it('should throw UserRejectedRequestError when user rejects signature', async () => {
|
|
271
|
+
const error = new TransactionSignatureError(
|
|
272
|
+
StepType.signEIP191,
|
|
273
|
+
new ViemUserRejectedRequestError(
|
|
274
|
+
new BaseError('User rejected request', {
|
|
275
|
+
cause: new Error('User rejected request'),
|
|
276
|
+
}),
|
|
277
|
+
),
|
|
278
|
+
);
|
|
279
|
+
vi.mocked(mockWalletClient.signMessage).mockRejectedValueOnce(error);
|
|
280
|
+
await expect(
|
|
281
|
+
walletInstance.handleSignMessageStep(mockSignatureStep),
|
|
282
|
+
).rejects.toThrow(UserRejectedRequestError);
|
|
283
|
+
});
|
|
267
284
|
});
|
|
268
285
|
|
|
269
286
|
describe('handleSendTransactionStep', () => {
|
|
@@ -315,6 +332,19 @@ describe('wallet', () => {
|
|
|
315
332
|
).rejects.toThrow(TransactionExecutionError);
|
|
316
333
|
});
|
|
317
334
|
|
|
335
|
+
it('should throw UserRejectedRequestError when user rejects transaction', async () => {
|
|
336
|
+
const error = new TransactionExecutionError(
|
|
337
|
+
StepType.buy,
|
|
338
|
+
new ViemUserRejectedRequestError(
|
|
339
|
+
new BaseError('User rejected request'),
|
|
340
|
+
),
|
|
341
|
+
);
|
|
342
|
+
vi.mocked(mockWalletClient.sendTransaction).mockRejectedValueOnce(error);
|
|
343
|
+
await expect(
|
|
344
|
+
walletInstance.handleSendTransactionStep(1, mockTxStep),
|
|
345
|
+
).rejects.toThrow(UserRejectedRequestError);
|
|
346
|
+
});
|
|
347
|
+
|
|
318
348
|
it('should handle transaction with contract interaction', async () => {
|
|
319
349
|
const mockContractTxStep: TransactionStep = {
|
|
320
350
|
id: StepType.buy,
|
|
@@ -2,11 +2,13 @@ import type { TransactionReceipt } from '@0xsequence/indexer';
|
|
|
2
2
|
import {
|
|
3
3
|
type Account,
|
|
4
4
|
type Address,
|
|
5
|
+
BaseError,
|
|
5
6
|
type Chain,
|
|
6
7
|
type Hex,
|
|
7
8
|
type PublicClient,
|
|
8
9
|
TransactionReceiptNotFoundError,
|
|
9
10
|
type TypedDataDomain,
|
|
11
|
+
UserRejectedRequestError as ViemUserRejectedRequestError,
|
|
10
12
|
type WalletClient as ViemWalletClient,
|
|
11
13
|
WaitForTransactionReceiptTimeoutError,
|
|
12
14
|
custom,
|
|
@@ -59,6 +61,7 @@ export interface WalletInstance {
|
|
|
59
61
|
contractAddress: Address;
|
|
60
62
|
spender: Address | 'sequenceMarketV1' | 'sequenceMarketV2';
|
|
61
63
|
}) => Promise<bigint | boolean>;
|
|
64
|
+
publicClient: PublicClient;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
const isSequenceWallet = (connector: Connector) =>
|
|
@@ -147,8 +150,17 @@ export const wallet = ({
|
|
|
147
150
|
message: stepItem.signature!.value,
|
|
148
151
|
});
|
|
149
152
|
}
|
|
150
|
-
} catch (
|
|
153
|
+
} catch (e) {
|
|
154
|
+
const error = e as TransactionSignatureError;
|
|
151
155
|
logger.error('Signature failed', error);
|
|
156
|
+
|
|
157
|
+
if (error.cause instanceof BaseError) {
|
|
158
|
+
const viemError = error.cause as BaseError;
|
|
159
|
+
if (viemError instanceof ViemUserRejectedRequestError) {
|
|
160
|
+
throw new UserRejectedRequestError();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
152
164
|
throw new TransactionSignatureError(stepItem.id, error as Error);
|
|
153
165
|
}
|
|
154
166
|
},
|
|
@@ -180,8 +192,17 @@ export const wallet = ({
|
|
|
180
192
|
gas: hexToBigInt(stepItem.gas),
|
|
181
193
|
}),
|
|
182
194
|
});
|
|
183
|
-
} catch (
|
|
195
|
+
} catch (e) {
|
|
196
|
+
const error = e as TransactionExecutionError;
|
|
184
197
|
logger.error('Transaction failed', error);
|
|
198
|
+
|
|
199
|
+
if (error.cause instanceof BaseError) {
|
|
200
|
+
const viemError = error.cause as BaseError;
|
|
201
|
+
if (viemError instanceof ViemUserRejectedRequestError) {
|
|
202
|
+
throw new UserRejectedRequestError();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
185
206
|
throw new TransactionExecutionError(stepItem.id, error as Error);
|
|
186
207
|
}
|
|
187
208
|
},
|
|
@@ -197,6 +218,7 @@ export const wallet = ({
|
|
|
197
218
|
return receipt;
|
|
198
219
|
} catch (error) {
|
|
199
220
|
logger.error('Transaction confirmation failed', error);
|
|
221
|
+
|
|
200
222
|
throw new TransactionConfirmationError(txHash, error as Error);
|
|
201
223
|
}
|
|
202
224
|
},
|
|
@@ -243,6 +265,7 @@ export const wallet = ({
|
|
|
243
265
|
throw new Error('Unsupported contract type for approval checking');
|
|
244
266
|
}
|
|
245
267
|
},
|
|
268
|
+
publicClient,
|
|
246
269
|
};
|
|
247
270
|
|
|
248
271
|
return walletInstance;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`useMarketplaceConfig > should fetch marketplace config and styles successfully 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"bannerUrl": "",
|
|
6
|
+
"collections": [
|
|
7
|
+
{
|
|
8
|
+
"address": "0x0000000000000000000000000000000000000000",
|
|
9
|
+
"bannerUrl": "",
|
|
10
|
+
"chainId": 1,
|
|
11
|
+
"currencyOptions": [
|
|
12
|
+
"0x0000000000000000000000000000000000000000",
|
|
13
|
+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
14
|
+
],
|
|
15
|
+
"destinationMarketplace": "sequence_marketplace_v2",
|
|
16
|
+
"exchanges": [],
|
|
17
|
+
"feePercentage": 3.5,
|
|
18
|
+
"filterSettings": {
|
|
19
|
+
"exclusions": [
|
|
20
|
+
{
|
|
21
|
+
"condition": "SPECIFIC_VALUE",
|
|
22
|
+
"key": "Type",
|
|
23
|
+
"value": "Sample",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
"filterOrder": [
|
|
27
|
+
"Type",
|
|
28
|
+
"Rarity",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
"marketplaceType": "ORDERBOOK",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"address": "0x1234567890123456789012345678901234567890",
|
|
35
|
+
"bannerUrl": "https://example.com/collection-banner.png",
|
|
36
|
+
"chainId": 137,
|
|
37
|
+
"currencyOptions": [
|
|
38
|
+
"0x0000000000000000000000000000000000000000",
|
|
39
|
+
],
|
|
40
|
+
"destinationMarketplace": "opensea",
|
|
41
|
+
"exchanges": [],
|
|
42
|
+
"feePercentage": 2.5,
|
|
43
|
+
"filterSettings": {
|
|
44
|
+
"exclusions": [
|
|
45
|
+
{
|
|
46
|
+
"condition": "ENTIRE_KEY",
|
|
47
|
+
"key": "Category",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"condition": "SPECIFIC_VALUE",
|
|
51
|
+
"key": "Level",
|
|
52
|
+
"value": "Legendary",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"filterOrder": [
|
|
56
|
+
"Category",
|
|
57
|
+
"Level",
|
|
58
|
+
"Element",
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
"marketplaceType": "ORDERBOOK",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
"cssString": "
|
|
65
|
+
.marketplace-theme {
|
|
66
|
+
--primary-color: #000000;
|
|
67
|
+
}
|
|
68
|
+
",
|
|
69
|
+
"faviconUrl": "https://example.com/favicon.png",
|
|
70
|
+
"landingBannerUrl": "https://example.com/banner.png",
|
|
71
|
+
"landingPageLayout": "default",
|
|
72
|
+
"logoUrl": "https://example.com/logo.png",
|
|
73
|
+
"manifestUrl": "https://api.sequence.build/marketplace//manifest.json",
|
|
74
|
+
"projectId": 1,
|
|
75
|
+
"publisherId": "test-publisher",
|
|
76
|
+
"shortDescription": "A test marketplace",
|
|
77
|
+
"socials": {
|
|
78
|
+
"discord": "https://discord.com/test",
|
|
79
|
+
"instagram": "https://instagram.com/test",
|
|
80
|
+
"tiktok": "",
|
|
81
|
+
"twitter": "https://twitter.com/test",
|
|
82
|
+
"website": "",
|
|
83
|
+
"youtube": "",
|
|
84
|
+
},
|
|
85
|
+
"title": "Test Marketplace",
|
|
86
|
+
"walletOptions": {
|
|
87
|
+
"connectors": [
|
|
88
|
+
"coinbase",
|
|
89
|
+
"walletconnect",
|
|
90
|
+
],
|
|
91
|
+
"includeEIP6963Wallets": true,
|
|
92
|
+
"oidcIssuers": {},
|
|
93
|
+
"walletType": "UNIVERSAL",
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
@@ -3,7 +3,7 @@ import { http, HttpResponse } from 'msw';
|
|
|
3
3
|
import { zeroAddress } from 'viem';
|
|
4
4
|
import { describe, expect, it } from 'vitest';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
mockEthCollection,
|
|
7
7
|
mockMetadataEndpoint,
|
|
8
8
|
} from '../../_internal/api/__mocks__/metadata.msw';
|
|
9
9
|
import type { UseCollectionArgs } from '../useCollection';
|
|
@@ -11,9 +11,8 @@ import { useCollection } from '../useCollection';
|
|
|
11
11
|
|
|
12
12
|
describe('useCollection', () => {
|
|
13
13
|
const defaultArgs: UseCollectionArgs = {
|
|
14
|
-
chainId:
|
|
15
|
-
collectionAddress:
|
|
16
|
-
query: {},
|
|
14
|
+
chainId: mockEthCollection.chainId,
|
|
15
|
+
collectionAddress: mockEthCollection.address,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
it('should fetch collection data successfully', async () => {
|
|
@@ -29,7 +28,7 @@ describe('useCollection', () => {
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
// Verify the data matches our mock
|
|
32
|
-
expect(result.current.data).toEqual(
|
|
31
|
+
expect(result.current.data).toEqual(mockEthCollection);
|
|
33
32
|
expect(result.current.error).toBeNull();
|
|
34
33
|
});
|
|
35
34
|
|
|
@@ -2,11 +2,11 @@ import { renderHook, server, waitFor } from '@test';
|
|
|
2
2
|
import { USDC_ADDRESS } from '@test/const';
|
|
3
3
|
import { http, HttpResponse } from 'msw';
|
|
4
4
|
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { mockConfig } from '../../_internal/api/__mocks__/builder.msw';
|
|
5
6
|
import {
|
|
6
7
|
mockCurrencies,
|
|
7
8
|
mockMarketplaceEndpoint,
|
|
8
9
|
} from '../../_internal/api/__mocks__/marketplace.msw';
|
|
9
|
-
import { mockConfig } from '../options/__mocks__/marketplaceConfig.msw';
|
|
10
10
|
import { useCurrencies } from '../useCurrencies';
|
|
11
11
|
|
|
12
12
|
describe('useCurrencies', () => {
|
|
@@ -2,6 +2,10 @@ import { renderHook, server, waitFor } from '@test';
|
|
|
2
2
|
import { http, HttpResponse } from 'msw';
|
|
3
3
|
import { zeroAddress } from 'viem';
|
|
4
4
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
createLookupMarketplaceConfigHandler,
|
|
7
|
+
mockConfig,
|
|
8
|
+
} from '../../_internal/api/__mocks__/builder.msw';
|
|
5
9
|
import {
|
|
6
10
|
mockIndexerEndpoint,
|
|
7
11
|
mockTokenBalance,
|
|
@@ -11,7 +15,6 @@ import {
|
|
|
11
15
|
mockMarketplaceEndpoint,
|
|
12
16
|
} from '../../_internal/api/__mocks__/marketplace.msw';
|
|
13
17
|
import type { UseInventoryArgs } from '../../queries/inventory';
|
|
14
|
-
import { mockConfig } from '../options/__mocks__/marketplaceConfig.msw';
|
|
15
18
|
import { useInventory } from '../useInventory';
|
|
16
19
|
|
|
17
20
|
// Make sure mockCollectibleOrder has a tokenId of "1" for tests
|
|
@@ -128,21 +131,17 @@ describe('useInventory', () => {
|
|
|
128
131
|
it('should use isLaos721 flag from marketplaceConfig', async () => {
|
|
129
132
|
// Setup config with LAOS collection
|
|
130
133
|
const laosCollectionAddress = '0x1234567890123456789012345678901234567890';
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
collections
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
return HttpResponse.json(configWithLaos);
|
|
144
|
-
}),
|
|
145
|
-
);
|
|
134
|
+
const configWithLaos = {
|
|
135
|
+
...mockConfig,
|
|
136
|
+
collections: [
|
|
137
|
+
{
|
|
138
|
+
...mockConfig.collections[0],
|
|
139
|
+
address: laosCollectionAddress,
|
|
140
|
+
isLAOSERC721: true,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
server.use(createLookupMarketplaceConfigHandler(configWithLaos));
|
|
146
145
|
|
|
147
146
|
const laosArgs: UseInventoryArgs = {
|
|
148
147
|
...defaultArgs,
|