From ce1375f4c03a971b2306cbf3eeebae2431b47216 Mon Sep 17 00:00:00 2001 From: kevin <35275952+kaladinlight@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:17:01 -0600 Subject: [PATCH 1/3] chore: add types dependency for ethereumjs-util (#637) --- packages/hdwallet-ledger/package.json | 1 + yarn.lock | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/hdwallet-ledger/package.json b/packages/hdwallet-ledger/package.json index cd49e6e75..d3a96d4ad 100644 --- a/packages/hdwallet-ledger/package.json +++ b/packages/hdwallet-ledger/package.json @@ -35,6 +35,7 @@ "@types/bchaddrjs": "^0.4.0", "@types/bs58check": "^2.1.0", "@types/ethereumjs-tx": "1.0.1", + "@types/ethereumjs-util": "^6.1.0", "typedoc": "^0.20.36" } } diff --git a/yarn.lock b/yarn.lock index d8410d1b4..fdfdcc817 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6138,6 +6138,13 @@ "@types/bn.js" "*" "@types/node" "*" +"@types/ethereumjs-util@^6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@types/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz#9dabd7302ec9728a7d99be15f4143977c33cd5ac" + integrity sha512-5N0RJldhKCKwDksdnuNHbEJuwO5pjEdtwdHj/kZLxaS84s5R1NLgYfAuDF/VZ4whYABJJvv+o0O8TXLm+F/Byw== + dependencies: + ethereumjs-util "*" + "@types/eventsource@1.1.8", "@types/eventsource@^1.1.2": version "1.1.8" resolved "https://registry.yarnpkg.com/@types/eventsource/-/eventsource-1.1.8.tgz#48ae1f3aaf9bb84c713038f354112cc7ceaad519" @@ -11080,6 +11087,17 @@ ethereumjs-tx@^2.1.1, ethereumjs-tx@^2.1.2: ethereumjs-common "^1.5.0" ethereumjs-util "^6.0.0" +ethereumjs-util@*: + version "7.1.5" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz#9ecf04861e4fbbeed7465ece5f23317ad1129181" + integrity sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg== + dependencies: + "@types/bn.js" "^5.1.0" + bn.js "^5.1.2" + create-hash "^1.1.2" + ethereum-cryptography "^0.1.3" + rlp "^2.2.4" + ethereumjs-util@5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#3e0c0d1741471acf1036052d048623dee54ad642" From e82f3956c9e13e7609ff0134fae611dec7b5815b Mon Sep 17 00:00:00 2001 From: kevin <35275952+kaladinlight@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:24:14 -0600 Subject: [PATCH 2/3] chore: ignore ethereumjs-util error (#638) --- packages/hdwallet-ledger/src/ethereum.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/hdwallet-ledger/src/ethereum.ts b/packages/hdwallet-ledger/src/ethereum.ts index 080470482..73e61655b 100644 --- a/packages/hdwallet-ledger/src/ethereum.ts +++ b/packages/hdwallet-ledger/src/ethereum.ts @@ -2,6 +2,9 @@ import Common from "@ethereumjs/common"; import { Transaction } from "@ethereumjs/tx"; import * as core from "@shapeshiftoss/hdwallet-core"; import EthereumTx from "ethereumjs-tx"; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +// TODO: fix ts-ignore import * as ethereumUtil from "ethereumjs-util"; import * as ethers from "ethers"; From b2d570703da26dd673beeecd1101f2edbf446787 Mon Sep 17 00:00:00 2001 From: Apotheosis <0xapotheosis@gmail.com> Date: Tue, 3 Oct 2023 10:46:43 +1100 Subject: [PATCH 3/3] fix: `ethSignMessage` expect hex string message (#635) --- examples/sandbox/package.json | 32 +++++++++---------- integration/package.json | 20 ++++++------ integration/src/ethereum/ethereum.ts | 2 +- integration/src/wallets/metamask.ts | 4 +-- integration/src/wallets/trezor.ts | 2 +- lerna.json | 2 +- packages/hdwallet-coinbase/package.json | 4 +-- .../hdwallet-coinbase/src/coinbase.test.ts | 6 ++-- packages/hdwallet-coinbase/src/ethereum.ts | 8 ++--- packages/hdwallet-core/package.json | 2 +- packages/hdwallet-core/src/ethereum.ts | 2 +- .../hdwallet-keepkey-chromeusb/package.json | 6 ++-- .../hdwallet-keepkey-electron/package.json | 4 +-- .../hdwallet-keepkey-nodehid/package.json | 4 +-- .../hdwallet-keepkey-nodewebusb/package.json | 6 ++-- packages/hdwallet-keepkey-tcp/package.json | 6 ++-- packages/hdwallet-keepkey-webusb/package.json | 6 ++-- packages/hdwallet-keepkey/package.json | 4 +-- packages/hdwallet-keepkey/src/ethereum.ts | 6 ++-- packages/hdwallet-keplr/package.json | 4 +-- packages/hdwallet-ledger-webhid/package.json | 6 ++-- packages/hdwallet-ledger-webusb/package.json | 6 ++-- packages/hdwallet-ledger/package.json | 4 +-- packages/hdwallet-ledger/src/ethereum.ts | 7 ++-- .../package.json | 4 +-- .../src/ethereum.ts | 8 ++--- .../src/shapeshift-multichain.test.ts | 6 ++-- packages/hdwallet-metamask/package.json | 4 +-- packages/hdwallet-metamask/src/ethereum.ts | 8 ++--- .../hdwallet-metamask/src/metamask.test.ts | 6 ++-- packages/hdwallet-native-vault/package.json | 4 +-- packages/hdwallet-native/package.json | 4 +-- packages/hdwallet-native/src/ethereum.test.ts | 10 +++--- packages/hdwallet-portis/package.json | 4 +-- packages/hdwallet-portis/src/ethereum.ts | 2 ++ packages/hdwallet-tallyho/package.json | 4 +-- .../hdwallet-tallyho/src/ethereum.test.ts | 24 +++++++------- packages/hdwallet-tallyho/src/ethereum.ts | 8 ++--- packages/hdwallet-tallyho/src/tallyho.test.ts | 6 ++-- packages/hdwallet-trezor-connect/package.json | 6 ++-- packages/hdwallet-trezor/package.json | 4 +-- packages/hdwallet-trezor/src/ethereum.ts | 2 ++ packages/hdwallet-walletconnect/package.json | 4 +-- .../hdwallet-walletconnect/src/ethereum.ts | 11 +++---- .../hdwallet-walletconnectV2/package.json | 4 +-- .../hdwallet-walletconnectV2/src/ethereum.ts | 9 +++--- packages/hdwallet-xdefi/package.json | 4 +-- packages/hdwallet-xdefi/src/ethereum.test.ts | 25 +++++++-------- packages/hdwallet-xdefi/src/ethereum.ts | 8 ++--- packages/hdwallet-xdefi/src/xdefi.test.ts | 6 ++-- 50 files changed, 163 insertions(+), 175 deletions(-) diff --git a/examples/sandbox/package.json b/examples/sandbox/package.json index cf1bc4ccd..d74cd8345 100644 --- a/examples/sandbox/package.json +++ b/examples/sandbox/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-sandbox", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "private": true, "browserslist": "> 0.5%, last 2 versions, not dead", @@ -10,21 +10,21 @@ "clean": "rm -rf dist node_modules public .parcel-cache" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey-tcp": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey-webusb": "1.50.10", - "@shapeshiftoss/hdwallet-keplr": "1.50.10", - "@shapeshiftoss/hdwallet-ledger": "1.50.10", - "@shapeshiftoss/hdwallet-ledger-webhid": "1.50.10", - "@shapeshiftoss/hdwallet-ledger-webusb": "1.50.10", - "@shapeshiftoss/hdwallet-metamask": "1.50.10", - "@shapeshiftoss/hdwallet-native": "1.50.10", - "@shapeshiftoss/hdwallet-portis": "1.50.10", - "@shapeshiftoss/hdwallet-tallyho": "1.50.10", - "@shapeshiftoss/hdwallet-trezor": "1.50.10", - "@shapeshiftoss/hdwallet-trezor-connect": "1.50.10", - "@shapeshiftoss/hdwallet-walletconnect": "1.50.10", - "@shapeshiftoss/hdwallet-xdefi": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey-tcp": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey-webusb": "1.51.0", + "@shapeshiftoss/hdwallet-keplr": "1.51.0", + "@shapeshiftoss/hdwallet-ledger": "1.51.0", + "@shapeshiftoss/hdwallet-ledger-webhid": "1.51.0", + "@shapeshiftoss/hdwallet-ledger-webusb": "1.51.0", + "@shapeshiftoss/hdwallet-metamask": "1.51.0", + "@shapeshiftoss/hdwallet-native": "1.51.0", + "@shapeshiftoss/hdwallet-portis": "1.51.0", + "@shapeshiftoss/hdwallet-tallyho": "1.51.0", + "@shapeshiftoss/hdwallet-trezor": "1.51.0", + "@shapeshiftoss/hdwallet-trezor-connect": "1.51.0", + "@shapeshiftoss/hdwallet-walletconnect": "1.51.0", + "@shapeshiftoss/hdwallet-xdefi": "1.51.0", "bip32": "^2.0.4", "jquery": "^3.4.1", "json": "^9.0.6", diff --git a/integration/package.json b/integration/package.json index 6ace3236d..e84e9939a 100644 --- a/integration/package.json +++ b/integration/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/integration", - "version": "1.50.10", + "version": "1.51.0", "main": "index.js", "license": "MIT", "private": true, @@ -10,15 +10,15 @@ "dev": "lerna run test --scope integration --parallel --include-filtered-dependencies" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey-tcp": "1.50.10", - "@shapeshiftoss/hdwallet-ledger": "1.50.10", - "@shapeshiftoss/hdwallet-native": "1.50.10", - "@shapeshiftoss/hdwallet-portis": "1.50.10", - "@shapeshiftoss/hdwallet-trezor": "1.50.10", - "@shapeshiftoss/hdwallet-xdefi": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey-tcp": "1.51.0", + "@shapeshiftoss/hdwallet-ledger": "1.51.0", + "@shapeshiftoss/hdwallet-native": "1.51.0", + "@shapeshiftoss/hdwallet-portis": "1.51.0", + "@shapeshiftoss/hdwallet-trezor": "1.51.0", + "@shapeshiftoss/hdwallet-xdefi": "1.51.0", "fast-json-stable-stringify": "^2.1.0", "msw": "^0.27.1", "whatwg-fetch": "^3.6.2" diff --git a/integration/src/ethereum/ethereum.ts b/integration/src/ethereum/ethereum.ts index ec211d9dc..4f3c68423 100644 --- a/integration/src/ethereum/ethereum.ts +++ b/integration/src/ethereum/ethereum.ts @@ -396,7 +396,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW if (ledger.isLedger(wallet)) return; // FIXME: Expected failure const res = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - message: "Hello World", + message: "0x48656c6c6f20576f726c64", // "Hello World", }); expect(res?.address).toEqual("0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"); expect(res?.signature).toEqual( diff --git a/integration/src/wallets/metamask.ts b/integration/src/wallets/metamask.ts index 5d2be0523..9812d4a9f 100644 --- a/integration/src/wallets/metamask.ts +++ b/integration/src/wallets/metamask.ts @@ -18,7 +18,7 @@ export async function createWallet(): Promise { case "personal_sign": { const [message] = params; - if (message === "48656c6c6f20576f726c64") + if (message === "48656c6c6f20576f726c64" || message === "0x48656c6c6f20576f726c64") return "0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b"; throw new Error("unknown message"); @@ -161,7 +161,7 @@ export function selfTest(get: () => core.HDWallet): void { if (!wallet) return; const res = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - message: "Hello World", + message: "0x48656c6c6f20576f726c64", // "Hello World" }); expect(res?.address).toEqual("0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"); expect(res?.signature).toEqual( diff --git a/integration/src/wallets/trezor.ts b/integration/src/wallets/trezor.ts index 187ea02e2..d641b04f1 100644 --- a/integration/src/wallets/trezor.ts +++ b/integration/src/wallets/trezor.ts @@ -112,7 +112,7 @@ export class MockTransport extends trezor.TrezorTransport { "ethereumSignMessage", { path: [2147483692, 2147483708, 2147483648, 0, 0], - message: "Hello World", + message: "0x48656c6c6f20576f726c64", // "Hello World" }, { success: true, diff --git a/lerna.json b/lerna.json index 97abadac6..752855c87 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "5.2.0", - "version": "1.50.10", + "version": "1.51.0", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/hdwallet-coinbase/package.json b/packages/hdwallet-coinbase/package.json index 1a6d7b656..1f917e920 100644 --- a/packages/hdwallet-coinbase/package.json +++ b/packages/hdwallet-coinbase/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-coinbase", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@coinbase/wallet-sdk": "^3.6.6", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "eth-rpc-errors": "^4.0.3", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-coinbase/src/coinbase.test.ts b/packages/hdwallet-coinbase/src/coinbase.test.ts index 555d85d2a..1da5a9ab5 100644 --- a/packages/hdwallet-coinbase/src/coinbase.test.ts +++ b/packages/hdwallet-coinbase/src/coinbase.test.ts @@ -51,7 +51,7 @@ describe("CoinbaseHDWallet", () => { }` ), } as any; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -73,7 +73,7 @@ describe("CoinbaseHDWallet", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), } as any; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, @@ -87,7 +87,7 @@ describe("CoinbaseHDWallet", () => { request: jest.fn().mockReturnValue(["0x73d0385F4d8E00C5e6504C6030F47BF6212736A8"]), } as any; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, diff --git a/packages/hdwallet-coinbase/src/ethereum.ts b/packages/hdwallet-coinbase/src/ethereum.ts index 777e16455..16bf4edce 100644 --- a/packages/hdwallet-coinbase/src/ethereum.ts +++ b/packages/hdwallet-coinbase/src/ethereum.ts @@ -1,6 +1,6 @@ import * as core from "@shapeshiftoss/hdwallet-core"; import { ETHSignedMessage } from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import { isHexString } from "ethers/lib/utils"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { return core.describeETHPath(path); @@ -86,12 +86,10 @@ export async function ethSignMessage( address: string ): Promise { try { - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", - params: [buffer.toString("hex"), address], + params: [msg, address], }); return { diff --git a/packages/hdwallet-core/package.json b/packages/hdwallet-core/package.json index 9ad95c3fd..616121985 100644 --- a/packages/hdwallet-core/package.json +++ b/packages/hdwallet-core/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-core", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/hdwallet-core/src/ethereum.ts b/packages/hdwallet-core/src/ethereum.ts index fbc5a79b4..004fe56bb 100644 --- a/packages/hdwallet-core/src/ethereum.ts +++ b/packages/hdwallet-core/src/ethereum.ts @@ -94,7 +94,7 @@ export interface ETHSignedTx { export interface ETHSignMessage { addressNList: BIP32Path; - message: string | Bytes; + message: string; } export interface ETHSignedMessage { diff --git a/packages/hdwallet-keepkey-chromeusb/package.json b/packages/hdwallet-keepkey-chromeusb/package.json index 8db84132e..f515c2ab0 100644 --- a/packages/hdwallet-keepkey-chromeusb/package.json +++ b/packages/hdwallet-keepkey-chromeusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-chromeusb", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey": "1.50.10" + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0" } } diff --git a/packages/hdwallet-keepkey-electron/package.json b/packages/hdwallet-keepkey-electron/package.json index 00d688d0f..2396224e5 100644 --- a/packages/hdwallet-keepkey-electron/package.json +++ b/packages/hdwallet-keepkey-electron/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-electron", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-keepkey": "1.50.10", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0", "uuid": "^8.3.2" }, "peerDependencies": { diff --git a/packages/hdwallet-keepkey-nodehid/package.json b/packages/hdwallet-keepkey-nodehid/package.json index 91bead463..11cee6fc6 100644 --- a/packages/hdwallet-keepkey-nodehid/package.json +++ b/packages/hdwallet-keepkey-nodehid/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-nodehid", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-keepkey": "1.50.10" + "@shapeshiftoss/hdwallet-keepkey": "1.51.0" }, "peerDependencies": { "node-hid": "^2.1.1" diff --git a/packages/hdwallet-keepkey-nodewebusb/package.json b/packages/hdwallet-keepkey-nodewebusb/package.json index 25e88d8fd..318c44c43 100644 --- a/packages/hdwallet-keepkey-nodewebusb/package.json +++ b/packages/hdwallet-keepkey-nodewebusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-nodewebusb", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey": "1.50.10" + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0" }, "peerDependencies": { "usb": "^2.3.1" diff --git a/packages/hdwallet-keepkey-tcp/package.json b/packages/hdwallet-keepkey-tcp/package.json index 5cbd9325b..5a51868cf 100644 --- a/packages/hdwallet-keepkey-tcp/package.json +++ b/packages/hdwallet-keepkey-tcp/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-tcp", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0", "axios": "^0.21.1" } } diff --git a/packages/hdwallet-keepkey-webusb/package.json b/packages/hdwallet-keepkey-webusb/package.json index 218c5276c..082fbdd8a 100644 --- a/packages/hdwallet-keepkey-webusb/package.json +++ b/packages/hdwallet-keepkey-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-webusb", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-keepkey": "1.50.10" + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-keepkey": "1.51.0" }, "devDependencies": { "@types/w3c-web-usb": "^1.0.4" diff --git a/packages/hdwallet-keepkey/package.json b/packages/hdwallet-keepkey/package.json index a9bcf686a..2f1cb1707 100644 --- a/packages/hdwallet-keepkey/package.json +++ b/packages/hdwallet-keepkey/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -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.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "bignumber.js": "^9.0.1", "bnb-javascript-sdk-nobroadcast": "^2.16.14", diff --git a/packages/hdwallet-keepkey/src/ethereum.ts b/packages/hdwallet-keepkey/src/ethereum.ts index 08daccb99..4c2d0ddd4 100644 --- a/packages/hdwallet-keepkey/src/ethereum.ts +++ b/packages/hdwallet-keepkey/src/ethereum.ts @@ -173,12 +173,10 @@ export async function ethGetAddress(transport: Transport, msg: core.ETHGetAddres export async function ethSignMessage(transport: Transport, msg: core.ETHSignMessage): Promise { const { addressNList, message } = msg; + if (!ethers.utils.isHexString(message)) throw new Error("data is not an hex string"); const m = new Ethereum.EthereumSignMessage(); m.setAddressNList(addressNList); - const messageBytes = - typeof message === "string" && !ethers.utils.isHexString(message) - ? ethers.utils.toUtf8Bytes(message) - : ethers.utils.arrayify(message); + const messageBytes = ethers.utils.arrayify(message); m.setMessage(messageBytes); const response = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUMSIGNMESSAGE, m, { msgTimeout: core.LONG_TIMEOUT, diff --git a/packages/hdwallet-keplr/package.json b/packages/hdwallet-keplr/package.json index 6711cbaf1..f7e0f1e12 100644 --- a/packages/hdwallet-keplr/package.json +++ b/packages/hdwallet-keplr/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keplr", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@shapeshiftoss/caip": "8.15.0", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "@shapeshiftoss/types": "3.1.3", "base64-js": "^1.5.1", diff --git a/packages/hdwallet-ledger-webhid/package.json b/packages/hdwallet-ledger-webhid/package.json index 8c0fb7352..6c8a0969f 100644 --- a/packages/hdwallet-ledger-webhid/package.json +++ b/packages/hdwallet-ledger-webhid/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger-webhid", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -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.50.10", - "@shapeshiftoss/hdwallet-ledger": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-ledger": "1.51.0", "@types/w3c-web-hid": "^1.0.2" }, "devDependencies": { diff --git a/packages/hdwallet-ledger-webusb/package.json b/packages/hdwallet-ledger-webusb/package.json index 560d40c26..0b7139b2e 100644 --- a/packages/hdwallet-ledger-webusb/package.json +++ b/packages/hdwallet-ledger-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger-webusb", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -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.50.10", - "@shapeshiftoss/hdwallet-ledger": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-ledger": "1.51.0", "@types/w3c-web-usb": "^1.0.4", "p-queue": "^7.4.1" }, diff --git a/packages/hdwallet-ledger/package.json b/packages/hdwallet-ledger/package.json index d3a96d4ad..c92a72993 100644 --- a/packages/hdwallet-ledger/package.json +++ b/packages/hdwallet-ledger/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -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.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "base64-js": "^1.5.1", "bchaddrjs": "^0.4.4", "bitcoinjs-message": "^2.0.0", diff --git a/packages/hdwallet-ledger/src/ethereum.ts b/packages/hdwallet-ledger/src/ethereum.ts index 73e61655b..5d2dc0045 100644 --- a/packages/hdwallet-ledger/src/ethereum.ts +++ b/packages/hdwallet-ledger/src/ethereum.ts @@ -7,6 +7,7 @@ import EthereumTx from "ethereumjs-tx"; // TODO: fix ts-ignore import * as ethereumUtil from "ethereumjs-util"; import * as ethers from "ethers"; +import { isHexString } from "ethjs-util"; import { LedgerTransport } from "./transport"; import { compressPublicKey, createXpub, handleError, networksUtil } from "./utils"; @@ -155,10 +156,8 @@ export async function ethSignMessage( ): Promise { const bip32path = core.addressNListToBIP32(msg.addressNList); - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); - const res = await transport.call("Eth", "signPersonalMessage", bip32path, buffer.toString("hex")); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + const res = await transport.call("Eth", "signPersonalMessage", bip32path, msg.message); handleError(res, transport, "Could not sign ETH message with Ledger"); let { v } = res.payload; diff --git a/packages/hdwallet-metamask-shapeshift-multichain/package.json b/packages/hdwallet-metamask-shapeshift-multichain/package.json index 76d683ef1..7a6bf8455 100644 --- a/packages/hdwallet-metamask-shapeshift-multichain/package.json +++ b/packages/hdwallet-metamask-shapeshift-multichain/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-shapeshift-multichain", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -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.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@shapeshiftoss/metamask-snaps-adapter": "^1.0.6", "@shapeshiftoss/metamask-snaps-types": "^1.0.6", "eth-rpc-errors": "^4.0.3", diff --git a/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts b/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts index 923f6e3d4..558df86f5 100644 --- a/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts +++ b/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts @@ -1,6 +1,6 @@ import * as core from "@shapeshiftoss/hdwallet-core"; import { ETHSignedMessage } from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import { isHexString } from "ethers/lib/utils"; // eslint-disable-next-line @typescript-eslint/no-unused-vars export async function ethVerifyMessage(msg: core.ETHVerifyMessage, ethereum: any): Promise { @@ -71,12 +71,10 @@ export async function ethSignMessage( address: string ): Promise { try { - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", - params: [buffer.toString("hex"), address], + params: [msg.message, address], }); return { diff --git a/packages/hdwallet-metamask-shapeshift-multichain/src/shapeshift-multichain.test.ts b/packages/hdwallet-metamask-shapeshift-multichain/src/shapeshift-multichain.test.ts index 5a58773d1..3f3044fd3 100644 --- a/packages/hdwallet-metamask-shapeshift-multichain/src/shapeshift-multichain.test.ts +++ b/packages/hdwallet-metamask-shapeshift-multichain/src/shapeshift-multichain.test.ts @@ -53,7 +53,7 @@ describe("MetaMaskShapeShiftMultiChainHDWallet", () => { }` ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -75,7 +75,7 @@ describe("MetaMaskShapeShiftMultiChainHDWallet", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, @@ -89,7 +89,7 @@ describe("MetaMaskShapeShiftMultiChainHDWallet", () => { request: jest.fn().mockReturnValue(["0x73d0385F4d8E00C5e6504C6030F47BF6212736A8"]), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, diff --git a/packages/hdwallet-metamask/package.json b/packages/hdwallet-metamask/package.json index 5cd53a5e8..db9dc59ac 100644 --- a/packages/hdwallet-metamask/package.json +++ b/packages/hdwallet-metamask/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-metamask", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -16,7 +16,7 @@ "dependencies": { "@metamask/detect-provider": "^1.2.0", "@metamask/onboarding": "^1.0.1", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "eth-rpc-errors": "^4.0.3", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-metamask/src/ethereum.ts b/packages/hdwallet-metamask/src/ethereum.ts index e9c1378ae..3a6734e84 100644 --- a/packages/hdwallet-metamask/src/ethereum.ts +++ b/packages/hdwallet-metamask/src/ethereum.ts @@ -1,6 +1,6 @@ import * as core from "@shapeshiftoss/hdwallet-core"; import { ETHSignedMessage } from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import { isHexString } from "ethers/lib/utils"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -101,12 +101,10 @@ export async function ethSignMessage( address: string ): Promise { try { - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", - params: [buffer.toString("hex"), address], + params: [msg.message, address], }); return { diff --git a/packages/hdwallet-metamask/src/metamask.test.ts b/packages/hdwallet-metamask/src/metamask.test.ts index b2beddb30..05da66e19 100644 --- a/packages/hdwallet-metamask/src/metamask.test.ts +++ b/packages/hdwallet-metamask/src/metamask.test.ts @@ -51,7 +51,7 @@ describe("MetaMaskHDWallet", () => { }` ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -73,7 +73,7 @@ describe("MetaMaskHDWallet", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, @@ -87,7 +87,7 @@ describe("MetaMaskHDWallet", () => { request: jest.fn().mockReturnValue(["0x73d0385F4d8E00C5e6504C6030F47BF6212736A8"]), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, diff --git a/packages/hdwallet-native-vault/package.json b/packages/hdwallet-native-vault/package.json index 38d19caba..c58acc0f6 100644 --- a/packages/hdwallet-native-vault/package.json +++ b/packages/hdwallet-native-vault/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-native-vault", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-native": "1.50.10", + "@shapeshiftoss/hdwallet-native": "1.51.0", "bip39": "^3.0.4", "hash-wasm": "^4.9.0", "idb-keyval": "^6.0.3", diff --git a/packages/hdwallet-native/package.json b/packages/hdwallet-native/package.json index 561dfb801..533a3933d 100644 --- a/packages/hdwallet-native/package.json +++ b/packages/hdwallet-native/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-native", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -16,7 +16,7 @@ "dependencies": { "@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2", "@shapeshiftoss/fiosdk": "1.2.1-shapeshift.6", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "@zxing/text-encoding": "^0.9.0", "bchaddrjs": "^0.4.9", diff --git a/packages/hdwallet-native/src/ethereum.test.ts b/packages/hdwallet-native/src/ethereum.test.ts index 3847ea5a8..224278c6a 100644 --- a/packages/hdwallet-native/src/ethereum.test.ts +++ b/packages/hdwallet-native/src/ethereum.test.ts @@ -182,7 +182,7 @@ describe("NativeETHWallet", () => { describe("sign and verify message", () => { it("should handle a utf8 message", async () => { - const message = "super secret message"; + const message = "0x737570657220736563726574206d657373616765"; // super secret message const result = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message, @@ -233,7 +233,7 @@ describe("NativeETHWallet", () => { }); it("should handle a byte message", async () => { - const message = ethers.utils.arrayify("0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea"); + const message = "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea"; const result = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message, @@ -250,10 +250,11 @@ describe("NativeETHWallet", () => { }); it("should pass verification of a message signed with a different format", async () => { + const message = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethVerifyMessage({ address: "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", - message: "super secret message", + message, signature: "0x72d4baca0c1ca0eea587decb0177ded99fb50f62c4bd24d8595000d70e6383833eb0700fb6c96086154c2607b735ee1047ed4060211b32a52b43d827615b3e691c", }) @@ -272,10 +273,11 @@ describe("NativeETHWallet", () => { }); it("should fail verification if the signature is invalid", async () => { + const message = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethVerifyMessage({ address: "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", - message: "super secret message", + message, signature: "deadbeef16d6fbc19fb9db81f32dd22cb67570b93b1c0e64ae30a4c2bc0b9c265c2d0f86906610d0cecac42ab90ee298a3474a5eb6d895aa7279d344f32aab191b", }) diff --git a/packages/hdwallet-portis/package.json b/packages/hdwallet-portis/package.json index d57717f8b..301c5a48e 100644 --- a/packages/hdwallet-portis/package.json +++ b/packages/hdwallet-portis/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-portis", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@portis/web3": "3.0.10", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "base64-js": "^1.5.1", "bip32": "^2.0.4", "bitcoinjs-lib": "^5.1.6", diff --git a/packages/hdwallet-portis/src/ethereum.ts b/packages/hdwallet-portis/src/ethereum.ts index 09b77a9bf..449adbe22 100644 --- a/packages/hdwallet-portis/src/ethereum.ts +++ b/packages/hdwallet-portis/src/ethereum.ts @@ -1,4 +1,5 @@ import * as core from "@shapeshiftoss/hdwallet-core"; +import { isHexString } from "ethers/lib/utils"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -71,6 +72,7 @@ export async function ethSignMessage( web3: any, address: string ): Promise { + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const result = await web3.eth.sign(msg.message, address); return { address, diff --git a/packages/hdwallet-tallyho/package.json b/packages/hdwallet-tallyho/package.json index 1f4c26986..52094c2c5 100644 --- a/packages/hdwallet-tallyho/package.json +++ b/packages/hdwallet-tallyho/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-tallyho", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "lodash": "^4.17.21", "tallyho-onboarding": "^1.0.2" }, diff --git a/packages/hdwallet-tallyho/src/ethereum.test.ts b/packages/hdwallet-tallyho/src/ethereum.test.ts index 2753672c5..99d465539 100644 --- a/packages/hdwallet-tallyho/src/ethereum.test.ts +++ b/packages/hdwallet-tallyho/src/ethereum.test.ts @@ -139,7 +139,7 @@ describe("Tally Ho - Ethereum Adapter", () => { ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -170,9 +170,7 @@ describe("Tally Ho - Ethereum Adapter", () => { ), }; - const msg: ethers.Bytes = ethers.utils.arrayify( - "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea" - ); + const msg = "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea"; const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -183,14 +181,14 @@ describe("Tally Ho - Ethereum Adapter", () => { ); expect(ethereumProvider.request.mock.calls[0][0]).toMatchInlineSnapshot(` - Object { - "method": "personal_sign", - "params": Array [ - "cf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea", - "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", - ], - } - `); + Object { + "method": "personal_sign", + "params": Array [ + "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea", + "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", + ], + } + `); expect(sig).toMatchInlineSnapshot(` Object { "address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", @@ -207,7 +205,7 @@ describe("Tally Ho - Ethereum Adapter", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), diff --git a/packages/hdwallet-tallyho/src/ethereum.ts b/packages/hdwallet-tallyho/src/ethereum.ts index 7dbbf8fe4..cc264ec7c 100644 --- a/packages/hdwallet-tallyho/src/ethereum.ts +++ b/packages/hdwallet-tallyho/src/ethereum.ts @@ -1,5 +1,5 @@ import * as core from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import { isHexString } from "ethers/lib/utils"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -100,12 +100,10 @@ export async function ethSignMessage( address: string ): Promise { try { - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", - params: [buffer.toString("hex"), address], + params: [msg.message, address], }); return { diff --git a/packages/hdwallet-tallyho/src/tallyho.test.ts b/packages/hdwallet-tallyho/src/tallyho.test.ts index 56ae7e227..4c4b3b729 100644 --- a/packages/hdwallet-tallyho/src/tallyho.test.ts +++ b/packages/hdwallet-tallyho/src/tallyho.test.ts @@ -86,7 +86,7 @@ describe("TallyHoHDWallet", () => { }` ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -108,7 +108,7 @@ describe("TallyHoHDWallet", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, @@ -122,7 +122,7 @@ describe("TallyHoHDWallet", () => { request: jest.fn().mockReturnValue(["0x73d0385F4d8E00C5e6504C6030F47BF6212736A8"]), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, diff --git a/packages/hdwallet-trezor-connect/package.json b/packages/hdwallet-trezor-connect/package.json index 995610532..8f524c0b4 100644 --- a/packages/hdwallet-trezor-connect/package.json +++ b/packages/hdwallet-trezor-connect/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-trezor-connect", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", - "@shapeshiftoss/hdwallet-trezor": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", + "@shapeshiftoss/hdwallet-trezor": "1.51.0", "@trezor/rollout": "^1.2.0", "trezor-connect": "^8.2.1" } diff --git a/packages/hdwallet-trezor/package.json b/packages/hdwallet-trezor/package.json index 139fc5076..985a2d224 100644 --- a/packages/hdwallet-trezor/package.json +++ b/packages/hdwallet-trezor/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-trezor", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -17,7 +17,7 @@ "dependencies": { "@ethereumjs/common": "^2.4.0", "@ethereumjs/tx": "^3.3.0", - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "base64-js": "^1.5.1", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-trezor/src/ethereum.ts b/packages/hdwallet-trezor/src/ethereum.ts index 11d97d163..cf8a99667 100644 --- a/packages/hdwallet-trezor/src/ethereum.ts +++ b/packages/hdwallet-trezor/src/ethereum.ts @@ -1,6 +1,7 @@ import Common from "@ethereumjs/common"; import { Transaction } from "@ethereumjs/tx"; import * as core from "@shapeshiftoss/hdwallet-core"; +import { isHexString } from "ethers/lib/utils"; import { TrezorTransport } from "./transport"; import { handleError } from "./utils"; @@ -73,6 +74,7 @@ export async function ethSignMessage( transport: TrezorTransport, msg: core.ETHSignMessage ): Promise { + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const res = await transport.call("ethereumSignMessage", { path: msg.addressNList, message: msg.message, diff --git a/packages/hdwallet-walletconnect/package.json b/packages/hdwallet-walletconnect/package.json index f33c71ddd..ae3fb5617 100644 --- a/packages/hdwallet-walletconnect/package.json +++ b/packages/hdwallet-walletconnect/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-walletconnect", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@walletconnect/qrcode-modal": "^1.7.8", "@walletconnect/web3-provider": "^1.7.8", "ethers": "^5.6.5" diff --git a/packages/hdwallet-walletconnect/src/ethereum.ts b/packages/hdwallet-walletconnect/src/ethereum.ts index af310ebf7..4c32a1807 100644 --- a/packages/hdwallet-walletconnect/src/ethereum.ts +++ b/packages/hdwallet-walletconnect/src/ethereum.ts @@ -1,5 +1,6 @@ import * as core from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import type { Bytes } from "ethers"; +import { isHexString } from "ethers/lib/utils"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -51,13 +52,11 @@ export async function ethSendTx( } export async function ethSignMessage( - args: { data: string | ethers.Bytes; fromAddress: string }, + args: { data: string | Bytes; fromAddress: string }, provider: any ): Promise { - const buffer = ethers.utils.isBytes(args.data) - ? Buffer.from(ethers.utils.arrayify(args.data)) - : Buffer.from(args.data); - return await provider.wc.signMessage([buffer.toString("hex"), args.fromAddress]); + if (!isHexString(args.data)) throw new Error("data is not an hex string"); + return await provider.wc.signMessage([args.data, args.fromAddress]); } export async function ethGetAddress(provider: any): Promise { diff --git a/packages/hdwallet-walletconnectV2/package.json b/packages/hdwallet-walletconnectV2/package.json index 1b022cf6b..0d558bf3d 100644 --- a/packages/hdwallet-walletconnectV2/package.json +++ b/packages/hdwallet-walletconnectV2/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-walletconnectv2", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "@walletconnect/ethereum-provider": "^2.10.1", "@walletconnect/modal": "^2.6.2", "ethers": "^5.6.5" diff --git a/packages/hdwallet-walletconnectV2/src/ethereum.ts b/packages/hdwallet-walletconnectV2/src/ethereum.ts index f14795591..1875f3147 100644 --- a/packages/hdwallet-walletconnectV2/src/ethereum.ts +++ b/packages/hdwallet-walletconnectV2/src/ethereum.ts @@ -9,8 +9,7 @@ import type { } from "@shapeshiftoss/hdwallet-core"; import { addressNListToBIP32, slip44ByCoin } from "@shapeshiftoss/hdwallet-core"; import EthereumProvider from "@walletconnect/ethereum-provider"; -import type { Bytes } from "ethers"; -import { arrayify, isBytes } from "ethers/lib/utils"; +import { isHexString } from "ethers/lib/utils"; const getUnsignedTxFromMessage = (msg: ETHSignTx & { from: string }) => { const utxBase = { @@ -84,14 +83,14 @@ export async function ethSendTx( } export async function ethSignMessage( - args: { data: string | Bytes; fromAddress: string }, + args: { data: string; fromAddress: string }, provider: EthereumProvider ): Promise { - const buffer = isBytes(args.data) ? Buffer.from(arrayify(args.data)) : Buffer.from(args.data); + if (!isHexString(args.data)) throw new Error("data is not an hex string"); const signedMsg: string = await provider.request({ method: "personal_sign", - params: [buffer.toString("hex"), args.fromAddress], + params: [args.data, args.fromAddress], }); return { diff --git a/packages/hdwallet-xdefi/package.json b/packages/hdwallet-xdefi/package.json index 70534161a..d82b69864 100644 --- a/packages/hdwallet-xdefi/package.json +++ b/packages/hdwallet-xdefi/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-xdefi", - "version": "1.50.10", + "version": "1.51.0", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.50.10", + "@shapeshiftoss/hdwallet-core": "1.51.0", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/hdwallet-xdefi/src/ethereum.test.ts b/packages/hdwallet-xdefi/src/ethereum.test.ts index 936103157..1643c591f 100644 --- a/packages/hdwallet-xdefi/src/ethereum.test.ts +++ b/packages/hdwallet-xdefi/src/ethereum.test.ts @@ -146,9 +146,8 @@ describe("XDEFI - Ethereum Adapter", () => { ), }; - const msg: ethers.Bytes = ethers.utils.arrayify( - "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea" - ); + const msg = "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea"; + const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -159,14 +158,14 @@ describe("XDEFI - Ethereum Adapter", () => { ); expect(ethereumProvider.request.mock.calls[0][0]).toMatchInlineSnapshot(` - Object { - "method": "personal_sign", - "params": Array [ - "cf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea", - "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", - ], - } - `); + Object { + "method": "personal_sign", + "params": Array [ + "0xcf8746d5aa75ecfd907eb3cae0aecf7f698a8bfe1f97eb2d77d6539e8991b0ea", + "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8", + ], + } + `); expect(sig).toMatchInlineSnapshot(` Object { @@ -189,7 +188,7 @@ describe("XDEFI - Ethereum Adapter", () => { ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -215,7 +214,7 @@ describe("XDEFI - Ethereum Adapter", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await ethereum.ethSignMessage( { addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), diff --git a/packages/hdwallet-xdefi/src/ethereum.ts b/packages/hdwallet-xdefi/src/ethereum.ts index e8a1ea27d..43ed76973 100644 --- a/packages/hdwallet-xdefi/src/ethereum.ts +++ b/packages/hdwallet-xdefi/src/ethereum.ts @@ -1,6 +1,6 @@ import * as core from "@shapeshiftoss/hdwallet-core"; import { ETHSignedMessage } from "@shapeshiftoss/hdwallet-core"; -import * as ethers from "ethers"; +import { isHexString } from "ethers/lib/utils"; export async function ethVerifyMessage(msg: core.ETHVerifyMessage, ethereum: any): Promise { const recoveredAddress = await ethereum.request({ @@ -72,12 +72,10 @@ export async function ethSignMessage( address: string ): Promise { try { - const buffer = ethers.utils.isBytes(msg.message) - ? Buffer.from(ethers.utils.arrayify(msg.message)) - : Buffer.from(msg.message); + if (!isHexString(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", - params: [buffer.toString("hex"), address], + params: [msg.message, address], }); return { diff --git a/packages/hdwallet-xdefi/src/xdefi.test.ts b/packages/hdwallet-xdefi/src/xdefi.test.ts index d0dd4c59b..fa73a160c 100644 --- a/packages/hdwallet-xdefi/src/xdefi.test.ts +++ b/packages/hdwallet-xdefi/src/xdefi.test.ts @@ -93,7 +93,7 @@ describe("XDEFIHDWallet", () => { }` ), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message expect( await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), @@ -115,7 +115,7 @@ describe("XDEFIHDWallet", () => { request: jest.fn().mockRejectedValue(new Error("An Error has occurred")), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg, @@ -129,7 +129,7 @@ describe("XDEFIHDWallet", () => { request: jest.fn().mockReturnValue(["0x73d0385F4d8E00C5e6504C6030F47BF6212736A8"]), }; - const msg = "super secret message"; + const msg = "0x737570657220736563726574206d657373616765"; // super secret message const sig = await wallet.ethSignMessage({ addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), message: msg,