1 |
|
2 | import './common/eager_offset';
|
3 | import { ByteArray, Bytes, Entity } from './common/collections';
|
4 | import { Value } from './common/value';
|
5 |
|
6 | export * from './chain/arweave';
|
7 |
|
8 | export * from './chain/ethereum';
|
9 |
|
10 | export * from './chain/near';
|
11 |
|
12 | export * from './chain/cosmos';
|
13 |
|
14 | export * from './common/collections';
|
15 | export * from './common/conversion';
|
16 | export * from './common/datasource';
|
17 | export * from './common/json';
|
18 | export * from './common/numbers';
|
19 | export * from './common/value';
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export declare namespace store {
|
25 | function get(entity: string, id: string): Entity | null;
|
26 | function set(entity: string, id: string, data: Entity): void;
|
27 | function remove(entity: string, id: string): void;
|
28 | }
|
29 |
|
30 |
|
31 | export declare namespace ipfs {
|
32 | function cat(hash: string): Bytes | null;
|
33 | function map(hash: string, callback: string, userData: Value, flags: string[]): void;
|
34 | }
|
35 |
|
36 | export namespace ipfs {
|
37 | export function mapJSON(hash: string, callback: string, userData: Value): void {
|
38 | ipfs.map(hash, callback, userData, ['json']);
|
39 | }
|
40 | }
|
41 |
|
42 |
|
43 | export declare namespace crypto {
|
44 | function keccak256(input: ByteArray): ByteArray;
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export declare namespace ens {
|
53 | function nameByHash(hash: string): string | null;
|
54 | }
|
55 |
|
56 | function format(fmt: string, args: string[]): string {
|
57 | let out = '';
|
58 | let argIndex = 0;
|
59 | for (let i: i32 = 0, len: i32 = fmt.length; i < len; i++) {
|
60 | if (
|
61 | i < len - 1 &&
|
62 | fmt.charCodeAt(i) == 0x7b &&
|
63 | fmt.charCodeAt(i + 1) == 0x7d
|
64 | ) {
|
65 | if (argIndex >= args.length) {
|
66 | throw new Error('Too few arguments for format string: ' + fmt);
|
67 | } else {
|
68 | out += args[argIndex++];
|
69 | i++;
|
70 | }
|
71 | } else {
|
72 | out += fmt.charAt(i);
|
73 | }
|
74 | }
|
75 | return out;
|
76 | }
|
77 |
|
78 |
|
79 | export declare namespace log {
|
80 |
|
81 | export function log(level: Level, msg: string): void;
|
82 | }
|
83 |
|
84 | export namespace log {
|
85 | export enum Level {
|
86 | CRITICAL = 0,
|
87 | ERROR = 1,
|
88 | WARNING = 2,
|
89 | INFO = 3,
|
90 | DEBUG = 4,
|
91 | }
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export function critical(msg: string, args: Array<string>): void {
|
100 | log.log(Level.CRITICAL, format(msg, args));
|
101 | }
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | export function error(msg: string, args: Array<string>): void {
|
110 | log.log(Level.ERROR, format(msg, args));
|
111 | }
|
112 |
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 | export function warning(msg: string, args: Array<string>): void {
|
119 | log.log(Level.WARNING, format(msg, args));
|
120 | }
|
121 |
|
122 | |
123 |
|
124 |
|
125 |
|
126 |
|
127 | export function info(msg: string, args: Array<string>): void {
|
128 | log.log(Level.INFO, format(msg, args));
|
129 | }
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 | export function debug(msg: string, args: Array<string>): void {
|
137 | log.log(Level.DEBUG, format(msg, args));
|
138 | }
|
139 | }
|