@odatano/contract-m402-vault 0.0.0-stage → 0.2.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.
@@ -0,0 +1,2216 @@
1
+ import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
2
+ __compactRuntime.checkRuntimeVersion('0.21.0');
3
+
4
+ const _descriptor_0 = new __compactRuntime.CompactTypeBytes(32);
5
+
6
+ const _descriptor_1 = __compactRuntime.CompactTypeBoolean;
7
+
8
+ const _descriptor_2 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
9
+
10
+ class _ContractAddress_0 {
11
+ alignment() {
12
+ return _descriptor_0.alignment();
13
+ }
14
+ fromValue(value_0) {
15
+ return {
16
+ bytes: _descriptor_0.fromValue(value_0)
17
+ }
18
+ }
19
+ toValue(value_0) {
20
+ return _descriptor_0.toValue(value_0.bytes);
21
+ }
22
+ }
23
+
24
+ const _descriptor_3 = new _ContractAddress_0();
25
+
26
+ const _descriptor_4 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
27
+
28
+ class _ShieldedCoinInfo_0 {
29
+ alignment() {
30
+ return _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_4.alignment()));
31
+ }
32
+ fromValue(value_0) {
33
+ return {
34
+ nonce: _descriptor_0.fromValue(value_0),
35
+ color: _descriptor_0.fromValue(value_0),
36
+ value: _descriptor_4.fromValue(value_0)
37
+ }
38
+ }
39
+ toValue(value_0) {
40
+ return _descriptor_0.toValue(value_0.nonce).concat(_descriptor_0.toValue(value_0.color).concat(_descriptor_4.toValue(value_0.value)));
41
+ }
42
+ }
43
+
44
+ const _descriptor_5 = new _ShieldedCoinInfo_0();
45
+
46
+ const _descriptor_6 = new __compactRuntime.CompactTypeUnsignedInteger(65535n, 2);
47
+
48
+ class _QualifiedShieldedCoinInfo_0 {
49
+ alignment() {
50
+ return _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_4.alignment().concat(_descriptor_2.alignment())));
51
+ }
52
+ fromValue(value_0) {
53
+ return {
54
+ nonce: _descriptor_0.fromValue(value_0),
55
+ color: _descriptor_0.fromValue(value_0),
56
+ value: _descriptor_4.fromValue(value_0),
57
+ mt_index: _descriptor_2.fromValue(value_0)
58
+ }
59
+ }
60
+ toValue(value_0) {
61
+ return _descriptor_0.toValue(value_0.nonce).concat(_descriptor_0.toValue(value_0.color).concat(_descriptor_4.toValue(value_0.value).concat(_descriptor_2.toValue(value_0.mt_index))));
62
+ }
63
+ }
64
+
65
+ const _descriptor_7 = new _QualifiedShieldedCoinInfo_0();
66
+
67
+ class _ZswapCoinPublicKey_0 {
68
+ alignment() {
69
+ return _descriptor_0.alignment();
70
+ }
71
+ fromValue(value_0) {
72
+ return {
73
+ bytes: _descriptor_0.fromValue(value_0)
74
+ }
75
+ }
76
+ toValue(value_0) {
77
+ return _descriptor_0.toValue(value_0.bytes);
78
+ }
79
+ }
80
+
81
+ const _descriptor_8 = new _ZswapCoinPublicKey_0();
82
+
83
+ class _Either_0 {
84
+ alignment() {
85
+ return _descriptor_1.alignment().concat(_descriptor_8.alignment().concat(_descriptor_3.alignment()));
86
+ }
87
+ fromValue(value_0) {
88
+ return {
89
+ is_left: _descriptor_1.fromValue(value_0),
90
+ left: _descriptor_8.fromValue(value_0),
91
+ right: _descriptor_3.fromValue(value_0)
92
+ }
93
+ }
94
+ toValue(value_0) {
95
+ return _descriptor_1.toValue(value_0.is_left).concat(_descriptor_8.toValue(value_0.left).concat(_descriptor_3.toValue(value_0.right)));
96
+ }
97
+ }
98
+
99
+ const _descriptor_9 = new _Either_0();
100
+
101
+ const _descriptor_10 = __compactRuntime.CompactTypeField;
102
+
103
+ const _descriptor_11 = new __compactRuntime.CompactTypeVector(2, _descriptor_0);
104
+
105
+ const _descriptor_12 = new __compactRuntime.CompactTypeVector(4, _descriptor_0);
106
+
107
+ const _descriptor_13 = new __compactRuntime.CompactTypeBytes(21);
108
+
109
+ class _CoinPreimage_0 {
110
+ alignment() {
111
+ return _descriptor_13.alignment().concat(_descriptor_5.alignment().concat(_descriptor_1.alignment().concat(_descriptor_0.alignment())));
112
+ }
113
+ fromValue(value_0) {
114
+ return {
115
+ domain_sep: _descriptor_13.fromValue(value_0),
116
+ info: _descriptor_5.fromValue(value_0),
117
+ dataType: _descriptor_1.fromValue(value_0),
118
+ data: _descriptor_0.fromValue(value_0)
119
+ }
120
+ }
121
+ toValue(value_0) {
122
+ return _descriptor_13.toValue(value_0.domain_sep).concat(_descriptor_5.toValue(value_0.info).concat(_descriptor_1.toValue(value_0.dataType).concat(_descriptor_0.toValue(value_0.data))));
123
+ }
124
+ }
125
+
126
+ const _descriptor_14 = new _CoinPreimage_0();
127
+
128
+ const _descriptor_15 = new __compactRuntime.CompactTypeVector(2, _descriptor_10);
129
+
130
+ const _descriptor_16 = new __compactRuntime.CompactTypeVector(3, _descriptor_0);
131
+
132
+ class _Either_1 {
133
+ alignment() {
134
+ return _descriptor_1.alignment().concat(_descriptor_0.alignment().concat(_descriptor_0.alignment()));
135
+ }
136
+ fromValue(value_0) {
137
+ return {
138
+ is_left: _descriptor_1.fromValue(value_0),
139
+ left: _descriptor_0.fromValue(value_0),
140
+ right: _descriptor_0.fromValue(value_0)
141
+ }
142
+ }
143
+ toValue(value_0) {
144
+ return _descriptor_1.toValue(value_0.is_left).concat(_descriptor_0.toValue(value_0.left).concat(_descriptor_0.toValue(value_0.right)));
145
+ }
146
+ }
147
+
148
+ const _descriptor_17 = new _Either_1();
149
+
150
+ const _descriptor_18 = new __compactRuntime.CompactTypeVector(3, _descriptor_10);
151
+
152
+ class _UserAddress_0 {
153
+ alignment() {
154
+ return _descriptor_0.alignment();
155
+ }
156
+ fromValue(value_0) {
157
+ return {
158
+ bytes: _descriptor_0.fromValue(value_0)
159
+ }
160
+ }
161
+ toValue(value_0) {
162
+ return _descriptor_0.toValue(value_0.bytes);
163
+ }
164
+ }
165
+
166
+ const _descriptor_19 = new _UserAddress_0();
167
+
168
+ class _Either_2 {
169
+ alignment() {
170
+ return _descriptor_1.alignment().concat(_descriptor_3.alignment().concat(_descriptor_19.alignment()));
171
+ }
172
+ fromValue(value_0) {
173
+ return {
174
+ is_left: _descriptor_1.fromValue(value_0),
175
+ left: _descriptor_3.fromValue(value_0),
176
+ right: _descriptor_19.fromValue(value_0)
177
+ }
178
+ }
179
+ toValue(value_0) {
180
+ return _descriptor_1.toValue(value_0.is_left).concat(_descriptor_3.toValue(value_0.left).concat(_descriptor_19.toValue(value_0.right)));
181
+ }
182
+ }
183
+
184
+ const _descriptor_20 = new _Either_2();
185
+
186
+ class _Maybe_0 {
187
+ alignment() {
188
+ return _descriptor_1.alignment().concat(_descriptor_5.alignment());
189
+ }
190
+ fromValue(value_0) {
191
+ return {
192
+ is_some: _descriptor_1.fromValue(value_0),
193
+ value: _descriptor_5.fromValue(value_0)
194
+ }
195
+ }
196
+ toValue(value_0) {
197
+ return _descriptor_1.toValue(value_0.is_some).concat(_descriptor_5.toValue(value_0.value));
198
+ }
199
+ }
200
+
201
+ const _descriptor_21 = new _Maybe_0();
202
+
203
+ class _ShieldedSendResult_0 {
204
+ alignment() {
205
+ return _descriptor_21.alignment().concat(_descriptor_5.alignment());
206
+ }
207
+ fromValue(value_0) {
208
+ return {
209
+ change: _descriptor_21.fromValue(value_0),
210
+ sent: _descriptor_5.fromValue(value_0)
211
+ }
212
+ }
213
+ toValue(value_0) {
214
+ return _descriptor_21.toValue(value_0.change).concat(_descriptor_5.toValue(value_0.sent));
215
+ }
216
+ }
217
+
218
+ const _descriptor_22 = new _ShieldedSendResult_0();
219
+
220
+ class _Maybe_1 {
221
+ alignment() {
222
+ return _descriptor_1.alignment().concat(_descriptor_20.alignment());
223
+ }
224
+ fromValue(value_0) {
225
+ return {
226
+ is_some: _descriptor_1.fromValue(value_0),
227
+ value: _descriptor_20.fromValue(value_0)
228
+ }
229
+ }
230
+ toValue(value_0) {
231
+ return _descriptor_1.toValue(value_0.is_some).concat(_descriptor_20.toValue(value_0.value));
232
+ }
233
+ }
234
+
235
+ const _descriptor_23 = new _Maybe_1();
236
+
237
+ const _descriptor_24 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
238
+
239
+ const _descriptor_25 = new __compactRuntime.CompactTypeUnsignedInteger(4294967295n, 4);
240
+
241
+ export class Contract {
242
+ witnesses;
243
+ constructor(...args_0) {
244
+ if (args_0.length !== 1) {
245
+ throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
246
+ }
247
+ const witnesses_0 = args_0[0];
248
+ if (typeof(witnesses_0) !== 'object') {
249
+ throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
250
+ }
251
+ this.witnesses = witnesses_0;
252
+ this.circuits = {
253
+ async creditColor(context, ...args_1) {
254
+ return { result: pureCircuits.creditColor(...args_1), context };
255
+ },
256
+ async deriveReceipt(context, ...args_1) {
257
+ return { result: pureCircuits.deriveReceipt(...args_1), context };
258
+ },
259
+ async deriveServiceId(context, ...args_1) {
260
+ return { result: pureCircuits.deriveServiceId(...args_1), context };
261
+ },
262
+ registerService: async (...args_1) => {
263
+ if (args_1.length !== 4) {
264
+ throw new __compactRuntime.CompactError(`registerService: expected 4 arguments (as invoked from Typescript), received ${args_1.length}`);
265
+ }
266
+ const contextOrig_0 = args_1[0];
267
+ const salt_0 = args_1[1];
268
+ const price_0 = args_1[2];
269
+ const owner_0 = args_1[3];
270
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
271
+ __compactRuntime.typeError('registerService',
272
+ 'argument 1 (as invoked from Typescript)',
273
+ 'm402-vault.compact line 44 char 1',
274
+ 'CircuitContext',
275
+ contextOrig_0)
276
+ }
277
+ if (!(salt_0.buffer instanceof ArrayBuffer && salt_0.BYTES_PER_ELEMENT === 1 && salt_0.length === 32)) {
278
+ __compactRuntime.typeError('registerService',
279
+ 'argument 1 (argument 2 as invoked from Typescript)',
280
+ 'm402-vault.compact line 44 char 1',
281
+ 'Bytes<32>',
282
+ salt_0)
283
+ }
284
+ if (!(typeof(price_0) === 'bigint' && price_0 >= 0n && price_0 <= 18446744073709551615n)) {
285
+ __compactRuntime.typeError('registerService',
286
+ 'argument 2 (argument 3 as invoked from Typescript)',
287
+ 'm402-vault.compact line 44 char 1',
288
+ 'Uint<0..18446744073709551616>',
289
+ price_0)
290
+ }
291
+ if (!(owner_0.buffer instanceof ArrayBuffer && owner_0.BYTES_PER_ELEMENT === 1 && owner_0.length === 32)) {
292
+ __compactRuntime.typeError('registerService',
293
+ 'argument 3 (argument 4 as invoked from Typescript)',
294
+ 'm402-vault.compact line 44 char 1',
295
+ 'Bytes<32>',
296
+ owner_0)
297
+ }
298
+ const context = __compactRuntime.copyCircuitContext(contextOrig_0);
299
+ const partialProofData = {
300
+ input: {
301
+ value: _descriptor_0.toValue(salt_0).concat(_descriptor_2.toValue(price_0).concat(_descriptor_0.toValue(owner_0))),
302
+ alignment: _descriptor_0.alignment().concat(_descriptor_2.alignment().concat(_descriptor_0.alignment()))
303
+ },
304
+ output: undefined,
305
+ publicTranscript: [],
306
+ privateTranscriptOutputs: []
307
+ };
308
+ const result_0 = await this._registerService_0(context,
309
+ partialProofData,
310
+ salt_0,
311
+ price_0,
312
+ owner_0);
313
+ partialProofData.output = { value: [], alignment: [] };
314
+ __compactRuntime.finalizeCallProofData(context, partialProofData);
315
+ return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
316
+ },
317
+ deposit: async (...args_1) => {
318
+ if (args_1.length !== 3) {
319
+ throw new __compactRuntime.CompactError(`deposit: expected 3 arguments (as invoked from Typescript), received ${args_1.length}`);
320
+ }
321
+ const contextOrig_0 = args_1[0];
322
+ const amount_0 = args_1[1];
323
+ const nonceSeed_0 = args_1[2];
324
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
325
+ __compactRuntime.typeError('deposit',
326
+ 'argument 1 (as invoked from Typescript)',
327
+ 'm402-vault.compact line 59 char 1',
328
+ 'CircuitContext',
329
+ contextOrig_0)
330
+ }
331
+ if (!(typeof(amount_0) === 'bigint' && amount_0 >= 0n && amount_0 <= 18446744073709551615n)) {
332
+ __compactRuntime.typeError('deposit',
333
+ 'argument 1 (argument 2 as invoked from Typescript)',
334
+ 'm402-vault.compact line 59 char 1',
335
+ 'Uint<0..18446744073709551616>',
336
+ amount_0)
337
+ }
338
+ if (!(nonceSeed_0.buffer instanceof ArrayBuffer && nonceSeed_0.BYTES_PER_ELEMENT === 1 && nonceSeed_0.length === 32)) {
339
+ __compactRuntime.typeError('deposit',
340
+ 'argument 2 (argument 3 as invoked from Typescript)',
341
+ 'm402-vault.compact line 59 char 1',
342
+ 'Bytes<32>',
343
+ nonceSeed_0)
344
+ }
345
+ const context = __compactRuntime.copyCircuitContext(contextOrig_0);
346
+ const partialProofData = {
347
+ input: {
348
+ value: _descriptor_2.toValue(amount_0).concat(_descriptor_0.toValue(nonceSeed_0)),
349
+ alignment: _descriptor_2.alignment().concat(_descriptor_0.alignment())
350
+ },
351
+ output: undefined,
352
+ publicTranscript: [],
353
+ privateTranscriptOutputs: []
354
+ };
355
+ const result_0 = await this._deposit_0(context,
356
+ partialProofData,
357
+ amount_0,
358
+ nonceSeed_0);
359
+ partialProofData.output = { value: [], alignment: [] };
360
+ __compactRuntime.finalizeCallProofData(context, partialProofData);
361
+ return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
362
+ },
363
+ pay: async (...args_1) => {
364
+ if (args_1.length !== 4) {
365
+ throw new __compactRuntime.CompactError(`pay: expected 4 arguments (as invoked from Typescript), received ${args_1.length}`);
366
+ }
367
+ const contextOrig_0 = args_1[0];
368
+ const serviceId_0 = args_1[1];
369
+ const credit_0 = args_1[2];
370
+ const receiptSecret_0 = args_1[3];
371
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
372
+ __compactRuntime.typeError('pay',
373
+ 'argument 1 (as invoked from Typescript)',
374
+ 'm402-vault.compact line 81 char 1',
375
+ 'CircuitContext',
376
+ contextOrig_0)
377
+ }
378
+ if (!(serviceId_0.buffer instanceof ArrayBuffer && serviceId_0.BYTES_PER_ELEMENT === 1 && serviceId_0.length === 32)) {
379
+ __compactRuntime.typeError('pay',
380
+ 'argument 1 (argument 2 as invoked from Typescript)',
381
+ 'm402-vault.compact line 81 char 1',
382
+ 'Bytes<32>',
383
+ serviceId_0)
384
+ }
385
+ if (!(typeof(credit_0) === 'object' && credit_0.nonce.buffer instanceof ArrayBuffer && credit_0.nonce.BYTES_PER_ELEMENT === 1 && credit_0.nonce.length === 32 && credit_0.color.buffer instanceof ArrayBuffer && credit_0.color.BYTES_PER_ELEMENT === 1 && credit_0.color.length === 32 && typeof(credit_0.value) === 'bigint' && credit_0.value >= 0n && credit_0.value <= 340282366920938463463374607431768211455n)) {
386
+ __compactRuntime.typeError('pay',
387
+ 'argument 2 (argument 3 as invoked from Typescript)',
388
+ 'm402-vault.compact line 81 char 1',
389
+ 'struct ShieldedCoinInfo<nonce: Bytes<32>, color: Bytes<32>, value: Uint<0..340282366920938463463374607431768211456>>',
390
+ credit_0)
391
+ }
392
+ if (!(receiptSecret_0.buffer instanceof ArrayBuffer && receiptSecret_0.BYTES_PER_ELEMENT === 1 && receiptSecret_0.length === 32)) {
393
+ __compactRuntime.typeError('pay',
394
+ 'argument 3 (argument 4 as invoked from Typescript)',
395
+ 'm402-vault.compact line 81 char 1',
396
+ 'Bytes<32>',
397
+ receiptSecret_0)
398
+ }
399
+ const context = __compactRuntime.copyCircuitContext(contextOrig_0);
400
+ const partialProofData = {
401
+ input: {
402
+ value: _descriptor_0.toValue(serviceId_0).concat(_descriptor_5.toValue(credit_0).concat(_descriptor_0.toValue(receiptSecret_0))),
403
+ alignment: _descriptor_0.alignment().concat(_descriptor_5.alignment().concat(_descriptor_0.alignment()))
404
+ },
405
+ output: undefined,
406
+ publicTranscript: [],
407
+ privateTranscriptOutputs: []
408
+ };
409
+ const result_0 = await this._pay_0(context,
410
+ partialProofData,
411
+ serviceId_0,
412
+ credit_0,
413
+ receiptSecret_0);
414
+ partialProofData.output = { value: [], alignment: [] };
415
+ __compactRuntime.finalizeCallProofData(context, partialProofData);
416
+ return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
417
+ },
418
+ redeem: async (...args_1) => {
419
+ if (args_1.length !== 3) {
420
+ throw new __compactRuntime.CompactError(`redeem: expected 3 arguments (as invoked from Typescript), received ${args_1.length}`);
421
+ }
422
+ const contextOrig_0 = args_1[0];
423
+ const recipient_0 = args_1[1];
424
+ const credit_0 = args_1[2];
425
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
426
+ __compactRuntime.typeError('redeem',
427
+ 'argument 1 (as invoked from Typescript)',
428
+ 'm402-vault.compact line 104 char 1',
429
+ 'CircuitContext',
430
+ contextOrig_0)
431
+ }
432
+ if (!(recipient_0.buffer instanceof ArrayBuffer && recipient_0.BYTES_PER_ELEMENT === 1 && recipient_0.length === 32)) {
433
+ __compactRuntime.typeError('redeem',
434
+ 'argument 1 (argument 2 as invoked from Typescript)',
435
+ 'm402-vault.compact line 104 char 1',
436
+ 'Bytes<32>',
437
+ recipient_0)
438
+ }
439
+ if (!(typeof(credit_0) === 'object' && credit_0.nonce.buffer instanceof ArrayBuffer && credit_0.nonce.BYTES_PER_ELEMENT === 1 && credit_0.nonce.length === 32 && credit_0.color.buffer instanceof ArrayBuffer && credit_0.color.BYTES_PER_ELEMENT === 1 && credit_0.color.length === 32 && typeof(credit_0.value) === 'bigint' && credit_0.value >= 0n && credit_0.value <= 340282366920938463463374607431768211455n)) {
440
+ __compactRuntime.typeError('redeem',
441
+ 'argument 2 (argument 3 as invoked from Typescript)',
442
+ 'm402-vault.compact line 104 char 1',
443
+ 'struct ShieldedCoinInfo<nonce: Bytes<32>, color: Bytes<32>, value: Uint<0..340282366920938463463374607431768211456>>',
444
+ credit_0)
445
+ }
446
+ const context = __compactRuntime.copyCircuitContext(contextOrig_0);
447
+ const partialProofData = {
448
+ input: {
449
+ value: _descriptor_0.toValue(recipient_0).concat(_descriptor_5.toValue(credit_0)),
450
+ alignment: _descriptor_0.alignment().concat(_descriptor_5.alignment())
451
+ },
452
+ output: undefined,
453
+ publicTranscript: [],
454
+ privateTranscriptOutputs: []
455
+ };
456
+ const result_0 = await this._redeem_0(context,
457
+ partialProofData,
458
+ recipient_0,
459
+ credit_0);
460
+ partialProofData.output = { value: [], alignment: [] };
461
+ __compactRuntime.finalizeCallProofData(context, partialProofData);
462
+ return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
463
+ },
464
+ withdraw: async (...args_1) => {
465
+ if (args_1.length !== 3) {
466
+ throw new __compactRuntime.CompactError(`withdraw: expected 3 arguments (as invoked from Typescript), received ${args_1.length}`);
467
+ }
468
+ const contextOrig_0 = args_1[0];
469
+ const serviceId_0 = args_1[1];
470
+ const amount_0 = args_1[2];
471
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
472
+ __compactRuntime.typeError('withdraw',
473
+ 'argument 1 (as invoked from Typescript)',
474
+ 'm402-vault.compact line 118 char 1',
475
+ 'CircuitContext',
476
+ contextOrig_0)
477
+ }
478
+ if (!(serviceId_0.buffer instanceof ArrayBuffer && serviceId_0.BYTES_PER_ELEMENT === 1 && serviceId_0.length === 32)) {
479
+ __compactRuntime.typeError('withdraw',
480
+ 'argument 1 (argument 2 as invoked from Typescript)',
481
+ 'm402-vault.compact line 118 char 1',
482
+ 'Bytes<32>',
483
+ serviceId_0)
484
+ }
485
+ if (!(typeof(amount_0) === 'bigint' && amount_0 >= 0n && amount_0 <= 18446744073709551615n)) {
486
+ __compactRuntime.typeError('withdraw',
487
+ 'argument 2 (argument 3 as invoked from Typescript)',
488
+ 'm402-vault.compact line 118 char 1',
489
+ 'Uint<0..18446744073709551616>',
490
+ amount_0)
491
+ }
492
+ const context = __compactRuntime.copyCircuitContext(contextOrig_0);
493
+ const partialProofData = {
494
+ input: {
495
+ value: _descriptor_0.toValue(serviceId_0).concat(_descriptor_2.toValue(amount_0)),
496
+ alignment: _descriptor_0.alignment().concat(_descriptor_2.alignment())
497
+ },
498
+ output: undefined,
499
+ publicTranscript: [],
500
+ privateTranscriptOutputs: []
501
+ };
502
+ const result_0 = await this._withdraw_0(context,
503
+ partialProofData,
504
+ serviceId_0,
505
+ amount_0);
506
+ partialProofData.output = { value: [], alignment: [] };
507
+ __compactRuntime.finalizeCallProofData(context, partialProofData);
508
+ return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
509
+ }
510
+ };
511
+ this.impureCircuits = {
512
+ registerService: this.circuits.registerService,
513
+ deposit: this.circuits.deposit,
514
+ pay: this.circuits.pay,
515
+ redeem: this.circuits.redeem,
516
+ withdraw: this.circuits.withdraw
517
+ };
518
+ this.provableCircuits = {
519
+ registerService: this.circuits.registerService,
520
+ deposit: this.circuits.deposit,
521
+ pay: this.circuits.pay,
522
+ redeem: this.circuits.redeem,
523
+ withdraw: this.circuits.withdraw
524
+ };
525
+ }
526
+ async initialState(...args_0) {
527
+ if (args_0.length !== 1) {
528
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
529
+ }
530
+ const constructorContext_0 = args_0[0];
531
+ if (typeof(constructorContext_0) !== 'object') {
532
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
533
+ }
534
+ if (!('initialZswapLocalState' in constructorContext_0)) {
535
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
536
+ }
537
+ if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
538
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
539
+ }
540
+ const state_0 = new __compactRuntime.ContractState();
541
+ let stateValue_0 = __compactRuntime.StateValue.newArray();
542
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
543
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
544
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
545
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
546
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
547
+ state_0.data = new __compactRuntime.ChargedState(stateValue_0);
548
+ state_0.setOperation('registerService', new __compactRuntime.ContractOperation());
549
+ state_0.setOperation('deposit', new __compactRuntime.ContractOperation());
550
+ state_0.setOperation('pay', new __compactRuntime.ContractOperation());
551
+ state_0.setOperation('redeem', new __compactRuntime.ContractOperation());
552
+ state_0.setOperation('withdraw', new __compactRuntime.ContractOperation());
553
+ const context = __compactRuntime.createCircuitContext({circuitId: 'constructor', contractAddress: __compactRuntime.dummyContractAddress(), coinPublicKeyOrZswapState: constructorContext_0.initialZswapLocalState.coinPublicKey, contractState: state_0.data, privateState: constructorContext_0.initialPrivateState});
554
+ const partialProofData = {
555
+ input: { value: [], alignment: [] },
556
+ output: undefined,
557
+ publicTranscript: [],
558
+ privateTranscriptOutputs: []
559
+ };
560
+ __compactRuntime.queryLedgerState(context,
561
+ partialProofData,
562
+ [
563
+ { push: { storage: false,
564
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_24.toValue(0n),
565
+ alignment: _descriptor_24.alignment() }).encode() } },
566
+ { push: { storage: true,
567
+ value: __compactRuntime.StateValue.newMap(
568
+ new __compactRuntime.StateMap()
569
+ ).encode() } },
570
+ { ins: { cached: false, n: 1 } }]);
571
+ __compactRuntime.queryLedgerState(context,
572
+ partialProofData,
573
+ [
574
+ { push: { storage: false,
575
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_24.toValue(1n),
576
+ alignment: _descriptor_24.alignment() }).encode() } },
577
+ { push: { storage: true,
578
+ value: __compactRuntime.StateValue.newMap(
579
+ new __compactRuntime.StateMap()
580
+ ).encode() } },
581
+ { ins: { cached: false, n: 1 } }]);
582
+ __compactRuntime.queryLedgerState(context,
583
+ partialProofData,
584
+ [
585
+ { push: { storage: false,
586
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_24.toValue(2n),
587
+ alignment: _descriptor_24.alignment() }).encode() } },
588
+ { push: { storage: true,
589
+ value: __compactRuntime.StateValue.newMap(
590
+ new __compactRuntime.StateMap()
591
+ ).encode() } },
592
+ { ins: { cached: false, n: 1 } }]);
593
+ __compactRuntime.queryLedgerState(context,
594
+ partialProofData,
595
+ [
596
+ { push: { storage: false,
597
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_24.toValue(3n),
598
+ alignment: _descriptor_24.alignment() }).encode() } },
599
+ { push: { storage: true,
600
+ value: __compactRuntime.StateValue.newMap(
601
+ new __compactRuntime.StateMap()
602
+ ).encode() } },
603
+ { ins: { cached: false, n: 1 } }]);
604
+ __compactRuntime.queryLedgerState(context,
605
+ partialProofData,
606
+ [
607
+ { push: { storage: false,
608
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_24.toValue(4n),
609
+ alignment: _descriptor_24.alignment() }).encode() } },
610
+ { push: { storage: true,
611
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(0n),
612
+ alignment: _descriptor_2.alignment() }).encode() } },
613
+ { ins: { cached: false, n: 1 } }]);
614
+ state_0.data = new __compactRuntime.ChargedState(context.callContext.currentQueryContext.state.state);
615
+ return {
616
+ currentContractState: state_0,
617
+ currentPrivateState: context.callContext.currentPrivateState,
618
+ currentZswapLocalState: context.callContext.currentZswapLocalState
619
+ }
620
+ }
621
+ _some_0(value_0) { return { is_some: true, value: value_0 }; }
622
+ _none_0() {
623
+ return { is_some: false,
624
+ value:
625
+ { nonce: new Uint8Array(32), color: new Uint8Array(32), value: 0n } };
626
+ }
627
+ _left_0(value_0) {
628
+ return { is_left: true, left: value_0, right: { bytes: new Uint8Array(32) } };
629
+ }
630
+ _left_1(value_0) {
631
+ return { is_left: true, left: value_0, right: new Uint8Array(32) };
632
+ }
633
+ _right_0(value_0) {
634
+ return { is_left: false, left: { bytes: new Uint8Array(32) }, right: value_0 };
635
+ }
636
+ _right_1(value_0) {
637
+ return { is_left: false, left: { bytes: new Uint8Array(32) }, right: value_0 };
638
+ }
639
+ _nativeToken_0() {
640
+ return new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
641
+ }
642
+ _tokenType_0(domain_sep_0, contractAddress_0) {
643
+ return this._persistentCommit_0([domain_sep_0, contractAddress_0.bytes],
644
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 100, 101, 114, 105, 118, 101, 95, 116, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
645
+ }
646
+ async _mintShieldedToken_0(context,
647
+ partialProofData,
648
+ domain_sep_0,
649
+ value_0,
650
+ nonce_0,
651
+ recipient_0)
652
+ {
653
+ const coin_0 = { nonce: nonce_0,
654
+ color:
655
+ this._tokenType_0(domain_sep_0,
656
+ _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
657
+ partialProofData,
658
+ [
659
+ { dup: { n: 2 } },
660
+ { idx: { cached: true,
661
+ pushPath: false,
662
+ path: [
663
+ { tag: 'value',
664
+ value: { value: _descriptor_24.toValue(0n),
665
+ alignment: _descriptor_24.alignment() } }] } },
666
+ { popeq: { cached: true,
667
+ result: undefined } }]).value)),
668
+ value: value_0 };
669
+ __compactRuntime.queryLedgerState(context,
670
+ partialProofData,
671
+ [
672
+ { swap: { n: 0 } },
673
+ { idx: { cached: true,
674
+ pushPath: true,
675
+ path: [
676
+ { tag: 'value',
677
+ value: { value: _descriptor_24.toValue(4n),
678
+ alignment: _descriptor_24.alignment() } }] } },
679
+ { push: { storage: false,
680
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(domain_sep_0),
681
+ alignment: _descriptor_0.alignment() }).encode() } },
682
+ { dup: { n: 1 } },
683
+ { dup: { n: 1 } },
684
+ 'member',
685
+ { push: { storage: false,
686
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(value_0),
687
+ alignment: _descriptor_2.alignment() }).encode() } },
688
+ { swap: { n: 0 } },
689
+ 'neg',
690
+ { branch: { skip: 4 } },
691
+ { dup: { n: 2 } },
692
+ { dup: { n: 2 } },
693
+ { idx: { cached: true,
694
+ pushPath: false,
695
+ path: [ { tag: 'stack' }] } },
696
+ 'add',
697
+ { ins: { cached: true, n: 2 } },
698
+ { swap: { n: 0 } }]);
699
+ this._createZswapOutput_0(context, partialProofData, coin_0, recipient_0);
700
+ const cm_0 = this._coinCommitment_0(coin_0, recipient_0);
701
+ __compactRuntime.queryLedgerState(context,
702
+ partialProofData,
703
+ [
704
+ { swap: { n: 0 } },
705
+ { idx: { cached: true,
706
+ pushPath: true,
707
+ path: [
708
+ { tag: 'value',
709
+ value: { value: _descriptor_24.toValue(2n),
710
+ alignment: _descriptor_24.alignment() } }] } },
711
+ { push: { storage: false,
712
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(cm_0),
713
+ alignment: _descriptor_0.alignment() }).encode() } },
714
+ { push: { storage: false,
715
+ value: __compactRuntime.StateValue.newNull().encode() } },
716
+ { ins: { cached: true, n: 2 } },
717
+ { swap: { n: 0 } }]);
718
+ if (!recipient_0.is_left
719
+ &&
720
+ this._equal_0(recipient_0.right.bytes,
721
+ _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
722
+ partialProofData,
723
+ [
724
+ { dup: { n: 2 } },
725
+ { idx: { cached: true,
726
+ pushPath: false,
727
+ path: [
728
+ { tag: 'value',
729
+ value: { value: _descriptor_24.toValue(0n),
730
+ alignment: _descriptor_24.alignment() } }] } },
731
+ { popeq: { cached: true,
732
+ result: undefined } }]).value).bytes))
733
+ {
734
+ __compactRuntime.queryLedgerState(context,
735
+ partialProofData,
736
+ [
737
+ { swap: { n: 0 } },
738
+ { idx: { cached: true,
739
+ pushPath: true,
740
+ path: [
741
+ { tag: 'value',
742
+ value: { value: _descriptor_24.toValue(1n),
743
+ alignment: _descriptor_24.alignment() } }] } },
744
+ { push: { storage: false,
745
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(cm_0),
746
+ alignment: _descriptor_0.alignment() }).encode() } },
747
+ { push: { storage: false,
748
+ value: __compactRuntime.StateValue.newNull().encode() } },
749
+ { ins: { cached: true, n: 2 } },
750
+ { swap: { n: 0 } }]);
751
+ }
752
+ return coin_0;
753
+ }
754
+ _evolveNonce_0(index_0, nonce_0) {
755
+ return this._upgradeFromTransient_0(this._transientHash_0([__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
756
+ 28,
757
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 107, 101, 114, 110, 101, 108, 58, 110, 111, 110, 99, 101, 95, 101, 118, 111, 108, 118, 101]),
758
+ 'Field',
759
+ '<standard library>'),
760
+ index_0,
761
+ this._degradeToTransient_0(nonce_0)]));
762
+ }
763
+ async _receiveShielded_0(context, partialProofData, coin_0) {
764
+ const recipient_0 = this._right_0(_descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
765
+ partialProofData,
766
+ [
767
+ { dup: { n: 2 } },
768
+ { idx: { cached: true,
769
+ pushPath: false,
770
+ path: [
771
+ { tag: 'value',
772
+ value: { value: _descriptor_24.toValue(0n),
773
+ alignment: _descriptor_24.alignment() } }] } },
774
+ { popeq: { cached: true,
775
+ result: undefined } }]).value));
776
+ this._createZswapOutput_0(context, partialProofData, coin_0, recipient_0);
777
+ const tmp_0 = this._coinCommitment_0(coin_0, recipient_0);
778
+ __compactRuntime.queryLedgerState(context,
779
+ partialProofData,
780
+ [
781
+ { swap: { n: 0 } },
782
+ { idx: { cached: true,
783
+ pushPath: true,
784
+ path: [
785
+ { tag: 'value',
786
+ value: { value: _descriptor_24.toValue(1n),
787
+ alignment: _descriptor_24.alignment() } }] } },
788
+ { push: { storage: false,
789
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_0),
790
+ alignment: _descriptor_0.alignment() }).encode() } },
791
+ { push: { storage: false,
792
+ value: __compactRuntime.StateValue.newNull().encode() } },
793
+ { ins: { cached: true, n: 2 } },
794
+ { swap: { n: 0 } }]);
795
+ return [];
796
+ }
797
+ async _sendShielded_0(context, partialProofData, input_0, recipient_0, value_0)
798
+ {
799
+ const selfAddr_0 = _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
800
+ partialProofData,
801
+ [
802
+ { dup: { n: 2 } },
803
+ { idx: { cached: true,
804
+ pushPath: false,
805
+ path: [
806
+ { tag: 'value',
807
+ value: { value: _descriptor_24.toValue(0n),
808
+ alignment: _descriptor_24.alignment() } }] } },
809
+ { popeq: { cached: true,
810
+ result: undefined } }]).value);
811
+ this._createZswapInput_0(context, partialProofData, input_0);
812
+ const tmp_0 = this._coinNullifier_0(this._downcastQualifiedCoin_0(input_0),
813
+ selfAddr_0);
814
+ __compactRuntime.queryLedgerState(context,
815
+ partialProofData,
816
+ [
817
+ { swap: { n: 0 } },
818
+ { idx: { cached: true,
819
+ pushPath: true,
820
+ path: [
821
+ { tag: 'value',
822
+ value: { value: _descriptor_24.toValue(0n),
823
+ alignment: _descriptor_24.alignment() } }] } },
824
+ { push: { storage: false,
825
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_0),
826
+ alignment: _descriptor_0.alignment() }).encode() } },
827
+ { push: { storage: false,
828
+ value: __compactRuntime.StateValue.newNull().encode() } },
829
+ { ins: { cached: true, n: 2 } },
830
+ { swap: { n: 0 } }]);
831
+ let t_0;
832
+ const change_0 = (t_0 = input_0.value,
833
+ (__compactRuntime.assert(t_0 >= value_0,
834
+ 'result of subtraction would be negative'),
835
+ t_0 - value_0));
836
+ const output_0 = { nonce:
837
+ this._upgradeFromTransient_0(this._transientHash_1([__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
838
+ 28,
839
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 107, 101, 114, 110, 101, 108, 58, 110, 111, 110, 99, 101, 95, 101, 118, 111, 108, 118, 101]),
840
+ 'Field',
841
+ '<standard library>'),
842
+ this._degradeToTransient_0(input_0.nonce)])),
843
+ color: input_0.color,
844
+ value: value_0 };
845
+ this._createZswapOutput_0(context, partialProofData, output_0, recipient_0);
846
+ const tmp_1 = this._coinCommitment_0(output_0, recipient_0);
847
+ __compactRuntime.queryLedgerState(context,
848
+ partialProofData,
849
+ [
850
+ { swap: { n: 0 } },
851
+ { idx: { cached: true,
852
+ pushPath: true,
853
+ path: [
854
+ { tag: 'value',
855
+ value: { value: _descriptor_24.toValue(2n),
856
+ alignment: _descriptor_24.alignment() } }] } },
857
+ { push: { storage: false,
858
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_1),
859
+ alignment: _descriptor_0.alignment() }).encode() } },
860
+ { push: { storage: false,
861
+ value: __compactRuntime.StateValue.newNull().encode() } },
862
+ { ins: { cached: true, n: 2 } },
863
+ { swap: { n: 0 } }]);
864
+ if (!recipient_0.is_left
865
+ &&
866
+ this._equal_1(recipient_0.right.bytes, selfAddr_0.bytes))
867
+ {
868
+ const tmp_2 = this._coinCommitment_0(output_0, recipient_0);
869
+ __compactRuntime.queryLedgerState(context,
870
+ partialProofData,
871
+ [
872
+ { swap: { n: 0 } },
873
+ { idx: { cached: true,
874
+ pushPath: true,
875
+ path: [
876
+ { tag: 'value',
877
+ value: { value: _descriptor_24.toValue(1n),
878
+ alignment: _descriptor_24.alignment() } }] } },
879
+ { push: { storage: false,
880
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_2),
881
+ alignment: _descriptor_0.alignment() }).encode() } },
882
+ { push: { storage: false,
883
+ value: __compactRuntime.StateValue.newNull().encode() } },
884
+ { ins: { cached: true, n: 2 } },
885
+ { swap: { n: 0 } }]);
886
+ }
887
+ if (change_0 === 0n) {
888
+ return { change: this._none_0(), sent: output_0 };
889
+ } else {
890
+ const changeCoin_0 = { nonce:
891
+ this._upgradeFromTransient_0(this._transientHash_1([__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
892
+ 30,
893
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 107, 101, 114, 110, 101, 108, 58, 110, 111, 110, 99, 101, 95, 101, 118, 111, 108, 118, 101, 47, 50]),
894
+ 'Field',
895
+ '<standard library>'),
896
+ this._degradeToTransient_0(input_0.nonce)])),
897
+ color: input_0.color,
898
+ value: change_0 };
899
+ this._createZswapOutput_0(context,
900
+ partialProofData,
901
+ changeCoin_0,
902
+ this._right_0(selfAddr_0));
903
+ const cm_0 = this._coinCommitment_0(changeCoin_0,
904
+ this._right_0(selfAddr_0));
905
+ __compactRuntime.queryLedgerState(context,
906
+ partialProofData,
907
+ [
908
+ { swap: { n: 0 } },
909
+ { idx: { cached: true,
910
+ pushPath: true,
911
+ path: [
912
+ { tag: 'value',
913
+ value: { value: _descriptor_24.toValue(2n),
914
+ alignment: _descriptor_24.alignment() } }] } },
915
+ { push: { storage: false,
916
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(cm_0),
917
+ alignment: _descriptor_0.alignment() }).encode() } },
918
+ { push: { storage: false,
919
+ value: __compactRuntime.StateValue.newNull().encode() } },
920
+ { ins: { cached: true, n: 2 } },
921
+ { swap: { n: 0 } }]);
922
+ __compactRuntime.queryLedgerState(context,
923
+ partialProofData,
924
+ [
925
+ { swap: { n: 0 } },
926
+ { idx: { cached: true,
927
+ pushPath: true,
928
+ path: [
929
+ { tag: 'value',
930
+ value: { value: _descriptor_24.toValue(1n),
931
+ alignment: _descriptor_24.alignment() } }] } },
932
+ { push: { storage: false,
933
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(cm_0),
934
+ alignment: _descriptor_0.alignment() }).encode() } },
935
+ { push: { storage: false,
936
+ value: __compactRuntime.StateValue.newNull().encode() } },
937
+ { ins: { cached: true, n: 2 } },
938
+ { swap: { n: 0 } }]);
939
+ return { change: this._some_0(changeCoin_0), sent: output_0 };
940
+ }
941
+ }
942
+ async _sendImmediateShielded_0(context,
943
+ partialProofData,
944
+ input_0,
945
+ target_0,
946
+ value_0)
947
+ {
948
+ return await this._sendShielded_0(context,
949
+ partialProofData,
950
+ this._upcastQualifiedCoin_0(input_0),
951
+ target_0,
952
+ value_0);
953
+ }
954
+ _downcastQualifiedCoin_0(coin_0) {
955
+ return { nonce: coin_0.nonce, color: coin_0.color, value: coin_0.value };
956
+ }
957
+ _upcastQualifiedCoin_0(coin_0) {
958
+ return { nonce: coin_0.nonce,
959
+ color: coin_0.color,
960
+ value: coin_0.value,
961
+ mt_index: 0n };
962
+ }
963
+ _coinCommitment_0(coin_0, recipient_0) {
964
+ return this._persistentHash_2({ domain_sep:
965
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 122, 115, 119, 97, 112, 45, 99, 99, 91, 118, 49, 93]),
966
+ info: coin_0,
967
+ dataType: recipient_0.is_left,
968
+ data:
969
+ recipient_0.is_left ?
970
+ recipient_0.left.bytes :
971
+ recipient_0.right.bytes });
972
+ }
973
+ _coinNullifier_0(coin_0, addr_0) {
974
+ return this._persistentHash_2({ domain_sep:
975
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 122, 115, 119, 97, 112, 45, 99, 110, 91, 118, 49, 93]),
976
+ info: coin_0,
977
+ dataType: false,
978
+ data: addr_0.bytes });
979
+ }
980
+ async _sendUnshielded_0(context,
981
+ partialProofData,
982
+ color_0,
983
+ amount_0,
984
+ recipient_0)
985
+ {
986
+ const tmp_0 = this._left_1(color_0);
987
+ __compactRuntime.queryLedgerState(context,
988
+ partialProofData,
989
+ [
990
+ { swap: { n: 0 } },
991
+ { idx: { cached: true,
992
+ pushPath: true,
993
+ path: [
994
+ { tag: 'value',
995
+ value: { value: _descriptor_24.toValue(7n),
996
+ alignment: _descriptor_24.alignment() } }] } },
997
+ { push: { storage: false,
998
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_17.toValue(tmp_0),
999
+ alignment: _descriptor_17.alignment() }).encode() } },
1000
+ { dup: { n: 1 } },
1001
+ { dup: { n: 1 } },
1002
+ 'member',
1003
+ { push: { storage: false,
1004
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(amount_0),
1005
+ alignment: _descriptor_4.alignment() }).encode() } },
1006
+ { swap: { n: 0 } },
1007
+ 'neg',
1008
+ { branch: { skip: 4 } },
1009
+ { dup: { n: 2 } },
1010
+ { dup: { n: 2 } },
1011
+ { idx: { cached: true,
1012
+ pushPath: false,
1013
+ path: [ { tag: 'stack' }] } },
1014
+ 'add',
1015
+ { ins: { cached: true, n: 2 } },
1016
+ { swap: { n: 0 } }]);
1017
+ const tmp_1 = this._left_1(color_0);
1018
+ __compactRuntime.queryLedgerState(context,
1019
+ partialProofData,
1020
+ [
1021
+ { swap: { n: 0 } },
1022
+ { idx: { cached: true,
1023
+ pushPath: true,
1024
+ path: [
1025
+ { tag: 'value',
1026
+ value: { value: _descriptor_24.toValue(8n),
1027
+ alignment: _descriptor_24.alignment() } }] } },
1028
+ { push: { storage: false,
1029
+ value: __compactRuntime.StateValue.newCell(__compactRuntime.alignedConcat(
1030
+ { value: _descriptor_17.toValue(tmp_1),
1031
+ alignment: _descriptor_17.alignment() },
1032
+ { value: _descriptor_20.toValue(recipient_0),
1033
+ alignment: _descriptor_20.alignment() }
1034
+ )).encode() } },
1035
+ { dup: { n: 1 } },
1036
+ { dup: { n: 1 } },
1037
+ 'member',
1038
+ { push: { storage: false,
1039
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(amount_0),
1040
+ alignment: _descriptor_4.alignment() }).encode() } },
1041
+ { swap: { n: 0 } },
1042
+ 'neg',
1043
+ { branch: { skip: 4 } },
1044
+ { dup: { n: 2 } },
1045
+ { dup: { n: 2 } },
1046
+ { idx: { cached: true,
1047
+ pushPath: false,
1048
+ path: [ { tag: 'stack' }] } },
1049
+ 'add',
1050
+ { ins: { cached: true, n: 2 } },
1051
+ { swap: { n: 0 } }]);
1052
+ if (recipient_0.is_left
1053
+ &&
1054
+ this._equal_2(recipient_0.left.bytes,
1055
+ _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
1056
+ partialProofData,
1057
+ [
1058
+ { dup: { n: 2 } },
1059
+ { idx: { cached: true,
1060
+ pushPath: false,
1061
+ path: [
1062
+ { tag: 'value',
1063
+ value: { value: _descriptor_24.toValue(0n),
1064
+ alignment: _descriptor_24.alignment() } }] } },
1065
+ { popeq: { cached: true,
1066
+ result: undefined } }]).value).bytes))
1067
+ {
1068
+ const tmp_2 = this._left_1(color_0);
1069
+ __compactRuntime.queryLedgerState(context,
1070
+ partialProofData,
1071
+ [
1072
+ { swap: { n: 0 } },
1073
+ { idx: { cached: true,
1074
+ pushPath: true,
1075
+ path: [
1076
+ { tag: 'value',
1077
+ value: { value: _descriptor_24.toValue(6n),
1078
+ alignment: _descriptor_24.alignment() } }] } },
1079
+ { push: { storage: false,
1080
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_17.toValue(tmp_2),
1081
+ alignment: _descriptor_17.alignment() }).encode() } },
1082
+ { dup: { n: 1 } },
1083
+ { dup: { n: 1 } },
1084
+ 'member',
1085
+ { push: { storage: false,
1086
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(amount_0),
1087
+ alignment: _descriptor_4.alignment() }).encode() } },
1088
+ { swap: { n: 0 } },
1089
+ 'neg',
1090
+ { branch: { skip: 4 } },
1091
+ { dup: { n: 2 } },
1092
+ { dup: { n: 2 } },
1093
+ { idx: { cached: true,
1094
+ pushPath: false,
1095
+ path: [ { tag: 'stack' }] } },
1096
+ 'add',
1097
+ { ins: { cached: true, n: 2 } },
1098
+ { swap: { n: 0 } }]);
1099
+ }
1100
+ return [];
1101
+ }
1102
+ async _receiveUnshielded_0(context, partialProofData, color_0, amount_0) {
1103
+ const tmp_0 = this._left_1(color_0);
1104
+ __compactRuntime.queryLedgerState(context,
1105
+ partialProofData,
1106
+ [
1107
+ { swap: { n: 0 } },
1108
+ { idx: { cached: true,
1109
+ pushPath: true,
1110
+ path: [
1111
+ { tag: 'value',
1112
+ value: { value: _descriptor_24.toValue(6n),
1113
+ alignment: _descriptor_24.alignment() } }] } },
1114
+ { push: { storage: false,
1115
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_17.toValue(tmp_0),
1116
+ alignment: _descriptor_17.alignment() }).encode() } },
1117
+ { dup: { n: 1 } },
1118
+ { dup: { n: 1 } },
1119
+ 'member',
1120
+ { push: { storage: false,
1121
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(amount_0),
1122
+ alignment: _descriptor_4.alignment() }).encode() } },
1123
+ { swap: { n: 0 } },
1124
+ 'neg',
1125
+ { branch: { skip: 4 } },
1126
+ { dup: { n: 2 } },
1127
+ { dup: { n: 2 } },
1128
+ { idx: { cached: true,
1129
+ pushPath: false,
1130
+ path: [ { tag: 'stack' }] } },
1131
+ 'add',
1132
+ { ins: { cached: true, n: 2 } },
1133
+ { swap: { n: 0 } }]);
1134
+ return [];
1135
+ }
1136
+ _transientHash_0(value_0) {
1137
+ const result_0 = __compactRuntime.transientHash(_descriptor_18, value_0);
1138
+ return result_0;
1139
+ }
1140
+ _transientHash_1(value_0) {
1141
+ const result_0 = __compactRuntime.transientHash(_descriptor_15, value_0);
1142
+ return result_0;
1143
+ }
1144
+ _persistentHash_0(value_0) {
1145
+ const result_0 = __compactRuntime.persistentHash(_descriptor_16, value_0);
1146
+ return result_0;
1147
+ }
1148
+ _persistentHash_1(value_0) {
1149
+ const result_0 = __compactRuntime.persistentHash(_descriptor_12, value_0);
1150
+ return result_0;
1151
+ }
1152
+ _persistentHash_2(value_0) {
1153
+ const result_0 = __compactRuntime.persistentHash(_descriptor_14, value_0);
1154
+ return result_0;
1155
+ }
1156
+ _persistentCommit_0(value_0, rand_0) {
1157
+ const result_0 = __compactRuntime.persistentCommit(_descriptor_11,
1158
+ value_0,
1159
+ rand_0);
1160
+ return result_0;
1161
+ }
1162
+ _degradeToTransient_0(x_0) {
1163
+ const result_0 = __compactRuntime.degradeToTransient(x_0);
1164
+ return result_0;
1165
+ }
1166
+ _upgradeFromTransient_0(x_0) {
1167
+ const result_0 = __compactRuntime.upgradeFromTransient(x_0);
1168
+ return result_0;
1169
+ }
1170
+ _ownPublicKey_0(context, partialProofData) {
1171
+ const result_0 = __compactRuntime.ownPublicKey(context);
1172
+ partialProofData.privateTranscriptOutputs.push({
1173
+ value: _descriptor_8.toValue(result_0),
1174
+ alignment: _descriptor_8.alignment()
1175
+ });
1176
+ return result_0;
1177
+ }
1178
+ _createZswapInput_0(context, partialProofData, coin_0) {
1179
+ const result_0 = __compactRuntime.createZswapInput(context, coin_0);
1180
+ partialProofData.privateTranscriptOutputs.push({
1181
+ value: [],
1182
+ alignment: []
1183
+ });
1184
+ return result_0;
1185
+ }
1186
+ _createZswapOutput_0(context, partialProofData, coin_0, recipient_0) {
1187
+ const result_0 = __compactRuntime.createZswapOutput(context,
1188
+ coin_0,
1189
+ recipient_0);
1190
+ partialProofData.privateTranscriptOutputs.push({
1191
+ value: [],
1192
+ alignment: []
1193
+ });
1194
+ return result_0;
1195
+ }
1196
+ _creditDomain_0() {
1197
+ return new Uint8Array([109, 52, 48, 50, 58, 99, 114, 101, 100, 105, 116, 58, 118, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1198
+ }
1199
+ _creditColor_0(self_0) {
1200
+ return this._tokenType_0(this._creditDomain_0(), self_0);
1201
+ }
1202
+ _deriveReceipt_0(secret_0, serviceId_0) {
1203
+ return this._persistentHash_0([new Uint8Array([109, 52, 48, 50, 58, 114, 101, 99, 101, 105, 112, 116, 58, 118, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
1204
+ secret_0,
1205
+ serviceId_0]);
1206
+ }
1207
+ _deriveServiceId_0(owner_0, salt_0, price_0) {
1208
+ return this._persistentHash_1([new Uint8Array([109, 52, 48, 50, 58, 115, 105, 100, 58, 118, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
1209
+ owner_0,
1210
+ salt_0,
1211
+ __compactRuntime.convertBigintToBytes(32,
1212
+ price_0,
1213
+ 'm402-vault.compact line 40 char 43')]);
1214
+ }
1215
+ async _registerService_0(context, partialProofData, salt_0, price_0, owner_0)
1216
+ {
1217
+ __compactRuntime.assert(price_0 > 0n, 'price must be positive');
1218
+ __compactRuntime.assert(!this._equal_3(owner_0,
1219
+ new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])),
1220
+ 'owner must be set');
1221
+ const serviceId_0 = this._deriveServiceId_0(owner_0, salt_0, price_0);
1222
+ __compactRuntime.assert(!_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1223
+ partialProofData,
1224
+ [
1225
+ { dup: { n: 0 } },
1226
+ { idx: { cached: false,
1227
+ pushPath: false,
1228
+ path: [
1229
+ { tag: 'value',
1230
+ value: { value: _descriptor_24.toValue(0n),
1231
+ alignment: _descriptor_24.alignment() } }] } },
1232
+ { push: { storage: false,
1233
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(serviceId_0),
1234
+ alignment: _descriptor_0.alignment() }).encode() } },
1235
+ 'member',
1236
+ { popeq: { cached: true,
1237
+ result: undefined } }]).value),
1238
+ 'already registered');
1239
+ __compactRuntime.assert(!_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1240
+ partialProofData,
1241
+ [
1242
+ { dup: { n: 0 } },
1243
+ { idx: { cached: false,
1244
+ pushPath: false,
1245
+ path: [
1246
+ { tag: 'value',
1247
+ value: { value: _descriptor_24.toValue(1n),
1248
+ alignment: _descriptor_24.alignment() } }] } },
1249
+ { push: { storage: false,
1250
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(serviceId_0),
1251
+ alignment: _descriptor_0.alignment() }).encode() } },
1252
+ 'member',
1253
+ { popeq: { cached: true,
1254
+ result: undefined } }]).value),
1255
+ 'already registered');
1256
+ __compactRuntime.queryLedgerState(context,
1257
+ partialProofData,
1258
+ [
1259
+ { idx: { cached: false,
1260
+ pushPath: true,
1261
+ path: [
1262
+ { tag: 'value',
1263
+ value: { value: _descriptor_24.toValue(0n),
1264
+ alignment: _descriptor_24.alignment() } }] } },
1265
+ { push: { storage: false,
1266
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(serviceId_0),
1267
+ alignment: _descriptor_0.alignment() }).encode() } },
1268
+ { push: { storage: true,
1269
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(price_0),
1270
+ alignment: _descriptor_2.alignment() }).encode() } },
1271
+ { ins: { cached: false, n: 1 } },
1272
+ { ins: { cached: true, n: 1 } }]);
1273
+ __compactRuntime.queryLedgerState(context,
1274
+ partialProofData,
1275
+ [
1276
+ { idx: { cached: false,
1277
+ pushPath: true,
1278
+ path: [
1279
+ { tag: 'value',
1280
+ value: { value: _descriptor_24.toValue(1n),
1281
+ alignment: _descriptor_24.alignment() } }] } },
1282
+ { push: { storage: false,
1283
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(serviceId_0),
1284
+ alignment: _descriptor_0.alignment() }).encode() } },
1285
+ { push: { storage: true,
1286
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(owner_0),
1287
+ alignment: _descriptor_0.alignment() }).encode() } },
1288
+ { ins: { cached: false, n: 1 } },
1289
+ { ins: { cached: true, n: 1 } }]);
1290
+ return [];
1291
+ }
1292
+ async _deposit_0(context, partialProofData, amount_0, nonceSeed_0) {
1293
+ __compactRuntime.assert(amount_0 > 0n, 'amount must be positive');
1294
+ await this._receiveUnshielded_0(context,
1295
+ partialProofData,
1296
+ this._nativeToken_0(),
1297
+ amount_0);
1298
+ const nonce_0 = this._evolveNonce_0(((t1) => {
1299
+ if (t1 > 18446744073709551615n) {
1300
+ throw new __compactRuntime.CompactError('m402-vault.compact line 63 char 38: cast from Field or Uint value to smaller Uint value failed: ' + t1 + ' is greater than 18446744073709551615');
1301
+ }
1302
+ return t1;
1303
+ })(_descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1304
+ partialProofData,
1305
+ [
1306
+ { dup: { n: 0 } },
1307
+ { idx: { cached: false,
1308
+ pushPath: false,
1309
+ path: [
1310
+ { tag: 'value',
1311
+ value: { value: _descriptor_24.toValue(4n),
1312
+ alignment: _descriptor_24.alignment() } }] } },
1313
+ { popeq: { cached: true,
1314
+ result: undefined } }]).value)),
1315
+ nonceSeed_0);
1316
+ const coin_0 = await this._mintShieldedToken_0(context,
1317
+ partialProofData,
1318
+ this._creditDomain_0(),
1319
+ amount_0,
1320
+ nonce_0,
1321
+ this._right_0(_descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
1322
+ partialProofData,
1323
+ [
1324
+ { dup: { n: 2 } },
1325
+ { idx: { cached: true,
1326
+ pushPath: false,
1327
+ path: [
1328
+ { tag: 'value',
1329
+ value: { value: _descriptor_24.toValue(0n),
1330
+ alignment: _descriptor_24.alignment() } }] } },
1331
+ { popeq: { cached: true,
1332
+ result: undefined } }]).value)));
1333
+ await this._sendImmediateShielded_0(context,
1334
+ partialProofData,
1335
+ coin_0,
1336
+ this._left_0(this._ownPublicKey_0(context,
1337
+ partialProofData)),
1338
+ coin_0.value);
1339
+ const tmp_0 = 1n;
1340
+ __compactRuntime.queryLedgerState(context,
1341
+ partialProofData,
1342
+ [
1343
+ { idx: { cached: false,
1344
+ pushPath: true,
1345
+ path: [
1346
+ { tag: 'value',
1347
+ value: { value: _descriptor_24.toValue(4n),
1348
+ alignment: _descriptor_24.alignment() } }] } },
1349
+ { addi: { immediate: parseInt(__compactRuntime.valueToBigInt(
1350
+ { value: _descriptor_6.toValue(tmp_0),
1351
+ alignment: _descriptor_6.alignment() }
1352
+ .value
1353
+ )) } },
1354
+ { ins: { cached: true, n: 1 } }]);
1355
+ return [];
1356
+ }
1357
+ async _pay_0(context, partialProofData, serviceId_0, credit_0, receiptSecret_0)
1358
+ {
1359
+ const sid_0 = serviceId_0;
1360
+ __compactRuntime.assert(_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1361
+ partialProofData,
1362
+ [
1363
+ { dup: { n: 0 } },
1364
+ { idx: { cached: false,
1365
+ pushPath: false,
1366
+ path: [
1367
+ { tag: 'value',
1368
+ value: { value: _descriptor_24.toValue(0n),
1369
+ alignment: _descriptor_24.alignment() } }] } },
1370
+ { push: { storage: false,
1371
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(sid_0),
1372
+ alignment: _descriptor_0.alignment() }).encode() } },
1373
+ 'member',
1374
+ { popeq: { cached: true,
1375
+ result: undefined } }]).value),
1376
+ 'unknown service');
1377
+ const price_0 = _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1378
+ partialProofData,
1379
+ [
1380
+ { dup: { n: 0 } },
1381
+ { idx: { cached: false,
1382
+ pushPath: false,
1383
+ path: [
1384
+ { tag: 'value',
1385
+ value: { value: _descriptor_24.toValue(0n),
1386
+ alignment: _descriptor_24.alignment() } }] } },
1387
+ { idx: { cached: false,
1388
+ pushPath: false,
1389
+ path: [
1390
+ { tag: 'value',
1391
+ value: { value: _descriptor_0.toValue(sid_0),
1392
+ alignment: _descriptor_0.alignment() } }] } },
1393
+ { popeq: { cached: false,
1394
+ result: undefined } }]).value);
1395
+ __compactRuntime.assert(this._equal_4(credit_0.color,
1396
+ this._tokenType_0(this._creditDomain_0(),
1397
+ _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
1398
+ partialProofData,
1399
+ [
1400
+ { dup: { n: 2 } },
1401
+ { idx: { cached: true,
1402
+ pushPath: false,
1403
+ path: [
1404
+ { tag: 'value',
1405
+ value: { value: _descriptor_24.toValue(0n),
1406
+ alignment: _descriptor_24.alignment() } }] } },
1407
+ { popeq: { cached: true,
1408
+ result: undefined } }]).value))),
1409
+ 'not an m402 credit');
1410
+ __compactRuntime.assert(credit_0.value === price_0, 'wrong amount');
1411
+ const receipt_0 = this._deriveReceipt_0(receiptSecret_0, sid_0);
1412
+ __compactRuntime.assert(!_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1413
+ partialProofData,
1414
+ [
1415
+ { dup: { n: 0 } },
1416
+ { idx: { cached: false,
1417
+ pushPath: false,
1418
+ path: [
1419
+ { tag: 'value',
1420
+ value: { value: _descriptor_24.toValue(2n),
1421
+ alignment: _descriptor_24.alignment() } }] } },
1422
+ { push: { storage: false,
1423
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(receipt_0),
1424
+ alignment: _descriptor_0.alignment() }).encode() } },
1425
+ 'member',
1426
+ { popeq: { cached: true,
1427
+ result: undefined } }]).value),
1428
+ 'receipt reused');
1429
+ await this._receiveShielded_0(context, partialProofData, credit_0);
1430
+ __compactRuntime.queryLedgerState(context,
1431
+ partialProofData,
1432
+ [
1433
+ { idx: { cached: false,
1434
+ pushPath: true,
1435
+ path: [
1436
+ { tag: 'value',
1437
+ value: { value: _descriptor_24.toValue(2n),
1438
+ alignment: _descriptor_24.alignment() } }] } },
1439
+ { push: { storage: false,
1440
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(receipt_0),
1441
+ alignment: _descriptor_0.alignment() }).encode() } },
1442
+ { push: { storage: true,
1443
+ value: __compactRuntime.StateValue.newNull().encode() } },
1444
+ { ins: { cached: false, n: 1 } },
1445
+ { ins: { cached: true, n: 1 } }]);
1446
+ const owner_0 = _descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
1447
+ partialProofData,
1448
+ [
1449
+ { dup: { n: 0 } },
1450
+ { idx: { cached: false,
1451
+ pushPath: false,
1452
+ path: [
1453
+ { tag: 'value',
1454
+ value: { value: _descriptor_24.toValue(1n),
1455
+ alignment: _descriptor_24.alignment() } }] } },
1456
+ { idx: { cached: false,
1457
+ pushPath: false,
1458
+ path: [
1459
+ { tag: 'value',
1460
+ value: { value: _descriptor_0.toValue(sid_0),
1461
+ alignment: _descriptor_0.alignment() } }] } },
1462
+ { popeq: { cached: false,
1463
+ result: undefined } }]).value);
1464
+ const prior_0 = _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1465
+ partialProofData,
1466
+ [
1467
+ { dup: { n: 0 } },
1468
+ { idx: { cached: false,
1469
+ pushPath: false,
1470
+ path: [
1471
+ { tag: 'value',
1472
+ value: { value: _descriptor_24.toValue(3n),
1473
+ alignment: _descriptor_24.alignment() } }] } },
1474
+ { push: { storage: false,
1475
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(owner_0),
1476
+ alignment: _descriptor_0.alignment() }).encode() } },
1477
+ 'member',
1478
+ { popeq: { cached: true,
1479
+ result: undefined } }]).value)
1480
+ ?
1481
+ _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1482
+ partialProofData,
1483
+ [
1484
+ { dup: { n: 0 } },
1485
+ { idx: { cached: false,
1486
+ pushPath: false,
1487
+ path: [
1488
+ { tag: 'value',
1489
+ value: { value: _descriptor_24.toValue(3n),
1490
+ alignment: _descriptor_24.alignment() } }] } },
1491
+ { idx: { cached: false,
1492
+ pushPath: false,
1493
+ path: [
1494
+ { tag: 'value',
1495
+ value: { value: _descriptor_0.toValue(owner_0),
1496
+ alignment: _descriptor_0.alignment() } }] } },
1497
+ { popeq: { cached: false,
1498
+ result: undefined } }]).value)
1499
+ :
1500
+ 0n;
1501
+ const tmp_0 = ((t1) => {
1502
+ if (t1 > 18446744073709551615n) {
1503
+ throw new __compactRuntime.CompactError('m402-vault.compact line 99 char 33: cast from Field or Uint value to smaller Uint value failed: ' + t1 + ' is greater than 18446744073709551615');
1504
+ }
1505
+ return t1;
1506
+ })(prior_0 + price_0);
1507
+ __compactRuntime.queryLedgerState(context,
1508
+ partialProofData,
1509
+ [
1510
+ { idx: { cached: false,
1511
+ pushPath: true,
1512
+ path: [
1513
+ { tag: 'value',
1514
+ value: { value: _descriptor_24.toValue(3n),
1515
+ alignment: _descriptor_24.alignment() } }] } },
1516
+ { push: { storage: false,
1517
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(owner_0),
1518
+ alignment: _descriptor_0.alignment() }).encode() } },
1519
+ { push: { storage: true,
1520
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(tmp_0),
1521
+ alignment: _descriptor_2.alignment() }).encode() } },
1522
+ { ins: { cached: false, n: 1 } },
1523
+ { ins: { cached: true, n: 1 } }]);
1524
+ return [];
1525
+ }
1526
+ async _redeem_0(context, partialProofData, recipient_0, credit_0) {
1527
+ __compactRuntime.assert(!this._equal_5(recipient_0,
1528
+ new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])),
1529
+ 'recipient must be set');
1530
+ __compactRuntime.assert(this._equal_6(credit_0.color,
1531
+ this._tokenType_0(this._creditDomain_0(),
1532
+ _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
1533
+ partialProofData,
1534
+ [
1535
+ { dup: { n: 2 } },
1536
+ { idx: { cached: true,
1537
+ pushPath: false,
1538
+ path: [
1539
+ { tag: 'value',
1540
+ value: { value: _descriptor_24.toValue(0n),
1541
+ alignment: _descriptor_24.alignment() } }] } },
1542
+ { popeq: { cached: true,
1543
+ result: undefined } }]).value))),
1544
+ 'not an m402 credit');
1545
+ let t_0;
1546
+ __compactRuntime.assert((t_0 = credit_0.value, t_0 > 0n),
1547
+ 'nothing to redeem');
1548
+ await this._receiveShielded_0(context, partialProofData, credit_0);
1549
+ await this._sendUnshielded_0(context,
1550
+ partialProofData,
1551
+ this._nativeToken_0(),
1552
+ credit_0.value,
1553
+ this._right_1({ bytes: recipient_0 }));
1554
+ return [];
1555
+ }
1556
+ async _withdraw_0(context, partialProofData, serviceId_0, amount_0) {
1557
+ const sid_0 = serviceId_0;
1558
+ __compactRuntime.assert(amount_0 > 0n, 'amount must be positive');
1559
+ __compactRuntime.assert(_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1560
+ partialProofData,
1561
+ [
1562
+ { dup: { n: 0 } },
1563
+ { idx: { cached: false,
1564
+ pushPath: false,
1565
+ path: [
1566
+ { tag: 'value',
1567
+ value: { value: _descriptor_24.toValue(1n),
1568
+ alignment: _descriptor_24.alignment() } }] } },
1569
+ { push: { storage: false,
1570
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(sid_0),
1571
+ alignment: _descriptor_0.alignment() }).encode() } },
1572
+ 'member',
1573
+ { popeq: { cached: true,
1574
+ result: undefined } }]).value),
1575
+ 'unknown service');
1576
+ const owner_0 = _descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
1577
+ partialProofData,
1578
+ [
1579
+ { dup: { n: 0 } },
1580
+ { idx: { cached: false,
1581
+ pushPath: false,
1582
+ path: [
1583
+ { tag: 'value',
1584
+ value: { value: _descriptor_24.toValue(1n),
1585
+ alignment: _descriptor_24.alignment() } }] } },
1586
+ { idx: { cached: false,
1587
+ pushPath: false,
1588
+ path: [
1589
+ { tag: 'value',
1590
+ value: { value: _descriptor_0.toValue(sid_0),
1591
+ alignment: _descriptor_0.alignment() } }] } },
1592
+ { popeq: { cached: false,
1593
+ result: undefined } }]).value);
1594
+ __compactRuntime.assert(_descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1595
+ partialProofData,
1596
+ [
1597
+ { dup: { n: 0 } },
1598
+ { idx: { cached: false,
1599
+ pushPath: false,
1600
+ path: [
1601
+ { tag: 'value',
1602
+ value: { value: _descriptor_24.toValue(3n),
1603
+ alignment: _descriptor_24.alignment() } }] } },
1604
+ { push: { storage: false,
1605
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(owner_0),
1606
+ alignment: _descriptor_0.alignment() }).encode() } },
1607
+ 'member',
1608
+ { popeq: { cached: true,
1609
+ result: undefined } }]).value),
1610
+ 'no balance');
1611
+ const balance_0 = _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1612
+ partialProofData,
1613
+ [
1614
+ { dup: { n: 0 } },
1615
+ { idx: { cached: false,
1616
+ pushPath: false,
1617
+ path: [
1618
+ { tag: 'value',
1619
+ value: { value: _descriptor_24.toValue(3n),
1620
+ alignment: _descriptor_24.alignment() } }] } },
1621
+ { idx: { cached: false,
1622
+ pushPath: false,
1623
+ path: [
1624
+ { tag: 'value',
1625
+ value: { value: _descriptor_0.toValue(owner_0),
1626
+ alignment: _descriptor_0.alignment() } }] } },
1627
+ { popeq: { cached: false,
1628
+ result: undefined } }]).value);
1629
+ __compactRuntime.assert(balance_0 >= amount_0, 'insufficient balance');
1630
+ await this._sendUnshielded_0(context,
1631
+ partialProofData,
1632
+ this._nativeToken_0(),
1633
+ amount_0,
1634
+ this._right_1({ bytes: owner_0 }));
1635
+ let t_0;
1636
+ const tmp_0 = (t_0 = amount_0,
1637
+ (__compactRuntime.assert(balance_0 >= t_0,
1638
+ 'result of subtraction would be negative'),
1639
+ balance_0 - t_0));
1640
+ __compactRuntime.queryLedgerState(context,
1641
+ partialProofData,
1642
+ [
1643
+ { idx: { cached: false,
1644
+ pushPath: true,
1645
+ path: [
1646
+ { tag: 'value',
1647
+ value: { value: _descriptor_24.toValue(3n),
1648
+ alignment: _descriptor_24.alignment() } }] } },
1649
+ { push: { storage: false,
1650
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(owner_0),
1651
+ alignment: _descriptor_0.alignment() }).encode() } },
1652
+ { push: { storage: true,
1653
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(tmp_0),
1654
+ alignment: _descriptor_2.alignment() }).encode() } },
1655
+ { ins: { cached: false, n: 1 } },
1656
+ { ins: { cached: true, n: 1 } }]);
1657
+ return [];
1658
+ }
1659
+ _equal_0(x0, y0) {
1660
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1661
+ return true;
1662
+ }
1663
+ _equal_1(x0, y0) {
1664
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1665
+ return true;
1666
+ }
1667
+ _equal_2(x0, y0) {
1668
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1669
+ return true;
1670
+ }
1671
+ _equal_3(x0, y0) {
1672
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1673
+ return true;
1674
+ }
1675
+ _equal_4(x0, y0) {
1676
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1677
+ return true;
1678
+ }
1679
+ _equal_5(x0, y0) {
1680
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1681
+ return true;
1682
+ }
1683
+ _equal_6(x0, y0) {
1684
+ if (!x0.every((x, i) => y0[i] === x)) { return false; }
1685
+ return true;
1686
+ }
1687
+ }
1688
+ export function ledger(stateOrChargedState) {
1689
+ const state = stateOrChargedState instanceof __compactRuntime.StateValue ? stateOrChargedState : stateOrChargedState.state;
1690
+ const chargedState = stateOrChargedState instanceof __compactRuntime.StateValue ? new __compactRuntime.ChargedState(stateOrChargedState) : stateOrChargedState;
1691
+ const context = {
1692
+ callContext: { currentQueryContext: new __compactRuntime.QueryContext(chargedState, __compactRuntime.dummyContractAddress()), currentGasCost: __compactRuntime.emptyRunningCost() },
1693
+ costModel: __compactRuntime.CostModel.initialCostModel()
1694
+ };
1695
+ const partialProofData = {
1696
+ input: { value: [], alignment: [] },
1697
+ output: undefined,
1698
+ publicTranscript: [],
1699
+ privateTranscriptOutputs: []
1700
+ };
1701
+ return {
1702
+ servicePrice: {
1703
+ isEmpty(...args_0) {
1704
+ if (args_0.length !== 0) {
1705
+ throw new __compactRuntime.CompactError(`isEmpty: expected 0 arguments, received ${args_0.length}`);
1706
+ }
1707
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1708
+ partialProofData,
1709
+ [
1710
+ { dup: { n: 0 } },
1711
+ { idx: { cached: false,
1712
+ pushPath: false,
1713
+ path: [
1714
+ { tag: 'value',
1715
+ value: { value: _descriptor_24.toValue(0n),
1716
+ alignment: _descriptor_24.alignment() } }] } },
1717
+ 'size',
1718
+ { push: { storage: false,
1719
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(0n),
1720
+ alignment: _descriptor_2.alignment() }).encode() } },
1721
+ 'eq',
1722
+ { popeq: { cached: true,
1723
+ result: undefined } }]).value);
1724
+ },
1725
+ size(...args_0) {
1726
+ if (args_0.length !== 0) {
1727
+ throw new __compactRuntime.CompactError(`size: expected 0 arguments, received ${args_0.length}`);
1728
+ }
1729
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1730
+ partialProofData,
1731
+ [
1732
+ { dup: { n: 0 } },
1733
+ { idx: { cached: false,
1734
+ pushPath: false,
1735
+ path: [
1736
+ { tag: 'value',
1737
+ value: { value: _descriptor_24.toValue(0n),
1738
+ alignment: _descriptor_24.alignment() } }] } },
1739
+ 'size',
1740
+ { popeq: { cached: true,
1741
+ result: undefined } }]).value);
1742
+ },
1743
+ member(...args_0) {
1744
+ if (args_0.length !== 1) {
1745
+ throw new __compactRuntime.CompactError(`member: expected 1 argument, received ${args_0.length}`);
1746
+ }
1747
+ const key_0 = args_0[0];
1748
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
1749
+ __compactRuntime.typeError('member',
1750
+ 'argument 1',
1751
+ 'm402-vault.compact line 10 char 1',
1752
+ 'Bytes<32>',
1753
+ key_0)
1754
+ }
1755
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1756
+ partialProofData,
1757
+ [
1758
+ { dup: { n: 0 } },
1759
+ { idx: { cached: false,
1760
+ pushPath: false,
1761
+ path: [
1762
+ { tag: 'value',
1763
+ value: { value: _descriptor_24.toValue(0n),
1764
+ alignment: _descriptor_24.alignment() } }] } },
1765
+ { push: { storage: false,
1766
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(key_0),
1767
+ alignment: _descriptor_0.alignment() }).encode() } },
1768
+ 'member',
1769
+ { popeq: { cached: true,
1770
+ result: undefined } }]).value);
1771
+ },
1772
+ lookup(...args_0) {
1773
+ if (args_0.length !== 1) {
1774
+ throw new __compactRuntime.CompactError(`lookup: expected 1 argument, received ${args_0.length}`);
1775
+ }
1776
+ const key_0 = args_0[0];
1777
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
1778
+ __compactRuntime.typeError('lookup',
1779
+ 'argument 1',
1780
+ 'm402-vault.compact line 10 char 1',
1781
+ 'Bytes<32>',
1782
+ key_0)
1783
+ }
1784
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1785
+ partialProofData,
1786
+ [
1787
+ { dup: { n: 0 } },
1788
+ { idx: { cached: false,
1789
+ pushPath: false,
1790
+ path: [
1791
+ { tag: 'value',
1792
+ value: { value: _descriptor_24.toValue(0n),
1793
+ alignment: _descriptor_24.alignment() } }] } },
1794
+ { idx: { cached: false,
1795
+ pushPath: false,
1796
+ path: [
1797
+ { tag: 'value',
1798
+ value: { value: _descriptor_0.toValue(key_0),
1799
+ alignment: _descriptor_0.alignment() } }] } },
1800
+ { popeq: { cached: false,
1801
+ result: undefined } }]).value);
1802
+ },
1803
+ [Symbol.iterator](...args_0) {
1804
+ if (args_0.length !== 0) {
1805
+ throw new __compactRuntime.CompactError(`iter: expected 0 arguments, received ${args_0.length}`);
1806
+ }
1807
+ const self_0 = state.asArray()[0];
1808
+ return self_0.asMap().keys().map( (key) => { const value = self_0.asMap().get(key).asCell(); return [ _descriptor_0.fromValue(key.value), _descriptor_2.fromValue(value.value) ]; })[Symbol.iterator]();
1809
+ }
1810
+ },
1811
+ serviceOwner: {
1812
+ isEmpty(...args_0) {
1813
+ if (args_0.length !== 0) {
1814
+ throw new __compactRuntime.CompactError(`isEmpty: expected 0 arguments, received ${args_0.length}`);
1815
+ }
1816
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1817
+ partialProofData,
1818
+ [
1819
+ { dup: { n: 0 } },
1820
+ { idx: { cached: false,
1821
+ pushPath: false,
1822
+ path: [
1823
+ { tag: 'value',
1824
+ value: { value: _descriptor_24.toValue(1n),
1825
+ alignment: _descriptor_24.alignment() } }] } },
1826
+ 'size',
1827
+ { push: { storage: false,
1828
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(0n),
1829
+ alignment: _descriptor_2.alignment() }).encode() } },
1830
+ 'eq',
1831
+ { popeq: { cached: true,
1832
+ result: undefined } }]).value);
1833
+ },
1834
+ size(...args_0) {
1835
+ if (args_0.length !== 0) {
1836
+ throw new __compactRuntime.CompactError(`size: expected 0 arguments, received ${args_0.length}`);
1837
+ }
1838
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1839
+ partialProofData,
1840
+ [
1841
+ { dup: { n: 0 } },
1842
+ { idx: { cached: false,
1843
+ pushPath: false,
1844
+ path: [
1845
+ { tag: 'value',
1846
+ value: { value: _descriptor_24.toValue(1n),
1847
+ alignment: _descriptor_24.alignment() } }] } },
1848
+ 'size',
1849
+ { popeq: { cached: true,
1850
+ result: undefined } }]).value);
1851
+ },
1852
+ member(...args_0) {
1853
+ if (args_0.length !== 1) {
1854
+ throw new __compactRuntime.CompactError(`member: expected 1 argument, received ${args_0.length}`);
1855
+ }
1856
+ const key_0 = args_0[0];
1857
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
1858
+ __compactRuntime.typeError('member',
1859
+ 'argument 1',
1860
+ 'm402-vault.compact line 11 char 1',
1861
+ 'Bytes<32>',
1862
+ key_0)
1863
+ }
1864
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1865
+ partialProofData,
1866
+ [
1867
+ { dup: { n: 0 } },
1868
+ { idx: { cached: false,
1869
+ pushPath: false,
1870
+ path: [
1871
+ { tag: 'value',
1872
+ value: { value: _descriptor_24.toValue(1n),
1873
+ alignment: _descriptor_24.alignment() } }] } },
1874
+ { push: { storage: false,
1875
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(key_0),
1876
+ alignment: _descriptor_0.alignment() }).encode() } },
1877
+ 'member',
1878
+ { popeq: { cached: true,
1879
+ result: undefined } }]).value);
1880
+ },
1881
+ lookup(...args_0) {
1882
+ if (args_0.length !== 1) {
1883
+ throw new __compactRuntime.CompactError(`lookup: expected 1 argument, received ${args_0.length}`);
1884
+ }
1885
+ const key_0 = args_0[0];
1886
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
1887
+ __compactRuntime.typeError('lookup',
1888
+ 'argument 1',
1889
+ 'm402-vault.compact line 11 char 1',
1890
+ 'Bytes<32>',
1891
+ key_0)
1892
+ }
1893
+ return _descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
1894
+ partialProofData,
1895
+ [
1896
+ { dup: { n: 0 } },
1897
+ { idx: { cached: false,
1898
+ pushPath: false,
1899
+ path: [
1900
+ { tag: 'value',
1901
+ value: { value: _descriptor_24.toValue(1n),
1902
+ alignment: _descriptor_24.alignment() } }] } },
1903
+ { idx: { cached: false,
1904
+ pushPath: false,
1905
+ path: [
1906
+ { tag: 'value',
1907
+ value: { value: _descriptor_0.toValue(key_0),
1908
+ alignment: _descriptor_0.alignment() } }] } },
1909
+ { popeq: { cached: false,
1910
+ result: undefined } }]).value);
1911
+ },
1912
+ [Symbol.iterator](...args_0) {
1913
+ if (args_0.length !== 0) {
1914
+ throw new __compactRuntime.CompactError(`iter: expected 0 arguments, received ${args_0.length}`);
1915
+ }
1916
+ const self_0 = state.asArray()[1];
1917
+ return self_0.asMap().keys().map( (key) => { const value = self_0.asMap().get(key).asCell(); return [ _descriptor_0.fromValue(key.value), _descriptor_0.fromValue(value.value) ]; })[Symbol.iterator]();
1918
+ }
1919
+ },
1920
+ receipts: {
1921
+ isEmpty(...args_0) {
1922
+ if (args_0.length !== 0) {
1923
+ throw new __compactRuntime.CompactError(`isEmpty: expected 0 arguments, received ${args_0.length}`);
1924
+ }
1925
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1926
+ partialProofData,
1927
+ [
1928
+ { dup: { n: 0 } },
1929
+ { idx: { cached: false,
1930
+ pushPath: false,
1931
+ path: [
1932
+ { tag: 'value',
1933
+ value: { value: _descriptor_24.toValue(2n),
1934
+ alignment: _descriptor_24.alignment() } }] } },
1935
+ 'size',
1936
+ { push: { storage: false,
1937
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(0n),
1938
+ alignment: _descriptor_2.alignment() }).encode() } },
1939
+ 'eq',
1940
+ { popeq: { cached: true,
1941
+ result: undefined } }]).value);
1942
+ },
1943
+ size(...args_0) {
1944
+ if (args_0.length !== 0) {
1945
+ throw new __compactRuntime.CompactError(`size: expected 0 arguments, received ${args_0.length}`);
1946
+ }
1947
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
1948
+ partialProofData,
1949
+ [
1950
+ { dup: { n: 0 } },
1951
+ { idx: { cached: false,
1952
+ pushPath: false,
1953
+ path: [
1954
+ { tag: 'value',
1955
+ value: { value: _descriptor_24.toValue(2n),
1956
+ alignment: _descriptor_24.alignment() } }] } },
1957
+ 'size',
1958
+ { popeq: { cached: true,
1959
+ result: undefined } }]).value);
1960
+ },
1961
+ member(...args_0) {
1962
+ if (args_0.length !== 1) {
1963
+ throw new __compactRuntime.CompactError(`member: expected 1 argument, received ${args_0.length}`);
1964
+ }
1965
+ const elem_0 = args_0[0];
1966
+ if (!(elem_0.buffer instanceof ArrayBuffer && elem_0.BYTES_PER_ELEMENT === 1 && elem_0.length === 32)) {
1967
+ __compactRuntime.typeError('member',
1968
+ 'argument 1',
1969
+ 'm402-vault.compact line 12 char 1',
1970
+ 'Bytes<32>',
1971
+ elem_0)
1972
+ }
1973
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
1974
+ partialProofData,
1975
+ [
1976
+ { dup: { n: 0 } },
1977
+ { idx: { cached: false,
1978
+ pushPath: false,
1979
+ path: [
1980
+ { tag: 'value',
1981
+ value: { value: _descriptor_24.toValue(2n),
1982
+ alignment: _descriptor_24.alignment() } }] } },
1983
+ { push: { storage: false,
1984
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(elem_0),
1985
+ alignment: _descriptor_0.alignment() }).encode() } },
1986
+ 'member',
1987
+ { popeq: { cached: true,
1988
+ result: undefined } }]).value);
1989
+ },
1990
+ [Symbol.iterator](...args_0) {
1991
+ if (args_0.length !== 0) {
1992
+ throw new __compactRuntime.CompactError(`iter: expected 0 arguments, received ${args_0.length}`);
1993
+ }
1994
+ const self_0 = state.asArray()[2];
1995
+ return self_0.asMap().keys().map((elem) => _descriptor_0.fromValue(elem.value))[Symbol.iterator]();
1996
+ }
1997
+ },
1998
+ merchantBalance: {
1999
+ isEmpty(...args_0) {
2000
+ if (args_0.length !== 0) {
2001
+ throw new __compactRuntime.CompactError(`isEmpty: expected 0 arguments, received ${args_0.length}`);
2002
+ }
2003
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
2004
+ partialProofData,
2005
+ [
2006
+ { dup: { n: 0 } },
2007
+ { idx: { cached: false,
2008
+ pushPath: false,
2009
+ path: [
2010
+ { tag: 'value',
2011
+ value: { value: _descriptor_24.toValue(3n),
2012
+ alignment: _descriptor_24.alignment() } }] } },
2013
+ 'size',
2014
+ { push: { storage: false,
2015
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(0n),
2016
+ alignment: _descriptor_2.alignment() }).encode() } },
2017
+ 'eq',
2018
+ { popeq: { cached: true,
2019
+ result: undefined } }]).value);
2020
+ },
2021
+ size(...args_0) {
2022
+ if (args_0.length !== 0) {
2023
+ throw new __compactRuntime.CompactError(`size: expected 0 arguments, received ${args_0.length}`);
2024
+ }
2025
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
2026
+ partialProofData,
2027
+ [
2028
+ { dup: { n: 0 } },
2029
+ { idx: { cached: false,
2030
+ pushPath: false,
2031
+ path: [
2032
+ { tag: 'value',
2033
+ value: { value: _descriptor_24.toValue(3n),
2034
+ alignment: _descriptor_24.alignment() } }] } },
2035
+ 'size',
2036
+ { popeq: { cached: true,
2037
+ result: undefined } }]).value);
2038
+ },
2039
+ member(...args_0) {
2040
+ if (args_0.length !== 1) {
2041
+ throw new __compactRuntime.CompactError(`member: expected 1 argument, received ${args_0.length}`);
2042
+ }
2043
+ const key_0 = args_0[0];
2044
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
2045
+ __compactRuntime.typeError('member',
2046
+ 'argument 1',
2047
+ 'm402-vault.compact line 13 char 1',
2048
+ 'Bytes<32>',
2049
+ key_0)
2050
+ }
2051
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
2052
+ partialProofData,
2053
+ [
2054
+ { dup: { n: 0 } },
2055
+ { idx: { cached: false,
2056
+ pushPath: false,
2057
+ path: [
2058
+ { tag: 'value',
2059
+ value: { value: _descriptor_24.toValue(3n),
2060
+ alignment: _descriptor_24.alignment() } }] } },
2061
+ { push: { storage: false,
2062
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(key_0),
2063
+ alignment: _descriptor_0.alignment() }).encode() } },
2064
+ 'member',
2065
+ { popeq: { cached: true,
2066
+ result: undefined } }]).value);
2067
+ },
2068
+ lookup(...args_0) {
2069
+ if (args_0.length !== 1) {
2070
+ throw new __compactRuntime.CompactError(`lookup: expected 1 argument, received ${args_0.length}`);
2071
+ }
2072
+ const key_0 = args_0[0];
2073
+ if (!(key_0.buffer instanceof ArrayBuffer && key_0.BYTES_PER_ELEMENT === 1 && key_0.length === 32)) {
2074
+ __compactRuntime.typeError('lookup',
2075
+ 'argument 1',
2076
+ 'm402-vault.compact line 13 char 1',
2077
+ 'Bytes<32>',
2078
+ key_0)
2079
+ }
2080
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
2081
+ partialProofData,
2082
+ [
2083
+ { dup: { n: 0 } },
2084
+ { idx: { cached: false,
2085
+ pushPath: false,
2086
+ path: [
2087
+ { tag: 'value',
2088
+ value: { value: _descriptor_24.toValue(3n),
2089
+ alignment: _descriptor_24.alignment() } }] } },
2090
+ { idx: { cached: false,
2091
+ pushPath: false,
2092
+ path: [
2093
+ { tag: 'value',
2094
+ value: { value: _descriptor_0.toValue(key_0),
2095
+ alignment: _descriptor_0.alignment() } }] } },
2096
+ { popeq: { cached: false,
2097
+ result: undefined } }]).value);
2098
+ },
2099
+ [Symbol.iterator](...args_0) {
2100
+ if (args_0.length !== 0) {
2101
+ throw new __compactRuntime.CompactError(`iter: expected 0 arguments, received ${args_0.length}`);
2102
+ }
2103
+ const self_0 = state.asArray()[3];
2104
+ return self_0.asMap().keys().map( (key) => { const value = self_0.asMap().get(key).asCell(); return [ _descriptor_0.fromValue(key.value), _descriptor_2.fromValue(value.value) ]; })[Symbol.iterator]();
2105
+ }
2106
+ },
2107
+ get mintCounter() {
2108
+ return _descriptor_2.fromValue(__compactRuntime.queryLedgerState(context,
2109
+ partialProofData,
2110
+ [
2111
+ { dup: { n: 0 } },
2112
+ { idx: { cached: false,
2113
+ pushPath: false,
2114
+ path: [
2115
+ { tag: 'value',
2116
+ value: { value: _descriptor_24.toValue(4n),
2117
+ alignment: _descriptor_24.alignment() } }] } },
2118
+ { popeq: { cached: true,
2119
+ result: undefined } }]).value);
2120
+ }
2121
+ };
2122
+ }
2123
+ const _emptyContext = {
2124
+ callContext: { currentQueryContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress()), currentGasCost: __compactRuntime.emptyRunningCost() }
2125
+ };
2126
+ const _dummyContract = new Contract({ });
2127
+ export const pureCircuits = {
2128
+ creditColor: (...args_0) => {
2129
+ if (args_0.length !== 1) {
2130
+ throw new __compactRuntime.CompactError(`creditColor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
2131
+ }
2132
+ const self_0 = args_0[0];
2133
+ if (!(typeof(self_0) === 'object' && self_0.bytes.buffer instanceof ArrayBuffer && self_0.bytes.BYTES_PER_ELEMENT === 1 && self_0.bytes.length === 32)) {
2134
+ __compactRuntime.typeError('creditColor',
2135
+ 'argument 1',
2136
+ 'm402-vault.compact line 20 char 1',
2137
+ 'struct ContractAddress<bytes: Bytes<32>>',
2138
+ self_0)
2139
+ }
2140
+ return _dummyContract._creditColor_0(self_0);
2141
+ },
2142
+ deriveReceipt: (...args_0) => {
2143
+ if (args_0.length !== 2) {
2144
+ throw new __compactRuntime.CompactError(`deriveReceipt: expected 2 arguments (as invoked from Typescript), received ${args_0.length}`);
2145
+ }
2146
+ const secret_0 = args_0[0];
2147
+ const serviceId_0 = args_0[1];
2148
+ if (!(secret_0.buffer instanceof ArrayBuffer && secret_0.BYTES_PER_ELEMENT === 1 && secret_0.length === 32)) {
2149
+ __compactRuntime.typeError('deriveReceipt',
2150
+ 'argument 1',
2151
+ 'm402-vault.compact line 26 char 1',
2152
+ 'Bytes<32>',
2153
+ secret_0)
2154
+ }
2155
+ if (!(serviceId_0.buffer instanceof ArrayBuffer && serviceId_0.BYTES_PER_ELEMENT === 1 && serviceId_0.length === 32)) {
2156
+ __compactRuntime.typeError('deriveReceipt',
2157
+ 'argument 2',
2158
+ 'm402-vault.compact line 26 char 1',
2159
+ 'Bytes<32>',
2160
+ serviceId_0)
2161
+ }
2162
+ return _dummyContract._deriveReceipt_0(secret_0, serviceId_0);
2163
+ },
2164
+ deriveServiceId: (...args_0) => {
2165
+ if (args_0.length !== 3) {
2166
+ throw new __compactRuntime.CompactError(`deriveServiceId: expected 3 arguments (as invoked from Typescript), received ${args_0.length}`);
2167
+ }
2168
+ const owner_0 = args_0[0];
2169
+ const salt_0 = args_0[1];
2170
+ const price_0 = args_0[2];
2171
+ if (!(owner_0.buffer instanceof ArrayBuffer && owner_0.BYTES_PER_ELEMENT === 1 && owner_0.length === 32)) {
2172
+ __compactRuntime.typeError('deriveServiceId',
2173
+ 'argument 1',
2174
+ 'm402-vault.compact line 34 char 1',
2175
+ 'Bytes<32>',
2176
+ owner_0)
2177
+ }
2178
+ if (!(salt_0.buffer instanceof ArrayBuffer && salt_0.BYTES_PER_ELEMENT === 1 && salt_0.length === 32)) {
2179
+ __compactRuntime.typeError('deriveServiceId',
2180
+ 'argument 2',
2181
+ 'm402-vault.compact line 34 char 1',
2182
+ 'Bytes<32>',
2183
+ salt_0)
2184
+ }
2185
+ if (!(typeof(price_0) === 'bigint' && price_0 >= 0n && price_0 <= 18446744073709551615n)) {
2186
+ __compactRuntime.typeError('deriveServiceId',
2187
+ 'argument 3',
2188
+ 'm402-vault.compact line 34 char 1',
2189
+ 'Uint<0..18446744073709551616>',
2190
+ price_0)
2191
+ }
2192
+ return _dummyContract._deriveServiceId_0(owner_0, salt_0, price_0);
2193
+ }
2194
+ };
2195
+ export const expectedVk = {
2196
+ 'deposit': '3967aa980c22fa7db0111c36ab0580752d1c27d242cbef9461fea2b2c0562566',
2197
+ 'pay': '44146e9d3102fc60deb47d61cc44029424f841c589322d9944b866b9e8d44a34',
2198
+ 'redeem': '13b94ab51c5988bbfd64c2aabd243da27a3ffffe298aa7041ef957480d2fb915',
2199
+ 'registerService': 'dece03cc1c292c0d305f9bd23485399c71336c88d74765f1ab1e53ced6905ff8',
2200
+ 'withdraw': 'a61392d20dae6d8fa2d7faac960b0213b92264c267fbdef1ad3b4415794d12d8',
2201
+ };
2202
+
2203
+ export const circuitSignatures = {
2204
+ 'creditColor': {pure: true, provable: false, argumentTypes: [{tag: 'Struct', name: 'ContractAddress', elements: [{name: 'bytes', type: {tag: 'Bytes', length: 32}}]}], resultType: {tag: 'Bytes', length: 32}},
2205
+ 'deriveReceipt': {pure: true, provable: false, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Bytes', length: 32}], resultType: {tag: 'Bytes', length: 32}},
2206
+ 'deriveServiceId': {pure: true, provable: false, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Bytes', length: 32}, {tag: 'Uint', maxval: '18446744073709551615'}], resultType: {tag: 'Bytes', length: 32}},
2207
+ 'registerService': {pure: false, provable: true, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Uint', maxval: '18446744073709551615'}, {tag: 'Bytes', length: 32}], resultType: {tag: 'Tuple', types: []}},
2208
+ 'deposit': {pure: false, provable: true, argumentTypes: [{tag: 'Uint', maxval: '18446744073709551615'}, {tag: 'Bytes', length: 32}], resultType: {tag: 'Tuple', types: []}},
2209
+ 'pay': {pure: false, provable: true, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Struct', name: 'ShieldedCoinInfo', elements: [{name: 'nonce', type: {tag: 'Bytes', length: 32}}, {name: 'color', type: {tag: 'Bytes', length: 32}}, {name: 'value', type: {tag: 'Uint', maxval: '340282366920938463463374607431768211455'}}]}, {tag: 'Bytes', length: 32}], resultType: {tag: 'Tuple', types: []}},
2210
+ 'redeem': {pure: false, provable: true, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Struct', name: 'ShieldedCoinInfo', elements: [{name: 'nonce', type: {tag: 'Bytes', length: 32}}, {name: 'color', type: {tag: 'Bytes', length: 32}}, {name: 'value', type: {tag: 'Uint', maxval: '340282366920938463463374607431768211455'}}]}], resultType: {tag: 'Tuple', types: []}},
2211
+ 'withdraw': {pure: false, provable: true, argumentTypes: [{tag: 'Bytes', length: 32}, {tag: 'Uint', maxval: '18446744073709551615'}], resultType: {tag: 'Tuple', types: []}},
2212
+ };
2213
+
2214
+ export const declaredInterfaces = {};
2215
+
2216
+ //# sourceMappingURL=index.js.map