diff options
author | Jacob Evans <jacob@dekz.net> | 2018-04-12 15:10:17 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2018-04-12 15:10:17 +0800 |
commit | ce3f25d48f3eb7a71953515e30a3f0c49881eac4 (patch) | |
tree | 346cd9ac0721ae886016a6c0734173d5ccb1d31b | |
parent | b669508c34e541416b157babe3fc57d74216ee50 (diff) | |
download | dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar.gz dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar.bz2 dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar.lz dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar.xz dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.tar.zst dexon-sol-tools-ce3f25d48f3eb7a71953515e30a3f0c49881eac4.zip |
Rename to parentDerivedKeyInfo to be explicity about how we walk the tree
-rw-r--r-- | packages/subproviders/src/utils/wallet_utils.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/subproviders/src/utils/wallet_utils.ts b/packages/subproviders/src/utils/wallet_utils.ts index 4db876748..cd5cd9ba0 100644 --- a/packages/subproviders/src/utils/wallet_utils.ts +++ b/packages/subproviders/src/utils/wallet_utils.ts @@ -7,22 +7,22 @@ import { DerivedHDKeyInfo, WalletSubproviderErrors } from '../types'; const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; class DerivedHDKeyInfoIterator implements IterableIterator<DerivedHDKeyInfo> { - private _initialDerivedKey: DerivedHDKeyInfo; + private _parentDerivedKeyInfo: DerivedHDKeyInfo; private _searchLimit: number; private _index: number; constructor(initialDerivedKey: DerivedHDKeyInfo, searchLimit: number = DEFAULT_ADDRESS_SEARCH_LIMIT) { this._searchLimit = searchLimit; - this._initialDerivedKey = initialDerivedKey; + this._parentDerivedKeyInfo = initialDerivedKey; this._index = 0; } public next(): IteratorResult<DerivedHDKeyInfo> { - const baseDerivationPath = this._initialDerivedKey.baseDerivationPath; + const baseDerivationPath = this._parentDerivedKeyInfo.baseDerivationPath; const derivationIndex = this._index; const fullDerivationPath = `m/${baseDerivationPath}/${derivationIndex}`; const path = `m/${derivationIndex}`; - const hdKey = this._initialDerivedKey.hdKey.derive(path); + const hdKey = this._parentDerivedKeyInfo.hdKey.derive(path); const address = walletUtils.addressOfHDKey(hdKey); const derivedKey: DerivedHDKeyInfo = { address, @@ -44,9 +44,9 @@ class DerivedHDKeyInfoIterator implements IterableIterator<DerivedHDKeyInfo> { } export const walletUtils = { - calculateDerivedHDKeyInfos(initialDerivedKey: DerivedHDKeyInfo, numberOfKeys: number): DerivedHDKeyInfo[] { + calculateDerivedHDKeyInfos(parentDerivedKeyInfo: DerivedHDKeyInfo, numberOfKeys: number): DerivedHDKeyInfo[] { const derivedKeys: DerivedHDKeyInfo[] = []; - const derivedKeyIterator = new DerivedHDKeyInfoIterator(initialDerivedKey, numberOfKeys); + const derivedKeyIterator = new DerivedHDKeyInfoIterator(parentDerivedKeyInfo, numberOfKeys); for (const key of derivedKeyIterator) { derivedKeys.push(key); } @@ -54,11 +54,11 @@ export const walletUtils = { }, findDerivedKeyInfoForAddressIfExists( address: string, - initialDerivedKey: DerivedHDKeyInfo, + parentDerivedKeyInfo: DerivedHDKeyInfo, searchLimit: number, ): DerivedHDKeyInfo | undefined { let matchedKey: DerivedHDKeyInfo | undefined; - const derivedKeyIterator = new DerivedHDKeyInfoIterator(initialDerivedKey, searchLimit); + const derivedKeyIterator = new DerivedHDKeyInfoIterator(parentDerivedKeyInfo, searchLimit); for (const key of derivedKeyIterator) { if (key.address === address) { matchedKey = key; |