@0xsequence/marketplace-sdk 0.5.5 → 0.5.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.
Files changed (132) hide show
  1. package/dist/{builder-types-Jl3Ymws8.d.ts → builder-types-DgncJB3q.d.ts} +1 -1
  2. package/dist/{chunk-TFRAOS7F.js → chunk-3OP3WHPU.js} +1 -1
  3. package/dist/chunk-3OP3WHPU.js.map +1 -0
  4. package/dist/{chunk-J6F5QOW5.js → chunk-3OU7BADC.js} +9 -75
  5. package/dist/chunk-3OU7BADC.js.map +1 -0
  6. package/dist/{chunk-Y75XGZOB.js → chunk-5O3ZAEEX.js} +4 -2
  7. package/dist/chunk-5O3ZAEEX.js.map +1 -0
  8. package/dist/{chunk-P7UNMRZ5.js → chunk-G2T7HCWE.js} +5 -7
  9. package/dist/chunk-G2T7HCWE.js.map +1 -0
  10. package/dist/chunk-GFADBQPX.js +2 -0
  11. package/dist/chunk-GFADBQPX.js.map +1 -0
  12. package/dist/{chunk-CIPPTQDA.js → chunk-L2K4DBH2.js} +162 -108
  13. package/dist/chunk-L2K4DBH2.js.map +1 -0
  14. package/dist/{chunk-SA3U25NU.js → chunk-LNMMWV77.js} +23 -8
  15. package/dist/chunk-LNMMWV77.js.map +1 -0
  16. package/dist/{chunk-7C7ADZ2H.js → chunk-OMCWTRBR.js} +9 -42
  17. package/dist/chunk-OMCWTRBR.js.map +1 -0
  18. package/dist/{chunk-7FN62HOP.js → chunk-UMYRZJVY.js} +11 -3
  19. package/dist/chunk-UMYRZJVY.js.map +1 -0
  20. package/dist/{chunk-UZIAX32Y.js → chunk-Y56IIYDF.js} +6 -4
  21. package/dist/{chunk-UZIAX32Y.js.map → chunk-Y56IIYDF.js.map} +1 -1
  22. package/dist/{chunk-AXTDPTRD.js → chunk-YA3DWLDC.js} +30 -26
  23. package/dist/chunk-YA3DWLDC.js.map +1 -0
  24. package/dist/{chunk-3BLBZYQX.js → chunk-YYBU45PK.js} +10 -4
  25. package/dist/chunk-YYBU45PK.js.map +1 -0
  26. package/dist/{create-config-DOUq8Day.d.ts → create-config-CILyA_Hy.d.ts} +2 -2
  27. package/dist/index.css +12 -6
  28. package/dist/index.d.ts +8 -7
  29. package/dist/index.js +9 -6
  30. package/dist/{marketplace.gen-CCJ-URn2.d.ts → marketplace.gen-BVOc6fUW.d.ts} +4 -0
  31. package/dist/{marketplace.gen-D0ADxbfH.d.ts → marketplace.gen-DLOcW6C4.d.ts} +15 -3
  32. package/dist/react/_internal/api/index.d.ts +3 -3
  33. package/dist/react/_internal/api/index.js +1 -1
  34. package/dist/react/_internal/databeat/index.css.map +1 -1
  35. package/dist/react/_internal/databeat/index.d.ts +1 -1
  36. package/dist/react/_internal/databeat/index.js +7 -7
  37. package/dist/react/_internal/index.d.ts +6 -6
  38. package/dist/react/_internal/index.js +2 -2
  39. package/dist/react/_internal/wagmi/index.d.ts +4 -4
  40. package/dist/react/_internal/wagmi/index.js +1 -1
  41. package/dist/react/hooks/index.css.map +1 -1
  42. package/dist/react/hooks/index.d.ts +10 -17
  43. package/dist/react/hooks/index.js +6 -6
  44. package/dist/react/index.css +12 -6
  45. package/dist/react/index.css.map +1 -1
  46. package/dist/react/index.d.ts +6 -6
  47. package/dist/react/index.js +11 -10
  48. package/dist/react/ssr/index.d.ts +1 -0
  49. package/dist/react/ssr/index.js +10 -2
  50. package/dist/react/ssr/index.js.map +1 -1
  51. package/dist/react/ui/components/collectible-card/index.css +12 -6
  52. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  53. package/dist/react/ui/components/collectible-card/index.d.ts +4 -4
  54. package/dist/react/ui/components/collectible-card/index.js +11 -10
  55. package/dist/react/ui/icons/index.css.map +1 -1
  56. package/dist/react/ui/index.css +12 -6
  57. package/dist/react/ui/index.css.map +1 -1
  58. package/dist/react/ui/index.d.ts +4 -4
  59. package/dist/react/ui/index.js +11 -10
  60. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -1
  61. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -4
  62. package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -7
  63. package/dist/react/ui/styles/index.css.map +1 -1
  64. package/dist/{sdk-config-xWkdBdrL.d.ts → sdk-config-Bs3H_le_.d.ts} +1 -0
  65. package/dist/{services-Dd2MoBTM.d.ts → services-C3lzi1sL.d.ts} +2 -2
  66. package/dist/styles/index.css +12 -6
  67. package/dist/styles/index.css.map +1 -1
  68. package/dist/styles/index.d.ts +3 -2
  69. package/dist/styles/index.js +4 -2
  70. package/dist/types/index.d.ts +4 -4
  71. package/dist/types/index.js +2 -2
  72. package/dist/{types-vOfhbBkR.d.ts → types-BVD42zE_.d.ts} +3 -3
  73. package/dist/utils/index.d.ts +7 -8
  74. package/dist/utils/index.js +5 -5
  75. package/package.json +14 -14
  76. package/src/consts.ts +2 -0
  77. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +13 -12
  78. package/src/react/_internal/api/marketplace.gen.ts +38 -13
  79. package/src/react/_internal/databeat/index.ts +11 -3
  80. package/src/react/_internal/utils.ts +3 -0
  81. package/src/react/_internal/wagmi/create-config.ts +11 -2
  82. package/src/react/_internal/wallet/__tests__/wallet.test.ts +343 -0
  83. package/src/react/_internal/wallet/useWallet.ts +22 -15
  84. package/src/react/_internal/wallet/wallet.ts +11 -9
  85. package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +6 -14
  86. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +51 -154
  87. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +21 -19
  88. package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +5 -14
  89. package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +5 -10
  90. package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +69 -80
  91. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +12 -67
  92. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +7 -17
  93. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +7 -16
  94. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +8 -17
  95. package/src/react/hooks/__tests__/useListBalances.test.tsx +3 -8
  96. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +5 -10
  97. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +6 -11
  98. package/src/react/hooks/__tests__/useListCollections.test.tsx +5 -13
  99. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +5 -13
  100. package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +46 -78
  101. package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +9 -4
  102. package/src/react/hooks/useCurrencyBalance.tsx +4 -5
  103. package/src/react/hooks/useRoyaltyPercentage.tsx +16 -8
  104. package/src/react/ssr/__tests__/create-ssr-client.test.ts +118 -0
  105. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +25 -6
  106. package/src/react/ui/components/collectible-card/Footer.tsx +56 -7
  107. package/src/react/ui/components/collectible-card/styles.css.ts +26 -2
  108. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +10 -28
  109. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +9 -36
  110. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +2 -24
  111. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +16 -5
  112. package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -2
  113. package/src/react/ui/modals/SellModal/Modal.tsx +1 -0
  114. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +8 -7
  115. package/src/types/sdk-config.ts +1 -0
  116. package/src/utils/index.ts +0 -1
  117. package/src/utils/price.ts +11 -0
  118. package/tsconfig.tsbuildinfo +1 -1
  119. package/dist/chunk-3BLBZYQX.js.map +0 -1
  120. package/dist/chunk-7C7ADZ2H.js.map +0 -1
  121. package/dist/chunk-7FN62HOP.js.map +0 -1
  122. package/dist/chunk-AXTDPTRD.js.map +0 -1
  123. package/dist/chunk-CIPPTQDA.js.map +0 -1
  124. package/dist/chunk-J6F5QOW5.js.map +0 -1
  125. package/dist/chunk-P7UNMRZ5.js.map +0 -1
  126. package/dist/chunk-SA3U25NU.js.map +0 -1
  127. package/dist/chunk-TFRAOS7F.js.map +0 -1
  128. package/dist/chunk-Y75XGZOB.js.map +0 -1
  129. package/src/react/_internal/test/mocks/publicClient.ts +0 -39
  130. package/src/react/_internal/test/mocks/wagmi.ts +0 -61
  131. package/src/utils/__tests__/get-public-rpc-client.test.ts +0 -111
  132. package/src/utils/get-public-rpc-client.ts +0 -41
