Skip to content

Commit 31d892d

Browse files
fix: resolve frontend TypeScript build errors
1 parent b806d80 commit 31d892d

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

frontend/src/lib/contract/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export interface Market {
2-
id: u64;
2+
id: number;
33
creator: string;
44
title: string;
55
description: string;
6-
end_time: u64;
6+
end_time: number;
77
outcomes: string[];
88
resolved: boolean;
99
}

frontend/src/lib/env.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export const STELLAR_NETWORK = {
44
rpcUrl: "https://soroban-testnet.stellar.org",
55
};
66

7+
// Access environment variable safely at runtime
78
// NEXT_PUBLIC_ variables are injected at build time by Next.js
8-
const getContractId = () => {
9-
// @ts-expect-error - process.env is injected by Next.js
10-
return typeof process !== "undefined" ? process.env.NEXT_PUBLIC_CONTRACT_ID : "";
11-
};
12-
13-
export const CONTRACT_ID = getContractId() || "";
9+
export const CONTRACT_ID = (() => {
10+
if (typeof globalThis === "undefined") return "";
11+
const env = (globalThis as any).process?.env;
12+
return env?.NEXT_PUBLIC_CONTRACT_ID || "";
13+
})();

frontend/src/lib/wallet/freighter.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ export type FreighterConnection = {
55
};
66

77
export async function isFreighterInstalled(): Promise<boolean> {
8-
return await FreighterApi.isConnected();
8+
try {
9+
return await FreighterApi.isAllowed();
10+
} catch {
11+
return false;
12+
}
913
}
1014

1115
export async function connectFreighter(): Promise<FreighterConnection | null> {
1216
try {
1317
const installed = await isFreighterInstalled();
1418
if (!installed) {
15-
throw new Error("Freighter wallet is not installed");
19+
throw new Error("Freighter wallet is not installed or not allowed");
1620
}
1721

1822
const publicKey = await FreighterApi.getPublicKey();
@@ -36,10 +40,10 @@ export async function signTransaction(
3640
transactionXdr: string
3741
): Promise<string | null> {
3842
try {
39-
const signedXdr = await FreighterApi.signTransaction(transactionXdr, {
40-
network: "TESTNET",
43+
const signedTxXdr = await FreighterApi.signTransaction(transactionXdr, {
44+
networkPassphrase: "Test SDF Network ; September 2015",
4145
});
42-
return signedXdr;
46+
return signedTxXdr;
4347
} catch (error) {
4448
console.error("Transaction signing error:", error);
4549
return null;

0 commit comments

Comments
 (0)