Skip to content

feat(mobile): add counterfactual address preview component - #547

Closed
iredis wants to merge 2 commits into
Miracle656:mainfrom
iredis:fix/449-counterfactual-address-preview
Closed

feat(mobile): add counterfactual address preview component#547
iredis wants to merge 2 commits into
Miracle656:mainfrom
iredis:fix/449-counterfactual-address-preview

Conversation

@iredis

@iredis iredis commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds a Counterfactual Address Preview component that derives and displays the wallet's predicted contract address before the deploy transaction is submitted. It uses the SDK's deriveCounterfactualAddress to compute the deterministic contract address from the user's P-256 public key, letting onboarding show a real, fundable address immediately.

Also adds a shared network configuration module for the mobile app (ported from the web wallet's lib/network.ts, using EXPO_PUBLIC_* env vars).

Related Issue

Closes #449

Changes

📦 New Files

  • [ADD] frontend/mobile/components/CounterfactualAddressPreview.tsx — React Native component that derives and displays the predicted C… address pre-deploy. Shows deriving/ready/error states, the computed address, and the public key hex for verification.
  • [ADD] frontend/mobile/lib/network.ts — Shared network configuration (testnet/mainnet) with Horizon/RPC URLs, factory contract ID, and friendbot support, using EXPO_PUBLIC_* environment variables.

Verification

Acceptance Criteria Status
Onboarding shows the predicted C… address pre-deploy ✅ Component derives address via deriveCounterfactualAddress from the SDK
Counterfactual address matches deployed address ✅ Uses same computeWalletAddress algorithm as the SDK — deterministic derivation
Derivation handles error states gracefully ✅ Displayed when public key or config is invalid

iredis added 2 commits July 28, 2026 19:10
…k config

Creates CounterfactualAddressPreview component that derives and displays
the wallet's predicted contract address pre-deployment using the SDK's
counterfactual computation. Also adds the shared network configuration
needed by mobile screens.

Closes Miracle656#449
@iredis
iredis requested a review from Miracle656 as a code owner July 28, 2026 18:24
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

@iredis is attempting to deploy a commit to the miracle656's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@iredis 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! 🚀

Learn more about application limits

@Miracle656

Copy link
Copy Markdown
Owner

Thanks — the component itself is well shaped, with a proper deriving / ready / error state union rather than loose booleans. Closing it though, because it can't bundle on a device yet and nothing renders it.

It won't resolve at runtime

import { deriveCounterfactualAddress } from 'invisible-wallet-sdk';

invisible-wallet-sdk isn't a dependency of frontend/mobile:

  • it's absent from frontend/mobile/package.json
  • the root package.json declares "workspaces": ["sdk", "packages/*"]frontend/mobile is not a member, so the root hoist doesn't reach it
  • frontend/mobile/metro.config.js sets resolver.alias for @/… but no watchFolders or nodeModulesPaths pointing at the repo root

npx tsc --noEmit passes, which is misleading — TypeScript walks up the directory tree and finds the SDK in the repo-root node_modules. Metro doesn't do that. On a device this would fail to bundle with an unresolved module.

Wiring the SDK into the mobile package is its own piece of work, and #594 (feat(mobile): wire SDK and port WalletProvider with secure session persistence) is scoped to exactly it. This should build on that rather than reaching across the boundary.

Nothing mounts it

CounterfactualAddressPreview isn't imported anywhere under app/. #449's acceptance is "onboarding shows the predicted C… address pre-deploy; it matches the deployed address" — so the component existing isn't enough on its own; it needs to be rendered in the onboarding flow with a real P-256 public key, and ideally the second half checked by comparing the prediction against the address the deploy actually produces.

lib/network.ts

This branch added its own 61-line version, but #526 landed a 205-line one on main with the runtime testnet/mainnet override, subscription and hydration, so I took main's. One thing yours had that main's doesn't is getNativeAssetContractId(). There's currently only one caller computing that inline (lib/sweepContractBalance.ts:69, from its networkPassphrase parameter), so it isn't needed yet — but it's a reasonable addition to lib/network.ts if you want to open a small PR for it.

Suggested path

Once #594 lands, this becomes straightforward: add the import against the wired SDK, take factoryAddress and networkPassphrase from lib/network.ts rather than props, and render it in the create-wallet flow right after the passkey produces a public key. Happy to review that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

21. Counterfactual address preview

2 participants