Skip to content

chore: migrate solana-wallet-snap history into merged-packages - #57

Closed
Battambang wants to merge 509 commits into
mainfrom
migrate-solana-wallet-snap
Closed

chore: migrate solana-wallet-snap history into merged-packages#57
Battambang wants to merge 509 commits into
mainfrom
migrate-solana-wallet-snap

Conversation

@Battambang

@Battambang Battambang commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Phase B: Staging from merged-packages/: import @metamask/solana-wallet-snap git history into merged-packages/solana-wallet-snap/ via git filter-repo.
  • Source: MetaMask/snap-solana-wallet main @ eb5d13a (#628), rewritten to merged-packages/solana-wallet-snap/.
  • No squash on merge - merge commit is used (imported history). No branch rebasing.

Scope

This PR is history import only. Follow-ups PRs will continue to update any config files not aligned to this monorepo. ie: changelog reset, strip monorepo-replaced files, config/deps/README alignment...

Notes

  • Phase A PR#4 (final source release) was skipped due to already recent release; published baseline remains 3.0.0. Unreleased source work (#627/#628) is included in the imported history.
  • packages/site/ and other non-snap paths were dropped by filter-repo.

Check

  • Confirm merged-packages/solana-wallet-snap/ is present and looks complete (src/, package.json, locales, scripts).
  • Confirm no secret .env was imported (.env.sample only).
  • Confirm merge into main uses a merge commit (not squash/rebase).

aganglada and others added 30 commits April 30, 2025 15:51
This is the release candidate for version 1.25.1.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
Add missing time range "All" to the historical prices the snap returns.
Price API does not support something like `timePeriod=all`, so we use
`1000Y` in the same fashion as in the extension code to fetch EVM
prices.


![image](https://github.com/user-attachments/assets/8750d885-1ed3-4811-bd96-98d6d1bc0aad)
Provide a skeleton width as a workaround for a couple of issues with the
default state of the component.
Integrates `AssetSelector` from `snaps-sdk`
Removes `tokenMetadata` from `context` which was very large

<img width="403" alt="Screenshot 2025-05-08 at 10 11 57"
src="https://github.com/user-attachments/assets/a6127046-8e0b-48df-94e4-7eab6602dfea"
/>

<img width="403" alt="Screenshot 2025-05-07 at 15 17 25"
src="https://github.com/user-attachments/assets/60662f3f-d331-4e4d-ad7f-0bf19595342a"
/>
This is the release candidate for version 1.26.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
This is the release candidate for version 1.26.1.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
This is the release candidate for version 1.27.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
test: add test case for problematic Swap maps
fix: adjust fee handling for fee payer in transaction parsing
chore: simplify fee calculation logic using fixed base fee
chore: disable Devnet on the production environment
Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
This is the release candidate for version 1.28.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
Simplify the code by:
- including unit in variable names to prevent confusion
- applying absolute value at the right time, allowing us to...
  - remove conditional logic
  - and use immutable variables
The keyring API is strict, and we were using a `SolanaKeyringAccount`
(which has additional fields compared to a `KeyringAccount`), making
this assert to fail:
-
https://github.com/MetaMask/accounts/blob/v47.0.0/packages/keyring-snap-client/src/KeyringClient.ts#L108-L114

So, the fix for now is just to re-create a stricter `KeyringAccount` and
use it in both `return`s.
* Fixes send form not triggering the can pick up amount update
* Fixes not showing a warning when simulation fails from blockaid
This is the release candidate for version 1.28.1.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
This is the release candidate for version 1.28.2.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
This is the release candidate for version 1.28.3.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
This is the release candidate for version 1.29.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
- Re-implement `AssetsService.getAccountBalances` in order to only fetch
balances for the requested caip asset types. Before, we were calling
`getTokenAccountsByOwner` which was returning ALL account's assets, even
those not requested, and we were filtering them out afterward, which was
not optimal.
- Cache calls to `fetchMint` (equivalent to `getAccountInfo` for the
mint) for 1 hour
- Adapt some mocks so that they use valid addresses (required for
deriving the ATA PDA)
- Clean up unused method `AssetsService.#updateNativeTokenBalances`
- Rename field `SolanaAsset.address` > `SolanaAsset.assetType` because
it was misleading.
…#365)

* Replaces `refreshTransaction`and `refreshAssets` with
`refreshAccounts` which does both by checking on account signatures per
address.
Brunonascdev and others added 22 commits March 20, 2026 13:43
This is the release candidate for version 2.7.4.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Implementing the new `keyring_createAccounts` that's used to batch
account creations (for sequential indices).

This can be enabled in the clients using the `SolAccountProviderConfig`
like so:
```diff
diff --git a/app/scripts/controller-init/multichain/multichain-account-service-init.ts b/app/scripts/controller-init/multichain/multichain-account-service-init.ts
index 4caa3ad15c..a0bf9d9860 100644
--- a/app/scripts/controller-init/multichain/multichain-account-service-init.ts
+++ b/app/scripts/controller-init/multichain/multichain-account-service-init.ts
@@ -49,7 +49,13 @@ export const MultichainAccountServiceInit: ControllerInitFunction<
   const controller = new MultichainAccountService({
     messenger: controllerMessenger,
     providerConfigs: {
-      [SOL_ACCOUNT_PROVIDER_NAME]: snapAccountProviderConfig,
+      [SOL_ACCOUNT_PROVIDER_NAME]: {
+        ...snapAccountProviderConfig,
+        createAccounts: {
+          ...snapAccountProviderConfig.createAccounts,
+          batched: true, // Solana can handle batched requests, so we enable it here.
+        },
+      },
       [BTC_ACCOUNT_PROVIDER_NAME]: snapAccountProviderConfig,
       [TRX_ACCOUNT_PROVIDER_NAME]: snapAccountProviderConfig,
     },
```

And can be tested using this PR:
- MetaMask/metamask-extension#41149

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Adds new batched account-creation flow and new atomic state update
helper, touching key derivation and persisted account state; mistakes
could create wrong keys, overwrite state, or break client expectations.
> 
> **Overview**
> Adds support for `keyring_createAccounts` to batch-create Solana
accounts for a specific BIP-44 index or an index range, returning
existing accounts when already present and minimizing snap API calls by
deriving from a cached `m/44'/501'` coin-type node.
> 
> Introduces `IStateManager.setKeyWith` (implemented in `State` and
`InMemoryState` with tests) to perform atomic read-modify-write updates,
and uses it to flush newly created accounts to `keyringAccounts` in a
single state write.
> 
> Updates permissions to allow `KeyringRpcMethod.CreateAccounts`,
refactors account-building/address decoding reuse, adds derivation tests
for `deriveSolanaKeypairFromCoinTypeNode`, and bumps keyring
dependencies (`@metamask/keyring-api` to `22.0.0`,
`@metamask/keyring-snap-sdk` to `8.0.0`) plus manifest shasum.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
974aa06dd2567700fb663aedd5db7560f39a031f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 2.8.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: gantunesr <17601467+gantunesr@users.noreply.github.com>
… signing (#611)

Related to: https://consensyssoftware.atlassian.net/browse/MUL-1903

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Introduces silent cryptographic signing gated to the MetaMask origin,
but misuse or permission misconfiguration could allow signing ownership
proofs without user approval.
> 
> **Overview**
> Adds a new **`signProofOfOwnership`** client RPC that signs
`metamask:proof-of-ownership:{nonce}:{address}` messages **without a
user prompt**, returning an ed25519 signature for profile-metrics-style
wallet ownership proofs.
> 
> The handler follows the same pattern as rewards/card signing: validate
request params, load the account by ID, parse the message (nonce split
on the **last** `:` so opaque nonces can contain colons), and **reject**
if the embedded address does not match the signing account. The
plaintext message is UTF-8–encoded to base64 before
`WalletService.signMessage`.
> 
> **`signProofOfOwnership` is allowed only for the `metamask` origin**
(not general dapp permissions). Changelog, manifest shasum, and unit
tests for parsing, handler behavior, and permissions are included.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
618095dd40e17a47b3c46b583cb94838662d1c79. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 2.9.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
Bumps the pinned Yarn version to 4.17.0 to satisfy the minimum Yarn
4.16.0 requirement introduced by [MetaMask/action-npm-publish
v6](https://github.com/MetaMask/action-npm-publish/blob/main/CHANGELOG.md#600).
v6's publish script hard-fails on any Yarn below 4.16.0, so this is a
prerequisite before that action can be upgraded (tracked separately
under me/update-action-npm-publish).
Fixes `handleSignProofOfOwnership` so that it returns hex signatures
instead of base58
This is the release candidate for version 2.9.1.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
Reverting Release PR commit as `action-npm-publish` needs to be bumped
to v6 in order to work.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Metadata-only revert with no wallet or signing logic changes; main
risk is release/process confusion if 2.9.1 was already published
externally.
> 
> **Overview**
> Reverts the **2.9.1** release commit so the repo is back on **2.9.0**
until npm publish automation is fixed (bump to `action-npm-publish` v6).
> 
> Version fields are set back to `2.9.0` in the root `package.json`,
`packages/snap/package.json`, and `snap.manifest.json`, and the manifest
**source shasum** is updated to match the reverted bundle. The changelog
drops the `## [2.9.1]` release section and keeps the
`signProofOfOwnership` hex-encoding fix under **`[Unreleased]`**, with
compare links pointed at `v2.9.0` again.
> 
> There are **no application/runtime code changes** in this diff—only
release versioning and changelog/manifest metadata.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
31adab02dbe8078e687e6ffd212dc7fc2407da6e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 2.9.1.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
Added suppressed error tracking for non-blocking failure paths by wiring
trackError into the affected send/confirmation flows and instruction
parsing fallback, without changing the user-facing fallback behavior.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Observability-only changes in existing catch/fallback paths; user
flows and return values stay the same, with user rejections excluded
from tracking.
> 
> **Overview**
> Adds centralized **`trackError`** that reports failures to MetaMask
via `snap_trackError` (with safe fallback if tracking itself fails), and
wires it into paths that already **swallow** errors—NFT metadata,
analytics, transaction scan/mapping/fetch, subscriptions, cron refresh
handlers, send/confirmation UI fallbacks, instruction parsing, keyring
address resolution, and related services.
> 
> **`withCatchAndThrowSnapError`** now calls `trackError` before
rethrowing, but **skips** `UserRejectedRequestError`. Invalid response
validation attaches the struct cause via `getJsonError`. User-visible
fallback behavior (null returns, empty arrays, failure stages) is
unchanged; the manifest **shasum** is updated for the rebuilt bundle.
> 
> Tests assert `trackError` is invoked across these failure paths.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a1190cc83f8c190ca335f2a6cc892c991a5e0662. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 2.10.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Andrew Taran <andrew.taran@consensys.net>
## Summary

Migrates the Solana snap to the v2 Keyring API and declares the
corresponding capabilities in the manifest. Also removes all v1-only
keyring methods and fixes a latent test-isolation bug surfaced while
validating the migration.

- Rewrites `SolanaKeyring` to implement `KeyringSnapRpc` (from
`@metamask/keyring-api/v2`): adds `getAccounts`, `getAccount` (throws on
missing IDs instead of returning `undefined`), and `exportAccount`
(base58 only); renames `listAccountAssets` / `listAccountTransactions` →
`getAccountAssets` / `getAccountTransactions`
- Removes v1-only flows (`createAccount`, `listAccounts`,
`discoverAccounts`, `updateAccount`, `filterAccountChains`) and stops
emitting `AccountCreated` / `AccountDeleted` events
- Folds `bip44:discover` into `createAccounts` via on-chain activity
checks
- Wraps all public keyring method errors in a single `SnapError`
- Switches `handleKeyringRequest` to the v2 dispatcher
(`@metamask/keyring-snap-sdk/v2`)
- Adds `endowment:keyring.capabilities` to `snap.manifest.json`
- Bumps `@metamask/snaps-sdk` → 11.1.1, `snaps-cli` → 8.4.1,
`snaps-jest` → 10.1.3, `keyring-snap-sdk` → 9.1.0, and updates the root
`resolutions` to match; `snaps-utils` resolves to 12.2.0 which is
required to validate the new manifest field
- Sets `moduleResolution: "bundler"` in `packages/snap/tsconfig.json` so
v2 subpath types resolve correctly
- Fixes a flaky `jest --runInBand` failure: replaces an incomplete
`jest.mock('@noble/ed25519', ...)` in `index.test.ts` with
`jest.mock('./polyfills', ...)`. The previous mock was captured by the
ed25519 polyfill's closure when it patched `globalThis.crypto.subtle`,
leaking into other test files via shared global state under
`--runInBand`


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Touches account creation/deletion, private key export, and keyring RPC
contracts—security-sensitive paths with breaking behavior changes for v1
callers and clients that relied on keyring events or `getAccount`
returning undefined.
> 
> **Overview**
> Migrates the Solana wallet snap from the v1 keyring protocol to
**Keyring API v2**, with dependency bumps and manifest updates so
MetaMask can drive account lifecycle through the new RPC surface.
> 
> **`SolanaKeyring`** now implements `KeyringSnapRpc` instead of v1
`Keyring`. Entry point uses `handleKeyringRequest` from
`@metamask/keyring-snap-sdk/v2`. **Added:** `getAccounts`,
`exportAccount` (base58 64-byte secret key), and `bip44:discover` inside
`createAccounts` via on-chain activity. **Renamed:** `listAccountAssets`
/ `listAccountTransactions` → `getAccountAssets` /
`getAccountTransactions`. **Removed:** `createAccount`, `listAccounts`,
`discoverAccounts`, `updateAccount`, `filterAccountChains`, and
`AccountCreated` / `AccountDeleted` events; `deleteAccount` only clears
snap state. **`getAccount`** now throws when the id is missing (no
`undefined`). Public keyring errors are wrapped in a single
**`SnapError`**.
> 
> **`snap.manifest.json`** adds `endowment:keyring.capabilities`
(scopes, `privateKey` export, `bip44` derive/discover) and bumps
**`platformVersion`** to 11.1.1. **`permissions.ts`** allows v2
`KeyringSnapRpcMethod`s plus a subset of v1 method names for
compatibility.
> 
> Tooling: `@metamask/keyring-api` ^23.5.0, `keyring-snap-sdk` ^9.2.0,
`snaps-sdk` ^11.1.1; root **`resolutions`** and **`.yarnrc.yml`**
preapproved packages for fresh MetaMask releases; snap **`tsconfig`**
uses `moduleResolution: "bundler"`.
> 
> Tests: keyring suite aligned to v2 APIs and `exportAccount`;
**`index.test.ts`** mocks `./polyfills` instead of `@noble/ed25519` to
avoid flaky `globalThis.crypto.subtle` leakage under `jest --runInBand`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
754dc8677f81277057309da7f1977daaa53c1d61. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 2.11.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Frederic HENG <frederic.heng@consensys.net>
Reverts MetaMask/snap-solana-wallet#629

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Metadata-only version and changelog rollback with no runtime code
changes in the diff.
> 
> **Overview**
> Reverts the **2.11.0** release tagging from #629 by restoring package
and Snap versions to **2.10.0** in the monorepo root,
`packages/snap/package.json`, and `snap.manifest.json`.
> 
> Updates the manifest **source shasum** to match the bundle at the
reverted version. In `CHANGELOG.md`, removes the `## [2.11.0]` section
so the keyring V2 notes remain under **`[Unreleased]`** instead of a
shipped release.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e9dedce62b10e8d01dbbf969bb41b0179ccbc537. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This is the release candidate for version 3.0.0.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Frederic HENG <frederic.heng@consensys.net>
Upgrade Yarn, TypeScript, and ESLint to match internal-snaps, add oxfmt,
and migrate to a flat ESLint config so the Solana snap is ready for
monorepo migration. Keep ahead snaps-cli and snaps-jest pins; soften
noisy pre-existing lint rules for this upgrade.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are confined to dev tooling, formatting, and manifest checksum
drift from locale output; no intentional changes to snap wallet or
keyring runtime behavior.
> 
> **Overview**
> Aligns the Solana wallet snap monorepo with **internal-snaps** by
upgrading the lint/format stack and refreshing dependencies.
> 
> **ESLint 9** replaces the legacy `.eslintrc.js` tree with a root
**`eslint.config.mjs`** using `@metamask/eslint-config` v15 (flat
config, `import-x`, per-package overrides for snap/site/tests). A shared
**`preexistingPatternRules`** block turns off rules that became noisy
under the upgrade so behavior stays stable until a follow-up cleanup.
> 
> **oxfmt** takes over repo-wide formatting via `lint:misc` (with
`.oxfmtrc.json`); root **`prettier:check` / `prettier:fix`** are removed
and **lint-staged** now runs `yarn lint:fix` only. Package-level lint
scripts drop `--ext` and delegate ESLint/oxfmt through the workspace
root.
> 
> **TypeScript ~5.8.3**, **Jest 30** (snap), **@types/jest** ^30, and
assorted MetaMask dev deps are bumped; **Yarn** is pinned to **4.17.1**.
The diff is largely mechanical—import splits, JSDoc blank lines, removal
of file-level eslint disables—and **`populate-locale.js`** now writes a
trailing newline to **`locales/en.json`**, which updates
**`snap.manifest.json`** shasum.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
97046227f6063ccb69cd19046c9b969aa318ef1c. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Switch to MIT (matching internal-snaps), add package LICENSE, and align
keywords, publish files, and Node engine with sample-snap conventions.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Metadata, licensing, and publish layout only; the breaking Node engine
bump may affect consumers still on Node 18.
> 
> **Overview**
> Aligns **`packages/snap`** with the monorepo snap template
(internal-snaps / sample-snap): packaging and metadata only, no snap
runtime changes.
> 
> **License:** Replaces dual **`(MIT-0 OR Apache-2.0)`** with **`MIT`**
and adds a root **`LICENSE`** file in the package.
> 
> **`package.json`:** Adds **`keywords`** (`MetaMask`, `Solana`);
publishes the full **`images/`** directory instead of only
**`images/icon.svg`**; raises **`engines.node`** from **`>=18.6.0`** to
**`>=20`** (called out as **BREAKING** in the changelog).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7a2bf1c6c182ab5085757d30577ba442f31b2c1a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@Battambang
Battambang marked this pull request as ready for review July 28, 2026 13:24
@Battambang
Battambang requested review from a team as code owners July 28, 2026 13:24
@Battambang Battambang closed this Jul 28, 2026
@Battambang
Battambang deleted the migrate-solana-wallet-snap branch July 28, 2026 17:29
@Battambang

Copy link
Copy Markdown
Contributor Author

Recreate one based on a latest release cut from Solana source repo.

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.