Skip to content

Commit fcdb0be

Browse files
authored
Merge pull request #440 from hypercerts-org/fix/count_after_filter
Fix/count after filter
2 parents 554f1b8 + 4d5d75a commit fcdb0be

File tree

8 files changed

+443
-491
lines changed

8 files changed

+443
-491
lines changed

hypercerts/getAllHypercerts.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,16 @@ filteredIds.add(
147147
"42220-0x16bA53B74c234C870c61EFC04cD418B8f2865959-27222589353675077077069968594541456916480",
148148
);
149149
filteredIds.add(
150-
"10-0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07-16604758658641034201622290718847993414418432 ",
150+
"10-0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07-16604758658641034201622290718847993414418432",
151+
);
152+
filteredIds.add(
153+
"314-0xc756B203cA9e13BAB3a93F1dA756bb19ac3C395b-2041694201525630780780247644590609268736",
154+
);
155+
filteredIds.add(
156+
"314-0xc756B203cA9e13BAB3a93F1dA756bb19ac3C395b-2381976568446569244243622252022377480192",
157+
);
158+
filteredIds.add(
159+
"314-0xc756B203cA9e13BAB3a93F1dA756bb19ac3C395b-680564733841876926926749214863536422912",
151160
);
152161

153162
export async function getAllHypercerts({
@@ -183,10 +192,12 @@ export async function getAllHypercerts({
183192
[],
184193
);
185194

186-
const totalCount = Math.max(
187-
0,
188-
(res.hypercerts.count ?? 0) - filteredIds.size,
189-
);
195+
const difference = res.hypercerts?.count
196+
? res.hypercerts?.count - data.length
197+
: 0;
198+
const totalCount = res.hypercerts?.count
199+
? res.hypercerts?.count - difference
200+
: 0;
190201

191202
return {
192203
count: totalCount,

lib/sign-api-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { type SignTypedDataParameters } from "viem";
1+
import { Address, type SignTypedDataParameters } from "viem";
22
import { signTypedData } from "@wagmi/core";
33

44
import { config as wagmiConfig } from "@/configs/wagmi";
55
import { hypercertApiSigningDomain } from "@/configs/constants";
66

77
export async function signMessage(
8-
signerAddress: `0x${string}`,
8+
signerAddress: Address,
99
chainId: number,
1010
config: Pick<SignTypedDataParameters, "types" | "primaryType" | "message">,
1111
): Promise<`0x${string}`> {

marketplace/BuyFractionalStrategy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import type { AppRouterInstance } from "next/dist/shared/lib/app-router-context.
1010
import { useStepProcessDialogContext } from "@/components/global/step-process-dialog";
1111

1212
import { MarketplaceOrder } from "./types";
13+
import { Address } from "viem";
1314

1415
export abstract class BuyFractionalStrategy {
1516
constructor(
16-
protected address: `0x${string}`,
17+
protected address: Address,
1718
protected chainId: number,
1819
protected exchangeClient: HypercertExchangeClient,
1920
protected dialogContext: ReturnType<typeof useStepProcessDialogContext>,

marketplace/useBuyFractionalStrategy.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useStepProcessDialogContext } from "@/components/global/step-process-di
88
import { BuyFractionalStrategy } from "./BuyFractionalStrategy";
99
import { EOABuyFractionalStrategy } from "./EOABuyFractionalStrategy";
1010
import { SafeBuyFractionalStrategy } from "./SafeBuyFractionalStrategy";
11+
import { Address, getAddress, isAddress } from "viem";
1112

1213
export const useBuyFractionalStrategy = (): (() => BuyFractionalStrategy) => {
1314
const { address, chainId } = useAccount();
@@ -20,17 +21,20 @@ export const useBuyFractionalStrategy = (): (() => BuyFractionalStrategy) => {
2021
const activeAddress = selectedAccount?.address || address;
2122

2223
return () => {
23-
if (!activeAddress) throw new Error("No address found");
24+
if (!activeAddress || !isAddress(activeAddress))
25+
throw new Error("No address found");
2426
if (!chainId) throw new Error("No chainId found");
2527
if (!exchangeClient) throw new Error("No HypercertExchangeClient found");
2628
if (!walletClient) throw new Error("No walletClient found");
2729
if (!dialogContext) throw new Error("No dialogContext found");
2830
if (!router) throw new Error("No router found");
2931

32+
const buyerAddress = getAddress(activeAddress);
33+
3034
if (selectedAccount?.type === "safe") {
3135
if (!selectedAccount) throw new Error("No selected account found");
3236
return new SafeBuyFractionalStrategy(
33-
activeAddress,
37+
buyerAddress,
3438
chainId,
3539
exchangeClient,
3640
dialogContext,
@@ -40,7 +44,7 @@ export const useBuyFractionalStrategy = (): (() => BuyFractionalStrategy) => {
4044
}
4145

4246
return new EOABuyFractionalStrategy(
43-
activeAddress,
47+
buyerAddress,
4448
chainId,
4549
exchangeClient,
4650
dialogContext,

package.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@
2121
"@hypercerts-org/sdk": "2.5.0-beta.6",
2222
"@next/env": "^14.2.10",
2323
"@openzeppelin/merkle-tree": "^1.0.6",
24-
"@radix-ui/react-accordion": "^1.1.2",
25-
"@radix-ui/react-alert-dialog": "^1.1.1",
26-
"@radix-ui/react-avatar": "^1.0.4",
27-
"@radix-ui/react-checkbox": "^1.0.4",
28-
"@radix-ui/react-collapsible": "^1.0.3",
29-
"@radix-ui/react-dialog": "^1.1.1",
30-
"@radix-ui/react-dropdown-menu": "^2.0.6",
31-
"@radix-ui/react-label": "^2.0.2",
32-
"@radix-ui/react-menubar": "^1.0.4",
33-
"@radix-ui/react-popover": "^1.0.7",
34-
"@radix-ui/react-progress": "^1.0.3",
35-
"@radix-ui/react-scroll-area": "^1.0.5",
36-
"@radix-ui/react-select": "^2.1.1",
37-
"@radix-ui/react-separator": "^1.0.3",
38-
"@radix-ui/react-slot": "^1.1.0",
39-
"@radix-ui/react-toast": "^1.1.5",
40-
"@radix-ui/react-tooltip": "^1.0.7",
41-
"@safe-global/api-kit": "^2.5.6",
42-
"@safe-global/protocol-kit": "^5.1.1",
43-
"@safe-global/types-kit": "^1.0.1",
44-
"@tanstack/query-core": "^5.32.0",
45-
"@tanstack/react-query": "^5.32.0",
24+
"@radix-ui/react-accordion": "^1.2.3",
25+
"@radix-ui/react-alert-dialog": "^1.1.6",
26+
"@radix-ui/react-avatar": "^1.1.3",
27+
"@radix-ui/react-checkbox": "^1.1.4",
28+
"@radix-ui/react-collapsible": "^1.1.3",
29+
"@radix-ui/react-dialog": "^1.1.6",
30+
"@radix-ui/react-dropdown-menu": "^2.1.6",
31+
"@radix-ui/react-label": "^2.1.2",
32+
"@radix-ui/react-menubar": "^1.1.6",
33+
"@radix-ui/react-popover": "^1.1.6",
34+
"@radix-ui/react-progress": "^1.1.2",
35+
"@radix-ui/react-scroll-area": "^1.2.3",
36+
"@radix-ui/react-select": "^2.1.6",
37+
"@radix-ui/react-separator": "^1.1.2",
38+
"@radix-ui/react-slot": "^1.1.2",
39+
"@radix-ui/react-toast": "^1.2.6",
40+
"@radix-ui/react-tooltip": "^1.1.8",
41+
"@safe-global/api-kit": "^2.5.9",
42+
"@safe-global/protocol-kit": "^5.2.2",
43+
"@safe-global/types-kit": "^1.0.2",
44+
"@tanstack/query-core": "^5.66.0",
45+
"@tanstack/react-query": "^5.66.0",
4646
"@tanstack/react-query-devtools": "4",
4747
"@tanstack/react-table": "^8.17.3",
48-
"@types/lodash": "^4.17.5",
48+
"@types/lodash": "^4.17.15",
4949
"@types/validator": "^13.12.2",
5050
"@uiw/react-md-editor": "^4.0.5",
51-
"@vercel/analytics": "^1.4.1",
51+
"@vercel/analytics": "^1.5.0",
5252
"@vercel/flags": "^3.1.0",
53-
"@wagmi/core": "^2.16.3",
54-
"@yaireo/tagify": "^4.21.1",
53+
"@wagmi/core": "^2.16.4",
54+
"@yaireo/tagify": "^4.33.2",
5555
"class-variance-authority": "^0.7.0",
5656
"clsx": "^2.1.1",
5757
"cmdk": "^1.0.0",
@@ -71,16 +71,16 @@
7171
"react-markdown": "^9.0.3",
7272
"react-use": "^17.5.1",
7373
"rehype-sanitize": "^6.0.0",
74-
"remeda": "^2.0.3",
74+
"remeda": "^2.20.1",
7575
"server-only": "^0.0.1",
7676
"sharp": "^0.33.5",
7777
"tailwind-merge": "^2.3.0",
7878
"tailwindcss-animate": "^1.0.7",
7979
"use-debounce": "^10.0.4",
8080
"validator": "^13.12.0",
8181
"vaul": "^0.9.0",
82-
"viem": "^2.22.9",
83-
"wagmi": "^2.14.8",
82+
"viem": "^2.23.0",
83+
"wagmi": "^2.14.11",
8484
"zod": "^3.23.4",
8585
"zustand": "^4.5.2"
8686
},

0 commit comments

Comments
 (0)