-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sayfer MM Snap Edits - Throw an error when the account private key isn't found instead of silently failing - Removed `getWallet` function from snapWallet.ts as well as it's associated tests and mocks - Re arranged imports in api.ts - Added documentation for snap - Renamed jest.config.snap.js to jest.config.js so we don't have to explicitly pass in the config path to jest command * Adjusted snap manifest * MM Snap Coin Type Update - Revert change making coin type 60 instead of 118. MM snaps do not allow you to access coin type 118 as of now. * Added changeset * Reverted package.json version bump * Improved documentation
- Loading branch information
1 parent
48ae725
commit 127ad0d
Showing
11 changed files
with
87 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'@sei-js/metamask-snap': patch | ||
--- | ||
|
||
Fixes a silent return if the account private key is not found, adds documentation, removes unused getWallet function from @sei-js/metamask-snap all as fixes to code audit. |
This file contains 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 |
---|---|---|
@@ -1,3 +1,65 @@ | ||
## Sei Metamask Snap | ||
# Sei Metamask Snap | ||
|
||
This snap is under active development and is not yet ready for use until this packages has been properly audited by a third party. | ||
This documentation describes the functions and RPC request handler used in a MetaMask Snap to handle cryptocurrency transactions and account management using BIP44 standards. | ||
|
||
### `onRpcRequest` | ||
|
||
An RPC request handler that processes different request methods including `signDirect`, `signAmino`, and `getPrivateKey`. It handles the signing of transactions both in Amino and Direct mode, and also retrieves the private key. | ||
|
||
- **Syntax**: `onRpcRequest({ request }): Promise<TransactionSignature | PrivateKey>` | ||
- **Parameters**: | ||
- `request`: An object representing the RPC request. | ||
- **Returns**: A Promise that resolves to a `TransactionSignature` or `PrivateKey`. | ||
|
||
## RPC Methods | ||
|
||
### `signDirect` | ||
|
||
Signs a transaction in Direct mode. | ||
|
||
- **Parameters**: | ||
- `account_index`: The bip44 coin type 118 account index to use for signing. | ||
- `signerAddress`: The address of the signer. | ||
- `signDoc`: The document to be signed. | ||
- **Error Handling**: Throws an error if the private key is not available or if the user denies the transaction. | ||
|
||
### `signAmino` | ||
|
||
Signs a transaction in Amino mode. | ||
|
||
- **Parameters**: | ||
- `account_index`: The bip44 coin type 118 account index to use for signing. | ||
- `signerAddress`: The address of the signer. | ||
- `signDoc`: The document to be signed. | ||
- `enableExtraEntropy`: Boolean flag for extra entropy. | ||
- `isADR36`: Boolean flag for ADR-36 compliance. | ||
- **Error Handling**: Throws an error if the private key is not available or if the user denies the transaction. | ||
|
||
|
||
### `getPrivateKey` | ||
|
||
Retrieves the private key for a specified account index using MetaMask's `snap_getBip44Entropy` method and BIP44 standards and coin type 118. | ||
|
||
- **Syntax**: `getPrivateKey(account_index: number = 0): Promise<PrivateKey>` | ||
- **Parameters**: | ||
- `account_index` (number, optional): The index of the account, defaulting to 0. | ||
- **Returns**: A Promise resolving to a `PrivateKey`. | ||
|
||
|
||
## Local development and testing | ||
|
||
### Setup | ||
Run `yarn` to install dependencies. | ||
|
||
### Running the snap locally | ||
In order to run the snap locally simply run `yarn start` and the snap will be served at `localhost:8080`. | ||
|
||
### Testing the snap | ||
|
||
#### Test UI | ||
This package has a helpful UI for testing all the exposed functions. | ||
|
||
`cd` into the `./test-ui` directory and run `yarn` to install dependencies. Then run `yarn dev` to start the test UI. The test UI will be served at `localhost:3000`. Please checkout the README.md in that directory to learn how to set the snap ID. | ||
|
||
#### Unit tests | ||
Run `yarn test` to run the unit tests. |
File renamed without changes.
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
export const ACCOUNT_ONE_PRIVATE_KEY = '0x0ca350a5d50a08caf95d0922d3adf4117a1ea5b7c24b7c6021173c8d46eceb37'; | ||
export const ACCOUNT_ONE_PUBLIC_KEY = | ||
'0x0405794d2d33a8a8c7e21caa891a9cb5b4539fb4c2fb50e46b326b322474ce719763ca0a0c869a87640289ebe4a2c008822059bbf7564129bafe51676abc53b921'; | ||
export const ACCOUNT_ONE_ADDRESS = 'sei15u8zs9pqdjddgv8pkyyh6zvsg4ujs2y6s6cq6u'; | ||
export const ACCOUNT_ONE_PUBKEY_BYTES = new Uint8Array([ | ||
3, 5, 121, 77, 45, 51, 168, 168, 199, 226, 28, 170, 137, 26, 156, 181, 180, 83, 159, 180, 194, 251, 80, 228, 107, 50, 107, 50, 36, 116, 206, 113, 151 | ||
]); | ||
|
This file contains 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 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 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 |
---|---|---|
|
@@ -6405,7 +6405,7 @@ [email protected]: | |
|
||
babel-jest@^29.7.0: | ||
version "29.7.0" | ||
resolved "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" | ||
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" | ||
integrity sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg== | ||
dependencies: | ||
"@jest/transform" "^29.7.0" | ||
|