@proto-kit/protocol 0.1.1-develop.153
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/LICENSE.md +201 -0
- package/README.md +45 -0
- package/dist/Constants.d.ts +4 -0
- package/dist/Constants.d.ts.map +1 -0
- package/dist/Constants.js +3 -0
- package/dist/config/ConfigurableModule.d.ts +18 -0
- package/dist/config/ConfigurableModule.d.ts.map +1 -0
- package/dist/config/ConfigurableModule.js +20 -0
- package/dist/config/ConfigurationAggregator.d.ts +10 -0
- package/dist/config/ConfigurationAggregator.d.ts.map +1 -0
- package/dist/config/ConfigurationAggregator.js +35 -0
- package/dist/config/ConfigurationReceiver.d.ts +25 -0
- package/dist/config/ConfigurationReceiver.d.ts.map +1 -0
- package/dist/config/ConfigurationReceiver.js +36 -0
- package/dist/config/ModuleContainer.d.ts +44 -0
- package/dist/config/ModuleContainer.d.ts.map +1 -0
- package/dist/config/ModuleContainer.js +89 -0
- package/dist/config/types.d.ts +2 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/model/MethodPublicInput.d.ts +51 -0
- package/dist/model/MethodPublicInput.d.ts.map +1 -0
- package/dist/model/MethodPublicInput.js +11 -0
- package/dist/model/MethodPublicOutput.d.ts +59 -0
- package/dist/model/MethodPublicOutput.d.ts.map +1 -0
- package/dist/model/MethodPublicOutput.js +12 -0
- package/dist/model/Option.d.ts +94 -0
- package/dist/model/Option.d.ts.map +1 -0
- package/dist/model/Option.js +96 -0
- package/dist/model/Path.d.ts +31 -0
- package/dist/model/Path.d.ts.map +1 -0
- package/dist/model/Path.js +44 -0
- package/dist/model/StateTransition.d.ts +85 -0
- package/dist/model/StateTransition.d.ts.map +1 -0
- package/dist/model/StateTransition.js +58 -0
- package/dist/model/StateTransitionProvableBatch.d.ts +57 -0
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -0
- package/dist/model/StateTransitionProvableBatch.js +21 -0
- package/dist/model/network/NetworkState.d.ts +64 -0
- package/dist/model/network/NetworkState.d.ts.map +1 -0
- package/dist/model/network/NetworkState.js +14 -0
- package/dist/model/transaction/ProtocolTransaction.d.ts +70 -0
- package/dist/model/transaction/ProtocolTransaction.d.ts.map +1 -0
- package/dist/model/transaction/ProtocolTransaction.js +18 -0
- package/dist/model/transaction/RuntimeTransaction.d.ts +55 -0
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -0
- package/dist/model/transaction/RuntimeTransaction.js +26 -0
- package/dist/protocol/Protocol.d.ts +37 -0
- package/dist/protocol/Protocol.d.ts.map +1 -0
- package/dist/protocol/Protocol.js +50 -0
- package/dist/protocol/ProtocolModule.d.ts +9 -0
- package/dist/protocol/ProtocolModule.d.ts.map +1 -0
- package/dist/protocol/ProtocolModule.js +10 -0
- package/dist/prover/block/BlockProvable.d.ts +149 -0
- package/dist/prover/block/BlockProvable.d.ts.map +1 -0
- package/dist/prover/block/BlockProvable.js +20 -0
- package/dist/prover/block/BlockProver.d.ts +48 -0
- package/dist/prover/block/BlockProver.d.ts.map +1 -0
- package/dist/prover/block/BlockProver.js +171 -0
- package/dist/prover/block/BlockScopedModule.d.ts +3 -0
- package/dist/prover/block/BlockScopedModule.d.ts.map +1 -0
- package/dist/prover/block/BlockScopedModule.js +6 -0
- package/dist/prover/statetransition/StateTransitionProvable.d.ts +84 -0
- package/dist/prover/statetransition/StateTransitionProvable.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionProvable.js +11 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts +39 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionProver.js +157 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +16 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.js +17 -0
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.d.ts +7 -0
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.js +20 -0
- package/dist/src/model/Option.d.ts +158 -0
- package/dist/src/model/Option.d.ts.map +1 -0
- package/dist/src/model/Option.js +53 -0
- package/dist/src/model/Path.d.ts +35 -0
- package/dist/src/model/Path.d.ts.map +1 -0
- package/dist/src/model/Path.js +51 -0
- package/dist/src/model/StateTransition.d.ts +201 -0
- package/dist/src/model/StateTransition.d.ts.map +1 -0
- package/dist/src/model/StateTransition.js +43 -0
- package/dist/src/utils/PrefixedHashList.d.ts +15 -0
- package/dist/src/utils/PrefixedHashList.d.ts.map +1 -0
- package/dist/src/utils/PrefixedHashList.js +28 -0
- package/dist/src/utils/ProvableHashList.d.ts +30 -0
- package/dist/src/utils/ProvableHashList.d.ts.map +1 -0
- package/dist/src/utils/ProvableHashList.js +43 -0
- package/dist/utils/PrefixedHashList.d.ts +14 -0
- package/dist/utils/PrefixedHashList.d.ts.map +1 -0
- package/dist/utils/PrefixedHashList.js +12 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +8 -0
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -0
- package/dist/utils/PrefixedProvableHashList.js +12 -0
- package/dist/utils/ProvableHashList.d.ts +27 -0
- package/dist/utils/ProvableHashList.d.ts.map +1 -0
- package/dist/utils/ProvableHashList.js +43 -0
- package/dist/utils/Utils.d.ts +17 -0
- package/dist/utils/Utils.d.ts.map +1 -0
- package/dist/utils/Utils.js +63 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts +25 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.js +72 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts +26 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.js +79 -0
- package/dist/utils/merkletree/MerkleTreeStore.d.ts +11 -0
- package/dist/utils/merkletree/MerkleTreeStore.d.ts.map +1 -0
- package/dist/utils/merkletree/MerkleTreeStore.js +1 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +130 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -0
- package/dist/utils/merkletree/RollupMerkleTree.js +244 -0
- package/jest.config.cjs +1 -0
- package/package.json +35 -0
- package/src/Constants.ts +3 -0
- package/src/index.ts +23 -0
- package/src/model/MethodPublicOutput.ts +12 -0
- package/src/model/Option.test.ts +21 -0
- package/src/model/Option.ts +133 -0
- package/src/model/Path.ts +52 -0
- package/src/model/StateTransition.ts +72 -0
- package/src/model/StateTransitionProvableBatch.ts +31 -0
- package/src/model/Transaction.ts +29 -0
- package/src/model/network/NetworkState.ts +15 -0
- package/src/model/transaction/ProtocolTransaction.ts +25 -0
- package/src/model/transaction/RuntimeTransaction.ts +34 -0
- package/src/protocol/Protocol.ts +129 -0
- package/src/protocol/ProtocolModule.ts +27 -0
- package/src/prover/block/BlockProvable.ts +45 -0
- package/src/prover/block/BlockProver.ts +302 -0
- package/src/prover/statetransition/StateTransitionProvable.ts +40 -0
- package/src/prover/statetransition/StateTransitionProver.ts +270 -0
- package/src/prover/statetransition/StateTransitionWitnessProvider.ts +24 -0
- package/src/prover/statetransition/StateTransitionWitnessProviderReference.ts +17 -0
- package/src/utils/PrefixedProvableHashList.ts +21 -0
- package/src/utils/ProvableHashList.ts +50 -0
- package/src/utils/merkletree/InMemoryMerkleTreeStorage.ts +99 -0
- package/src/utils/merkletree/MerkleTreeStore.ts +15 -0
- package/src/utils/merkletree/RollupMerkleTree.ts +250 -0
- package/src/utils/merkletree/VirtualMerkleTreeStore.ts +21 -0
- package/src/utils/utils.ts +103 -0
- package/test/BlockProver.test.ts +127 -0
- package/test/Protocol.test.ts +27 -0
- package/test/StateTransition.test.ts +182 -0
- package/tsconfig.json +8 -0
- package/tsconfig.test.json +9 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2023] [Stove Labs]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# YAB: Protocol
|
|
2
|
+
|
|
3
|
+
Protocol contains to all circuit-aware data types and provers
|
|
4
|
+
|
|
5
|
+
### StateTransitionProver
|
|
6
|
+
|
|
7
|
+
The StateTransitionProver takes a list of StateTransitions, checks and proves their precondition and update to the respective merkletree represented by the state root public input.
|
|
8
|
+
|
|
9
|
+
In the public input, the prover transitions from two fields:
|
|
10
|
+
|
|
11
|
+
- state root
|
|
12
|
+
- transitions hash
|
|
13
|
+
|
|
14
|
+
The transitions hash is the commitment to a hash list where every state transition gets appended one-by-one.
|
|
15
|
+
|
|
16
|
+
The StateTransitionsProver batches the application of multiple state transitions together.
|
|
17
|
+
If the amount of state transitions if greater than the batch size, the seperate proofs can be merged together.
|
|
18
|
+
|
|
19
|
+
In the end, the publicInput of the StateTransitionProof should contain the following content:
|
|
20
|
+
|
|
21
|
+
- `fromTransitionsHash: 0` To prove that all STs have been applied, the transitionsHash must start at zero (i.e. a empty hash list)
|
|
22
|
+
- `toTransitionsHash` This value must be the same as the transitionsHash in the AppChainProof to guarantee that all (and same) statetransitions that have been outputted by the AppChain have been applied
|
|
23
|
+
- `from- and toStateRoot` These values represent the root of the state tree and will later be stitched together to arrive at the final stateroot for a bundle
|
|
24
|
+
|
|
25
|
+
### BlockProver
|
|
26
|
+
|
|
27
|
+
The BlockProver's responsibility is to verify and put together the AppChainProof and StateTransitionProof.
|
|
28
|
+
It verifies that the transitionsHash is the same across both proofs and then takes the new state root proved by the STProof.
|
|
29
|
+
|
|
30
|
+
In the end, the BlockProof proofs that:
|
|
31
|
+
|
|
32
|
+
- the AppChain has been executed correctly
|
|
33
|
+
- the resulting state changes have been applied correctly and fully to the state root
|
|
34
|
+
|
|
35
|
+
Multiple BlockProofs will then be merged together, signed by the sequencer and published to the base layer.
|
|
36
|
+
|
|
37
|
+
### RollupMerkleTree
|
|
38
|
+
|
|
39
|
+
The RollupMerkleTree is a custom merkle tree implementation that supports the injection of a storage adapter.
|
|
40
|
+
The interface for that adapter can be found as the interface `MerkleTreeStorage`.
|
|
41
|
+
|
|
42
|
+
Adapters can implement any storage backend, like In-Memory and Database, and supports a process called "virtualization".
|
|
43
|
+
Virtualization is the process of layering different Adapters on top of each other.
|
|
44
|
+
For example if I want to simulate some transactions to a merkle tree, I can virtualize a database adapter into a MemoryAdapter.
|
|
45
|
+
If I am happy with the result, I can merge the results into the database or, if not, discard them without writing the changes to the database.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;CAErB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Preset<Config> = Config | ((...args: any[]) => Config);
|
|
2
|
+
export type Presets<Config> = Record<string, Preset<Config>>;
|
|
3
|
+
export interface Configurable<Config> {
|
|
4
|
+
config: Config;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Used by various module sub-types that may need to be configured
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConfigurableModule<Config> implements Configurable<Config> {
|
|
10
|
+
protected currentConfig: Config | undefined;
|
|
11
|
+
constructor(...args: any[]);
|
|
12
|
+
get config(): Config;
|
|
13
|
+
set config(config: Config);
|
|
14
|
+
}
|
|
15
|
+
export interface StaticConfigurableModule<Config> {
|
|
16
|
+
presets: Presets<Config>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ConfigurableModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurableModule.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurableModule.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,MAAM,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;AACnE,MAAM,MAAM,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAG7D,MAAM,WAAW,YAAY,CAAC,MAAM;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,kBAAkB,CAAC,MAAM,CAAE,YAAW,YAAY,CAAC,MAAM,CAAC;IACrE,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;gBAIzB,GAAG,IAAI,EAAE,GAAG,EAAE;IAEjC,IAAW,MAAM,IAAI,MAAM,CAK1B;IAED,IAAW,MAAM,CAAC,MAAM,EAAE,MAAM,EAE/B;CACF;AAGD,MAAM,WAAW,wBAAwB,CAAC,MAAM;IAC9C,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const errors = {
|
|
2
|
+
configNotSet: (moduleName) => new Error(`Trying to retrieve config of ${moduleName}, which was not yet set`),
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Used by various module sub-types that may need to be configured
|
|
6
|
+
*/
|
|
7
|
+
export class ConfigurableModule {
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
10
|
+
constructor(...args) { }
|
|
11
|
+
get config() {
|
|
12
|
+
if (this.currentConfig === undefined) {
|
|
13
|
+
throw errors.configNotSet(this.constructor.name);
|
|
14
|
+
}
|
|
15
|
+
return this.currentConfig;
|
|
16
|
+
}
|
|
17
|
+
set config(config) {
|
|
18
|
+
this.currentConfig = config;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentConfig, Components, RemoveUndefinedKeys, UninitializedComponentConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* In this context, a "Component" is just a way of generalizing Modules,
|
|
4
|
+
* because they don't have to be modules, they can be any configurable unit
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class ConfigurationAggregator<Comps extends Components> {
|
|
7
|
+
protected applyConfig(modules: Comps, currentConfig: UninitializedComponentConfig<ComponentConfig<Comps>>, config: RemoveUndefinedKeys<ComponentConfig<Comps>>): ComponentConfig<Comps>;
|
|
8
|
+
abstract configure(config: RemoveUndefinedKeys<ComponentConfig<Comps>>): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ConfigurationAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationAggregator.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,KAAK,SAAS,UAAU;IACpE,SAAS,CAAC,WAAW,CACnB,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EACnE,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,eAAe,CAAC,KAAK,CAAC;aAgCT,SAAS,CACvB,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,IAAI;CACR"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,guard-for-in,@typescript-eslint/no-unsafe-member-access,max-len,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/consistent-type-assertions */
|
|
2
|
+
import merge from "lodash/merge";
|
|
3
|
+
/**
|
|
4
|
+
* In this context, a "Component" is just a way of generalizing Modules,
|
|
5
|
+
* because they don't have to be modules, they can be any configurable unit
|
|
6
|
+
*/
|
|
7
|
+
export class ConfigurationAggregator {
|
|
8
|
+
applyConfig(modules, currentConfig, config) {
|
|
9
|
+
const nextConfig = {};
|
|
10
|
+
for (const key in config) {
|
|
11
|
+
// Set config to module
|
|
12
|
+
if (currentConfig[key] === undefined) {
|
|
13
|
+
// Initialize config with merge between config and defaultConfig
|
|
14
|
+
// eslint-disable-next-line prefer-destructuring,putout/putout
|
|
15
|
+
const defaultConfig = modules[key].defaultConfig;
|
|
16
|
+
const newConfig = config[key];
|
|
17
|
+
for (const configKey in newConfig) {
|
|
18
|
+
defaultConfig[configKey] = newConfig[configKey];
|
|
19
|
+
}
|
|
20
|
+
// The result of that is always a valid Required<Config> since FlipOptional<Config> requires the exact opposite of Config
|
|
21
|
+
modules[key].config = defaultConfig;
|
|
22
|
+
nextConfig[key] = defaultConfig;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Append/overwrite to existing config
|
|
26
|
+
const newConfig = config[key];
|
|
27
|
+
const moduleConfig = currentConfig[key];
|
|
28
|
+
merge(moduleConfig, newConfig);
|
|
29
|
+
modules[key].config = moduleConfig;
|
|
30
|
+
nextConfig[key] = moduleConfig;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return nextConfig;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FlipOptional } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Configs:
|
|
4
|
+
*
|
|
5
|
+
* A property that accepts undefined, is an optional argument.
|
|
6
|
+
* That means that you will have to provide it via defaultConfig() and it will
|
|
7
|
+
* be non-undefined via this.config. This is used by devs to indicate
|
|
8
|
+
* configurability but not necessary explicit definition.
|
|
9
|
+
* I.e. when the default arguments will work most of the time
|
|
10
|
+
*
|
|
11
|
+
* If devs want a property that can be undefined, they should use null instead
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class ConfigurationReceiver<Config> {
|
|
15
|
+
private currentConfig?;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the configured config object.
|
|
18
|
+
* This is only available in instance methods like start(), using this in
|
|
19
|
+
* the constructor will throw an Exception
|
|
20
|
+
*/
|
|
21
|
+
get config(): Required<Config>;
|
|
22
|
+
set config(config: Required<Config>);
|
|
23
|
+
abstract get defaultConfig(): FlipOptional<Config>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ConfigurationReceiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationReceiver.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationReceiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5C;;;;;;;;;;;GAWG;AACH,8BAAsB,qBAAqB,CAAC,MAAM;IAChD,OAAO,CAAC,aAAa,CAAC,CAA+B;IAErD;;;;OAIG;IACH,IAAW,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,CAOpC;IAED,IAAW,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAEzC;IAED,aAAoB,aAAa,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const errors = {
|
|
2
|
+
configNotSet: (name) => new Error(`RuntimeModule (${name}) config has not been set!`),
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Configs:
|
|
6
|
+
*
|
|
7
|
+
* A property that accepts undefined, is an optional argument.
|
|
8
|
+
* That means that you will have to provide it via defaultConfig() and it will
|
|
9
|
+
* be non-undefined via this.config. This is used by devs to indicate
|
|
10
|
+
* configurability but not necessary explicit definition.
|
|
11
|
+
* I.e. when the default arguments will work most of the time
|
|
12
|
+
*
|
|
13
|
+
* If devs want a property that can be undefined, they should use null instead
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export class ConfigurationReceiver {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.currentConfig = undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the configured config object.
|
|
22
|
+
* This is only available in instance methods like start(), using this in
|
|
23
|
+
* the constructor will throw an Exception
|
|
24
|
+
*/
|
|
25
|
+
get config() {
|
|
26
|
+
if (this.currentConfig === undefined) {
|
|
27
|
+
// eslint-disable-next-line no-warning-comments
|
|
28
|
+
// TODO Check properly, Config could also be void
|
|
29
|
+
throw errors.configNotSet(this.constructor.name);
|
|
30
|
+
}
|
|
31
|
+
return this.currentConfig;
|
|
32
|
+
}
|
|
33
|
+
set config(config) {
|
|
34
|
+
this.currentConfig = config;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Frequency, InjectionToken } from "tsyringe";
|
|
2
|
+
import { TypedClassConstructor } from "../utils/utils";
|
|
3
|
+
import { Configurable, ConfigurableModule } from "./ConfigurableModule";
|
|
4
|
+
export declare const errors: {
|
|
5
|
+
configNotSet: (moduleName: string) => Error;
|
|
6
|
+
configNotSetInContainer: (moduleName: string) => Error;
|
|
7
|
+
onlyStringModuleNames: (moduleName: NonNullable<unknown>) => Error;
|
|
8
|
+
unableToDecorateModule: (moduleName: InjectionToken<unknown>) => Error;
|
|
9
|
+
nonModuleDependecy: (runtimeModuleName: string) => Error;
|
|
10
|
+
unknownDependency: (runtimeModuleName: string, name: string) => Error;
|
|
11
|
+
};
|
|
12
|
+
export type BaseModuleType = TypedClassConstructor<Configurable<unknown>>;
|
|
13
|
+
export interface ModulesRecord<ModuleType extends BaseModuleType = BaseModuleType> {
|
|
14
|
+
[name: string]: ModuleType;
|
|
15
|
+
}
|
|
16
|
+
export type ModulesConfig<Modules extends ModulesRecord> = {
|
|
17
|
+
[ConfigKey in keyof Modules]: InstanceType<Modules[ConfigKey]>["config"];
|
|
18
|
+
};
|
|
19
|
+
export declare abstract class ModuleContainer<Modules extends ModulesRecord, Config extends ModulesConfig<Modules>> {
|
|
20
|
+
definition: {
|
|
21
|
+
modules: Modules;
|
|
22
|
+
config?: Config;
|
|
23
|
+
};
|
|
24
|
+
static moduleDecorationFrequency: Frequency;
|
|
25
|
+
container: import("tsyringe").DependencyContainer;
|
|
26
|
+
constructor(definition: {
|
|
27
|
+
modules: Modules;
|
|
28
|
+
config?: Config;
|
|
29
|
+
});
|
|
30
|
+
get moduleNames(): string[];
|
|
31
|
+
validateModule<ModuleName extends keyof Modules>(moduleName: ModuleName | string, containedModule: ConfigurableModule<unknown>): void;
|
|
32
|
+
registerModules(modules: Modules): void;
|
|
33
|
+
registerValue<Value>(modules: Record<string, Value>): void;
|
|
34
|
+
configure(config: Config): void;
|
|
35
|
+
resolve<ModuleName extends keyof Modules>(moduleName: ModuleName): InstanceType<Modules[ModuleName]>;
|
|
36
|
+
moduleNameToString<ModuleName extends keyof Modules>(moduleName: ModuleName | string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Override this in the child class to provide custom
|
|
39
|
+
* features or module checks
|
|
40
|
+
*/
|
|
41
|
+
decorateModule<ModuleName extends keyof Modules>(moduleName: ModuleName | string, containedModule: InstanceType<Modules[ModuleName]>): void;
|
|
42
|
+
onAfterModuleResolution<ModuleName extends keyof Modules>(moduleName: ModuleName | string): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ModuleContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleContainer.d.ts","sourceRoot":"","sources":["../../src/config/ModuleContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAExE,eAAO,MAAM,MAAM;+BACU,MAAM;0CAKK,MAAM;wCAKR,YAAY,OAAO,CAAC;yCAMnB,eAAe,OAAO,CAAC;4CAIpB,MAAM;2CAIP,MAAM,QAAQ,MAAM;CAM5D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1E,MAAM,WAAW,aAAa,CAC5B,UAAU,SAAS,cAAc,GAAG,cAAc;IAElD,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,aAAa,IAAI;KACxD,SAAS,IAAI,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;CACzE,CAAC;AAEF,8BAAsB,eAAe,CACnC,OAAO,SAAS,aAAa,EAC7B,MAAM,SAAS,aAAa,CAAC,OAAO,CAAC;IAO5B,UAAU,EAAE;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IARH,OAAc,yBAAyB,EAAE,SAAS,CAAU;IAErD,SAAS,yCAAoC;gBAG3C,UAAU,EAAE;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAKH,IAAW,WAAW,aAErB;IAEM,cAAc,CAAC,UAAU,SAAS,MAAM,OAAO,EACpD,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,eAAe,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAC3C,IAAI;IAsBA,eAAe,CAAC,OAAO,EAAE,OAAO;IAahC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAMnD,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,OAAO,CAAC,UAAU,SAAS,MAAM,OAAO,EAC7C,UAAU,EAAE,UAAU,GACrB,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAI7B,kBAAkB,CAAC,UAAU,SAAS,MAAM,OAAO,EACxD,UAAU,EAAE,UAAU,GAAG,MAAM,GAC9B,MAAM;IAQT;;;OAGG;IACI,cAAc,CAAC,UAAU,SAAS,MAAM,OAAO,EACpD,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAa7C,uBAAuB,CAAC,UAAU,SAAS,MAAM,OAAO,EAC7D,UAAU,EAAE,UAAU,GAAG,MAAM;CAclC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { container, Lifecycle } from "tsyringe";
|
|
2
|
+
export const errors = {
|
|
3
|
+
configNotSet: (moduleName) => new Error(`Trying to retrieve config of ${moduleName}, which was not yet set`),
|
|
4
|
+
configNotSetInContainer: (moduleName) => new Error(`Trying to set config of ${moduleName}, but it was not yet set in the module container`),
|
|
5
|
+
onlyStringModuleNames: (moduleName) => new Error(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
7
|
+
`Only string module names, using ${typeof moduleName} instead: ${moduleName.toString()}`),
|
|
8
|
+
unableToDecorateModule: (moduleName) =>
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
10
|
+
new Error(`Unable to decorate module ${moduleName.toString()}`),
|
|
11
|
+
nonModuleDependecy: (runtimeModuleName) => new Error(`
|
|
12
|
+
Unable to register module: ${runtimeModuleName}, attempting to inject a non-module dependency`),
|
|
13
|
+
unknownDependency: (runtimeModuleName, name) => new Error(`Unable to register module: ${runtimeModuleName},
|
|
14
|
+
attempting to inject a dependency that is not registred
|
|
15
|
+
as a runtime module for this chain: ${name}`),
|
|
16
|
+
};
|
|
17
|
+
export class ModuleContainer {
|
|
18
|
+
constructor(definition) {
|
|
19
|
+
this.definition = definition;
|
|
20
|
+
this.container = container.createChildContainer();
|
|
21
|
+
this.registerModules(definition.modules);
|
|
22
|
+
}
|
|
23
|
+
get moduleNames() {
|
|
24
|
+
return Object.keys(this.definition.modules);
|
|
25
|
+
}
|
|
26
|
+
validateModule(moduleName, containedModule) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
28
|
+
const dependencies = Reflect.getMetadata("design:paramtypes", containedModule);
|
|
29
|
+
dependencies?.forEach((dependency) => {
|
|
30
|
+
const name = typeof dependency === "string" ? dependency : dependency.name;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
32
|
+
if (!name) {
|
|
33
|
+
throw errors.nonModuleDependecy(this.moduleNameToString(moduleName));
|
|
34
|
+
}
|
|
35
|
+
if (!this.moduleNames.includes(name)) {
|
|
36
|
+
throw errors.unknownDependency(this.moduleNameToString(moduleName), name);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
registerModules(modules) {
|
|
41
|
+
for (const moduleName in modules) {
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(modules, moduleName)) {
|
|
43
|
+
this.container.register(moduleName, { useClass: modules[moduleName] }, { lifecycle: Lifecycle.ContainerScoped });
|
|
44
|
+
this.onAfterModuleResolution(moduleName);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
registerValue(modules) {
|
|
49
|
+
Object.entries(modules).forEach(([moduleName, useValue]) => {
|
|
50
|
+
this.container.register(moduleName, { useValue });
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
configure(config) {
|
|
54
|
+
this.definition.config = config;
|
|
55
|
+
}
|
|
56
|
+
resolve(moduleName) {
|
|
57
|
+
return this.container.resolve(this.moduleNameToString(moduleName));
|
|
58
|
+
}
|
|
59
|
+
moduleNameToString(moduleName) {
|
|
60
|
+
if (typeof moduleName !== "string") {
|
|
61
|
+
throw errors.onlyStringModuleNames(moduleName);
|
|
62
|
+
}
|
|
63
|
+
return moduleName;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Override this in the child class to provide custom
|
|
67
|
+
* features or module checks
|
|
68
|
+
*/
|
|
69
|
+
decorateModule(moduleName, containedModule) {
|
|
70
|
+
const moduleNameString = this.moduleNameToString(moduleName);
|
|
71
|
+
const config = this.definition.config?.[moduleNameString];
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
73
|
+
if (!config) {
|
|
74
|
+
throw errors.configNotSetInContainer(moduleNameString);
|
|
75
|
+
}
|
|
76
|
+
containedModule.config = config;
|
|
77
|
+
}
|
|
78
|
+
onAfterModuleResolution(moduleName) {
|
|
79
|
+
this.container.afterResolution(
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
81
|
+
moduleName, (containedModuleName, containedModule) => {
|
|
82
|
+
if (Array.isArray(containedModule)) {
|
|
83
|
+
throw errors.unableToDecorateModule(containedModuleName);
|
|
84
|
+
}
|
|
85
|
+
this.decorateModule(moduleName, containedModule);
|
|
86
|
+
}, { frequency: ModuleContainer.moduleDecorationFrequency });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
ModuleContainer.moduleDecorationFrequency = "Once";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./utils/ProvableHashList";
|
|
2
|
+
export * from "./model/StateTransition";
|
|
3
|
+
export * from "./model/StateTransitionProvableBatch";
|
|
4
|
+
export * from "./model/Option";
|
|
5
|
+
export * from "./model/Path";
|
|
6
|
+
export * from "./model/network/NetworkState";
|
|
7
|
+
export * from "./model/transaction/ProtocolTransaction";
|
|
8
|
+
export * from "./model/transaction/RuntimeTransaction";
|
|
9
|
+
export * from "./utils/PrefixedProvableHashList.js";
|
|
10
|
+
export * from "./utils/utils";
|
|
11
|
+
export * from "./prover/block/BlockProver";
|
|
12
|
+
export * from "./prover/block/BlockProvable";
|
|
13
|
+
export * from "./prover/statetransition/StateTransitionProver";
|
|
14
|
+
export * from "./prover/statetransition/StateTransitionProvable";
|
|
15
|
+
export * from "./prover/statetransition/StateTransitionWitnessProvider";
|
|
16
|
+
export * from "./utils/merkletree/MerkleTreeStore";
|
|
17
|
+
export * from "./utils/merkletree/InMemoryMerkleTreeStorage";
|
|
18
|
+
export * from "./utils/merkletree/RollupMerkleTree";
|
|
19
|
+
export * from "./model/MethodPublicOutput";
|
|
20
|
+
export * from "./prover/statetransition/StateTransitionWitnessProviderReference";
|
|
21
|
+
export * from "./protocol/Protocol";
|
|
22
|
+
export * from "./protocol/ProtocolModule";
|
|
23
|
+
export { constants as ProtocolConstants } from "./Constants";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kDAAkD,CAAC;AACjE,cAAc,yDAAyD,CAAC;AACxE,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kEAAkE,CAAC;AACjF,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./utils/ProvableHashList";
|
|
2
|
+
export * from "./model/StateTransition";
|
|
3
|
+
export * from "./model/StateTransitionProvableBatch";
|
|
4
|
+
export * from "./model/Option";
|
|
5
|
+
export * from "./model/Path";
|
|
6
|
+
export * from "./model/network/NetworkState";
|
|
7
|
+
export * from "./model/transaction/ProtocolTransaction";
|
|
8
|
+
export * from "./model/transaction/RuntimeTransaction";
|
|
9
|
+
export * from "./utils/PrefixedProvableHashList.js";
|
|
10
|
+
export * from "./utils/utils";
|
|
11
|
+
export * from "./prover/block/BlockProver";
|
|
12
|
+
export * from "./prover/block/BlockProvable";
|
|
13
|
+
export * from "./prover/statetransition/StateTransitionProver";
|
|
14
|
+
export * from "./prover/statetransition/StateTransitionProvable";
|
|
15
|
+
export * from "./prover/statetransition/StateTransitionWitnessProvider";
|
|
16
|
+
export * from "./utils/merkletree/MerkleTreeStore";
|
|
17
|
+
export * from "./utils/merkletree/InMemoryMerkleTreeStorage";
|
|
18
|
+
export * from "./utils/merkletree/RollupMerkleTree";
|
|
19
|
+
export * from "./model/MethodPublicOutput";
|
|
20
|
+
export * from "./prover/statetransition/StateTransitionWitnessProviderReference";
|
|
21
|
+
export * from "./protocol/Protocol";
|
|
22
|
+
export * from "./protocol/ProtocolModule";
|
|
23
|
+
export { constants as ProtocolConstants } from "./Constants";
|