@midnightntwrk/testkit-js 0.0.0-stage → 5.0.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.
Files changed (56) hide show
  1. package/README.md +409 -2
  2. package/dist/fixtures/hf/README.md +781 -0
  3. package/dist/fixtures/hf/coin-receiver-016/coin-receiver.compact +24 -0
  4. package/dist/fixtures/hf/coin-receiver-016/compiled/compiler/contract-info.json +104 -0
  5. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.d.ts +47 -0
  6. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.js +412 -0
  7. package/dist/fixtures/hf/coin-receiver-016/receive-coin-transcript.recording.json +668 -0
  8. package/dist/fixtures/hf/coin-receiver-016/state-v6-envelope.hex +1 -0
  9. package/dist/fixtures/hf/coin-receiver-016/state-v9.hex +1 -0
  10. package/dist/fixtures/hf/counter-016/compiled/compiler/contract-info.json +31 -0
  11. package/dist/fixtures/hf/counter-016/compiled/contract/index.d.ts +39 -0
  12. package/dist/fixtures/hf/counter-016/compiled/contract/index.js +189 -0
  13. package/dist/fixtures/hf/counter-016/compiled/keys/increment.prover +0 -0
  14. package/dist/fixtures/hf/counter-016/compiled/keys/increment.verifier +0 -0
  15. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.bzkir +0 -0
  16. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.zkir +22 -0
  17. package/dist/fixtures/hf/counter-016/increment-transcript.golden.json +23 -0
  18. package/dist/fixtures/hf/fixtures.json +69 -0
  19. package/dist/fixtures/hf/pre-fork-private-state-store/.gitattributes +8 -0
  20. package/dist/fixtures/hf/pre-fork-private-state-store/ENVELOPE.md +70 -0
  21. package/dist/fixtures/hf/pre-fork-private-state-store/store/000005.ldb +0 -0
  22. package/dist/fixtures/hf/pre-fork-private-state-store/store/000006.log +0 -0
  23. package/dist/fixtures/hf/pre-fork-private-state-store/store/CURRENT +1 -0
  24. package/dist/fixtures/hf/pre-fork-private-state-store/store/MANIFEST-000004 +0 -0
  25. package/dist/fixtures/hf/private-counter-016/README.md +13 -0
  26. package/dist/fixtures/hf/private-counter-016/compiled/compiler/contract-info.json +40 -0
  27. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.d.ts +40 -0
  28. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.js +211 -0
  29. package/dist/fixtures/hf/private-counter-twin/compiled/compiler/contract-info.json +41 -0
  30. package/dist/fixtures/hf/private-counter-twin/compiled/contract/index.js +271 -0
  31. package/dist/fixtures/hf/private-counter-twin/private-counter.compact +27 -0
  32. package/dist/fixtures/hf/state-both-keys.hex +1 -0
  33. package/dist/fixtures/hf/state-co-v2-only-foreign.hex +1 -0
  34. package/dist/fixtures/hf/state-migrated-v9-merkle.hex +1 -0
  35. package/dist/fixtures/hf/state-migrated-v9.hex +1 -0
  36. package/dist/fixtures/hf/state-tampered-bytes.hex +1 -0
  37. package/dist/fixtures/hf/state-tampered-keyset-v8to9.hex +1 -0
  38. package/dist/fixtures/hf/state-tampered-keyset-v9to8.hex +1 -0
  39. package/dist/fixtures/hf/state-v8-v6-envelope.hex +1 -0
  40. package/dist/fixtures/hf/state-v8.hex +1 -0
  41. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-info.json +31 -0
  42. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-manifest.json +58 -0
  43. package/dist/fixtures/hf/twin-contract/compiled/contract/index.d.ts +40 -0
  44. package/dist/fixtures/hf/twin-contract/compiled/contract/index.js +196 -0
  45. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.prover +0 -0
  46. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.verifier +0 -0
  47. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.bzkir +0 -0
  48. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.zkir +22 -0
  49. package/dist/fixtures/hf/twin-contract/counter.compact +15 -0
  50. package/dist/fixtures-hf.d.ts +70 -0
  51. package/dist/fixtures-hf.js +161 -0
  52. package/dist/fixtures-hf.js.map +1 -0
  53. package/dist/index.d.ts +1067 -0
  54. package/dist/index.js +3459 -0
  55. package/dist/index.js.map +1 -0
  56. package/package.json +82 -3
