Skip to content

Export the private key of the active chain's wallet - #350

Merged
joalavedra merged 1 commit into
mainfrom
clean/export-key-active-chain
Sep 17, 2026
Merged

joalavedra merged 1 commit into
mainfrom
clean/export-key-active-chain

Conversation

@joalavedra

Copy link
Copy Markdown
Collaborator

Replaces #345, rebuilt on current main with the secret-scanner failure fixed. Same change, same author; #345's single commit could not be made to pass gitleaks without rewriting it, since CI scans the whole BASE_SHA..HEAD range and the finding is in that commit.

What

The modal's "Export key" page calls useEthereumEmbeddedWallet() unconditionally. On a Solana project that hook resolves no matching account, so captureActiveAccountIdentity hands assertActiveEmbeddedAccount an EVM identity while embeddedWallet.get() returns the live SVM account. The assertion throws WalletNotConnectedError and the page renders it as "You cannot export the private key for this wallet." — for every Solana user, always. The call never reaches the SDK.

Export itself is chain-agnostic: openfort-js's exportPrivateKey is signer.export() through the iframe, and useSolanaEmbeddedWallet already exposes the same action, returning the base58 secret key.

Change

  • ExportKey selects the hook for the configured chainType, the way LoadWallets, Recover and SignMessage already do.
  • The smart-account explanation ("this is your owner/signer key, not the account") is scoped to Ethereum. Solana accounts are keypairs and have no ownerAddress, so the copy never applied there.
  • A failed export reports the error's own shortMessage and keeps the blanket sentence as the fallback. Every failure previously rendered identically, including transient ones like a wallet that is still reconnecting.
  • The exported-key fixture is a repeated character rather than a realistic base58 string. gitleaks read the original as a live credential (generic-api-key, entropy 4.99), and AGENTS.md asks fixtures to use obviously fake values. The allowlist was the wrong place for it: that list is for values published by design, and the test only checks that the page renders whatever the hook returns.

Tests

src/__tests__/pages/ExportKey.test.tsx — four cases: exports through the Solana hook on a Solana project (and never touches the Ethereum one), the same for Ethereum, the owner-key copy appears only for an Ethereum smart account, and a failure surfaces its own reason.

Per AGENTS.md, verified against this branch: restoring const wallet = ethereumWallet fails the two Solana-path cases. pnpm check, pnpm check:types, pnpm test:unit (889) and pnpm scan:secrets pass locally.

Not verified

Not exercised in a real browser against a live embedded signer. The chain routing and error reporting are covered at the page level; a devnet export through <OpenfortButton /> on a Solana project is worth doing before release.

Reported by a Solana devnet integrator alongside #341 and #342.

🤖 Generated with Claude Code

The export-key page read useEthereumEmbeddedWallet unconditionally, so on a
Solana project it resolved no matching account and every export failed the
active-account assertion. The page now selects the hook for the configured
chain, and the owner-key explanation is scoped to Ethereum smart accounts,
which are the only accounts that have one.

A failed export also rendered one blanket sentence whatever went wrong. It now
reports the error's own short message and keeps the blanket sentence as the
fallback.

The exported-key fixture is a repeated character rather than a realistic base58
string, which the secret scanner reads as a live credential.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
playground Ready Ready Preview Sep 17, 2026 11:15am UTC

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@openfort/react@350

commit: 290df5a

@joalavedra
joalavedra merged commit 1e05d32 into main Sep 17, 2026
21 of 22 checks passed
@joalavedra
joalavedra deleted the clean/export-key-active-chain branch September 17, 2026 11:29
@github-actions github-actions Bot mentioned this pull request Sep 17, 2026

This branch was successfully deployed

1 active deployment
Preview — 290df5a0 Deployed Sep 17, 2026 by vercel[bot]
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.

2 participants