Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/validate-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
deps-dev
keyring-api
keyring-eth-hd
keyring-eth-cash
keyring-eth-ledger-bridge
keyring-eth-simple
keyring-eth-trezor
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This repository contains the following packages [^fn1]:
<!-- start package list -->

- [`@metamask/account-api`](packages/account-api)
- [`@metamask/eth-cash-keyring`](packages/keyring-eth-cash)
- [`@metamask/eth-hd-keyring`](packages/keyring-eth-hd)
- [`@metamask/eth-ledger-bridge-keyring`](packages/keyring-eth-ledger-bridge)
- [`@metamask/eth-qr-keyring`](packages/keyring-eth-qr)
Expand Down Expand Up @@ -40,6 +41,7 @@ linkStyle default opacity:0.5
account_api(["@metamask/account-api"]);
hw_wallet_sdk(["@metamask/hw-wallet-sdk"]);
keyring_api(["@metamask/keyring-api"]);
eth_cash_keyring(["@metamask/eth-cash-keyring"]);
eth_hd_keyring(["@metamask/eth-hd-keyring"]);
eth_ledger_bridge_keyring(["@metamask/eth-ledger-bridge-keyring"]);
eth_qr_keyring(["@metamask/eth-qr-keyring"]);
Expand All @@ -54,6 +56,7 @@ linkStyle default opacity:0.5
account_api --> keyring_api;
account_api --> keyring_utils;
keyring_api --> keyring_utils;
eth_cash_keyring --> keyring_eth_hd;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mermaid diagram references wrong node variable name

Medium Severity

The new dependency edge eth_cash_keyring --> keyring_eth_hd references an undefined Mermaid node keyring_eth_hd. The correct variable name is eth_hd_keyring, as defined on line 45 and used consistently on lines 60–62. Mermaid will auto-create a separate orphan node instead of linking to the actual @metamask/eth-hd-keyring node, causing the dependency graph to render incorrectly.

Fix in Cursor Fix in Web

eth_hd_keyring --> keyring_api;
eth_hd_keyring --> keyring_utils;
eth_hd_keyring --> account_api;
Expand Down
1 change: 1 addition & 0 deletions packages/keyring-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add `KeyringType.Cash` variant ([#472](https://github.com/MetaMask/accounts/pull/472))
- Add optional `details` field to `Transaction` type ([#445](https://github.com/MetaMask/accounts/pull/445))
- Add `SecurityAlertResponse` enum with values: `benign`, `warning`, `malicious`
- Add optional `origin` field (string) to track transaction request source
Expand Down
5 changes: 5 additions & 0 deletions packages/keyring-api/src/api/v2/keyring-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ export enum KeyringType {
* Represents keyring backed by a OneKey hardware wallet.
*/
OneKey = 'onekey',

/**
* Represents keyring for cash accounts.
*/
Cash = 'cash',
}
1 change: 1 addition & 0 deletions packages/keyring-api/src/api/v2/keyring.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { ImportPrivateKeyFormat } from './private-key';

// Test KeyringType enum
expectAssignable<KeyringType>(KeyringType.Hd);
expectAssignable<KeyringType>(KeyringType.Cash);
expectAssignable<KeyringType>(KeyringType.PrivateKey);
expectAssignable<KeyringType>(KeyringType.Qr);
expectAssignable<KeyringType>(KeyringType.Snap);
Expand Down
17 changes: 17 additions & 0 deletions packages/keyring-eth-cash/CHANGELOG.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a new entry in this workflow file, so we can use it as a scope for PR titles?

See:

keyring-api
keyring-eth-hd
keyring-eth-ledger-bridge
keyring-eth-simple
keyring-eth-trezor
keyring-internal-api
keyring-internal-snap-client
keyring-snap-bridge
keyring-snap-client
keyring-snap-sdk
keyring-utils

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add initial implementation of `CashKeyring` ([#472](https://github.com/MetaMask/accounts/pull/472))
- Extends `HdKeyring` from `@metamask/eth-hd-keyring`.
- Uses keyring type `"Cash Keyring"`.
- Uses derivation path `"m/44'/4392018'/0'/0"`.

[Unreleased]: https://github.com/MetaMask/accounts/
15 changes: 15 additions & 0 deletions packages/keyring-eth-cash/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2020 MetaMask

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
38 changes: 38 additions & 0 deletions packages/keyring-eth-cash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Cash Keyring

An Ethereum keyring that extends [`@metamask/eth-hd-keyring`](../keyring-eth-hd) with a distinct keyring type and derivation path for cash accounts.

Cash accounts use a separate HD derivation path to keep funds isolated from the primary HD keyring, while reusing the same seed phrase and signing infrastructure.

## Installation

`yarn add @metamask/eth-cash-keyring`

or

`npm install @metamask/eth-cash-keyring`

## Usage

```ts
import { CashKeyring } from '@metamask/eth-cash-keyring';

const keyring = new CashKeyring();
```

The `CashKeyring` class implements the same `Keyring` interface as `HdKeyring` — see the [HD Keyring README](../keyring-eth-hd/README.md) for full API documentation.

## Contributing

### Setup

- Install [Node.js](https://nodejs.org) version 18
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.
- Install [Yarn v4](https://yarnpkg.com/getting-started/install)
- Run `yarn install` to install dependencies and run any required post-install scripts

### Testing and Linting

Run `yarn test` to run the tests once.

Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and fix any automatically fixable issues.
19 changes: 19 additions & 0 deletions packages/keyring-eth-cash/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

const merge = require('deepmerge');
const path = require('path');

const baseConfig = require('../../jest.config.packages');

const displayName = path.basename(__dirname);

module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// The glob patterns Jest uses to detect test files
testMatch: ['**/*.test.[jt]s?(x)'],
});
71 changes: 71 additions & 0 deletions packages/keyring-eth-cash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "@metamask/eth-cash-keyring",
"version": "0.0.0",
"description": "A cash account keyring that extends the HD keyring with a different keyring type and derivation path.",
"keywords": [
"ethereum",
"keyring"
],
"homepage": "https://github.com/MetaMask/accounts#readme",
"bugs": {
"url": "https://github.com/MetaMask/accounts/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/accounts.git"
},
"license": "ISC",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"files": [
"dist/"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --no-references",
"build:clean": "yarn build --clean",
"build:docs": "typedoc",
"changelog:update": "../../scripts/update-changelog.sh @metamask/eth-cash-keyring",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/eth-cash-keyring",
"publish:preview": "yarn npm publish --tag preview",
"test": "jest",
"test:clean": "jest --clearCache"
},
"dependencies": {
"@metamask/eth-hd-keyring": "workspace:^"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/utils": "^11.1.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^29.5.12",
"deepmerge": "^4.2.2",
"jest": "^29.5.0"
},
"engines": {
"node": "^18.18 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false
}
}
}
Loading
Loading