@@ -1,39 +0,0 @@
1
- import { vi } from 'vitest';
2
- import type { PublicClient } from 'viem';
3
-
4
- export type MockPublicClient = PublicClient;
5
-
6
- /**
7
- * Common mock implementations for public client functions
8
- */
9
- export const commonPublicClientMocks = {
10
- getBalance: vi.fn().mockResolvedValue(BigInt('1000000000000000000')), // 1 ETH
11
- readContract: vi.fn().mockImplementation(async ({ functionName }) => {
12
- if (functionName === 'balanceOf') {
13
- return BigInt('1000000000000000000'); // 1 Token
14
- }
15
- if (functionName === 'decimals') {
16
- return 18;
17
- }
18
- return BigInt(0);
19
- }),
20
- };
21
-
22
- /**
23
- * Creates a mock public client with pre-configured mock functions for testing
24
- * @param overrides - Optional overrides for the default mock implementations
25
- * @returns A mock public client instance with vitest mock functions
26
- */
27
- export function createMockPublicClient(
28
- overrides?: Partial<MockPublicClient>,
29
- ): MockPublicClient {
30
- const defaultMockPublicClient = {
31
- getBalance: commonPublicClientMocks.getBalance,
32
- readContract: commonPublicClientMocks.readContract,
33
- } as unknown as PublicClient;
34
-
35
- return {
36
- ...defaultMockPublicClient,
37
- ...overrides,
38
- };
39
- }
@@ -1,61 +0,0 @@
1
- import { vi } from 'vitest';
2
- import type { Config } from 'wagmi';
3
- import type { ReactNode } from 'react';
4
- import { zeroAddress } from 'viem';
5
-
6
- export type MockWagmiConfig = Config;
7
-
8
- /**
9
- * Common mock implementations for wagmi hooks and functions
10
- */
11
- export const commonWagmiMocks = {
12
- useAccount: vi.fn().mockReturnValue({
13
- address: zeroAddress,
14
- isConnecting: false,
15
- isDisconnected: false,
16
- isReconnecting: false,
17
- status: 'connected',
18
- }),
19
- createConfig: vi.fn().mockReturnValue({
20
- chains: [],
21
- connectors: [],
22
- transports: {},
23
- }),
24
- http: vi.fn().mockReturnValue({}),
25
- WagmiProvider: vi
26
- .fn()
27
- .mockImplementation(({ children }: { children: ReactNode }) => children),
28
- };
29
-
30
- /**
31
- * Creates mock wagmi hooks and functions with pre-configured implementations for testing
32
- * @param overrides - Optional overrides for the default mock implementations
33
- * @returns Mock wagmi hooks and functions with vitest mock functions
34
- */
35
- export function createMockWagmi(overrides?: Partial<typeof commonWagmiMocks>) {
36
- return {
37
- ...commonWagmiMocks,
38
- ...overrides,
39
- };
40
- }
41
-
42
- /**
43
- * Mock chain data for testing
44
- */
45
- export const mockChains = {
46
- mainnet: { id: 1, name: 'Ethereum', network: 'mainnet' },
47
- sepolia: { id: 11155111, name: 'Sepolia', network: 'sepolia' },
48
- };
49
-
50
- /**
51
- * Mock connector data for testing
52
- */
53
- export const mockConnectors = {
54
- mock: () => ({
55
- accounts: [
56
- '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
57
- '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
58
- '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
59
- ],
60
- }),
61
- };
@@ -1,111 +0,0 @@
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
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
54
- expect(client.chain!.rpcUrls.default.http).toEqual([network!.rpcUrl]);
55
- });
56
-
57
- test('should set up native currency details', () => {
58
- const chainId = 1;
59
- const network = findNetworkConfig(allNetworks, chainId);
60
- expect(network).toBeDefined();
61
- const client = getPublicRpcClient(chainId);
62
-
63
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
64
- expect(client.chain!.nativeCurrency).toEqual(network!.nativeToken);
65
- });
66
- });
67
-
68
- describe('error handling', () => {
69
- test('should throw MissingConfigError for invalid chainId', () => {
70
- const invalidChainId = 999999;
71
-
72
- expect(() => getPublicRpcClient(invalidChainId)).toThrow(
73
- MissingConfigError,
74
- );
75
- expect(() => getPublicRpcClient(invalidChainId)).toThrow(
76
- `Network configuration for chainId: ${invalidChainId}`,
77
- );
78
- });
79
-
80
- test('should throw MissingConfigError for undefined chainId', () => {
81
- const undefinedChainId = undefined as unknown as number;
82
-
83
- expect(() => getPublicRpcClient(undefinedChainId)).toThrow(
84
- `Network configuration for chainId: ${undefinedChainId}`,
85
- );
86
- });
87
- });
88
-
89
- describe('client configuration', () => {
90
- test('should create client with correct transport configuration', () => {
91
- const chainId = 1;
92
- const client = getPublicRpcClient(chainId);
93
-
94
- expect(client).toHaveProperty('transport');
95
- expect(client.transport).toHaveProperty('request');
96
- expect(typeof client.transport.request).toBe('function');
97
- });
98
-
99
- test('should create unique instances for different chains', () => {
100
- const mainnetClient = getPublicRpcClient(1);
101
- const polygonClient = getPublicRpcClient(137);
102
-
103
- expect(mainnetClient).not.toBe(polygonClient);
104
- expect(
105
- (mainnetClient as PublicClient & { chain: { id: number } }).chain.id,
106
- ).not.toBe(
107
- (polygonClient as PublicClient & { chain: { id: number } }).chain.id,
108
- );
109
- });
110
- });
111
- });
@@ -1,41 +0,0 @@
1
- import { allNetworks, findNetworkConfig } from '@0xsequence/network';
2
- import { http, type PublicClient, createPublicClient } from 'viem';
3
- import type { ChainId } from '../react/_internal';
4
- import { MissingConfigError } from './_internal/error/transaction';
5
-
6
- export const getPublicRpcClient = (chainId: ChainId): PublicClient => {
7
- if (chainId === undefined) {
8
- throw new MissingConfigError(
9
- `Network configuration for chainId: ${chainId}`,
10
- );
11
- }
12
-
13
- const network = findNetworkConfig(allNetworks, chainId);
14
-
15
- if (!network) {
16
- throw new MissingConfigError(
17
- `Network configuration for chainId: ${chainId}`,
18
- );
19
- }
20
-
21
- return createPublicClient({
22
- chain: {
23
- ...network,
24
- id: Number(chainId),
25
- name: network.name,
26
- nativeCurrency: { ...network.nativeToken },
27
- rpcUrls: {
28
- default: {
29
- http: [network.rpcUrl],
30
- },
31
- public: {
32
- http: [network.rpcUrl],
33
- },
34
- },
35
- },
36
- batch: {
37
- multicall: true,
38
- },
39
- transport: http(),
40
- });
41
- };