Skip to content

Commit

Permalink
Add support for Wallet private keys without 0x prefix (#3768).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Feb 18, 2023
1 parent b1bb693 commit 4665fb4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src.ts/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class Wallet extends BaseWallet {
* to %%provider%%.
*/
constructor(key: string | SigningKey, provider?: null | Provider) {
if (typeof(key) === "string" && !key.startsWith("0x")) {
key = "0x" + key;
}

let signingKey = (typeof(key) === "string") ? new SigningKey(key): key;
super(signingKey, provider);
}
Expand Down

0 comments on commit 4665fb4

Please sign in to comment.