diff --git a/src/components/dashboard/AuditLog.tsx b/src/components/dashboard/AuditLog.tsx index 6d0b6298..2fb0f42c 100644 --- a/src/components/dashboard/AuditLog.tsx +++ b/src/components/dashboard/AuditLog.tsx @@ -766,6 +766,5 @@ export default function AuditLog() { )} - ); } diff --git a/src/lib/sac.ts b/src/lib/sac.ts index 91a4d0eb..8ba0f25c 100644 --- a/src/lib/sac.ts +++ b/src/lib/sac.ts @@ -56,7 +56,7 @@ export async function inspectSac(asset: SacAsset, network: NetworkName): Promise await server.getContractData( contractId, StellarSdk.xdr.ScVal.scvLedgerKeyContractInstance(), - StellarSdk.SorobanRpc.Durability.Persistent, + StellarSdk.rpc.Durability.Persistent, ) return { contractId, deployed: true, metadata } } catch (error) { diff --git a/src/lib/stellar/networks.ts b/src/lib/stellar/networks.ts index 77715c3f..108108c5 100644 --- a/src/lib/stellar/networks.ts +++ b/src/lib/stellar/networks.ts @@ -227,7 +227,7 @@ export function getServer(network: NetworkName = 'testnet'): StellarSdk.Horizon. export const ee = getServer; -export function getSorobanServer(network: NetworkName = 'testnet'): StellarSdk.SorobanRpc.Server { +export function getSorobanServer(network: NetworkName = 'testnet'): StellarSdk.rpc.Server { const config = NETWORKS[network]; if (network === 'custom' && !config.sorobanUrl) { throw new Error('Custom Soroban RPC URL not configured'); diff --git a/src/lib/stellar/rpcReadSource.ts b/src/lib/stellar/rpcReadSource.ts index 6d9d6f45..0fe51a6a 100644 --- a/src/lib/stellar/rpcReadSource.ts +++ b/src/lib/stellar/rpcReadSource.ts @@ -36,19 +36,19 @@ export const RPC_RETENTION_LIMIT_LEDGERS = 100_000; export class RpcReadSource implements StellarReadSource { private network: NetworkName; private retentionLimit: number; - private serverGetter?: (_network: NetworkName) => StellarSdk.SorobanRpc.Server; + private serverGetter?: (_network: NetworkName) => StellarSdk.rpc.Server; constructor( network: NetworkName = 'testnet', retentionLimit: number = RPC_RETENTION_LIMIT_LEDGERS, - serverGetter?: (_network: NetworkName) => StellarSdk.SorobanRpc.Server + serverGetter?: (_network: NetworkName) => StellarSdk.rpc.Server ) { this.network = network; this.retentionLimit = retentionLimit; this.serverGetter = serverGetter; } - private getServer(): StellarSdk.SorobanRpc.Server { + private getServer(): StellarSdk.rpc.Server { if (this.serverGetter) { return this.serverGetter(this.network); } diff --git a/src/lib/store.ts b/src/lib/store.ts index becda15c..b888672f 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -2,7 +2,7 @@ import { create } from 'zustand' import { getStoredValue } from './storage' import { syncState, onStateChange, resolveStateConflict, loadSyncedState, getTabId } from '../utils/stateSync' import type { NetworkName, NetworkStats } from './stellar' -import type { Horizon, SorobanRpc } from '@stellar/stellar-sdk' +import type { Horizon, rpc } from '@stellar/stellar-sdk' import { generateInsights, type AnalyticsSummary } from './analytics' import { accountRequests } from './requestCancellation' import { applyCustomThemeToDOM, removeCustomThemeFromDOM, saveThemeVarsToStorage, clearThemeVarsFromStorage, type ThemeDefinition } from '../styles/themeTypes' @@ -93,7 +93,7 @@ export interface NetworkSlice { faucetLoading: boolean faucetResult: unknown contractId: string - contractData: SorobanRpc.Api.LedgerEntryResult | null + contractData: rpc.Api.LedgerEntryResult | null contractLoading: boolean contractError: string | null deploymentStatus: Record | null @@ -247,7 +247,7 @@ export interface StoreState extends NetworkSlice, SessionSlice, AccountSlice, Ui setFaucetResult: (r: unknown) => void setContractId: (id: string) => void - setContractData: (data: SorobanRpc.Api.LedgerEntryResult) => void + setContractData: (data: rpc.Api.LedgerEntryResult) => void setContractLoading: (v: boolean) => void setContractError: (e: string | null) => void diff --git a/src/lib/wallet/smartWallet.ts b/src/lib/wallet/smartWallet.ts index 4a4068ab..7ac43010 100644 --- a/src/lib/wallet/smartWallet.ts +++ b/src/lib/wallet/smartWallet.ts @@ -217,7 +217,7 @@ export async function fetchSacBalances( const simResponse = await server.simulateTransaction(tx) if ( - StellarSdk.SorobanRpc.Api.isSimulationSuccess(simResponse) && + StellarSdk.rpc.Api.isSimulationSuccess(simResponse) && simResponse.result?.retval ) { const retval = simResponse.result.retval @@ -363,7 +363,7 @@ export async function fetchSmartWalletAccount( const simResp = await server.simulateTransaction(tx) if ( - StellarSdk.SorobanRpc.Api.isSimulationSuccess(simResp) && + StellarSdk.rpc.Api.isSimulationSuccess(simResp) && simResp.result?.retval ) { const native = StellarSdk.scValToNative(simResp.result.retval) diff --git a/src/ml/isolation_forest.cjs b/src/ml/isolation_forest.cjs index b544d2a8..64545c8b 100644 --- a/src/ml/isolation_forest.cjs +++ b/src/ml/isolation_forest.cjs @@ -1,5 +1,4 @@ // Simple Isolation Forest implementation (approximate) -const fs = require('fs'); function c(n) { if (n <= 1) return 0; @@ -77,11 +76,13 @@ class IsolationForest { } save(path) { + const fs = require('fs'); fs.mkdirSync(require('path').dirname(path), { recursive: true }); fs.writeFileSync(path, JSON.stringify(this.toJSON())); } static load(path) { + const fs = require('fs'); const raw = fs.readFileSync(path, 'utf8'); const obj = JSON.parse(raw); const f = new IsolationForest(obj.nTrees, obj.sampleSize); diff --git a/src/ml/isolation_forest.ts b/src/ml/isolation_forest.ts index a81e0430..04cbd968 100644 --- a/src/ml/isolation_forest.ts +++ b/src/ml/isolation_forest.ts @@ -1,19 +1,5 @@ -// Browser-compatible shim — the real CJS module only runs in Node (training/server). -// In the browser bundle we export a no-op class so the import chain doesn't break. -let IsolationForest: any; +import isolationForestModule from './isolation_forest.cjs' -if (typeof window === 'undefined') { - // Node environment (training scripts, server-side) - // eslint-disable-next-line @typescript-eslint/no-var-requires - IsolationForest = require('./isolation_forest.cjs').IsolationForest; -} else { - IsolationForest = class { - fit() { return this; } - predict() { return []; } - score() { return 0; } - save() {} - static load() { return new IsolationForest(); } - }; -} +const { IsolationForest } = isolationForestModule -export { IsolationForest }; +export { IsolationForest }