@0xsequence/marketplace-sdk 0.4.6 → 0.4.7
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/dist/alien_swap-4GAIV7PA.png +0 -0
- package/dist/alien_swap-IZONL4XB.js +8 -0
- package/dist/alien_swap-PMYKGY6A.js +8 -0
- package/dist/aqua-xyz-HLNZIFE2.js +8 -0
- package/dist/aqua-xyz-HLNZIFE2.js.map +1 -0
- package/dist/aqua-xyz-JY5QCI5L.js +8 -0
- package/dist/aqua-xyz-JY5QCI5L.js.map +1 -0
- package/dist/aqua-xyz-WU4JVU2K.png +0 -0
- package/dist/aura-CYKEACX2.js +8 -0
- package/dist/aura-CYKEACX2.js.map +1 -0
- package/dist/aura-HLMWKNSP.js +8 -0
- package/dist/aura-HLMWKNSP.js.map +1 -0
- package/dist/aura-RITZV42R.png +0 -0
- package/dist/blur-2ABQMPTL.png +0 -0
- package/dist/blur-MIPRQYJL.js +8 -0
- package/dist/blur-MIPRQYJL.js.map +1 -0
- package/dist/blur-XDIGHYB7.js +8 -0
- package/dist/blur-XDIGHYB7.js.map +1 -0
- package/dist/{chunk-2FOUCP2R.js → chunk-5UCKYAMR.js} +724 -737
- package/dist/chunk-5UCKYAMR.js.map +1 -0
- package/dist/{chunk-QVOUL555.js → chunk-6R4G7J6Q.js} +86 -26
- package/dist/chunk-6R4G7J6Q.js.map +1 -0
- package/dist/{chunk-RD7HPANB.js → chunk-AQT3BQ67.js} +9 -9
- package/dist/chunk-AQT3BQ67.js.map +1 -0
- package/dist/{chunk-3C2MT5TM.js → chunk-FWN2MCLI.js} +12 -6
- package/dist/chunk-FWN2MCLI.js.map +1 -0
- package/dist/{chunk-5D3ARFFZ.js → chunk-JEOUQFT3.js} +17 -129
- package/dist/chunk-JEOUQFT3.js.map +1 -0
- package/dist/chunk-MWDG7UTB.js +132 -0
- package/dist/chunk-MWDG7UTB.js.map +1 -0
- package/dist/{chunk-36NGHJH5.js → chunk-R7GVMKMM.js} +124 -37
- package/dist/chunk-R7GVMKMM.js.map +1 -0
- package/dist/chunk-RK6KYMZM.js +18 -0
- package/dist/chunk-RK6KYMZM.js.map +1 -0
- package/dist/{chunk-LTHX6RXH.js → chunk-XP3WY5AX.js} +90 -2
- package/dist/chunk-XP3WY5AX.js.map +1 -0
- package/dist/{chunk-DNVERQ5J.js → chunk-YOKGP2EQ.js} +1 -1
- package/dist/chunk-YOKGP2EQ.js.map +1 -0
- package/dist/chunk-ZUEQGPLO.js +302 -0
- package/dist/chunk-ZUEQGPLO.js.map +1 -0
- package/dist/coinbase-MIJPE653.js +8 -0
- package/dist/coinbase-MIJPE653.js.map +1 -0
- package/dist/coinbase-MZUBBEC4.png +0 -0
- package/dist/coinbase-T24XHLQL.js +8 -0
- package/dist/coinbase-T24XHLQL.js.map +1 -0
- package/dist/{create-config-BBTTSJyp.d.ts → create-config-D5WqfUft.d.ts} +2 -2
- package/dist/element-GHIPFSB6.png +0 -0
- package/dist/element-MWATR3ON.js +8 -0
- package/dist/element-MWATR3ON.js.map +1 -0
- package/dist/element-X45NH4D7.js +8 -0
- package/dist/element-X45NH4D7.js.map +1 -0
- package/dist/foundation-BDJUT6CK.js +8 -0
- package/dist/foundation-BDJUT6CK.js.map +1 -0
- package/dist/foundation-FJKIXLS5.png +0 -0
- package/dist/foundation-Z6D6U74V.js +8 -0
- package/dist/foundation-Z6D6U74V.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +10 -4
- package/dist/looks-rare-B6G3OQAP.png +0 -0
- package/dist/looks-rare-LBHT6EXZ.js +8 -0
- package/dist/looks-rare-LBHT6EXZ.js.map +1 -0
- package/dist/looks-rare-STS6IKI4.js +8 -0
- package/dist/looks-rare-STS6IKI4.js.map +1 -0
- package/dist/magic-eden-HA3X3P2O.png +0 -0
- package/dist/magic-eden-RMZ24554.js +8 -0
- package/dist/magic-eden-RMZ24554.js.map +1 -0
- package/dist/magic-eden-YMTLPKLE.js +8 -0
- package/dist/magic-eden-YMTLPKLE.js.map +1 -0
- package/dist/manifold-I4NT4V5L.png +0 -0
- package/dist/manifold-L7FLFDRO.js +8 -0
- package/dist/manifold-L7FLFDRO.js.map +1 -0
- package/dist/manifold-YIUSABCZ.js +8 -0
- package/dist/manifold-YIUSABCZ.js.map +1 -0
- package/dist/{marketplace-config-vioKvBQe.d.ts → marketplace-config-C_fDWzz0.d.ts} +2 -2
- package/dist/marketplace.gen-B8S8fflj.d.ts +390 -0
- package/dist/mintify-ARDASD5Z.js +8 -0
- package/dist/mintify-ARDASD5Z.js.map +1 -0
- package/dist/mintify-OLOGFTWQ.png +0 -0
- package/dist/mintify-TSZA3SQT.js +8 -0
- package/dist/mintify-TSZA3SQT.js.map +1 -0
- package/dist/nftx-67RX7ZV6.js +8 -0
- package/dist/nftx-67RX7ZV6.js.map +1 -0
- package/dist/nftx-DJIV3PYG.png +0 -0
- package/dist/nftx-KVJ3T3G2.js +8 -0
- package/dist/nftx-KVJ3T3G2.js.map +1 -0
- package/dist/okx-MOA2EFVR.js +8 -0
- package/dist/okx-MOA2EFVR.js.map +1 -0
- package/dist/okx-WNQRV3WE.png +0 -0
- package/dist/okx-WQA7H7EM.js +8 -0
- package/dist/okx-WQA7H7EM.js.map +1 -0
- package/dist/open-sea-2HWFM4P6.js +8 -0
- package/dist/open-sea-2HWFM4P6.js.map +1 -0
- package/dist/open-sea-C57XWTAR.png +0 -0
- package/dist/open-sea-GESD6S2M.js +8 -0
- package/dist/open-sea-GESD6S2M.js.map +1 -0
- package/dist/rarible-GHMFCPBT.js +8 -0
- package/dist/rarible-GHMFCPBT.js.map +1 -0
- package/dist/rarible-QNNAZZQC.js +8 -0
- package/dist/rarible-QNNAZZQC.js.map +1 -0
- package/dist/rarible-ZCE7U3I5.png +0 -0
- package/dist/react/_internal/api/index.d.ts +4 -2
- package/dist/react/_internal/api/index.js +5 -1
- package/dist/react/_internal/index.d.ts +5 -5
- package/dist/react/_internal/index.js +6 -2
- package/dist/react/_internal/wagmi/index.d.ts +3 -3
- package/dist/react/hooks/index.d.ts +668 -5
- package/dist/react/hooks/index.js +15 -5
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +17 -8
- package/dist/react/ssr/index.js +8 -30
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css.map +1 -0
- package/dist/react/ui/components/{index.d.ts → collectible-card/index.d.ts} +3 -3
- package/dist/react/ui/components/collectible-card/index.js +29 -0
- package/dist/react/ui/components/collectible-card/index.js.map +1 -0
- package/dist/react/ui/components/marketplace-logos/index.d.ts +26 -0
- package/dist/react/ui/components/marketplace-logos/index.js +46 -0
- package/dist/react/ui/components/marketplace-logos/index.js.map +1 -0
- package/dist/react/ui/icons/index.js +0 -8
- package/dist/react/ui/icons/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +4 -4
- package/dist/react/ui/index.js +9 -8
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -3
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -5
- package/dist/{sdk-config-CasNGLz4.d.ts → sdk-config-BXVH8PS2.d.ts} +68 -16
- package/dist/sequence-JAFBEQNI.png +0 -0
- package/dist/sequence-OIPVNE5P.js +8 -0
- package/dist/sequence-OIPVNE5P.js.map +1 -0
- package/dist/sequence-QNNBU34G.js +8 -0
- package/dist/sequence-QNNBU34G.js.map +1 -0
- package/dist/{services-CbsurKYr.d.ts → services-CdXAIjt1.d.ts} +1 -1
- package/dist/sudo-swap-D3FAP7W4.js +8 -0
- package/dist/sudo-swap-D3FAP7W4.js.map +1 -0
- package/dist/sudo-swap-XNJ3BIUD.js +8 -0
- package/dist/sudo-swap-XNJ3BIUD.js.map +1 -0
- package/dist/sudo-swap-Y6GICQTL.png +0 -0
- package/dist/super-rare-VIUS3P6B.js +8 -0
- package/dist/super-rare-VIUS3P6B.js.map +1 -0
- package/dist/super-rare-WWXZ3MQL.png +0 -0
- package/dist/super-rare-YPU3Y7EF.js +8 -0
- package/dist/super-rare-YPU3Y7EF.js.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +7 -4
- package/dist/{types-rupsBCjv.d.ts → types-eX4P9xju.d.ts} +2 -2
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +8 -1
- package/dist/x2y2-CXOXXZKS.png +0 -0
- package/dist/x2y2-G2SXS5VR.js +8 -0
- package/dist/x2y2-G2SXS5VR.js.map +1 -0
- package/dist/x2y2-GKWTQTPB.js +8 -0
- package/dist/x2y2-GKWTQTPB.js.map +1 -0
- package/dist/zora-3DPG4KAY.png +0 -0
- package/dist/zora-JUDT67NX.js +8 -0
- package/dist/zora-JUDT67NX.js.map +1 -0
- package/dist/zora-Z5VR477F.js +8 -0
- package/dist/zora-Z5VR477F.js.map +1 -0
- package/package.json +33 -19
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +218 -0
- package/src/react/_internal/api/marketplace.gen.ts +125 -42
- package/src/react/_internal/api/query-keys.ts +8 -0
- package/src/react/_internal/api/zod-schema.ts +33 -0
- package/src/react/_internal/test-utils.tsx +68 -0
- package/src/react/_internal/types.ts +3 -3
- package/src/react/hooks/index.ts +2 -0
- package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +77 -0
- package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +144 -0
- package/src/react/hooks/useCancelOrder.tsx +1 -1
- package/src/react/hooks/useCancelTransactionSteps.tsx +6 -6
- package/src/react/hooks/useCurrencies.tsx +2 -5
- package/src/react/hooks/useCurrency.tsx +10 -1
- package/src/react/hooks/useCurrencyBalance.tsx +38 -36
- package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
- package/src/react/hooks/useListCollectibleActivities.tsx +57 -0
- package/src/react/hooks/useListCollectionActivities.tsx +57 -0
- package/src/react/ssr/create-ssr-client.ts +1 -1
- package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +89 -0
- package/src/react/ui/components/collectible-card/index.ts +1 -0
- package/src/react/ui/components/marketplace-logos/index.ts +23 -0
- package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +111 -0
- package/src/react/ui/images/marketplaces/alien_swap.png +0 -0
- package/src/react/ui/images/marketplaces/aqua-xyz.png +0 -0
- package/src/react/ui/images/marketplaces/aura.png +0 -0
- package/src/react/ui/images/marketplaces/blur.png +0 -0
- package/src/react/ui/images/marketplaces/coinbase.png +0 -0
- package/src/react/ui/images/marketplaces/element.png +0 -0
- package/src/react/ui/images/marketplaces/foundation.png +0 -0
- package/src/react/ui/images/marketplaces/looks-rare.png +0 -0
- package/src/react/ui/images/marketplaces/magic-eden.png +0 -0
- package/src/react/ui/images/marketplaces/manifold.png +0 -0
- package/src/react/ui/images/marketplaces/mintify.png +0 -0
- package/src/react/ui/images/marketplaces/nftx.png +0 -0
- package/src/react/ui/images/marketplaces/okx.png +0 -0
- package/src/react/ui/images/marketplaces/open-sea.png +0 -0
- package/src/react/ui/images/marketplaces/rarible.png +0 -0
- package/src/react/ui/images/marketplaces/sequence.png +0 -0
- package/src/react/ui/images/marketplaces/sudo-swap.png +0 -0
- package/src/react/ui/images/marketplaces/super-rare.png +0 -0
- package/src/react/ui/images/marketplaces/x2y2.png +0 -0
- package/src/react/ui/images/marketplaces/zora.png +0 -0
- package/src/react/ui/modals/BuyModal/Modal.tsx +3 -1
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +1 -0
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +2 -1
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +208 -0
- package/src/react/ui/modals/CreateListingModal/store.ts +26 -16
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +199 -0
- package/src/react/ui/modals/MakeOfferModal/store.ts +27 -16
- package/src/react/ui/modals/SellModal/Modal.tsx +1 -0
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +192 -0
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +3 -3
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +3 -3
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +8 -8
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +2 -0
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +7 -1
- package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +7 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +159 -0
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +4 -5
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +124 -0
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +48 -45
- package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +221 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +24 -5
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +2 -2
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +16 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +147 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +218 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +27 -10
- package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +1 -1
- package/src/react/ui/modals/modal-provider.tsx +0 -2
- package/src/types/marketplace-config.ts +1 -1
- package/src/utils/__tests__/address.test.ts +65 -0
- package/src/utils/__tests__/date.test.ts +31 -0
- package/src/utils/__tests__/get-public-rpc-client.test.ts +109 -0
- package/src/utils/__tests__/getMarketplaceDetails.test.ts +134 -0
- package/src/utils/__tests__/price.test.ts +42 -0
- package/src/utils/get-public-rpc-client.ts +6 -0
- package/src/utils/getMarketplaceDetails.ts +110 -0
- package/src/utils/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.js +10 -0
- package/dist/chunk-2FOUCP2R.js.map +0 -1
- package/dist/chunk-36NGHJH5.js.map +0 -1
- package/dist/chunk-3C2MT5TM.js.map +0 -1
- package/dist/chunk-5D3ARFFZ.js.map +0 -1
- package/dist/chunk-6WB4GCCJ.js +0 -38
- package/dist/chunk-6WB4GCCJ.js.map +0 -1
- package/dist/chunk-CP2IVRMX.js +0 -85
- package/dist/chunk-CP2IVRMX.js.map +0 -1
- package/dist/chunk-DNVERQ5J.js.map +0 -1
- package/dist/chunk-LTHX6RXH.js.map +0 -1
- package/dist/chunk-MJ4YU7RW.js +0 -2
- package/dist/chunk-QVOUL555.js.map +0 -1
- package/dist/chunk-RD7HPANB.js.map +0 -1
- package/dist/react/ui/components/index.css.map +0 -1
- package/dist/react/ui/components/index.js +0 -28
- package/src/react/ui/components/index.ts +0 -1
- package/src/react/ui/modals/Account/index.tsx +0 -29
- package/src/react/ui/modals/_internal/components/priceInput/hooks/useBalanceCheck.ts +0 -67
- package/src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts +0 -54
- /package/dist/{chunk-MJ4YU7RW.js.map → alien_swap-IZONL4XB.js.map} +0 -0
- /package/dist/{react/ui/components/index.js.map → alien_swap-PMYKGY6A.js.map} +0 -0
- /package/dist/react/ui/components/{index.css → collectible-card/index.css} +0 -0
package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { TransactionType } from '../../../../../../_internal/types';
|
|
3
|
+
import { getFormattedType } from '../util/getFormattedType';
|
|
4
|
+
import { getTransactionStatusModalMessage } from '../util/getMessage';
|
|
5
|
+
import {
|
|
6
|
+
getTransactionStatusModalTitle,
|
|
7
|
+
getTransactionStatusModalSpinnerTitle,
|
|
8
|
+
} from '../util/getTitle';
|
|
9
|
+
import type { TransactionStatus } from '../store';
|
|
10
|
+
|
|
11
|
+
describe('Transaction Status Modal Utils', () => {
|
|
12
|
+
describe('getFormattedType', () => {
|
|
13
|
+
it('should return correct format for each transaction type', () => {
|
|
14
|
+
expect(getFormattedType(TransactionType.TRANSFER)).toBe('transfer');
|
|
15
|
+
expect(getFormattedType(TransactionType.LISTING)).toBe('listing');
|
|
16
|
+
expect(getFormattedType(TransactionType.BUY)).toBe('purchase');
|
|
17
|
+
expect(getFormattedType(TransactionType.SELL)).toBe('sale');
|
|
18
|
+
expect(getFormattedType(TransactionType.CANCEL)).toBe('cancellation');
|
|
19
|
+
expect(getFormattedType(TransactionType.OFFER)).toBe('offer');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should return correct verb format when verb flag is true', () => {
|
|
23
|
+
expect(getFormattedType(TransactionType.TRANSFER, true)).toBe(
|
|
24
|
+
'transferred',
|
|
25
|
+
);
|
|
26
|
+
expect(getFormattedType(TransactionType.LISTING, true)).toBe('listed');
|
|
27
|
+
expect(getFormattedType(TransactionType.BUY, true)).toBe('purchased');
|
|
28
|
+
expect(getFormattedType(TransactionType.SELL, true)).toBe('sold');
|
|
29
|
+
expect(getFormattedType(TransactionType.CANCEL, true)).toBe('cancelled');
|
|
30
|
+
expect(getFormattedType(TransactionType.OFFER, true)).toBe('offered');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return 'transaction' for unknown transaction types", () => {
|
|
34
|
+
expect(getFormattedType('UNKNOWN' as TransactionType)).toBe(
|
|
35
|
+
'transaction',
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('getTransactionStatusModalMessage', () => {
|
|
41
|
+
const baseArgs = {
|
|
42
|
+
transactionType: TransactionType.BUY,
|
|
43
|
+
collectibleName: 'Test NFT',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
it('should return correct message for each transaction status', () => {
|
|
47
|
+
expect(
|
|
48
|
+
getTransactionStatusModalMessage({
|
|
49
|
+
...baseArgs,
|
|
50
|
+
transactionStatus: 'PENDING',
|
|
51
|
+
}),
|
|
52
|
+
).toBe(
|
|
53
|
+
'You just purchased Test NFT. It should be confirmed on the blockchain shortly.',
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
getTransactionStatusModalMessage({
|
|
58
|
+
...baseArgs,
|
|
59
|
+
transactionStatus: 'SUCCESS',
|
|
60
|
+
}),
|
|
61
|
+
).toBe(
|
|
62
|
+
"You just purchased Test NFT. It's been confirmed on the blockchain!",
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(
|
|
66
|
+
getTransactionStatusModalMessage({
|
|
67
|
+
...baseArgs,
|
|
68
|
+
transactionStatus: 'FAILED',
|
|
69
|
+
}),
|
|
70
|
+
).toBe('Your purchase has failed.');
|
|
71
|
+
|
|
72
|
+
expect(
|
|
73
|
+
getTransactionStatusModalMessage({
|
|
74
|
+
...baseArgs,
|
|
75
|
+
transactionStatus: 'TIMEOUT',
|
|
76
|
+
}),
|
|
77
|
+
).toBe(
|
|
78
|
+
'Your purchase takes too long. Click the link below to track it on the explorer.',
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should handle order ID case', () => {
|
|
83
|
+
expect(
|
|
84
|
+
getTransactionStatusModalMessage({
|
|
85
|
+
...baseArgs,
|
|
86
|
+
orderId: '123',
|
|
87
|
+
transactionStatus: 'SUCCESS',
|
|
88
|
+
}),
|
|
89
|
+
).toBe(
|
|
90
|
+
"You just purchased Test NFT. It's been confirmed on the blockchain!",
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should handle offer with price', () => {
|
|
95
|
+
expect(
|
|
96
|
+
getTransactionStatusModalMessage({
|
|
97
|
+
transactionType: TransactionType.OFFER,
|
|
98
|
+
collectibleName: 'Test NFT',
|
|
99
|
+
transactionStatus: 'SUCCESS',
|
|
100
|
+
price: {
|
|
101
|
+
amountRaw: '1000000000000000000',
|
|
102
|
+
currency: {
|
|
103
|
+
chainId: 1,
|
|
104
|
+
contractAddress: '0x0000000000000000000000000000000000000000',
|
|
105
|
+
name: 'Ethereum',
|
|
106
|
+
symbol: 'ETH',
|
|
107
|
+
decimals: 18,
|
|
108
|
+
imageUrl: 'https://ethereum.org/eth.png',
|
|
109
|
+
exchangeRate: 1,
|
|
110
|
+
defaultChainCurrency: true,
|
|
111
|
+
nativeCurrency: true,
|
|
112
|
+
createdAt: '2024-01-21T00:00:00Z',
|
|
113
|
+
updatedAt: '2024-01-21T00:00:00Z',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
).toBe(
|
|
118
|
+
"You just offered 1 ETH for Test NFT. It's been confirmed on the blockchain!",
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should hide collectible name for cancel transactions', () => {
|
|
123
|
+
expect(
|
|
124
|
+
getTransactionStatusModalMessage({
|
|
125
|
+
transactionType: TransactionType.CANCEL,
|
|
126
|
+
collectibleName: 'Test NFT',
|
|
127
|
+
transactionStatus: 'SUCCESS',
|
|
128
|
+
}),
|
|
129
|
+
).toBe("You just cancelled. It's been confirmed on the blockchain!");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('getTransactionStatusModalTitle', () => {
|
|
134
|
+
const baseArgs = {
|
|
135
|
+
transactionType: TransactionType.BUY,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
it('should return correct title for each transaction status', () => {
|
|
139
|
+
expect(
|
|
140
|
+
getTransactionStatusModalTitle({
|
|
141
|
+
...baseArgs,
|
|
142
|
+
transactionStatus: 'PENDING',
|
|
143
|
+
}),
|
|
144
|
+
).toBe('Your purchase is processing');
|
|
145
|
+
|
|
146
|
+
expect(
|
|
147
|
+
getTransactionStatusModalTitle({
|
|
148
|
+
...baseArgs,
|
|
149
|
+
transactionStatus: 'SUCCESS',
|
|
150
|
+
}),
|
|
151
|
+
).toBe('Your purchase has processed');
|
|
152
|
+
|
|
153
|
+
expect(
|
|
154
|
+
getTransactionStatusModalTitle({
|
|
155
|
+
...baseArgs,
|
|
156
|
+
transactionStatus: 'FAILED',
|
|
157
|
+
}),
|
|
158
|
+
).toBe('Your purchase has failed');
|
|
159
|
+
|
|
160
|
+
expect(
|
|
161
|
+
getTransactionStatusModalTitle({
|
|
162
|
+
...baseArgs,
|
|
163
|
+
transactionStatus: 'TIMEOUT',
|
|
164
|
+
}),
|
|
165
|
+
).toBe('Your purchase takes too long');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should handle order ID case', () => {
|
|
169
|
+
expect(
|
|
170
|
+
getTransactionStatusModalTitle({
|
|
171
|
+
...baseArgs,
|
|
172
|
+
orderId: '123',
|
|
173
|
+
transactionStatus: 'SUCCESS',
|
|
174
|
+
}),
|
|
175
|
+
).toBe('Your purchase has processed');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should return empty string when transaction type is undefined', () => {
|
|
179
|
+
expect(
|
|
180
|
+
getTransactionStatusModalTitle({
|
|
181
|
+
transactionType: undefined,
|
|
182
|
+
transactionStatus: 'SUCCESS',
|
|
183
|
+
}),
|
|
184
|
+
).toBe('');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('getTransactionStatusModalSpinnerTitle', () => {
|
|
189
|
+
it('should return correct spinner title for each status', () => {
|
|
190
|
+
const statuses: TransactionStatus[] = [
|
|
191
|
+
'PENDING',
|
|
192
|
+
'SUCCESS',
|
|
193
|
+
'FAILED',
|
|
194
|
+
'TIMEOUT',
|
|
195
|
+
];
|
|
196
|
+
const expectedTitles = {
|
|
197
|
+
PENDING: 'Processing transaction',
|
|
198
|
+
SUCCESS: 'Transaction completed',
|
|
199
|
+
FAILED: 'Transaction failed',
|
|
200
|
+
TIMEOUT: 'Taking too long',
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
for (const status of statuses) {
|
|
204
|
+
expect(
|
|
205
|
+
getTransactionStatusModalSpinnerTitle({ transactionStatus: status }),
|
|
206
|
+
).toBe(expectedTitles[status]);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should return default title for unknown status', () => {
|
|
211
|
+
expect(
|
|
212
|
+
getTransactionStatusModalSpinnerTitle({
|
|
213
|
+
transactionStatus: 'UNKNOWN' as TransactionStatus,
|
|
214
|
+
}),
|
|
215
|
+
).toBe('Processing transaction');
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
@@ -82,6 +82,12 @@ const TransactionStatusModal = observer(() => {
|
|
|
82
82
|
orderId ? 'SUCCESS' : 'PENDING',
|
|
83
83
|
);
|
|
84
84
|
const queryClient = getQueryClient();
|
|
85
|
+
const publicClient = chainId ? getPublicRpcClient(chainId) : null;
|
|
86
|
+
const waitForTransactionReceiptPromise =
|
|
87
|
+
publicClient?.waitForTransactionReceipt({
|
|
88
|
+
confirmations: confirmations || TRANSACTION_CONFIRMATIONS_DEFAULT,
|
|
89
|
+
hash: hash || '0x',
|
|
90
|
+
});
|
|
85
91
|
|
|
86
92
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
87
93
|
useEffect(() => {
|
|
@@ -148,38 +154,49 @@ const TransactionStatusModal = observer(() => {
|
|
|
148
154
|
orderId,
|
|
149
155
|
price,
|
|
150
156
|
});
|
|
151
|
-
const publicClient = chainId ? getPublicRpcClient(chainId) : null;
|
|
152
|
-
const waitForTransactionReceiptPromise =
|
|
153
|
-
publicClient?.waitForTransactionReceipt({
|
|
154
|
-
confirmations: confirmations || TRANSACTION_CONFIRMATIONS_DEFAULT,
|
|
155
|
-
hash: hash || '0x',
|
|
156
|
-
});
|
|
157
157
|
|
|
158
158
|
return (
|
|
159
159
|
<Root open={transactionStatusModal$.isOpen.get()}>
|
|
160
160
|
<Portal container={getProviderEl()}>
|
|
161
161
|
<Overlay className={dialogOverlay} />
|
|
162
162
|
|
|
163
|
-
<Content
|
|
163
|
+
<Content
|
|
164
|
+
className={transactionStatusModalContent}
|
|
165
|
+
data-testid="transaction-status-modal"
|
|
166
|
+
>
|
|
164
167
|
{title ? (
|
|
165
168
|
<Text
|
|
166
169
|
fontSize="large"
|
|
167
170
|
fontWeight="bold"
|
|
168
171
|
color="text100"
|
|
169
172
|
fontFamily="body"
|
|
173
|
+
data-testid="transaction-status-title"
|
|
170
174
|
>
|
|
171
175
|
{title}
|
|
172
176
|
</Text>
|
|
173
177
|
) : (
|
|
174
|
-
<Skeleton
|
|
178
|
+
<Skeleton
|
|
179
|
+
width="16"
|
|
180
|
+
height="6"
|
|
181
|
+
data-testid="transaction-modal-title-skeleton"
|
|
182
|
+
/>
|
|
175
183
|
)}
|
|
176
184
|
|
|
177
185
|
{message ? (
|
|
178
|
-
<Text
|
|
186
|
+
<Text
|
|
187
|
+
fontSize="small"
|
|
188
|
+
color="text80"
|
|
189
|
+
fontFamily="body"
|
|
190
|
+
data-testid="transaction-status-message"
|
|
191
|
+
>
|
|
179
192
|
{message}
|
|
180
193
|
</Text>
|
|
181
194
|
) : (
|
|
182
|
-
<Skeleton
|
|
195
|
+
<Skeleton
|
|
196
|
+
width="20"
|
|
197
|
+
height="4"
|
|
198
|
+
data-testid="transaction-modal-content-skeleton"
|
|
199
|
+
/>
|
|
183
200
|
)}
|
|
184
201
|
|
|
185
202
|
<TransactionPreview
|
|
@@ -35,7 +35,7 @@ export function getTransactionStatusModalMessage({
|
|
|
35
35
|
case 'PENDING':
|
|
36
36
|
return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ''}. It should be confirmed on the blockchain shortly.`;
|
|
37
37
|
case 'SUCCESS':
|
|
38
|
-
return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ''}. It
|
|
38
|
+
return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ''}. It's been confirmed on the blockchain!`;
|
|
39
39
|
case 'FAILED':
|
|
40
40
|
return `Your ${getFormattedType(transactionType)} has failed.`;
|
|
41
41
|
case 'TIMEOUT':
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { observer } from '@legendapp/state/react';
|
|
2
|
-
import { AccountModal } from './Account';
|
|
3
2
|
import { MakeOfferModal } from './MakeOfferModal/Modal';
|
|
4
3
|
import { SellModal } from './SellModal/Modal';
|
|
5
4
|
import SuccessfulPurchaseModal from './SuccessfulPurchaseModal';
|
|
@@ -13,7 +12,6 @@ import { BuyModal } from './BuyModal/Modal';
|
|
|
13
12
|
export const ModalProvider = observer(() => {
|
|
14
13
|
return (
|
|
15
14
|
<>
|
|
16
|
-
<AccountModal />
|
|
17
15
|
<CreateListingModal />
|
|
18
16
|
<MakeOfferModal />
|
|
19
17
|
<TransferModal />
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { truncateMiddle, truncateEnd, compareAddress } from '../address';
|
|
3
|
+
|
|
4
|
+
describe('address utils', () => {
|
|
5
|
+
describe('truncateMiddle', () => {
|
|
6
|
+
test('should truncate address with default parameters', () => {
|
|
7
|
+
const address = '0x1234567890123456789012345678901234567890';
|
|
8
|
+
const result = truncateMiddle(address);
|
|
9
|
+
expect(result).toBe('0x12345678901234567890…890');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should return full address if minPrefix + minSuffix >= 40', () => {
|
|
13
|
+
const address = '0x1234567890123456789012345678901234567890';
|
|
14
|
+
const result = truncateMiddle(address, 35, 6);
|
|
15
|
+
expect(result).toBe(address);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should truncate with custom prefix and suffix lengths', () => {
|
|
19
|
+
const address = '0x1234567890123456789012345678901234567890';
|
|
20
|
+
const result = truncateMiddle(address, 10, 5);
|
|
21
|
+
expect(result).toBe('0x1234567890…67890');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('truncateEnd', () => {
|
|
26
|
+
test('should return empty string for undefined input', () => {
|
|
27
|
+
expect(truncateEnd(undefined, 10)).toBe('');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('should not truncate text shorter than truncateAt', () => {
|
|
31
|
+
const text = 'Short';
|
|
32
|
+
expect(truncateEnd(text, 10)).toBe('Short');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('should truncate text longer than truncateAt', () => {
|
|
36
|
+
const text = 'This is a very long text';
|
|
37
|
+
expect(truncateEnd(text, 10)).toBe('This is a ...');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('should truncate text equal to truncateAt', () => {
|
|
41
|
+
const text = '1234567890';
|
|
42
|
+
expect(truncateEnd(text, 10)).toBe('1234567890...');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('compareAddress', () => {
|
|
47
|
+
test('should return true for matching addresses with different cases', () => {
|
|
48
|
+
expect(compareAddress('0x1234567890abcdef', '0x1234567890ABCDEF')).toBe(
|
|
49
|
+
true,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('should return false for different addresses', () => {
|
|
54
|
+
expect(compareAddress('0x1234567890abcdef', '0x1234567890abcdef1')).toBe(
|
|
55
|
+
false,
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('should handle undefined or empty inputs', () => {
|
|
60
|
+
expect(compareAddress()).toBe(true);
|
|
61
|
+
expect(compareAddress('', '')).toBe(true);
|
|
62
|
+
expect(compareAddress('0x123', '')).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { dateToUnixTime } from '../date';
|
|
3
|
+
|
|
4
|
+
describe('date utils', () => {
|
|
5
|
+
describe('dateToUnixTime', () => {
|
|
6
|
+
test('should convert date to unix timestamp string', () => {
|
|
7
|
+
const date = new Date('2024-01-01T00:00:00Z');
|
|
8
|
+
const result = dateToUnixTime(date);
|
|
9
|
+
expect(result).toBe('1704067200');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should handle current date', () => {
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const result = dateToUnixTime(now);
|
|
15
|
+
const expectedTimestamp = Math.floor(now.getTime() / 1000).toString();
|
|
16
|
+
expect(result).toBe(expectedTimestamp);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('should handle dates with milliseconds', () => {
|
|
20
|
+
const date = new Date('2024-01-01T00:00:00.999Z');
|
|
21
|
+
const result = dateToUnixTime(date);
|
|
22
|
+
expect(result).toBe('1704067200');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('should handle dates before unix epoch', () => {
|
|
26
|
+
const date = new Date('1969-12-31T23:59:59Z');
|
|
27
|
+
const result = dateToUnixTime(date);
|
|
28
|
+
expect(result).toBe('-1');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { getPublicRpcClient } from '../get-public-rpc-client';
|
|
3
|
+
import { allNetworks, findNetworkConfig } from '@0xsequence/network';
|
|
4
|
+
import { MissingConfigError } from '../_internal/error/transaction';
|
|
5
|
+
import type { PublicClient } from 'viem';
|
|
6
|
+
|
|
7
|
+
describe('getPublicRpcClient', () => {
|
|
8
|
+
describe('successful client creation', () => {
|
|
9
|
+
test('should create client for mainnet', () => {
|
|
10
|
+
const chainId = 1;
|
|
11
|
+
const client = getPublicRpcClient(chainId);
|
|
12
|
+
|
|
13
|
+
expect(client).toBeDefined();
|
|
14
|
+
expect(client).toHaveProperty('chain');
|
|
15
|
+
expect(
|
|
16
|
+
(client as PublicClient & { chain: { id: number } }).chain.id,
|
|
17
|
+
).toBe(chainId);
|
|
18
|
+
expect(
|
|
19
|
+
(client as PublicClient & { chain: { name: string } }).chain.name,
|
|
20
|
+
).toBe('mainnet');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('should create client for polygon', () => {
|
|
24
|
+
const chainId = 137;
|
|
25
|
+
const client = getPublicRpcClient(chainId);
|
|
26
|
+
|
|
27
|
+
expect(client).toBeDefined();
|
|
28
|
+
expect(
|
|
29
|
+
(client as PublicClient & { chain: { id: number } }).chain.id,
|
|
30
|
+
).toBe(chainId);
|
|
31
|
+
expect(
|
|
32
|
+
(client as PublicClient & { chain: { name: string } }).chain.name,
|
|
33
|
+
).toBe('polygon');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('should set up multicall batching', () => {
|
|
37
|
+
const chainId = 1;
|
|
38
|
+
const client = getPublicRpcClient(chainId);
|
|
39
|
+
|
|
40
|
+
expect(client).toHaveProperty('batch');
|
|
41
|
+
expect(
|
|
42
|
+
(client as PublicClient & { batch: { multicall: boolean } }).batch
|
|
43
|
+
.multicall,
|
|
44
|
+
).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('should configure RPC URLs correctly', () => {
|
|
48
|
+
const chainId = 1;
|
|
49
|
+
const network = findNetworkConfig(allNetworks, chainId);
|
|
50
|
+
expect(network).toBeDefined();
|
|
51
|
+
const client = getPublicRpcClient(chainId);
|
|
52
|
+
|
|
53
|
+
expect(client.chain!.rpcUrls.default.http).toEqual([network!.rpcUrl]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('should set up native currency details', () => {
|
|
57
|
+
const chainId = 1;
|
|
58
|
+
const network = findNetworkConfig(allNetworks, chainId);
|
|
59
|
+
expect(network).toBeDefined();
|
|
60
|
+
const client = getPublicRpcClient(chainId);
|
|
61
|
+
|
|
62
|
+
expect(client.chain!.nativeCurrency).toEqual(network!.nativeToken);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('error handling', () => {
|
|
67
|
+
test('should throw MissingConfigError for invalid chainId', () => {
|
|
68
|
+
const invalidChainId = 999999;
|
|
69
|
+
|
|
70
|
+
expect(() => getPublicRpcClient(invalidChainId)).toThrow(
|
|
71
|
+
MissingConfigError,
|
|
72
|
+
);
|
|
73
|
+
expect(() => getPublicRpcClient(invalidChainId)).toThrow(
|
|
74
|
+
`Network configuration for chainId: ${invalidChainId}`,
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('should throw MissingConfigError for undefined chainId', () => {
|
|
79
|
+
const undefinedChainId = undefined as unknown as number;
|
|
80
|
+
|
|
81
|
+
expect(() => getPublicRpcClient(undefinedChainId)).toThrow(
|
|
82
|
+
`Network configuration for chainId: ${undefinedChainId}`,
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('client configuration', () => {
|
|
88
|
+
test('should create client with correct transport configuration', () => {
|
|
89
|
+
const chainId = 1;
|
|
90
|
+
const client = getPublicRpcClient(chainId);
|
|
91
|
+
|
|
92
|
+
expect(client).toHaveProperty('transport');
|
|
93
|
+
expect(client.transport).toHaveProperty('request');
|
|
94
|
+
expect(typeof client.transport.request).toBe('function');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('should create unique instances for different chains', () => {
|
|
98
|
+
const mainnetClient = getPublicRpcClient(1);
|
|
99
|
+
const polygonClient = getPublicRpcClient(137);
|
|
100
|
+
|
|
101
|
+
expect(mainnetClient).not.toBe(polygonClient);
|
|
102
|
+
expect(
|
|
103
|
+
(mainnetClient as PublicClient & { chain: { id: number } }).chain.id,
|
|
104
|
+
).not.toBe(
|
|
105
|
+
(polygonClient as PublicClient & { chain: { id: number } }).chain.id,
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { getMarketplaceDetails } from '../getMarketplaceDetails';
|
|
3
|
+
import { MarketplaceKind } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
SequenceLogo,
|
|
6
|
+
OpenSeaLogo,
|
|
7
|
+
MagicEdenLogo,
|
|
8
|
+
} from '../../react/ui/components/marketplace-logos';
|
|
9
|
+
|
|
10
|
+
describe('getMarketplaceDetails', () => {
|
|
11
|
+
describe('detection by marketplace kind', () => {
|
|
12
|
+
test('should detect Sequence marketplace v1', () => {
|
|
13
|
+
const result = getMarketplaceDetails({
|
|
14
|
+
originName: 'any',
|
|
15
|
+
kind: MarketplaceKind.sequence_marketplace_v1,
|
|
16
|
+
});
|
|
17
|
+
expect(result).toBeDefined();
|
|
18
|
+
expect(result?.logo).toBe(SequenceLogo);
|
|
19
|
+
expect(result?.displayName).toBe('Sequence');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('should detect Sequence marketplace v2', () => {
|
|
23
|
+
const result = getMarketplaceDetails({
|
|
24
|
+
originName: 'any',
|
|
25
|
+
kind: MarketplaceKind.sequence_marketplace_v2,
|
|
26
|
+
});
|
|
27
|
+
expect(result).toBeDefined();
|
|
28
|
+
expect(result?.logo).toBe(SequenceLogo);
|
|
29
|
+
expect(result?.displayName).toBe('Sequence');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('should detect OpenSea by kind', () => {
|
|
33
|
+
const result = getMarketplaceDetails({
|
|
34
|
+
originName: 'any',
|
|
35
|
+
kind: MarketplaceKind.opensea,
|
|
36
|
+
});
|
|
37
|
+
expect(result).toBeDefined();
|
|
38
|
+
expect(result?.logo).toBe(OpenSeaLogo);
|
|
39
|
+
expect(result?.displayName).toBe('OpenSea');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('detection by marketplace name', () => {
|
|
44
|
+
test('should detect OpenSea by name', () => {
|
|
45
|
+
const result = getMarketplaceDetails({
|
|
46
|
+
originName: 'opensea',
|
|
47
|
+
kind: MarketplaceKind.unknown,
|
|
48
|
+
});
|
|
49
|
+
expect(result).toBeDefined();
|
|
50
|
+
expect(result?.logo).toBe(OpenSeaLogo);
|
|
51
|
+
expect(result?.displayName).toBe('OpenSea');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('should detect Magic Eden by name', () => {
|
|
55
|
+
const result = getMarketplaceDetails({
|
|
56
|
+
originName: 'magiceden',
|
|
57
|
+
kind: MarketplaceKind.unknown,
|
|
58
|
+
});
|
|
59
|
+
expect(result).toBeDefined();
|
|
60
|
+
expect(result?.logo).toBe(MagicEdenLogo);
|
|
61
|
+
expect(result?.displayName).toBe('Magic Eden');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('should be case insensitive', () => {
|
|
65
|
+
const result = getMarketplaceDetails({
|
|
66
|
+
originName: 'OPENSEA',
|
|
67
|
+
kind: MarketplaceKind.unknown,
|
|
68
|
+
});
|
|
69
|
+
expect(result).toBeDefined();
|
|
70
|
+
expect(result?.logo).toBe(OpenSeaLogo);
|
|
71
|
+
expect(result?.displayName).toBe('OpenSea');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('should handle spaces in name', () => {
|
|
75
|
+
const result = getMarketplaceDetails({
|
|
76
|
+
originName: 'magic eden',
|
|
77
|
+
kind: MarketplaceKind.unknown,
|
|
78
|
+
});
|
|
79
|
+
expect(result).toBeDefined();
|
|
80
|
+
expect(result?.logo).toBe(MagicEdenLogo);
|
|
81
|
+
expect(result?.displayName).toBe('Magic Eden');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('detection by URL', () => {
|
|
86
|
+
test('should detect marketplace from URL', () => {
|
|
87
|
+
const result = getMarketplaceDetails({
|
|
88
|
+
originName: 'https://opensea.io/assets/123',
|
|
89
|
+
kind: MarketplaceKind.unknown,
|
|
90
|
+
});
|
|
91
|
+
expect(result).toBeDefined();
|
|
92
|
+
expect(result?.logo).toBe(OpenSeaLogo);
|
|
93
|
+
expect(result?.displayName).toBe('OpenSea');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('should handle www subdomain', () => {
|
|
97
|
+
const result = getMarketplaceDetails({
|
|
98
|
+
originName: 'https://www.opensea.io',
|
|
99
|
+
kind: MarketplaceKind.unknown,
|
|
100
|
+
});
|
|
101
|
+
expect(result).toBeDefined();
|
|
102
|
+
expect(result?.logo).toBe(OpenSeaLogo);
|
|
103
|
+
expect(result?.displayName).toBe('OpenSea');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('should handle invalid URLs gracefully', () => {
|
|
107
|
+
const result = getMarketplaceDetails({
|
|
108
|
+
originName: 'not-a-url',
|
|
109
|
+
kind: MarketplaceKind.unknown,
|
|
110
|
+
});
|
|
111
|
+
expect(result).toBeUndefined();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('fallback behavior', () => {
|
|
116
|
+
test('should return undefined for unknown marketplace', () => {
|
|
117
|
+
const result = getMarketplaceDetails({
|
|
118
|
+
originName: 'unknown-marketplace',
|
|
119
|
+
kind: MarketplaceKind.unknown,
|
|
120
|
+
});
|
|
121
|
+
expect(result).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('should prioritize kind over name for Sequence marketplaces', () => {
|
|
125
|
+
const result = getMarketplaceDetails({
|
|
126
|
+
originName: 'opensea',
|
|
127
|
+
kind: MarketplaceKind.sequence_marketplace_v1,
|
|
128
|
+
});
|
|
129
|
+
expect(result).toBeDefined();
|
|
130
|
+
expect(result?.logo).toBe(SequenceLogo);
|
|
131
|
+
expect(result?.displayName).toBe('Sequence');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|