All files ids.ts

100% Statements 16/16
100% Branches 11/11
100% Functions 2/2
100% Lines 16/16

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 191x   1x 20x 20x 20x 7x 7x 7x 20x 6x 6x 1x 1x   1x 3x 3x  
import { bytesToUint256LittleEndian } from './subgraph.js';
 
export function toBigIntId(id: string | Uint8Array | number | bigint): bigint {
  if (typeof id === 'bigint') return id;
  if (typeof id === 'number') return BigInt(id);
  if (typeof id === 'string') {
    const trimmed = id.startsWith('0x') ? id : `0x${id}`;
    return BigInt(trimmed);
  }
  if (id instanceof Uint8Array) {
    return bytesToUint256LittleEndian(id);
  }
  throw new Error('Unsupported position id type');
}
 
export function decodePositionId(id: string | Uint8Array | number | bigint): bigint {
  return toBigIntId(id);
}