Skip to content

Commit

Permalink
Fix minor bugs for release (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: Kipkap <[email protected]>
  • Loading branch information
himalayan-dev authored Feb 5, 2024
1 parent 7787f48 commit 1d11b42
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-metamask-snaps",
"version": "0.2.3",
"version": "0.2.4",
"description": "A collection of Hedera related Metamask snaps that expose and utilize Hedera functionality inside Metamask",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
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.2.3",
"version": "0.2.4",
"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
2 changes: 1 addition & 1 deletion 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.2.3",
"version": "0.2.4",
"private": true,
"license": "Apache-2.0",
"scripts": {
Expand Down
12 changes: 12 additions & 0 deletions packages/hedera-wallet-snap/packages/snap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.2.4](https://github.com/hashgraph/hedera-metamask-snaps/compare/v0.2.4...v0.2.4) (2024-02-05)

### :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

### :bug: Bug Fixes

- Fixed some import issues

## [0.2.3](https://github.com/hashgraph/hedera-metamask-snaps/compare/v0.2.3...v0.2.3) (2024-02-02)

### :page_with_curl: Documentation
Expand Down
2 changes: 1 addition & 1 deletion 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.2.3",
"version": "0.2.4",
"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
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.2.3",
"version": "0.2.4",
"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": "g6gofXCeKQf0dIKntm0UGIntbbn4MqFAPyhDWeKJK8M=",
"shasum": "GW5ZWO6uAdBmSjuVTZtszHzTfHTb4/uASBVTOxvPCU4=",
"location": {
"npm": {
"filePath": "dist/snap.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import { providerErrors } from '@metamask/rpc-errors';
import { divider, heading, text } from '@metamask/snaps-ui';
import _ from 'lodash';
import { AccountInfo } from 'src/types/account';
import { SimpleTransfer, TxReceipt } from '../../services/hedera';
import { HederaServiceImpl } from '../../services/impl/hedera';
import { createHederaClient } from '../../snap/account';
import { generateCommonPanel, snapDialog } from '../../snap/dialog';
import { updateSnapState } from '../../snap/state';
import { AccountInfo } from '../../types/account';
import {
GetAccountInfoRequestParams,
ServiceFee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export type HederaService = {
};

export type SimpleHederaClient = {
// close the client
close(): void;

// get the associated client
getClient(): Client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class SimpleHederaClientImpl implements SimpleHederaClient {
this._privateKey = privateKey;
}

close() {
this._client.close();
}

getClient(): Client {
return this._client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import _ from 'lodash';

import { StakingInfoJson } from '@hashgraph/sdk/lib/StakingInfo';
import { providerErrors } from '@metamask/rpc-errors';
import { AccountInfo } from 'src/types/account';
import { Wallet } from '../../../domain/wallet/abstract';
import { PrivateKeySoftwareWallet } from '../../../domain/wallet/software-private-key';
import { AccountInfo } from '../../../types/account';
import { FetchResponse, fetchDataFromUrl } from '../../../utils/fetch';
import { timestampToString } from '../../../utils/helper';
import {
Expand Down
29 changes: 20 additions & 9 deletions packages/hedera-wallet-snap/packages/snap/src/snap/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ export async function setCurrentAccount(
const { accountIdOrEvmAddress, curve = 'ECDSA_SECP256K1' } =
nonMetamaskAccount.externalAccount;
if (ethers.isAddress(accountIdOrEvmAddress)) {
if (curve !== 'ECDSA_SECP256K1') {
console.error(
`You must use 'ECDSA_SECP256K1' as the curve if you want to import an EVM address. Please make sure to pass in the correct value for "curve".`,
);
throw providerErrors.unsupportedMethod(
`You must use 'ECDSA_SECP256K1' as the curve if you want to import an EVM address. Please make sure to pass in the correct value for "curve".`,
);
}

const { connectedAddress: _connectedAddress, keyStore: _keyStore } =
await connectEVMAccount(
origin,
Expand Down Expand Up @@ -229,6 +220,16 @@ async function connectEVMAccount(
const { keyStore } = state.accountState[addr][network];

if (evmAddress === keyStore.address) {
if (keyStore.curve !== curve) {
console.error(
`You passed '${curve}' as the digital signature algorithm to use but the account was derived using ${keyStore.curve} on '${network}'. Please make sure to pass in the correct value for "curve".`,
);
throw providerErrors.custom({
code: 4200,
message: `You passed '${curve}' as the digital signature algorithm to use but the account was derived using ${keyStore.curve} on '${network}'. Please make sure to pass in the correct value for "curve".`,
data: { network, curve, evmAddress },
});
}
connectedAddress = addr;
result = keyStore;
break;
Expand Down Expand Up @@ -390,6 +391,16 @@ async function connectHederaAccount(
if (state.accountState[addr][network]) {
const { keyStore } = state.accountState[addr][network];
if (keyStore.hederaAccountId === accountId) {
if (keyStore.curve !== curve) {
console.error(
`You passed '${curve}' as the digital signature algorithm to use but the account was derived using ${keyStore.curve} on '${network}'. Please make sure to pass in the correct value for "curve".`,
);
throw providerErrors.custom({
code: 4200,
message: `You passed '${curve}' as the digital signature algorithm to use but the account was derived using ${keyStore.curve} on '${network}'. Please make sure to pass in the correct value for "curve".`,
data: { network, curve, accountId },
});
}
connectedAddress = addr;
result = keyStore;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import BigNumber from 'bignumber.js';
import { ethers } from 'ethers';
import { SimpleHederaClient, SimpleTransfer } from 'src/services/hedera';
import { SimpleHederaClient, SimpleTransfer } from '../services/hedera';

export type QueryCost = {
serviceFeeToPay: number;
Expand Down

0 comments on commit 1d11b42

Please sign in to comment.