for look index namings (consistency) (#1183)

This commit is contained in:
Jaco
2021-11-14 19:22:06 +02:00
committed by GitHub
parent 36f6407796
commit e93f8d7418
5 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -29,8 +29,8 @@ export function ethereumEncode (addressOrPublic?: HexString | string | Uint8Arra
const hash = u8aToHex(keccakAsU8a(address), -1, false);
let result = '';
for (let index = 0; index < 40; index++) {
result = `${result}${parseInt(hash[index], 16) > 7 ? address[index].toUpperCase() : address[index]}`;
for (let i = 0; i < 40; i++) {
result = `${result}${parseInt(hash[i], 16) > 7 ? address[i].toUpperCase() : address[i]}`;
}
return `0x${result}`;
@@ -17,8 +17,8 @@ export function isEthereumChecksum (_address: string): boolean {
const address = _address.replace('0x', '');
const hash = u8aToHex(keccakAsU8a(address.toLowerCase()), -1, false);
for (let index = 0; index < 40; index++) {
if (isInvalidChar(address[index], parseInt(hash[index], 16))) {
for (let i = 0; i < 40; i++) {
if (isInvalidChar(address[i], parseInt(hash[i], 16))) {
return false;
}
}
+3 -3
View File
@@ -19,10 +19,10 @@ export function arrayChunk <T> (array: T[], chunkSize: number): T[][] {
const outputSize = Math.ceil(array.length / chunkSize);
const output = Array<T[]>(outputSize);
for (let index = 0; index < outputSize; index++) {
const offset = index * chunkSize;
for (let i = 0; i < outputSize; i++) {
const offset = i * chunkSize;
output[index] = array.slice(offset, offset + chunkSize);
output[i] = array.slice(offset, offset + chunkSize);
}
return output;
+2 -2
View File
@@ -27,12 +27,12 @@ export function arrayFlatten <T> (arrays: T[][]): T[] {
}
const output = new Array<T>(size);
let index = -1;
let i = -1;
for (const a of arrays) {
// instead of pushing, we just set the entries
for (let e = 0; e < a.length; e++) {
output[++index] = a[e];
output[++i] = a[e];
}
}
+2 -2
View File
@@ -40,10 +40,10 @@ export function hexToU8a (_value?: HexString | string | null, bitLength = -1): U
const result = new Uint8Array(resultLength);
const offset = Math.max(0, resultLength - valLength);
for (let index = 0; index < resultLength; index++) {
for (let i = 0; i < resultLength; i++) {
// TODO With some magic we can use the HEX_TO_U16 lookups here as well
// (and then finally HEX_TO_U8 for the overflows)
result[index + offset] = HEX_TO_U8[value.substr(index * 2, 2)];
result[i + offset] = HEX_TO_U8[value.substr(i * 2, 2)];
}
return result;