@@ -0,0 +1,24 @@
1
+ // Minimal SECOND-generation fixture for the era boundary's partition path: the
2
+ // smallest contract that RECEIVES a shielded coin in-contract and then writes
3
+ // it into its own ledger cell.
4
+ //
5
+ // `writeCoin` on a `QualifiedShieldedCoinInfo` cell is the point. Receiving
6
+ // registers the coin's commitment with the runtime, and writing it back needs
7
+ // that commitment's recorded INDEX to qualify the coin — so a transcript from
8
+ // this circuit cannot be partitioned unless the indices the runtime recorded
9
+ // travel with the call. `counter-016` cannot exercise that: it moves no coins.
10
+ //
11
+ // Deliberately not the spike's micro-dao: same receive path, without the
12
+ // witnesses, Merkle tree, minting or voting phases none of this tests.
13
+ pragma language_version >= 0.23;
14
+
15
+ import CompactStandardLibrary;
16
+
17
+ export ledger pot: QualifiedShieldedCoinInfo;
18
+ export ledger pot_has_coin: Boolean;
19
+
20
+ export circuit receive_coin(coin: ShieldedCoinInfo): [] {
21
+ receiveShielded(disclose(coin));
22
+ pot.writeCoin(disclose(coin), right<ZswapCoinPublicKey, ContractAddress>(kernel.self()));
23
+ pot_has_coin = true;
24
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "compiler-version": "0.31.1",
3
+ "language-version": "0.23.0",
4
+ "runtime-version": "0.16.0",
5
+ "circuits": [
6
+ {
7
+ "name": "receive_coin",
8
+ "pure": false,
9
+ "proof": true,
10
+ "arguments": [
11
+ {
12
+ "name": "coin",
13
+ "type": {
14
+ "type-name": "Struct",
15
+ "name": "ShieldedCoinInfo",
16
+ "elements": [
17
+ {
18
+ "name": "nonce",
19
+ "type": {
20
+ "type-name": "Bytes",
21
+ "length": 32
22
+ }
23
+ },
24
+ {
25
+ "name": "color",
26
+ "type": {
27
+ "type-name": "Bytes",
28
+ "length": 32
29
+ }
30
+ },
31
+ {
32
+ "name": "value",
33
+ "type": {
34
+ "type-name": "Uint",
35
+ "maxval": 340282366920938463463374607431768211455
36
+ }
37
+ }
38
+ ]
39
+ }
40
+ }
41
+ ],
42
+ "result-type": {
43
+ "type-name": "Tuple",
44
+ "types": [
45
+ ]
46
+ }
47
+ }
48
+ ],
49
+ "witnesses": [
50
+ ],
51
+ "contracts": [
52
+ ],
53
+ "ledger": [
54
+ {
55
+ "name": "pot",
56
+ "index": 0,
57
+ "exported": true,
58
+ "storage": "Cell",
59
+ "type": {
60
+ "type-name": "Struct",
61
+ "name": "QualifiedShieldedCoinInfo",
62
+ "elements": [
63
+ {
64
+ "name": "nonce",
65
+ "type": {
66
+ "type-name": "Bytes",
67
+ "length": 32
68
+ }
69
+ },
70
+ {
71
+ "name": "color",
72
+ "type": {
73
+ "type-name": "Bytes",
74
+ "length": 32
75
+ }
76
+ },
77
+ {
78
+ "name": "value",
79
+ "type": {
80
+ "type-name": "Uint",
81
+ "maxval": 340282366920938463463374607431768211455
82
+ }
83
+ },
84
+ {
85
+ "name": "mt_index",
86
+ "type": {
87
+ "type-name": "Uint",
88
+ "maxval": 18446744073709551615
89
+ }
90
+ }
91
+ ]
92
+ }
93
+ },
94
+ {
95
+ "name": "pot_has_coin",
96
+ "index": 1,
97
+ "exported": true,
98
+ "storage": "Cell",
99
+ "type": {
100
+ "type-name": "Boolean"
101
+ }
102
+ }
103
+ ]
104
+ }
@@ -0,0 +1,47 @@
1
+ import type * as __compactRuntime from 'compact-runtime-ledger8';
2
+
3
+ export type Witnesses<PS> = {
4
+ }
5
+
6
+ export type ImpureCircuits<PS> = {
7
+ receive_coin(context: __compactRuntime.CircuitContext<PS>,
8
+ coin_0: { nonce: Uint8Array, color: Uint8Array, value: bigint }): __compactRuntime.CircuitResults<PS, []>;
9
+ }
10
+
11
+ export type ProvableCircuits<PS> = {
12
+ receive_coin(context: __compactRuntime.CircuitContext<PS>,
13
+ coin_0: { nonce: Uint8Array, color: Uint8Array, value: bigint }): __compactRuntime.CircuitResults<PS, []>;
14
+ }
15
+
16
+ export type PureCircuits = {
17
+ }
18
+
19
+ export type Circuits<PS> = {
20
+ receive_coin(context: __compactRuntime.CircuitContext<PS>,
21
+ coin_0: { nonce: Uint8Array, color: Uint8Array, value: bigint }): __compactRuntime.CircuitResults<PS, []>;
22
+ }
23
+
24
+ export type Ledger = {
25
+ readonly pot: { nonce: Uint8Array,
26
+ color: Uint8Array,
27
+ value: bigint,
28
+ mt_index: bigint
29
+ };
30
+ readonly pot_has_coin: boolean;
31
+ }
32
+
33
+ export type ContractReferenceLocations = any;
34
+
35
+ export declare const contractReferenceLocations : ContractReferenceLocations;
36
+
37
+ export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
38
+ witnesses: W;
39
+ circuits: Circuits<PS>;
40
+ impureCircuits: ImpureCircuits<PS>;
41
+ provableCircuits: ProvableCircuits<PS>;
42
+ constructor(witnesses: W);
43
+ initialState(context: __compactRuntime.ConstructorContext<PS>): __compactRuntime.ConstructorResult<PS>;
44
+ }
45
+
46
+ export declare function ledger(state: __compactRuntime.StateValue | __compactRuntime.ChargedState): Ledger;
47
+ export declare const pureCircuits: PureCircuits;
@@ -0,0 +1,412 @@
1
+ import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
2
+ __compactRuntime.checkRuntimeVersion('0.16.0');
3
+
4
+ const _descriptor_0 = new __compactRuntime.CompactTypeBytes(32);
5
+
6
+ const _descriptor_1 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
7
+
8
+ class _ShieldedCoinInfo_0 {
9
+ alignment() {
10
+ return _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_1.alignment()));
11
+ }
12
+ fromValue(value_0) {
13
+ return {
14
+ nonce: _descriptor_0.fromValue(value_0),
15
+ color: _descriptor_0.fromValue(value_0),
16
+ value: _descriptor_1.fromValue(value_0)
17
+ }
18
+ }
19
+ toValue(value_0) {
20
+ return _descriptor_0.toValue(value_0.nonce).concat(_descriptor_0.toValue(value_0.color).concat(_descriptor_1.toValue(value_0.value)));
21
+ }
22
+ }
23
+
24
+ const _descriptor_2 = new _ShieldedCoinInfo_0();
25
+
26
+ const _descriptor_3 = __compactRuntime.CompactTypeBoolean;
27
+
28
+ class _ZswapCoinPublicKey_0 {
29
+ alignment() {
30
+ return _descriptor_0.alignment();
31
+ }
32
+ fromValue(value_0) {
33
+ return {
34
+ bytes: _descriptor_0.fromValue(value_0)
35
+ }
36
+ }
37
+ toValue(value_0) {
38
+ return _descriptor_0.toValue(value_0.bytes);
39
+ }
40
+ }
41
+
42
+ const _descriptor_4 = new _ZswapCoinPublicKey_0();
43
+
44
+ class _ContractAddress_0 {
45
+ alignment() {
46
+ return _descriptor_0.alignment();
47
+ }
48
+ fromValue(value_0) {
49
+ return {
50
+ bytes: _descriptor_0.fromValue(value_0)
51
+ }
52
+ }
53
+ toValue(value_0) {
54
+ return _descriptor_0.toValue(value_0.bytes);
55
+ }
56
+ }
57
+
58
+ const _descriptor_5 = new _ContractAddress_0();
59
+
60
+ class _Either_0 {
61
+ alignment() {
62
+ return _descriptor_3.alignment().concat(_descriptor_4.alignment().concat(_descriptor_5.alignment()));
63
+ }
64
+ fromValue(value_0) {
65
+ return {
66
+ is_left: _descriptor_3.fromValue(value_0),
67
+ left: _descriptor_4.fromValue(value_0),
68
+ right: _descriptor_5.fromValue(value_0)
69
+ }
70
+ }
71
+ toValue(value_0) {
72
+ return _descriptor_3.toValue(value_0.is_left).concat(_descriptor_4.toValue(value_0.left).concat(_descriptor_5.toValue(value_0.right)));
73
+ }
74
+ }
75
+
76
+ const _descriptor_6 = new _Either_0();
77
+
78
+ const _descriptor_7 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
79
+
80
+ class _QualifiedShieldedCoinInfo_0 {
81
+ alignment() {
82
+ return _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_1.alignment().concat(_descriptor_7.alignment())));
83
+ }
84
+ fromValue(value_0) {
85
+ return {
86
+ nonce: _descriptor_0.fromValue(value_0),
87
+ color: _descriptor_0.fromValue(value_0),
88
+ value: _descriptor_1.fromValue(value_0),
89
+ mt_index: _descriptor_7.fromValue(value_0)
90
+ }
91
+ }
92
+ toValue(value_0) {
93
+ return _descriptor_0.toValue(value_0.nonce).concat(_descriptor_0.toValue(value_0.color).concat(_descriptor_1.toValue(value_0.value).concat(_descriptor_7.toValue(value_0.mt_index))));
94
+ }
95
+ }
96
+
97
+ const _descriptor_8 = new _QualifiedShieldedCoinInfo_0();
98
+
99
+ const _descriptor_9 = new __compactRuntime.CompactTypeBytes(21);
100
+
101
+ class _CoinPreimage_0 {
102
+ alignment() {
103
+ return _descriptor_9.alignment().concat(_descriptor_2.alignment().concat(_descriptor_3.alignment().concat(_descriptor_0.alignment())));
104
+ }
105
+ fromValue(value_0) {
106
+ return {
107
+ domain_sep: _descriptor_9.fromValue(value_0),
108
+ info: _descriptor_2.fromValue(value_0),
109
+ dataType: _descriptor_3.fromValue(value_0),
110
+ data: _descriptor_0.fromValue(value_0)
111
+ }
112
+ }
113
+ toValue(value_0) {
114
+ return _descriptor_9.toValue(value_0.domain_sep).concat(_descriptor_2.toValue(value_0.info).concat(_descriptor_3.toValue(value_0.dataType).concat(_descriptor_0.toValue(value_0.data))));
115
+ }
116
+ }
117
+
118
+ const _descriptor_10 = new _CoinPreimage_0();
119
+
120
+ class _Either_1 {
121
+ alignment() {
122
+ return _descriptor_3.alignment().concat(_descriptor_0.alignment().concat(_descriptor_0.alignment()));
123
+ }
124
+ fromValue(value_0) {
125
+ return {
126
+ is_left: _descriptor_3.fromValue(value_0),
127
+ left: _descriptor_0.fromValue(value_0),
128
+ right: _descriptor_0.fromValue(value_0)
129
+ }
130
+ }
131
+ toValue(value_0) {
132
+ return _descriptor_3.toValue(value_0.is_left).concat(_descriptor_0.toValue(value_0.left).concat(_descriptor_0.toValue(value_0.right)));
133
+ }
134
+ }
135
+
136
+ const _descriptor_11 = new _Either_1();
137
+
138
+ const _descriptor_12 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
139
+
140
+ export class Contract {
141
+ witnesses;
142
+ constructor(...args_0) {
143
+ if (args_0.length !== 1) {
144
+ throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
145
+ }
146
+ const witnesses_0 = args_0[0];
147
+ if (typeof(witnesses_0) !== 'object') {
148
+ throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
149
+ }
150
+ this.witnesses = witnesses_0;
151
+ this.circuits = {
152
+ receive_coin: (...args_1) => {
153
+ if (args_1.length !== 2) {
154
+ throw new __compactRuntime.CompactError(`receive_coin: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`);
155
+ }
156
+ const contextOrig_0 = args_1[0];
157
+ const coin_0 = args_1[1];
158
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
159
+ __compactRuntime.typeError('receive_coin',
160
+ 'argument 1 (as invoked from Typescript)',
161
+ 'coin-receiver.compact line 20 char 1',
162
+ 'CircuitContext',
163
+ contextOrig_0)
164
+ }
165
+ if (!(typeof(coin_0) === 'object' && coin_0.nonce.buffer instanceof ArrayBuffer && coin_0.nonce.BYTES_PER_ELEMENT === 1 && coin_0.nonce.length === 32 && coin_0.color.buffer instanceof ArrayBuffer && coin_0.color.BYTES_PER_ELEMENT === 1 && coin_0.color.length === 32 && typeof(coin_0.value) === 'bigint' && coin_0.value >= 0n && coin_0.value <= 340282366920938463463374607431768211455n)) {
166
+ __compactRuntime.typeError('receive_coin',
167
+ 'argument 1 (argument 2 as invoked from Typescript)',
168
+ 'coin-receiver.compact line 20 char 1',
169
+ 'struct ShieldedCoinInfo<nonce: Bytes<32>, color: Bytes<32>, value: Uint<0..340282366920938463463374607431768211456>>',
170
+ coin_0)
171
+ }
172
+ const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
173
+ const partialProofData = {
174
+ input: {
175
+ value: _descriptor_2.toValue(coin_0),
176
+ alignment: _descriptor_2.alignment()
177
+ },
178
+ output: undefined,
179
+ publicTranscript: [],
180
+ privateTranscriptOutputs: []
181
+ };
182
+ const result_0 = this._receive_coin_0(context, partialProofData, coin_0);
183
+ partialProofData.output = { value: [], alignment: [] };
184
+ return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
185
+ }
186
+ };
187
+ this.impureCircuits = { receive_coin: this.circuits.receive_coin };
188
+ this.provableCircuits = { receive_coin: this.circuits.receive_coin };
189
+ }
190
+ initialState(...args_0) {
191
+ if (args_0.length !== 1) {
192
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
193
+ }
194
+ const constructorContext_0 = args_0[0];
195
+ if (typeof(constructorContext_0) !== 'object') {
196
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
197
+ }
198
+ if (!('initialZswapLocalState' in constructorContext_0)) {
199
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
200
+ }
201
+ if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
202
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
203
+ }
204
+ const state_0 = new __compactRuntime.ContractState();
205
+ let stateValue_0 = __compactRuntime.StateValue.newArray();
206
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
207
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
208
+ state_0.data = new __compactRuntime.ChargedState(stateValue_0);
209
+ state_0.setOperation('receive_coin', new __compactRuntime.ContractOperation());
210
+ const context = __compactRuntime.createCircuitContext(__compactRuntime.dummyContractAddress(), constructorContext_0.initialZswapLocalState.coinPublicKey, state_0.data, constructorContext_0.initialPrivateState);
211
+ const partialProofData = {
212
+ input: { value: [], alignment: [] },
213
+ output: undefined,
214
+ publicTranscript: [],
215
+ privateTranscriptOutputs: []
216
+ };
217
+ __compactRuntime.queryLedgerState(context,
218
+ partialProofData,
219
+ [
220
+ { push: { storage: false,
221
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_12.toValue(0n),
222
+ alignment: _descriptor_12.alignment() }).encode() } },
223
+ { push: { storage: true,
224
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_8.toValue({ nonce: new Uint8Array(32), color: new Uint8Array(32), value: 0n, mt_index: 0n }),
225
+ alignment: _descriptor_8.alignment() }).encode() } },
226
+ { ins: { cached: false, n: 1 } }]);
227
+ __compactRuntime.queryLedgerState(context,
228
+ partialProofData,
229
+ [
230
+ { push: { storage: false,
231
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_12.toValue(1n),
232
+ alignment: _descriptor_12.alignment() }).encode() } },
233
+ { push: { storage: true,
234
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_3.toValue(false),
235
+ alignment: _descriptor_3.alignment() }).encode() } },
236
+ { ins: { cached: false, n: 1 } }]);
237
+ state_0.data = new __compactRuntime.ChargedState(context.currentQueryContext.state.state);
238
+ return {
239
+ currentContractState: state_0,
240
+ currentPrivateState: context.currentPrivateState,
241
+ currentZswapLocalState: context.currentZswapLocalState
242
+ }
243
+ }
244
+ _right_0(value_0) {
245
+ return { is_left: false, left: { bytes: new Uint8Array(32) }, right: value_0 };
246
+ }
247
+ _receiveShielded_0(context, partialProofData, coin_0) {
248
+ const recipient_0 = this._right_0(_descriptor_5.fromValue(__compactRuntime.queryLedgerState(context,
249
+ partialProofData,
250
+ [
251
+ { dup: { n: 2 } },
252
+ { idx: { cached: true,
253
+ pushPath: false,
254
+ path: [
255
+ { tag: 'value',
256
+ value: { value: _descriptor_12.toValue(0n),
257
+ alignment: _descriptor_12.alignment() } }] } },
258
+ { popeq: { cached: true,
259
+ result: undefined } }]).value));
260
+ this._createZswapOutput_0(context, partialProofData, coin_0, recipient_0);
261
+ const tmp_0 = this._coinCommitment_0(coin_0, recipient_0);
262
+ __compactRuntime.queryLedgerState(context,
263
+ partialProofData,
264
+ [
265
+ { swap: { n: 0 } },
266
+ { idx: { cached: true,
267
+ pushPath: true,
268
+ path: [
269
+ { tag: 'value',
270
+ value: { value: _descriptor_12.toValue(1n),
271
+ alignment: _descriptor_12.alignment() } }] } },
272
+ { push: { storage: false,
273
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(tmp_0),
274
+ alignment: _descriptor_0.alignment() }).encode() } },
275
+ { push: { storage: false,
276
+ value: __compactRuntime.StateValue.newNull().encode() } },
277
+ { ins: { cached: true, n: 2 } },
278
+ { swap: { n: 0 } }]);
279
+ return [];
280
+ }
281
+ _coinCommitment_0(coin_0, recipient_0) {
282
+ return this._persistentHash_0({ domain_sep:
283
+ new Uint8Array([109, 105, 100, 110, 105, 103, 104, 116, 58, 122, 115, 119, 97, 112, 45, 99, 99, 91, 118, 49, 93]),
284
+ info: coin_0,
285
+ dataType: recipient_0.is_left,
286
+ data:
287
+ recipient_0.is_left ?
288
+ recipient_0.left.bytes :
289
+ recipient_0.right.bytes });
290
+ }
291
+ _persistentHash_0(value_0) {
292
+ const result_0 = __compactRuntime.persistentHash(_descriptor_10, value_0);
293
+ return result_0;
294
+ }
295
+ _createZswapOutput_0(context, partialProofData, coin_0, recipient_0) {
296
+ const result_0 = __compactRuntime.createZswapOutput(context,
297
+ coin_0,
298
+ recipient_0);
299
+ partialProofData.privateTranscriptOutputs.push({
300
+ value: [],
301
+ alignment: []
302
+ });
303
+ return result_0;
304
+ }
305
+ _receive_coin_0(context, partialProofData, coin_0) {
306
+ this._receiveShielded_0(context, partialProofData, coin_0);
307
+ const tmp_0 = this._right_0(_descriptor_5.fromValue(__compactRuntime.queryLedgerState(context,
308
+ partialProofData,
309
+ [
310
+ { dup: { n: 2 } },
311
+ { idx: { cached: true,
312
+ pushPath: false,
313
+ path: [
314
+ { tag: 'value',
315
+ value: { value: _descriptor_12.toValue(0n),
316
+ alignment: _descriptor_12.alignment() } }] } },
317
+ { popeq: { cached: true,
318
+ result: undefined } }]).value));
319
+ __compactRuntime.hasCoinCommitment(context, coin_0, tmp_0) ? __compactRuntime.queryLedgerState(context,
320
+ partialProofData,
321
+ [
322
+ { push: { storage: false,
323
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_12.toValue(0n),
324
+ alignment: _descriptor_12.alignment() }).encode() } },
325
+ { dup: { n: 3 } },
326
+ { push: { storage: false,
327
+ value: __compactRuntime.StateValue.newCell(__compactRuntime.runtimeCoinCommitment(
328
+ { value: _descriptor_2.toValue(coin_0),
329
+ alignment: _descriptor_2.alignment() },
330
+ { value: _descriptor_6.toValue(tmp_0),
331
+ alignment: _descriptor_6.alignment() }
332
+ )).encode() } },
333
+ { idx: { cached: true,
334
+ pushPath: false,
335
+ path: [
336
+ { tag: 'value',
337
+ value: { value: _descriptor_12.toValue(1n),
338
+ alignment: _descriptor_12.alignment() } },
339
+ { tag: 'stack' }] } },
340
+ { push: { storage: false,
341
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(coin_0),
342
+ alignment: _descriptor_2.alignment() }).encode() } },
343
+ { swap: { n: 0 } },
344
+ { concat: { cached: true,
345
+ n: 91 } },
346
+ { ins: { cached: false,
347
+ n: 1 } }]) : (() => { throw new __compactRuntime.CompactError(`coin-receiver.compact line 22 char 3: Coin commitment not found. Check the coin has been received (or call 'createZswapOutput')`); })();
348
+ __compactRuntime.queryLedgerState(context,
349
+ partialProofData,
350
+ [
351
+ { push: { storage: false,
352
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_12.toValue(1n),
353
+ alignment: _descriptor_12.alignment() }).encode() } },
354
+ { push: { storage: true,
355
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_3.toValue(true),
356
+ alignment: _descriptor_3.alignment() }).encode() } },
357
+ { ins: { cached: false, n: 1 } }]);
358
+ return [];
359
+ }
360
+ }
361
+ export function ledger(stateOrChargedState) {
362
+ const state = stateOrChargedState instanceof __compactRuntime.StateValue ? stateOrChargedState : stateOrChargedState.state;
363
+ const chargedState = stateOrChargedState instanceof __compactRuntime.StateValue ? new __compactRuntime.ChargedState(stateOrChargedState) : stateOrChargedState;
364
+ const context = {
365
+ currentQueryContext: new __compactRuntime.QueryContext(chargedState, __compactRuntime.dummyContractAddress()),
366
+ costModel: __compactRuntime.CostModel.initialCostModel()
367
+ };
368
+ const partialProofData = {
369
+ input: { value: [], alignment: [] },
370
+ output: undefined,
371
+ publicTranscript: [],
372
+ privateTranscriptOutputs: []
373
+ };
374
+ return {
375
+ get pot() {
376
+ return _descriptor_8.fromValue(__compactRuntime.queryLedgerState(context,
377
+ partialProofData,
378
+ [
379
+ { dup: { n: 0 } },
380
+ { idx: { cached: false,
381
+ pushPath: false,
382
+ path: [
383
+ { tag: 'value',
384
+ value: { value: _descriptor_12.toValue(0n),
385
+ alignment: _descriptor_12.alignment() } }] } },
386
+ { popeq: { cached: false,
387
+ result: undefined } }]).value);
388
+ },
389
+ get pot_has_coin() {
390
+ return _descriptor_3.fromValue(__compactRuntime.queryLedgerState(context,
391
+ partialProofData,
392
+ [
393
+ { dup: { n: 0 } },
394
+ { idx: { cached: false,
395
+ pushPath: false,
396
+ path: [
397
+ { tag: 'value',
398
+ value: { value: _descriptor_12.toValue(1n),
399
+ alignment: _descriptor_12.alignment() } }] } },
400
+ { popeq: { cached: false,
401
+ result: undefined } }]).value);
402
+ }
403
+ };
404
+ }
405
+ const _emptyContext = {
406
+ currentQueryContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress())
407
+ };
408
+ const _dummyContract = new Contract({ });
409
+ export const pureCircuits = {};
410
+ export const contractReferenceLocations =
411
+ { tag: 'publicLedgerArray', indices: { } };
412
+ //# sourceMappingURL=index.js.map