From 167acc0fd5dba17e0a8e46b47d1fee472260ad8b Mon Sep 17 00:00:00 2001 From: sisou Date: Wed, 27 Feb 2019 14:31:44 -0600 Subject: [PATCH] Adapt IqonHash calls, dependencies --- src/components/DownloadLoginFile.js | 4 ++-- src/lib/IqonHash.js | 12 +++++++----- src/request/change-password/ChangePassword.js | 4 ++-- src/request/change-password/index.html | 2 +- src/request/create/index.html | 1 + src/request/derive-address/index.html | 1 + src/request/export/ExportFile.js | 4 ++-- src/request/export/index.html | 2 +- src/request/import/ImportWords.js | 4 ++-- src/request/import/index.html | 2 +- src/request/remove-key/index.html | 2 +- src/request/sign-message/index.html | 1 + src/request/sign-transaction/index.html | 1 + 13 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/DownloadLoginFile.js b/src/components/DownloadLoginFile.js index d3278def7..589a0e7c2 100644 --- a/src/components/DownloadLoginFile.js +++ b/src/components/DownloadLoginFile.js @@ -3,7 +3,7 @@ /* global LoginFile */ /* global KeyStore */ /* global Errors */ -/* global Iqons */ +/* global IqonHash */ class DownloadLoginFile extends Nimiq.Observable { /** @@ -84,7 +84,7 @@ class DownloadLoginFile extends Nimiq.Observable { throw new Errors.KeyguardError('Can only export encrypted Entropies'); } - const color = Iqons.getBackgroundColorIndex(firstAddress.toUserFriendlyAddress()); + const color = IqonHash.getBackgroundColorIndex(firstAddress.toUserFriendlyAddress()); this.file = new LoginFile(Nimiq.BufferUtils.toBase64(encryptedEntropy), color); } diff --git a/src/lib/IqonHash.js b/src/lib/IqonHash.js index c55be8f9f..cd412d34a 100644 --- a/src/lib/IqonHash.js +++ b/src/lib/IqonHash.js @@ -1,4 +1,4 @@ -class IqonHash { +class IqonHash { /* eslint-disable-line no-unused-vars */ /** * @param {string} address * @returns {number} @@ -53,12 +53,14 @@ class IqonHash { * @param {string} string * @param {number} maxLength * @param {string} fillString + * @returns {string} */ static _padEnd(string, maxLength, fillString) { - if (!!String.prototype.padEnd) return string.padEnd(maxLength, fillString); - else { - while (string.length < maxLength) string += fillString; - return string.substring(0, Math.max(string.length, maxLength)); + if (String.prototype.padEnd) return string.padEnd(maxLength, fillString); + + while (string.length < maxLength) { + string += fillString; } + return string.substring(0, Math.max(string.length, maxLength)); } } diff --git a/src/request/change-password/ChangePassword.js b/src/request/change-password/ChangePassword.js index f4f13e72a..d0d71a96f 100644 --- a/src/request/change-password/ChangePassword.js +++ b/src/request/change-password/ChangePassword.js @@ -9,7 +9,7 @@ /* global DownloadLoginFile */ /* global LoginFileIcon */ /* global ProgressIndicator */ -/* global Iqons */ +/* global IqonHash */ /* global LoginFile */ /** @@ -149,7 +149,7 @@ class ChangePassword { async _prepare() { let colorClass = ''; if (this.key.secret instanceof Nimiq.Entropy) { - const color = Iqons.getBackgroundColorIndex( + const color = IqonHash.getBackgroundColorIndex( new Nimiq.Address( // use color of first address as loginFile color this.key.deriveAddress(Constants.DEFAULT_DERIVATION_PATH).serialize(), diff --git a/src/request/change-password/index.html b/src/request/change-password/index.html index 6ef541dd6..9ff5e39d9 100644 --- a/src/request/change-password/index.html +++ b/src/request/change-password/index.html @@ -37,7 +37,7 @@ - + diff --git a/src/request/create/index.html b/src/request/create/index.html index 5bf7b5741..6a49b92cd 100644 --- a/src/request/create/index.html +++ b/src/request/create/index.html @@ -36,6 +36,7 @@ + diff --git a/src/request/derive-address/index.html b/src/request/derive-address/index.html index 30b186bf0..8a8fbd78e 100644 --- a/src/request/derive-address/index.html +++ b/src/request/derive-address/index.html @@ -37,6 +37,7 @@ + diff --git a/src/request/export/ExportFile.js b/src/request/export/ExportFile.js index bb24616df..a1da652d7 100644 --- a/src/request/export/ExportFile.js +++ b/src/request/export/ExportFile.js @@ -1,5 +1,5 @@ /* global Constants */ -/* global Iqons */ +/* global IqonHash */ /* global LoginFileIcon */ /* global LoginFile */ /* global Nimiq */ @@ -117,7 +117,7 @@ class ExportFile extends Nimiq.Observable { $setPasswordPage.classList.add('repeat-password'); let colorClass = ''; - const color = Iqons.getBackgroundColorIndex( + const color = IqonHash.getBackgroundColorIndex( this._request.keyInfo.defaultAddress.toUserFriendlyAddress(), ); const colorString = LoginFile.CONFIG[color].name; diff --git a/src/request/export/index.html b/src/request/export/index.html index fdbdfaeaa..c8c943d56 100644 --- a/src/request/export/index.html +++ b/src/request/export/index.html @@ -38,7 +38,7 @@ - + diff --git a/src/request/import/ImportWords.js b/src/request/import/ImportWords.js index d6e231517..76023a9c7 100644 --- a/src/request/import/ImportWords.js +++ b/src/request/import/ImportWords.js @@ -3,7 +3,7 @@ /* global Errors */ /* global FlippableHandler */ /* global ImportApi */ -/* global Iqons */ +/* global IqonHash */ /* global Key */ /* global KeyStore */ /* global LoginFile */ @@ -90,7 +90,7 @@ class ImportWords { let colorClass = ''; if (this._secrets.entropy) { const key = new Key(this._secrets.entropy, false); - const color = Iqons.getBackgroundColorIndex( + const color = IqonHash.getBackgroundColorIndex( key.defaultAddress.toUserFriendlyAddress(), ); const colorString = LoginFile.CONFIG[color].name; diff --git a/src/request/import/index.html b/src/request/import/index.html index 12d163913..5d4d2bebc 100644 --- a/src/request/import/index.html +++ b/src/request/import/index.html @@ -38,7 +38,7 @@ - + diff --git a/src/request/remove-key/index.html b/src/request/remove-key/index.html index c389183dc..17d45d1ed 100644 --- a/src/request/remove-key/index.html +++ b/src/request/remove-key/index.html @@ -39,7 +39,7 @@ - + diff --git a/src/request/sign-message/index.html b/src/request/sign-message/index.html index aac1dafda..8ed56e176 100644 --- a/src/request/sign-message/index.html +++ b/src/request/sign-message/index.html @@ -37,6 +37,7 @@ + diff --git a/src/request/sign-transaction/index.html b/src/request/sign-transaction/index.html index aae6de7aa..79527462a 100644 --- a/src/request/sign-transaction/index.html +++ b/src/request/sign-transaction/index.html @@ -37,6 +37,7 @@ +