Skip to content

Commit 4a7d035

Browse files
authored
feat: add MoneyKeyring keyring V2 wrapper (#554)
Added a v2 wrapper for the `MoneyKeyring`. Since the underlying keyring is an `HDKeyring`, this wrapper is just converting the underlying accounts to `KeyringAccount`. Note: `deleteAccount` was added to satisfy the v2 interface but is a no-op since deletion of Money accounts is not supported. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches account exposure and signing request handling for money accounts, but follows the same EthKeyringWrapper pattern as other ETH keyrings with extensive new tests. > > **Overview** > Adds a **v2 `MoneyKeyring` adapter** for `@metamask/eth-money-keyring` that wraps the existing legacy keyring behind the unified `Keyring` API (`@metamask/keyring-sdk/v2`’s `EthKeyringWrapper`). > > Consumers can import it via the new **`@metamask/eth-money-keyring/v2`** export (plus a Browserify `v2.js` shim). The wrapper maps the inner HD-backed money keyring to **`KeyringAccount`** objects: EOA scope, mnemonic entropy metadata on `MONEY_DERIVATION_PATH`, and a **fixed signing method set** (personal sign, typed data v1–v4, EIP-7702 authorization). Account lifecycle is **strictly single-account**: `getAccounts`/`createAccounts` only allow index `0`, reject other BIP-44 creation types and entropy mismatches, and **`deleteAccount` is intentionally a no-op** to satisfy the v2 interface without removing money accounts. Package metadata, changelog, README dependency graph, and **`@metamask/keyring-sdk`** dependency are updated accordingly; broad Jest coverage exercises account shape, creation guards, serialize/deserialize, and signing requests. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8761382. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent f6e4d2e commit 4a7d035

8 files changed

Lines changed: 795 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ linkStyle default opacity:0.5
7575
eth_ledger_bridge_keyring --> keyring_utils;
7676
eth_money_keyring --> keyring_eth_hd;
7777
eth_money_keyring --> keyring_api;
78+
eth_money_keyring --> keyring_sdk;
7879
eth_money_keyring --> keyring_utils;
7980
eth_qr_keyring --> keyring_api;
8081
eth_qr_keyring --> keyring_sdk;

packages/keyring-eth-money/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `MoneyKeyring` v2 wrapper ([#554](https://github.com/MetaMask/accounts/pull/554))
13+
1014
### Changed
1115

1216
- **BREAKING:** Remove `signTransaction` pass-through; Money accounts do not sign transactions ([#521](https://github.com/MetaMask/accounts/pull/521))

packages/keyring-eth-money/package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"url": "https://github.com/MetaMask/accounts.git"
1717
},
1818
"files": [
19-
"dist/"
19+
"dist/",
20+
"v2.js"
2021
],
2122
"sideEffects": false,
2223
"main": "./dist/index.cjs",
@@ -32,6 +33,16 @@
3233
"default": "./dist/index.cjs"
3334
}
3435
},
36+
"./v2": {
37+
"import": {
38+
"types": "./dist/v2/index.d.mts",
39+
"default": "./dist/v2/index.mjs"
40+
},
41+
"require": {
42+
"types": "./dist/v2/index.d.cts",
43+
"default": "./dist/v2/index.cjs"
44+
}
45+
},
3546
"./package.json": "./package.json"
3647
},
3748
"publishConfig": {
@@ -57,6 +68,7 @@
5768
"dependencies": {
5869
"@metamask/eth-hd-keyring": "^14.1.1",
5970
"@metamask/keyring-api": "^23.1.0",
71+
"@metamask/keyring-sdk": "^2.1.1",
6072
"@metamask/keyring-utils": "^3.3.1",
6173
"@metamask/superstruct": "^3.1.0",
6274
"async-mutex": "^0.5.0"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { MoneyKeyring } from './money-keyring';
2+
export { MONEY_DERIVATION_PATH } from '../money-keyring';

0 commit comments

Comments
 (0)