@airgap/icp 0.13.11-beta.1 → 0.13.11-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +4 -8
- package/v1/block-explorer/ICPBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/ICPBlockExplorer.js +74 -0
- package/v1/block-explorer/ICPBlockExplorer.js.map +1 -0
- package/v1/index.d.ts +13 -0
- package/v1/index.js +11 -0
- package/v1/index.js.map +1 -0
- package/v1/module/ICPModule.d.ts +15 -0
- package/v1/module/ICPModule.js +107 -0
- package/v1/module/ICPModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/ICPImplementation.d.ts +26 -0
- package/v1/protocol/ICPImplementation.js +344 -0
- package/v1/protocol/ICPImplementation.js.map +1 -0
- package/v1/protocol/ICPProtocol.d.ts +42 -0
- package/v1/protocol/ICPProtocol.js +416 -0
- package/v1/protocol/ICPProtocol.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +4 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +32 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-icp.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +14 -0
- package/v1/serializer/v3/serializer-companion.js +174 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
- package/v1/serializer/v3/validators/transaction-validator.js +100 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/serializer/v3/validators/validators.d.ts +5 -0
- package/v1/serializer/v3/validators/validators.js +106 -0
- package/v1/serializer/v3/validators/validators.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/governance.d.ts +580 -0
- package/v1/types/governance.js +796 -0
- package/v1/types/governance.js.map +1 -0
- package/v1/types/ledger.d.ts +143 -0
- package/v1/types/ledger.js +146 -0
- package/v1/types/ledger.js.map +1 -0
- package/v1/types/management_idl.d.ts +7 -0
- package/v1/types/management_idl.js +72 -0
- package/v1/types/management_idl.js.map +1 -0
- package/v1/types/protocol.d.ts +8 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +11 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/account.d.ts +24 -0
- package/v1/utils/account.js +112 -0
- package/v1/utils/account.js.map +1 -0
- package/v1/utils/actor.d.ts +246 -0
- package/v1/utils/actor.js +458 -0
- package/v1/utils/actor.js.map +1 -0
- package/v1/utils/agent.d.ts +156 -0
- package/v1/utils/agent.js +16 -0
- package/v1/utils/agent.js.map +1 -0
- package/v1/utils/auth.d.ts +110 -0
- package/v1/utils/auth.js +261 -0
- package/v1/utils/auth.js.map +1 -0
- package/v1/utils/bls.d.ts +38 -0
- package/v1/utils/bls.js +204 -0
- package/v1/utils/bls.js.map +1 -0
- package/v1/utils/buffer.d.ts +70 -0
- package/v1/utils/buffer.js +216 -0
- package/v1/utils/buffer.js.map +1 -0
- package/v1/utils/cbor.d.ts +9 -0
- package/v1/utils/cbor.js +178 -0
- package/v1/utils/cbor.js.map +1 -0
- package/v1/utils/certificate.d.ts +74 -0
- package/v1/utils/certificate.js +396 -0
- package/v1/utils/certificate.js.map +1 -0
- package/v1/utils/convert.d.ts +8 -0
- package/v1/utils/convert.js +80 -0
- package/v1/utils/convert.js.map +1 -0
- package/v1/utils/crypto.d.ts +0 -0
- package/v1/utils/crypto.js +104 -0
- package/v1/utils/crypto.js.map +1 -0
- package/v1/utils/der.d.ts +35 -0
- package/v1/utils/der.js +176 -0
- package/v1/utils/der.js.map +1 -0
- package/v1/utils/errors.d.ts +7 -0
- package/v1/utils/errors.js +38 -0
- package/v1/utils/errors.js.map +1 -0
- package/v1/utils/hdkey.d.ts +13 -0
- package/v1/utils/hdkey.js +265 -0
- package/v1/utils/hdkey.js.map +1 -0
- package/v1/utils/http.d.ts +284 -0
- package/v1/utils/http.js +614 -0
- package/v1/utils/http.js.map +1 -0
- package/v1/utils/idl.d.ts +515 -0
- package/v1/utils/idl.js +2103 -0
- package/v1/utils/idl.js.map +1 -0
- package/v1/utils/leb128.d.ts +63 -0
- package/v1/utils/leb128.js +224 -0
- package/v1/utils/leb128.js.map +1 -0
- package/v1/utils/polling.d.ts +59 -0
- package/v1/utils/polling.js +325 -0
- package/v1/utils/polling.js.map +1 -0
- package/v1/utils/principal.d.ts +58 -0
- package/v1/utils/principal.js +543 -0
- package/v1/utils/principal.js.map +1 -0
- package/v1/utils/secp256k1.d.ts +79 -0
- package/v1/utils/secp256k1.js +278 -0
- package/v1/utils/secp256k1.js.map +1 -0
- package/v1/utils/transaction.d.ts +3 -0
- package/v1/utils/transaction.js +56 -0
- package/v1/utils/transaction.js.map +1 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { PipeArrayBuffer as Pipe } from './buffer';
|
|
2
|
+
import { Principal as PrincipalId } from './principal';
|
|
3
|
+
/**
|
|
4
|
+
* Equivalent to `Math.log2(n)` with support for `BigInt` values
|
|
5
|
+
*
|
|
6
|
+
* @param n bigint or integer
|
|
7
|
+
* @returns integer
|
|
8
|
+
*/
|
|
9
|
+
export declare function ilog2(n: bigint | number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Equivalent to `2 ** n` with support for `BigInt` values
|
|
12
|
+
* (necessary for browser preprocessors which replace the `**` operator with `Math.pow`)
|
|
13
|
+
*
|
|
14
|
+
* @param n bigint or integer
|
|
15
|
+
* @returns bigint
|
|
16
|
+
*/
|
|
17
|
+
export declare function iexp2(n: bigint | number): bigint;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param label string
|
|
21
|
+
* @returns number representing hashed label
|
|
22
|
+
*/
|
|
23
|
+
export declare function idlLabelToId(label: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* An IDL Type Table, which precedes the data in the stream.
|
|
26
|
+
*/
|
|
27
|
+
declare class TypeTable {
|
|
28
|
+
private _typs;
|
|
29
|
+
private _idx;
|
|
30
|
+
has(obj: ConstructType): boolean;
|
|
31
|
+
add<T>(type: ConstructType<T>, buf: ArrayBuffer): void;
|
|
32
|
+
merge<T>(obj: ConstructType<T>, knot: string): void;
|
|
33
|
+
encode(): ArrayBuffer;
|
|
34
|
+
indexOf(typeName: string): ArrayBuffer;
|
|
35
|
+
}
|
|
36
|
+
export declare abstract class Visitor<D, R> {
|
|
37
|
+
visitType<T>(t: Type<T>, data: D): R;
|
|
38
|
+
visitPrimitive<T>(t: PrimitiveType<T>, data: D): R;
|
|
39
|
+
visitEmpty(t: EmptyClass, data: D): R;
|
|
40
|
+
visitBool(t: BoolClass, data: D): R;
|
|
41
|
+
visitNull(t: NullClass, data: D): R;
|
|
42
|
+
visitReserved(t: ReservedClass, data: D): R;
|
|
43
|
+
visitText(t: TextClass, data: D): R;
|
|
44
|
+
visitNumber<T>(t: PrimitiveType<T>, data: D): R;
|
|
45
|
+
visitInt(t: IntClass, data: D): R;
|
|
46
|
+
visitNat(t: NatClass, data: D): R;
|
|
47
|
+
visitFloat(t: FloatClass, data: D): R;
|
|
48
|
+
visitFixedInt(t: FixedIntClass, data: D): R;
|
|
49
|
+
visitFixedNat(t: FixedNatClass, data: D): R;
|
|
50
|
+
visitPrincipal(t: PrincipalClass, data: D): R;
|
|
51
|
+
visitConstruct<T>(t: ConstructType<T>, data: D): R;
|
|
52
|
+
visitVec<T>(t: VecClass<T>, ty: Type<T>, data: D): R;
|
|
53
|
+
visitOpt<T>(t: OptClass<T>, ty: Type<T>, data: D): R;
|
|
54
|
+
visitRecord(t: RecordClass, fields: Array<[string, Type]>, data: D): R;
|
|
55
|
+
visitTuple<T extends any[]>(t: TupleClass<T>, components: Type[], data: D): R;
|
|
56
|
+
visitVariant(t: VariantClass, fields: Array<[string, Type]>, data: D): R;
|
|
57
|
+
visitRec<T>(t: RecClass<T>, ty: ConstructType<T>, data: D): R;
|
|
58
|
+
visitFunc(t: FuncClass, data: D): R;
|
|
59
|
+
visitService(t: ServiceClass, data: D): R;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents an IDL type.
|
|
63
|
+
*/
|
|
64
|
+
export declare abstract class Type<T = any> {
|
|
65
|
+
abstract readonly name: string;
|
|
66
|
+
abstract accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
67
|
+
display(): string;
|
|
68
|
+
valueToString(x: T): string;
|
|
69
|
+
buildTypeTable(typeTable: TypeTable): void;
|
|
70
|
+
/**
|
|
71
|
+
* Assert that JavaScript's `x` is the proper type represented by this
|
|
72
|
+
* Type.
|
|
73
|
+
*/
|
|
74
|
+
abstract covariant(x: any): x is T;
|
|
75
|
+
/**
|
|
76
|
+
* Encode the value. This needs to be public because it is used by
|
|
77
|
+
* encodeValue() from different types.
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
abstract encodeValue(x: T): ArrayBuffer;
|
|
81
|
+
/**
|
|
82
|
+
* Implement `I` in the IDL spec.
|
|
83
|
+
* Encode this type for the type table.
|
|
84
|
+
*/
|
|
85
|
+
abstract encodeType(typeTable: TypeTable): ArrayBuffer;
|
|
86
|
+
abstract checkType(t: Type): Type;
|
|
87
|
+
abstract decodeValue(x: Pipe, t: Type): T;
|
|
88
|
+
protected abstract _buildTypeTableImpl(typeTable: TypeTable): void;
|
|
89
|
+
}
|
|
90
|
+
export declare abstract class PrimitiveType<T = any> extends Type<T> {
|
|
91
|
+
checkType(t: Type): Type;
|
|
92
|
+
_buildTypeTableImpl(typeTable: TypeTable): void;
|
|
93
|
+
}
|
|
94
|
+
export declare abstract class ConstructType<T = any> extends Type<T> {
|
|
95
|
+
checkType(t: Type): ConstructType<T>;
|
|
96
|
+
encodeType(typeTable: TypeTable): ArrayBuffer;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Represents an IDL Empty, a type which has no inhabitants.
|
|
100
|
+
* Since no values exist for this type, it cannot be serialised or deserialised.
|
|
101
|
+
* Result types like `Result<Text, Empty>` should always succeed.
|
|
102
|
+
*/
|
|
103
|
+
export declare class EmptyClass extends PrimitiveType<never> {
|
|
104
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
105
|
+
covariant(x: any): x is never;
|
|
106
|
+
encodeValue(): never;
|
|
107
|
+
valueToString(): never;
|
|
108
|
+
encodeType(): ArrayBuffer;
|
|
109
|
+
decodeValue(): never;
|
|
110
|
+
get name(): string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Represents an IDL Unknown, a placeholder type for deserialization only.
|
|
114
|
+
* When decoding a value as Unknown, all fields will be retained but the names are only available in
|
|
115
|
+
* hashed form.
|
|
116
|
+
* A deserialized unknown will offer it's actual type by calling the `type()` function.
|
|
117
|
+
* Unknown cannot be serialized and attempting to do so will throw an error.
|
|
118
|
+
*/
|
|
119
|
+
export declare class UnknownClass extends Type {
|
|
120
|
+
checkType(t: Type): Type;
|
|
121
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
122
|
+
covariant(x: any): x is any;
|
|
123
|
+
encodeValue(): never;
|
|
124
|
+
valueToString(): never;
|
|
125
|
+
encodeType(): never;
|
|
126
|
+
decodeValue(b: Pipe, t: Type): any;
|
|
127
|
+
protected _buildTypeTableImpl(): void;
|
|
128
|
+
get name(): string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Represents an IDL Bool
|
|
132
|
+
*/
|
|
133
|
+
export declare class BoolClass extends PrimitiveType<boolean> {
|
|
134
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
135
|
+
covariant(x: any): x is boolean;
|
|
136
|
+
encodeValue(x: boolean): ArrayBuffer;
|
|
137
|
+
encodeType(): ArrayBuffer;
|
|
138
|
+
decodeValue(b: Pipe, t: Type): boolean;
|
|
139
|
+
get name(): string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Represents an IDL Null
|
|
143
|
+
*/
|
|
144
|
+
export declare class NullClass extends PrimitiveType<null> {
|
|
145
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
146
|
+
covariant(x: any): x is null;
|
|
147
|
+
encodeValue(): ArrayBuffer;
|
|
148
|
+
encodeType(): ArrayBuffer;
|
|
149
|
+
decodeValue(b: Pipe, t: Type): null;
|
|
150
|
+
get name(): string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Represents an IDL Reserved
|
|
154
|
+
*/
|
|
155
|
+
export declare class ReservedClass extends PrimitiveType<any> {
|
|
156
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
157
|
+
covariant(x: any): x is any;
|
|
158
|
+
encodeValue(): ArrayBuffer;
|
|
159
|
+
encodeType(): ArrayBuffer;
|
|
160
|
+
decodeValue(b: Pipe, t: Type): null;
|
|
161
|
+
get name(): string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Represents an IDL Text
|
|
165
|
+
*/
|
|
166
|
+
export declare class TextClass extends PrimitiveType<string> {
|
|
167
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
168
|
+
covariant(x: any): x is string;
|
|
169
|
+
encodeValue(x: string): ArrayBuffer;
|
|
170
|
+
encodeType(): ArrayBuffer;
|
|
171
|
+
decodeValue(b: Pipe, t: Type): string;
|
|
172
|
+
get name(): string;
|
|
173
|
+
valueToString(x: string): string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Represents an IDL Int
|
|
177
|
+
*/
|
|
178
|
+
export declare class IntClass extends PrimitiveType<bigint> {
|
|
179
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
180
|
+
covariant(x: any): x is bigint;
|
|
181
|
+
encodeValue(x: bigint | number): ArrayBuffer;
|
|
182
|
+
encodeType(): ArrayBuffer;
|
|
183
|
+
decodeValue(b: Pipe, t: Type): bigint;
|
|
184
|
+
get name(): string;
|
|
185
|
+
valueToString(x: bigint): string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Represents an IDL Nat
|
|
189
|
+
*/
|
|
190
|
+
export declare class NatClass extends PrimitiveType<bigint> {
|
|
191
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
192
|
+
covariant(x: any): x is bigint;
|
|
193
|
+
encodeValue(x: bigint | number): ArrayBuffer;
|
|
194
|
+
encodeType(): ArrayBuffer;
|
|
195
|
+
decodeValue(b: Pipe, t: Type): bigint;
|
|
196
|
+
get name(): string;
|
|
197
|
+
valueToString(x: bigint): string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Represents an IDL Float
|
|
201
|
+
*/
|
|
202
|
+
export declare class FloatClass extends PrimitiveType<number> {
|
|
203
|
+
private _bits;
|
|
204
|
+
constructor(_bits: number);
|
|
205
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
206
|
+
covariant(x: any): x is number;
|
|
207
|
+
encodeValue(x: number): ArrayBuffer;
|
|
208
|
+
encodeType(): ArrayBuffer;
|
|
209
|
+
decodeValue(b: Pipe, t: Type): number;
|
|
210
|
+
get name(): string;
|
|
211
|
+
valueToString(x: number): string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Represents an IDL fixed-width Int(n)
|
|
215
|
+
*/
|
|
216
|
+
export declare class FixedIntClass extends PrimitiveType<bigint | number> {
|
|
217
|
+
readonly _bits: number;
|
|
218
|
+
constructor(_bits: number);
|
|
219
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
220
|
+
covariant(x: any): x is bigint;
|
|
221
|
+
encodeValue(x: bigint | number): ArrayBuffer;
|
|
222
|
+
encodeType(): ArrayBuffer;
|
|
223
|
+
decodeValue(b: Pipe, t: Type): number | bigint;
|
|
224
|
+
get name(): string;
|
|
225
|
+
valueToString(x: bigint | number): string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Represents an IDL fixed-width Nat(n)
|
|
229
|
+
*/
|
|
230
|
+
export declare class FixedNatClass extends PrimitiveType<bigint | number> {
|
|
231
|
+
readonly _bits: number;
|
|
232
|
+
constructor(_bits: number);
|
|
233
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
234
|
+
covariant(x: any): x is bigint;
|
|
235
|
+
encodeValue(x: bigint | number): ArrayBuffer;
|
|
236
|
+
encodeType(): ArrayBuffer;
|
|
237
|
+
decodeValue(b: Pipe, t: Type): number | bigint;
|
|
238
|
+
get name(): string;
|
|
239
|
+
valueToString(x: bigint | number): string;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Represents an IDL Array
|
|
243
|
+
*
|
|
244
|
+
* Arrays of fixed-sized nat/int type (e.g. nat8), are encoded from and decoded to TypedArrays (e.g. Uint8Array).
|
|
245
|
+
* Arrays of float or other non-primitive types are encoded/decoded as untyped array in Javascript.
|
|
246
|
+
*
|
|
247
|
+
* @param {Type} t
|
|
248
|
+
*/
|
|
249
|
+
export declare class VecClass<T> extends ConstructType<T[]> {
|
|
250
|
+
protected _type: Type<T>;
|
|
251
|
+
private _blobOptimization;
|
|
252
|
+
constructor(_type: Type<T>);
|
|
253
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
254
|
+
covariant(x: any): x is T[];
|
|
255
|
+
encodeValue(x: T[]): ArrayBuffer;
|
|
256
|
+
_buildTypeTableImpl(typeTable: TypeTable): void;
|
|
257
|
+
decodeValue(b: Pipe, t: Type): T[];
|
|
258
|
+
get name(): string;
|
|
259
|
+
display(): string;
|
|
260
|
+
valueToString(x: T[]): string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Represents an IDL Option
|
|
264
|
+
* @param {Type} t
|
|
265
|
+
*/
|
|
266
|
+
export declare class OptClass<T> extends ConstructType<[T] | []> {
|
|
267
|
+
protected _type: Type<T>;
|
|
268
|
+
constructor(_type: Type<T>);
|
|
269
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
270
|
+
covariant(x: any): x is [T] | [];
|
|
271
|
+
encodeValue(x: [T] | []): ArrayBuffer;
|
|
272
|
+
_buildTypeTableImpl(typeTable: TypeTable): void;
|
|
273
|
+
decodeValue(b: Pipe, t: Type): [T] | [];
|
|
274
|
+
get name(): string;
|
|
275
|
+
display(): string;
|
|
276
|
+
valueToString(x: [T] | []): string;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Represents an IDL Record
|
|
280
|
+
* @param {Object} [fields] - mapping of function name to Type
|
|
281
|
+
*/
|
|
282
|
+
export declare class RecordClass extends ConstructType<Record<string, any>> {
|
|
283
|
+
protected readonly _fields: Array<[string, Type]>;
|
|
284
|
+
constructor(fields?: Record<string, Type>);
|
|
285
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
286
|
+
tryAsTuple(): Type[] | null;
|
|
287
|
+
covariant(x: any): x is Record<string, any>;
|
|
288
|
+
encodeValue(x: Record<string, any>): ArrayBuffer;
|
|
289
|
+
_buildTypeTableImpl(T: TypeTable): void;
|
|
290
|
+
decodeValue(b: Pipe, t: Type): Record<string, any>;
|
|
291
|
+
get name(): string;
|
|
292
|
+
display(): string;
|
|
293
|
+
valueToString(x: Record<string, any>): string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Represents Tuple, a syntactic sugar for Record.
|
|
297
|
+
* @param {Type} components
|
|
298
|
+
*/
|
|
299
|
+
export declare class TupleClass<T extends any[]> extends RecordClass {
|
|
300
|
+
protected readonly _components: Type[];
|
|
301
|
+
constructor(_components: Type[]);
|
|
302
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
303
|
+
covariant(x: any): x is T;
|
|
304
|
+
encodeValue(x: any[]): ArrayBuffer;
|
|
305
|
+
decodeValue(b: Pipe, t: Type): T;
|
|
306
|
+
display(): string;
|
|
307
|
+
valueToString(values: any[]): string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Represents an IDL Variant
|
|
311
|
+
* @param {Object} [fields] - mapping of function name to Type
|
|
312
|
+
*/
|
|
313
|
+
export declare class VariantClass extends ConstructType<Record<string, any>> {
|
|
314
|
+
private readonly _fields;
|
|
315
|
+
constructor(fields?: Record<string, Type>);
|
|
316
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
317
|
+
covariant(x: any): x is Record<string, any>;
|
|
318
|
+
encodeValue(x: Record<string, any>): ArrayBuffer;
|
|
319
|
+
_buildTypeTableImpl(typeTable: TypeTable): void;
|
|
320
|
+
decodeValue(b: Pipe, t: Type): {
|
|
321
|
+
[x: string]: any;
|
|
322
|
+
};
|
|
323
|
+
get name(): string;
|
|
324
|
+
display(): string;
|
|
325
|
+
valueToString(x: Record<string, any>): string;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Represents a reference to an IDL type, used for defining recursive data
|
|
329
|
+
* types.
|
|
330
|
+
*/
|
|
331
|
+
export declare class RecClass<T = any> extends ConstructType<T> {
|
|
332
|
+
private static _counter;
|
|
333
|
+
private _id;
|
|
334
|
+
private _type;
|
|
335
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
336
|
+
fill(t: ConstructType<T>): void;
|
|
337
|
+
getType(): ConstructType<T> | undefined;
|
|
338
|
+
covariant(x: any): x is T;
|
|
339
|
+
encodeValue(x: T): ArrayBuffer;
|
|
340
|
+
_buildTypeTableImpl(typeTable: TypeTable): void;
|
|
341
|
+
decodeValue(b: Pipe, t: Type): T;
|
|
342
|
+
get name(): string;
|
|
343
|
+
display(): string;
|
|
344
|
+
valueToString(x: T): string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Represents an IDL principal reference
|
|
348
|
+
*/
|
|
349
|
+
export declare class PrincipalClass extends PrimitiveType<PrincipalId> {
|
|
350
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
351
|
+
covariant(x: any): x is PrincipalId;
|
|
352
|
+
encodeValue(x: PrincipalId): ArrayBuffer;
|
|
353
|
+
encodeType(): ArrayBuffer;
|
|
354
|
+
decodeValue(b: Pipe, t: Type): PrincipalId;
|
|
355
|
+
get name(): string;
|
|
356
|
+
valueToString(x: PrincipalId): string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Represents an IDL function reference.
|
|
360
|
+
* @param argTypes Argument types.
|
|
361
|
+
* @param retTypes Return types.
|
|
362
|
+
* @param annotations Function annotations.
|
|
363
|
+
*/
|
|
364
|
+
export declare class FuncClass extends ConstructType<[PrincipalId, string]> {
|
|
365
|
+
argTypes: Type[];
|
|
366
|
+
retTypes: Type[];
|
|
367
|
+
annotations: string[];
|
|
368
|
+
static argsToString(types: Type[], v: any[]): string;
|
|
369
|
+
constructor(argTypes: Type[], retTypes: Type[], annotations?: string[]);
|
|
370
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
371
|
+
covariant(x: any): x is [PrincipalId, string];
|
|
372
|
+
encodeValue([principal, methodName]: [PrincipalId, string]): ArrayBuffer;
|
|
373
|
+
_buildTypeTableImpl(T: TypeTable): void;
|
|
374
|
+
decodeValue(b: Pipe): [PrincipalId, string];
|
|
375
|
+
get name(): string;
|
|
376
|
+
valueToString([principal, str]: [PrincipalId, string]): string;
|
|
377
|
+
display(): string;
|
|
378
|
+
private encodeAnnotation;
|
|
379
|
+
}
|
|
380
|
+
export declare class ServiceClass extends ConstructType<PrincipalId> {
|
|
381
|
+
readonly _fields: Array<[string, FuncClass]>;
|
|
382
|
+
constructor(fields: Record<string, FuncClass>);
|
|
383
|
+
accept<D, R>(v: Visitor<D, R>, d: D): R;
|
|
384
|
+
covariant(x: any): x is PrincipalId;
|
|
385
|
+
encodeValue(x: PrincipalId): ArrayBuffer;
|
|
386
|
+
_buildTypeTableImpl(T: TypeTable): void;
|
|
387
|
+
decodeValue(b: Pipe): PrincipalId;
|
|
388
|
+
get name(): string;
|
|
389
|
+
valueToString(x: PrincipalId): string;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Encode a array of values
|
|
393
|
+
* @param argTypes
|
|
394
|
+
* @param args
|
|
395
|
+
* @returns {Buffer} serialised value
|
|
396
|
+
*/
|
|
397
|
+
export declare function encode(argTypes: Array<Type<any>>, args: any[]): ArrayBuffer;
|
|
398
|
+
export interface JsonArray extends Array<JsonValue> {
|
|
399
|
+
}
|
|
400
|
+
export interface JsonObject extends Record<string, JsonValue> {
|
|
401
|
+
}
|
|
402
|
+
export declare type JsonValue = boolean | string | number | JsonArray | JsonObject;
|
|
403
|
+
/**
|
|
404
|
+
* Decode a binary value
|
|
405
|
+
* @param retTypes - Types expected in the buffer.
|
|
406
|
+
* @param bytes - hex-encoded string, or buffer.
|
|
407
|
+
* @returns Value deserialised to JS type
|
|
408
|
+
*/
|
|
409
|
+
export declare function decode(retTypes: Type[], bytes: ArrayBuffer): JsonValue[];
|
|
410
|
+
/**
|
|
411
|
+
* An Interface Factory, normally provided by a Candid code generation.
|
|
412
|
+
*/
|
|
413
|
+
export declare type InterfaceFactory = (idl: {
|
|
414
|
+
IDL: {
|
|
415
|
+
Empty: EmptyClass;
|
|
416
|
+
Reserved: ReservedClass;
|
|
417
|
+
Unknown: UnknownClass;
|
|
418
|
+
Bool: BoolClass;
|
|
419
|
+
Null: NullClass;
|
|
420
|
+
Text: TextClass;
|
|
421
|
+
Int: IntClass;
|
|
422
|
+
Nat: NatClass;
|
|
423
|
+
Float32: FloatClass;
|
|
424
|
+
Float64: FloatClass;
|
|
425
|
+
Int8: FixedIntClass;
|
|
426
|
+
Int16: FixedIntClass;
|
|
427
|
+
Int32: FixedIntClass;
|
|
428
|
+
Int64: FixedIntClass;
|
|
429
|
+
Nat8: FixedNatClass;
|
|
430
|
+
Nat16: FixedNatClass;
|
|
431
|
+
Nat32: FixedNatClass;
|
|
432
|
+
Nat64: FixedNatClass;
|
|
433
|
+
Principal: PrincipalClass;
|
|
434
|
+
Tuple: typeof Tuple;
|
|
435
|
+
Vec: typeof Vec;
|
|
436
|
+
Opt: typeof Opt;
|
|
437
|
+
Record: typeof Record;
|
|
438
|
+
Variant: typeof Variant;
|
|
439
|
+
Rec: typeof Rec;
|
|
440
|
+
Func: typeof Func;
|
|
441
|
+
Service(t: Record<string, FuncClass>): ServiceClass;
|
|
442
|
+
};
|
|
443
|
+
}) => ServiceClass;
|
|
444
|
+
export declare const Empty: EmptyClass;
|
|
445
|
+
export declare const Reserved: ReservedClass;
|
|
446
|
+
/**
|
|
447
|
+
* Client-only type for deserializing unknown data. Not supported by Candid, and its use is discouraged.
|
|
448
|
+
*/
|
|
449
|
+
export declare const Unknown: UnknownClass;
|
|
450
|
+
export declare const Bool: BoolClass;
|
|
451
|
+
export declare const Null: NullClass;
|
|
452
|
+
export declare const Text: TextClass;
|
|
453
|
+
export declare const Int: IntClass;
|
|
454
|
+
export declare const Nat: NatClass;
|
|
455
|
+
export declare const Float32: FloatClass;
|
|
456
|
+
export declare const Float64: FloatClass;
|
|
457
|
+
export declare const Int8: FixedIntClass;
|
|
458
|
+
export declare const Int16: FixedIntClass;
|
|
459
|
+
export declare const Int32: FixedIntClass;
|
|
460
|
+
export declare const Int64: FixedIntClass;
|
|
461
|
+
export declare const Nat8: FixedNatClass;
|
|
462
|
+
export declare const Nat16: FixedNatClass;
|
|
463
|
+
export declare const Nat32: FixedNatClass;
|
|
464
|
+
export declare const Nat64: FixedNatClass;
|
|
465
|
+
export declare const Principal: PrincipalClass;
|
|
466
|
+
/**
|
|
467
|
+
*
|
|
468
|
+
* @param types array of any types
|
|
469
|
+
* @returns TupleClass from those types
|
|
470
|
+
*/
|
|
471
|
+
export declare function Tuple<T extends any[]>(...types: T): TupleClass<T>;
|
|
472
|
+
/**
|
|
473
|
+
*
|
|
474
|
+
* @param t IDL Type
|
|
475
|
+
* @returns VecClass from that type
|
|
476
|
+
*/
|
|
477
|
+
export declare function Vec<T>(t: Type<T>): VecClass<T>;
|
|
478
|
+
/**
|
|
479
|
+
*
|
|
480
|
+
* @param t IDL Type
|
|
481
|
+
* @returns OptClass of Type
|
|
482
|
+
*/
|
|
483
|
+
export declare function Opt<T>(t: Type<T>): OptClass<T>;
|
|
484
|
+
/**
|
|
485
|
+
*
|
|
486
|
+
* @param t Record of string and IDL Type
|
|
487
|
+
* @returns RecordClass of string and Type
|
|
488
|
+
*/
|
|
489
|
+
export declare function Record(t: Record<string, Type>): RecordClass;
|
|
490
|
+
/**
|
|
491
|
+
*
|
|
492
|
+
* @param fields Record of string and IDL Type
|
|
493
|
+
* @returns VariantClass
|
|
494
|
+
*/
|
|
495
|
+
export declare function Variant(fields: Record<string, Type>): VariantClass;
|
|
496
|
+
/**
|
|
497
|
+
*
|
|
498
|
+
* @returns new RecClass
|
|
499
|
+
*/
|
|
500
|
+
export declare function Rec(): RecClass;
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
* @param args array of IDL Types
|
|
504
|
+
* @param ret array of IDL Types
|
|
505
|
+
* @param annotations array of strings, [] by default
|
|
506
|
+
* @returns new FuncClass
|
|
507
|
+
*/
|
|
508
|
+
export declare function Func(args: Type[], ret: Type[], annotations?: string[]): FuncClass;
|
|
509
|
+
/**
|
|
510
|
+
*
|
|
511
|
+
* @param t Record of string and FuncClass
|
|
512
|
+
* @returns ServiceClass
|
|
513
|
+
*/
|
|
514
|
+
export declare function Service(t: Record<string, FuncClass>): ServiceClass;
|
|
515
|
+
export {};
|