Skip to content
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

perf: don't import * as ethers #651

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions examples/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-sandbox",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"private": true,
"browserslist": "> 0.5%, last 2 versions, not dead",
Expand All @@ -10,21 +10,21 @@
"clean": "rm -rf dist node_modules public .parcel-cache"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.52.9",
"@shapeshiftoss/hdwallet-keplr": "1.52.9",
"@shapeshiftoss/hdwallet-ledger": "1.52.9",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.52.9",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.52.9",
"@shapeshiftoss/hdwallet-metamask": "1.52.9",
"@shapeshiftoss/hdwallet-native": "1.52.9",
"@shapeshiftoss/hdwallet-portis": "1.52.9",
"@shapeshiftoss/hdwallet-tallyho": "1.52.9",
"@shapeshiftoss/hdwallet-trezor": "1.52.9",
"@shapeshiftoss/hdwallet-trezor-connect": "1.52.9",
"@shapeshiftoss/hdwallet-walletconnect": "1.52.9",
"@shapeshiftoss/hdwallet-xdefi": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.52.10",
"@shapeshiftoss/hdwallet-keplr": "1.52.10",
"@shapeshiftoss/hdwallet-ledger": "1.52.10",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.52.10",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.52.10",
"@shapeshiftoss/hdwallet-metamask": "1.52.10",
"@shapeshiftoss/hdwallet-native": "1.52.10",
"@shapeshiftoss/hdwallet-portis": "1.52.10",
"@shapeshiftoss/hdwallet-tallyho": "1.52.10",
"@shapeshiftoss/hdwallet-trezor": "1.52.10",
"@shapeshiftoss/hdwallet-trezor-connect": "1.52.10",
"@shapeshiftoss/hdwallet-walletconnect": "1.52.10",
"@shapeshiftoss/hdwallet-xdefi": "1.52.10",
"bip32": "^2.0.4",
"jquery": "^3.4.1",
"json": "^9.0.6",
Expand Down
20 changes: 10 additions & 10 deletions integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/integration",
"version": "1.52.9",
"version": "1.52.10",
"main": "index.js",
"license": "MIT",
"private": true,
Expand All @@ -10,15 +10,15 @@
"dev": "lerna run test --scope integration --parallel --include-filtered-dependencies"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.9",
"@shapeshiftoss/hdwallet-ledger": "1.52.9",
"@shapeshiftoss/hdwallet-native": "1.52.9",
"@shapeshiftoss/hdwallet-portis": "1.52.9",
"@shapeshiftoss/hdwallet-trezor": "1.52.9",
"@shapeshiftoss/hdwallet-xdefi": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.10",
"@shapeshiftoss/hdwallet-ledger": "1.52.10",
"@shapeshiftoss/hdwallet-native": "1.52.10",
"@shapeshiftoss/hdwallet-portis": "1.52.10",
"@shapeshiftoss/hdwallet-trezor": "1.52.10",
"@shapeshiftoss/hdwallet-xdefi": "1.52.10",
"fast-json-stable-stringify": "^2.1.0",
"msw": "^0.27.1",
"whatwg-fetch": "^3.6.2"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "5.2.0",
"version": "1.52.9",
"version": "1.52.10",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-coinbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-coinbase",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -15,7 +15,7 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.6.6",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"eth-rpc-errors": "^4.0.3",
"lodash": "^4.17.21"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/hdwallet-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-core",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-chromeusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-chromeusb",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,7 +14,7 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.9"
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10"
}
}
4 changes: 2 additions & 2 deletions packages/hdwallet-keepkey-electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-electron",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,7 +14,7 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-keepkey": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10",
"uuid": "^8.3.2"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-keepkey-nodehid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-nodehid",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,7 +14,7 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-keepkey": "1.52.9"
"@shapeshiftoss/hdwallet-keepkey": "1.52.10"
},
"peerDependencies": {
"node-hid": "^2.1.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-nodewebusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-nodewebusb",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.9"
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10"
},
"peerDependencies": {
"usb": "^2.3.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-tcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-tcp",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10",
"axios": "^0.21.1"
}
}
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-webusb",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-keepkey": "1.52.9"
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-keepkey": "1.52.10"
},
"devDependencies": {
"@types/w3c-web-usb": "^1.0.4"
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-keepkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -19,7 +19,7 @@
"@ethereumjs/tx": "^3.3.0",
"@keepkey/device-protocol": "^7.12.2",
"@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/proto-tx-builder": "^0.8.0",
"bignumber.js": "^9.0.1",
"bnb-javascript-sdk-nobroadcast": "^2.16.14",
Expand Down
8 changes: 4 additions & 4 deletions packages/hdwallet-keepkey/src/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Types from "@keepkey/device-protocol/lib/types_pb";
import * as core from "@shapeshiftoss/hdwallet-core";
import { getMessage, getTypeHash } from "eip-712";
import * as eip55 from "eip55";
import * as ethers from "ethers";
import { arrayify, isBytes, isHexString } from "ethers/lib/utils.js";

import { Transport } from "./transport";
import { toUTF8Array } from "./utils";
Expand Down Expand Up @@ -173,10 +173,10 @@ export async function ethGetAddress(transport: Transport, msg: core.ETHGetAddres

export async function ethSignMessage(transport: Transport, msg: core.ETHSignMessage): Promise<core.ETHSignedMessage> {
const { addressNList, message } = msg;
if (!ethers.utils.isHexString(message)) throw new Error("data is not an hex string");
if (!isHexString(message)) throw new Error("data is not an hex string");
const m = new Ethereum.EthereumSignMessage();
m.setAddressNList(addressNList);
const messageBytes = ethers.utils.arrayify(message);
const messageBytes = arrayify(message);
m.setMessage(messageBytes);
const response = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUMSIGNMESSAGE, m, {
msgTimeout: core.LONG_TIMEOUT,
Expand Down Expand Up @@ -272,7 +272,7 @@ export async function ethVerifyMessage(transport: Transport, msg: core.ETHVerify
const m = new Ethereum.EthereumVerifyMessage();
m.setAddress(core.arrayify(msg.address));
m.setSignature(core.arrayify(msg.signature));
m.setMessage(ethers.utils.isBytes(msg.message) ? ethers.utils.arrayify(msg.message) : toUTF8Array(msg.message));
m.setMessage(isBytes(msg.message) ? arrayify(msg.message) : toUTF8Array(msg.message));
let event: core.Event;
try {
event = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUMVERIFYMESSAGE, m, {
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-keplr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keplr",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -15,7 +15,7 @@
},
"dependencies": {
"@shapeshiftoss/caip": "8.15.0",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/proto-tx-builder": "^0.8.0",
"@shapeshiftoss/types": "3.1.3",
"base64-js": "^1.5.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-ledger-webhid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger-webhid",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -19,8 +19,8 @@
"@ledgerhq/hw-transport": "^6.7.0",
"@ledgerhq/hw-transport-webhid": "^6.7.0",
"@ledgerhq/live-common": "^21.8.2",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-ledger": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-ledger": "1.52.10",
"@types/w3c-web-hid": "^1.0.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-ledger-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger-webusb",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -20,8 +20,8 @@
"@ledgerhq/hw-transport-webusb": "^6.7.0",
"@ledgerhq/live-common": "^21.8.2",
"@ledgerhq/logs": "^6.10.1",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-ledger": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/hdwallet-ledger": "1.52.10",
"@types/w3c-web-usb": "^1.0.4",
"p-queue": "^7.4.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -18,7 +18,7 @@
"@ethereumjs/common": "^2.4.0",
"@ethereumjs/tx": "^3.3.0",
"@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"base64-js": "^1.5.1",
"bchaddrjs": "^0.4.4",
"bitcoinjs-message": "^2.0.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/hdwallet-ledger/src/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EthereumTx from "ethereumjs-tx";
// @ts-ignore
// TODO: fix ts-ignore
import * as ethereumUtil from "ethereumjs-util";
import * as ethers from "ethers";
import { arrayify, isBytes } from "ethers/lib/utils.js";
import { isHexString } from "ethjs-util";

import { LedgerTransport } from "./transport";
Expand Down Expand Up @@ -189,9 +189,7 @@ export async function ethVerifyMessage(msg: core.ETHVerifyMessage): Promise<bool
return false;
}
sigb[64] = sigb[64] === 0 || sigb[64] === 1 ? sigb[64] + 27 : sigb[64];
const buffer = ethers.utils.isBytes(msg.message)
? Buffer.from(ethers.utils.arrayify(msg.message))
: Buffer.from(msg.message);
const buffer = isBytes(msg.message) ? Buffer.from(arrayify(msg.message)) : Buffer.from(msg.message);
const hash = ethereumUtil.hashPersonalMessage(buffer);
const pubKey = ethereumUtil.ecrecover(hash, sigb[64], sigb.slice(0, 32), sigb.slice(32, 64));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-shapeshift-multichain",
"version": "1.52.9",
"version": "1.52.10",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -17,7 +17,7 @@
"@metamask/detect-provider": "^1.2.0",
"@metamask/onboarding": "^1.0.1",
"@shapeshiftoss/common-api": "^9.3.0",
"@shapeshiftoss/hdwallet-core": "1.52.9",
"@shapeshiftoss/hdwallet-core": "1.52.10",
"@shapeshiftoss/metamask-snaps-adapter": "^1.0.8",
"@shapeshiftoss/metamask-snaps-types": "^1.0.8",
"eth-rpc-errors": "^4.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import detectEthereumProvider from "@metamask/detect-provider";
import MetaMaskOnboarding from "@metamask/onboarding";
import * as core from "@shapeshiftoss/hdwallet-core";
import { enableShapeShiftSnap, shapeShiftSnapInstalled } from "@shapeshiftoss/metamask-snaps-adapter";
import * as ethers from "ethers";
import { providers } from "ethers";

import { SNAP_ID } from "./common";
import { MetaMaskShapeShiftMultiChainHDWallet } from "./shapeshift-multichain";
Expand All @@ -29,7 +29,7 @@ export class MetaMaskAdapter {
mustBeMetaMask: true,
silent: false,
timeout: 3000,
})) as ethers.providers.ExternalProvider | null;
})) as providers.ExternalProvider | null;
if (!provider) {
const onboarding = new MetaMaskOnboarding();
onboarding.startOnboarding();
Expand Down
Loading
Loading