-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.d.ts
162 lines (135 loc) · 4.54 KB
/
index.d.ts
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import JSBI from "jsbi";
export class Reader {
constructor(reader: string | ArrayBuffer | Reader);
static fromRawString(s: string): Reader;
length(): number;
indexAt(i: number): number;
toArrayBuffer(): ArrayBuffer;
serializeJson(): string;
}
export type RPCValue = any;
export type RPCSyncHandler = (...params: RPCValue[]) => RPCValue;
export type RPCHandler = (...params: RPCValue[]) => Promise<RPCValue>;
export class BatchRPCMethods {
send: RPCHandler;
}
export class BatchRPCProxy {
[method: string]: RPCSyncHandler;
}
export type BatchRPC = BatchRPCMethods & BatchRPCProxy;
export class RPCMethods {
batch: () => BatchRPC;
}
export class RPCProxy {
[method: string]: RPCHandler;
}
export class RPC {
/**
* To preserve compatibility, we still provide the default constructor
* but it cannot tell if you are calling the sync method batch, or other
* async methods. You will need to distinguish between them yourself.
*/
constructor(uri: string, options?: object);
[method: string]: RPCHandler | RPCSyncHandler;
static create(uri: string): RPCMethods & RPCProxy;
}
export function HexStringToBigInt(hexString: string): JSBI;
export function BigIntToHexString(i: JSBI): string;
export interface ValidatorOptions {
nestedValidation?: boolean;
debugPath?: string;
}
type ValidatorFunction = (value: object, options?: ValidatorOptions) => void;
export namespace validators {
const ValidateScript: ValidatorFunction;
const ValidateOutPoint: ValidatorFunction;
const ValidateCellInput: ValidatorFunction;
const ValidateCellOutput: ValidatorFunction;
const ValidateCellDep: ValidatorFunction;
const ValidateRawTransaction: ValidatorFunction;
const ValidateTransaction: ValidatorFunction;
const ValidateRawHeader: ValidatorFunction;
const ValidateHeader: ValidatorFunction;
const ValidateUncleBlock: ValidatorFunction;
const ValidateBlock: ValidatorFunction;
const ValidateCellbaseWitness: ValidatorFunction;
const ValidateWitnessArgs: ValidatorFunction;
}
export interface TransformerOptions {
validation?: boolean;
debugPath?: string;
}
type TransformerFunction = (
value: object,
options?: TransformerOptions
) => object;
export namespace transformers {
const TransformScript: TransformerFunction;
const TransformOutPoint: TransformerFunction;
const TransformCellInput: TransformerFunction;
const TransformCellOutput: TransformerFunction;
const TransformCellDep: TransformerFunction;
const TransformRawTransaction: TransformerFunction;
const TransformTransaction: TransformerFunction;
const TransformRawHeader: TransformerFunction;
const TransformHeader: TransformerFunction;
const TransformUncleBlock: TransformerFunction;
const TransformBlock: TransformerFunction;
const TransformCellbaseWitness: TransformerFunction;
const TransformWitnessArgs: TransformerFunction;
}
export interface NormalizerOptions {
debugPath?: string;
}
type NormalizerFunction = (
value: object,
options?: NormalizerOptions
) => object;
export namespace normalizers {
const NormalizeScript: NormalizerFunction;
const NormalizeOutPoint: NormalizerFunction;
const NormalizeCellInput: NormalizerFunction;
const NormalizeCellOutput: NormalizerFunction;
const NormalizeCellDep: NormalizerFunction;
const NormalizeRawTransaction: NormalizerFunction;
const NormalizeTransaction: NormalizerFunction;
const NormalizeRawHeader: NormalizerFunction;
const NormalizeHeader: NormalizerFunction;
const NormalizeUncleBlock: NormalizerFunction;
const NormalizeBlock: NormalizerFunction;
const NormalizeCellbaseWitness: NormalizerFunction;
const NormalizeWitnessArgs: NormalizerFunction;
}
export interface Cell {
cell_output: object;
out_point: object;
block_hash: string;
data?: string;
block_number?: string;
}
export interface CellCollectorResults {
[Symbol.asyncIterator](): AsyncIterator<Cell>;
}
export interface CellCollector {
collect(): CellCollectorResults;
}
export namespace cell_collectors {
interface RPCCollectorOptions {
skipCellWithContent?: boolean;
loadData?: boolean;
}
class RPCCollector implements CellCollector {
constructor(rpc: RPC, lockHash: string, options?: RPCCollectorOptions);
collect(): CellCollectorResults;
}
}
export type DepGroupUnpacker = (data: Reader) => Array<object>;
export interface TransactionDumperOptions {
validateTransaction?: boolean;
depGroupUnpacker?: DepGroupUnpacker;
}
export class TransactionDumper {
constructor(rpc: RPC, options?: TransactionDumperOptions);
dump(tx: object): Promise<string>;
}
export const VERSION: string;