@0xsequence/marketplace-sdk 0.8.1 → 0.8.3
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/.changeset/flat-parks-clean.md +8 -0
- package/.changeset/red-buckets-deny.md +6 -0
- package/CHANGELOG.md +17 -0
- package/dist/{builder-types-QlHwc9bI.d.ts → builder-types-BY6eD6vD.d.ts} +1 -1
- package/dist/{chunk-IZ44XPBH.js → chunk-25CAMYCG.js} +2 -2
- package/dist/{chunk-ABSYNRT5.js → chunk-5ATGT5S4.js} +3 -11
- package/dist/chunk-5ATGT5S4.js.map +1 -0
- package/dist/{chunk-BNAUZXPV.js → chunk-ALICO7NG.js} +3 -3
- package/dist/chunk-ALICO7NG.js.map +1 -0
- package/dist/{chunk-Q5RKAMYF.js → chunk-BGY4WXER.js} +43 -1
- package/dist/chunk-BGY4WXER.js.map +1 -0
- package/dist/{chunk-X3QNSQER.js → chunk-DFI52A2E.js} +56 -86
- package/dist/chunk-DFI52A2E.js.map +1 -0
- package/dist/{chunk-A5ACY5YV.js → chunk-FH4TZRDV.js} +2 -2
- package/dist/{chunk-3JU7SQVE.js → chunk-FSJKN4YN.js} +61 -24
- package/dist/chunk-FSJKN4YN.js.map +1 -0
- package/dist/{chunk-3II5GLHE.js → chunk-HGKWWZWY.js} +2 -2
- package/dist/{chunk-BN36GABQ.js → chunk-QTV77W42.js} +89 -65
- package/dist/chunk-QTV77W42.js.map +1 -0
- package/dist/{chunk-BCO4CYE4.js → chunk-SJU6QZHM.js} +2 -2
- package/dist/{chunk-2VHHJNXY.js → chunk-WXKV5N4T.js} +3 -3
- package/dist/{chunk-GBQVYNCD.js → chunk-XUNDLCEH.js} +3 -3
- package/dist/{create-config-ClkUr27C.d.ts → create-config-qDML4ZNn.d.ts} +1 -1
- package/dist/{index-CnaFSNE9.d.ts → index-DtWR0b_l.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -10
- package/dist/{listCollectibles-B0tbqnRd.d.ts → lowestListing-DUZ_nYml.d.ts} +49 -42
- package/dist/{marketplace.gen-BTHxxhG2.d.ts → marketplace.gen-DS-MmGEB.d.ts} +35 -4
- package/dist/react/_internal/api/index.d.ts +2 -2
- package/dist/react/_internal/api/index.js +1 -1
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +10 -10
- package/dist/react/_internal/index.d.ts +5 -5
- package/dist/react/_internal/index.js +2 -2
- package/dist/react/_internal/wagmi/index.d.ts +3 -3
- package/dist/react/_internal/wagmi/index.js +2 -2
- package/dist/react/hooks/index.d.ts +68 -183
- package/dist/react/hooks/index.js +11 -13
- package/dist/react/hooks/options/index.d.ts +3 -3
- package/dist/react/hooks/options/index.js +4 -4
- package/dist/react/index.d.ts +8 -8
- package/dist/react/index.js +15 -17
- package/dist/react/queries/index.d.ts +2 -2
- package/dist/react/queries/index.js +11 -28
- package/dist/react/queries/index.js.map +1 -1
- package/dist/react/ssr/index.d.ts +2 -2
- package/dist/react/ssr/index.js +3 -3
- package/dist/react/ui/components/collectible-card/index.d.ts +1 -1
- package/dist/react/ui/components/collectible-card/index.js +13 -13
- package/dist/react/ui/icons/index.js +6 -6
- package/dist/react/ui/index.d.ts +1 -1
- package/dist/react/ui/index.js +13 -13
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +10 -10
- package/dist/{services-ybGoDJd9.d.ts → services-BOX67E7W.d.ts} +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -4
- package/dist/{types-o_pKUpQG.d.ts → types-CJLhc2VZ.d.ts} +2 -2
- package/dist/utils/abi/index.js +5 -5
- package/dist/utils/index.d.ts +54 -2
- package/dist/utils/index.js +12 -8
- package/package.json +4 -2
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +5 -2
- package/src/react/_internal/api/marketplace.gen.ts +39 -6
- package/src/react/_internal/api/zod-schema.ts +7 -18
- package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +10 -2
- package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +10 -2
- package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +5 -1
- package/src/react/hooks/__tests__/useHighestOffer.test.tsx +7 -8
- package/src/react/hooks/__tests__/useLowestListing.test.tsx +4 -5
- package/src/react/hooks/useCancelTransactionSteps.tsx +2 -2
- package/src/react/hooks/useHighestOffer.tsx +1 -39
- package/src/react/hooks/useLowestListing.tsx +4 -51
- package/src/react/queries/highestOffer.ts +25 -30
- package/src/react/queries/index.ts +1 -0
- package/src/react/queries/lowestListing.ts +52 -0
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +6 -9
- package/src/react/ui/modals/BuyModal/Modal.tsx +26 -8
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +6 -2
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +4 -4
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -5
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +4 -4
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +18 -14
- package/src/types/api-types.ts +1 -2
- package/src/types/types.ts +5 -0
- package/src/utils/price.ts +103 -0
- package/dist/chunk-3JU7SQVE.js.map +0 -1
- package/dist/chunk-ABSYNRT5.js.map +0 -1
- package/dist/chunk-BN36GABQ.js.map +0 -1
- package/dist/chunk-BNAUZXPV.js.map +0 -1
- package/dist/chunk-Q5RKAMYF.js.map +0 -1
- package/dist/chunk-X3QNSQER.js.map +0 -1
- /package/dist/{chunk-IZ44XPBH.js.map → chunk-25CAMYCG.js.map} +0 -0
- /package/dist/{chunk-A5ACY5YV.js.map → chunk-FH4TZRDV.js.map} +0 -0
- /package/dist/{chunk-3II5GLHE.js.map → chunk-HGKWWZWY.js.map} +0 -0
- /package/dist/{chunk-BCO4CYE4.js.map → chunk-SJU6QZHM.js.map} +0 -0
- /package/dist/{chunk-2VHHJNXY.js.map → chunk-WXKV5N4T.js.map} +0 -0
- /package/dist/{chunk-GBQVYNCD.js.map → chunk-XUNDLCEH.js.map} +0 -0
|
@@ -50,8 +50,12 @@ describe('useGenerateListingTransaction', () => {
|
|
|
50
50
|
[
|
|
51
51
|
{
|
|
52
52
|
"data": "0x...",
|
|
53
|
-
"executeType": "order",
|
|
54
53
|
"id": "tokenApproval",
|
|
54
|
+
"post": {
|
|
55
|
+
"body": {},
|
|
56
|
+
"endpoint": "/api/order",
|
|
57
|
+
"method": "POST",
|
|
58
|
+
},
|
|
55
59
|
"price": "0",
|
|
56
60
|
"to": "0x1234567890123456789012345678901234567890",
|
|
57
61
|
"value": "0",
|
|
@@ -91,8 +95,12 @@ describe('useGenerateListingTransaction', () => {
|
|
|
91
95
|
[
|
|
92
96
|
{
|
|
93
97
|
"data": "0x...",
|
|
94
|
-
"executeType": "order",
|
|
95
98
|
"id": "tokenApproval",
|
|
99
|
+
"post": {
|
|
100
|
+
"body": {},
|
|
101
|
+
"endpoint": "/api/order",
|
|
102
|
+
"method": "POST",
|
|
103
|
+
},
|
|
96
104
|
"price": "0",
|
|
97
105
|
"to": "0x1234567890123456789012345678901234567890",
|
|
98
106
|
"value": "0",
|
|
@@ -49,8 +49,12 @@ describe('useGenerateOfferTransaction', () => {
|
|
|
49
49
|
[
|
|
50
50
|
{
|
|
51
51
|
"data": "0x...",
|
|
52
|
-
"executeType": "order",
|
|
53
52
|
"id": "tokenApproval",
|
|
53
|
+
"post": {
|
|
54
|
+
"body": {},
|
|
55
|
+
"endpoint": "/api/order",
|
|
56
|
+
"method": "POST",
|
|
57
|
+
},
|
|
54
58
|
"price": "0",
|
|
55
59
|
"to": "0x1234567890123456789012345678901234567890",
|
|
56
60
|
"value": "0",
|
|
@@ -89,8 +93,12 @@ describe('useGenerateOfferTransaction', () => {
|
|
|
89
93
|
[
|
|
90
94
|
{
|
|
91
95
|
"data": "0x...",
|
|
92
|
-
"executeType": "order",
|
|
93
96
|
"id": "tokenApproval",
|
|
97
|
+
"post": {
|
|
98
|
+
"body": {},
|
|
99
|
+
"endpoint": "/api/order",
|
|
100
|
+
"method": "POST",
|
|
101
|
+
},
|
|
94
102
|
"price": "0",
|
|
95
103
|
"to": "0x1234567890123456789012345678901234567890",
|
|
96
104
|
"value": "0",
|
|
@@ -52,8 +52,12 @@ describe('useGenerateSellTransaction', () => {
|
|
|
52
52
|
[
|
|
53
53
|
{
|
|
54
54
|
"data": "0x...",
|
|
55
|
-
"executeType": "order",
|
|
56
55
|
"id": "tokenApproval",
|
|
56
|
+
"post": {
|
|
57
|
+
"body": {},
|
|
58
|
+
"endpoint": "/api/order",
|
|
59
|
+
"method": "POST",
|
|
60
|
+
},
|
|
57
61
|
"price": "0",
|
|
58
62
|
"to": "0x1234567890123456789012345678901234567890",
|
|
59
63
|
"value": "0",
|
|
@@ -4,17 +4,16 @@ import { zeroAddress } from 'viem';
|
|
|
4
4
|
import { describe, expect, it } from 'vitest';
|
|
5
5
|
import {
|
|
6
6
|
mockMarketplaceEndpoint,
|
|
7
|
-
|
|
7
|
+
mockOrder,
|
|
8
8
|
} from '../../_internal/api/__mocks__/marketplace.msw';
|
|
9
|
-
import type { UseHighestOfferArgs } from '
|
|
9
|
+
import type { UseHighestOfferArgs } from '../../queries/highestOffer';
|
|
10
10
|
import { useHighestOffer } from '../useHighestOffer';
|
|
11
11
|
|
|
12
12
|
describe('useHighestOffer', () => {
|
|
13
13
|
const defaultArgs: UseHighestOfferArgs = {
|
|
14
|
-
chainId:
|
|
14
|
+
chainId: mockOrder.chainId,
|
|
15
15
|
collectionAddress: zeroAddress,
|
|
16
|
-
tokenId: '1',
|
|
17
|
-
query: {},
|
|
16
|
+
tokenId: mockOrder.tokenId ?? '1',
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
it('should fetch highest offer data successfully', async () => {
|
|
@@ -30,7 +29,7 @@ describe('useHighestOffer', () => {
|
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
// Verify the data matches our mock with BigInt values
|
|
33
|
-
expect(result.current.data).toEqual(
|
|
32
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
34
33
|
expect(result.current.error).toBeNull();
|
|
35
34
|
});
|
|
36
35
|
|
|
@@ -78,8 +77,8 @@ describe('useHighestOffer', () => {
|
|
|
78
77
|
expect(result.current.data).toBeDefined();
|
|
79
78
|
});
|
|
80
79
|
|
|
81
|
-
// Verify that the query was refetched with new args using
|
|
82
|
-
expect(result.current.data).toEqual(
|
|
80
|
+
// Verify that the query was refetched with new args using string values
|
|
81
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
83
82
|
expect(result.current.isSuccess).toBe(true);
|
|
84
83
|
});
|
|
85
84
|
|
|
@@ -14,7 +14,6 @@ describe('useLowestListing', () => {
|
|
|
14
14
|
chainId: 1,
|
|
15
15
|
collectionAddress: zeroAddress as `0x${string}`,
|
|
16
16
|
tokenId: '1',
|
|
17
|
-
query: {},
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
it('should fetch lowest listing data successfully', async () => {
|
|
@@ -31,7 +30,7 @@ describe('useLowestListing', () => {
|
|
|
31
30
|
|
|
32
31
|
// Verify the data matches our mock
|
|
33
32
|
expect(result.current.data).toBeDefined();
|
|
34
|
-
expect(result.current.data
|
|
33
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
35
34
|
expect(result.current.error).toBeNull();
|
|
36
35
|
});
|
|
37
36
|
|
|
@@ -82,7 +81,7 @@ describe('useLowestListing', () => {
|
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
// Verify that the query was refetched with new args
|
|
85
|
-
expect(result.current.data
|
|
84
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
86
85
|
expect(result.current.isSuccess).toBe(true);
|
|
87
86
|
});
|
|
88
87
|
|
|
@@ -103,7 +102,7 @@ describe('useLowestListing', () => {
|
|
|
103
102
|
expect(result.current.isLoading).toBe(false);
|
|
104
103
|
});
|
|
105
104
|
|
|
106
|
-
expect(result.current.data
|
|
105
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
107
106
|
expect(result.current.isSuccess).toBe(true);
|
|
108
107
|
});
|
|
109
108
|
|
|
@@ -123,7 +122,7 @@ describe('useLowestListing', () => {
|
|
|
123
122
|
expect(result.current.isLoading).toBe(false);
|
|
124
123
|
});
|
|
125
124
|
|
|
126
|
-
expect(result.current.data
|
|
125
|
+
expect(result.current.data).toEqual(mockOrder);
|
|
127
126
|
expect(result.current.isSuccess).toBe(true);
|
|
128
127
|
});
|
|
129
128
|
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
WalletInstanceNotFoundError,
|
|
5
5
|
} from '../../utils/_internal/error/transaction';
|
|
6
6
|
import {
|
|
7
|
-
ExecuteType,
|
|
8
7
|
type MarketplaceKind,
|
|
9
8
|
type Step,
|
|
10
9
|
StepType,
|
|
@@ -218,7 +217,8 @@ export const useCancelTransactionSteps = ({
|
|
|
218
217
|
|
|
219
218
|
const result = await marketplaceClient.execute({
|
|
220
219
|
signature: signature as string,
|
|
221
|
-
|
|
220
|
+
method: signatureStep.post?.method as string,
|
|
221
|
+
endpoint: signatureStep.post?.endpoint as string,
|
|
222
222
|
body: signatureStep.post?.body,
|
|
223
223
|
});
|
|
224
224
|
|
|
@@ -1,45 +1,7 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { highestOfferOptions } from '../queries
|
|
2
|
+
import { type UseHighestOfferArgs, highestOfferOptions } from '../queries';
|
|
3
3
|
import { useConfig } from './useConfig';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Type for the highest offer hook parameters
|
|
7
|
-
* @property {string} collectionAddress - The contract address of the collection
|
|
8
|
-
* @property {string} tokenId - The ID of the specific token
|
|
9
|
-
* @property {string} chainId - The chain ID where the collection exists
|
|
10
|
-
* @property {object} [query] - Optional query configuration parameters
|
|
11
|
-
*/
|
|
12
|
-
export type UseHighestOfferArgs = {
|
|
13
|
-
collectionAddress: string;
|
|
14
|
-
tokenId: string;
|
|
15
|
-
chainId: number;
|
|
16
|
-
query?: {
|
|
17
|
-
enabled?: boolean;
|
|
18
|
-
staleTime?: number;
|
|
19
|
-
gcTime?: number;
|
|
20
|
-
refetchInterval?: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Hook to fetch the highest offer for a specific collectible
|
|
26
|
-
*
|
|
27
|
-
* @param args - The arguments for fetching the highest offer
|
|
28
|
-
* @returns Query result containing the highest offer data
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* const { data, isLoading, error } = useHighestOffer({
|
|
33
|
-
* collectionAddress: '0x123...',
|
|
34
|
-
* tokenId: '1',
|
|
35
|
-
* chainId: 1,
|
|
36
|
-
* query: {
|
|
37
|
-
* enabled: true,
|
|
38
|
-
* refetchInterval: 10000,
|
|
39
|
-
* }
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
5
|
export function useHighestOffer(args: UseHighestOfferArgs) {
|
|
44
6
|
const config = useConfig();
|
|
45
7
|
return useQuery(highestOfferOptions(args, config));
|
|
@@ -1,55 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type { SdkConfig } from '../../types';
|
|
4
|
-
import {
|
|
5
|
-
AddressSchema,
|
|
6
|
-
QueryArgSchema,
|
|
7
|
-
collectableKeys,
|
|
8
|
-
getMarketplaceClient,
|
|
9
|
-
} from '../_internal';
|
|
10
|
-
import { getCollectibleLowestListingArgsSchema } from '../_internal/api/zod-schema';
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { type UseLowestListingArgs, lowestListingOptions } from '../queries';
|
|
11
3
|
import { useConfig } from './useConfig';
|
|
12
4
|
|
|
13
|
-
|
|
14
|
-
.omit({
|
|
15
|
-
contractAddress: true,
|
|
16
|
-
})
|
|
17
|
-
.extend({
|
|
18
|
-
collectionAddress: AddressSchema,
|
|
19
|
-
chainId: z.number(),
|
|
20
|
-
query: QueryArgSchema,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export type UseLowestListingArgs = z.infer<typeof UseLowestListingSchema>;
|
|
24
|
-
|
|
25
|
-
export type UseLowestListingReturn = Awaited<
|
|
26
|
-
ReturnType<typeof fetchLowestListing>
|
|
27
|
-
>;
|
|
28
|
-
|
|
29
|
-
const fetchLowestListing = async (
|
|
30
|
-
args: UseLowestListingArgs,
|
|
31
|
-
config: SdkConfig,
|
|
32
|
-
) => {
|
|
33
|
-
const parsedArgs = UseLowestListingSchema.parse(args);
|
|
34
|
-
const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
|
|
35
|
-
return marketplaceClient.getCollectibleLowestListing({
|
|
36
|
-
...parsedArgs,
|
|
37
|
-
contractAddress: parsedArgs.collectionAddress,
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const lowestListingOptions = (
|
|
42
|
-
args: UseLowestListingArgs,
|
|
43
|
-
config: SdkConfig,
|
|
44
|
-
) => {
|
|
45
|
-
return queryOptions({
|
|
46
|
-
...args.query,
|
|
47
|
-
queryKey: [...collectableKeys.lowestListings, args, config],
|
|
48
|
-
queryFn: () => fetchLowestListing(args, config),
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const useLowestListing = (args: UseLowestListingArgs) => {
|
|
5
|
+
export function useLowestListing(args: UseLowestListingArgs) {
|
|
53
6
|
const config = useConfig();
|
|
54
7
|
return useQuery(lowestListingOptions(args, config));
|
|
55
|
-
}
|
|
8
|
+
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
2
|
+
import type { Address } from 'viem';
|
|
3
|
+
import type { SdkConfig } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
type GetCollectibleHighestOfferArgs,
|
|
6
|
+
collectableKeys,
|
|
7
|
+
getMarketplaceClient,
|
|
8
|
+
} from '../_internal';
|
|
5
9
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
export interface UseHighestOfferArgs
|
|
11
|
+
extends Omit<GetCollectibleHighestOfferArgs, 'contractAddress'> {
|
|
12
|
+
collectionAddress: Address;
|
|
9
13
|
chainId: number;
|
|
10
|
-
query?:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
priceAmount: bigint;
|
|
15
|
-
priceAmountNet: bigint;
|
|
16
|
-
};
|
|
14
|
+
query?: {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
17
18
|
|
|
18
|
-
/**
|
|
19
|
-
* Fetches the highest offer for a specific collectible
|
|
20
|
-
*
|
|
21
|
-
* @param args - Arguments for the API call
|
|
22
|
-
* @param config - SDK configuration
|
|
23
|
-
* @returns The highest offer data
|
|
24
|
-
*/
|
|
25
19
|
export async function fetchHighestOffer(
|
|
26
20
|
args: UseHighestOfferArgs,
|
|
27
21
|
config: SdkConfig,
|
|
@@ -30,19 +24,19 @@ export async function fetchHighestOffer(
|
|
|
30
24
|
|
|
31
25
|
const data = await marketplaceClient.getCollectibleHighestOffer({
|
|
32
26
|
contractAddress: args.collectionAddress,
|
|
33
|
-
|
|
27
|
+
...args,
|
|
34
28
|
});
|
|
35
29
|
|
|
36
|
-
let order: Order | undefined;
|
|
37
|
-
if (data.order) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
30
|
+
// let order: Order | undefined;
|
|
31
|
+
// if (data.order) {
|
|
32
|
+
// order = {
|
|
33
|
+
// ...data.order,
|
|
34
|
+
// priceAmount: BigInt(data.order.priceAmount),
|
|
35
|
+
// priceAmountNet: BigInt(data.order.priceAmountNet),
|
|
36
|
+
// };
|
|
37
|
+
// }
|
|
44
38
|
|
|
45
|
-
return order ?? null;
|
|
39
|
+
return data.order ?? null;
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
/**
|
|
@@ -57,6 +51,7 @@ export function highestOfferOptions(
|
|
|
57
51
|
config: SdkConfig,
|
|
58
52
|
) {
|
|
59
53
|
return queryOptions({
|
|
54
|
+
enabled: args.query?.enabled ?? true,
|
|
60
55
|
queryKey: [...collectableKeys.highestOffers, args],
|
|
61
56
|
queryFn: () => fetchHighestOffer(args, config),
|
|
62
57
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { Address } from 'viem';
|
|
3
|
+
import type { SdkConfig } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
type GetCollectibleLowestListingArgs,
|
|
6
|
+
type GetCollectibleLowestListingReturn,
|
|
7
|
+
collectableKeys,
|
|
8
|
+
getMarketplaceClient,
|
|
9
|
+
} from '../_internal';
|
|
10
|
+
|
|
11
|
+
export interface UseLowestListingArgs
|
|
12
|
+
extends Omit<GetCollectibleLowestListingArgs, 'contractAddress'> {
|
|
13
|
+
collectionAddress: Address;
|
|
14
|
+
chainId: number;
|
|
15
|
+
query?: {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function fetchLowestListing(
|
|
21
|
+
args: UseLowestListingArgs,
|
|
22
|
+
config: SdkConfig,
|
|
23
|
+
): Promise<GetCollectibleLowestListingReturn['order'] | null> {
|
|
24
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
25
|
+
|
|
26
|
+
const data = await marketplaceClient.getCollectibleLowestListing({
|
|
27
|
+
contractAddress: args.collectionAddress,
|
|
28
|
+
...args,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// let order: Order | undefined;
|
|
32
|
+
// if (data.order) {
|
|
33
|
+
// order = {
|
|
34
|
+
// ...data.order,
|
|
35
|
+
// priceAmount: BigInt(data.order.priceAmount),
|
|
36
|
+
// priceAmountNet: BigInt(data.order.priceAmountNet),
|
|
37
|
+
// };
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
return data.order || null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function lowestListingOptions(
|
|
44
|
+
args: UseLowestListingArgs,
|
|
45
|
+
config: SdkConfig,
|
|
46
|
+
) {
|
|
47
|
+
return queryOptions({
|
|
48
|
+
enabled: args.query?.enabled ?? true,
|
|
49
|
+
queryKey: [...collectableKeys.lowestListings, args],
|
|
50
|
+
queryFn: () => fetchLowestListing(args, config),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { use$, useObservable } from '@legendapp/state/react';
|
|
4
|
-
import * as dn from 'dnum';
|
|
5
4
|
|
|
6
5
|
import { Text, TokenImage } from '@0xsequence/design-system';
|
|
7
6
|
import { DEFAULT_MARKETPLACE_FEE_PERCENTAGE } from '../../../../consts';
|
|
8
7
|
import { compareAddress } from '../../../../utils/address';
|
|
8
|
+
import { formatPriceWithFee } from '../../../../utils/price';
|
|
9
9
|
import type { Order } from '../../../_internal';
|
|
10
10
|
import { useCurrency, useMarketplaceConfig } from '../../../hooks';
|
|
11
11
|
import { ActionModal } from '../_internal/components/actionModal';
|
|
@@ -70,21 +70,18 @@ const TotalPrice = ({
|
|
|
70
70
|
|
|
71
71
|
if (currency) {
|
|
72
72
|
try {
|
|
73
|
-
const price = dn.from(order.priceAmount, currency.decimals);
|
|
74
|
-
|
|
75
|
-
const totalPriceWithoutFees = dn.multiply(quantityStr, price);
|
|
76
73
|
const marketplaceFeePercentage =
|
|
77
74
|
marketplaceConfig?.collections.find((collection) =>
|
|
78
75
|
compareAddress(collection.address, order.collectionContractAddress),
|
|
79
76
|
)?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
|
|
77
|
+
const quantity = BigInt(quantityStr);
|
|
78
|
+
const totalPriceRaw = BigInt(order.priceAmount) * quantity;
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
formattedPrice = formatPriceWithFee(
|
|
81
|
+
totalPriceRaw,
|
|
83
82
|
currency.decimals,
|
|
83
|
+
marketplaceFeePercentage,
|
|
84
84
|
);
|
|
85
|
-
const totalPrice = dn.multiply(totalPriceWithoutFees, feeMultiplier);
|
|
86
|
-
|
|
87
|
-
formattedPrice = dn.format(totalPrice, { trailingZeros: false });
|
|
88
85
|
} catch (e) {
|
|
89
86
|
console.error('Error formatting price', e);
|
|
90
87
|
error = 'Unable to calculate total price';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
type SelectPaymentSettings,
|
|
5
|
+
useSelectPaymentModal,
|
|
6
|
+
} from '@0xsequence/checkout';
|
|
7
|
+
import { useEffect, useRef } from 'react';
|
|
5
8
|
import { ContractType } from '../../../_internal';
|
|
6
9
|
import { ErrorModal } from '../_internal/components/actionModal/ErrorModal';
|
|
7
10
|
import { LoadingModal } from '../_internal/components/actionModal/LoadingModal';
|
|
@@ -27,11 +30,10 @@ export const BuyModal = () => {
|
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
const BuyModalContent = () => {
|
|
30
|
-
const { chainId
|
|
33
|
+
const { chainId } = useBuyModalProps();
|
|
31
34
|
|
|
32
35
|
const onError = useOnError();
|
|
33
36
|
|
|
34
|
-
const { openSelectPaymentModal } = useSelectPaymentModal();
|
|
35
37
|
const quantity = useQuantity();
|
|
36
38
|
|
|
37
39
|
const {
|
|
@@ -98,9 +100,25 @@ const BuyModalContent = () => {
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
if (paymentModalParams) {
|
|
101
|
-
|
|
102
|
-
...paymentModalParams,
|
|
103
|
-
skipNativeBalanceCheck,
|
|
104
|
-
});
|
|
103
|
+
return <PaymentModalOpener paymentModalParams={paymentModalParams} />;
|
|
105
104
|
}
|
|
106
105
|
};
|
|
106
|
+
|
|
107
|
+
const PaymentModalOpener = ({
|
|
108
|
+
paymentModalParams,
|
|
109
|
+
}: {
|
|
110
|
+
paymentModalParams: SelectPaymentSettings;
|
|
111
|
+
}) => {
|
|
112
|
+
const { openSelectPaymentModal } = useSelectPaymentModal();
|
|
113
|
+
const hasOpenedRef = useRef(false);
|
|
114
|
+
|
|
115
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!hasOpenedRef.current) {
|
|
118
|
+
hasOpenedRef.current = true;
|
|
119
|
+
openSelectPaymentModal(paymentModalParams);
|
|
120
|
+
}
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return null;
|
|
124
|
+
};
|
|
@@ -57,6 +57,7 @@ export const getBuyCollectableParams = async ({
|
|
|
57
57
|
collectable,
|
|
58
58
|
checkoutOptions,
|
|
59
59
|
fee,
|
|
60
|
+
skipNativeBalanceCheck,
|
|
60
61
|
}: GetBuyCollectableParams) => {
|
|
61
62
|
const marketplaceClient = getMarketplaceClient(chainId, config);
|
|
62
63
|
const { steps } = await marketplaceClient.generateBuyTransaction({
|
|
@@ -119,6 +120,7 @@ export const getBuyCollectableParams = async ({
|
|
|
119
120
|
queryClient.invalidateQueries();
|
|
120
121
|
buyModalStore.send({ type: 'close' });
|
|
121
122
|
},
|
|
123
|
+
skipNativeBalanceCheck,
|
|
122
124
|
...(customCreditCardProviderCallback && {
|
|
123
125
|
customProviderCallback: () => {
|
|
124
126
|
customCreditCardProviderCallback(buyStep);
|
|
@@ -147,6 +149,7 @@ export const usePaymentModalParams = (args: usePaymentModalParams) => {
|
|
|
147
149
|
quantity,
|
|
148
150
|
} = args;
|
|
149
151
|
|
|
152
|
+
const buyModalProps = useBuyModalProps();
|
|
150
153
|
const {
|
|
151
154
|
chainId,
|
|
152
155
|
collectionAddress,
|
|
@@ -154,7 +157,8 @@ export const usePaymentModalParams = (args: usePaymentModalParams) => {
|
|
|
154
157
|
orderId,
|
|
155
158
|
customCreditCardProviderCallback,
|
|
156
159
|
skipNativeBalanceCheck,
|
|
157
|
-
} =
|
|
160
|
+
} = buyModalProps;
|
|
161
|
+
|
|
158
162
|
const config = useConfig();
|
|
159
163
|
const fee = useFees({
|
|
160
164
|
chainId,
|
|
@@ -172,7 +176,7 @@ export const usePaymentModalParams = (args: usePaymentModalParams) => {
|
|
|
172
176
|
!!quantity;
|
|
173
177
|
|
|
174
178
|
return useQuery({
|
|
175
|
-
queryKey: ['buyCollectableParams',
|
|
179
|
+
queryKey: ['buyCollectableParams', buyModalProps, args, fee],
|
|
176
180
|
queryFn: enabled
|
|
177
181
|
? () =>
|
|
178
182
|
getBuyCollectableParams({
|
|
@@ -2,7 +2,6 @@ import type { Observable } from '@legendapp/state';
|
|
|
2
2
|
import { type Address, type Hex, formatUnits } from 'viem';
|
|
3
3
|
import type { OrderbookKind, Price } from '../../../../../types';
|
|
4
4
|
import {
|
|
5
|
-
ExecuteType,
|
|
6
5
|
type Step,
|
|
7
6
|
StepType,
|
|
8
7
|
type TransactionSteps,
|
|
@@ -249,7 +248,8 @@ export const useTransactionSteps = ({
|
|
|
249
248
|
|
|
250
249
|
const result = await marketplaceClient.execute({
|
|
251
250
|
signature: signature as string,
|
|
252
|
-
|
|
251
|
+
method: signatureStep.post?.method as string,
|
|
252
|
+
endpoint: signatureStep.post?.endpoint as string,
|
|
253
253
|
body: signatureStep.post?.body,
|
|
254
254
|
});
|
|
255
255
|
|
|
@@ -118,7 +118,7 @@ const Modal = observer(() => {
|
|
|
118
118
|
tokenId: collectibleId,
|
|
119
119
|
chainId,
|
|
120
120
|
collectionAddress,
|
|
121
|
-
|
|
121
|
+
filter: {
|
|
122
122
|
currencies: [offerPrice.currency.contractAddress],
|
|
123
123
|
},
|
|
124
124
|
});
|
|
@@ -256,13 +256,13 @@ const Modal = observer(() => {
|
|
|
256
256
|
onBuyNow={() => {
|
|
257
257
|
makeOfferModal$.close();
|
|
258
258
|
|
|
259
|
-
if (lowestListing
|
|
259
|
+
if (lowestListing) {
|
|
260
260
|
buyModal.show({
|
|
261
261
|
chainId,
|
|
262
262
|
collectionAddress,
|
|
263
263
|
collectibleId,
|
|
264
|
-
orderId: lowestListing.
|
|
265
|
-
marketplace: lowestListing.
|
|
264
|
+
orderId: lowestListing.orderId,
|
|
265
|
+
marketplace: lowestListing.marketplace,
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
}}
|
|
@@ -2,7 +2,6 @@ import type { Observable } from '@legendapp/state';
|
|
|
2
2
|
import { type Address, type Hex, formatUnits } from 'viem';
|
|
3
3
|
import { OrderbookKind, type Price } from '../../../../../types';
|
|
4
4
|
import {
|
|
5
|
-
ExecuteType,
|
|
6
5
|
type Step,
|
|
7
6
|
StepType,
|
|
8
7
|
type TransactionSteps,
|
|
@@ -242,7 +241,8 @@ export const useTransactionSteps = ({
|
|
|
242
241
|
|
|
243
242
|
const result = await marketplaceClient.execute({
|
|
244
243
|
signature: signature as string,
|
|
245
|
-
|
|
244
|
+
method: signatureStep.post?.method as string,
|
|
245
|
+
endpoint: signatureStep.post?.endpoint as string,
|
|
246
246
|
body: signatureStep.post?.body,
|
|
247
247
|
});
|
|
248
248
|
|
|
@@ -2,7 +2,6 @@ import type { Observable } from '@legendapp/state';
|
|
|
2
2
|
import { formatUnits } from 'viem';
|
|
3
3
|
import type { Address, Hex } from 'viem';
|
|
4
4
|
import {
|
|
5
|
-
ExecuteType,
|
|
6
5
|
type MarketplaceKind,
|
|
7
6
|
type Step,
|
|
8
7
|
StepType,
|
|
@@ -246,7 +245,8 @@ export const useTransactionSteps = ({
|
|
|
246
245
|
|
|
247
246
|
const result = await marketplaceClient.execute({
|
|
248
247
|
signature: signature as string,
|
|
249
|
-
|
|
248
|
+
method: signatureStep.post?.method as string,
|
|
249
|
+
endpoint: signatureStep.post?.endpoint as string,
|
|
250
250
|
body: signatureStep.post?.body,
|
|
251
251
|
});
|
|
252
252
|
|
|
@@ -77,11 +77,7 @@ export const ActionModal = observer(
|
|
|
77
77
|
disableAnimation={disableAnimation}
|
|
78
78
|
>
|
|
79
79
|
<div className="relative flex grow flex-col items-center gap-4 p-6">
|
|
80
|
-
<Text
|
|
81
|
-
className="w-full text-center font-body text-large"
|
|
82
|
-
fontWeight="bold"
|
|
83
|
-
color="text100"
|
|
84
|
-
>
|
|
80
|
+
<Text className="w-full text-center font-body font-bold text-large text-text-100">
|
|
85
81
|
{title}
|
|
86
82
|
</Text>
|
|
87
83
|
|