Repository navigation
fix #144 contract integrity, #143 spec diff, #142 sdk check, and #141 watch-only mode - #195
Merged
Marvell69 merged 2 commits intoOct 21, 2026
Conversation
…leDesk#142 sdk check, and OracleDesk#141 watch-only mode
|
@Owolabenjade Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Alosnireda is attempting to deploy a commit to the Marvel's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #144, Closes #143, Closes #142, Closes #141
Summary & Motivation
This PR delivers comprehensive solutions for four core contract integration, developer tooling, and portfolio usability issues:
Issue Detect at runtime when deployed contracts don't match the bundled bindings #144 (Runtime Contract Integrity Detection):
lib/stellar/generated/*.ts) and deployed bytecode on-chain.NEXT_PUBLIC_*_CONTRACT_IDto forked or outdated contract deployments.contractspecv0sections from WASM bytecode at runtime via custom ULEB-128 parsing, computes canonical SHA-256 spec fingerprints, verifies SAC contracts, and gates write transactions before submission.IntegrityBanneralerting operators with Stellar Expert explorer links and error summaries.Issue Report contract interface changes when the contracts submodule moves #143 (Contract Interface Diff & Error Coverage):
contracts/submodule is updated.scripts/spec-diff.mjs) comparing local generated bindings againstorigin/develop, detecting additions, deletions, or signature modifications and scanning all frontend files for impacted call sites.lib/stellar/errors.ts.Issue Coordinate the upgrade to stellar-sdk 17 and a newer wallets kit #142 (Stellar SDK & Wallets Kit Multi-Dependency Guard):
@stellar/stellar-sdkand@creit.tech/stellar-wallets-kit.scripts/check-sdk-major.mjs) run in CI to verify that only a single major version of@stellar/stellar-sdkexists in the dependency tree.@trezor,ledger) from core frontend SDK alignment checks.Issue Watch-only mode to inspect any address's positions and history #141 (Watch-Only Mode for Addresses):
SignerAddress(allowed to sign transactions) fromViewedAddress(the subject of portfolio inspections).?watch=G...), manual input, or preset pills without requiring wallet connection.DataKey::Position(market_id, holder)) in chunks up to 200 keys per RPC request, drastically reducing latency compared to sequential contract simulations.useBuy,useSell,useRedeem,useUsdcTransfer) and copy-trade balance sizing to prevent unauthorized transaction preparation while inspecting third-party addresses.How the Flow Works Now
useContractIntegrity()fetches deployed contract bytecode usinggetLedgerEntries, parses Wasm custom sections to extract the spec, normalizes parameter structures, and compares the fingerprint with bundled client specs. If mismatch or archived status is detected, the UI displaysIntegrityBanner, anduseWriteGuardblocks transaction signing with a clearUserFacingError.npm run spec:diffinspects git diffs against the upstream branch and parses TypeScript AST declarations. If signatures drift or functions are removed, it prints a GitHub markdown report detailing affected call sites.errors-coverage.test.tsvalidates that every contract error code has an intuitive user message.npm run check:sdkparsespackage-lock.jsonpackages, validating that no duplicated or mismatched@stellar/stellar-sdkmajor versions are installed./portfolio, or load any page with?watch=G....useViewedAddressparses and validates the address checksum and stores it in session storage.ViewingBanner.tsx) displays the watched address and a one-click "Stop watching" control.fetchPositionsFor(viewedAddress)to chunk ledger lookups up to 200 keys per call.viewedAddress === signerAddress.Changed
lib/stellar/contract-check.ts: Custom Wasm section parser (ULEB-128 decoder), canonical spec normalizer, SHA-256 fingerprint generator, Stellar Asset Contract (SAC) validator, anduseContractIntegrityhook.components/layout/IntegrityBanner.tsx: Operator warning banner with explorer links and refresh action; mounted inapp/layout.tsx.lib/stellar/__tests__/contract-check.test.ts: 8 unit tests covering custom section extraction, fingerprinting, SAC verification, archived contracts, and error conditions.scripts/lib/files.mjsandscripts/lib/spec.mjs: AST extraction for Soroban bindings and reference scanner for frontend call sites.scripts/spec-diff.mjs: CLI diff reporter supporting git revisions with markdown table outputs.lib/stellar/errors.ts: Complete mapping of contract errors to user-friendly messages andUNFRIENDLY_ALLOWLISTvalidator.package.jsonscript"spec:diff"and integrated step into.github/workflows/ci.yml.scripts/__tests__/spec-diff.test.ts(8 tests) andlib/stellar/__tests__/errors-coverage.test.ts(1 test).lib/stellar/sdk-major.ts: Lockfile analyzer detecting split or duplicate SDK dependencies with hardware wallet path filtering.scripts/check-sdk-major.mjs: CLI script for CI validation.package.jsonscript"check:sdk"and integrated step into.github/workflows/ci.yml.lib/stellar/__tests__/sdk-major.test.ts: 4 unit tests covering single/multiple installations, major mismatches, and hardware wallet exclusions.lib/stellar/identity.ts: Branded typesSignerAddressandViewedAddresswith runtime StrKey validation.lib/stellar/write-guard.ts: Pure assertionassertCanWritepreventing write actions when in watch mode.lib/stellar/positions.ts: Batched persistent ledger entry queries forDataKey::Position(market_id, holder)chunked up to 200 keys/request.lib/hooks/useViewedAddress.tsx: React context syncing viewed address with URL search params (?watch=) and session storage.components/layout/ViewingBanner.tsx: Global status banner indicating watch mode.components/layout/WalletDropdown.tsx: Added "Stop watching" action when watch mode is active.app/portfolio/page.tsx: Added address watch form, quick picks, live position listing, and valuation for viewed address.app/portfolio/wallets/page.tsx: Display viewed identity and watched balances.components/market/buy-ticket.tsxandapp/markets/quick-view/page.tsx: Render viewed address positions and gate trade buttons.app/copy-trade/page.tsx: Bound copy-trade balance checks strictly to signer wallet USDC.lib/stellar/__tests__/identity.test.ts(7 tests),lib/hooks/__tests__/write-guard.test.ts(8 tests), andlib/stellar/__tests__/positions.test.ts(4 tests).docs/architecture.mdwith "Contract integrity check" and "Viewed address vs signer (Watch-only mode)" sections.docs/manual-test.mdwith complete manual verification protocol for Watch-Only mode.Testing
Ran the following verification test suites and build checks:
npm run check:sdk(passed: exit code 0)npm run spec:diff(passed: exit code 0)npx vitest run lib/stellar/__tests__/contract-check.test.ts scripts/__tests__/spec-diff.test.ts lib/stellar/__tests__/errors-coverage.test.ts lib/stellar/__tests__/sdk-major.test.ts lib/stellar/__tests__/identity.test.ts lib/stellar/__tests__/positions.test.ts lib/hooks/__tests__/write-guard.test.ts(passed: 7 files, 40 tests)npm run typecheck(passed: exit code 0, 0 errors)npx eslint lib/stellar/contract-check.ts lib/stellar/identity.ts lib/stellar/positions.ts lib/stellar/sdk-major.ts lib/stellar/write-guard.ts lib/hooks/useViewedAddress.tsx components/layout/IntegrityBanner.tsx components/layout/ViewingBanner.tsx scripts/spec-diff.mjs scripts/check-sdk-major.mjs(passed: 0 errors, 0 warnings)npm run build(passed: exit code 0, all 28 routes compiled and static pages generated successfully)Scope Notes
?watch=query or watched address is specified.@stellar/stellar-sdkpackages bundled within Ledger/Trezor hardware drivers are intentionally scoped and isolated from core SDK version validation.Push Command