@toruslabs/ethereum-controllers 5.5.0 → 5.5.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "5.5.0",
3
+ "version": "5.5.2",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "main": "dist/ethereumControllers.cjs.js",
@@ -24,7 +24,7 @@
24
24
  "@ethereumjs/util": "^9.0.2",
25
25
  "@metamask/eth-sig-util": "^7.0.1",
26
26
  "@metamask/rpc-errors": "^6.1.0",
27
- "@toruslabs/base-controllers": "^5.5.0",
27
+ "@toruslabs/base-controllers": "^5.5.1",
28
28
  "@toruslabs/http-helpers": "^6.0.0",
29
29
  "@toruslabs/openlogin-jrpc": "^7.0.0",
30
30
  "async-mutex": "^0.4.1",
@@ -64,7 +64,7 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "bf6f09bf4354a511adf6f8fbb5eea94ddddcdb40",
67
+ "gitHead": "ba6a8e2124bfe47b5d75a27cda6492a46e09d59d",
68
68
  "devDependencies": {
69
69
  "@nomicfoundation/hardhat-toolbox": "^4.0.0",
70
70
  "hardhat": "^2.19.5"
@@ -1,5 +1,5 @@
1
1
  import { BaseBlockTracker, PollingBlockTrackerConfig, timeout } from "@toruslabs/base-controllers";
2
- import { BlockParams } from "ethers";
2
+ import { type BlockParams } from "ethers";
3
3
  import log from "loglevel";
4
4
 
5
5
  import { idleTimeTracker } from "../utils/helpers";
@@ -1,5 +1,5 @@
1
1
  import { TypedTransaction } from "@ethereumjs/tx";
2
- import { addHexPrefix, bigIntToBytes, ecsign, stripHexPrefix } from "@ethereumjs/util";
2
+ import { bigIntToBytes, bytesToHex, ecsign, privateToAddress, privateToPublic, stripHexPrefix } from "@ethereumjs/util";
3
3
  import {
4
4
  concatSig,
5
5
  decrypt,
@@ -13,7 +13,6 @@ import {
13
13
  TypedMessage,
14
14
  } from "@metamask/eth-sig-util";
15
15
  import { BaseConfig, BaseKeyringController, IKeyringController, KeyringControllerState } from "@toruslabs/base-controllers";
16
- import { SigningKey, Wallet } from "ethers";
17
16
 
18
17
  export default class KeyringController extends BaseKeyringController<Partial<BaseConfig>, KeyringControllerState> implements IKeyringController {
19
18
  constructor({ config, state }: { config: Partial<BaseConfig>; state: Partial<KeyringControllerState> }) {
@@ -36,10 +35,10 @@ export default class KeyringController extends BaseKeyringController<Partial<Bas
36
35
  }
37
36
 
38
37
  importAccount(accountPrivateKey: string): string {
39
- const hexPrivateKey = addHexPrefix(accountPrivateKey);
40
- const signingKey = new SigningKey(hexPrivateKey);
41
- const wallet = new Wallet(signingKey.privateKey);
42
- const { address } = wallet;
38
+ const hexPrivateKey = accountPrivateKey.padStart(64, "0");
39
+ const bufferPrivKey = Buffer.from(hexPrivateKey, "hex");
40
+ const publicKey = bytesToHex(privateToPublic(bufferPrivKey));
41
+ const address = bytesToHex(privateToAddress(bufferPrivKey));
43
42
 
44
43
  const existingWallet = this.state.wallets.find((w) => w.address === address);
45
44
  if (existingWallet) return existingWallet.address;
@@ -48,7 +47,7 @@ export default class KeyringController extends BaseKeyringController<Partial<Bas
48
47
  wallets: [
49
48
  ...this.state.wallets,
50
49
  {
51
- publicKey: signingKey.publicKey,
50
+ publicKey,
52
51
  privateKey: accountPrivateKey,
53
52
  address,
54
53
  },
@@ -34,7 +34,7 @@ export class AddChainController extends AbstractMessageController<AddChainMessag
34
34
  try {
35
35
  const msgObject = this.getMessage(messageId);
36
36
  await this.approveMessage(messageId, msgObject.messageParams);
37
- this.addChain(msgObject.messageParams);
37
+ await this.addChain(msgObject.messageParams);
38
38
  this.updateMessage({ ...msgObject, rawSig: JSON.stringify(msgObject.messageParams) });
39
39
  this.setMessageStatus(messageId, MessageStatus.SIGNED);
40
40
  return null;