Skip to content

Commit

Permalink
Fixed message signing errors that clobbered critical Error properties (
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Sep 14, 2022
1 parent 4c86dc9 commit b14cb0f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/providers/src.ts/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,14 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
async signMessage(message: Bytes | string): Promise<string> {
const data = ((typeof(message) === "string") ? toUtf8Bytes(message): message);
const address = await this.getAddress();


try {
return await this.provider.send("personal_sign", [ hexlify(data), address.toLowerCase() ]);
} catch (error) {
if (typeof(error.message) === "string" && error.message.match(/user denied/i)) {
logger.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, {
action: "signMessage",
from: address,
message: data
messageData: message
});
}
throw error;
Expand All @@ -326,7 +324,7 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
logger.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, {
action: "_legacySignMessage",
from: address,
message: data
messageData: message
});
}
throw error;
Expand All @@ -351,7 +349,7 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
logger.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, {
action: "_signTypedData",
from: address,
message: { domain: populated.domain, types, value: populated.value }
messageData: { domain: populated.domain, types, value: populated.value }
});
}
throw error;
Expand Down

0 comments on commit b14cb0f

Please sign in to comment.