Closed alejoacosta74 closed 2 months ago
The current implementation works, but contains a cyclic dependency between base class AbstractHDWallet and its childrens QiHDWallet and QuaiHDWallet:
AbstractHDWallet
QiHDWallet
QuaiHDWallet
static async deserialize<T extends AbstractHDWallet>( this: new (root: HDNodeWallet, provider?: Provider) => T, serialized: SerializedHDWallet ): Promise<QuaiHDWallet|QiHDWallet> { if (serialized.version !== (this as any)._version) { throw new Error(`Invalid version ${serialized.version} for wallet (expected ${(this as any)._version})`); } if (serialized.coinType !== (this as any)._coinType) { throw new Error(`Invalid coinType ${serialized.coinType} for wallet (expected ${(this as any)._coinType})`); } const mnemonic = Mnemonic.fromPhrase(serialized.phrase); const path = (this as any).parentPath(serialized.coinType); const root = HDNodeWallet.fromMnemonic(mnemonic, path ); const wallet = new this(root, serialized.provider); for (const addressInfo of serialized.addresses) { wallet._addresses.set(addressInfo.address, addressInfo); } for (const address of serialized.addresses) { if (!wallet._accounts.has(address.account)) { wallet.addAccount(address.account); } } return wallet as T; }
The current implementation works, but contains a cyclic dependency between base class
AbstractHDWallet
and its childrensQiHDWallet
andQuaiHDWallet
: