From ff9ac3184c49e22620ffb039f4054316a7ffdf58 Mon Sep 17 00:00:00 2001 From: hotequil Date: Tue, 4 Feb 2025 14:59:03 -0300 Subject: [PATCH] CU-86a6hw98x-BS Lib - Use the fromMnemonic by Ethers.js (Utils) --- .../bs-ethereum/CU-86a6hw98x_2025-02-04-17-58.json | 10 ++++++++++ packages/bs-ethereum/src/BSEthereum.ts | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 common/changes/@cityofzion/bs-ethereum/CU-86a6hw98x_2025-02-04-17-58.json diff --git a/common/changes/@cityofzion/bs-ethereum/CU-86a6hw98x_2025-02-04-17-58.json b/common/changes/@cityofzion/bs-ethereum/CU-86a6hw98x_2025-02-04-17-58.json new file mode 100644 index 0000000..ba16f9c --- /dev/null +++ b/common/changes/@cityofzion/bs-ethereum/CU-86a6hw98x_2025-02-04-17-58.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cityofzion/bs-ethereum", + "comment": "Change the Wallet to HDNode", + "type": "patch" + } + ], + "packageName": "@cityofzion/bs-ethereum" +} \ No newline at end of file diff --git a/packages/bs-ethereum/src/BSEthereum.ts b/packages/bs-ethereum/src/BSEthereum.ts index e71c9e7..19eb1aa 100644 --- a/packages/bs-ethereum/src/BSEthereum.ts +++ b/packages/bs-ethereum/src/BSEthereum.ts @@ -176,11 +176,13 @@ export class BSEthereum generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Account { const bip44Path = this.bip44DerivationPath.replace('?', index.toString()) - const wallet = ethers.Wallet.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic, bip44Path) + const hd = ethers.utils.HDNode.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic).derivePath( + bip44Path + ) return { - address: wallet.address, - key: wallet.privateKey, + address: hd.address, + key: hd.privateKey, type: 'privateKey', bip44Path, blockchain: this.name,