@midnightntwrk/midnight-js-protocol 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 (61) hide show
  1. package/README.md +291 -2
  2. package/dist/compact-js-v8-effect.d.ts +1 -0
  3. package/dist/compact-js-v8-effect.js +2 -0
  4. package/dist/compact-js-v8-effect.js.map +1 -0
  5. package/dist/engine.d.ts +420 -0
  6. package/dist/engine.js +832 -0
  7. package/dist/engine.js.map +1 -0
  8. package/dist/errors.d.ts +601 -0
  9. package/dist/errors.js +810 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +1471 -0
  12. package/dist/index.js +799 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/platform-effect-configuration.d.ts +1 -0
  15. package/dist/platform-effect-configuration.js +2 -0
  16. package/dist/platform-effect-configuration.js.map +1 -0
  17. package/dist/platform-effect-contract-address.d.ts +1 -0
  18. package/dist/platform-effect-contract-address.js +2 -0
  19. package/dist/platform-effect-contract-address.js.map +1 -0
  20. package/dist/platform.d.ts +1 -0
  21. package/dist/platform.js +2 -0
  22. package/dist/platform.js.map +1 -0
  23. package/dist/prove.d.ts +45 -0
  24. package/dist/prove.js +61 -0
  25. package/dist/prove.js.map +1 -0
  26. package/dist/shared/compose-options-BFA09u9q.js +468 -0
  27. package/dist/shared/compose-options-BFA09u9q.js.map +1 -0
  28. package/dist/shared/ledger-transaction-DQP8J8tv.js +134 -0
  29. package/dist/shared/ledger-transaction-DQP8J8tv.js.map +1 -0
  30. package/dist/shared/load-BMVWoBo6.js +49 -0
  31. package/dist/shared/load-BMVWoBo6.js.map +1 -0
  32. package/dist/shared/transaction-tags-I3J_Hh8r.js +82 -0
  33. package/dist/shared/transaction-tags-I3J_Hh8r.js.map +1 -0
  34. package/dist/transaction.d.ts +92 -0
  35. package/dist/transaction.js +6 -0
  36. package/dist/transaction.js.map +1 -0
  37. package/dist/v8.d.ts +1 -0
  38. package/dist/v8.js +3 -0
  39. package/dist/v8.js.map +1 -0
  40. package/dist/v9-compact-js-effect-contract.d.ts +1 -0
  41. package/dist/v9-compact-js-effect-contract.js +2 -0
  42. package/dist/v9-compact-js-effect-contract.js.map +1 -0
  43. package/dist/v9-compact-js-effect.d.ts +1 -0
  44. package/dist/v9-compact-js-effect.js +2 -0
  45. package/dist/v9-compact-js-effect.js.map +1 -0
  46. package/dist/v9-compact-js.d.ts +1 -0
  47. package/dist/v9-compact-js.js +2 -0
  48. package/dist/v9-compact-js.js.map +1 -0
  49. package/dist/v9-compact-runtime.d.ts +1 -0
  50. package/dist/v9-compact-runtime.js +2 -0
  51. package/dist/v9-compact-runtime.js.map +1 -0
  52. package/dist/v9-onchain-runtime.d.ts +1 -0
  53. package/dist/v9-onchain-runtime.js +2 -0
  54. package/dist/v9-onchain-runtime.js.map +1 -0
  55. package/dist/v9.d.ts +1 -0
  56. package/dist/v9.js +2 -0
  57. package/dist/v9.js.map +1 -0
  58. package/dist/version.d.ts +173 -0
  59. package/dist/version.js +125 -0
  60. package/dist/version.js.map +1 -0
  61. package/package.json +122 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/lib/shared/unshielded.ts","../src/lib/v8/compose.ts","../src/lib/v8/deploy.ts","../src/lib/v8/adapt.ts","../src/lib/v9/compose.ts","../src/lib/era/envelope.ts","../src/lib/era/load-era.ts","../src/lib/v8/load-engine.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":["readZswapOffer","readContractState","Ledger9ContractState"],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;AAaG;AA2CH;;;;;;;;;;;;;;AAcG;AACI,MAAM,2BAA2B,GAAG,CACzC,UAAgD,EAChD,OAAkB,EAClB,SAAiB,KACD;AAChB,IAAA,IAAI,UAAU,KAAK,SAAS,EAAE;AAC5B,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,OAAO,GAAiB,EAAE;AAChC,IAAA,KAAK,MAAM,CAAC,C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A,KAAK,CAAC,CAAC,KAAc,KAAI;IACxB,aAAa,GAAG,SAAS;AACzB,IAAA,MAAM,KAAK,YAAY,0BAA0B,GAAG,KAAK,GAAG,IAAI,0BAA0B,CAAC,YAAY,EAAE,KAAK,CAAC;AACjH,CAAC,CAAC;;"}
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/platform-js/effect/Configuration';
@@ -0,0 +1,2 @@
1
+ export * from '@midnight-ntwrk/platform-js/effect/Configuration';
2
+ //# sourceMappingURL=platform-effect-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-effect-configuration.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/platform-js/effect/ContractAddress';
@@ -0,0 +1,2 @@
1
+ export * from '@midnight-ntwrk/platform-js/effect/ContractAddress';
2
+ //# sourceMappingURL=platform-effect-contract-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-effect-contract-address.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from '@midnight-ntwrk/platform-js';
@@ -0,0 +1,2 @@
1
+ export * from '@midnight-ntwrk/platform-js';
2
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,45 @@
1
+ import { UnprovenTransaction, Transaction, SignatureEnabled, Proof, PreBinding, FinalizedTransaction, ProvingProvider } from '@midnightntwrk/ledger-v8';
2
+ import { UnprovenTransaction as UnprovenTransaction$1, Transaction as Transaction$1, SignatureEnabled as SignatureEnabled$1, Proof as Proof$1, PreBinding as PreBinding$1, FinalizedTransaction as FinalizedTransaction$1 } from '@midnightntwrk/ledger-v9';
3
+
4
+ /** The ledger transaction class of each era at each {@link TransactionStage}. */
5
+ interface LedgerTransactionTypes {
6
+ v8: {
7
+ Unproven: UnprovenTransaction;
8
+ Unbound: Transaction<SignatureEnabled, Proof, PreBinding>;
9
+ Finalized: FinalizedTransaction;
10
+ };
11
+ v9: {
12
+ Unproven: UnprovenTransaction$1;
13
+ Unbound: Transaction$1<SignatureEnabled$1, Proof$1, PreBinding$1>;
14
+ Finalized: FinalizedTransaction$1;
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Proves a retained-era transaction.
20
+ *
21
+ * The cost model comes from the same `loadLedger8Protocol` result as the
22
+ * transaction class, and that pairing is load-bearing: the retained ledger
23
+ * ships its own `CostModel` and its `prove()` checks the argument against that
24
+ * class across the WASM boundary, so the current era's cost model is rejected
25
+ * with `expected instance of CostModel`.
26
+ *
27
+ * @param tx The unproven transaction, an object of the v8 ledger copy this
28
+ * framework loaded (read one with `deserializeTransactionAtStage`).
29
+ * @param provingProvider The circuit-level proving provider to drive, typed as
30
+ * the RETAINED era's `ProvingProvider`: `check` and `prove`, and no
31
+ * `lookupKey`. That is the declared return type of an in-process prover's
32
+ * `asV8ProvingProvider()`, so registering one here needs no cast. The current
33
+ * era's shape is a superset, so a provider serving both eras also satisfies
34
+ * this parameter and needs no adapter.
35
+ * @returns The proven, unbound transaction.
36
+ * @throws Ledger8RuntimeMissingError If the retained runtime cannot be loaded.
37
+ * @throws InvalidArgumentError If `tx` is not an unproven transaction of the
38
+ * v8 ledger copy this framework loaded.
39
+ *
40
+ * @remarks Intended for `ProofProvider` implementations. Application code
41
+ * should call `proveTx` on a provider rather than this directly.
42
+ */
43
+ declare const proveLedger8Transaction: (tx: LedgerTransactionTypes["v8"]["Unproven"], provingProvider: ProvingProvider) => Promise<LedgerTransactionTypes["v8"]["Unbound"]>;
44
+
45
+ export { proveLedger8Transaction };
package/dist/prove.js ADDED
@@ -0,0 +1,61 @@
1
+ import { InvalidArgumentError } from './errors.js';
2
+ import { i as isFrameworkLedgerTransaction, t as transactionStageOf } from './shared/ledger-transaction-DQP8J8tv.js';
3
+ import { l as loadLedger8Protocol } from './shared/load-BMVWoBo6.js';
4
+ import '@midnightntwrk/ledger-v9';
5
+ import './shared/transaction-tags-I3J_Hh8r.js';
6
+
7
+ /*
8
+ * This file is part of midnight-js.
9
+ * Copyright (C) Midnight Foundation
10
+ * SPDX-License-Identifier: Apache-2.0
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * You may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ /**
22
+ * Proves a retained-era transaction.
23
+ *
24
+ * The cost model comes from the same `loadLedger8Protocol` result as the
25
+ * transaction class, and that pairing is load-bearing: the retained ledger
26
+ * ships its own `CostModel` and its `prove()` checks the argument against that
27
+ * class across the WASM boundary, so the current era's cost model is rejected
28
+ * with `expected instance of CostModel`.
29
+ *
30
+ * @param tx The unproven transaction, an object of the v8 ledger copy this
31
+ * framework loaded (read one with `deserializeTransactionAtStage`).
32
+ * @param provingProvider The circuit-level proving provider to drive, typed as
33
+ * the RETAINED era's `ProvingProvider`: `check` and `prove`, and no
34
+ * `lookupKey`. That is the declared return type of an in-process prover's
35
+ * `asV8ProvingProvider()`, so registering one here needs no cast. The current
36
+ * era's shape is a superset, so a provider serving both eras also satisfies
37
+ * this parameter and needs no adapter.
38
+ * @returns The proven, unbound transaction.
39
+ * @throws Ledger8RuntimeMissingError If the retained runtime cannot be loaded.
40
+ * @throws InvalidArgumentError If `tx` is not an unproven transaction of the
41
+ * v8 ledger copy this framework loaded.
42
+ *
43
+ * @remarks Intended for `ProofProvider` implementations. Application code
44
+ * should call `proveTx` on a provider rather than this directly.
45
+ */
46
+ const proveLedger8Transaction = async (tx, provingProvider) => {
47
+ const v8 = await loadLedger8Protocol();
48
+ const check = isFrameworkLedgerTransaction('v8', tx);
49
+ if (check !== 'own') {
50
+ throw new InvalidArgumentError(`proveLedger8Transaction takes a v8 transaction of the ledger copy this framework loaded (${check}). ` +
51
+ `Read one with deserializeTransactionAtStage('v8', 'Unproven', bytes).`);
52
+ }
53
+ const stage = transactionStageOf(tx);
54
+ if (stage !== 'Unproven') {
55
+ throw new InvalidArgumentError(`proveLedger8Transaction takes an Unproven transaction, but the transaction is ${stage ?? 'at no pipeline stage'}.`);
56
+ }
57
+ return tx.prove(provingProvider, v8.CostModel.initialCostModel());
58
+ };
59
+
60
+ export { proveLedger8Transaction };
61
+ //# sourceMappingURL=prove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prove.js","sources":["../src/lib/v8/prove.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;AAaG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACI,MAAM,uBAAuB,GAAG,OACrC,EAA4C,EAC5C,eAAgC,KACoB;AACpD,IAAA,MAAM,EAAE,GAAG,MAAM,mBAAmB,EAAE;IACtC,MAAM,KAAK,GAAG,4BAA4B,CAAC,IAAI,EAAE,EAAE,CAAC;AACpD,IAAA,IAAI,KAAK,KAAK,KAAK,EAAE;AACnB,QAAA,MAAM,IAAI,oBAAoB,CAC5B,CAAA,yFAAA,EAA4F,KAAK,CAAA,GAAA,CAAK;AACpG,YAAA,CAAA,qEAAA,CAAuE,CAC1E;IACH;AACA,IAAA,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,KAAK,KAAK,UAAU,EAAE;QACxB,MAAM,IAAI,oBAAoB,CAC5B,CAAA,8EAAA,EAAiF,KAAK,IAAI,sBAAsB,CAAA,CAAA,CAAG,CACpH;IACH;AACA,IAAA,OAAO,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;AACnE;;"}
@@ -0,0 +1,468 @@
1
+ import { encodeContractKeyLocation, hashVerifierKey } from '@midnight-ntwrk/compact-js';
2
+ import { ComposeFailedError, ComposeOptionError, InvariantViolationError, StateDecodeFailedError, StateInconsistentError } from '../errors.js';
3
+
4
+ /*
5
+ * This file is part of midnight-js.
6
+ * Copyright (C) Midnight Foundation
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * You may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * The sentinel that asks for the ledger's own INITIAL cost model instead of the chain's.
20
+ *
21
+ * Spelled out as a value a caller has to name, because the thing it selects is wrong for any chain
22
+ * that has been running: the initial parameters are the model the chain started with, and prices
23
+ * adjust per block. Partitioning against them draws the guaranteed/fallible boundary in the wrong
24
+ * place and the node then refuses the guaranteed segment with `Transcript(Execution(OutOfGas))` --
25
+ * after the caller has already paid to prove it.
26
+ */
27
+ const INITIAL_LEDGER_PARAMETERS = 'initial';
28
+
29
+ /*
30
+ * This file is part of midnight-js.
31
+ * Copyright (C) Midnight Foundation
32
+ * SPDX-License-Identifier: Apache-2.0
33
+ * Licensed under the Apache License, Version 2.0 (the "License");
34
+ * You may not use this file except in compliance with the License.
35
+ * You may obtain a copy of the License at
36
+ * http://www.apache.org/licenses/LICENSE-2.0
37
+ * Unless required by applicable law or agreed to in writing, software
38
+ * distributed under the License is distributed on an "AS IS" BASIS,
39
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ * See the License for the specific language governing permissions and
41
+ * limitations under the License.
42
+ */
43
+ /**
44
+ * Writes the context a call recorded onto the query context its transcript is
45
+ * about to be partitioned against. Returns the folded context, never the one
46
+ * it started from.
47
+ *
48
+ * @see {@link ComposeRefusalOrder}
49
+ */
50
+ const bridgePartitionContext = (queryContext, partitionContext) => {
51
+ queryContext.block = partitionContext.block;
52
+ queryContext.effects = partitionContext.effects;
53
+ let bridged = queryContext;
54
+ for (const [commitment, index] of partitionContext.comIndices) {
55
+ bridged = bridged.insertCommitment(commitment, index);
56
+ }
57
+ return bridged;
58
+ };
59
+ /**
60
+ * Resolves a call's guaranteed/fallible transcript pair: a partitioned source
61
+ * is passed through untouched, an unpartitioned one is bridged into the
62
+ * module's own `QueryContext` ({@link bridgePartitionContext}) and split there.
63
+ *
64
+ * @see {@link ComposeRefusalOrder}
65
+ */
66
+ const resolvePartition = (ledger, options) => {
67
+ const { transcript, contractAddress, circuitId, version } = options;
68
+ if (transcript.kind === 'partitioned') {
69
+ // Only the CALLER-supplied pair is checked for emptiness, never the
70
+ // partitioner's own answer below -- see ComposeRefusalOrder.
71
+ if (transcript.guaranteed === undefined && transcript.fallible === undefined) {
72
+ throw new ComposeFailedError(version, 'call-transcript-empty', circuitId);
73
+ }
74
+ return [transcript.guaranteed, transcript.fallible];
75
+ }
76
+ let queryContext;
77
+ try {
78
+ const stateValue = ledger.StateValue.decode(transcript.preState);
79
+ queryContext = new ledger.QueryContext(new ledger.ChargedState(stateValue), contractAddress);
80
+ }
81
+ catch (cause) {
82
+ throw new ComposeFailedError(version, 'call-contract-state', circuitId, cause);
83
+ }
84
+ try {
85
+ queryContext = bridgePartitionContext(queryContext, transcript.partitionContext);
86
+ }
87
+ catch (cause) {
88
+ throw new ComposeFailedError(version, 'call-partition-context', circuitId, cause);
89
+ }
90
+ // The partitioner rejects caller data with a raw error from inside wasm, so
91
+ // it is coded here -- see ComposeRefusalOrder.
92
+ let partitioned;
93
+ // Read BEFORE the partitioner runs and reported separately, because a rejected parameter blob is
94
+ // a bad option and not a failed partition -- reporting it as the latter sends a reader after the
95
+ // transcript when the fault is in the bytes they passed. See ComposeRefusalOrder.
96
+ let parameters;
97
+ try {
98
+ parameters =
99
+ options.ledgerParametersBytes === INITIAL_LEDGER_PARAMETERS
100
+ ? // The ledger's INITIAL parameters: a compatibility path for a caller with no read
101
+ // surface, and not a correct substitute. They are the model the chain started with, not
102
+ // the one it is running -- prices adjust per block -- so partitioning against them draws
103
+ // the guaranteed/fallible boundary in the wrong place and the node refuses the guaranteed
104
+ // segment for running out of gas. Reachable only by naming the sentinel, never by
105
+ // omission -- see LedgerParametersOption.
106
+ ledger.LedgerParameters.initialParameters()
107
+ : // Deserialized with THIS era's reader, which is right because the bytes came from a block
108
+ // this era's call is being built against.
109
+ ledger.LedgerParameters.deserialize(options.ledgerParametersBytes);
110
+ }
111
+ catch (cause) {
112
+ throw new ComposeOptionError(version, 'ledgerParametersBytes', cause);
113
+ }
114
+ try {
115
+ partitioned = ledger.partitionTranscripts([new ledger.PreTranscript(queryContext, transcript.publicTranscript)], parameters);
116
+ }
117
+ catch (cause) {
118
+ throw new ComposeFailedError(version, 'call-partition', circuitId, cause);
119
+ }
120
+ const first = partitioned[0];
121
+ if (first === undefined) {
122
+ throw new InvariantViolationError('partitionTranscripts returned no result for the call transcript.');
123
+ }
124
+ return first;
125
+ };
126
+ /**
127
+ * Assembles one call prototype against the given ledger module — the sequence
128
+ * every composition leg shares: resolve the circuit's registered operation,
129
+ * resolve the call's guaranteed/fallible transcript pair (see
130
+ * {@link resolvePartition}), and construct the module's
131
+ * `ContractCallPrototype`.
132
+ *
133
+ * @typeParam TQueryContext The module's own `QueryContext`. Every other type
134
+ * parameter is inferred from the module namespace, so callers pass the module
135
+ * and never spell out type arguments.
136
+ * @typeParam TOperation The resolved operation, constrained to
137
+ * {@link VerifiableOperation}.
138
+ * @param ledger The ledger module (ledger-v8 or ledger-v9) to assemble
139
+ * against.
140
+ * @param options The call's own inputs, the operation registry to resolve
141
+ * `circuitId` against, and the era to name in a failure.
142
+ * @returns The module's own `ContractCallPrototype` for this call, and the
143
+ * guaranteed/fallible pair it was built from.
144
+ * @throws ComposeFailedError naming `version` and `circuitId`, at
145
+ * `options.stage` when `operations` has no registered operation for
146
+ * `circuitId`; at `'call-verifier-key'` when the resolved operation carries no
147
+ * verifier key; at `'call-transcript-empty'`, `'call-contract-state'`,
148
+ * `'call-partition-context'` or `'call-partition'` from resolving the
149
+ * transcript pair; at `'call-prototype'` when the module rejects the call's
150
+ * own inputs.
151
+ * @throws InvariantViolationError when the module's own partitioner returns no
152
+ * result — its invariant, not a caller fault.
153
+ * @see {@link ComposeRefusalOrder}
154
+ */
155
+ const assembleCallPrototype = (ledger, options) => {
156
+ const { circuitId, contractAddress, operations, stage, version } = options;
157
+ const op = operations.operation(circuitId);
158
+ if (op === undefined) {
159
+ throw new ComposeFailedError(version, stage, circuitId);
160
+ }
161
+ if (op.verifierKey === undefined) {
162
+ throw new ComposeFailedError(version, 'call-verifier-key', circuitId);
163
+ }
164
+ const [guaranteed, fallible] = resolvePartition(ledger, options);
165
+ // Wrapped as one step rather than per argument -- see ComposeRefusalOrder.
166
+ let prototype;
167
+ try {
168
+ prototype = new ledger.ContractCallPrototype(contractAddress, circuitId, op, guaranteed, fallible, options.privateTranscriptOutputs, options.input, options.output, options.communicationCommitmentRandomness ?? ledger.communicationCommitmentRandomness(),
169
+ // The canonical, contract-qualified key location this framework's
170
+ // provers resolve artifacts by -- see ComposeRefusalOrder.
171
+ encodeContractKeyLocation({
172
+ contractAddress,
173
+ circuitId,
174
+ verifierKeyHash: hashVerifierKey(op.verifierKey)
175
+ }));
176
+ }
177
+ catch (cause) {
178
+ throw new ComposeFailedError(version, 'call-prototype', circuitId, cause);
179
+ }
180
+ // Copied into a mutable pair rather than handed on: the partitioner answers
181
+ // with a readonly tuple, and the ledger's own `PartitionedTranscript` --
182
+ // which is what every consumer of this pair is typed against -- is not.
183
+ return { prototype, partition: [guaranteed, fallible] };
184
+ };
185
+
186
+ /*
187
+ * This file is part of midnight-js.
188
+ * Copyright (C) Midnight Foundation
189
+ * SPDX-License-Identifier: Apache-2.0
190
+ * Licensed under the Apache License, Version 2.0 (the "License");
191
+ * You may not use this file except in compliance with the License.
192
+ * You may obtain a copy of the License at
193
+ * http://www.apache.org/licenses/LICENSE-2.0
194
+ * Unless required by applicable law or agreed to in writing, software
195
+ * distributed under the License is distributed on an "AS IS" BASIS,
196
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
197
+ * See the License for the specific language governing permissions and
198
+ * limitations under the License.
199
+ */
200
+ /**
201
+ * Resolves a ledger entry-point key to its name.
202
+ *
203
+ * @param id The entry point as the state declares it — already a string, or
204
+ * the bytes a byte-declared entry point carries.
205
+ * @returns `id` itself when it is a string, otherwise its UTF-8 decoding.
206
+ * @see {@link VerifierKeys}
207
+ */
208
+ const entryPointName = (id) => typeof id === 'string' ? id : new TextDecoder().decode(id);
209
+ /**
210
+ * Pairs each supplied verifier key with the entry point the state declares for
211
+ * it, after validating the map against those entry points in BOTH directions:
212
+ * every key must name a declared entry point, and every declared entry point
213
+ * must have a key.
214
+ *
215
+ * @param entryPoints The entry points the state declares, as `operations()`
216
+ * returns them.
217
+ * @param verifierKeys Entry-point name -> raw, tagged verifier key bytes.
218
+ * @param version The era every failure raised here names.
219
+ * @returns One registration per supplied key, in the map's own order, each
220
+ * carrying the DECLARED entry point rather than its resolved name — which is
221
+ * what `setOperation` must be handed.
222
+ * @throws ComposeFailedError at stage `'deploy-ambiguous-circuit'` when two
223
+ * declared entry points resolve to the same name. Checked before either
224
+ * direction below.
225
+ * @throws ComposeFailedError at stage `'deploy-unknown-circuit'` when a key
226
+ * names an entry point the state does not declare.
227
+ * @throws ComposeFailedError at stage `'deploy-verifier-key'` when a declared
228
+ * entry point has no key in the map.
229
+ * @see {@link VerifierKeys}
230
+ */
231
+ const resolveVerifierKeyRegistrations = (entryPoints, verifierKeys, version) => {
232
+ const declared = new Map();
233
+ for (const entryPoint of entryPoints) {
234
+ const circuitId = entryPointName(entryPoint);
235
+ if (declared.has(circuitId)) {
236
+ throw new ComposeFailedError(version, 'deploy-ambiguous-circuit', circuitId);
237
+ }
238
+ declared.set(circuitId, entryPoint);
239
+ }
240
+ const registrations = [];
241
+ for (const [circuitId, verifierKey] of verifierKeys) {
242
+ const entryPoint = declared.get(circuitId);
243
+ if (entryPoint === undefined) {
244
+ throw new ComposeFailedError(version, 'deploy-unknown-circuit', circuitId);
245
+ }
246
+ registrations.push({ entryPoint, circuitId, verifierKey });
247
+ }
248
+ for (const circuitId of declared.keys()) {
249
+ if (!verifierKeys.has(circuitId)) {
250
+ throw new ComposeFailedError(version, 'deploy-verifier-key', circuitId);
251
+ }
252
+ }
253
+ return registrations;
254
+ };
255
+
256
+ /*
257
+ * This file is part of midnight-js.
258
+ * Copyright (C) Midnight Foundation
259
+ * SPDX-License-Identifier: Apache-2.0
260
+ * Licensed under the Apache License, Version 2.0 (the "License");
261
+ * You may not use this file except in compliance with the License.
262
+ * You may obtain a copy of the License at
263
+ * http://www.apache.org/licenses/LICENSE-2.0
264
+ * Unless required by applicable law or agreed to in writing, software
265
+ * distributed under the License is distributed on an "AS IS" BASIS,
266
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
267
+ * See the License for the specific language governing permissions and
268
+ * limitations under the License.
269
+ */
270
+ /**
271
+ * Names what a rejected value WAS, without rendering any of it.
272
+ *
273
+ * `typeof` alone reports `'object'` for `null`, which reads as a map that was
274
+ * there, and that is the one distinction a caller chasing an absent balance
275
+ * needs.
276
+ *
277
+ * @param value The rejected value.
278
+ * @returns `'null'`, or the value's `typeof`.
279
+ */
280
+ const describeValue = (value) => (value === null ? 'null' : typeof value);
281
+ /**
282
+ * Whether a candidate answers the `ReadonlyMap` lookup surface.
283
+ *
284
+ * Iterability is NOT checked here: `everyEntryIsAColouredAmount` iterates, so a
285
+ * non-iterable candidate is refused there. A clause for it as well would be one
286
+ * no test could distinguish -- verified by deleting it.
287
+ */
288
+ const answersTheMapSurface = (candidate) => typeof candidate.get === 'function' && typeof candidate.has === 'function' && typeof candidate.size === 'number';
289
+ /**
290
+ * Whether every entry is a colour keyed against an amount the ledger can do
291
+ * arithmetic with.
292
+ *
293
+ * Refuses a candidate that cannot be iterated at all: `for...of` throws on one,
294
+ * and {@link isContractBalance} turns that into the refusal.
295
+ */
296
+ const everyEntryIsAColouredAmount = (candidate) => {
297
+ for (const entry of candidate) {
298
+ if (!Array.isArray(entry) || entry.length !== 2) {
299
+ return false;
300
+ }
301
+ const [colour, amount] = entry;
302
+ if (typeof amount !== 'bigint' || typeof colour !== 'object' || colour === null) {
303
+ return false;
304
+ }
305
+ if (typeof colour.tag !== 'string') {
306
+ return false;
307
+ }
308
+ }
309
+ return true;
310
+ };
311
+ /**
312
+ * Whether a value can serve as a {@link ContractBalance}.
313
+ *
314
+ * Structural rather than `instanceof Map`, so a map from another realm — a
315
+ * worker, a VM context — is accepted. Every other iterable is refused: `new
316
+ * Map(...)` turns an empty array, an empty `Set` and an empty string alike into
317
+ * an empty map, which is the substitution the balance guards exist to prevent.
318
+ *
319
+ * The entries are checked too, not just the container. A map carrying amounts
320
+ * that are not `bigint`s answers every structural clause and then feeds the
321
+ * circuit arithmetic it cannot do — the same class of silent wrong answer this
322
+ * guard exists to stop — so the `value is ContractBalance` narrowing has to
323
+ * cover them or it overclaims.
324
+ *
325
+ * TOTAL: it answers rather than throws for every input. `Map.prototype`'s
326
+ * members reject a foreign receiver — a proxied map and an object that merely
327
+ * inherits the prototype both make `size` and iteration throw — and neither can
328
+ * serve as a balance, because `new Map(...)` would throw on that same receiver.
329
+ * They belong in the refusal, carrying the caller's diagnosis rather than the
330
+ * vendor's `TypeError`.
331
+ *
332
+ * Not a claim that an empty answer is genuine: a hand-built object declaring an
333
+ * empty iterator is a valid empty balance as far as anything here can tell, and
334
+ * so is a contract holding nothing. That is why the option is required at the
335
+ * entry points rather than defaulted.
336
+ *
337
+ * @param value The candidate, from an injected decoder or an untyped caller.
338
+ * @returns Whether it answers the `ReadonlyMap` surface with usable entries.
339
+ * @see {@link FailClosedDecoding}
340
+ */
341
+ const isContractBalance = (value) => {
342
+ if (typeof value !== 'object' || value === null) {
343
+ return false;
344
+ }
345
+ const candidate = value;
346
+ try {
347
+ return answersTheMapSurface(candidate) && everyEntryIsAColouredAmount(candidate);
348
+ }
349
+ catch {
350
+ return false;
351
+ }
352
+ };
353
+ /**
354
+ * Reads the primary state out of a raw envelope with the given era's extractor,
355
+ * reporting every failure as {@link StateDecodeFailedError} naming `version`.
356
+ *
357
+ * @param raw The serialized contract-state envelope.
358
+ * @param version The era whose extractor is used, and which every failure
359
+ * raised here names.
360
+ * @param extract The era's own envelope extractor.
361
+ * @returns The primary state read out of the envelope.
362
+ * @throws StateDecodeFailedError for every failure, carrying the extractor's
363
+ * own diagnosis on `cause`.
364
+ * @see {@link FailClosedDecoding}
365
+ */
366
+ const extractStateWith = (raw, version, extract) => {
367
+ try {
368
+ return extract(raw);
369
+ }
370
+ catch (cause) {
371
+ throw new StateDecodeFailedError(version, cause);
372
+ }
373
+ };
374
+ /**
375
+ * Reads a raw, serialized contract-state envelope into a
376
+ * {@link ContractStatePojo} using the given era's own `ContractState`.
377
+ *
378
+ * Nothing that crosses back is a live WASM handle: the primary state leaves as
379
+ * an `EncodedStateValue` (plain objects, arrays, `Map`s, `Uint8Array`s and
380
+ * primitives) and each entry point as a plain record.
381
+ *
382
+ * @param raw The serialized contract-state envelope.
383
+ * @param version The era whose decoder is used, and which every failure raised
384
+ * here names.
385
+ * @param ledger The era module slice carrying its own `ContractState`.
386
+ * @returns The state and the entry points it declares, as plain data.
387
+ * @throws StateDecodeFailedError if this era's decoder rejects `raw`.
388
+ * @throws StateInconsistentError if the decoded state is internally
389
+ * inconsistent. Every failure carries its own diagnosis on `cause`.
390
+ * @see {@link FailClosedDecoding}
391
+ * @see {@link EraBoundary}
392
+ */
393
+ const decodeContractStateWith = (raw, version, ledger) => {
394
+ let decoded;
395
+ try {
396
+ decoded = ledger.ContractState.deserialize(raw);
397
+ }
398
+ catch (cause) {
399
+ throw new StateDecodeFailedError(version, cause);
400
+ }
401
+ try {
402
+ const entryPoints = decoded.operations().map((entryPoint) => {
403
+ // Deliberately not optional-chained: an unresolvable entry point is an
404
+ // inconsistent state, not a blank slot -- see FailClosedDecoding.
405
+ const operation = decoded.operation(entryPoint);
406
+ if (operation === undefined) {
407
+ throw new StateInconsistentError(version, new Error(`contract state declares entry point '${entryPointName(entryPoint)}' but resolves no operation for it.`));
408
+ }
409
+ const { verifierKey } = operation;
410
+ return {
411
+ circuitId: entryPointName(entryPoint),
412
+ verifierKey,
413
+ verifierKeyHash: verifierKey === undefined ? undefined : hashVerifierKey(verifierKey)
414
+ };
415
+ });
416
+ // Read ONCE. An injected decoder may answer with a different object on each
417
+ // access, which would have the guard validate one map and the copy take
418
+ // another.
419
+ const balance = decoded.balance;
420
+ // Not defaulted: `new Map(undefined)` is an empty map, indistinguishable
421
+ // from a contract that holds nothing. @see FailClosedDecoding
422
+ if (!isContractBalance(balance)) {
423
+ throw new StateInconsistentError(version, new Error(`contract state resolves no usable balance (received ${describeValue(balance)}); a contract that holds ` +
424
+ 'nothing still declares an empty map.'));
425
+ }
426
+ // Copied, so the pojo owns a map nothing else holds.
427
+ return { state: decoded.data.state.encode(), balance: new Map(balance), entryPoints };
428
+ }
429
+ catch (cause) {
430
+ throw cause instanceof StateInconsistentError ? cause : new StateInconsistentError(version, cause);
431
+ }
432
+ };
433
+
434
+ /*
435
+ * This file is part of midnight-js.
436
+ * Copyright (C) Midnight Foundation
437
+ * SPDX-License-Identifier: Apache-2.0
438
+ * Licensed under the Apache License, Version 2.0 (the "License");
439
+ * You may not use this file except in compliance with the License.
440
+ * You may obtain a copy of the License at
441
+ * http://www.apache.org/licenses/LICENSE-2.0
442
+ * Unless required by applicable law or agreed to in writing, software
443
+ * distributed under the License is distributed on an "AS IS" BASIS,
444
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
445
+ * See the License for the specific language governing permissions and
446
+ * limitations under the License.
447
+ */
448
+ /**
449
+ * Rejects the two envelope options the ledger accepts but should not: an
450
+ * empty `networkId`, and a `ttl` that is not a valid instant.
451
+ *
452
+ * @param options The transaction-envelope options to check.
453
+ * @param version The era every failure raised here names.
454
+ * @throws ComposeOptionError naming option `'networkId'` for an empty network
455
+ * id, or `'ttl'` for a `ttl` that is not a valid instant.
456
+ * @see {@link ComposeRefusalOrder}
457
+ */
458
+ const assertComposeEnvelope = (options, version) => {
459
+ if (options.networkId.length === 0) {
460
+ throw new ComposeOptionError(version, 'networkId');
461
+ }
462
+ if (Number.isNaN(options.ttl.getTime())) {
463
+ throw new ComposeOptionError(version, 'ttl');
464
+ }
465
+ };
466
+
467
+ export { INITIAL_LEDGER_PARAMETERS as I, assembleCallPrototype as a, assertComposeEnvelope as b, decodeContractStateWith as c, describeValue as d, entryPointName as e, extractStateWith as f, isContractBalance as i, resolveVerifierKeyRegistrations as r };
468
+ //# sourceMappingURL=compose-options-BFA09u9q.js.map