From 6776e3d568db7450112fcf6a97d13c396cc01621 Mon Sep 17 00:00:00 2001 From: ghzhost Date: Thu, 3 Sep 2026 02:28:25 +0000 Subject: [PATCH 1/2] fix(wallet): reuse getNetworkPassphrase from lib/stellar.ts in signTransaction (#48) --- src/context/WalletContext.test.tsx | 32 ++++++++++++++++++++++++++++++ src/context/WalletContext.tsx | 6 ++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/context/WalletContext.test.tsx b/src/context/WalletContext.test.tsx index 5086977..8d75416 100644 --- a/src/context/WalletContext.test.tsx +++ b/src/context/WalletContext.test.tsx @@ -20,6 +20,7 @@ const apiMocks = vi.hoisted(() => ({ vi.mock('@/lib/api', () => apiMocks) import { WalletProvider, useWalletContext, WALLET_POLL_INTERVAL_MS } from './WalletContext' +import { getNetworkPassphrase } from '@/lib/stellar' const PUBLIC_KEY_A = 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5' const PUBLIC_KEY_B = 'GDRREYWHQWJDICNH4SAH4TT2JPVYWIX6JEWAHE2W6BZDJBIJ4VSX227Z' @@ -155,3 +156,34 @@ describe('Freighter account-drift polling', () => { expect(result.current.wallet.publicKey).toBe(PUBLIC_KEY_A) }, WALLET_POLL_INTERVAL_MS + 5_000) }) + +describe('signTransaction', () => { + it('calls Freighter signTransaction with SDK getNetworkPassphrase for testnet and mainnet', async () => { + const { result } = await connectWallet(PUBLIC_KEY_A) + freighterMocks.signTransaction.mockResolvedValue('signed-xdr-output') + + // Test on testnet + let signed = await act(async () => { + return await result.current.signTransaction('dummy-xdr-testnet') + }) + expect(signed).toBe('signed-xdr-output') + expect(freighterMocks.signTransaction).toHaveBeenCalledWith('dummy-xdr-testnet', { + networkPassphrase: getNetworkPassphrase('testnet'), + accountToSign: PUBLIC_KEY_A, + }) + + // Switch to mainnet + act(() => { + result.current.setNetwork('mainnet') + }) + + signed = await act(async () => { + return await result.current.signTransaction('dummy-xdr-mainnet') + }) + expect(signed).toBe('signed-xdr-output') + expect(freighterMocks.signTransaction).toHaveBeenCalledWith('dummy-xdr-mainnet', { + networkPassphrase: getNetworkPassphrase('mainnet'), + accountToSign: PUBLIC_KEY_A, + }) + }) +}) diff --git a/src/context/WalletContext.tsx b/src/context/WalletContext.tsx index bfb9473..90258aa 100644 --- a/src/context/WalletContext.tsx +++ b/src/context/WalletContext.tsx @@ -17,6 +17,7 @@ import { import type { Network, WalletState, AccountInfo } from '@/types' import { DEFAULT_SETTINGS } from '@/types' import { fetchAccountFromHorizon } from '@/lib/api' +import { getNetworkPassphrase } from '@/lib/stellar' // Freighter's own popup lets the user switch accounts entirely outside this // app. Poll for that drift on an interval distinct from (and shorter than) @@ -246,10 +247,7 @@ export function WalletProvider({ children }: { children: React.ReactNode }) { // Dynamic import to avoid SSR issues const { signTransaction: freighterSign } = await import('@stellar/freighter-api') - const networkPassphrase = - wallet.network === 'testnet' - ? 'Test SDF Network ; September 2015' - : 'Public Global Stellar Network ; September 2015' + const networkPassphrase = getNetworkPassphrase(wallet.network) const result = await freighterSign(xdr, { networkPassphrase, From 92ba01f1fa11257cd72cf8fb213504afc5d23c16 Mon Sep 17 00:00:00 2001 From: ghzhost Date: Thu, 3 Sep 2026 03:37:40 +0000 Subject: [PATCH 2/2] ci: run vitest test suite in CI (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repository ships vitest.config.ts, src/test/setup.ts, and 15+ test files, plus vitest / @testing-library/react / jsdom in devDependencies and a 'test: vitest run' script in package.json — but the CI workflow never invoked npm test, so the suite silently bit-rotted with no signal. Add a dedicated 'test' job to ci.yml that runs npm ci && npm test on every push and pull_request, parallel to the existing 'build' job. Fixes #1 --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6936044..2f2e7df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,3 +8,10 @@ jobs: - uses: actions/setup-node@v4 with: {node-version: 20} - run: npm ci && npm run build + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: {node-version: 20} + - run: npm ci && npm test