All files / src bn.ts

27.27% Statements 3/11
100% Branches 0/0
0% Functions 0/8
27.27% Lines 3/11

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                    1x       1x                                                                                       1x    
/* eslint-disable max-len */
/* eslint-disable no-useless-constructor */
/* eslint-disable lines-between-class-members */
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-useless-constructor */
 
 
// TODO: This is terrible, hacky method to declare the class definition for `bn.js` 
//       in a way that prevents `@types/bn.js` from causing issues in other libs. The 
//       `@types/bn.js` package is improperly typed and requires `syntheticDefaultImports` 
//       or `skipLibCheck` to be enabled on consumer packages. 
//       This should be replaced with a PR to fix the `@types/bn.js` code.  
 
 
// @ts-ignore ts(2497): "This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export."
import * as BN_Borked from 'bn.js'
 
export type Endianness = 'le' | 'be';
 
const BadTypeUsage = new Error('Class only used as an interface')
 
 
class BNClass {
  constructor(number: number | string | number[] | Uint8Array | Buffer | BNClass, endian?: Endianness);
  constructor(number: number | string | number[] | Uint8Array | Buffer | BNClass, base?: number | 'hex', endian?: Endianness);
  constructor(...args: any[]) { throw BadTypeUsage }
 
  /**
   * @description  convert to byte Array, and optionally zero pad to length, throwing if already exceeding
   */
  toArray(endian?: Endianness, length?: number): number[] { throw BadTypeUsage }
 
  /**
   * @description  convert to base-string and pad with zeroes
   */
  toString(base?: number | 'hex', length?: number): string { throw BadTypeUsage }
 
  /**
   * @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
   */
  ucmp(b: BNClass): -1 | 0 | 1 { throw BadTypeUsage }
 
  /**
   * @description convert to Javascript Number (limited to 53 bits)
   */
  toNumber(): number { throw BadTypeUsage }
 
  /**
   * @description raise `a` to the power of `b`
   */
  pow(b: BNClass): BNClass { throw BadTypeUsage }
 
  /**
   * @description multiply
   */
  mul(b: BNClass): BNClass { throw BadTypeUsage }
 
  /**
   * @description addition
   */
  add(b: BNClass): BNClass { throw BadTypeUsage }
}
 
export const BNConstructor: typeof BNClass = BN_Borked as any
export type BN = BNClass