diff --git a/src/ethereum/EthereumEngine.ts b/src/ethereum/EthereumEngine.ts index 4e9f667cb..19997425d 100644 --- a/src/ethereum/EthereumEngine.ts +++ b/src/ethereum/EthereumEngine.ts @@ -8,7 +8,6 @@ import { EdgeCurrencyInfo, EdgeFetchFunction, EdgeFreshAddress, - EdgeSignBytesOptions, EdgeSignMessageOptions, EdgeSpendInfo, EdgeSpendTarget, @@ -144,27 +143,6 @@ export class EthereumEngine extends CurrencyEngine< ] this.utils = { - signBytes: (bytes: Uint8Array, privateKeys: EthereumPrivateKeys) => { - const privKey = Buffer.from(privateKeys.privateKey, 'hex') - const bufferHash = EthereumUtil.hashPersonalMessage(bytes) - const { v, r, s } = EthereumUtil.ecsign(bufferHash, privKey) - - return EthereumUtil.toRpcSig(v, r, s) - }, - - signMessage: (message: string, privateKeys: EthereumPrivateKeys) => { - if (!isHex(message)) - throw new Error( - 'EthereumEngine: signMessage() requires a hex message parameter' - ) - const privKey = Buffer.from(privateKeys.privateKey, 'hex') - const messageBuffer = hexToBuf(message) - const messageHash = EthereumUtil.hashPersonalMessage(messageBuffer) - const { v, r, s } = EthereumUtil.ecsign(messageHash, privKey) - - return EthereumUtil.toRpcSig(v, r, s) - }, - signTypedData: ( typedData: EIP712TypedDataParam, privateKeys: EthereumPrivateKeys @@ -1225,18 +1203,29 @@ export class EthereumEngine extends CurrencyEngine< } } - return this.utils.signMessage(message, ethereumPrivateKeys) + if (!isHex(message)) + throw new Error( + 'EthereumEngine: signMessage() requires a hex message parameter' + ) + + const privKey = Buffer.from(privateKeys.privateKey, 'hex') + const messageBuffer = hexToBuf(message) + const messageHash = EthereumUtil.hashPersonalMessage(messageBuffer) + const { v, r, s } = EthereumUtil.ecsign(messageHash, privKey) + + return EthereumUtil.toRpcSig(v, r, s) } - async signBytes( - bytes: Uint8Array, - privateKeys: JsonObject, - opts: EdgeSignBytesOptions - ): Promise { + async signBytes(bytes: Uint8Array, privateKeys: JsonObject): Promise { const ethereumPrivateKeys = asEthereumPrivateKeys( this.currencyInfo.pluginId )(privateKeys) - return this.utils.signBytes(bytes, ethereumPrivateKeys) + + const privKey = Buffer.from(ethereumPrivateKeys.privateKey, 'hex') + const bufferHash = EthereumUtil.hashPersonalMessage(bytes) + const { v, r, s } = EthereumUtil.ecsign(bufferHash, privKey) + + return EthereumUtil.toRpcSig(v, r, s) } async signTx( diff --git a/src/ethereum/ethereumTypes.ts b/src/ethereum/ethereumTypes.ts index 634d4c7ab..b9f9e5971 100644 --- a/src/ethereum/ethereumTypes.ts +++ b/src/ethereum/ethereumTypes.ts @@ -431,8 +431,6 @@ export interface EIP712TypedDataParam { } export interface EthereumUtils { - signMessage: (message: string, privateKeys: EthereumPrivateKeys) => string - signBytes: (bytes: Uint8Array, privateKeys: EthereumPrivateKeys) => string signTypedData: ( typedData: EIP712TypedDataParam, privateKeys: EthereumPrivateKeys