@lucid-evolution/uplc 0.4.0 → 0.5.1

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.
Binary file
@@ -1,13 +1,41 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_evalbuiltinresult_free: (a: number, b: number) => void;
4
5
  export const __wbg_evalprogramresult_free: (a: number, b: number) => void;
5
- export const __wbg_get_evalprogramresult_cpu: (a: number) => bigint;
6
+ export const __wbg_get_evalbuiltinresult_cpu: (a: number) => bigint;
7
+ export const __wbg_get_evalbuiltinresult_error: (a: number) => [number, number];
8
+ export const __wbg_get_evalbuiltinresult_error_kind: (a: number) => number;
9
+ export const __wbg_get_evalbuiltinresult_mem: (a: number) => bigint;
10
+ export const __wbg_get_evalbuiltinresult_ok: (a: number) => number;
11
+ export const __wbg_get_evalbuiltinresult_result: (
12
+ a: number,
13
+ ) => [number, number];
14
+ export const __wbg_get_evalbuiltinresult_result_kind: (a: number) => number;
6
15
  export const __wbg_get_evalprogramresult_error_kind: (a: number) => number;
7
16
  export const __wbg_get_evalprogramresult_logs: (a: number) => [number, number];
8
- export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
9
17
  export const __wbg_get_evalprogramresult_ok: (a: number) => number;
