@lucid-evolution/uplc 0.5.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
@@ -95,7 +95,6 @@ export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
95
95
  export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
96
96
  export const __wbg_set_evalprogramresult_cpu: (a: number, b: bigint) => void;
97
97
  export const __wbg_get_evalprogramresult_cpu: (a: number) => bigint;
98
- export const __wbindgen_export_0: WebAssembly.Table;
99
98
  export const __wbindgen_malloc: (a: number, b: number) => number;
100
99
  export const __wbindgen_realloc: (
101
100
  a: number,
@@ -103,8 +102,9 @@ export const __wbindgen_realloc: (
103
102
  c: number,
104
103
  d: number,
105
104
  ) => number;
106
- export const __externref_table_alloc: () => number;
105
+ export const __wbindgen_externrefs: WebAssembly.Table;
107
106
  export const __externref_table_dealloc: (a: number) => void;
108
- export const __externref_drop_slice: (a: number, b: number) => void;
109
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;
110
110
  export const __wbindgen_start: () => void;
@@ -1,98 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function eval_phase_two_raw(
4
- tx_bytes: Uint8Array,
5
- utxos_bytes_x: Uint8Array[],
6
- utxos_bytes_y: Uint8Array[],
7
- cost_mdls_bytes: Uint8Array,
8
- initial_budget_n: bigint,
9
- initial_budget_d: bigint,
10
- slot_config_x: bigint,
11
- slot_config_y: bigint,
12
- slot_config_z: number,
13
- protocol_major_version?: number | null,
14
- ): Uint8Array[];
15
- export function apply_params_to_script(
16
- params_bytes: Uint8Array,
17
- plutus_script_bytes: Uint8Array,
18
- ): Uint8Array;
19
- /**
20
- * Evaluates a UPLC program applied to Data arguments, outside of any
21
- * transaction: the caller builds whatever arguments the program expects,
22
- * including its script context.
23
- *
24
- * - `program_flat`: the program, flat-encoded without a CBOR wrapper.
25
- * - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
26
- * - `language`: the Plutus version to evaluate as, 1, 2 or 3.
27
- * - `protocol_major_version`: the protocol version whose semantics to use,
28
- * from 5 (Alonzo) to 12 (Dijkstra).
29
- * - `cost_model`: the cost model parameters, every one the evaluator knows
30
- * for this Plutus version (350 for Plutus V3), in the ledger's order.
31
- * - `budget_cpu`, `budget_mem`: the budget.
32
- * - `strict_budget`: charge every step as the machine takes it, and stop the
33
- * program as soon as it goes over budget, instead of charging steps and
34
- * checking the budget every 200 steps as the ledger does. Only the cost of a
35
- * program that fails differs: the ledger does not charge the steps it took
36
- * since the budget was last checked.
37
- *
38
- * Fails only when the inputs are malformed or unsupported. A program that fails
39
- * is an [`EvalProgramResult`] that is not `ok`.
40
- */
41
- export function eval_program_raw(
42
- program_flat: Uint8Array,
43
- args_cbor: Uint8Array[],
44
- language: number,
45
- protocol_major_version: number,
46
- cost_model: BigInt64Array,
47
- budget_cpu: bigint,
48
- budget_mem: bigint,
49
- strict_budget: boolean,
50
- ): EvalProgramResult;
51
- /**
52
- * Describes this build of the evaluator as JSON: the uplc crate it was built
53
- * from, the length of each Plutus version's cost model, and a digest of what a
54
- * fixed set of programs evaluate to, with their costs, under Plutus V3 and the
55
- * latest protocol version. Two builds with the same digest agree on those
56
- * programs; `selfTest` says whether this one gives the expected results.
57
- */
58
- export function uplc_build_info(): string;
59
- /**
60
- * Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
61
- * evaluates it at a protocol version, without any program around it: the
62
- * result, or how it fails, is what the machine gives for the saturated
63
- * application.
64
- *
65
- * - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
66
- * The Miller-loop builtins (68 to 70) are not supported, since their
67
- * results cannot be returned.
68
- * - `args`: exactly the builtin's arguments, in order, each encoded as the
69
- * matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
70
- * flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
71
- * for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
72
- * points, 5 for an array of G1 points and 6 for an array of G2 points, each
73
- * list or array as the compressed points one after the other. Flat cannot
74
- * encode BLS12-381 points, so they cross as their compressed bytes.
75
- * - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
76
- * 12 (Dijkstra). It decides which builtins are available and the semantics
77
- * they have.
78
- *
79
- * The result's `cpu` and `mem` are the builtin's charge for the application
80
- * under Plutus' default Plutus V3 cost model (not the ledger's protocol
81
- * parameters), excluding the machine's per-step costs.
82
- *
83
- * Fails only when the inputs are malformed or unsupported: an unknown or
84
- * Miller-loop tag, a number of arguments other than the builtin's arity, an
85
- * argument that does not decode as its kind says or is not a constant, an
86
- * invalid compressed point, a protocol version out of range, or a result that
87
- * none of the kinds can encode. A builtin that fails is an
88
- * [`EvalBuiltinResult`] that is not `ok`.
89
- */
90
- export function eval_builtin_raw(
91
- tag: number,
92
- args: Uint8Array[],
93
- arg_kinds: Uint8Array,
94
- protocol_major_version: number,
95
- ): EvalBuiltinResult;
3
+
96
4
  /**
97
5
  * Why the builtin given to [`eval_builtin_raw`] did not return a value: the
98
6
  * codes of the result's `error_kind`.
@@ -116,6 +24,7 @@ export enum BuiltinErrorKind {
116
24
  */
117
25
  Failed = 3,
118
26
  }
