generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat(keyring-eth-cash): add cash account keyring based on hd-key-ring #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jwhiles
wants to merge
12
commits into
main
Choose a base branch
from
create-cash-account-keyring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
01e9b64
feat: add cash account keyring based on hd-key-ring
Jwhiles 77eaae7
chore: add comments explaining origin of deriation path
Jwhiles fe2949a
chore: various small non-functional tweaks based on PR feedback
Jwhiles 3de607b
feat: only allow a single account to be added to cash keyring
Jwhiles 8fb69f7
chore: update keyring-api changelog
Jwhiles 8ebb609
feat: limit options that can be passed to deserialize in cash keyring
Jwhiles 5df4e9b
chore: rename new keyring package to simply cash
Jwhiles b26b341
chore: change version of eth-cash to 0.0.0
Jwhiles 980df04
fix: only allow one account to be added
Jwhiles edd76fb
chore: remove un-needed tests
Jwhiles 702efff
chore: fix pr tag
Jwhiles 25e4b24
chore: export the derivation path
Jwhiles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: accounts/.github/workflows/validate-pr-title.yml Lines 44 to 54 in 3c3001b
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)'], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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_hdreferences an undefined Mermaid nodekeyring_eth_hd. The correct variable name iseth_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-keyringnode, causing the dependency graph to render incorrectly.