10
- export const __wbg_set_evalprogramresult_cpu: (a: number, b: bigint) => void;
18
+ export const __wbg_set_evalbuiltinresult_cpu: (a: number, b: bigint) => void;
19
+ export const __wbg_set_evalbuiltinresult_error: (
20
+ a: number,
21
+ b: number,
22
+ c: number,
23
+ ) => void;
24
+ export const __wbg_set_evalbuiltinresult_error_kind: (
25
+ a: number,
26
+ b: number,
27
+ ) => void;
28
+ export const __wbg_set_evalbuiltinresult_mem: (a: number, b: bigint) => void;
29
+ export const __wbg_set_evalbuiltinresult_ok: (a: number, b: number) => void;
30
+ export const __wbg_set_evalbuiltinresult_result: (
31
+ a: number,
32
+ b: number,
33
+ c: number,
34
+ ) => void;
35
+ export const __wbg_set_evalbuiltinresult_result_kind: (
36
+ a: number,
37
+ b: number,
38
+ ) => void;
11
39
  export const __wbg_set_evalprogramresult_error_kind: (
12
40
  a: number,
13
41
  b: number,
@@ -17,7 +45,6 @@ export const __wbg_set_evalprogramresult_logs: (
17
45
  b: number,
18
46
  c: number,
19
47
  ) => void;
20
- export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
21
48
  export const __wbg_set_evalprogramresult_ok: (a: number, b: number) => void;
22
49
  export const apply_params_to_script: (
23
50
  a: number,
@@ -25,6 +52,14 @@ export const apply_params_to_script: (
25
52
  c: number,
26
53
  d: number,
27
54
  ) => [number, number, number, number];
55
+ export const eval_builtin_raw: (
56
+ a: number,
57
+ b: number,
58
+ c: number,
59
+ d: number,
60
+ e: number,
61
+ f: number,
62
+ ) => [number, number, number];
28
63
  export const eval_phase_two_raw: (
29
64
  a: number,
30
65
  b: number,
@@ -56,7 +91,10 @@ export const eval_program_raw: (
56
91
  k: number,
57
92
  ) => [number, number, number];
58
93
  export const uplc_build_info: () => [number, number];
59
- export const __wbindgen_export_0: WebAssembly.Table;
94
+ export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
95
+ export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
96
+ export const __wbg_set_evalprogramresult_cpu: (a: number, b: bigint) => void;
97
+ export const __wbg_get_evalprogramresult_cpu: (a: number) => bigint;
60
98
  export const __wbindgen_malloc: (a: number, b: number) => number;
61
99
  export const __wbindgen_realloc: (
62
100
  a: number,
@@ -64,8 +102,9 @@ export const __wbindgen_realloc: (
64
102
  c: number,
65
103
  d: number,
66
104
  ) => number;
67
- export const __externref_table_alloc: () => number;
105
+ export const __wbindgen_externrefs: WebAssembly.Table;
68
106
  export const __externref_table_dealloc: (a: number) => void;
69
- export const __externref_drop_slice: (a: number, b: number) => void;
70
107
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
108
+ export const __externref_table_alloc: () => number;
109
+ export const __externref_drop_slice: (a: number, b: number) => void;
71
110
  export const __wbindgen_start: () => void;
@@ -0,0 +1,11 @@
1
+ export {
2
+ apply_params_to_script,
3
+ eval_builtin_raw,
4
+ eval_phase_two_raw,
5
+ eval_program_raw,
6
+ uplc_build_info,
7
+ BuiltinErrorKind,
8
+ BuiltinValueKind,
9
+ EvalBuiltinResult,
10
+ EvalProgramResult,
11
+ } from "./node/uplc_tx.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ // The Node.js entry: the bindings in ./node, recovering from a wasm trap (see
4
+ // ../recover-from-trap.js). Each export is assigned by name so that ES module
5
+ // imports of this CommonJS file see it.
6
+ const bindings = require("./node/uplc_tx.js");
7
+ const recovering = require("../recover-from-trap.js")(bindings);
8
+
9
+ exports.apply_params_to_script = recovering(bindings.apply_params_to_script);
10
+ exports.eval_builtin_raw = recovering(bindings.eval_builtin_raw);
11
+ exports.eval_phase_two_raw = recovering(bindings.eval_phase_two_raw);
12
+ exports.eval_program_raw = recovering(bindings.eval_program_raw);
13
+ exports.uplc_build_info = recovering(bindings.uplc_build_info);
14
+ exports.BuiltinErrorKind = bindings.BuiltinErrorKind;
15
+ exports.BuiltinValueKind = bindings.BuiltinValueKind;
16
+ exports.EvalBuiltinResult = bindings.EvalBuiltinResult;
17
+ exports.EvalProgramResult = bindings.EvalProgramResult;
@@ -1,5 +1,194 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Why the builtin given to [`eval_builtin_raw`] did not return a value: the
6
+ * codes of the result's `error_kind`.
7
+ */
8
+ export enum BuiltinErrorKind {
9
+ /**
10
+ * The builtin returned a value.
11
+ */
12
+ Ok = 0,
13
+ /**
14
+ * The builtin is not available to Plutus V3 at the protocol version.
15
+ */
16
+ NotAvailable = 1,
17
+ /**
18
+ * The builtin did not accept its arguments, which fails the application
19
+ * before it is costed.
20
+ */
21
+ RejectedArguments = 2,
22
+ /**
23
+ * The builtin failed after it was costed.
24
+ */
25
+ Failed = 3,
26
+ }
27
+
28
+ /**
29
+ * How a value of [`eval_builtin_raw`] is encoded: the codes of its
30
+ * `arg_kinds` and of the result's `result_kind`.
31
+ */
32
+ export enum BuiltinValueKind {
33
+ /**
34
+ * A flat-encoded program whose body is a constant,
35
+ * `(program 1.1.0 (con …))`. A result in this form is always version
36
+ * 1.1.0.
37
+ */
38
+ Flat = 0,
39
+ /**
40
+ * A BLS12-381 G1 point, as its 48-byte compressed encoding.
41
+ */
42
+ G1 = 1,
43
+ /**
44
+ * A BLS12-381 G2 point, as its 96-byte compressed encoding.
45
+ */
46
+ G2 = 2,
47
+ /**
48
+ * A list of BLS12-381 G1 points, as their compressed encodings one after
49
+ * the other.
50
+ */
51
+ G1List = 3,
52
+ /**
53
+ * A list of BLS12-381 G2 points, as their compressed encodings one after
54
+ * the other.
55
+ */
56
+ G2List = 4,
57
+ /**
58
+ * An array of BLS12-381 G1 points, as their compressed encodings one after
59
+ * the other.
60
+ */
61
+ G1Array = 5,
62
+ /**
63
+ * An array of BLS12-381 G2 points, as their compressed encodings one after
64
+ * the other.
65
+ */
66
+ G2Array = 6,
67
+ }
68
+
69
+ /**
70
+ * The outcome of [`eval_builtin_raw`].
71
+ */
72
+ export class EvalBuiltinResult {
73
+ private constructor();
74
+ free(): void;
75
+ [Symbol.dispose](): void;
76
+ /**
77
+ * The CPU the builtin's cost model charges for this application, under
78
+ * Plutus' default cost model for Plutus V3 at the protocol version; 0
79
+ * when the builtin was not costed (error kinds 1 and 2). It leaves out the
80
+ * machine's own step costs for evaluating the application (the builtin,
81
+ * each force and each apply).
82
+ */
83
+ cpu: bigint;
84
+ /**
85
+ * Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
86
+ * it did, 1 when it is not available to Plutus V3 at the protocol version,
87
+ * 2 when it did not accept its arguments (so the machine fails before
88
+ * costing it) and 3 when it failed after being costed.
89
+ */
90
+ error_kind: number;
91
+ /**
92
+ * The evaluator's description of why the builtin did not return a value;
93
+ * empty when it did.
94
+ */
95
+ error: string;
96
+ /**
97
+ * The memory the builtin's cost model charges for this application; see
98
+ * `cpu`.
99
+ */
100
+ mem: bigint;
101
+ /**
102
+ * Whether the builtin returned a value.
103
+ */
104
+ ok: boolean;
105
+ /**
106
+ * How `result` encodes the value, a [`BuiltinValueKind`] as for the
107
+ * arguments of [`eval_builtin_raw`]; 0 when there is no value.
108
+ */
109
+ result_kind: number;
110
+ /**
111
+ * The value the builtin returned; empty when there is none.
112
+ */
113
+ result: Uint8Array;
114
+ }
115
+
116
+ /**
117
+ * The outcome of [`eval_program_raw`].
118
+ */
119
+ export class EvalProgramResult {
120
+ private constructor();
121
+ free(): void;
122
+ [Symbol.dispose](): void;
123
+ /**
124
+ * The CPU the program used. A program that went over budget is charged
125
+ * what it used up to the point where the machine stopped it.
126
+ */
127
+ cpu: bigint;
128
+ /**
129
+ * Why the program did not succeed: 0 when it did, 1 when it went over
130
+ * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
131
+ * returned something other than unit.
132
+ */
133
+ error_kind: number;
134
+ /**
135
+ * The messages the program traced, in order.
136
+ */
137
+ logs: string[];
138
+ /**
139
+ * The memory the program used.
140
+ */
141
+ mem: bigint;
142
+ /**
143
+ * Whether the program succeeded: it did not fail and, for Plutus V3, it
144
+ * returned unit.
145
+ */
146
+ ok: boolean;
147
+ }
148
+
149
+ export function apply_params_to_script(
150
+ params_bytes: Uint8Array,
151
+ plutus_script_bytes: Uint8Array,
152
+ ): Uint8Array;
153
+
154
+ /**
155
+ * Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
156
+ * evaluates it at a protocol version, without any program around it: the
157
+ * result, or how it fails, is what the machine gives for the saturated
158
+ * application.
159
+ *
160
+ * - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
161
+ * The Miller-loop builtins (68 to 70) are not supported, since their
162
+ * results cannot be returned.
163
+ * - `args`: exactly the builtin's arguments, in order, each encoded as the
164
+ * matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
165
+ * flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
166
+ * for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
167
+ * points, 5 for an array of G1 points and 6 for an array of G2 points, each
168
+ * list or array as the compressed points one after the other. Flat cannot
169
+ * encode BLS12-381 points, so they cross as their compressed bytes.
170
+ * - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
171
+ * 12 (Dijkstra). It decides which builtins are available and the semantics
172
+ * they have.
173
+ *
174
+ * The result's `cpu` and `mem` are the builtin's charge for the application
175
+ * under Plutus' default Plutus V3 cost model (not the ledger's protocol
176
+ * parameters), excluding the machine's per-step costs.
177
+ *
178
+ * Fails only when the inputs are malformed or unsupported: an unknown or
179
+ * Miller-loop tag, a number of arguments other than the builtin's arity, an
180
+ * argument that does not decode as its kind says or is not a constant, an
181
+ * invalid compressed point, a protocol version out of range, or a result that
182
+ * none of the kinds can encode. A builtin that fails is an
183
+ * [`EvalBuiltinResult`] that is not `ok`.
184
+ */
185
+ export function eval_builtin_raw(
186
+ tag: number,
187
+ args: Uint8Array[],
188
+ arg_kinds: Uint8Array,
189
+ protocol_major_version: number,
190
+ ): EvalBuiltinResult;
191
+
3
192
  export function eval_phase_two_raw(
4
193
  tx_bytes: Uint8Array,
5
194
  utxos_bytes_x: Uint8Array[],
@@ -12,10 +201,7 @@ export function eval_phase_two_raw(
12
201
  slot_config_z: number,
13
202
  protocol_major_version?: number | null,
14
203
  ): Uint8Array[];
15
- export function apply_params_to_script(
16
- params_bytes: Uint8Array,
17
- plutus_script_bytes: Uint8Array,
18
- ): Uint8Array;
204
+
19
205
  /**
20
206
  * Evaluates a UPLC program applied to Data arguments, outside of any
21
207
  * transaction: the caller builds whatever arguments the program expects,
@@ -48,6 +234,7 @@ export function eval_program_raw(
48
234
  budget_mem: bigint,
49
235
  strict_budget: boolean,
50
236
  ): EvalProgramResult;
237
+
51
238
  /**
52
239
  * Describes this build of the evaluator as JSON: the uplc crate it was built
53
240
  * from, the length of each Plutus version's cost model, and a digest of what a
@@ -56,34 +243,3 @@ export function eval_program_raw(
56
243
  * programs; `selfTest` says whether this one gives the expected results.
57
244
  */
58
245
  export function uplc_build_info(): string;
59
- /**
60
- * The outcome of [`eval_program_raw`].
61
- */
62
- export class EvalProgramResult {
63
- private constructor();
64
- free(): void;
65
- /**
66
- * Whether the program succeeded: it did not fail and, for Plutus V3, it
67
- * returned unit.
68
- */
69
- ok: boolean;
70
- /**
71
- * The CPU the program used. A program that went over budget is charged
72
- * what it used up to the point where the machine stopped it.
73
- */
74
- cpu: bigint;
75
- /**
76
- * The memory the program used.
77
- */
78
- mem: bigint;
79
- /**
80
- * Why the program did not succeed: 0 when it did, 1 when it went over
81
- * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
82
- * returned something other than unit.
83
- */
84
- error_kind: number;
85
- /**
86
- * The messages the program traced, in order.
87
- */
88
- logs: string[];
89
- }
@@ -1,5 +1,9 @@
1
+ /* @ts-self-types="./uplc_tx.d.ts" */
1
2
  import * as wasm from "./uplc_tx_bg.wasm";
2
- export * from "./uplc_tx_bg.js";
3
3
  import { __wbg_set_wasm } from "./uplc_tx_bg.js";
4
+
4
5
  __wbg_set_wasm(wasm);
5
6
  wasm.__wbindgen_start();
7
+ export {
8
+ BuiltinErrorKind, BuiltinValueKind, EvalBuiltinResult, EvalProgramResult, apply_params_to_script, eval_builtin_raw, eval_phase_two_raw, eval_program_raw, uplc_build_info
9
+ } from "./uplc_tx_bg.js";