27
+
119
28
  /**
120
29
  * How a value of [`eval_builtin_raw`] is encoded: the codes of its
121
30
  * `arg_kinds` and of the result's `result_kind`.
@@ -156,16 +65,22 @@ export enum BuiltinValueKind {
156
65
  */
157
66
  G2Array = 6,
158
67
  }
68
+
159
69
  /**
160
70
  * The outcome of [`eval_builtin_raw`].
161
71
  */
162
72
  export class EvalBuiltinResult {
163
73
  private constructor();
164
74
  free(): void;
75
+ [Symbol.dispose](): void;
165
76
  /**
166
- * Whether the builtin returned a value.
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).
167
82
  */
168
- ok: boolean;
83
+ cpu: bigint;
169
84
  /**
170
85
  * Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
171
86
  * it did, 1 when it is not available to Plutus V3 at the protocol version,
@@ -174,53 +89,42 @@ export class EvalBuiltinResult {
174
89
  */
175
90
  error_kind: number;
176
91
  /**
177
- * How `result` encodes the value, a [`BuiltinValueKind`] as for the
178
- * arguments of [`eval_builtin_raw`]; 0 when there is no value.
92
+ * The evaluator's description of why the builtin did not return a value;
93
+ * empty when it did.
179
94
  */
180
- result_kind: number;
95
+ error: string;
181
96
  /**
182
- * The value the builtin returned; empty when there is none.
97
+ * The memory the builtin's cost model charges for this application; see
98
+ * `cpu`.
183
99
  */
184
- result: Uint8Array;
100
+ mem: bigint;
185
101
  /**
186
- * The CPU the builtin's cost model charges for this application, under
187
- * Plutus' default cost model for Plutus V3 at the protocol version; 0
188
- * when the builtin was not costed (error kinds 1 and 2). It leaves out the
189
- * machine's own step costs for evaluating the application (the builtin,
190
- * each force and each apply).
102
+ * Whether the builtin returned a value.
191
103
  */
192
- cpu: bigint;
104
+ ok: boolean;
193
105
  /**
194
- * The memory the builtin's cost model charges for this application; see
195
- * `cpu`.
106
+ * How `result` encodes the value, a [`BuiltinValueKind`] as for the
107
+ * arguments of [`eval_builtin_raw`]; 0 when there is no value.
196
108
  */
197
- mem: bigint;
109
+ result_kind: number;
198
110
  /**
199
- * The evaluator's description of why the builtin did not return a value;
200
- * empty when it did.
111
+ * The value the builtin returned; empty when there is none.
201
112
  */
202
- error: string;
113
+ result: Uint8Array;
203
114
  }
115
+
204
116
  /**
205
117
  * The outcome of [`eval_program_raw`].
206
118
  */
207
119
  export class EvalProgramResult {
208
120
  private constructor();
209
121
  free(): void;
210
- /**
211
- * Whether the program succeeded: it did not fail and, for Plutus V3, it
212
- * returned unit.
213
- */
214
- ok: boolean;
122
+ [Symbol.dispose](): void;
215
123
  /**
216
124
  * The CPU the program used. A program that went over budget is charged
217
125
  * what it used up to the point where the machine stopped it.
218
126
  */
219
127
  cpu: bigint;
220
- /**
221
- * The memory the program used.
222
- */
223
- mem: bigint;
224
128
  /**
225
129
  * Why the program did not succeed: 0 when it did, 1 when it went over
226
130
  * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
@@ -231,4 +135,113 @@ export class EvalProgramResult {
231
135
  * The messages the program traced, in order.
232
136
  */
233
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;
234
147
  }
