@toruslabs/ethereum-controllers 6.0.2 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2679,7 +2679,11 @@ class KeyringController extends base_controllers_namespaceObject.BaseKeyringCont
|
|
|
2679
2679
|
async signPersonalMessage(data, address) {
|
|
2680
2680
|
const wallet = this._getWalletForAccount(address);
|
|
2681
2681
|
const privKey = new external_ethers_namespaceObject.SigningKey((0,util_namespaceObject.addHexPrefix)(wallet.privateKey));
|
|
2682
|
-
|
|
2682
|
+
// we need to check if the data is hex or not
|
|
2683
|
+
// For historical reasons, you must submit the message to sign in hex-encoded UTF-8.
|
|
2684
|
+
// https://docs.metamask.io/wallet/how-to/sign-data/#use-personal_sign
|
|
2685
|
+
const message = (0,util_namespaceObject.isHexString)(data) ? Buffer.from((0,util_namespaceObject.stripHexPrefix)(data), "hex") : Buffer.from(data);
|
|
2686
|
+
const signature = privKey.sign((0,external_ethers_namespaceObject.hashMessage)(message)).serialized;
|
|
2683
2687
|
return signature;
|
|
2684
2688
|
}
|
|
2685
2689
|
|
|
@@ -2326,7 +2326,11 @@ class KeyringController extends BaseKeyringController {
|
|
|
2326
2326
|
async signPersonalMessage(data, address) {
|
|
2327
2327
|
const wallet = this._getWalletForAccount(address);
|
|
2328
2328
|
const privKey = new SigningKey(addHexPrefix(wallet.privateKey));
|
|
2329
|
-
|
|
2329
|
+
// we need to check if the data is hex or not
|
|
2330
|
+
// For historical reasons, you must submit the message to sign in hex-encoded UTF-8.
|
|
2331
|
+
// https://docs.metamask.io/wallet/how-to/sign-data/#use-personal_sign
|
|
2332
|
+
const message = isHexString(data) ? Buffer.from(stripHexPrefix(data), "hex") : Buffer.from(data);
|
|
2333
|
+
const signature = privKey.sign(hashMessage(message)).serialized;
|
|
2330
2334
|
return signature;
|
|
2331
2335
|
}
|
|
2332
2336
|
|