UNPKG

1.98 kBTypeScriptView Raw
1/// <reference types="bn.js" />
2import type { BN } from './bn/bn.js';
3/** An interface that defines an actual JS class */
4export interface Class<T = any, A extends unknown[] = any[]> {
5 prototype: T;
6 new (...args: A): T;
7 hasOwnProperty(prop: string): boolean;
8 isPrototypeOf(other: unknown): boolean;
9}
10export type Constructor<T = any, A extends unknown[] = any[]> = Class<T, A>;
11export interface ToBigInt {
12 toBigInt: () => bigint;
13}
14export interface ToBn {
15 toBn: () => BN;
16}
17export interface SiDef {
18 power: number;
19 text: string;
20 value: string;
21}
22export interface Logger {
23 debug: (...values: unknown[]) => void;
24 error: (...values: unknown[]) => void;
25 log: (...values: unknown[]) => void;
26 noop: (...values: unknown[]) => void;
27 warn: (...values: unknown[]) => void;
28}
29export interface ToBnOptions {
30 /** Convert in LE format */
31 isLe?: boolean;
32 /** Number is signed, apply two's complement */
33 isNegative?: boolean;
34}
35export interface NumberOptions extends ToBnOptions {
36 /** Limit to the specified bitLength, despite input length */
37 bitLength?: number;
38}
39export interface Time {
40 days: number;
41 hours: number;
42 minutes: number;
43 seconds: number;
44 milliseconds: number;
45}
46export type Memoized<F> = F & {
47 unmemoize: (...args: unknown[]) => void;
48};
49export type AnyString = string | String;
50export type HexDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
51export type HexString = `0x${string}`;
52export interface BufferObject extends Uint8Array {
53 equals: (otherBuffer: Uint8Array) => boolean;
54 readDoubleLE: (offset?: number) => number;
55}
56export interface BufferClass extends Class<BufferObject> {
57 from: <T = BufferObject>(value: unknown) => T;
58 isBuffer: (value: unknown) => boolean;
59}
60export type U8aLike = number[] | Uint8Array | AnyString;
61export interface Observable {
62 next: (...params: unknown[]) => unknown;
63}