@tezos-x/octez.js-michel-codec 0.9.0
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/README.md +174 -0
- package/dist/lib/base58.js +255 -0
- package/dist/lib/binary.js +1272 -0
- package/dist/lib/errors.js +90 -0
- package/dist/lib/formatters.js +60 -0
- package/dist/lib/global-constants.js +12 -0
- package/dist/lib/macros.js +548 -0
- package/dist/lib/micheline-emitter.js +132 -0
- package/dist/lib/micheline-parser.js +403 -0
- package/dist/lib/micheline.js +5 -0
- package/dist/lib/michelson-contract.js +93 -0
- package/dist/lib/michelson-typecheck.js +1752 -0
- package/dist/lib/michelson-types.js +83 -0
- package/dist/lib/michelson-validator.js +835 -0
- package/dist/lib/octez.js-michel-codec.js +38 -0
- package/dist/lib/scan.js +128 -0
- package/dist/lib/utils.js +321 -0
- package/dist/lib/version.js +8 -0
- package/dist/octez.js-michel-codec.es6.js +5790 -0
- package/dist/octez.js-michel-codec.es6.js.map +1 -0
- package/dist/octez.js-michel-codec.umd.js +5854 -0
- package/dist/octez.js-michel-codec.umd.js.map +1 -0
- package/dist/types/base58.d.ts +13 -0
- package/dist/types/binary.d.ts +127 -0
- package/dist/types/errors.d.ts +57 -0
- package/dist/types/formatters.d.ts +6 -0
- package/dist/types/global-constants.d.ts +3 -0
- package/dist/types/macros.d.ts +13 -0
- package/dist/types/micheline-emitter.d.ts +17 -0
- package/dist/types/micheline-parser.d.ts +130 -0
- package/dist/types/micheline.d.ts +44 -0
- package/dist/types/michelson-contract.d.ts +24 -0
- package/dist/types/michelson-typecheck.d.ts +38 -0
- package/dist/types/michelson-types.d.ts +147 -0
- package/dist/types/michelson-validator.d.ts +66 -0
- package/dist/types/octez.js-michel-codec.d.ts +16 -0
- package/dist/types/scan.d.ts +26 -0
- package/dist/types/utils.d.ts +77 -0
- package/dist/types/version.d.ts +4 -0
- package/package.json +94 -0
- package/signature.json +315 -0
|
@@ -0,0 +1 @@
|
|
|
1
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TaquitoError } from '@tezos-x/octez.js-core';
|
|
2
|
+
/**
|
|
3
|
+
* @category Error
|
|
4
|
+
* @description Error that indicates a failure when decoding a base58 encoding
|
|
5
|
+
*/
|
|
6
|
+
export declare class Base58DecodingError extends TaquitoError {
|
|
7
|
+
readonly message: string;
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare function decodeBase58(src: string): number[];
|
|
11
|
+
export declare function encodeBase58(src: number[] | Uint8Array): string;
|
|
12
|
+
export declare function decodeBase58Check(src: string): number[];
|
|
13
|
+
export declare function encodeBase58Check(src: number[] | Uint8Array): string;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BytesLiteral } from './micheline';
|
|
2
|
+
import { MichelsonData, MichelsonType } from './michelson-types';
|
|
3
|
+
type AddressType = 'ED25519PublicKeyHash' | 'SECP256K1PublicKeyHash' | 'P256PublicKeyHash' | 'ContractHash';
|
|
4
|
+
export interface Address {
|
|
5
|
+
type: AddressType;
|
|
6
|
+
hash: number[] | Uint8Array;
|
|
7
|
+
entryPoint?: string;
|
|
8
|
+
}
|
|
9
|
+
export type PublicKeyType = 'ED25519PublicKey' | 'SECP256K1PublicKey' | 'P256PublicKey';
|
|
10
|
+
export interface PublicKey {
|
|
11
|
+
type: PublicKeyType;
|
|
12
|
+
publicKey: number[] | Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Serializes any value of packable type to its optimized binary representation
|
|
16
|
+
* identical to the one used by PACK and UNPACK Michelson instructions.
|
|
17
|
+
* Without a type definition (not recommended) the data will be encoded as a binary form of a generic Michelson expression.
|
|
18
|
+
* Type definition allows some types like `timestamp` and `address` and other base58 representable types to be encoded to
|
|
19
|
+
* corresponding optimized binary forms borrowed from the Tezos protocol
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const data: MichelsonData = {
|
|
23
|
+
* string: "KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo"
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* const typ: MichelsonType = {
|
|
27
|
+
* prim: "address"
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* const packed = packData(data, typ);
|
|
31
|
+
*
|
|
32
|
+
* // 050a0000001901be41ee922ddd2cf33201e49d32da0afec571dce300666f6f
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Without a type definition the base58 encoded address will be treated as a string
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const data: MichelsonData = {
|
|
38
|
+
* string: "KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo"
|
|
39
|
+
* };
|
|
40
|
+
*
|
|
41
|
+
* const packed = packData(data);
|
|
42
|
+
*
|
|
43
|
+
* // 0501000000284b543152766b7746344637707a3167436f786b795a724731526b7278517933676d46547625666f6f
|
|
44
|
+
* ```
|
|
45
|
+
* @param d Data object
|
|
46
|
+
* @param t Optional type definition
|
|
47
|
+
* @returns Binary representation as numeric array
|
|
48
|
+
*/
|
|
49
|
+
export declare function packData(d: MichelsonData, t?: MichelsonType): number[];
|
|
50
|
+
/**
|
|
51
|
+
* Serializes any value of packable type to its optimized binary representation
|
|
52
|
+
* identical to the one used by PACK and UNPACK Michelson instructions.
|
|
53
|
+
* Same as {@link packData} but returns a `bytes` Michelson data literal instead of an array
|
|
54
|
+
*
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const data: MichelsonData = {
|
|
57
|
+
* string: "2019-09-26T10:59:51Z"
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* const typ: MichelsonType = {
|
|
61
|
+
* prim: "timestamp"
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* const packed = packDataBytes(data, typ);
|
|
65
|
+
*
|
|
66
|
+
* // { bytes: "0500a7e8e4d80b" }
|
|
67
|
+
* ```
|
|
68
|
+
* @param d Data object
|
|
69
|
+
* @param t Optional type definition
|
|
70
|
+
* @returns Binary representation as a bytes literal
|
|
71
|
+
*/
|
|
72
|
+
export declare function packDataBytes(d: MichelsonData, t?: MichelsonType): BytesLiteral;
|
|
73
|
+
/**
|
|
74
|
+
* Deserialize a byte array into the corresponding Michelson value.
|
|
75
|
+
* Without a type definition (not recommended) the binary data will be treated as a binary form of a generic Michelson expression and returned as is.
|
|
76
|
+
* Type definition allows some types like `timestamp` and `address` and other types usually encoded in optimized binary forms to be transformed
|
|
77
|
+
* back to their string representations like base58 and ISO timestamps.
|
|
78
|
+
*
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];
|
|
81
|
+
*
|
|
82
|
+
* const typ: MichelsonType = {
|
|
83
|
+
* prim: "timestamp"
|
|
84
|
+
* };
|
|
85
|
+
*
|
|
86
|
+
* const data = unpackData(src, typ);
|
|
87
|
+
*
|
|
88
|
+
* // { string: "2019-09-26T10:59:51Z" }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Same binary data without a type definition
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];
|
|
94
|
+
*
|
|
95
|
+
* const data = unpackData(src);
|
|
96
|
+
*
|
|
97
|
+
* // { int: "1569495591" }
|
|
98
|
+
* ```
|
|
99
|
+
* @param src Byte array
|
|
100
|
+
* @param t Optional type definition
|
|
101
|
+
* @returns Deserialized data
|
|
102
|
+
*/
|
|
103
|
+
export declare function unpackData(src: number[] | Uint8Array, t?: MichelsonType): MichelsonData;
|
|
104
|
+
/**
|
|
105
|
+
* Deserialize a byte array into the corresponding Michelson value.
|
|
106
|
+
* Same as {@link unpackData} but takes a `bytes` Michelson data literal instead of an array
|
|
107
|
+
*
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const src = { bytes: "0500a7e8e4d80b" };
|
|
110
|
+
*
|
|
111
|
+
* const typ: MichelsonType = {
|
|
112
|
+
* prim: "timestamp"
|
|
113
|
+
* };
|
|
114
|
+
*
|
|
115
|
+
* const data = unpackDataBytes(src, typ);
|
|
116
|
+
*
|
|
117
|
+
* // { string: "2019-09-26T10:59:51Z" }
|
|
118
|
+
* ```
|
|
119
|
+
* @param src Bytes object
|
|
120
|
+
* @param t Optional type definition
|
|
121
|
+
* @returns Deserialized data
|
|
122
|
+
*/
|
|
123
|
+
export declare function unpackDataBytes(src: BytesLiteral, t?: MichelsonType): MichelsonData;
|
|
124
|
+
export declare function decodeAddressBytes(b: BytesLiteral): Address;
|
|
125
|
+
export declare function decodePublicKeyHashBytes(b: BytesLiteral): Address;
|
|
126
|
+
export declare function decodePublicKeyBytes(b: BytesLiteral): PublicKey;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ParameterValidationError, TaquitoError } from '@tezos-x/octez.js-core';
|
|
2
|
+
/**
|
|
3
|
+
* @category Error
|
|
4
|
+
* @description Error that indicates an invalid Michelson being passed or used
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidMichelsonError extends ParameterValidationError {
|
|
7
|
+
readonly message: string;
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @category Error
|
|
12
|
+
* @description Error that indicates an invalid type expression being passed or used
|
|
13
|
+
*/
|
|
14
|
+
export declare class InvalidTypeExpressionError extends ParameterValidationError {
|
|
15
|
+
readonly message: string;
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @category Error
|
|
20
|
+
* @description Error that indicates an invalid data expression being passed or used
|
|
21
|
+
*/
|
|
22
|
+
export declare class InvalidDataExpressionError extends ParameterValidationError {
|
|
23
|
+
readonly message: string;
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @category Error
|
|
28
|
+
* @description Error that indicates an invalid contract entrypoint being referenced or passed
|
|
29
|
+
*/
|
|
30
|
+
export declare class InvalidEntrypointError extends ParameterValidationError {
|
|
31
|
+
readonly entrypoint?: string | undefined;
|
|
32
|
+
constructor(entrypoint?: string | undefined);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @category Error
|
|
36
|
+
* @description Error that indicates a failure happening when trying to encode Tezos ID
|
|
37
|
+
*/
|
|
38
|
+
export declare class TezosIdEncodeError extends ParameterValidationError {
|
|
39
|
+
readonly message: string;
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @category Error
|
|
44
|
+
* @description Error that indicates a general error happening when trying to create a LongInteger
|
|
45
|
+
*/
|
|
46
|
+
export declare class LongIntegerError extends TaquitoError {
|
|
47
|
+
readonly message: string;
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @category Error
|
|
52
|
+
* @description Error that indicates a failure occurring when trying to parse a hex byte
|
|
53
|
+
*/
|
|
54
|
+
export declare class HexParseError extends TaquitoError {
|
|
55
|
+
readonly hexByte: string;
|
|
56
|
+
constructor(hexByte: string);
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InstructionTrace } from './michelson-typecheck';
|
|
2
|
+
import { MichelsonError } from './utils';
|
|
3
|
+
import { MichelsonReturnType } from './michelson-types';
|
|
4
|
+
export declare function formatStack(s: MichelsonReturnType): string;
|
|
5
|
+
export declare function traceDumpFunc(blocks: boolean, cb: (s: string) => void): (v: InstructionTrace) => void;
|
|
6
|
+
export declare function formatError(err: MichelsonError): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TaquitoError } from '@tezos-x/octez.js-core';
|
|
2
|
+
import { Prim, Expr } from './micheline';
|
|
3
|
+
import { ProtocolOptions } from './michelson-types';
|
|
4
|
+
/**
|
|
5
|
+
* @category Error
|
|
6
|
+
* @description Error that indicates macros failed to be expanded
|
|
7
|
+
*/
|
|
8
|
+
export declare class MacroError extends TaquitoError {
|
|
9
|
+
readonly prim: Prim;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
constructor(prim: Prim, message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare function expandMacros(ex: Prim, opt?: ProtocolOptions): Expr;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Expr } from './micheline';
|
|
2
|
+
export interface FormatOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A string used for code indentation if desired. Usually a tab character or a number of spaces.
|
|
5
|
+
*/
|
|
6
|
+
indent?: string;
|
|
7
|
+
/**
|
|
8
|
+
* A string used for line separation. Usually a newline character ("\n");
|
|
9
|
+
*/
|
|
10
|
+
newline?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Formats Micheline expression
|
|
14
|
+
* @param expr An AST node
|
|
15
|
+
* @param opt Options
|
|
16
|
+
*/
|
|
17
|
+
export declare function emitMicheline(expr: Expr, opt?: FormatOptions, foldMacros?: boolean): string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Token } from './scan';
|
|
2
|
+
import { Expr } from './micheline';
|
|
3
|
+
import { ProtocolOptions } from './michelson-types';
|
|
4
|
+
import { TaquitoError } from '@tezos-x/octez.js-core';
|
|
5
|
+
/**
|
|
6
|
+
* @category Error
|
|
7
|
+
* @description Error that indicates a failure when parsing Micheline expressions
|
|
8
|
+
*/
|
|
9
|
+
export declare class MichelineParseError extends TaquitoError {
|
|
10
|
+
readonly token: Token | null;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
/**
|
|
13
|
+
* @param token A token caused the error
|
|
14
|
+
* @param message An error message
|
|
15
|
+
*/
|
|
16
|
+
constructor(token: Token | null, message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @category Error
|
|
20
|
+
* @description Error indicates a failure when parsing Micheline JSON
|
|
21
|
+
*/
|
|
22
|
+
export declare class JSONParseError extends TaquitoError {
|
|
23
|
+
readonly node: unknown;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
/**
|
|
26
|
+
* @param node A node caused the error
|
|
27
|
+
* @param message An error message
|
|
28
|
+
*/
|
|
29
|
+
constructor(node: unknown, message: string);
|
|
30
|
+
}
|
|
31
|
+
export interface GlobalConstantHashAndValue {
|
|
32
|
+
[globalConstantHash: string]: Expr;
|
|
33
|
+
}
|
|
34
|
+
export interface ParserOptions extends ProtocolOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Expand [Michelson macros](https://tezos.gitlab.io/whitedoc/michelson.html#macros) during parsing.
|
|
37
|
+
*/
|
|
38
|
+
expandMacros?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Expand global constants during parsing.
|
|
41
|
+
* `expandGlobalConstant` expects an object where the keys are global constant hashes and the values are the corresponding JSON Micheline expressions.
|
|
42
|
+
* @example
|
|
43
|
+
* ```
|
|
44
|
+
* const parserOptions: ParserOptions = {
|
|
45
|
+
* expandGlobalConstant: {
|
|
46
|
+
* 'expr...': { prim: 'DROP', args: [{ int: '2' }] }
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* const p = new Parser(parserOptions);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
expandGlobalConstant?: GlobalConstantHashAndValue;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Converts and validates Michelson expressions between JSON-based Michelson and Micheline
|
|
57
|
+
*
|
|
58
|
+
* Pretty Print a Michelson Smart Contract:
|
|
59
|
+
* ```
|
|
60
|
+
* const contract = await Tezos.contract.at("KT1Vsw3kh9638gqWoHTjvHCoHLPKvCbMVbCg");
|
|
61
|
+
* const p = new Parser();
|
|
62
|
+
*
|
|
63
|
+
* const michelsonCode = p.parseJSON(contract.script.code);
|
|
64
|
+
* const storage = p.parseJSON(contract.script.storage);
|
|
65
|
+
*
|
|
66
|
+
* console.log("Pretty print Michelson smart contract:");
|
|
67
|
+
* console.log(emitMicheline(michelsonCode, {indent:" ", newline: "\n",}));
|
|
68
|
+
*
|
|
69
|
+
* console.log("Pretty print Storage:");
|
|
70
|
+
* console.log(emitMicheline(storage, {indent:" ", newline: "\n",}));
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Encode a Michelson expression for initial storage of a smart contract
|
|
74
|
+
* ```
|
|
75
|
+
* const src = `(Pair (Pair { Elt 1
|
|
76
|
+
* (Pair (Pair "tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")
|
|
77
|
+
* 0x0501000000026869) }
|
|
78
|
+
* 10000000)
|
|
79
|
+
* (Pair 2 333))`;
|
|
80
|
+
*
|
|
81
|
+
* const p = new Parser();
|
|
82
|
+
*
|
|
83
|
+
* const exp = p.parseMichelineExpression(src);
|
|
84
|
+
* console.log(JSON.stringify(exp));
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare class Parser {
|
|
88
|
+
private opt?;
|
|
89
|
+
constructor(opt?: ParserOptions | undefined);
|
|
90
|
+
private expand;
|
|
91
|
+
private parseListExpr;
|
|
92
|
+
private parseArgs;
|
|
93
|
+
private parseSequenceExpr;
|
|
94
|
+
private parseExpr;
|
|
95
|
+
/**
|
|
96
|
+
* Parses a Micheline sequence expression, such as smart contract source. Enclosing curly brackets may be omitted.
|
|
97
|
+
* @param src A Micheline sequence `{parameter ...; storage int; code { DUP ; ...};}` or `parameter ...; storage int; code { DUP ; ...};`
|
|
98
|
+
*/
|
|
99
|
+
parseSequence(src: string): Expr[] | null;
|
|
100
|
+
/**
|
|
101
|
+
* Parse a Micheline sequence expression. Enclosing curly brackets may be omitted.
|
|
102
|
+
* @param src A Michelson list expression such as `(Pair {Elt "0" 0} 0)` or `Pair {Elt "0" 0} 0`
|
|
103
|
+
* @returns An AST node or null for empty document.
|
|
104
|
+
*/
|
|
105
|
+
parseList(src: string): Expr | null;
|
|
106
|
+
/**
|
|
107
|
+
* Parse any Michelson expression
|
|
108
|
+
* @param src A Michelson expression such as `(Pair {Elt "0" 0} 0)` or `{parameter ...; storage int; code { DUP ; ...};}`
|
|
109
|
+
* @returns An AST node or null for empty document.
|
|
110
|
+
*/
|
|
111
|
+
parseMichelineExpression(src: string): Expr | null;
|
|
112
|
+
/**
|
|
113
|
+
* Parse a Micheline sequence expression, such as smart contract source. Enclosing curly brackets may be omitted.
|
|
114
|
+
* An alias for `parseSequence`
|
|
115
|
+
* @param src A Micheline sequence `{parameter ...; storage int; code { DUP ; ...};}` or `parameter ...; storage int; code { DUP ; ...};`
|
|
116
|
+
*/
|
|
117
|
+
parseScript(src: string): Expr[] | null;
|
|
118
|
+
/**
|
|
119
|
+
* Parse a Micheline sequence expression. Enclosing curly brackets may be omitted.
|
|
120
|
+
* An alias for `parseList`
|
|
121
|
+
* @param src A Michelson list expression such as `(Pair {Elt "0" 0} 0)` or `Pair {Elt "0" 0} 0`
|
|
122
|
+
* @returns An AST node or null for empty document.
|
|
123
|
+
*/
|
|
124
|
+
parseData(src: string): Expr | null;
|
|
125
|
+
/**
|
|
126
|
+
* Takes a JSON-encoded Michelson, validates it, strips away unneeded properties and optionally expands macros (See {@link ParserOptions}).
|
|
127
|
+
* @param src An object containing JSON-encoded Michelson, usually returned by `JSON.parse()`
|
|
128
|
+
*/
|
|
129
|
+
parseJSON(src: object): Expr;
|
|
130
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type SourceReference = {
|
|
2
|
+
first: number;
|
|
3
|
+
last: number;
|
|
4
|
+
macro?: Expr;
|
|
5
|
+
globalConstant?: Expr;
|
|
6
|
+
};
|
|
7
|
+
export declare const sourceReference: unique symbol;
|
|
8
|
+
export interface Node {
|
|
9
|
+
[sourceReference]?: SourceReference;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An AST node representing Michelson string literal.
|
|
13
|
+
*/
|
|
14
|
+
export interface StringLiteral extends Node {
|
|
15
|
+
string: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An AST node representing Michelson int literal.
|
|
19
|
+
*/
|
|
20
|
+
export interface IntLiteral<T extends string = string> extends Node {
|
|
21
|
+
int: T;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An AST node representing Michelson bytes literal.
|
|
25
|
+
*/
|
|
26
|
+
export interface BytesLiteral extends Node {
|
|
27
|
+
bytes: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An AST node representing Michelson primitive.
|
|
31
|
+
*/
|
|
32
|
+
export interface Prim<PT extends string = string, AT extends Expr[] = Expr[]> extends Node {
|
|
33
|
+
prim: PT;
|
|
34
|
+
args?: AT;
|
|
35
|
+
annots?: string[];
|
|
36
|
+
}
|
|
37
|
+
export type List<T extends Expr> = T[] & Node;
|
|
38
|
+
interface ExprList extends List<Expr> {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* An AST node representing valid Michelson expression. Directly corresponds to JSON-encoded Michelson node
|
|
42
|
+
*/
|
|
43
|
+
export type Expr = Prim | StringLiteral | IntLiteral | BytesLiteral | ExprList;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MichelsonContract, MichelsonContractSection, MichelsonType, MichelsonData, MichelsonCode, MichelsonReturnType } from './michelson-types';
|
|
2
|
+
import { InstructionTrace } from './michelson-typecheck';
|
|
3
|
+
import { ParserOptions } from './micheline-parser';
|
|
4
|
+
export interface ContractOptions extends ParserOptions {
|
|
5
|
+
traceCallback?: (t: InstructionTrace) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare class Contract {
|
|
8
|
+
readonly contract: MichelsonContract;
|
|
9
|
+
private ctx;
|
|
10
|
+
readonly output: MichelsonReturnType;
|
|
11
|
+
constructor(contract: MichelsonContract, opt?: ContractOptions);
|
|
12
|
+
static parse(src: string | object, opt?: ContractOptions): Contract;
|
|
13
|
+
static parseTypeExpression(src: string | object, opt?: ParserOptions): MichelsonType;
|
|
14
|
+
static parseDataExpression(src: string | object, opt?: ParserOptions): MichelsonData;
|
|
15
|
+
section<T extends 'parameter' | 'storage' | 'code'>(section: T): MichelsonContractSection<T>;
|
|
16
|
+
entryPoints(): [string, MichelsonType][];
|
|
17
|
+
entryPoint(ep?: string): MichelsonType | null;
|
|
18
|
+
assertDataValid(d: MichelsonData, t: MichelsonType): void;
|
|
19
|
+
isDataValid(d: MichelsonData, t: MichelsonType): boolean;
|
|
20
|
+
assertParameterValid(ep: string | null, d: MichelsonData): void;
|
|
21
|
+
isParameterValid(ep: string | null, d: MichelsonData): boolean;
|
|
22
|
+
functionType(inst: MichelsonCode, stack: MichelsonType[]): MichelsonReturnType;
|
|
23
|
+
}
|
|
24
|
+
export declare const dummyContract: Contract;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MichelsonType, MichelsonData, MichelsonCode, MichelsonContract, MichelsonContractSection, MichelsonReturnType, MichelsonContractView } from './michelson-types';
|
|
2
|
+
import { MichelsonError } from './utils';
|
|
3
|
+
import { ParserOptions } from './micheline-parser';
|
|
4
|
+
export interface Context extends ParserOptions {
|
|
5
|
+
contract?: MichelsonContract;
|
|
6
|
+
traceCallback?: (t: InstructionTrace) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare class MichelsonInstructionError extends MichelsonError<MichelsonCode> {
|
|
9
|
+
readonly val: MichelsonCode;
|
|
10
|
+
readonly stackState: MichelsonReturnType;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
/**
|
|
13
|
+
* @param val Value of a type node caused the error
|
|
14
|
+
* @param stackState Current stack state
|
|
15
|
+
* @param message An error message
|
|
16
|
+
*/
|
|
17
|
+
constructor(val: MichelsonCode, stackState: MichelsonReturnType, message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function assertTypeAnnotationsValid(t: MichelsonType, field?: boolean): void;
|
|
20
|
+
export interface InstructionTrace {
|
|
21
|
+
op: MichelsonCode;
|
|
22
|
+
in: MichelsonType[];
|
|
23
|
+
out: MichelsonReturnType;
|
|
24
|
+
}
|
|
25
|
+
export declare function contractSection<T extends 'parameter' | 'storage' | 'code'>(contract: MichelsonContract, section: T): MichelsonContractSection<T>;
|
|
26
|
+
export declare function contractViews(contract: MichelsonContract): {
|
|
27
|
+
[name: string]: MichelsonContractView;
|
|
28
|
+
};
|
|
29
|
+
export declare function contractEntryPoint(src: MichelsonContract | MichelsonType, ep?: string): MichelsonType | null;
|
|
30
|
+
export declare function contractEntryPoints(src: MichelsonContract | MichelsonType): [string, MichelsonType][];
|
|
31
|
+
export declare function assertContractValid(contract: MichelsonContract, ctx?: Context): MichelsonReturnType;
|
|
32
|
+
export declare function assertDataValid(d: MichelsonData, t: MichelsonType, ctx?: Context): void;
|
|
33
|
+
export declare function functionType(inst: MichelsonCode, stack: MichelsonType[], ctx?: Context): MichelsonReturnType;
|
|
34
|
+
export declare function assertTypesEqual<T1 extends MichelsonType | MichelsonType[], T2 extends T1>(a: T1, b: T2, field?: boolean): void;
|
|
35
|
+
export declare function isTypeAnnotationsValid(t: MichelsonType, field?: boolean): boolean;
|
|
36
|
+
export declare function isContractValid(contract: MichelsonContract, ctx?: Context): MichelsonReturnType | null;
|
|
37
|
+
export declare function isDataValid(d: MichelsonData, t: MichelsonType, ctx?: Context): boolean;
|
|
38
|
+
export declare function isTypeEqual<T1 extends MichelsonType | MichelsonType[], T2 extends T1>(a: T1, b: T2, field?: boolean): boolean;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Prim, Expr, IntLiteral, StringLiteral, BytesLiteral, List, Node } from './micheline';
|
|
2
|
+
interface Prim0<PT extends string = string> extends Prim<PT> {
|
|
3
|
+
args?: never;
|
|
4
|
+
}
|
|
5
|
+
interface PrimX<PT extends string = string, AT extends Expr[] = Expr[]> extends Prim<PT, AT> {
|
|
6
|
+
args: AT;
|
|
7
|
+
}
|
|
8
|
+
type MichelsonNoArgInstructionID = 'ABS' | 'ADD' | 'ADDRESS' | 'AMOUNT' | 'AND' | 'APPLY' | 'BALANCE' | 'BLAKE2B' | 'CAR' | 'CDR' | 'CHAIN_ID' | 'CHECK_SIGNATURE' | 'COMPARE' | 'CONCAT' | 'CONS' | 'EDIV' | 'EQ' | 'EXEC' | 'FAILWITH' | 'GE' | 'GET_AND_UPDATE' | 'GT' | 'HASH_KEY' | 'IMPLICIT_ACCOUNT' | 'INT' | 'ISNAT' | 'JOIN_TICKETS' | 'KECCAK' | 'LE' | 'LEVEL' | 'LSL' | 'LSR' | 'LT' | 'MEM' | 'MUL' | 'NEG' | 'NEQ' | 'NEVER' | 'NOT' | 'NOW' | 'OR' | 'PACK' | 'PAIRING_CHECK' | 'READ_TICKET' | 'SAPLING_VERIFY_UPDATE' | 'SELF' | 'SELF_ADDRESS' | 'SENDER' | 'SET_DELEGATE' | 'SHA256' | 'SHA3' | 'SHA512' | 'SIZE' | 'SLICE' | 'SOME' | 'SOURCE' | 'SPLIT_TICKET' | 'SUB' | 'SUB_MUTEZ' | 'SWAP' | 'TICKET' | 'TICKET_DEPRECATED' | 'TOTAL_VOTING_POWER' | 'TRANSFER_TOKENS' | 'UNIT' | 'VOTING_POWER' | 'XOR' | 'RENAME' | 'OPEN_CHEST' | 'MIN_BLOCK_TIME' | 'BYTES' | 'NAT' | 'IS_IMPLICIT_ACCOUNT' | 'INDEX_ADDRESS' | 'GET_ADDRESS_INDEX';
|
|
9
|
+
type MichelsonRegularInstructionID = 'CONTRACT' | 'CREATE_CONTRACT' | 'DIG' | 'DIP' | 'DROP' | 'DUG' | 'DUP' | 'EMPTY_BIG_MAP' | 'EMPTY_MAP' | 'EMPTY_SET' | 'GET' | 'IF' | 'IF_CONS' | 'IF_LEFT' | 'IF_NONE' | 'ITER' | 'LAMBDA' | 'LAMBDA_REC' | 'LEFT' | 'LOOP' | 'LOOP_LEFT' | 'MAP' | 'NIL' | 'NONE' | 'PAIR' | 'PUSH' | 'RIGHT' | 'SAPLING_EMPTY_STATE' | 'UNPACK' | 'UNPAIR' | 'UPDATE' | 'CAST' | 'VIEW' | 'EMIT' | 'CREATE_ACCOUNT' | 'STEPS_TO_QUOTA';
|
|
10
|
+
export type MichelsonInstructionID = MichelsonNoArgInstructionID | MichelsonRegularInstructionID;
|
|
11
|
+
type InstrPrim<PT extends MichelsonInstructionID, AT extends Expr[]> = Prim<PT, AT>;
|
|
12
|
+
type Instr0<PT extends MichelsonNoArgInstructionID> = Prim0<PT>;
|
|
13
|
+
type InstrX<PT extends MichelsonRegularInstructionID, AT extends Expr[]> = PrimX<PT, AT>;
|
|
14
|
+
export type MichelsonCode = InstructionList | MichelsonInstruction;
|
|
15
|
+
export interface InstructionList extends List<MichelsonCode> {
|
|
16
|
+
}
|
|
17
|
+
export type MichelsonNoArgInstruction = Instr0<MichelsonNoArgInstructionID>;
|
|
18
|
+
export type MichelsonInstruction = MichelsonNoArgInstruction | InstrX<'DIG' | 'DUG' | 'SAPLING_EMPTY_STATE', [IntLiteral]> | InstrX<'NONE' | 'LEFT' | 'RIGHT' | 'NIL' | 'CAST', [MichelsonType]> | InstrX<'IF_NONE' | 'IF_LEFT' | 'IF_CONS' | 'IF', [InstructionList, InstructionList]> | InstrX<'MAP' | 'ITER' | 'LOOP' | 'LOOP_LEFT' | 'DIP', [InstructionList]> | InstrX<'UNPACK', [MichelsonType]> | InstrX<'CONTRACT', [MichelsonType]> | InstrX<'CREATE_CONTRACT', [MichelsonContract]> | InstrX<'PUSH', [MichelsonType, MichelsonData]> | InstrX<'EMPTY_SET', [MichelsonType]> | InstrX<'EMPTY_MAP', [MichelsonType, MichelsonType]> | InstrX<'EMPTY_BIG_MAP', [MichelsonType, MichelsonType]> | InstrX<'LAMBDA' | 'LAMBDA_REC', [MichelsonType, MichelsonType, InstructionList]> | InstrX<'DIP', [IntLiteral, InstructionList] | [InstructionList]> | InstrX<'VIEW', [StringLiteral, MichelsonType]> | InstrX<'EMIT', [MichelsonType]> | InstrPrim<'DROP' | 'PAIR' | 'UNPAIR' | 'DUP' | 'GET' | 'UPDATE', [IntLiteral]>;
|
|
19
|
+
export type MichelsonSimpleComparableTypeID = 'string' | 'nat' | 'int' | 'bytes' | 'bool' | 'mutez' | 'key_hash' | 'address' | 'timestamp' | 'never' | 'key' | 'unit' | 'signature' | 'chain_id' | 'tx_rollup_l2_address';
|
|
20
|
+
export type MichelsonTypeID = MichelsonSimpleComparableTypeID | 'option' | 'list' | 'set' | 'contract' | 'operation' | 'pair' | 'or' | 'lambda' | 'map' | 'big_map' | 'sapling_transaction' | 'sapling_transaction_deprecated' | 'sapling_state' | 'ticket' | 'bls12_381_g1' | 'bls12_381_g2' | 'bls12_381_fr' | 'chest_key' | 'chest';
|
|
21
|
+
type Type0<PT extends MichelsonTypeID> = Prim0<PT>;
|
|
22
|
+
type TypeX<PT extends MichelsonTypeID, AT extends Expr[]> = PrimX<PT, AT>;
|
|
23
|
+
export declare const refContract: unique symbol;
|
|
24
|
+
export interface MichelsonTypeAddress extends Type0<'address'> {
|
|
25
|
+
[refContract]?: MichelsonTypeContract<MichelsonType>;
|
|
26
|
+
}
|
|
27
|
+
export type MichelsonTypeInt = Type0<'int'>;
|
|
28
|
+
export type MichelsonTypeNat = Type0<'nat'>;
|
|
29
|
+
export type MichelsonTypeString = Type0<'string'>;
|
|
30
|
+
export type MichelsonTypeBytes = Type0<'bytes'>;
|
|
31
|
+
export type MichelsonTypeMutez = Type0<'mutez'>;
|
|
32
|
+
export type MichelsonTypeBool = Type0<'bool'>;
|
|
33
|
+
export type MichelsonTypeKeyHash = Type0<'key_hash'>;
|
|
34
|
+
export type MichelsonTypeTimestamp = Type0<'timestamp'>;
|
|
35
|
+
export type MichelsonTypeKey = Type0<'key'>;
|
|
36
|
+
export type MichelsonTypeUnit = Type0<'unit'>;
|
|
37
|
+
export type MichelsonTypeSignature = Type0<'signature'>;
|
|
38
|
+
export type MichelsonTypeOperation = Type0<'operation'>;
|
|
39
|
+
export type MichelsonTypeChainID = Type0<'chain_id'>;
|
|
40
|
+
export type MichelsonTypeNever = Type0<'never'>;
|
|
41
|
+
export type MichelsonTypeBLS12_381_G1 = Type0<'bls12_381_g1'>;
|
|
42
|
+
export type MichelsonTypeBLS12_381_G2 = Type0<'bls12_381_g2'>;
|
|
43
|
+
export type MichelsonTypeBLS12_381_FR = Type0<'bls12_381_fr'>;
|
|
44
|
+
export type MichelsonTypeChestKey = Type0<'chest_key'>;
|
|
45
|
+
export type MichelsonTypeChest = Type0<'chest'>;
|
|
46
|
+
type TypeList<T extends MichelsonType[]> = T & Node;
|
|
47
|
+
export type MichelsonTypePair<T extends MichelsonType[]> = TypeX<'pair', T> | TypeList<T>;
|
|
48
|
+
export interface MichelsonTypeOption<T extends MichelsonType> extends TypeX<'option', [T]> {
|
|
49
|
+
}
|
|
50
|
+
export interface MichelsonTypeList<T extends MichelsonType> extends TypeX<'list', [T]> {
|
|
51
|
+
}
|
|
52
|
+
export interface MichelsonTypeContract<T extends MichelsonType> extends TypeX<'contract', [T]> {
|
|
53
|
+
}
|
|
54
|
+
export interface MichelsonTypeOr<T extends [MichelsonType, MichelsonType]> extends TypeX<'or', T> {
|
|
55
|
+
}
|
|
56
|
+
export interface MichelsonTypeLambda<Arg extends MichelsonType, Ret extends MichelsonType> extends TypeX<'lambda', [Arg, Ret]> {
|
|
57
|
+
}
|
|
58
|
+
export interface MichelsonTypeSet<T extends MichelsonType> extends TypeX<'set', [T]> {
|
|
59
|
+
}
|
|
60
|
+
export interface MichelsonTypeMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<'map', [K, V]> {
|
|
61
|
+
}
|
|
62
|
+
export interface MichelsonTypeBigMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<'big_map', [K, V]> {
|
|
63
|
+
}
|
|
64
|
+
export interface MichelsonTypeSaplingState<S extends string = string> extends TypeX<'sapling_state', [IntLiteral<S>]> {
|
|
65
|
+
}
|
|
66
|
+
export interface MichelsonTypeSaplingTransaction<S extends string = string> extends TypeX<'sapling_transaction', [IntLiteral<S>]> {
|
|
67
|
+
}
|
|
68
|
+
export interface MichelsonTypeTicket<T extends MichelsonType> extends TypeX<'ticket', [T]> {
|
|
69
|
+
}
|
|
70
|
+
export type MichelsonType<T extends MichelsonTypeID = MichelsonTypeID> = T extends 'int' ? MichelsonTypeInt : T extends 'nat' ? MichelsonTypeNat : T extends 'string' ? MichelsonTypeString : T extends 'bytes' ? MichelsonTypeBytes : T extends 'mutez' ? MichelsonTypeMutez : T extends 'bool' ? MichelsonTypeBool : T extends 'key_hash' ? MichelsonTypeKeyHash : T extends 'timestamp' ? MichelsonTypeTimestamp : T extends 'address' ? MichelsonTypeAddress : T extends 'key' ? MichelsonTypeKey : T extends 'unit' ? MichelsonTypeUnit : T extends 'signature' ? MichelsonTypeSignature : T extends 'operation' ? MichelsonTypeOperation : T extends 'chain_id' ? MichelsonTypeChainID : T extends 'option' ? MichelsonTypeOption<MichelsonType> : T extends 'list' ? MichelsonTypeList<MichelsonType> : T extends 'contract' ? MichelsonTypeContract<MichelsonType> : T extends 'ticket' ? MichelsonTypeTicket<MichelsonType> : T extends 'pair' ? MichelsonTypePair<MichelsonType[]> : T extends 'or' ? MichelsonTypeOr<[MichelsonType, MichelsonType]> : T extends 'lambda' ? MichelsonTypeLambda<MichelsonType, MichelsonType> : T extends 'set' ? MichelsonTypeSet<MichelsonType> : T extends 'map' ? MichelsonTypeMap<MichelsonType, MichelsonType> : T extends 'big_map' ? MichelsonTypeBigMap<MichelsonType, MichelsonType> : T extends 'never' ? MichelsonTypeNever : T extends 'bls12_381_g1' ? MichelsonTypeBLS12_381_G1 : T extends 'bls12_381_g2' ? MichelsonTypeBLS12_381_G2 : T extends 'bls12_381_fr' ? MichelsonTypeBLS12_381_FR : T extends 'sapling_transaction' ? MichelsonTypeSaplingTransaction : T extends 'sapling_state' ? MichelsonTypeSaplingState : T extends 'chest_key' ? MichelsonTypeChestKey : MichelsonTypeChest;
|
|
71
|
+
export type MichelsonDataID = 'Unit' | 'True' | 'False' | 'None' | 'Pair' | 'Left' | 'Right' | 'Some' | 'Lambda_rec' | 'Ticket';
|
|
72
|
+
type Data0<PT extends MichelsonDataID> = Prim0<PT>;
|
|
73
|
+
type DataX<PT extends MichelsonDataID, AT extends MichelsonData[]> = PrimX<PT, AT>;
|
|
74
|
+
export type MichelsonDataOption = DataX<'Some', [MichelsonData]> | Data0<'None'>;
|
|
75
|
+
export type MichelsonDataOr = DataX<'Left' | 'Right', [MichelsonData]>;
|
|
76
|
+
type DataList<T extends MichelsonData[]> = T & Node;
|
|
77
|
+
export type MichelsonDataPair<T extends MichelsonData[]> = DataX<'Pair', T> | DataList<T>;
|
|
78
|
+
export type MichelsonMapElt = PrimX<'Elt', [MichelsonData, MichelsonData]>;
|
|
79
|
+
export type MichelsonMapEltList = List<MichelsonMapElt>;
|
|
80
|
+
export type MichelsonLambdaRec = DataX<'Lambda_rec', [InstructionList]>;
|
|
81
|
+
export type MichelsonTicket = PrimX<'Ticket', [
|
|
82
|
+
StringLiteral | BytesLiteral,
|
|
83
|
+
MichelsonType,
|
|
84
|
+
MichelsonData,
|
|
85
|
+
IntLiteral
|
|
86
|
+
]>;
|
|
87
|
+
export type MichelsonData = IntLiteral | StringLiteral | BytesLiteral | Data0<'Unit' | 'True' | 'False'> | MichelsonDataOption | MichelsonDataOr | DataList<MichelsonData[]> | MichelsonDataPair<MichelsonData[]> | InstructionList | MichelsonMapEltList | MichelsonLambdaRec | MichelsonTicket;
|
|
88
|
+
export type MichelsonSectionID = 'parameter' | 'storage' | 'code' | 'view';
|
|
89
|
+
type SectionPrim<PT extends MichelsonSectionID, AT extends Expr[]> = PrimX<PT, AT>;
|
|
90
|
+
export type MichelsonContractParameter = SectionPrim<'parameter', [MichelsonType]>;
|
|
91
|
+
export type MichelsonContractStorage = SectionPrim<'storage', [MichelsonType]>;
|
|
92
|
+
export type MichelsonContractCode = SectionPrim<'code', [InstructionList]>;
|
|
93
|
+
export type MichelsonContractView = SectionPrim<'view', [
|
|
94
|
+
StringLiteral,
|
|
95
|
+
MichelsonType,
|
|
96
|
+
MichelsonType,
|
|
97
|
+
InstructionList
|
|
98
|
+
]>;
|
|
99
|
+
export type MichelsonContract = MichelsonContractSection[];
|
|
100
|
+
export type MichelsonContractSection<T extends MichelsonSectionID = MichelsonSectionID> = T extends 'parameter' ? MichelsonContractParameter : T extends 'storage' ? MichelsonContractStorage : T extends 'view' ? MichelsonContractView : MichelsonContractCode;
|
|
101
|
+
export interface MichelsonTypeFailed {
|
|
102
|
+
failed: MichelsonType;
|
|
103
|
+
level: number;
|
|
104
|
+
}
|
|
105
|
+
export type MichelsonReturnType = MichelsonType[] | MichelsonTypeFailed;
|
|
106
|
+
export declare enum Protocol {
|
|
107
|
+
Ps9mPmXa = "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P",
|
|
108
|
+
PtCJ7pwo = "PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY",
|
|
109
|
+
PsYLVpVv = "PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt",
|
|
110
|
+
PsddFKi3 = "PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP",
|
|
111
|
+
Pt24m4xi = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",
|
|
112
|
+
PsBABY5H = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",
|
|
113
|
+
PsBabyM1 = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",
|
|
114
|
+
PsCARTHA = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",
|
|
115
|
+
PsDELPH1 = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
|
|
116
|
+
PtEdoTez = "PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq",
|
|
117
|
+
PtEdo2Zk = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",
|
|
118
|
+
PsFLorena = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",
|
|
119
|
+
PtGRANADs = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",
|
|
120
|
+
PtHangzH = "PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r",
|
|
121
|
+
PtHangz2 = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",
|
|
122
|
+
PsiThaCa = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",
|
|
123
|
+
Psithaca2 = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",
|
|
124
|
+
PtJakarta = "PtJakartaiDz69SfDDLXJSiuZqTSeSKRDbKVZC8MNzJnvRjvnGw",
|
|
125
|
+
PtJakart2 = "PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",
|
|
126
|
+
PtKathman = "PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",
|
|
127
|
+
PtLimaPtL = "PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",
|
|
128
|
+
PtMumbaii = "PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",
|
|
129
|
+
PtMumbai2 = "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",
|
|
130
|
+
PtNairobi = "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",
|
|
131
|
+
ProxfordY = "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",
|
|
132
|
+
PtParisBx = "PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",
|
|
133
|
+
PsParisCZ = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",
|
|
134
|
+
PsQuebecn = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",
|
|
135
|
+
PsRiotuma = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",
|
|
136
|
+
PtSeouLou = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",
|
|
137
|
+
PtTALLiNt = "PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",
|
|
138
|
+
ProtoALpha = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"
|
|
139
|
+
}
|
|
140
|
+
export declare const DefaultProtocol = Protocol.PtTALLiNt;
|
|
141
|
+
export type ProtocolID = `${Protocol}`;
|
|
142
|
+
export declare function ProtoGreaterOrEqual(a: ProtocolID, b: ProtocolID): boolean;
|
|
143
|
+
export declare function ProtoInferiorTo(a: ProtocolID, b: ProtocolID): boolean;
|
|
144
|
+
export interface ProtocolOptions {
|
|
145
|
+
protocol?: ProtocolID;
|
|
146
|
+
}
|
|
147
|
+
export {};
|