Skip to content

Commit

Permalink
Adapt IqonHash calls, dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Feb 27, 2019
1 parent cd737c4 commit 167acc0
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/components/DownloadLoginFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* global LoginFile */
/* global KeyStore */
/* global Errors */
/* global Iqons */
/* global IqonHash */

class DownloadLoginFile extends Nimiq.Observable {
/**
Expand Down Expand Up @@ -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);
}

Expand Down
12 changes: 7 additions & 5 deletions src/lib/IqonHash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class IqonHash {
class IqonHash { /* eslint-disable-line no-unused-vars */
/**
* @param {string} address
* @returns {number}
Expand Down Expand Up @@ -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));
}
}
4 changes: 2 additions & 2 deletions src/request/change-password/ChangePassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* global DownloadLoginFile */
/* global LoginFileIcon */
/* global ProgressIndicator */
/* global Iqons */
/* global IqonHash */
/* global LoginFile */

/**
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/request/change-password/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<script defer bundle-toplevel src="../TopLevelApi.js"></script>
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/LoginFile.js"></script>
<script defer src="../../lib/PasswordStrength.js"></script>
<script defer src="../../lib/QrEncoder.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/request/create/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script defer bundle-toplevel src="../TopLevelApi.js"></script>
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../lib/PasswordStrength.js"></script>
<script defer src="../../components/Identicon.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/request/derive-address/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<script defer bundle-toplevel src="../TopLevelApi.js"></script>
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../components/Identicon.js"></script>
<script defer src="DerivedIdenticonSelector.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions src/request/export/ExportFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global Constants */
/* global Iqons */
/* global IqonHash */
/* global LoginFileIcon */
/* global LoginFile */
/* global Nimiq */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/request/export/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/AutoComplete.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/PasswordStrength.js"></script>
<script defer src="../../lib/QrEncoder.js"></script>
<script defer src="../../lib/LoginFile.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions src/request/import/ImportWords.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* global Errors */
/* global FlippableHandler */
/* global ImportApi */
/* global Iqons */
/* global IqonHash */
/* global Key */
/* global KeyStore */
/* global LoginFile */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/request/import/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/AutoComplete.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/QrScanner.js"></script>
<script defer src="../../lib/LoginFile.js"></script>
<script defer src="../../lib/PasswordStrength.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/request/remove-key/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/AutoComplete.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/PasswordStrength.js"></script>
<script defer src="../../lib/QrEncoder.js"></script>
<script defer src="../../lib/LoginFile.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/request/sign-message/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<script defer bundle-toplevel src="../TopLevelApi.js"></script>
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../components/Identicon.js"></script>
<script defer src="SignMessageApi.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/request/sign-transaction/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<script defer bundle-toplevel src="../TopLevelApi.js"></script>
<script defer bundle-toplevel src="../../translations/index.js"></script>

<script defer src="../../lib/IqonHash.js"></script>
<script defer src="../../lib/Iqons.js"></script>
<script defer src="../../components/Identicon.js"></script>
<script defer src="../../components/AddressInfo.js"></script>
Expand Down

0 comments on commit 167acc0

Please sign in to comment.