diff --git a/packages/hdwallet-coinbase/src/ethereum.ts b/packages/hdwallet-coinbase/src/ethereum.ts index 348ce50e3..6337ec8a8 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 { isHexString } from "ethers"; +import { isHex } from "viem"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { return core.describeETHPath(path); @@ -86,7 +86,7 @@ export async function ethSignMessage( address: string ): Promise { try { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", params: [msg, address], diff --git a/packages/hdwallet-keepkey/src/ethereum.ts b/packages/hdwallet-keepkey/src/ethereum.ts index 64edd804f..989e1cfbb 100644 --- a/packages/hdwallet-keepkey/src/ethereum.ts +++ b/packages/hdwallet-keepkey/src/ethereum.ts @@ -6,7 +6,8 @@ import * as Types from "@keepkey/device-protocol/lib/types_pb"; import { SignTypedDataVersion, TypedDataUtils } from "@metamask/eth-sig-util"; import * as core from "@shapeshiftoss/hdwallet-core"; import * as eip55 from "eip55"; -import { getBytes, isBytesLike, isHexString } from "ethers"; +import { getBytes, isBytesLike } from "ethers"; +import { isHex } from "viem"; import { Transport } from "./transport"; import { toUTF8Array } from "./utils"; @@ -173,7 +174,7 @@ export async function ethGetAddress(transport: Transport, msg: core.ETHGetAddres export async function ethSignMessage(transport: Transport, msg: core.ETHSignMessage): Promise { const { addressNList, message } = msg; - if (!isHexString(message)) throw new Error("data is not an hex string"); + if (!isHex(message)) throw new Error("data is not an hex string"); const m = new Ethereum.EthereumSignMessage(); m.setAddressNList(addressNList); const messageBytes = getBytes(message); diff --git a/packages/hdwallet-ledger/src/ethereum.ts b/packages/hdwallet-ledger/src/ethereum.ts index 10a481b24..9fc16b17c 100644 --- a/packages/hdwallet-ledger/src/ethereum.ts +++ b/packages/hdwallet-ledger/src/ethereum.ts @@ -7,7 +7,7 @@ import EthereumTx from "ethereumjs-tx"; // TODO: fix ts-ignore import * as ethereumUtil from "ethereumjs-util"; import { getBytes, isBytesLike } from "ethers"; -import { isHexString } from "ethjs-util"; +import { isHex } from "viem"; import { LedgerTransport } from "./transport"; import { compressPublicKey, createXpub, handleError, networksUtil } from "./utils"; @@ -159,7 +159,7 @@ export async function ethSignMessage( ): Promise { const bip32path = core.addressNListToBIP32(msg.addressNList); - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); // Ledger's inner implementation does a Buffer.from(messageHex, "hex").length on our message // However, Buffer.from method with the "hex" encoding expects a valid hexadecimal string without the 0x prefix diff --git a/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts b/packages/hdwallet-metamask-shapeshift-multichain/src/ethereum.ts index e6dd048d6..3399848a5 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 { isHexString } from "ethers"; +import { isHex } from "viem"; // eslint-disable-next-line @typescript-eslint/no-unused-vars export async function ethVerifyMessage(msg: core.ETHVerifyMessage, ethereum: any): Promise { @@ -71,7 +71,7 @@ export async function ethSignMessage( address: string ): Promise { try { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", params: [msg.message, address], diff --git a/packages/hdwallet-metamask/src/ethereum.ts b/packages/hdwallet-metamask/src/ethereum.ts index ed9f27adc..bb8285b4d 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 { isHexString } from "ethers"; +import { isHex } from "viem"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -101,7 +101,7 @@ export async function ethSignMessage( address: string ): Promise { try { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", params: [msg.message, address], diff --git a/packages/hdwallet-native/src/util.ts b/packages/hdwallet-native/src/util.ts index c19053d7d..0fcbf1cd4 100644 --- a/packages/hdwallet-native/src/util.ts +++ b/packages/hdwallet-native/src/util.ts @@ -1,6 +1,7 @@ import * as core from "@shapeshiftoss/hdwallet-core"; import type { BytesLike } from "ethers"; -import { concat, getBytes, isHexString, toUtf8Bytes } from "ethers"; +import { concat, getBytes, toUtf8Bytes } from "ethers"; +import { isHex } from "viem"; import { BTCScriptType } from "./bitcoin"; import * as Isolation from "./crypto/isolation"; @@ -19,7 +20,7 @@ export async function getKeyPair( } export function buildMessage(message: BytesLike): Uint8Array { - const messageBytes = typeof message === "string" && !isHexString(message) ? toUtf8Bytes(message) : getBytes(message); + const messageBytes = typeof message === "string" && !isHex(message) ? toUtf8Bytes(message) : getBytes(message); return getBytes( concat([toUtf8Bytes("\x19Ethereum Signed Message:\n"), toUtf8Bytes(String(messageBytes.length)), messageBytes]) diff --git a/packages/hdwallet-portis/src/ethereum.ts b/packages/hdwallet-portis/src/ethereum.ts index fd7c1cd2f..50983f111 100644 --- a/packages/hdwallet-portis/src/ethereum.ts +++ b/packages/hdwallet-portis/src/ethereum.ts @@ -1,5 +1,5 @@ import * as core from "@shapeshiftoss/hdwallet-core"; -import { isHexString } from "ethers"; +import { isHex } from "viem"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -72,7 +72,7 @@ export async function ethSignMessage( web3: any, address: string ): Promise { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(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/src/ethereum.ts b/packages/hdwallet-tallyho/src/ethereum.ts index 2b5ba0132..cb8139787 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 { isHexString } from "ethers"; +import { isHex } from "viem"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -100,7 +100,7 @@ export async function ethSignMessage( address: string ): Promise { try { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", params: [msg.message, address], diff --git a/packages/hdwallet-trezor/src/ethereum.ts b/packages/hdwallet-trezor/src/ethereum.ts index 65fb8a342..0e2f6548c 100644 --- a/packages/hdwallet-trezor/src/ethereum.ts +++ b/packages/hdwallet-trezor/src/ethereum.ts @@ -1,7 +1,7 @@ import Common from "@ethereumjs/common"; import { Transaction } from "@ethereumjs/tx"; import * as core from "@shapeshiftoss/hdwallet-core"; -import { isHexString } from "ethers"; +import { isHex } from "viem"; import { TrezorTransport } from "./transport"; import { handleError } from "./utils"; @@ -74,7 +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"); + if (!isHex(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/src/ethereum.ts b/packages/hdwallet-walletconnect/src/ethereum.ts index 1b5cab3d2..5dbb4c74f 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 { BytesLike, isHexString } from "ethers"; +import { BytesLike } from "ethers"; +import { isHex } from "viem"; export function describeETHPath(path: core.BIP32Path): core.PathDescription { const pathStr = core.addressNListToBIP32(path); @@ -54,7 +55,7 @@ export async function ethSignMessage( args: { data: BytesLike; fromAddress: string }, provider: any ): Promise { - if (!isHexString(args.data)) throw new Error("data is not an hex string"); + if (!isHex(args.data)) throw new Error("data is not an hex string"); return await provider.wc.signMessage([args.data, args.fromAddress]); } diff --git a/packages/hdwallet-walletconnectV2/src/ethereum.ts b/packages/hdwallet-walletconnectV2/src/ethereum.ts index d9e739ef3..27e35fb46 100644 --- a/packages/hdwallet-walletconnectV2/src/ethereum.ts +++ b/packages/hdwallet-walletconnectV2/src/ethereum.ts @@ -9,7 +9,7 @@ import type { } from "@shapeshiftoss/hdwallet-core"; import { addressNListToBIP32, slip44ByCoin } from "@shapeshiftoss/hdwallet-core"; import EthereumProvider from "@walletconnect/ethereum-provider"; -import { isHexString } from "ethers"; +import { isHex } from "viem"; const getUnsignedTxFromMessage = (msg: ETHSignTx & { from: string }) => { const utxBase = { @@ -86,7 +86,7 @@ export async function ethSignMessage( args: { data: string; fromAddress: string }, provider: EthereumProvider ): Promise { - if (!isHexString(args.data)) throw new Error("data is not an hex string"); + if (!isHex(args.data)) throw new Error("data is not an hex string"); const signedMsg: string = await provider.request({ method: "personal_sign", diff --git a/packages/hdwallet-xdefi/src/ethereum.ts b/packages/hdwallet-xdefi/src/ethereum.ts index 5d91e7b36..43bda921c 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 { isHexString } from "ethers"; +import { isHex } from "viem"; export async function ethVerifyMessage(msg: core.ETHVerifyMessage, ethereum: any): Promise { const recoveredAddress = await ethereum.request({ @@ -72,7 +72,7 @@ export async function ethSignMessage( address: string ): Promise { try { - if (!isHexString(msg.message)) throw new Error("data is not an hex string"); + if (!isHex(msg.message)) throw new Error("data is not an hex string"); const signedMsg = await ethereum.request({ method: "personal_sign", params: [msg.message, address],