@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.
- package/README.md +291 -2
- package/dist/compact-js-v8-effect.d.ts +1 -0
- package/dist/compact-js-v8-effect.js +2 -0
- package/dist/compact-js-v8-effect.js.map +1 -0
- package/dist/engine.d.ts +420 -0
- package/dist/engine.js +832 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +601 -0
- package/dist/errors.js +810 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1471 -0
- package/dist/index.js +799 -0
- package/dist/index.js.map +1 -0
- package/dist/platform-effect-configuration.d.ts +1 -0
- package/dist/platform-effect-configuration.js +2 -0
- package/dist/platform-effect-configuration.js.map +1 -0
- package/dist/platform-effect-contract-address.d.ts +1 -0
- package/dist/platform-effect-contract-address.js +2 -0
- package/dist/platform-effect-contract-address.js.map +1 -0
- package/dist/platform.d.ts +1 -0
- package/dist/platform.js +2 -0
- package/dist/platform.js.map +1 -0
- package/dist/prove.d.ts +45 -0
- package/dist/prove.js +61 -0
- package/dist/prove.js.map +1 -0
- package/dist/shared/compose-options-BFA09u9q.js +468 -0
- package/dist/shared/compose-options-BFA09u9q.js.map +1 -0
- package/dist/shared/ledger-transaction-DQP8J8tv.js +134 -0
- package/dist/shared/ledger-transaction-DQP8J8tv.js.map +1 -0
- package/dist/shared/load-BMVWoBo6.js +49 -0
- package/dist/shared/load-BMVWoBo6.js.map +1 -0
- package/dist/shared/transaction-tags-I3J_Hh8r.js +82 -0
- package/dist/shared/transaction-tags-I3J_Hh8r.js.map +1 -0
- package/dist/transaction.d.ts +92 -0
- package/dist/transaction.js +6 -0
- package/dist/transaction.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/v9-compact-js-effect-contract.d.ts +1 -0
- package/dist/v9-compact-js-effect-contract.js +2 -0
- package/dist/v9-compact-js-effect-contract.js.map +1 -0
- package/dist/v9-compact-js-effect.d.ts +1 -0
- package/dist/v9-compact-js-effect.js +2 -0
- package/dist/v9-compact-js-effect.js.map +1 -0
- package/dist/v9-compact-js.d.ts +1 -0
- package/dist/v9-compact-js.js +2 -0
- package/dist/v9-compact-js.js.map +1 -0
- package/dist/v9-compact-runtime.d.ts +1 -0
- package/dist/v9-compact-runtime.js +2 -0
- package/dist/v9-compact-runtime.js.map +1 -0
- package/dist/v9-onchain-runtime.d.ts +1 -0
- package/dist/v9-onchain-runtime.js +2 -0
- package/dist/v9-onchain-runtime.js.map +1 -0
- package/dist/v9.d.ts +1 -0
- package/dist/v9.js +2 -0
- package/dist/v9.js.map +1 -0
- package/dist/version.d.ts +173 -0
- package/dist/version.js +125 -0
- package/dist/version.js.map +1 -0
- package/package.json +122 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-options-BFA09u9q.js","sources":["../../src/lib/shared/compose-types.ts","../../src/lib/shared/assemble-call.ts","../../src/lib/shared/verifier-keys.ts","../../src/lib/shared/contract-state.ts","../../src/lib/shared/compose-options.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;AAaG;AAiEH;;;;;;;;AAQG;AACI,MAAM,yBAAyB,GAAG;;ACvFzC;;;;;;;;;;;;;AAaG;AAoKH;;;;;;AAMG;AACH,MAAM,sBAAsB,GAAG,CAC7B,YAA2B,EAC3B,gBAAkC,KACjB;AACjB,IAAA,YAAY,CAAC,KAAK,GAAG,gBAAgB,CAAC,KAAK;AAC3C,IAAA,YAAY,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO;IAC/C,IAAI,OAAO,GAAG,YAAY;IAC1B,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE;QAC7D,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC;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MACU,qBAAqB,GAAG,CAAC,OAA+B,EAAE,OAAkB,KAAU;IACjG,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;AAClC,QAAA,MAAM,IAAI,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC;IACpD;AACA,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE;AACvC,QAAA,MAAM,IAAI,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC;IAC9C;AACF;;"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Transaction } from '@midnightntwrk/ledger-v9';
|
|
2
|
+
import { TRANSACTION_TAG_PREFIX, InvalidArgumentError, PayloadNotATransactionError, UnknownLedgerEraError } from '../errors.js';
|
|
3
|
+
import { l as loadLedger8Protocol, a as loadedLedger8Protocol } from './load-BMVWoBo6.js';
|
|
4
|
+
import { T as TRANSACTION_STAGES, L as LEDGER_ERAS } from './transaction-tags-I3J_Hh8r.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* This file is part of midnight-js.
|
|
8
|
+
* Copyright (C) Midnight Foundation
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* You may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
const ledger9Decoders = Object.freeze({
|
|
21
|
+
Unproven: (bytes) => Transaction.deserialize('signature', 'pre-proof', 'pre-binding', bytes),
|
|
22
|
+
Unbound: (bytes) => Transaction.deserialize('signature', 'proof', 'pre-binding', bytes),
|
|
23
|
+
Finalized: (bytes) => Transaction.deserialize('signature', 'proof', 'binding', bytes)
|
|
24
|
+
});
|
|
25
|
+
const ledger8DecodersOf = ({ Transaction }) => ({
|
|
26
|
+
Unproven: (bytes) => Transaction.deserialize('signature', 'pre-proof', 'pre-binding', bytes),
|
|
27
|
+
Unbound: (bytes) => Transaction.deserialize('signature', 'proof', 'pre-binding', bytes),
|
|
28
|
+
Finalized: (bytes) => Transaction.deserialize('signature', 'proof', 'binding', bytes)
|
|
29
|
+
});
|
|
30
|
+
const decodersOf = Object.freeze({
|
|
31
|
+
v8: async () => ledger8DecodersOf(await loadLedger8Protocol()),
|
|
32
|
+
v9: () => Promise.resolve(ledger9Decoders)
|
|
33
|
+
});
|
|
34
|
+
const TRANSACTION_TAG_PREFIX_BYTES = Uint8Array.from(TRANSACTION_TAG_PREFIX, (character) => character.charCodeAt(0));
|
|
35
|
+
const assertSerializedTransaction = (bytes) => {
|
|
36
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
37
|
+
throw PayloadNotATransactionError.notBytes(bytes);
|
|
38
|
+
}
|
|
39
|
+
const matchesPrefix = bytes.byteLength >= TRANSACTION_TAG_PREFIX_BYTES.length &&
|
|
40
|
+
TRANSACTION_TAG_PREFIX_BYTES.every((byte, index) => bytes[index] === byte);
|
|
41
|
+
if (!matchesPrefix) {
|
|
42
|
+
throw PayloadNotATransactionError.wrongTag(bytes.byteLength);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const isTransactionShaped = (value) => typeof value === 'object' && value !== null && typeof Reflect.get(value, 'serialize') === 'function';
|
|
46
|
+
const assertKnownEra = (era) => {
|
|
47
|
+
if (!LEDGER_ERAS.some((version) => version === era)) {
|
|
48
|
+
throw new UnknownLedgerEraError(era);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Reads serialized bytes as a transaction of the given era at the given stage.
|
|
53
|
+
*
|
|
54
|
+
* A v8 transaction is read through {@link loadLedger8Protocol}, so the result
|
|
55
|
+
* is an object of the ledger copy this framework loaded.
|
|
56
|
+
*
|
|
57
|
+
* @param era The ledger era that wrote the bytes.
|
|
58
|
+
* @param stage The stage the bytes were serialized at.
|
|
59
|
+
* @param bytes The serialized transaction.
|
|
60
|
+
* @returns The live transaction object.
|
|
61
|
+
* @throws PayloadNotATransactionError If `bytes` is not a serialized
|
|
62
|
+
* transaction, or the era's runtime cannot read it at `stage`; the runtime's
|
|
63
|
+
* refusal is on `cause`.
|
|
64
|
+
* @throws UnknownLedgerEraError If `era` is not a ledger era.
|
|
65
|
+
* @throws InvalidArgumentError If `stage` is not a transaction stage.
|
|
66
|
+
* @throws Ledger8RuntimeMissingError If the v8 runtime cannot be loaded.
|
|
67
|
+
*/
|
|
68
|
+
const deserializeTransactionAtStage = async (era, stage, bytes) => {
|
|
69
|
+
assertKnownEra(era);
|
|
70
|
+
if (!TRANSACTION_STAGES.some((known) => known === stage)) {
|
|
71
|
+
throw new InvalidArgumentError(`Unknown transaction stage; expected one of ${TRANSACTION_STAGES.join(', ')}.`);
|
|
72
|
+
}
|
|
73
|
+
assertSerializedTransaction(bytes);
|
|
74
|
+
const decoders = await decodersOf[era]();
|
|
75
|
+
try {
|
|
76
|
+
return decoders[stage](bytes);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
throw PayloadNotATransactionError.undecodable(era, stage, bytes.byteLength, error);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Checks, synchronously, whether `value` is a transaction of the ledger copy
|
|
84
|
+
* this framework loaded for `era`.
|
|
85
|
+
*
|
|
86
|
+
* A v8 value cannot be judged before {@link loadLedger8Protocol} has resolved,
|
|
87
|
+
* because the framework's v8 class does not exist yet; the answer is then
|
|
88
|
+
* `'ledger8-not-loaded'`.
|
|
89
|
+
*
|
|
90
|
+
* @param era The era the value claims to belong to.
|
|
91
|
+
* @param value The value to check.
|
|
92
|
+
* @returns See {@link FrameworkInstanceCheck}.
|
|
93
|
+
* @throws UnknownLedgerEraError If `era` is not a ledger era.
|
|
94
|
+
*/
|
|
95
|
+
const isFrameworkLedgerTransaction = (era, value) => {
|
|
96
|
+
assertKnownEra(era);
|
|
97
|
+
if (!isTransactionShaped(value)) {
|
|
98
|
+
return 'not-a-transaction';
|
|
99
|
+
}
|
|
100
|
+
switch (era) {
|
|
101
|
+
case 'v9':
|
|
102
|
+
return value instanceof Transaction ? 'own' : 'foreign-instance';
|
|
103
|
+
case 'v8': {
|
|
104
|
+
const v8 = loadedLedger8Protocol();
|
|
105
|
+
if (v8 === undefined) {
|
|
106
|
+
return 'ledger8-not-loaded';
|
|
107
|
+
}
|
|
108
|
+
return value instanceof v8.Transaction ? 'own' : 'foreign-instance';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const STAGE_OF_MARKERS = Object.freeze({
|
|
113
|
+
'proof-preimage,embedded-fr': 'Unproven',
|
|
114
|
+
'proof,embedded-fr': 'Unbound',
|
|
115
|
+
'proof,pedersen-schnorr': 'Finalized'
|
|
116
|
+
});
|
|
117
|
+
const TAG_MARKERS = /^midnight:transaction\[v\d+\]\([^,()]+,([a-z-]+)(?:\[v\d+\])?,([a-z-]+)(?:\[v\d+\])?\):/;
|
|
118
|
+
const TAG_READ_LENGTH = 128;
|
|
119
|
+
/**
|
|
120
|
+
* Reads the stage a transaction object is at from the proof and binding
|
|
121
|
+
* markers in its serialized tag.
|
|
122
|
+
*
|
|
123
|
+
* @param tx The transaction object, of either era.
|
|
124
|
+
* @returns The stage, or `undefined` when the markers name no
|
|
125
|
+
* {@link TransactionStage} (for example a bound transaction with no proofs).
|
|
126
|
+
*/
|
|
127
|
+
const transactionStageOf = (tx) => {
|
|
128
|
+
const head = String.fromCharCode(...tx.serialize().subarray(0, TAG_READ_LENGTH));
|
|
129
|
+
const markers = TAG_MARKERS.exec(head);
|
|
130
|
+
return markers === null ? undefined : STAGE_OF_MARKERS[`${markers[1]},${markers[2]}`];
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { deserializeTransactionAtStage as d, isFrameworkLedgerTransaction as i, transactionStageOf as t };
|
|
134
|
+
//# sourceMappingURL=ledger-transaction-DQP8J8tv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-transaction-DQP8J8tv.js","sources":["../../src/lib/shared/ledger-transaction.ts"],"sourcesContent":[null],"names":["Ledger9Transaction"],"mappings":";;;;;AAAA;;;;;;;;;;;;;AAaG;AA+DH,MAAM,eAAe,GAAwB,MAAM,CAAC,MAAM,CAAC;AACzD,IAAA,QAAQ,EAAE,CAAC,KAAK,KACdA,WAAkB,CAAC,WAAW,CAAyC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,CAAC;AACxH,IAAA,OAAO,EAAE,CAAC,KAAK,KACbA,WAAkB,CAAC,WAAW,CAAsC,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC;AACjH,IAAA,SAAS,EAAE,CAAC,KAAK,KACfA,WAAkB,CAAC,WAAW,CAAmC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK;AAC1G,CAAA,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,EAAE,WAAW,EAAmB,MAA2B;AACpF,IAAA,QAAQ,EAAE,CAAC,KAAK,KACd,WAAW,CAAC,WAAW,CACrB,WAAW,EACX,WAAW,EACX,aAAa,EACb,KAAK,CACN;AACH,IAAA,OAAO,EAAE,CAAC,KAAK,KACb,WAAW,CAAC,WAAW,CACrB,WAAW,EACX,OAAO,EACP,aAAa,EACb,KAAK,CACN;AACH,IAAA,SAAS,EAAE,CAAC,KAAK,KACf,WAAW,CAAC,WAAW,CACrB,WAAW,EACX,OAAO,EACP,SAAS,EACT,KAAK;AAEV,CAAA,CAAC;AAEF,MAAM,UAAU,GAAmE,MAAM,CAAC,MAAM,CAAC;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,MAAM,WAAW,GAAG,yFAAyF;AAE7G,MAAM,eAAe,GAAG,GAAG;AAE3B;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAA+B,KAAkC;AAClG,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IAChF,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;IACtC,OAAO,OAAO,KAAK,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA,CAAA,EAAI,OAAO,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACvF;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Ledger8RuntimeMissingError } from '../errors.js';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* This file is part of midnight-js.
|
|
5
|
+
* Copyright (C) Midnight Foundation
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* You may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
let ledger8ModulePromise;
|
|
18
|
+
let ledger8Module;
|
|
19
|
+
/**
|
|
20
|
+
* The v8 ledger module if {@link loadLedger8Protocol} has resolved, synchronously.
|
|
21
|
+
*
|
|
22
|
+
* @returns The loaded module, or `undefined` before the first successful load.
|
|
23
|
+
*/
|
|
24
|
+
const loadedLedger8Protocol = () => ledger8Module;
|
|
25
|
+
/**
|
|
26
|
+
* The only sanctioned runtime path to the v8 ledger era.
|
|
27
|
+
*
|
|
28
|
+
* The v8 WASM loads on the first call and not before.
|
|
29
|
+
*
|
|
30
|
+
* A failed load is not memoised: the rejection propagates as
|
|
31
|
+
* {@link Ledger8RuntimeMissingError} and the next call retries the import.
|
|
32
|
+
*
|
|
33
|
+
* @returns The v8 ledger module, memoised after the first successful load.
|
|
34
|
+
* @throws Ledger8RuntimeMissingError If the `./v8` chunk cannot be imported.
|
|
35
|
+
* The returned promise rejects with it, carrying the underlying failure on
|
|
36
|
+
* `cause`.
|
|
37
|
+
* @see {@link ModuleGraphAndLazyLoading}
|
|
38
|
+
* @see {@link EraBoundary}
|
|
39
|
+
*/
|
|
40
|
+
const loadLedger8Protocol = () => (ledger8ModulePromise ??= import('../v8.js').then((module) => {
|
|
41
|
+
ledger8Module = module;
|
|
42
|
+
return module;
|
|
43
|
+
}, (error) => {
|
|
44
|
+
ledger8ModulePromise = undefined;
|
|
45
|
+
throw new Ledger8RuntimeMissingError('/v8', error);
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
export { loadedLedger8Protocol as a, loadLedger8Protocol as l };
|
|
49
|
+
//# sourceMappingURL=load-BMVWoBo6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-BMVWoBo6.js","sources":["../../src/lib/v8/load.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;AAaG;AAQH,IAAI,oBAA0D;AAC9D,IAAI,aAA0C;AAE9C;;;;AAIG;MACU,qBAAqB,GAAG,MAAmC;AAExE;;;;;;;;;;;;;;AAcG;MACU,mBAAmB,GAAG,OAChC,oBAAoB,KAAK,OAAO,UAAa,CAAC,CAAC,IAAI,CAClD,CAAC,MAAM,KAAI;IACT,aAAa,GAAG,MAAM;AACtB,IAAA,OAAO,MAAM;AACf,CAAC,EACD,CAAC,KAAc,KAAI;IACjB,oBAAoB,GAAG,SAAS;AAChC,IAAA,MAAM,IAAI,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC;AACpD,CAAC,CACF;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
* The two ledger runtimes midnight-js can talk to. `v8` backs the node 1.x
|
|
17
|
+
* line; `v9` backs the 2.x line. This is a closed, exhaustive set — see
|
|
18
|
+
* `protocolVersionToLedger` (`../version.ts`) for how a raw `protocolVersion`
|
|
19
|
+
* integer maps onto it.
|
|
20
|
+
*
|
|
21
|
+
* compact-js names the same era by number: its `Ledger.Era['ledger']` (for
|
|
22
|
+
* example `executable.era.ledger`) is `8` for `'v8'` and `9` for `'v9'`.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link SharedTableDiscipline} for why the array is frozen.
|
|
25
|
+
* @see {@link ModuleGraphAndLazyLoading} for why the constant is declared in
|
|
26
|
+
* this leaf module and re-exported by `../version.ts`.
|
|
27
|
+
*/
|
|
28
|
+
const LEDGER_ERAS = Object.freeze(['v8', 'v9']);
|
|
29
|
+
/**
|
|
30
|
+
* The era whose objects this build links eagerly, today through `./v9`.
|
|
31
|
+
*
|
|
32
|
+
* "Current" is relative: today it is ledger 9 (`'v9'`). At the next hard fork it
|
|
33
|
+
* moves to the new ledger and ledger 9 joins {@link RetainedLedgerEra}. Code
|
|
34
|
+
* bound to one ledger is named after that ledger (`Ledger9*`) instead.
|
|
35
|
+
*
|
|
36
|
+
* A protocol fact rather than a consumer's choice: it is decided by which
|
|
37
|
+
* ledger the package links eagerly, and every other era is reached lazily and
|
|
38
|
+
* crosses package boundaries as bytes. Declared here so that no package
|
|
39
|
+
* downstream restates "which era is now" as a literal of its own.
|
|
40
|
+
*
|
|
41
|
+
* The type is the single literal, not {@link LedgerEra}, so a value typed
|
|
42
|
+
* by it DISCRIMINATES: `midnight-js-contracts` types a current-era result's
|
|
43
|
+
* `era` with it, so a union of both eras' results narrows on `era`.
|
|
44
|
+
*/
|
|
45
|
+
const CURRENT_LEDGER_ERA = 'v9';
|
|
46
|
+
const RETAINED_LEDGER_ERAS = Object.freeze(['v8']);
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
* This file is part of midnight-js.
|
|
50
|
+
* Copyright (C) Midnight Foundation
|
|
51
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
52
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
53
|
+
* You may not use this file except in compliance with the License.
|
|
54
|
+
* You may obtain a copy of the License at
|
|
55
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
56
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
57
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
+
* See the License for the specific language governing permissions and
|
|
60
|
+
* limitations under the License.
|
|
61
|
+
*/
|
|
62
|
+
/** Every transaction stage, in the order a transaction goes through them. */
|
|
63
|
+
const TRANSACTION_STAGES = Object.freeze(['Unproven', 'Unbound', 'Finalized']);
|
|
64
|
+
/**
|
|
65
|
+
* The full header each ledger era writes in front of a transaction at each stage: the schema
|
|
66
|
+
* version, then the signature, proof and binding markers.
|
|
67
|
+
*/
|
|
68
|
+
const LEDGER_TRANSACTION_TAGS = Object.freeze({
|
|
69
|
+
v8: Object.freeze({
|
|
70
|
+
Unproven: 'midnight:transaction[v9](signature[v1],proof-preimage,embedded-fr[v1])',
|
|
71
|
+
Unbound: 'midnight:transaction[v9](signature[v1],proof,embedded-fr[v1])',
|
|
72
|
+
Finalized: 'midnight:transaction[v9](signature[v1],proof,pedersen-schnorr[v1])'
|
|
73
|
+
}),
|
|
74
|
+
v9: Object.freeze({
|
|
75
|
+
Unproven: 'midnight:transaction[v12](signature[v2],proof-preimage,embedded-fr[v1])',
|
|
76
|
+
Unbound: 'midnight:transaction[v12](signature[v2],proof,embedded-fr[v1])',
|
|
77
|
+
Finalized: 'midnight:transaction[v12](signature[v2],proof,pedersen-schnorr[v1])'
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export { CURRENT_LEDGER_ERA as C, LEDGER_ERAS as L, RETAINED_LEDGER_ERAS as R, TRANSACTION_STAGES as T, LEDGER_TRANSACTION_TAGS as a };
|
|
82
|
+
//# sourceMappingURL=transaction-tags-I3J_Hh8r.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-tags-I3J_Hh8r.js","sources":["../../src/lib/shared/ledger-version.ts","../../src/lib/shared/transaction-tags.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AAEH;;;;;;;;;;;;AAYG;AACI,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,CAAU;AAG9D;;;;;;;;;;;;;;;AAeG;AACI,MAAM,kBAAkB,GAAG;AAiB3B,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAiD;;AChExG;;;;;;;;;;;;;AAaG;AAIH;AACO,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,CAAU;AAK7F;;;AAGG;AACI,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;AACnD,IAAA,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC;AAChB,QAAA,QAAQ,EAAE,wEAAwE;AAClF,QAAA,OAAO,EAAE,+DAA+D;AACxE,QAAA,SAAS,EAAE;KACZ,CAAC;AACF,IAAA,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC;AAChB,QAAA,QAAQ,EAAE,yEAAyE;AACnF,QAAA,OAAO,EAAE,gEAAgE;AACzE,QAAA,SAAS,EAAE;KACZ;AACqE,CAAA;;"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
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';
|
|
2
|
+
import { UnprovenTransaction, Transaction, SignatureEnabled, Proof, PreBinding, FinalizedTransaction } from '@midnightntwrk/ledger-v8';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The two ledger runtimes midnight-js can talk to. `v8` backs the node 1.x
|
|
6
|
+
* line; `v9` backs the 2.x line. This is a closed, exhaustive set — see
|
|
7
|
+
* `protocolVersionToLedger` (`../version.ts`) for how a raw `protocolVersion`
|
|
8
|
+
* integer maps onto it.
|
|
9
|
+
*
|
|
10
|
+
* compact-js names the same era by number: its `Ledger.Era['ledger']` (for
|
|
11
|
+
* example `executable.era.ledger`) is `8` for `'v8'` and `9` for `'v9'`.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link SharedTableDiscipline} for why the array is frozen.
|
|
14
|
+
* @see {@link ModuleGraphAndLazyLoading} for why the constant is declared in
|
|
15
|
+
* this leaf module and re-exported by `../version.ts`.
|
|
16
|
+
*/
|
|
17
|
+
declare const LEDGER_ERAS: readonly ["v8", "v9"];
|
|
18
|
+
type LedgerEra = (typeof LEDGER_ERAS)[number];
|
|
19
|
+
|
|
20
|
+
/** Every transaction stage, in the order a transaction goes through them. */
|
|
21
|
+
declare const TRANSACTION_STAGES: readonly ["Unproven", "Unbound", "Finalized"];
|
|
22
|
+
/** The point in its life a transaction has reached: before proving, after proving, after binding. */
|
|
23
|
+
type TransactionStage = (typeof TRANSACTION_STAGES)[number];
|
|
24
|
+
|
|
25
|
+
/** The ledger transaction class of each era at each {@link TransactionStage}. */
|
|
26
|
+
interface LedgerTransactionTypes {
|
|
27
|
+
v8: {
|
|
28
|
+
Unproven: UnprovenTransaction;
|
|
29
|
+
Unbound: Transaction<SignatureEnabled, Proof, PreBinding>;
|
|
30
|
+
Finalized: FinalizedTransaction;
|
|
31
|
+
};
|
|
32
|
+
v9: {
|
|
33
|
+
Unproven: UnprovenTransaction$1;
|
|
34
|
+
Unbound: Transaction$1<SignatureEnabled$1, Proof$1, PreBinding$1>;
|
|
35
|
+
Finalized: FinalizedTransaction$1;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether a value is a transaction of the ledger copy this framework loaded:
|
|
40
|
+
* `'own'` when it is, `'foreign-instance'` when it is a transaction object of
|
|
41
|
+
* another WASM instance of the same package, `'not-a-transaction'` when it is
|
|
42
|
+
* not a transaction object at all (bytes, `undefined`, a plain object), and
|
|
43
|
+
* `'ledger8-not-loaded'` when the v8 ledger has not been loaded yet, so no
|
|
44
|
+
* answer is possible.
|
|
45
|
+
*/
|
|
46
|
+
type FrameworkInstanceCheck = 'own' | 'foreign-instance' | 'not-a-transaction' | 'ledger8-not-loaded';
|
|
47
|
+
/**
|
|
48
|
+
* Reads serialized bytes as a transaction of the given era at the given stage.
|
|
49
|
+
*
|
|
50
|
+
* A v8 transaction is read through {@link loadLedger8Protocol}, so the result
|
|
51
|
+
* is an object of the ledger copy this framework loaded.
|
|
52
|
+
*
|
|
53
|
+
* @param era The ledger era that wrote the bytes.
|
|
54
|
+
* @param stage The stage the bytes were serialized at.
|
|
55
|
+
* @param bytes The serialized transaction.
|
|
56
|
+
* @returns The live transaction object.
|
|
57
|
+
* @throws PayloadNotATransactionError If `bytes` is not a serialized
|
|
58
|
+
* transaction, or the era's runtime cannot read it at `stage`; the runtime's
|
|
59
|
+
* refusal is on `cause`.
|
|
60
|
+
* @throws UnknownLedgerEraError If `era` is not a ledger era.
|
|
61
|
+
* @throws InvalidArgumentError If `stage` is not a transaction stage.
|
|
62
|
+
* @throws Ledger8RuntimeMissingError If the v8 runtime cannot be loaded.
|
|
63
|
+
*/
|
|
64
|
+
declare const deserializeTransactionAtStage: <E extends LedgerEra, S extends TransactionStage>(era: E, stage: S, bytes: Uint8Array) => Promise<LedgerTransactionTypes[E][S]>;
|
|
65
|
+
/**
|
|
66
|
+
* Checks, synchronously, whether `value` is a transaction of the ledger copy
|
|
67
|
+
* this framework loaded for `era`.
|
|
68
|
+
*
|
|
69
|
+
* A v8 value cannot be judged before {@link loadLedger8Protocol} has resolved,
|
|
70
|
+
* because the framework's v8 class does not exist yet; the answer is then
|
|
71
|
+
* `'ledger8-not-loaded'`.
|
|
72
|
+
*
|
|
73
|
+
* @param era The era the value claims to belong to.
|
|
74
|
+
* @param value The value to check.
|
|
75
|
+
* @returns See {@link FrameworkInstanceCheck}.
|
|
76
|
+
* @throws UnknownLedgerEraError If `era` is not a ledger era.
|
|
77
|
+
*/
|
|
78
|
+
declare const isFrameworkLedgerTransaction: (era: LedgerEra, value: unknown) => FrameworkInstanceCheck;
|
|
79
|
+
/**
|
|
80
|
+
* Reads the stage a transaction object is at from the proof and binding
|
|
81
|
+
* markers in its serialized tag.
|
|
82
|
+
*
|
|
83
|
+
* @param tx The transaction object, of either era.
|
|
84
|
+
* @returns The stage, or `undefined` when the markers name no
|
|
85
|
+
* {@link TransactionStage} (for example a bound transaction with no proofs).
|
|
86
|
+
*/
|
|
87
|
+
declare const transactionStageOf: (tx: {
|
|
88
|
+
serialize(): Uint8Array;
|
|
89
|
+
}) => TransactionStage | undefined;
|
|
90
|
+
|
|
91
|
+
export { deserializeTransactionAtStage, isFrameworkLedgerTransaction, transactionStageOf };
|
|
92
|
+
export type { FrameworkInstanceCheck, LedgerTransactionTypes, TransactionStage };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { d as deserializeTransactionAtStage, i as isFrameworkLedgerTransaction, t as transactionStageOf } from './shared/ledger-transaction-DQP8J8tv.js';
|
|
2
|
+
import '@midnightntwrk/ledger-v9';
|
|
3
|
+
import './errors.js';
|
|
4
|
+
import './shared/load-BMVWoBo6.js';
|
|
5
|
+
import './shared/transaction-tags-I3J_Hh8r.js';
|
|
6
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/v8.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnightntwrk/ledger-v8';
|
package/dist/v8.js
ADDED
package/dist/v8.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnight-ntwrk/compact-js/effect/Contract';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9-compact-js-effect-contract.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnight-ntwrk/compact-js/effect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9-compact-js-effect.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnight-ntwrk/compact-js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9-compact-js.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnight-ntwrk/compact-runtime';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9-compact-runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnightntwrk/onchain-runtime-v4';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9-onchain-runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/v9.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnightntwrk/ledger-v9';
|
package/dist/v9.js
ADDED
package/dist/v9.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v9.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|