@midnight-ntwrk/midnight-js-protocol 5.0.0-beta.7 → 5.0.0-beta.8
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.
- package/README.md +201 -2
- package/dist/engine.d.ts +367 -0
- package/dist/engine.js +519 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +467 -0
- package/dist/errors.js +595 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1278 -2
- package/dist/index.js +787 -2
- package/dist/index.js.map +1 -1
- package/dist/prove.d.ts +38 -0
- package/dist/prove.js +81 -0
- package/dist/prove.js.map +1 -0
- package/dist/shared/deploy-D6yyn9P7.js +428 -0
- package/dist/shared/deploy-D6yyn9P7.js.map +1 -0
- package/dist/shared/load-C0TZnEd2.js +39 -0
- package/dist/shared/load-C0TZnEd2.js.map +1 -0
- package/dist/v8.d.ts +1 -0
- package/dist/v8.js +3 -0
- package/dist/v8.js.map +1 -0
- package/dist/version.d.ts +121 -0
- package/dist/version.js +132 -0
- package/dist/version.js.map +1 -0
- package/package.json +28 -4
package/dist/errors.js
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-js.
|
|
3
|
+
* Copyright (C) Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Stable error-code strings for this package. Every error class in this module
|
|
17
|
+
* carries one of these on its `code` field, which is the field a consumer
|
|
18
|
+
* switches on to tell one failure from another.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link SharedTableDiscipline}
|
|
21
|
+
*/
|
|
22
|
+
const PROTOCOL_ERROR_CODES = Object.freeze({
|
|
23
|
+
UNKNOWN_PROTOCOL_VERSION_READ: 'MIDNIGHT_JS_P_UNKNOWN_PROTOCOL_VERSION_READ',
|
|
24
|
+
UNKNOWN_PROTOCOL_VERSION_CONSTRUCT: 'MIDNIGHT_JS_P_UNKNOWN_PROTOCOL_VERSION_CONSTRUCT',
|
|
25
|
+
LEDGER8_INSTANCE_MISMATCH: 'MIDNIGHT_JS_P_LEDGER8_INSTANCE_MISMATCH',
|
|
26
|
+
LEDGER8_RUNTIME_MISSING: 'MIDNIGHT_JS_P_LEDGER8_RUNTIME_MISSING',
|
|
27
|
+
DOWN_CONVERT_FAILED: 'MIDNIGHT_JS_P_DOWN_CONVERT_FAILED',
|
|
28
|
+
MERKLE_NOT_REHASHED: 'MIDNIGHT_JS_P_MERKLE_NOT_REHASHED',
|
|
29
|
+
COMPOSE_FAILED: 'MIDNIGHT_JS_P_COMPOSE_FAILED',
|
|
30
|
+
COMPOSE_OPTION_INVALID: 'MIDNIGHT_JS_P_COMPOSE_OPTION_INVALID',
|
|
31
|
+
STATE_DECODE_FAILED: 'MIDNIGHT_JS_P_STATE_DECODE_FAILED',
|
|
32
|
+
UNKNOWN_LEDGER_VERSION: 'MIDNIGHT_JS_P_UNKNOWN_LEDGER_VERSION',
|
|
33
|
+
LEDGER8_RUNTIME_INVALID: 'MIDNIGHT_JS_P_LEDGER8_RUNTIME_INVALID',
|
|
34
|
+
UNKNOWN_LEDGER8_AXIS: 'MIDNIGHT_JS_P_UNKNOWN_LEDGER8_AXIS',
|
|
35
|
+
PAYLOAD_NOT_A_TRANSACTION: 'MIDNIGHT_JS_P_PAYLOAD_NOT_A_TRANSACTION'
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Thrown by `protocolVersionToLedger` (and, transitively, `versionOfRecord` /
|
|
39
|
+
* `networkHeadVersion`) when a raw `protocolVersion` integer cannot be
|
|
40
|
+
* resolved to a `LedgerVersion`. Those live in `./version`, which imports this
|
|
41
|
+
* module -- the dependency stays one-way, so they are named here rather than
|
|
42
|
+
* linked.
|
|
43
|
+
*
|
|
44
|
+
* `code` is the field to switch on to tell all four cases apart: it splits
|
|
45
|
+
* `reason` by the `path` that produced it.
|
|
46
|
+
*
|
|
47
|
+
* @param protocolVersion The raw `protocolVersion` value that could not be
|
|
48
|
+
* resolved. Carried for programmatic use, and rendered in the message.
|
|
49
|
+
* @param path Which call path asked for the version — see
|
|
50
|
+
* {@link VersionResolutionPath}.
|
|
51
|
+
* @param reason A malformed input (wrong shape or type, not a
|
|
52
|
+
* protocol-version problem at all) or a well-formed but genuinely unknown
|
|
53
|
+
* version (a real protocol version this framework build does not support
|
|
54
|
+
* yet) — see {@link ProtocolVersionUnknownReason}.
|
|
55
|
+
*/
|
|
56
|
+
class UnknownProtocolVersionError extends Error {
|
|
57
|
+
protocolVersion;
|
|
58
|
+
path;
|
|
59
|
+
reason;
|
|
60
|
+
code;
|
|
61
|
+
constructor(protocolVersion, path, reason) {
|
|
62
|
+
super(reason === 'malformed'
|
|
63
|
+
? `Malformed protocolVersion (expected a non-negative integer, got ${typeof protocolVersion} ` +
|
|
64
|
+
`${String(protocolVersion)}) on the ${path} path. This usually means a non-numeric, fractional, or ` +
|
|
65
|
+
`negative value reached protocolVersionToLedger — check that the source field is actually a raw ` +
|
|
66
|
+
`protocolVersion integer (e.g. from an indexer transaction/block record or ` +
|
|
67
|
+
`queryLatestProtocolVersion()), not a derived or miscoded value.`
|
|
68
|
+
: `Unknown protocolVersion ${protocolVersion} on the ${path} path. ` +
|
|
69
|
+
`Supported eras: v8 (node 1.x) and v9 (node 2.x). ` +
|
|
70
|
+
`An unknown node major usually means this framework major predates a newer fork — upgrade midnight-js.`);
|
|
71
|
+
this.protocolVersion = protocolVersion;
|
|
72
|
+
this.path = path;
|
|
73
|
+
this.reason = reason;
|
|
74
|
+
this.name = 'UnknownProtocolVersionError';
|
|
75
|
+
this.code =
|
|
76
|
+
path === 'read'
|
|
77
|
+
? PROTOCOL_ERROR_CODES.UNKNOWN_PROTOCOL_VERSION_READ
|
|
78
|
+
: PROTOCOL_ERROR_CODES.UNKNOWN_PROTOCOL_VERSION_CONSTRUCT;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Thrown when a lazily-loaded subpath export carrying the retained pre-fork
|
|
83
|
+
* runtime could not be acquired at all. Raised by `loadLedger8`
|
|
84
|
+
* (`lib/v8/load.ts`) and `loadLedger8Engine` (`lib/v8/load-engine.ts`), and
|
|
85
|
+
* surfaced through `createLedger8Engine` and `loadLedgerEra('v8')`.
|
|
86
|
+
*
|
|
87
|
+
* A failed acquisition is not memoised: the next call retries the import.
|
|
88
|
+
* Distinct from {@link Ledger8RuntimeInvalidError}, which reports a runtime
|
|
89
|
+
* that WAS acquired and then handed over incomplete.
|
|
90
|
+
*
|
|
91
|
+
* @param subpath Which chunk failed to load — see {@link RetainedEraSubpath}.
|
|
92
|
+
* @param cause The underlying module-resolution or initialisation failure,
|
|
93
|
+
* preserved unchanged. Read it for which module actually failed.
|
|
94
|
+
* @see {@link ModuleGraphAndLazyLoading}
|
|
95
|
+
* @see {@link EraSeam}
|
|
96
|
+
*/
|
|
97
|
+
class Ledger8RuntimeMissingError extends Error {
|
|
98
|
+
subpath;
|
|
99
|
+
code = PROTOCOL_ERROR_CODES.LEDGER8_RUNTIME_MISSING;
|
|
100
|
+
constructor(subpath, cause) {
|
|
101
|
+
super(`Failed to load the retained pre-fork runtime via the midnight-js-protocol${subpath} subpath export. ` +
|
|
102
|
+
'Read the wrapped cause for which module actually failed to resolve or initialise. This usually means ' +
|
|
103
|
+
'a broken or partial install of the protocol package — reinstall dependencies and retry.', { cause });
|
|
104
|
+
this.subpath = subpath;
|
|
105
|
+
this.name = 'Ledger8RuntimeMissingError';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The npm scopes this package and its retained pre-fork runtimes are published
|
|
110
|
+
* under, while the scope migration runs.
|
|
111
|
+
*
|
|
112
|
+
* Do not join a scope to the `/` in one literal -- the dual-publish rewrite
|
|
113
|
+
* would collapse both names into one. See DualInstantiationGuard.
|
|
114
|
+
*/
|
|
115
|
+
const PUBLISHED_SCOPES = Object.freeze(['@midnight-ntwrk', '@midnightntwrk']);
|
|
116
|
+
/**
|
|
117
|
+
* The unscoped npm name of each axis; `axisPackageNames` joins every published
|
|
118
|
+
* scope onto it. See DualInstantiationGuard.
|
|
119
|
+
*/
|
|
120
|
+
const AXIS_BARE_PACKAGE_NAMES = Object.freeze(Object.assign(Object.create(null), {
|
|
121
|
+
'onchain-runtime-v3': 'onchain-runtime-v3'
|
|
122
|
+
}));
|
|
123
|
+
const axisPackageNames = (axis) => PUBLISHED_SCOPES.map((scope) => `${scope}/${AXIS_BARE_PACKAGE_NAMES[axis]}`);
|
|
124
|
+
/**
|
|
125
|
+
* Thrown by `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`)
|
|
126
|
+
* when the same-named WASM package resolved to two physically distinct copies
|
|
127
|
+
* in this process (a dual-instantiation).
|
|
128
|
+
*
|
|
129
|
+
* Carries no `cause`: this is a direct reference-equality assertion failure,
|
|
130
|
+
* not a wrapped lower-level exception.
|
|
131
|
+
*
|
|
132
|
+
* @param axis Which physical-copy axis the check ran on — see
|
|
133
|
+
* {@link Ledger8InstanceAxis}. It also selects the package names the
|
|
134
|
+
* message tells the reader to trace.
|
|
135
|
+
* @see {@link DualInstantiationGuard}
|
|
136
|
+
*/
|
|
137
|
+
class Ledger8InstanceMismatchError extends Error {
|
|
138
|
+
axis;
|
|
139
|
+
code = PROTOCOL_ERROR_CODES.LEDGER8_INSTANCE_MISMATCH;
|
|
140
|
+
constructor(axis) {
|
|
141
|
+
const packageNames = axisPackageNames(axis).join(' and ');
|
|
142
|
+
super(`Detected two physically distinct copies of ${axis} loaded into the same process (a dual-instantiation). ` +
|
|
143
|
+
"Objects created by one copy are rejected by the other copy's classes. This usually means a duplicate " +
|
|
144
|
+
'install; the package is published under two npm scopes while the scope migration is in progress, and ' +
|
|
145
|
+
'depending on both names is itself a duplicate that no resolver can dedupe. Trace ' +
|
|
146
|
+
`${packageNames} with your package manager's \`why\` command (npm why, yarn why, pnpm why, ` +
|
|
147
|
+
'bun pm why), then align every consumer on a single package name and version.');
|
|
148
|
+
this.axis = axis;
|
|
149
|
+
this.name = 'Ledger8InstanceMismatchError';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Thrown by the down-convert engine (`lib/era/envelope.ts`,
|
|
154
|
+
* `lib/v8/down-convert.ts`) when it cannot turn a raw contract-state
|
|
155
|
+
* envelope, or an already-extracted `EncodedStateValue`, into an executable
|
|
156
|
+
* pre-fork state. Raised by `extractV9EncodedStateValue` (`lib/era/envelope.ts`)
|
|
157
|
+
* and `downConvertForExecution` (`lib/v8/down-convert.ts`).
|
|
158
|
+
*
|
|
159
|
+
* Renders no raw hex and no decoded state contents — only the stage name and
|
|
160
|
+
* the wrapped `cause`.
|
|
161
|
+
*
|
|
162
|
+
* @param stage Which step failed — see {@link DownConvertStage}.
|
|
163
|
+
* @param cause The runtime's own failure, preserved unchanged. It is what
|
|
164
|
+
* distinguishes a tag mismatch from truncated, trailing, or empty input.
|
|
165
|
+
* @see {@link FailClosedDecoding}
|
|
166
|
+
*/
|
|
167
|
+
class DownConvertFailedError extends Error {
|
|
168
|
+
stage;
|
|
169
|
+
code = PROTOCOL_ERROR_CODES.DOWN_CONVERT_FAILED;
|
|
170
|
+
constructor(stage, cause) {
|
|
171
|
+
super(`Failed to down-convert a contract-state for execution during ${stage}. Read the wrapped cause for what ` +
|
|
172
|
+
'the runtime actually reported; it distinguishes a tag mismatch (an envelope tagged for a different ' +
|
|
173
|
+
'ledger version than the one requested) from truncated, trailing, or empty input bytes.', { cause });
|
|
174
|
+
this.stage = stage;
|
|
175
|
+
this.name = 'DownConvertFailedError';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Thrown by `checkRoot` (`lib/v8/down-convert.ts`) when a bounded Merkle
|
|
180
|
+
* tree's root is read before the tree has been rehashed. Reaches a caller
|
|
181
|
+
* through `assertMerkleTreesRehashed` and `downConvertForExecution`, which
|
|
182
|
+
* assert it on every tree they decode.
|
|
183
|
+
*
|
|
184
|
+
* The remediation is always the caller's: call `rehash()` on the tree before
|
|
185
|
+
* executing against it. Nothing here repairs the tree.
|
|
186
|
+
*
|
|
187
|
+
* @param cause The runtime's own failure, when reading the root threw. Absent
|
|
188
|
+
* when `root()` returned nothing instead of throwing.
|
|
189
|
+
* @see {@link FailClosedDecoding}
|
|
190
|
+
* @see {@link RetainedEraExecution}
|
|
191
|
+
*/
|
|
192
|
+
class MerkleNotRehashedError extends Error {
|
|
193
|
+
code = PROTOCOL_ERROR_CODES.MERKLE_NOT_REHASHED;
|
|
194
|
+
constructor(cause) {
|
|
195
|
+
super('Attempted to read the root of a bounded Merkle tree before it was rehashed. This usually means the ' +
|
|
196
|
+
'tree was built or updated in memory and never rehashed — call rehash() on it before executing ' +
|
|
197
|
+
'against it.', { cause });
|
|
198
|
+
this.name = 'MerkleNotRehashedError';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* What `circuitId` a {@link ComposeFailedError} names when the failure happened
|
|
203
|
+
* before any circuit was looked up — only `'call-empty'` reaches this today.
|
|
204
|
+
*
|
|
205
|
+
* Exported, and one literal rather than a per-module copy, so a consumer
|
|
206
|
+
* reading `circuitId` off a caught error can compare against it instead of
|
|
207
|
+
* matching a string this package could change, and so it can never be mistaken
|
|
208
|
+
* for a real entry point a caller might try to resolve.
|
|
209
|
+
*
|
|
210
|
+
* @see {@link ComposeRefusalOrder}
|
|
211
|
+
*/
|
|
212
|
+
const NO_CIRCUIT = '(none)';
|
|
213
|
+
/**
|
|
214
|
+
* Thrown when a transaction cannot be composed because a circuit's operation
|
|
215
|
+
* is missing, under-registered, or names a circuit the contract does not have.
|
|
216
|
+
* `stage` (see {@link ComposeStage}) names which composition step failed and is
|
|
217
|
+
* a closed union, so a consumer can `switch` on it exhaustively; `version`
|
|
218
|
+
* names the ledger era the composition was running against.
|
|
219
|
+
*
|
|
220
|
+
* Most stages are direct assertion failures (a missing lookup, not a wrapped
|
|
221
|
+
* lower-level exception) and carry no `cause`, like
|
|
222
|
+
* {@link Ledger8InstanceMismatchError}. The exceptions are the stages where
|
|
223
|
+
* the ledger itself rejected caller-supplied bytes — enumerated under `cause`
|
|
224
|
+
* below: that failure is preserved on `cause`, the same way
|
|
225
|
+
* {@link DownConvertFailedError} preserves its runtime's own message.
|
|
226
|
+
*
|
|
227
|
+
* `circuitId` names the entry point, never its raw contents: this class
|
|
228
|
+
* renders no hex and no byte-array dump. `'call-empty'` is the one stage with
|
|
229
|
+
* no circuit to name, and its message names none.
|
|
230
|
+
*
|
|
231
|
+
* @param version The ledger era the composition was running against.
|
|
232
|
+
* @param stage Which composition step failed — see {@link ComposeStage}. A
|
|
233
|
+
* closed union, so a consumer can `switch` on it exhaustively.
|
|
234
|
+
* @param circuitId The entry-point name, already decoded. {@link NO_CIRCUIT}
|
|
235
|
+
* for `'call-empty'`, the one stage raised before any circuit is looked up.
|
|
236
|
+
* @param cause The runtime's own failure, present only for the stages where
|
|
237
|
+
* the ledger itself rejected caller-supplied bytes: `'call-contract-state'`,
|
|
238
|
+
* `'call-partition-context'`, `'call-partition'`, `'call-prototype'` and
|
|
239
|
+
* `'deploy-verifier-key-blob'`.
|
|
240
|
+
* @see {@link ComposeRefusalOrder}
|
|
241
|
+
* @see {@link VerifierKeys}
|
|
242
|
+
*/
|
|
243
|
+
class ComposeFailedError extends Error {
|
|
244
|
+
version;
|
|
245
|
+
stage;
|
|
246
|
+
circuitId;
|
|
247
|
+
code = PROTOCOL_ERROR_CODES.COMPOSE_FAILED;
|
|
248
|
+
constructor(version, stage, circuitId, cause) {
|
|
249
|
+
super(ComposeFailedError.MESSAGES[stage](version, circuitId), { cause });
|
|
250
|
+
this.version = version;
|
|
251
|
+
this.stage = stage;
|
|
252
|
+
this.circuitId = circuitId;
|
|
253
|
+
this.name = 'ComposeFailedError';
|
|
254
|
+
}
|
|
255
|
+
// A total Record, and every entry takes the era rather than naming one --
|
|
256
|
+
// see SharedTableDiscipline. Keep both properties when adding a stage.
|
|
257
|
+
static MESSAGES = {
|
|
258
|
+
'wrap-call': (version, circuitId) => `Failed to compose a ${version}-native keep-state call: no registered operation found for circuit ` +
|
|
259
|
+
`'${circuitId}' on the given contract state. This usually means the contract state passed to ` +
|
|
260
|
+
'wrapKeepStateCall was not read from chain (or produced by a real deploy) — a bare/blank contract ' +
|
|
261
|
+
'state has no operations registered. Resolve the contract state that carries the deployed operation ' +
|
|
262
|
+
'for this circuit and pass that instead.',
|
|
263
|
+
'call-empty': (version) => `Refusing to compose a ${version} call transaction with no calls in it. An empty intent is accepted by ` +
|
|
264
|
+
'the ledger and serializes into a transaction that changes nothing, so the omission would only surface ' +
|
|
265
|
+
'as a call that appeared to succeed and had no effect. Pass at least one call.',
|
|
266
|
+
'call-operation': (version, circuitId) => `Failed to compose a ${version} call transaction: no registered operation found for circuit ` +
|
|
267
|
+
`'${circuitId}' on the given ${version}-native contract state. This usually means the contract state ` +
|
|
268
|
+
'passed to composeCallTx was not read from chain (or produced by a real deploy) — a bare/blank ' +
|
|
269
|
+
'contract state has no operations registered. Resolve the contract state that carries the deployed ' +
|
|
270
|
+
'operation for this circuit and pass that instead.',
|
|
271
|
+
'call-contract-state': (version, circuitId) => `Failed to compose a ${version} call transaction: the pre-call state carried by the transcript for ` +
|
|
272
|
+
`circuit '${circuitId}' could not be bridged into the ${version} ledger era. Read the wrapped cause ` +
|
|
273
|
+
'for what the decoder reported; it distinguishes a state encoded by a different runtime from ' +
|
|
274
|
+
'truncated or empty input. Pass the state the era it targets produced.',
|
|
275
|
+
'call-transcript-empty': (version, circuitId) => `Failed to compose a ${version} call: the transcript supplied for circuit '${circuitId}' carries neither ` +
|
|
276
|
+
'a guaranteed nor a fallible half, so the call would record no operations at all. A transaction built ' +
|
|
277
|
+
'from it serializes, proves and submits, and changes nothing — the same silent no-op an empty call list ' +
|
|
278
|
+
'would produce. Pass the partitioned pair the execution leg produced, at least one half of which is ' +
|
|
279
|
+
'always present for a circuit that ran.',
|
|
280
|
+
'call-dust-payout': (version, circuitId) => `Failed to compose a ${version} call: the transcript for circuit '${circuitId}' claims an unshielded ` +
|
|
281
|
+
'spend to a user address in DUST, which has no raw token type to be paid out in. The transaction ' +
|
|
282
|
+
'cannot carry that payout, and composing it anyway would tell the user they were paid while the ' +
|
|
283
|
+
'transaction paid them nothing. Settle dust through its own mechanism rather than as a claimed ' +
|
|
284
|
+
'unshielded spend.',
|
|
285
|
+
'call-unsupported-payout': (version, circuitId) => `Failed to compose a ${version} call: the transcript for circuit '${circuitId}' claims an unshielded ` +
|
|
286
|
+
'spend to a user address in a token type that cannot be paid out as an unshielded UTXO — a shielded ' +
|
|
287
|
+
'token type today. Shielded value moves through a Zswap offer, not through a claimed unshielded ' +
|
|
288
|
+
'spend, so nothing can settle this claim; composing it anyway would tell the user they were paid ' +
|
|
289
|
+
'while the transaction paid them nothing. Move the shielded value through the guaranteed or fallible ' +
|
|
290
|
+
'Zswap offer instead.',
|
|
291
|
+
'call-partition-context': (version, circuitId) => `Failed to compose a ${version} call: the ${version} era rejected the query-context state recorded ` +
|
|
292
|
+
`for circuit '${circuitId}' — its block, its starting effects, or one of the commitment indices it ` +
|
|
293
|
+
'registered for a coin received in-contract. Read the wrapped cause for the member the runtime could ' +
|
|
294
|
+
'not read. Pass the context the execution leg recorded on the transcript, unmodified.',
|
|
295
|
+
'call-partition': (version, circuitId) => `Failed to compose a ${version} call: the ${version} ledger rejected the public transcript supplied ` +
|
|
296
|
+
`for circuit '${circuitId}' while splitting it into its guaranteed and fallible halves. Read the ` +
|
|
297
|
+
'wrapped cause for what the runtime reported; it names the operation and the operand it could not ' +
|
|
298
|
+
'read. Two causes are common: a hand-built or re-encoded op sequence rather than one an execution ' +
|
|
299
|
+
'leg produced, or a call that received a coin in-contract whose recorded commitment indices never ' +
|
|
300
|
+
'reached the partitioner — a transcript that reads a received coin cannot be split without them.',
|
|
301
|
+
'call-prototype': (version, circuitId) => `Failed to compose a ${version} call: the ${version} ledger rejected the inputs supplied for circuit ` +
|
|
302
|
+
`'${circuitId}' while constructing the call prototype. Read the wrapped cause for what the runtime ` +
|
|
303
|
+
'reported; it distinguishes an out-of-range numeric field from a malformed address or aligned value. ' +
|
|
304
|
+
'Every part of a call is plain data that nothing type-checks into range, so this usually means a ' +
|
|
305
|
+
'hand-built transcript pair, private transcript output, or input/output value.',
|
|
306
|
+
'call-verifier-key': (version, circuitId) => `Failed to compose a ${version} call: the operation registered for circuit '${circuitId}' carries no ` +
|
|
307
|
+
'verifier key, so no ledger could verify a call against it. This usually means the contract state came ' +
|
|
308
|
+
'from a constructor result rather than from chain — a freshly built state declares its entry points ' +
|
|
309
|
+
'with blank keys, which only a deploy transaction fills in. Pass the contract state as read from chain ' +
|
|
310
|
+
'after a successful deploy.',
|
|
311
|
+
'deploy-verifier-key': (version, circuitId) => `Failed to compose a ${version} deploy transaction: no verifier key was supplied for circuit ` +
|
|
312
|
+
`'${circuitId}', which the contract state declares as an entry point. A deploy carrying an ` +
|
|
313
|
+
"unregistered entry point is rejected by a ledger's own well-formedness check. Resolve the compiled " +
|
|
314
|
+
"contract's verifier key for this circuit (from its keys/ artifacts) and include it in the map passed " +
|
|
315
|
+
'to composeDeployTx.',
|
|
316
|
+
'deploy-unknown-circuit': (version, circuitId) => `Failed to compose a ${version} deploy transaction: the verifier-key map names circuit '${circuitId}', ` +
|
|
317
|
+
'which the contract state does not declare as an entry point. Registering it would give the deployed ' +
|
|
318
|
+
"contract an entry point its compiled source never had, and would change the deployed contract's " +
|
|
319
|
+
'address. This usually means a stale or foreign key file was picked up (for example by globbing ' +
|
|
320
|
+
'keys/*.verifier across compiler runs) — supply keys for exactly the circuits this contract declares.',
|
|
321
|
+
'deploy-ambiguous-circuit': (version, circuitId) => `Failed to compose a ${version} deploy transaction: the contract state declares two entry points that ` +
|
|
322
|
+
`both resolve to the name '${circuitId}', so a verifier-key map keyed by name cannot tell them apart. ` +
|
|
323
|
+
'Registering under that name would key one slot and leave the other blank, deploying a contract whose ' +
|
|
324
|
+
"address does not match the caller's artifacts. This is not something a compactc-built contract " +
|
|
325
|
+
'produces — it means the contract state was assembled by hand, or by a tool that set an entry point to ' +
|
|
326
|
+
'bytes that are not valid UTF-8.',
|
|
327
|
+
'deploy-verifier-key-blob': (version, circuitId) => `Failed to compose a ${version} deploy transaction: the ledger rejected the verifier-key bytes supplied ` +
|
|
328
|
+
`for circuit '${circuitId}'. Read the wrapped cause for what the ledger reported; a verifier key must ` +
|
|
329
|
+
'be the tagged blob the compiler emits as keys/<circuit>.verifier, so this usually means a truncated ' +
|
|
330
|
+
'or empty file, or a key emitted for a different ledger era.'
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Thrown by the composition legs when one of their options cannot be used at
|
|
335
|
+
* all, as opposed to {@link ComposeFailedError}, which reports a circuit whose
|
|
336
|
+
* operation is missing or under-registered.
|
|
337
|
+
*
|
|
338
|
+
* These are the well-formedness checks the ledger itself does not make.
|
|
339
|
+
*
|
|
340
|
+
* Like {@link DownConvertFailedError}, this class renders no input contents of
|
|
341
|
+
* its own.
|
|
342
|
+
*
|
|
343
|
+
* @param version The ledger era the option was being used against.
|
|
344
|
+
* @param option Which option was unusable — see {@link ComposeOption}. A
|
|
345
|
+
* closed union, so a consumer can `switch` on it exhaustively.
|
|
346
|
+
* @param cause The decoder's own failure, present only for `'contractState'`
|
|
347
|
+
* and `'zswapOffer'`, where caller-supplied bytes were rejected.
|
|
348
|
+
* @see {@link ComposeRefusalOrder}
|
|
349
|
+
* @see {@link VerifierKeys}
|
|
350
|
+
*/
|
|
351
|
+
class ComposeOptionError extends Error {
|
|
352
|
+
version;
|
|
353
|
+
option;
|
|
354
|
+
code = PROTOCOL_ERROR_CODES.COMPOSE_OPTION_INVALID;
|
|
355
|
+
constructor(version, option, cause) {
|
|
356
|
+
super(ComposeOptionError.MESSAGES[option](version), { cause });
|
|
357
|
+
this.version = version;
|
|
358
|
+
this.option = option;
|
|
359
|
+
this.name = 'ComposeOptionError';
|
|
360
|
+
}
|
|
361
|
+
// A total Record, for exactly the reason `ComposeFailedError.MESSAGES` above
|
|
362
|
+
// is one -- see SharedTableDiscipline. Never make this an if-chain.
|
|
363
|
+
static MESSAGES = {
|
|
364
|
+
contractState: (version) => `Failed to compose a ${version} transaction: the given contract state could not be bridged into the ` +
|
|
365
|
+
`${version} ledger era. Read the wrapped cause for what the decoder reported; it distinguishes an ` +
|
|
366
|
+
'envelope tagged for a different ledger era from truncated or empty input bytes. Pass the contract ' +
|
|
367
|
+
'state the era it targets produced, not an already down-converted or otherwise re-tagged one.',
|
|
368
|
+
ledgerParameters: (version) => `Failed to compose a ${version} transaction: the supplied ledger parameters could not be read by the ` +
|
|
369
|
+
`${version} ledger. They are era-tagged, so bytes read from a block of the other era will be refused ` +
|
|
370
|
+
'here — read the wrapped cause for the tag the decoder found. Pass the parameters the block this call ' +
|
|
371
|
+
'is built against served, which is what `RawContractState.ledgerParameters` carries.',
|
|
372
|
+
networkId: () => 'Refusing to compose a transaction against an empty network id. The ledger would accept it and bake ' +
|
|
373
|
+
'it into the transaction, which the network then rejects at submission. Resolve the network id for ' +
|
|
374
|
+
'the target environment and pass it explicitly.',
|
|
375
|
+
ttl: () => 'Refusing to compose a transaction with an invalid time-to-live. An unparseable Date is recorded by ' +
|
|
376
|
+
'the ledger as the Unix epoch, producing a transaction that has already expired. Pass a valid future ' +
|
|
377
|
+
'instant as `ttl`.',
|
|
378
|
+
calls: (version) => `Refusing to compose a ${version} call transaction from this call list: the era can compose exactly ` +
|
|
379
|
+
'one call, and composing only the first would silently drop the rest. A cross-contract call is a ' +
|
|
380
|
+
'ledger-9-only feature a pre-fork contract cannot emit, so this era has no call tree to express — ' +
|
|
381
|
+
'compose each call as its own transaction, or target the era that carries call trees.',
|
|
382
|
+
verifierKeys: (version) => `Refusing to compose a ${version} deploy transaction with no verifier-key map. This era's deploy leg ` +
|
|
383
|
+
"registers the compiled contract's keys onto the initial state itself, and a constructor-built state " +
|
|
384
|
+
'declares every entry point with a blank key — without the map the deploy would carry unregistered ' +
|
|
385
|
+
"entry points and be refused by the ledger's own well-formedness check. Supply keys for exactly the " +
|
|
386
|
+
'circuits the contract declares. An era whose deploy leg accepts the omission still refuses it for a ' +
|
|
387
|
+
'state that declares a blank-keyed entry point, for the same reason.',
|
|
388
|
+
zswapOffer: (version) => `Failed to compose a ${version} transaction: the supplied Zswap offer bytes could not be read by ` +
|
|
389
|
+
`the ${version} ledger. Read the wrapped cause for what the decoder reported. Pass the bytes that ` +
|
|
390
|
+
"era's own offer serialization produced."
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Thrown when a raw, serialized contract-state envelope could not be read by
|
|
395
|
+
* the ledger era it was requested for. Raised by both of the facade's read
|
|
396
|
+
* paths, `extractState` and `decodeContractState`
|
|
397
|
+
* (`lib/shared/contract-state.ts`), so a caller writes one handler for both.
|
|
398
|
+
*
|
|
399
|
+
* Renders no hex and no byte dump of its own.
|
|
400
|
+
*
|
|
401
|
+
* @param version The era whose decoder rejected the envelope.
|
|
402
|
+
* @param cause The decoder's own diagnosis, preserved unchanged. It is what
|
|
403
|
+
* distinguishes a tag mismatch from truncated, trailing or empty input.
|
|
404
|
+
* @see {@link FailClosedDecoding}
|
|
405
|
+
*/
|
|
406
|
+
class StateDecodeFailedError extends Error {
|
|
407
|
+
version;
|
|
408
|
+
code = PROTOCOL_ERROR_CODES.STATE_DECODE_FAILED;
|
|
409
|
+
constructor(version, cause) {
|
|
410
|
+
super(`Failed to decode a contract state for the ${version} ledger era. Read the wrapped cause for what the ` +
|
|
411
|
+
'decoder reported; it distinguishes an envelope tagged for a different ledger era from truncated, ' +
|
|
412
|
+
'trailing, or empty input bytes. Resolve the era the state was written by — protocolVersionToLedger ' +
|
|
413
|
+
'maps a raw protocolVersion integer onto it — and decode it as that era.', { cause });
|
|
414
|
+
this.version = version;
|
|
415
|
+
this.name = 'StateDecodeFailedError';
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Thrown by `extractEncodedStateValue` (`lib/era/envelope.ts`) when the
|
|
420
|
+
* injected pre-fork runtime cannot be used — it was not passed at all, or the
|
|
421
|
+
* binding the decoder needs is absent from it. Also raised by
|
|
422
|
+
* `downConvertForExecution` (`lib/v8/down-convert.ts`) and
|
|
423
|
+
* `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`), the latter for a
|
|
424
|
+
* nullish instance probe.
|
|
425
|
+
*
|
|
426
|
+
* Nothing is wrong with the caller's input here. Distinct from
|
|
427
|
+
* {@link Ledger8RuntimeMissingError}, which reports the v8 chunk failing to
|
|
428
|
+
* load at all, and from {@link DownConvertFailedError}, which reports an
|
|
429
|
+
* envelope or state that could not be turned into an executable pre-fork
|
|
430
|
+
* state.
|
|
431
|
+
*
|
|
432
|
+
* @param missingMember Which binding was absent. One of this module's own
|
|
433
|
+
* literals, never caller-supplied text, so it is safe to log.
|
|
434
|
+
* @see {@link FailClosedDecoding}
|
|
435
|
+
* @see {@link DualInstantiationGuard}
|
|
436
|
+
*/
|
|
437
|
+
class Ledger8RuntimeInvalidError extends Error {
|
|
438
|
+
missingMember;
|
|
439
|
+
code = PROTOCOL_ERROR_CODES.LEDGER8_RUNTIME_INVALID;
|
|
440
|
+
constructor(missingMember) {
|
|
441
|
+
super('The ledger-8 runtime handed to the down-convert engine cannot be used: the binding it needs is missing. ' +
|
|
442
|
+
'Pass the classes of the onchain-runtime-v3 copy your application already loaded, all of them from that ' +
|
|
443
|
+
'one copy, rather than assembling the runtime object by hand. This package exposes no accessor for it — ' +
|
|
444
|
+
'loadLedger8() resolves the v8 ledger, a different package whose own same-named classes run on a ' +
|
|
445
|
+
'separate WASM instance. Read `missingMember` on this error for the absent member.');
|
|
446
|
+
this.missingMember = missingMember;
|
|
447
|
+
this.name = 'Ledger8RuntimeInvalidError';
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Thrown by `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`)
|
|
452
|
+
* when the `axis` it was handed is not a member of {@link Ledger8InstanceAxis}.
|
|
453
|
+
*
|
|
454
|
+
* A TypeScript caller cannot produce this — `axis` is typed as
|
|
455
|
+
* {@link Ledger8InstanceAxis}. It exists for the untyped JavaScript consumers
|
|
456
|
+
* this package also serves.
|
|
457
|
+
*
|
|
458
|
+
* @param requestedAxis The offending value that was passed. Carried for
|
|
459
|
+
* programmatic use only; it is deliberately kept out of the message.
|
|
460
|
+
* @see {@link DualInstantiationGuard}
|
|
461
|
+
*/
|
|
462
|
+
class UnknownLedger8AxisError extends Error {
|
|
463
|
+
requestedAxis;
|
|
464
|
+
code = PROTOCOL_ERROR_CODES.UNKNOWN_LEDGER8_AXIS;
|
|
465
|
+
constructor(requestedAxis) {
|
|
466
|
+
super('Unknown ledger-8 instance axis requested for the shared-instance guard. The only axis this framework ' +
|
|
467
|
+
'version checks is onchain-runtime-v3; read `requestedAxis` on this error for the value that was passed.');
|
|
468
|
+
this.requestedAxis = requestedAxis;
|
|
469
|
+
this.name = 'UnknownLedger8AxisError';
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Thrown when a ledger era was requested by a value that is not a member of
|
|
474
|
+
* `LEDGER_VERSIONS`. Raised by `loadLedgerEra` (`lib/era/load-era.ts`) and by
|
|
475
|
+
* `extractEncodedStateValue` (`lib/era/envelope.ts`).
|
|
476
|
+
*
|
|
477
|
+
* A TypeScript caller cannot produce this: `version` is typed as
|
|
478
|
+
* `LedgerVersion`. It exists for the untyped JavaScript consumers this package
|
|
479
|
+
* also serves.
|
|
480
|
+
*
|
|
481
|
+
* Carries no `version` field, unlike every other era-aware error here — there
|
|
482
|
+
* is no valid era to name.
|
|
483
|
+
*
|
|
484
|
+
* @param requestedVersion The offending value that was passed. Carried for
|
|
485
|
+
* programmatic use only; it is deliberately kept out of the message.
|
|
486
|
+
* @see {@link SharedTableDiscipline}
|
|
487
|
+
* @see {@link FailClosedDecoding}
|
|
488
|
+
*/
|
|
489
|
+
class UnknownLedgerVersionError extends Error {
|
|
490
|
+
requestedVersion;
|
|
491
|
+
code = PROTOCOL_ERROR_CODES.UNKNOWN_LEDGER_VERSION;
|
|
492
|
+
constructor(requestedVersion) {
|
|
493
|
+
super('Unknown ledger version requested. Supported eras are v8 (node 1.x) and ' +
|
|
494
|
+
'v9 (node 2.x); read `requestedVersion` on this error for the value that was passed. Derive it with ' +
|
|
495
|
+
'protocolVersionToLedger rather than constructing the string by hand.');
|
|
496
|
+
this.requestedVersion = requestedVersion;
|
|
497
|
+
this.name = 'UnknownLedgerVersionError';
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* The opening of the tag every serialized ledger transaction carries, on both
|
|
502
|
+
* eras.
|
|
503
|
+
*
|
|
504
|
+
* Stops before the bracketed version deliberately: a `[vN]` is the wire-schema
|
|
505
|
+
* version of the serialized OBJECT and never a ledger era — the retained era's
|
|
506
|
+
* transactions are tagged `transaction[v9]`.
|
|
507
|
+
*
|
|
508
|
+
* @see packages/contracts/docs/verification-path.md for the same rule stated
|
|
509
|
+
* about verifier-key tags.
|
|
510
|
+
*/
|
|
511
|
+
const TRANSACTION_TAG_PREFIX = 'midnight:transaction[';
|
|
512
|
+
/**
|
|
513
|
+
* The bounds on a constructor name reported by {@link describeType}. It is
|
|
514
|
+
* CALLER DATA — `{ constructor: { name: ... } }` sets it to anything at all —
|
|
515
|
+
* so it is bounded in length and restricted to an identifier alphabet before
|
|
516
|
+
* it can reach an error message and from there a logger provider.
|
|
517
|
+
*/
|
|
518
|
+
const MAX_TYPE_NAME_LENGTH = 32;
|
|
519
|
+
const TYPE_NAME_PATTERN = /^[A-Za-z0-9_$]+$/;
|
|
520
|
+
/**
|
|
521
|
+
* Reads a value's constructor name, or `undefined` where it cannot be read.
|
|
522
|
+
*
|
|
523
|
+
* The read is a property access on caller data, so it can throw: an object may
|
|
524
|
+
* define `constructor` as an accessor that throws, or be an exotic object whose
|
|
525
|
+
* trap does. No operation is being attempted here — only a label chosen for a
|
|
526
|
+
* payload that has ALREADY been refused — so letting the throw propagate would
|
|
527
|
+
* replace the coded refusal with the caller's own error.
|
|
528
|
+
*/
|
|
529
|
+
const readConstructorName = (value) => {
|
|
530
|
+
try {
|
|
531
|
+
return value.constructor?.name;
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
return undefined;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* Names the kind of a value without reproducing any of it verbatim.
|
|
539
|
+
*
|
|
540
|
+
* Validated AFTER truncation, and that order is the point: what is checked has
|
|
541
|
+
* to be exactly what is emitted.
|
|
542
|
+
*/
|
|
543
|
+
const describeType = (value) => {
|
|
544
|
+
if (value === null) {
|
|
545
|
+
return 'null';
|
|
546
|
+
}
|
|
547
|
+
if (typeof value !== 'object') {
|
|
548
|
+
return typeof value;
|
|
549
|
+
}
|
|
550
|
+
const constructorName = readConstructorName(value);
|
|
551
|
+
if (typeof constructorName !== 'string') {
|
|
552
|
+
return 'object';
|
|
553
|
+
}
|
|
554
|
+
const bounded = constructorName.slice(0, MAX_TYPE_NAME_LENGTH);
|
|
555
|
+
return TYPE_NAME_PATTERN.test(bounded) ? bounded : 'object';
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Thrown when a payload handed to a proving seam is not a serialized
|
|
559
|
+
* transaction at all.
|
|
560
|
+
*
|
|
561
|
+
* Distinct from a decode failure inside the ledger runtime: this is raised
|
|
562
|
+
* before any runtime is asked to read the bytes, so it says the caller sent the
|
|
563
|
+
* wrong KIND of payload rather than a damaged one. It covers three ways that
|
|
564
|
+
* can happen — a `txBytes` field that is not a byte string, a byte string
|
|
565
|
+
* shorter than the tag prefix, and one that does not open with the prefix.
|
|
566
|
+
*
|
|
567
|
+
* @remarks Raised by `proveV8Transaction`, so it reaches application code as a
|
|
568
|
+
* `proveTx` rejection. Match it with `hasErrorCode` against
|
|
569
|
+
* `PROTOCOL_ERROR_CODES.PAYLOAD_NOT_A_TRANSACTION` rather than constructing it.
|
|
570
|
+
*/
|
|
571
|
+
class PayloadNotATransactionError extends Error {
|
|
572
|
+
code = PROTOCOL_ERROR_CODES.PAYLOAD_NOT_A_TRANSACTION;
|
|
573
|
+
constructor(detail) {
|
|
574
|
+
super(`${detail} Pass the bytes produced by a sanctioned composition seam; a contract state, a ` +
|
|
575
|
+
'Zswap offer or a proof preimage is not a transaction and cannot be proved.');
|
|
576
|
+
this.name = 'PayloadNotATransactionError';
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* The `txBytes` field of a `v8` payload was not a `Uint8Array`. Reachable
|
|
580
|
+
* from JavaScript, from a consumer built against a pre-5.0.0
|
|
581
|
+
* `midnight-js-types`, or across an untyped boundary — so it is refused with
|
|
582
|
+
* a code rather than left to become a bare `TypeError`.
|
|
583
|
+
*/
|
|
584
|
+
static notBytes(received) {
|
|
585
|
+
return new PayloadNotATransactionError(`Refusing to prove a v8 payload whose 'txBytes' is ${describeType(received)} rather than a Uint8Array.`);
|
|
586
|
+
}
|
|
587
|
+
/** The payload is a byte string, but does not open with a transaction's tag. */
|
|
588
|
+
static wrongTag(byteLength) {
|
|
589
|
+
return new PayloadNotATransactionError(`Refusing to prove a ${byteLength}-byte payload that does not begin with the ` +
|
|
590
|
+
`'${TRANSACTION_TAG_PREFIX}' tag of a serialized ledger transaction.`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export { ComposeFailedError, ComposeOptionError, DownConvertFailedError, Ledger8InstanceMismatchError, Ledger8RuntimeInvalidError, Ledger8RuntimeMissingError, MerkleNotRehashedError, NO_CIRCUIT, PROTOCOL_ERROR_CODES, PayloadNotATransactionError, StateDecodeFailedError, TRANSACTION_TAG_PREFIX, UnknownLedger8AxisError, UnknownLedgerVersionError, UnknownProtocolVersionError };
|
|
595
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AAIH;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;AAChD,IAAA,6BAA6B,EAAE,6CAA6C;AAC5E,IAAA,kCAAkC,EAAE,kDAAkD;AACtF,IAAA,yBAAyB,EAAE,yCAAyC;AACpE,IAAA,uBAAuB,EAAE,uCAAuC;AAChE,IAAA,mBAAmB,EAAE,mCAAmC;AACxD,IAAA,mBAAmB,EAAE,mCAAmC;AACxD,IAAA,cAAc,EAAE,8BAA8B;AAC9C,IAAA,sBAAsB,EAAE,sCAAsC;AAC9D,IAAA,mBAAmB,EAAE,mCAAmC;AACxD,IAAA,sBAAsB,EAAE,sCAAsC;AAC9D,IAAA,uBAAuB,EAAE,uCAAuC;AAChE,IAAA,oBAAoB,EAAE,oCAAoC;AAC1D,IAAA,yBAAyB,EAAE;AACnB,CAAA;AAqBV;;;;;;;;;;;;;;;;;;AAkBG;AACG,MAAO,2BAA4B,SAAQ,KAAK,CAAA;AAMzC,IAAA,eAAA;AACA,IAAA,IAAA;AACA,IAAA,MAAA;AAPF,IAAA,IAAI;AAIb,IAAA,WAAA,CACW,eAAuB,EACvB,IAA2B,EAC3B,MAAoC,EAAA;QAE7C,KAAK,CACH,MAAM,KAAK;AACT,cAAE,CAAA,gEAAA,EAAmE,OAAO,eAA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