148
+
149
+ export function __wbg_reset_state(): void;
150
+
151
+ export function apply_params_to_script(
152
+ params_bytes: Uint8Array,
153
+ plutus_script_bytes: Uint8Array,
154
+ ): Uint8Array;
155
+
156
+ /**
157
+ * Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
158
+ * evaluates it at a protocol version, without any program around it: the
159
+ * result, or how it fails, is what the machine gives for the saturated
160
+ * application.
161
+ *
162
+ * - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
163
+ * The Miller-loop builtins (68 to 70) are not supported, since their
164
+ * results cannot be returned.
165
+ * - `args`: exactly the builtin's arguments, in order, each encoded as the
166
+ * matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
167
+ * flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
168
+ * for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
169
+ * points, 5 for an array of G1 points and 6 for an array of G2 points, each
170
+ * list or array as the compressed points one after the other. Flat cannot
171
+ * encode BLS12-381 points, so they cross as their compressed bytes.
172
+ * - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
173
+ * 12 (Dijkstra). It decides which builtins are available and the semantics
174
+ * they have.
175
+ *
176
+ * The result's `cpu` and `mem` are the builtin's charge for the application
177
+ * under Plutus' default Plutus V3 cost model (not the ledger's protocol
178
+ * parameters), excluding the machine's per-step costs.
179
+ *
180
+ * Fails only when the inputs are malformed or unsupported: an unknown or
181
+ * Miller-loop tag, a number of arguments other than the builtin's arity, an
182
+ * argument that does not decode as its kind says or is not a constant, an
183
+ * invalid compressed point, a protocol version out of range, or a result that
184
+ * none of the kinds can encode. A builtin that fails is an
185
+ * [`EvalBuiltinResult`] that is not `ok`.
186
+ */
187
+ export function eval_builtin_raw(
188
+ tag: number,
189
+ args: Uint8Array[],
190
+ arg_kinds: Uint8Array,
191
+ protocol_major_version: number,
192
+ ): EvalBuiltinResult;
193
+
194
+ export function eval_phase_two_raw(
195
+ tx_bytes: Uint8Array,
196
+ utxos_bytes_x: Uint8Array[],
197
+ utxos_bytes_y: Uint8Array[],
198
+ cost_mdls_bytes: Uint8Array,
199
+ initial_budget_n: bigint,
200
+ initial_budget_d: bigint,
201
+ slot_config_x: bigint,
202
+ slot_config_y: bigint,
203
+ slot_config_z: number,
204
+ protocol_major_version?: number | null,
205
+ ): Uint8Array[];
206
+
207
+ /**
208
+ * Evaluates a UPLC program applied to Data arguments, outside of any
209
+ * transaction: the caller builds whatever arguments the program expects,
210
+ * including its script context.
211
+ *
212
+ * - `program_flat`: the program, flat-encoded without a CBOR wrapper.
213
+ * - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
214
+ * - `language`: the Plutus version to evaluate as, 1, 2 or 3.
215
+ * - `protocol_major_version`: the protocol version whose semantics to use,
216
+ * from 5 (Alonzo) to 12 (Dijkstra).
217
+ * - `cost_model`: the cost model parameters, every one the evaluator knows
218
+ * for this Plutus version (350 for Plutus V3), in the ledger's order.
219
+ * - `budget_cpu`, `budget_mem`: the budget.
220
+ * - `strict_budget`: charge every step as the machine takes it, and stop the
221
+ * program as soon as it goes over budget, instead of charging steps and
222
+ * checking the budget every 200 steps as the ledger does. Only the cost of a
223
+ * program that fails differs: the ledger does not charge the steps it took
224
+ * since the budget was last checked.
225
+ *
226
+ * Fails only when the inputs are malformed or unsupported. A program that fails
227
+ * is an [`EvalProgramResult`] that is not `ok`.
228
+ */
229
+ export function eval_program_raw(
230
+ program_flat: Uint8Array,
231
+ args_cbor: Uint8Array[],
232
+ language: number,
233
+ protocol_major_version: number,
234
+ cost_model: BigInt64Array,
235
+ budget_cpu: bigint,
236
+ budget_mem: bigint,
237
+ strict_budget: boolean,
238
+ ): EvalProgramResult;
239
+
240
+ /**
241
+ * Describes this build of the evaluator as JSON: the uplc crate it was built
242
+ * from, the length of each Plutus version's cost model, and a digest of what a
243
+ * fixed set of programs evaluate to, with their costs, under Plutus V3 and the
244
+ * latest protocol version. Two builds with the same digest agree on those
245
+ * programs; `selfTest` says whether this one gives the expected results.
246
+ */
247
+ export function uplc_build_info(): string;