All files subgraph.ts

100% Statements 14/14
100% Branches 4/4
100% Functions 2/2
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x             22x   22x 88x 88x   22x 22x   1x 25x 25x 100x 100x 25x                 25x  
export function bytesToUint256LittleEndian(bytes: Uint8Array): bigint {
  // console.log(hexString);
  // const cleanHexString = hexString.startsWith('0x') ? hexString.substring(2) : hexString;
  //    const bytes = new Uint8Array(Math.ceil(cleanHexString.length / 2));
  //    for (let i = 0, j = 0; i < cleanHexString.length; i += 2, j++) {
  //        bytes[j] = parseInt(cleanHexString.slice(i, i + 2), 16);
  //    }
  let value: bigint = 0n;
 
  for (let i = bytes.length - 1; i >= 0; i--) {
    value = (value << 8n) | BigInt(bytes[i]);
  }
 
  return value;
}
 
export function uint256ToBytesLittleEndian(value: bigint): Uint8Array {
  const bytes = new Uint8Array(4);
  for (let i = 0; i < 4; i++) {
    bytes[i] = Number((value >> (8n * BigInt(i))) & 0xffn);
  }
  return bytes;
  // let hexString = '0x';
 
  // for (let i = 0; i < bytes.length; i++) {
  // 	// Convert each byte to a hexadecimal string and pad with zero if needed
  // 	hexString += bytes[i].toString(16).padStart(2, '0');
  // }
 
  // return hexString;
}