Skip to content

Commit 4d5d75a

Browse files
committed
fix(build): correct address types in hook and strategy
1 parent 03fb6f1 commit 4d5d75a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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,

0 commit comments

Comments
 (0)