Skip to content

Commit

Permalink
Merge pull request #4 from AstarNetwork/fix/text-links
Browse files Browse the repository at this point in the history
fix: text, links and svg
  • Loading branch information
gluneau authored Nov 1, 2023
2 parents 8c8f25b + 9552fcb commit d8b630c
Show file tree
Hide file tree
Showing 12 changed files with 950 additions and 893 deletions.
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
# Metamask <> Astar snap
![](https://github.com/AstarNetwork/metamask-snap-astar/workflows/ci/badge.svg)
![](https://img.shields.io/github/issues-raw/chainsafe/metamask-snap-polkadot)
![](https://img.shields.io/github/issues-raw/AstarNetwork/metamask-snap-astar)
![](https://img.shields.io/github/license/chainsafe/metamask-snap-polkadot)
![](https://img.shields.io/badge/yarn-%3E%3D1.17.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D12.x-orange.svg?style=flat-square)
![Discord](https://img.shields.io/discord/608204864593461248?color=blue&label=Discord&logo=discord)
![Discord](https://img.shields.io/discord/644182966574252073?color=blue&label=Discord&logo=discord)

Metamask snap (plugin) to enable Metamask users interaction with Polkadot dapps.

### Documentation

Go to [wiki](https://github.com/AstarNetwork/metamask-snap-astar/wiki) for detailed documentation on Polkadot snap.

Here you can find described [integration process](https://github.com/AstarNetwork/metamask-snap-astar/wiki#integration) and full [snap API documentation](https://github.com/AstarNetwork/metamask-snap-astar/wiki/API-Documentation).
Go to [docs](https://docs.astar.network/docs/build/astar-beta-labs/metamask-snaps/) for detailed documentation on Astar snap.

### Testing

#### Metamask
- [download latest Metamask snaps beta release](https://github.com/NodeFactoryIo/metamask-snaps-beta/releases) (chrome recommended)
- extract downloaded archive
- go to [chrome://extensions/](chrome://extensions/)
- enable "Developer mode"
- click "Load unpacked" and point to extracted archive chrome directory
- [Install Chrome Extension Metamask Flask](https://chrome.google.com/webstore/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk)


#### Extension
- `yarn install`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CloseIcon from '@material-ui/icons/Close';
import React, { Fragment, useCallback, useContext, useEffect } from 'react';
import Alert from '@material-ui/lab/Alert';
import { MetamaskActions, MetaMaskContext } from '../../context/metamask';
import { initiatePolkdatodSnap, isPolkadotSnapInstalled } from '../../services/metamask';
import { initiatePolkadotSnap, isPolkadotSnapInstalled } from '../../services/metamask';

export const MetaMaskConnector = (): React.JSX.Element => {
const [state, dispatch] = useContext(MetaMaskContext);
Expand All @@ -20,7 +20,7 @@ export const MetaMaskConnector = (): React.JSX.Element => {
}, [dispatch]);

const installSnap = useCallback(async (): Promise<void> => {
const installResult = await initiatePolkdatodSnap();
const installResult = await initiatePolkadotSnap();
if (!installResult.isSnapInstalled) {
dispatch({
payload: {
Expand Down
2 changes: 1 addition & 1 deletion packages/example/src/services/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface SnapInitializationResponse {
snap?: MetamaskPolkadotSnap;
}

export async function initiatePolkdatodSnap(): Promise<SnapInitializationResponse> {
export async function initiatePolkadotSnap(): Promise<SnapInitializationResponse> {
const snapId = process.env.REACT_APP_SNAP_ID ? process.env.REACT_APP_SNAP_ID : defaultSnapId;

try {
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/snap",
"version": "0.7.8",
"version": "0.7.9",
"description": "Metamask snap to interact with Astar dapps.",
"main": "build/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "0.7.8",
"version": "0.7.9",
"description": "The Astar snap.",
"proposedName": "Astar Wallet",
"repository": {
"type": "git",
"url": "git+https://github.com/AstarNetwork/metamask-snap-astar.git"
},
"source": {
"shasum": "zVR1revB6ibj1A6Ja2m2kcmQp07MtA80n0lmjY+OUnI=",
"shasum": "virkLODaqBe5JQhDMtMuniTbdmvJxyTQ9ivKPaMzpOI=",
"location": {
"npm": {
"filePath": "./dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/configuration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getDefaultConfiguration(networkName: string): SnapConfig {
export async function getConfiguration(): Promise<SnapConfig> {
const state = await getMetamaskState();

if (!state || !state.config) {
if (!state?.config) {
return defaultConfiguration;
}
return JSON.parse(<string>state.config) as SnapConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/configuration/predefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const polkadotConfiguration: SnapConfig = {
networkName: 'astar',
unit: {
decimals: 18,
image: 'https://polkadot.js.org/apps/static/polkadot-circle.1eea41b2..svg',
image: 'https://svgshare.com/i/zAE.svg',
symbol: 'ASTR'
},
wsRpcUrl: 'https://astar.api.onfinality.io/public'
Expand Down
11 changes: 10 additions & 1 deletion packages/snap/src/rpc/exportSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ const astarCoinType = 810;
export async function exportSeed(): Promise<string | null> {
// ask for confirmation
const confirmation = await showConfirmationDialog({
prompt: 'Do you want to export your seed?'
prompt: `Are you sure you want to export your seed?`,
description: `Please be aware that exporting your seed poses significant risks!
- If your seed is exposed to others, they can gain full access to your funds.
- A leaked seed can lead to a total loss of all your assets in this account.
To ensure the security of your funds:
- Store your seed in a secure, offline location.
- Do not share your seed with anyone.
- Avoid storing it on digital devices that can be hacked or accessed without your consent.
By exporting your seed, you acknowledge these risks and the responsibility for keeping it safe.
Do you still wish to proceed?`
});
// return seed if user confirmed action
if (confirmation) {
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/src/util/confirmation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { panel, text } from '@metamask/snaps-ui';
import { panel, heading, text } from '@metamask/snaps-ui';

type ConfirmationDialogContent = {
prompt: string;
Expand All @@ -11,7 +11,7 @@ export async function showConfirmationDialog(message: ConfirmationDialogContent)
method: 'snap_dialog',
params: {
content: panel([
text(message.prompt || 'Are you sure?'),
heading(message.prompt || 'Are you sure?'),
text(message.description || ''),
text(message.textAreaContent || '')
]),
Expand Down
4 changes: 4 additions & 0 deletions packages/snap/src/util/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const SignaturePayloadJSONSchema = type({
version: number()
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TS2322
export const validSignPayloadJSONSchema: Describe<{
payload: SignerPayloadJSON;
}> = object({
Expand Down Expand Up @@ -65,6 +67,8 @@ export const validGenerateTransactionPayloadSchema: Describe<{
to: string()
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TS2322
export const validSendSchema: Describe<{
signature: string;
txPayload: TxPayload;
Expand Down
1 change: 1 addition & 0 deletions packages/snap/test/unit/rpc/substrate/getBlock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getWalletMock } from '../../wallet.mock';
chai.use(sinonChai);

describe('Test rpc handler function: getBlock', function () {
// eslint-disable-next-line mocha/no-setup-in-describe
const walletStub = getWalletMock();

afterEach(function () {
Expand Down
Loading

0 comments on commit d8b630c

Please sign in to comment.