aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-16 20:59:10 +0800
committerFabio Berger <me@fabioberger.com>2018-05-16 20:59:10 +0800
commit839db68571037f6fff8273aaade6ea0bd14ea8a5 (patch)
tree302b3164f01bc5363bf07841a42fa30b3842169e /packages/subproviders/src
parentfec6ac3ff0c4781cea0b3f42e287aee2b8aa2a79 (diff)
downloaddexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar.gz
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar.bz2
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar.lz
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar.xz
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.tar.zst
dexon-sol-tools-839db68571037f6fff8273aaade6ea0bd14ea8a5.zip
Fix TSLint rules
Diffstat (limited to 'packages/subproviders/src')
-rw-r--r--packages/subproviders/src/subproviders/ledger.ts18
-rw-r--r--packages/subproviders/src/subproviders/nonce_tracker.ts3
-rw-r--r--packages/subproviders/src/subproviders/subprovider.ts5
-rw-r--r--packages/subproviders/src/utils/wallet_utils.ts4
4 files changed, 19 insertions, 11 deletions
diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts
index 347eda55f..467299db0 100644
--- a/packages/subproviders/src/subproviders/ledger.ts
+++ b/packages/subproviders/src/subproviders/ledger.ts
@@ -113,9 +113,12 @@ export class LedgerSubprovider extends BaseWalletSubprovider {
const tx = new EthereumTx(txParams);
// Set the EIP155 bits
- tx.raw[6] = Buffer.from([this._networkId]); // v
- tx.raw[7] = Buffer.from([]); // r
- tx.raw[8] = Buffer.from([]); // s
+ const vIndex = 6;
+ tx.raw[vIndex] = Buffer.from([this._networkId]); // v
+ const rIndex = 7;
+ tx.raw[rIndex] = Buffer.from([]); // r
+ const sIndex = 8;
+ tx.raw[sIndex] = Buffer.from([]); // s
const txHex = tx.serialize().toString('hex');
try {
@@ -127,7 +130,8 @@ export class LedgerSubprovider extends BaseWalletSubprovider {
tx.v = Buffer.from(result.v, 'hex');
// EIP155: v should be chain_id * 2 + {35, 36}
- const signedChainId = Math.floor((tx.v[0] - 35) / 2);
+ const eip55Constant = 35;
+ const signedChainId = Math.floor((tx.v[0] - eip55Constant) / 2);
if (signedChainId !== this._networkId) {
await this._destroyLedgerClientAsync();
const err = new Error(LedgerSubproviderErrors.TooOldLedgerFirmware);
@@ -169,8 +173,10 @@ export class LedgerSubprovider extends BaseWalletSubprovider {
fullDerivationPath,
ethUtil.stripHexPrefix(data),
);
- const v = result.v - 27;
- let vHex = v.toString(16);
+ const lowestValidV = 27;
+ const v = result.v - lowestValidV;
+ const hexBase = 16;
+ let vHex = v.toString(hexBase);
if (vHex.length < 2) {
vHex = `0${v}`;
}
diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts
index 907330111..345e5e975 100644
--- a/packages/subproviders/src/subproviders/nonce_tracker.ts
+++ b/packages/subproviders/src/subproviders/nonce_tracker.ts
@@ -93,7 +93,8 @@ export class NonceTrackerSubprovider extends Subprovider {
// Increment the nonce from the previous successfully submitted transaction
let nonce = ethUtil.bufferToInt(transaction.nonce);
nonce++;
- let nextHexNonce = nonce.toString(16);
+ const hexBase = 16;
+ let nextHexNonce = nonce.toString(hexBase);
if (nextHexNonce.length % 2) {
nextHexNonce = `0${nextHexNonce}`;
}
diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts
index 56d2381a0..cb6dffc4a 100644
--- a/packages/subproviders/src/subproviders/subprovider.ts
+++ b/packages/subproviders/src/subproviders/subprovider.ts
@@ -13,10 +13,11 @@ export abstract class Subprovider {
// Ported from: https://github.com/MetaMask/provider-engine/blob/master/util/random-id.js
private static _getRandomId(): number {
const extraDigits = 3;
+ const baseTen = 10;
// 13 time digits
- const datePart = new Date().getTime() * Math.pow(10, extraDigits);
+ const datePart = new Date().getTime() * Math.pow(baseTen, extraDigits);
// 3 random digits
- const extraPart = Math.floor(Math.random() * Math.pow(10, extraDigits));
+ const extraPart = Math.floor(Math.random() * Math.pow(baseTen, extraDigits));
// 16 digits
return datePart + extraPart;
}
diff --git a/packages/subproviders/src/utils/wallet_utils.ts b/packages/subproviders/src/utils/wallet_utils.ts
index cd5cd9ba0..c36fdb9fc 100644
--- a/packages/subproviders/src/utils/wallet_utils.ts
+++ b/packages/subproviders/src/utils/wallet_utils.ts
@@ -30,10 +30,10 @@ class DerivedHDKeyInfoIterator implements IterableIterator<DerivedHDKeyInfo> {
baseDerivationPath,
derivationPath: fullDerivationPath,
};
- const done = this._index === this._searchLimit;
+ const isDone = this._index === this._searchLimit;
this._index++;
return {
- done,
+ done: isDone,
value: derivedKey,
};
}