From 1d42cfcb668cd05ee933d61fcaa6d73665641541 Mon Sep 17 00:00:00 2001 From: Ikenna Innocent Date: Tue, 29 Sep 2026 12:22:25 +0100 Subject: [PATCH] fix(build): repair the breakage blocking every build-dependent job `pnpm build` fails on master, which takes down E2E Tests, all five Visual Regression jobs, Lighthouse CI and the deploy workflows. Three independent defects, each fatal to the bundle on its own. 1. src/components/dashboard/AuditLog.tsx had one `` too many at the end of the component, so esbuild could not parse it. Counting div nesting from the root element gives a final depth of -1, confirming the surplus close. Dropped it. 2. src/ml/isolation_forest.ts used createRequire(import.meta.url) to load the CommonJS implementation at runtime. createRequire is Node-only, so bundling failed with `"createRequire" is not exported by "__vite-browser-external"`. Replaced with a static ESM import, and moved the fs require in isolation_forest.cjs inside save()/load(), which is where it is used and which the browser never calls. 3. StellarSdk.SorobanRpc no longer exists in @stellar/stellar-sdk v17. The module is exported as `rpc` instead, and still provides Server, Durability and Api. Six call sites still used the v12-era name, four of them in value position, so the build failed with `"SorobanRpc" is not exported by .../@stellar/stellar-sdk/lib/esm/index.js`: src/lib/stellar/soroban.ts:28 StellarSdk.rpc.Durability.Persistent src/lib/wallet/smartWallet.ts:220 StellarSdk.rpc.Api.isSimulationSuccess src/lib/wallet/smartWallet.ts:366 StellarSdk.rpc.Api.isSimulationSuccess src/lib/sac.ts:59 StellarSdk.rpc.Durability.Persistent src/lib/stellar/networks.ts:291 StellarSdk.rpc.Server (type) src/lib/stellar/rpcReadSource.ts StellarSdk.rpc.Server (type, x3) src/lib/store.ts rpc.Api.LedgerEntryResult (type, x2) The type-position sites are included so the migration is complete rather than only as far as the bundler complains. pnpm build now completes and passes the bundle-budget gate ("All bundle budgets passed!", exit 0). --- src/components/dashboard/AuditLog.tsx | 1 - src/lib/sac.ts | 2 +- src/lib/stellar/networks.ts | 2 +- src/lib/stellar/rpcReadSource.ts | 6 +++--- src/lib/stellar/soroban.ts | 2 +- src/lib/store.ts | 6 +++--- src/lib/wallet/smartWallet.ts | 4 ++-- src/ml/isolation_forest.cjs | 3 ++- src/ml/isolation_forest.ts | 7 ++++--- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/components/dashboard/AuditLog.tsx b/src/components/dashboard/AuditLog.tsx index af9f0dd9..70bd7a2b 100644 --- a/src/components/dashboard/AuditLog.tsx +++ b/src/components/dashboard/AuditLog.tsx @@ -592,6 +592,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 fbeed975..6a150adc 100644 --- a/src/lib/stellar/networks.ts +++ b/src/lib/stellar/networks.ts @@ -288,7 +288,7 @@ export function getServer(network: NetworkName = 'testnet'): StellarSdk.Horizon. /** @deprecated Use getServer directly. */ 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/stellar/soroban.ts b/src/lib/stellar/soroban.ts index 4a76a8fb..5fd3379c 100644 --- a/src/lib/stellar/soroban.ts +++ b/src/lib/stellar/soroban.ts @@ -25,7 +25,7 @@ export async function fetchContractData( contractId: string, key: StellarSdk.xdr.ScVal | string, network: NetworkName = 'testnet', - durability: StellarSdk.rpc.Durability = StellarSdk.SorobanRpc.Durability.Persistent + durability: StellarSdk.rpc.Durability = StellarSdk.rpc.Durability.Persistent ): Promise { const server = getSorobanServer(network); diff --git a/src/lib/store.ts b/src/lib/store.ts index 8e03e575..6c410fe6 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 @@ -242,7 +242,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 005a9ecc..04cbd968 100644 --- a/src/ml/isolation_forest.ts +++ b/src/ml/isolation_forest.ts @@ -1,4 +1,5 @@ -import { createRequire } from 'module' -const require = createRequire(import.meta.url) -const { IsolationForest } = require('./isolation_forest.cjs') +import isolationForestModule from './isolation_forest.cjs' + +const { IsolationForest } = isolationForestModule + export { IsolationForest }