Skip to content

Commit

Permalink
Upgrade snap by adding home page and dialog boxes (#609)
Browse files Browse the repository at this point in the history
Signed-off-by: Himalayan Dev <[email protected]>
  • Loading branch information
himalayan-dev authored Sep 9, 2024
1 parent f9612e8 commit 2b56276
Show file tree
Hide file tree
Showing 48 changed files with 1,654 additions and 715 deletions.
9 changes: 8 additions & 1 deletion packages/hedera-wallet-snap/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ module.exports = {
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/naming-convention': 'off',
'import/order': 'off',
// This allows importing the `Text` JSX component.
'@typescript-eslint/no-shadow': [
'error',
{
allow: ['Text'],
},
],
},
},

{
files: ['**/*.test.ts', '**/*.test.js'],
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.test.js'],
extends: ['@metamask/eslint-config-jest'],
rules: {
'@typescript-eslint/no-shadow': [
Expand Down
2 changes: 1 addition & 1 deletion packages/hedera-wallet-snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-wallet-snap-monorepo",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"description": "Hedera Wallet Snap unlocks wallet functionality via Metamask that any other apps can interact with, thereby turning Metamask into a native Hedera wallet without relying on Hedera JSON-RPC Relay.",
"homepage": "https://github.com/hashgraph/hedera-metamask-snaps#readme",
Expand Down
28 changes: 14 additions & 14 deletions packages/hedera-wallet-snap/packages/site/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-wallet-snap-site",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"license": "Apache-2.0",
"scripts": {
Expand All @@ -26,7 +26,7 @@
},
"dependencies": {
"@hashgraph/sdk": "^2.48.1",
"@metamask/providers": "^17.1.0",
"@metamask/providers": "^17.2.0",
"bignumber.js": "^9.1.2",
"bootstrap": "^5.3.3",
"lodash": "^4.17.21",
Expand All @@ -35,24 +35,24 @@
"react-dom": "^18.3.1",
"react-is": "^18.3.1",
"react-select": "^5.8.0",
"sharp": "^0.33.4",
"styled-components": "^6.1.11"
"sharp": "^0.33.5",
"styled-components": "^6.1.13"
},
"devDependencies": {
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@svgr/webpack": "^8.1.0",
"@testing-library/dom": "^10.3.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/bootstrap": "^5.2.10",
"@types/jest": "^29.5.12",
"@types/lodash.clonedeep": "^4.5.9",
"@types/react": "^18.3.3",
"@types/react-bootstrap": "^0.32.36",
"@types/react-bootstrap": "^0.32.37",
"@types/react-dom": "^18.3.0",
"@types/react-select": "^5.0.1",
"@types/styled-components": "^5.1.34",
Expand All @@ -64,17 +64,17 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "28.3.0",
"eslint-plugin-jsdoc": "^48.7.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-n": "17.3.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"gatsby": "^5.13.6",
"eslint-plugin-prettier": "^5.2.1",
"gatsby": "^5.13.7",
"gatsby-plugin-manifest": "^5.13.1",
"gatsby-plugin-styled-components": "^6.13.1",
"gatsby-plugin-svgr": "^3.0.0-beta.0",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.0",
"rimraf": "^5.0.7",
"typescript": "^5.5.3"
"rimraf": "^6.0.1",
"typescript": "^5.6.2"
}
}
16 changes: 16 additions & 0 deletions packages/hedera-wallet-snap/packages/snap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [0.6.0](https://github.com/hashgraph/hedera-metamask-snaps/compare/v0.6.0...v0.6.0) (2024-09-09)

### :page_with_curl: Documentation

- Refer to the [Hedera Wallet Snap Wiki](https://docs.tuum.tech/hedera-wallet-snap/) for more info on how the snap works and how to integrate it into your own application.

### :rocket: Features

- [Added snap home page](https://github.com/hashgraph/hedera-metamask-snaps/issues/558)
- [Updated some dialog boxes](https://github.com/hashgraph/hedera-metamask-snaps/issues/559)
- [Send notifications for certain API calls whenever snap errors out](https://github.com/hashgraph/hedera-metamask-snaps/issues/560)
- Updated the dependencies
- Further optimized the code

### :bug: Bug Fixes

## [0.5.0](https://github.com/hashgraph/hedera-metamask-snaps/compare/v0.5.0...v0.5.0) (2024-07-12)

### :page_with_curl: Documentation
Expand Down
17 changes: 9 additions & 8 deletions packages/hedera-wallet-snap/packages/snap/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@ module.exports = {
},
},
},
moduleFileExtensions: ['js', 'json', 'ts', 'mjs', 'cjs'],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx', 'mjs', 'cjs'],
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.js$': 'babel-jest',
},
transformIgnorePatterns: [
'/node_modules/(?!normalize-url).+\\.js$'
],
transformIgnorePatterns: ['/node_modules/(?!normalize-url).+\\.js$'],
testTimeout: 120000,
reporters: [
'default',
['jest-junit', {
suiteName: 'Wallet Snap Unit Tests',
outputName: 'junit-snap.xml',
}]
[
'jest-junit',
{
suiteName: 'Wallet Snap Unit Tests',
outputName: 'junit-snap.xml',
},
],
],
};
28 changes: 14 additions & 14 deletions packages/hedera-wallet-snap/packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-wallet-snap",
"version": "0.5.0",
"version": "0.6.0",
"description": "Hedera Wallet Snap unlocks wallet functionality via Metamask that any other apps can interact with, thereby turning Metamask into a native Hedera wallet without relying on Hedera JSON-RPC Relay.",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -45,12 +45,12 @@
},
"dependencies": {
"@hashgraph/sdk": "^2.48.1",
"@metamask/key-tree": "^9.1.1",
"@metamask/providers": "^17.1.0",
"@metamask/key-tree": "^9.1.2",
"@metamask/providers": "^17.2.0",
"@metamask/rpc-errors": "^6.3.1",
"@metamask/snaps-sdk": "^6.0.0",
"@metamask/snaps-sdk": "^6.3.0",
"bignumber.js": "^9.1.2",
"ethers": "^6.13.1",
"ethers": "^6.13.2",
"lodash": "^4.17.21",
"normalize-url": "^8.0.1"
},
Expand All @@ -61,8 +61,8 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/snaps-cli": "^6.2.1",
"@metamask/snaps-jest": "^8.2.0",
"@metamask/snaps-cli": "^6.3.1",
"@metamask/snaps-jest": "^8.3.0",
"@types/jest": "^29.5.12",
"@types/lodash.clonedeep": "^4.5.9",
"@types/normalize-url": "^4.2.0",
Expand All @@ -72,21 +72,21 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "28.3.0",
"eslint-plugin-jsdoc": "^48.7.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-n": "17.3.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-mock": "^29.7.0",
"lodash.clonedeep": "^4.5.0",
"prettier": "^3.3.2",
"prettier-plugin-packagejson": "^2.5.0",
"rimraf": "^5.0.7",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.2",
"rimraf": "^6.0.1",
"ts-jest": "^29.2.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
"typescript": "^5.6.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/hedera-wallet-snap/packages/snap/snap.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { resolve } from 'path';
const config: SnapConfig = {
bundler: 'webpack',
// eslint-disable-next-line no-restricted-globals
input: resolve(__dirname, 'src/index.ts'),
input: resolve(__dirname, 'src/index.tsx'),
server: {
port: 9001,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/hedera-wallet-snap/packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "0.5.0",
"version": "0.6.0",
"description": "Hedera Wallet unlocks wallet functionality via Metamask that any other apps can interact with, thereby turning Metamask into a native Hedera wallet without relying on Hedera JSON-RPC Relay.",
"proposedName": "Hedera Wallet",
"repository": {
"type": "git",
"url": "git+https://github.com/hashgraph/hedera-metamask-snaps.git"
},
"source": {
"shasum": "U4OfhY1LOkXp6Taebcyi7dWfdMUr9vSODrSg9CPDBbo=",
"shasum": "WBElnq8QrvpYe+klfkrLW8iFPzdhnjgvJAKQbz9gTN8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import { PrivateKey } from '@hashgraph/sdk';
import { rpcErrors } from '@metamask/rpc-errors';
import type { DialogParams } from '@metamask/snaps-sdk';
import { copyable, heading, text } from '@metamask/snaps-sdk';
import { ethers, type Wallet } from 'ethers';
import { SignMessageUI } from '../components/signMessage';
import type { Wallet as HederaWallet } from '../domain/wallet/abstract';
import { PrivateKeySoftwareWallet } from '../domain/wallet/software-private-key';
import type { SignMessageRequestParams } from '../types/params';
Expand Down Expand Up @@ -55,18 +55,15 @@ export class SignMessageCommand {

let signature = '';
try {
const panelToShow = [
heading('Signature request'),
text('Are you sure you want to sign this message?'),
copyable(message),
];
const dialogParamsForSignMessage: DialogParams = {
type: 'confirmation',
content: await SnapUtils.generateCommonPanel(
origin,
network,
mirrorNodeUrl,
panelToShow,
content: (
<SignMessageUI
origin={origin}
network={network}
mirrorNodeUrl={mirrorNodeUrl}
message={message}
/>
),
};
const confirmed = await SnapUtils.snapDialog(dialogParamsForSignMessage);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*-
*
* Hedera Wallet Snap
*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import type { SnapComponent } from '@metamask/snaps-sdk/jsx';
import {
Address as MetamaskAddress,
Bold as MetamaskBold,
Box as MetamaskBox,
Copyable as MetamaskCopyable,
Divider as MetamaskDivider,
Heading as MetamaskHeading,
Link as MetamaskLink,
Row as MetamaskRow,
Text as MetamaskText,
} from '@metamask/snaps-sdk/jsx';

export const Box = MetamaskBox as any;
export const Heading = MetamaskHeading as any;
export const Divider = MetamaskDivider as any;
export const Row = MetamaskRow as any;
export const Text = MetamaskText as any;
export const Copyable = MetamaskCopyable as any;
export const Address = MetamaskAddress as any;
export const Link = MetamaskLink as any;
export const Bold = MetamaskBold as any;

export type CommonProps = {
origin: string;
network: string;
mirrorNodeUrl: string;
[key: string]: any;
};

const MetamaskUI: SnapComponent<CommonProps> = ({
origin,
network,
mirrorNodeUrl,
}) => {
return (
<Box>
<Heading>Request</Heading>
<Row label="Origin">
<Text>{origin}</Text>
</Row>
<Row label="Network">
<Text>{network}</Text>
</Row>
<Row label="Mirror Node">
<Text>{mirrorNodeUrl}</Text>
</Row>
<Divider />
</Box>
);
};

export const CommonUI = MetamaskUI as any;
Loading

0 comments on commit 2b56276

Please sign in to comment.