@feelyourprotocol/evm 8141.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +690 -0
  3. package/dist/cjs/binaryTreeAccessWitness.d.ts +61 -0
  4. package/dist/cjs/binaryTreeAccessWitness.d.ts.map +1 -0
  5. package/dist/cjs/binaryTreeAccessWitness.js +314 -0
  6. package/dist/cjs/binaryTreeAccessWitness.js.map +1 -0
  7. package/dist/cjs/chunkCache.d.ts +13 -0
  8. package/dist/cjs/chunkCache.d.ts.map +1 -0
  9. package/dist/cjs/chunkCache.js +30 -0
  10. package/dist/cjs/chunkCache.js.map +1 -0
  11. package/dist/cjs/constructors.d.ts +11 -0
  12. package/dist/cjs/constructors.d.ts.map +1 -0
  13. package/dist/cjs/constructors.js +30 -0
  14. package/dist/cjs/constructors.js.map +1 -0
  15. package/dist/cjs/eip7708.d.ts +24 -0
  16. package/dist/cjs/eip7708.d.ts.map +1 -0
  17. package/dist/cjs/eip7708.js +37 -0
  18. package/dist/cjs/eip7708.js.map +1 -0
  19. package/dist/cjs/eof/constants.d.ts +22 -0
  20. package/dist/cjs/eof/constants.d.ts.map +1 -0
  21. package/dist/cjs/eof/constants.js +31 -0
  22. package/dist/cjs/eof/constants.js.map +1 -0
  23. package/dist/cjs/eof/container.d.ts +87 -0
  24. package/dist/cjs/eof/container.d.ts.map +1 -0
  25. package/dist/cjs/eof/container.js +380 -0
  26. package/dist/cjs/eof/container.js.map +1 -0
  27. package/dist/cjs/eof/errors.d.ts +66 -0
  28. package/dist/cjs/eof/errors.d.ts.map +1 -0
  29. package/dist/cjs/eof/errors.js +200 -0
  30. package/dist/cjs/eof/errors.js.map +1 -0
  31. package/dist/cjs/eof/setup.d.ts +9 -0
  32. package/dist/cjs/eof/setup.d.ts.map +1 -0
  33. package/dist/cjs/eof/setup.js +26 -0
  34. package/dist/cjs/eof/setup.js.map +1 -0
  35. package/dist/cjs/eof/stackDelta.d.ts +10 -0
  36. package/dist/cjs/eof/stackDelta.d.ts.map +1 -0
  37. package/dist/cjs/eof/stackDelta.js +164 -0
  38. package/dist/cjs/eof/stackDelta.js.map +1 -0
  39. package/dist/cjs/eof/util.d.ts +8 -0
  40. package/dist/cjs/eof/util.d.ts.map +1 -0
  41. package/dist/cjs/eof/util.js +18 -0
  42. package/dist/cjs/eof/util.js.map +1 -0
  43. package/dist/cjs/eof/verify.d.ts +38 -0
  44. package/dist/cjs/eof/verify.d.ts.map +1 -0
  45. package/dist/cjs/eof/verify.js +436 -0
  46. package/dist/cjs/eof/verify.js.map +1 -0
  47. package/dist/cjs/errors.d.ts +40 -0
  48. package/dist/cjs/errors.d.ts.map +1 -0
  49. package/dist/cjs/errors.js +43 -0
  50. package/dist/cjs/errors.js.map +1 -0
  51. package/dist/cjs/evm.d.ts +181 -0
  52. package/dist/cjs/evm.d.ts.map +1 -0
  53. package/dist/cjs/evm.js +1142 -0
  54. package/dist/cjs/evm.js.map +1 -0
  55. package/dist/cjs/frameContext.d.ts +50 -0
  56. package/dist/cjs/frameContext.d.ts.map +1 -0
  57. package/dist/cjs/frameContext.js +17 -0
  58. package/dist/cjs/frameContext.js.map +1 -0
  59. package/dist/cjs/index.d.ts +18 -0
  60. package/dist/cjs/index.d.ts.map +1 -0
  61. package/dist/cjs/index.js +43 -0
  62. package/dist/cjs/index.js.map +1 -0
  63. package/dist/cjs/interpreter.d.ts +361 -0
  64. package/dist/cjs/interpreter.d.ts.map +1 -0
  65. package/dist/cjs/interpreter.js +1057 -0
  66. package/dist/cjs/interpreter.js.map +1 -0
  67. package/dist/cjs/journal.d.ts +69 -0
  68. package/dist/cjs/journal.d.ts.map +1 -0
  69. package/dist/cjs/journal.js +247 -0
  70. package/dist/cjs/journal.js.map +1 -0
  71. package/dist/cjs/logger.d.ts +38 -0
  72. package/dist/cjs/logger.d.ts.map +1 -0
  73. package/dist/cjs/logger.js +126 -0
  74. package/dist/cjs/logger.js.map +1 -0
  75. package/dist/cjs/memory.d.ts +29 -0
  76. package/dist/cjs/memory.d.ts.map +1 -0
  77. package/dist/cjs/memory.js +75 -0
  78. package/dist/cjs/memory.js.map +1 -0
  79. package/dist/cjs/message.d.ts +70 -0
  80. package/dist/cjs/message.d.ts.map +1 -0
  81. package/dist/cjs/message.js +51 -0
  82. package/dist/cjs/message.js.map +1 -0
  83. package/dist/cjs/opcodes/EIP1283.d.ts +13 -0
  84. package/dist/cjs/opcodes/EIP1283.d.ts.map +1 -0
  85. package/dist/cjs/opcodes/EIP1283.js +58 -0
  86. package/dist/cjs/opcodes/EIP1283.js.map +1 -0
  87. package/dist/cjs/opcodes/EIP2200.d.ts +13 -0
  88. package/dist/cjs/opcodes/EIP2200.d.ts.map +1 -0
  89. package/dist/cjs/opcodes/EIP2200.js +64 -0
  90. package/dist/cjs/opcodes/EIP2200.js.map +1 -0
  91. package/dist/cjs/opcodes/EIP2929.d.ts +68 -0
  92. package/dist/cjs/opcodes/EIP2929.d.ts.map +1 -0
  93. package/dist/cjs/opcodes/EIP2929.js +146 -0
  94. package/dist/cjs/opcodes/EIP2929.js.map +1 -0
  95. package/dist/cjs/opcodes/codes.d.ts +45 -0
  96. package/dist/cjs/opcodes/codes.d.ts.map +1 -0
  97. package/dist/cjs/opcodes/codes.js +453 -0
  98. package/dist/cjs/opcodes/codes.js.map +1 -0
  99. package/dist/cjs/opcodes/functions.d.ts +11 -0
  100. package/dist/cjs/opcodes/functions.d.ts.map +1 -0
  101. package/dist/cjs/opcodes/functions.js +1778 -0
  102. package/dist/cjs/opcodes/functions.js.map +1 -0
  103. package/dist/cjs/opcodes/gas.d.ts +15 -0
  104. package/dist/cjs/opcodes/gas.d.ts.map +1 -0
  105. package/dist/cjs/opcodes/gas.js +1016 -0
  106. package/dist/cjs/opcodes/gas.js.map +1 -0
  107. package/dist/cjs/opcodes/index.d.ts +4 -0
  108. package/dist/cjs/opcodes/index.d.ts.map +1 -0
  109. package/dist/cjs/opcodes/index.js +20 -0
  110. package/dist/cjs/opcodes/index.js.map +1 -0
  111. package/dist/cjs/opcodes/util.d.ts +86 -0
  112. package/dist/cjs/opcodes/util.d.ts.map +1 -0
  113. package/dist/cjs/opcodes/util.js +281 -0
  114. package/dist/cjs/opcodes/util.js.map +1 -0
  115. package/dist/cjs/package.json +3 -0
  116. package/dist/cjs/params.d.ts +3 -0
  117. package/dist/cjs/params.d.ts.map +1 -0
  118. package/dist/cjs/params.js +424 -0
  119. package/dist/cjs/params.js.map +1 -0
  120. package/dist/cjs/precompiles/01-ecrecover.d.ts +4 -0
  121. package/dist/cjs/precompiles/01-ecrecover.d.ts.map +1 -0
  122. package/dist/cjs/precompiles/01-ecrecover.js +58 -0
  123. package/dist/cjs/precompiles/01-ecrecover.js.map +1 -0
  124. package/dist/cjs/precompiles/02-sha256.d.ts +4 -0
  125. package/dist/cjs/precompiles/02-sha256.d.ts.map +1 -0
  126. package/dist/cjs/precompiles/02-sha256.js +27 -0
  127. package/dist/cjs/precompiles/02-sha256.js.map +1 -0
  128. package/dist/cjs/precompiles/03-ripemd160.d.ts +4 -0
  129. package/dist/cjs/precompiles/03-ripemd160.d.ts.map +1 -0
  130. package/dist/cjs/precompiles/03-ripemd160.js +26 -0
  131. package/dist/cjs/precompiles/03-ripemd160.js.map +1 -0
  132. package/dist/cjs/precompiles/04-identity.d.ts +4 -0
  133. package/dist/cjs/precompiles/04-identity.d.ts.map +1 -0
  134. package/dist/cjs/precompiles/04-identity.js +24 -0
  135. package/dist/cjs/precompiles/04-identity.js.map +1 -0
  136. package/dist/cjs/precompiles/05-modexp.d.ts +5 -0
  137. package/dist/cjs/precompiles/05-modexp.d.ts.map +1 -0
  138. package/dist/cjs/precompiles/05-modexp.js +185 -0
  139. package/dist/cjs/precompiles/05-modexp.js.map +1 -0
  140. package/dist/cjs/precompiles/06-bn254-add.d.ts +4 -0
  141. package/dist/cjs/precompiles/06-bn254-add.d.ts.map +1 -0
  142. package/dist/cjs/precompiles/06-bn254-add.js +42 -0
  143. package/dist/cjs/precompiles/06-bn254-add.js.map +1 -0
  144. package/dist/cjs/precompiles/07-bn254-mul.d.ts +4 -0
  145. package/dist/cjs/precompiles/07-bn254-mul.d.ts.map +1 -0
  146. package/dist/cjs/precompiles/07-bn254-mul.js +43 -0
  147. package/dist/cjs/precompiles/07-bn254-mul.js.map +1 -0
  148. package/dist/cjs/precompiles/08-bn254-pairing.d.ts +4 -0
  149. package/dist/cjs/precompiles/08-bn254-pairing.d.ts.map +1 -0
  150. package/dist/cjs/precompiles/08-bn254-pairing.js +45 -0
  151. package/dist/cjs/precompiles/08-bn254-pairing.js.map +1 -0
  152. package/dist/cjs/precompiles/09-blake2f.d.ts +5 -0
  153. package/dist/cjs/precompiles/09-blake2f.d.ts.map +1 -0
  154. package/dist/cjs/precompiles/09-blake2f.js +201 -0
  155. package/dist/cjs/precompiles/09-blake2f.js.map +1 -0
  156. package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
  157. package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
  158. package/dist/cjs/precompiles/0a-kzg-point-evaluation.js +68 -0
  159. package/dist/cjs/precompiles/0a-kzg-point-evaluation.js.map +1 -0
  160. package/dist/cjs/precompiles/0b-bls12-g1add.d.ts +4 -0
  161. package/dist/cjs/precompiles/0b-bls12-g1add.d.ts.map +1 -0
  162. package/dist/cjs/precompiles/0b-bls12-g1add.js +49 -0
  163. package/dist/cjs/precompiles/0b-bls12-g1add.js.map +1 -0
  164. package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts +4 -0
  165. package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
  166. package/dist/cjs/precompiles/0c-bls12-g1msm.js +62 -0
  167. package/dist/cjs/precompiles/0c-bls12-g1msm.js.map +1 -0
  168. package/dist/cjs/precompiles/0d-bls12-g2add.d.ts +4 -0
  169. package/dist/cjs/precompiles/0d-bls12-g2add.d.ts.map +1 -0
  170. package/dist/cjs/precompiles/0d-bls12-g2add.js +51 -0
  171. package/dist/cjs/precompiles/0d-bls12-g2add.js.map +1 -0
  172. package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts +4 -0
  173. package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
  174. package/dist/cjs/precompiles/0e-bls12-g2msm.js +60 -0
  175. package/dist/cjs/precompiles/0e-bls12-g2msm.js.map +1 -0
  176. package/dist/cjs/precompiles/0f-bls12-pairing.d.ts +4 -0
  177. package/dist/cjs/precompiles/0f-bls12-pairing.d.ts.map +1 -0
  178. package/dist/cjs/precompiles/0f-bls12-pairing.js +66 -0
  179. package/dist/cjs/precompiles/0f-bls12-pairing.js.map +1 -0
  180. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
  181. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
  182. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js +44 -0
  183. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
  184. package/dist/cjs/precompiles/100-p256verify.d.ts +4 -0
  185. package/dist/cjs/precompiles/100-p256verify.d.ts.map +1 -0
  186. package/dist/cjs/precompiles/100-p256verify.js +131 -0
  187. package/dist/cjs/precompiles/100-p256verify.js.map +1 -0
  188. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
  189. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
  190. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js +47 -0
  191. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
  192. package/dist/cjs/precompiles/bls12_381/constants.d.ts +10 -0
  193. package/dist/cjs/precompiles/bls12_381/constants.d.ts.map +1 -0
  194. package/dist/cjs/precompiles/bls12_381/constants.js +274 -0
  195. package/dist/cjs/precompiles/bls12_381/constants.js.map +1 -0
  196. package/dist/cjs/precompiles/bls12_381/index.d.ts +5 -0
  197. package/dist/cjs/precompiles/bls12_381/index.d.ts.map +1 -0
  198. package/dist/cjs/precompiles/bls12_381/index.js +24 -0
  199. package/dist/cjs/precompiles/bls12_381/index.js.map +1 -0
  200. package/dist/cjs/precompiles/bls12_381/mcl.d.ts +45 -0
  201. package/dist/cjs/precompiles/bls12_381/mcl.d.ts.map +1 -0
  202. package/dist/cjs/precompiles/bls12_381/mcl.js +264 -0
  203. package/dist/cjs/precompiles/bls12_381/mcl.js.map +1 -0
  204. package/dist/cjs/precompiles/bls12_381/noble.d.ts +39 -0
  205. package/dist/cjs/precompiles/bls12_381/noble.d.ts.map +1 -0
  206. package/dist/cjs/precompiles/bls12_381/noble.js +228 -0
  207. package/dist/cjs/precompiles/bls12_381/noble.js.map +1 -0
  208. package/dist/cjs/precompiles/bls12_381/util.d.ts +35 -0
  209. package/dist/cjs/precompiles/bls12_381/util.d.ts.map +1 -0
  210. package/dist/cjs/precompiles/bls12_381/util.js +68 -0
  211. package/dist/cjs/precompiles/bls12_381/util.js.map +1 -0
  212. package/dist/cjs/precompiles/bn254/index.d.ts +3 -0
  213. package/dist/cjs/precompiles/bn254/index.d.ts.map +1 -0
  214. package/dist/cjs/precompiles/bn254/index.js +8 -0
  215. package/dist/cjs/precompiles/bn254/index.js.map +1 -0
  216. package/dist/cjs/precompiles/bn254/noble.d.ts +13 -0
  217. package/dist/cjs/precompiles/bn254/noble.d.ts.map +1 -0
  218. package/dist/cjs/precompiles/bn254/noble.js +124 -0
  219. package/dist/cjs/precompiles/bn254/noble.js.map +1 -0
  220. package/dist/cjs/precompiles/bn254/rustbn.d.ts +16 -0
  221. package/dist/cjs/precompiles/bn254/rustbn.d.ts.map +1 -0
  222. package/dist/cjs/precompiles/bn254/rustbn.js +33 -0
  223. package/dist/cjs/precompiles/bn254/rustbn.js.map +1 -0
  224. package/dist/cjs/precompiles/index.d.ts +67 -0
  225. package/dist/cjs/precompiles/index.d.ts.map +1 -0
  226. package/dist/cjs/precompiles/index.js +262 -0
  227. package/dist/cjs/precompiles/index.js.map +1 -0
  228. package/dist/cjs/precompiles/types.d.ts +13 -0
  229. package/dist/cjs/precompiles/types.d.ts.map +1 -0
  230. package/dist/cjs/precompiles/types.js +3 -0
  231. package/dist/cjs/precompiles/types.js.map +1 -0
  232. package/dist/cjs/precompiles/util.d.ts +30 -0
  233. package/dist/cjs/precompiles/util.d.ts.map +1 -0
  234. package/dist/cjs/precompiles/util.js +63 -0
  235. package/dist/cjs/precompiles/util.js.map +1 -0
  236. package/dist/cjs/stack.d.ts +55 -0
  237. package/dist/cjs/stack.d.ts.map +1 -0
  238. package/dist/cjs/stack.js +143 -0
  239. package/dist/cjs/stack.js.map +1 -0
  240. package/dist/cjs/stemCache.d.ts +20 -0
  241. package/dist/cjs/stemCache.d.ts.map +1 -0
  242. package/dist/cjs/stemCache.js +37 -0
  243. package/dist/cjs/stemCache.js.map +1 -0
  244. package/dist/cjs/transientStorage.d.ts +54 -0
  245. package/dist/cjs/transientStorage.d.ts.map +1 -0
  246. package/dist/cjs/transientStorage.js +113 -0
  247. package/dist/cjs/transientStorage.js.map +1 -0
  248. package/dist/cjs/types.d.ts +465 -0
  249. package/dist/cjs/types.d.ts.map +1 -0
  250. package/dist/cjs/types.js +28 -0
  251. package/dist/cjs/types.js.map +1 -0
  252. package/dist/esm/binaryTreeAccessWitness.d.ts +61 -0
  253. package/dist/esm/binaryTreeAccessWitness.d.ts.map +1 -0
  254. package/dist/esm/binaryTreeAccessWitness.js +308 -0
  255. package/dist/esm/binaryTreeAccessWitness.js.map +1 -0
  256. package/dist/esm/chunkCache.d.ts +13 -0
  257. package/dist/esm/chunkCache.d.ts.map +1 -0
  258. package/dist/esm/chunkCache.js +26 -0
  259. package/dist/esm/chunkCache.js.map +1 -0
  260. package/dist/esm/constructors.d.ts +11 -0
  261. package/dist/esm/constructors.d.ts.map +1 -0
  262. package/dist/esm/constructors.js +27 -0
  263. package/dist/esm/constructors.js.map +1 -0
  264. package/dist/esm/eip7708.d.ts +24 -0
  265. package/dist/esm/eip7708.d.ts.map +1 -0
  266. package/dist/esm/eip7708.js +32 -0
  267. package/dist/esm/eip7708.js.map +1 -0
  268. package/dist/esm/eof/constants.d.ts +22 -0
  269. package/dist/esm/eof/constants.d.ts.map +1 -0
  270. package/dist/esm/eof/constants.js +28 -0
  271. package/dist/esm/eof/constants.js.map +1 -0
  272. package/dist/esm/eof/container.d.ts +87 -0
  273. package/dist/esm/eof/container.d.ts.map +1 -0
  274. package/dist/esm/eof/container.js +375 -0
  275. package/dist/esm/eof/container.js.map +1 -0
  276. package/dist/esm/eof/errors.d.ts +66 -0
  277. package/dist/esm/eof/errors.d.ts.map +1 -0
  278. package/dist/esm/eof/errors.js +195 -0
  279. package/dist/esm/eof/errors.js.map +1 -0
  280. package/dist/esm/eof/setup.d.ts +9 -0
  281. package/dist/esm/eof/setup.d.ts.map +1 -0
  282. package/dist/esm/eof/setup.js +23 -0
  283. package/dist/esm/eof/setup.js.map +1 -0
  284. package/dist/esm/eof/stackDelta.d.ts +10 -0
  285. package/dist/esm/eof/stackDelta.d.ts.map +1 -0
  286. package/dist/esm/eof/stackDelta.js +161 -0
  287. package/dist/esm/eof/stackDelta.js.map +1 -0
  288. package/dist/esm/eof/util.d.ts +8 -0
  289. package/dist/esm/eof/util.d.ts.map +1 -0
  290. package/dist/esm/eof/util.js +14 -0
  291. package/dist/esm/eof/util.js.map +1 -0
  292. package/dist/esm/eof/verify.d.ts +38 -0
  293. package/dist/esm/eof/verify.d.ts.map +1 -0
  294. package/dist/esm/eof/verify.js +432 -0
  295. package/dist/esm/eof/verify.js.map +1 -0
  296. package/dist/esm/errors.d.ts +40 -0
  297. package/dist/esm/errors.d.ts.map +1 -0
  298. package/dist/esm/errors.js +39 -0
  299. package/dist/esm/errors.js.map +1 -0
  300. package/dist/esm/evm.d.ts +181 -0
  301. package/dist/esm/evm.d.ts.map +1 -0
  302. package/dist/esm/evm.js +1131 -0
  303. package/dist/esm/evm.js.map +1 -0
  304. package/dist/esm/frameContext.d.ts +50 -0
  305. package/dist/esm/frameContext.d.ts.map +1 -0
  306. package/dist/esm/frameContext.js +14 -0
  307. package/dist/esm/frameContext.js.map +1 -0
  308. package/dist/esm/index.d.ts +18 -0
  309. package/dist/esm/index.d.ts.map +1 -0
  310. package/dist/esm/index.js +15 -0
  311. package/dist/esm/index.js.map +1 -0
  312. package/dist/esm/interpreter.d.ts +361 -0
  313. package/dist/esm/interpreter.d.ts.map +1 -0
  314. package/dist/esm/interpreter.js +1054 -0
  315. package/dist/esm/interpreter.js.map +1 -0
  316. package/dist/esm/journal.d.ts +69 -0
  317. package/dist/esm/journal.d.ts.map +1 -0
  318. package/dist/esm/journal.js +243 -0
  319. package/dist/esm/journal.js.map +1 -0
  320. package/dist/esm/logger.d.ts +38 -0
  321. package/dist/esm/logger.d.ts.map +1 -0
  322. package/dist/esm/logger.js +121 -0
  323. package/dist/esm/logger.js.map +1 -0
  324. package/dist/esm/memory.d.ts +29 -0
  325. package/dist/esm/memory.d.ts.map +1 -0
  326. package/dist/esm/memory.js +71 -0
  327. package/dist/esm/memory.js.map +1 -0
  328. package/dist/esm/message.d.ts +70 -0
  329. package/dist/esm/message.d.ts.map +1 -0
  330. package/dist/esm/message.js +47 -0
  331. package/dist/esm/message.js.map +1 -0
  332. package/dist/esm/opcodes/EIP1283.d.ts +13 -0
  333. package/dist/esm/opcodes/EIP1283.d.ts.map +1 -0
  334. package/dist/esm/opcodes/EIP1283.js +55 -0
  335. package/dist/esm/opcodes/EIP1283.js.map +1 -0
  336. package/dist/esm/opcodes/EIP2200.d.ts +13 -0
  337. package/dist/esm/opcodes/EIP2200.d.ts.map +1 -0
  338. package/dist/esm/opcodes/EIP2200.js +61 -0
  339. package/dist/esm/opcodes/EIP2200.js.map +1 -0
  340. package/dist/esm/opcodes/EIP2929.d.ts +68 -0
  341. package/dist/esm/opcodes/EIP2929.d.ts.map +1 -0
  342. package/dist/esm/opcodes/EIP2929.js +138 -0
  343. package/dist/esm/opcodes/EIP2929.js.map +1 -0
  344. package/dist/esm/opcodes/codes.d.ts +45 -0
  345. package/dist/esm/opcodes/codes.d.ts.map +1 -0
  346. package/dist/esm/opcodes/codes.js +448 -0
  347. package/dist/esm/opcodes/codes.js.map +1 -0
  348. package/dist/esm/opcodes/functions.d.ts +11 -0
  349. package/dist/esm/opcodes/functions.d.ts.map +1 -0
  350. package/dist/esm/opcodes/functions.js +1775 -0
  351. package/dist/esm/opcodes/functions.js.map +1 -0
  352. package/dist/esm/opcodes/gas.d.ts +15 -0
  353. package/dist/esm/opcodes/gas.d.ts.map +1 -0
  354. package/dist/esm/opcodes/gas.js +1013 -0
  355. package/dist/esm/opcodes/gas.js.map +1 -0
  356. package/dist/esm/opcodes/index.d.ts +4 -0
  357. package/dist/esm/opcodes/index.d.ts.map +1 -0
  358. package/dist/esm/opcodes/index.js +4 -0
  359. package/dist/esm/opcodes/index.js.map +1 -0
  360. package/dist/esm/opcodes/util.d.ts +86 -0
  361. package/dist/esm/opcodes/util.d.ts.map +1 -0
  362. package/dist/esm/opcodes/util.js +257 -0
  363. package/dist/esm/opcodes/util.js.map +1 -0
  364. package/dist/esm/package.json +3 -0
  365. package/dist/esm/params.d.ts +3 -0
  366. package/dist/esm/params.d.ts.map +1 -0
  367. package/dist/esm/params.js +421 -0
  368. package/dist/esm/params.js.map +1 -0
  369. package/dist/esm/precompiles/01-ecrecover.d.ts +4 -0
  370. package/dist/esm/precompiles/01-ecrecover.d.ts.map +1 -0
  371. package/dist/esm/precompiles/01-ecrecover.js +55 -0
  372. package/dist/esm/precompiles/01-ecrecover.js.map +1 -0
  373. package/dist/esm/precompiles/02-sha256.d.ts +4 -0
  374. package/dist/esm/precompiles/02-sha256.d.ts.map +1 -0
  375. package/dist/esm/precompiles/02-sha256.js +24 -0
  376. package/dist/esm/precompiles/02-sha256.js.map +1 -0
  377. package/dist/esm/precompiles/03-ripemd160.d.ts +4 -0
  378. package/dist/esm/precompiles/03-ripemd160.d.ts.map +1 -0
  379. package/dist/esm/precompiles/03-ripemd160.js +23 -0
  380. package/dist/esm/precompiles/03-ripemd160.js.map +1 -0
  381. package/dist/esm/precompiles/04-identity.d.ts +4 -0
  382. package/dist/esm/precompiles/04-identity.d.ts.map +1 -0
  383. package/dist/esm/precompiles/04-identity.js +21 -0
  384. package/dist/esm/precompiles/04-identity.js.map +1 -0
  385. package/dist/esm/precompiles/05-modexp.d.ts +5 -0
  386. package/dist/esm/precompiles/05-modexp.d.ts.map +1 -0
  387. package/dist/esm/precompiles/05-modexp.js +181 -0
  388. package/dist/esm/precompiles/05-modexp.js.map +1 -0
  389. package/dist/esm/precompiles/06-bn254-add.d.ts +4 -0
  390. package/dist/esm/precompiles/06-bn254-add.d.ts.map +1 -0
  391. package/dist/esm/precompiles/06-bn254-add.js +39 -0
  392. package/dist/esm/precompiles/06-bn254-add.js.map +1 -0
  393. package/dist/esm/precompiles/07-bn254-mul.d.ts +4 -0
  394. package/dist/esm/precompiles/07-bn254-mul.d.ts.map +1 -0
  395. package/dist/esm/precompiles/07-bn254-mul.js +40 -0
  396. package/dist/esm/precompiles/07-bn254-mul.js.map +1 -0
  397. package/dist/esm/precompiles/08-bn254-pairing.d.ts +4 -0
  398. package/dist/esm/precompiles/08-bn254-pairing.d.ts.map +1 -0
  399. package/dist/esm/precompiles/08-bn254-pairing.js +42 -0
  400. package/dist/esm/precompiles/08-bn254-pairing.js.map +1 -0
  401. package/dist/esm/precompiles/09-blake2f.d.ts +5 -0
  402. package/dist/esm/precompiles/09-blake2f.d.ts.map +1 -0
  403. package/dist/esm/precompiles/09-blake2f.js +197 -0
  404. package/dist/esm/precompiles/09-blake2f.js.map +1 -0
  405. package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
  406. package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
  407. package/dist/esm/precompiles/0a-kzg-point-evaluation.js +64 -0
  408. package/dist/esm/precompiles/0a-kzg-point-evaluation.js.map +1 -0
  409. package/dist/esm/precompiles/0b-bls12-g1add.d.ts +4 -0
  410. package/dist/esm/precompiles/0b-bls12-g1add.d.ts.map +1 -0
  411. package/dist/esm/precompiles/0b-bls12-g1add.js +46 -0
  412. package/dist/esm/precompiles/0b-bls12-g1add.js.map +1 -0
  413. package/dist/esm/precompiles/0c-bls12-g1msm.d.ts +4 -0
  414. package/dist/esm/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
  415. package/dist/esm/precompiles/0c-bls12-g1msm.js +59 -0
  416. package/dist/esm/precompiles/0c-bls12-g1msm.js.map +1 -0
  417. package/dist/esm/precompiles/0d-bls12-g2add.d.ts +4 -0
  418. package/dist/esm/precompiles/0d-bls12-g2add.d.ts.map +1 -0
  419. package/dist/esm/precompiles/0d-bls12-g2add.js +48 -0
  420. package/dist/esm/precompiles/0d-bls12-g2add.js.map +1 -0
  421. package/dist/esm/precompiles/0e-bls12-g2msm.d.ts +4 -0
  422. package/dist/esm/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
  423. package/dist/esm/precompiles/0e-bls12-g2msm.js +57 -0
  424. package/dist/esm/precompiles/0e-bls12-g2msm.js.map +1 -0
  425. package/dist/esm/precompiles/0f-bls12-pairing.d.ts +4 -0
  426. package/dist/esm/precompiles/0f-bls12-pairing.d.ts.map +1 -0
  427. package/dist/esm/precompiles/0f-bls12-pairing.js +63 -0
  428. package/dist/esm/precompiles/0f-bls12-pairing.js.map +1 -0
  429. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
  430. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
  431. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js +41 -0
  432. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
  433. package/dist/esm/precompiles/100-p256verify.d.ts +4 -0
  434. package/dist/esm/precompiles/100-p256verify.d.ts.map +1 -0
  435. package/dist/esm/precompiles/100-p256verify.js +128 -0
  436. package/dist/esm/precompiles/100-p256verify.js.map +1 -0
  437. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
  438. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
  439. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js +44 -0
  440. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
  441. package/dist/esm/precompiles/bls12_381/constants.d.ts +10 -0
  442. package/dist/esm/precompiles/bls12_381/constants.d.ts.map +1 -0
  443. package/dist/esm/precompiles/bls12_381/constants.js +271 -0
  444. package/dist/esm/precompiles/bls12_381/constants.js.map +1 -0
  445. package/dist/esm/precompiles/bls12_381/index.d.ts +5 -0
  446. package/dist/esm/precompiles/bls12_381/index.d.ts.map +1 -0
  447. package/dist/esm/precompiles/bls12_381/index.js +5 -0
  448. package/dist/esm/precompiles/bls12_381/index.js.map +1 -0
  449. package/dist/esm/precompiles/bls12_381/mcl.d.ts +45 -0
  450. package/dist/esm/precompiles/bls12_381/mcl.d.ts.map +1 -0
  451. package/dist/esm/precompiles/bls12_381/mcl.js +254 -0
  452. package/dist/esm/precompiles/bls12_381/mcl.js.map +1 -0
  453. package/dist/esm/precompiles/bls12_381/noble.d.ts +39 -0
  454. package/dist/esm/precompiles/bls12_381/noble.d.ts.map +1 -0
  455. package/dist/esm/precompiles/bls12_381/noble.js +218 -0
  456. package/dist/esm/precompiles/bls12_381/noble.js.map +1 -0
  457. package/dist/esm/precompiles/bls12_381/util.d.ts +35 -0
  458. package/dist/esm/precompiles/bls12_381/util.d.ts.map +1 -0
  459. package/dist/esm/precompiles/bls12_381/util.js +63 -0
  460. package/dist/esm/precompiles/bls12_381/util.js.map +1 -0
  461. package/dist/esm/precompiles/bn254/index.d.ts +3 -0
  462. package/dist/esm/precompiles/bn254/index.d.ts.map +1 -0
  463. package/dist/esm/precompiles/bn254/index.js +3 -0
  464. package/dist/esm/precompiles/bn254/index.js.map +1 -0
  465. package/dist/esm/precompiles/bn254/noble.d.ts +13 -0
  466. package/dist/esm/precompiles/bn254/noble.d.ts.map +1 -0
  467. package/dist/esm/precompiles/bn254/noble.js +120 -0
  468. package/dist/esm/precompiles/bn254/noble.js.map +1 -0
  469. package/dist/esm/precompiles/bn254/rustbn.d.ts +16 -0
  470. package/dist/esm/precompiles/bn254/rustbn.d.ts.map +1 -0
  471. package/dist/esm/precompiles/bn254/rustbn.js +29 -0
  472. package/dist/esm/precompiles/bn254/rustbn.js.map +1 -0
  473. package/dist/esm/precompiles/index.d.ts +67 -0
  474. package/dist/esm/precompiles/index.d.ts.map +1 -0
  475. package/dist/esm/precompiles/index.js +251 -0
  476. package/dist/esm/precompiles/index.js.map +1 -0
  477. package/dist/esm/precompiles/types.d.ts +13 -0
  478. package/dist/esm/precompiles/types.d.ts.map +1 -0
  479. package/dist/esm/precompiles/types.js +2 -0
  480. package/dist/esm/precompiles/types.js.map +1 -0
  481. package/dist/esm/precompiles/util.d.ts +30 -0
  482. package/dist/esm/precompiles/util.d.ts.map +1 -0
  483. package/dist/esm/precompiles/util.js +57 -0
  484. package/dist/esm/precompiles/util.js.map +1 -0
  485. package/dist/esm/stack.d.ts +55 -0
  486. package/dist/esm/stack.d.ts.map +1 -0
  487. package/dist/esm/stack.js +139 -0
  488. package/dist/esm/stack.js.map +1 -0
  489. package/dist/esm/stemCache.d.ts +20 -0
  490. package/dist/esm/stemCache.d.ts.map +1 -0
  491. package/dist/esm/stemCache.js +33 -0
  492. package/dist/esm/stemCache.js.map +1 -0
  493. package/dist/esm/transientStorage.d.ts +54 -0
  494. package/dist/esm/transientStorage.d.ts.map +1 -0
  495. package/dist/esm/transientStorage.js +109 -0
  496. package/dist/esm/transientStorage.js.map +1 -0
  497. package/dist/esm/types.d.ts +465 -0
  498. package/dist/esm/types.d.ts.map +1 -0
  499. package/dist/esm/types.js +23 -0
  500. package/dist/esm/types.js.map +1 -0
  501. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  502. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  503. package/package.json +98 -0
  504. package/src/binaryTreeAccessWitness.ts +447 -0
  505. package/src/chunkCache.ts +36 -0
  506. package/src/constructors.ts +35 -0
  507. package/src/eip7708.ts +47 -0
  508. package/src/eof/constants.ts +36 -0
  509. package/src/eof/container.ts +495 -0
  510. package/src/eof/errors.ts +214 -0
  511. package/src/eof/setup.ts +27 -0
  512. package/src/eof/stackDelta.ts +169 -0
  513. package/src/eof/util.ts +16 -0
  514. package/src/eof/verify.ts +531 -0
  515. package/src/errors.ts +45 -0
  516. package/src/evm.ts +1415 -0
  517. package/src/frameContext.ts +56 -0
  518. package/src/index.ts +75 -0
  519. package/src/interpreter.ts +1437 -0
  520. package/src/journal.ts +317 -0
  521. package/src/logger.ts +180 -0
  522. package/src/memory.ts +82 -0
  523. package/src/message.ts +114 -0
  524. package/src/opcodes/EIP1283.ts +77 -0
  525. package/src/opcodes/EIP2200.ts +87 -0
  526. package/src/opcodes/EIP2929.ts +173 -0
  527. package/src/opcodes/codes.ts +528 -0
  528. package/src/opcodes/functions.ts +1937 -0
  529. package/src/opcodes/gas.ts +1329 -0
  530. package/src/opcodes/index.ts +3 -0
  531. package/src/opcodes/util.ts +313 -0
  532. package/src/params.ts +423 -0
  533. package/src/precompiles/01-ecrecover.ts +77 -0
  534. package/src/precompiles/02-sha256.ts +32 -0
  535. package/src/precompiles/03-ripemd160.ts +32 -0
  536. package/src/precompiles/04-identity.ts +29 -0
  537. package/src/precompiles/05-modexp.ts +215 -0
  538. package/src/precompiles/06-bn254-add.ts +49 -0
  539. package/src/precompiles/07-bn254-mul.ts +50 -0
  540. package/src/precompiles/08-bn254-pairing.ts +54 -0
  541. package/src/precompiles/09-blake2f.ts +243 -0
  542. package/src/precompiles/0a-kzg-point-evaluation.ts +94 -0
  543. package/src/precompiles/0b-bls12-g1add.ts +63 -0
  544. package/src/precompiles/0c-bls12-g1msm.ts +87 -0
  545. package/src/precompiles/0d-bls12-g2add.ts +66 -0
  546. package/src/precompiles/0e-bls12-g2msm.ts +84 -0
  547. package/src/precompiles/0f-bls12-pairing.ts +86 -0
  548. package/src/precompiles/10-bls12-map-fp-to-g1.ts +58 -0
  549. package/src/precompiles/100-p256verify.ts +152 -0
  550. package/src/precompiles/11-bls12-map-fp2-to-g2.ts +61 -0
  551. package/src/precompiles/bls12_381/constants.ts +278 -0
  552. package/src/precompiles/bls12_381/index.ts +4 -0
  553. package/src/precompiles/bls12_381/mcl.ts +376 -0
  554. package/src/precompiles/bls12_381/noble.ts +307 -0
  555. package/src/precompiles/bls12_381/util.ts +78 -0
  556. package/src/precompiles/bn254/index.ts +2 -0
  557. package/src/precompiles/bn254/noble.ts +156 -0
  558. package/src/precompiles/bn254/rustbn.ts +35 -0
  559. package/src/precompiles/index.ts +344 -0
  560. package/src/precompiles/types.ts +15 -0
  561. package/src/precompiles/util.ts +70 -0
  562. package/src/stack.ts +166 -0
  563. package/src/stemCache.ts +45 -0
  564. package/src/transientStorage.ts +131 -0
  565. package/src/types.ts +538 -0
@@ -0,0 +1,13 @@
1
+ import type { Common } from '@feelyourprotocol/common';
2
+ import type { EVMInterface, ExecResult } from '../types.ts';
3
+ export interface PrecompileFunc {
4
+ (input: PrecompileInput): Promise<ExecResult> | ExecResult;
5
+ }
6
+ export interface PrecompileInput {
7
+ data: Uint8Array;
8
+ gasLimit: bigint;
9
+ common: Common;
10
+ _EVM: EVMInterface;
11
+ _debug?: debug.Debugger;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/precompiles/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE3D,MAAM,WAAW,cAAc;IAC7B,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAA;CAC3D;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,YAAY,CAAA;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAA;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/precompiles/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { PrecompileInput } from './index.ts';
2
+ /**
3
+ * Checks that the gas used remain under the gas limit.
4
+ *
5
+ * @param opts - Precompile input wrapper
6
+ * @param gasUsed - Amount of gas consumed by the precompile
7
+ * @param pName - Human readable precompile name for logging
8
+ * @returns `true` if the gas usage is within the provided limit
9
+ */
10
+ export declare const gasLimitCheck: (opts: PrecompileInput, gasUsed: bigint, pName: string) => boolean;
11
+ /**
12
+ * Checks that the length of the provided data is equal to `length`.
13
+ *
14
+ * @param opts - Precompile input wrapper
15
+ * @param length - Required data length in bytes
16
+ * @param pName - Human readable precompile name for logging
17
+ * @returns `true` if the provided data matches the required length
18
+ */
19
+ export declare const equalityLengthCheck: (opts: PrecompileInput, length: number, pName: string) => boolean;
20
+ /**
21
+ * Checks that the total length of the provided data input can be subdivided into k equal parts
22
+ * with `length` (without leaving some remainder bytes).
23
+ *
24
+ * @param opts - Precompile input wrapper
25
+ * @param length - Required chunk size
26
+ * @param pName - Human readable precompile name for logging
27
+ * @returns `true` if the length is divisible by the chunk size
28
+ */
29
+ export declare const moduloLengthCheck: (opts: PrecompileInput, length: number, pName: string) => boolean;
30
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/precompiles/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,eAAe,EAAE,SAAS,MAAM,EAAE,OAAO,MAAM,YAgBlF,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,eAAe,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,YAUvF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,eAAe,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,YAUrF,CAAA"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moduloLengthCheck = exports.equalityLengthCheck = exports.gasLimitCheck = void 0;
4
+ const util_1 = require("@feelyourprotocol/util");
5
+ /**
6
+ * Checks that the gas used remain under the gas limit.
7
+ *
8
+ * @param opts - Precompile input wrapper
9
+ * @param gasUsed - Amount of gas consumed by the precompile
10
+ * @param pName - Human readable precompile name for logging
11
+ * @returns `true` if the gas usage is within the provided limit
12
+ */
13
+ const gasLimitCheck = (opts, gasUsed, pName) => {
14
+ if (opts._debug !== undefined) {
15
+ opts._debug(`Run ${pName} precompile data=${(0, util_1.short)(opts.data)} length=${opts.data.length} gasLimit=${opts.gasLimit} gasUsed=${gasUsed}`);
16
+ }
17
+ if (opts.gasLimit < gasUsed) {
18
+ if (opts._debug !== undefined) {
19
+ opts._debug(`${pName} failed: OOG`);
20
+ }
21
+ return false;
22
+ }
23
+ return true;
24
+ };
25
+ exports.gasLimitCheck = gasLimitCheck;
26
+ /**
27
+ * Checks that the length of the provided data is equal to `length`.
28
+ *
29
+ * @param opts - Precompile input wrapper
30
+ * @param length - Required data length in bytes
31
+ * @param pName - Human readable precompile name for logging
32
+ * @returns `true` if the provided data matches the required length
33
+ */
34
+ const equalityLengthCheck = (opts, length, pName) => {
35
+ if (opts.data.length !== length) {
36
+ if (opts._debug !== undefined) {
37
+ opts._debug(`${pName} failed: Invalid input length length=${opts.data.length} (expected: ${length})`);
38
+ }
39
+ return false;
40
+ }
41
+ return true;
42
+ };
43
+ exports.equalityLengthCheck = equalityLengthCheck;
44
+ /**
45
+ * Checks that the total length of the provided data input can be subdivided into k equal parts
46
+ * with `length` (without leaving some remainder bytes).
47
+ *
48
+ * @param opts - Precompile input wrapper
49
+ * @param length - Required chunk size
50
+ * @param pName - Human readable precompile name for logging
51
+ * @returns `true` if the length is divisible by the chunk size
52
+ */
53
+ const moduloLengthCheck = (opts, length, pName) => {
54
+ if (opts.data.length % length !== 0) {
55
+ if (opts._debug !== undefined) {
56
+ opts._debug(`${pName} failed: Invalid input length length=${opts.data.length} (expected: ${length}*k bytes)`);
57
+ }
58
+ return false;
59
+ }
60
+ return true;
61
+ };
62
+ exports.moduloLengthCheck = moduloLengthCheck;
63
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/precompiles/util.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAIxC;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAE,OAAe,EAAE,KAAa,EAAE,EAAE;IACrF,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CACT,OAAO,KAAK,oBAAoB,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,CAAC,WAC9C,IAAI,CAAC,IAAI,CAAC,MACZ,aAAa,IAAI,CAAC,QAAQ,YAAY,OAAO,EAAE,CAChD,CAAA;IACH,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,cAAc,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAhBY,QAAA,aAAa,iBAgBzB;AAED;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,IAAqB,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IAC1F,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CACT,GAAG,KAAK,wCAAwC,IAAI,CAAC,IAAI,CAAC,MAAM,eAAe,MAAM,GAAG,CACzF,CAAA;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAVY,QAAA,mBAAmB,uBAU/B;AAED;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,IAAqB,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACxF,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CACT,GAAG,KAAK,wCAAwC,IAAI,CAAC,IAAI,CAAC,MAAM,eAAe,MAAM,WAAW,CACjG,CAAA;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAVY,QAAA,iBAAiB,qBAU7B"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Implementation of the stack used in evm.
3
+ */
4
+ export declare class Stack {
5
+ private _store;
6
+ private _maxHeight;
7
+ private _len;
8
+ constructor(maxHeight?: number);
9
+ get length(): number;
10
+ /**
11
+ * Pushes a new bigint onto the stack.
12
+ * @param value - Value to push (must fit within the configured max height)
13
+ */
14
+ push(value: bigint): void;
15
+ /**
16
+ * Pops the top value from the stack.
17
+ * @returns The value removed from the stack
18
+ */
19
+ pop(): bigint;
20
+ /**
21
+ * Pops multiple items from the stack with the top-most item returned first.
22
+ * @param num - Number of items to pop (defaults to 1)
23
+ * @returns Array containing the popped values
24
+ */
25
+ popN(num?: number): bigint[];
26
+ /**
27
+ * Returns items from the stack without removing them.
28
+ * @param num - Number of items to return (defaults to 1)
29
+ * @returns Array of items, with index 0 representing the top of the stack
30
+ * @throws {@link EVMError} with code STACK_UNDERFLOW if there are not enough items on the stack
31
+ */
32
+ peek(num?: number): bigint[];
33
+ /**
34
+ * Swaps the top of the stack with another item.
35
+ * @param position - Zero-based index from the top of the stack (0 swaps with the top itself)
36
+ */
37
+ swap(position: number): void;
38
+ /**
39
+ * Pushes a copy of an item deeper in the stack.
40
+ * @param position - One-based index of the item to duplicate
41
+ */
42
+ dup(position: number): void;
43
+ /**
44
+ * Swaps two arbitrary entries relative to the top of the stack.
45
+ * @param swap1 - Distance from the top (0 = top element) for the first entry
46
+ * @param swap2 - Distance from the top for the second entry
47
+ */
48
+ exchange(swap1: number, swap2: number): void;
49
+ /**
50
+ * Returns a copy of the current stack. This represents the actual state of the stack
51
+ * (not the internal state of the stack, which might have unreachable elements in it)
52
+ */
53
+ getStack(): bigint[];
54
+ }
55
+ //# sourceMappingURL=stack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/stack.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,KAAK;IAEhB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,UAAU,CAAQ;IAE1B,OAAO,CAAC,IAAI,CAAY;gBAEZ,SAAS,CAAC,EAAE,MAAM;IAO9B,IAAI,MAAM,WAET;IAED;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM;IASlB;;;OAGG;IACH,GAAG,IAAI,MAAM;IAYb;;;;OAIG;IACH,IAAI,CAAC,GAAG,GAAE,MAAU,GAAG,MAAM,EAAE;IAoB/B;;;;;OAKG;IACH,IAAI,CAAC,GAAG,GAAE,MAAU,GAAG,MAAM,EAAE;IAc/B;;;OAGG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM;IAkBrB;;;OAGG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM;IAepB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAerC;;;OAGG;IACH,QAAQ;CAGT"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stack = void 0;
4
+ const errors_ts_1 = require("./errors.js");
5
+ /**
6
+ * Implementation of the stack used in evm.
7
+ */
8
+ class Stack {
9
+ constructor(maxHeight) {
10
+ this._len = 0;
11
+ // It is possible to initialize the array with `maxHeight` items. However,
12
+ // this makes the constructor 10x slower and there do not seem to be any observable performance gains
13
+ this._store = [];
14
+ this._maxHeight = maxHeight ?? 1024;
15
+ }
16
+ get length() {
17
+ return this._len;
18
+ }
19
+ /**
20
+ * Pushes a new bigint onto the stack.
21
+ * @param value - Value to push (must fit within the configured max height)
22
+ */
23
+ push(value) {
24
+ if (this._len >= this._maxHeight) {
25
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_OVERFLOW);
26
+ }
27
+ // Read current length, set `_store` to value, and then increase the length
28
+ this._store[this._len++] = value;
29
+ }
30
+ /**
31
+ * Pops the top value from the stack.
32
+ * @returns The value removed from the stack
33
+ */
34
+ pop() {
35
+ if (this._len < 1) {
36
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
37
+ }
38
+ // Length is checked above, so pop shouldn't return undefined
39
+ // First decrease current length, then read the item and return it
40
+ // Note: this does thus not delete the item from the internal array
41
+ // However, the length is decreased, so it is not accessible to external observers
42
+ return this._store[--this._len];
43
+ }
44
+ /**
45
+ * Pops multiple items from the stack with the top-most item returned first.
46
+ * @param num - Number of items to pop (defaults to 1)
47
+ * @returns Array containing the popped values
48
+ */
49
+ popN(num = 1) {
50
+ if (this._len < num) {
51
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
52
+ }
53
+ if (num === 0) {
54
+ return [];
55
+ }
56
+ const arr = Array(num);
57
+ const cache = this._store;
58
+ for (let pop = 0; pop < num; pop++) {
59
+ // Note: this thus also (correctly) reduces the length of the internal array (without deleting items)
60
+ arr[pop] = cache[--this._len];
61
+ }
62
+ return arr;
63
+ }
64
+ /**
65
+ * Returns items from the stack without removing them.
66
+ * @param num - Number of items to return (defaults to 1)
67
+ * @returns Array of items, with index 0 representing the top of the stack
68
+ * @throws {@link EVMError} with code STACK_UNDERFLOW if there are not enough items on the stack
69
+ */
70
+ peek(num = 1) {
71
+ const peekArray = Array(num);
72
+ let start = this._len;
73
+ for (let peek = 0; peek < num; peek++) {
74
+ const index = --start;
75
+ if (index < 0) {
76
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
77
+ }
78
+ peekArray[peek] = this._store[index];
79
+ }
80
+ return peekArray;
81
+ }
82
+ /**
83
+ * Swaps the top of the stack with another item.
84
+ * @param position - Zero-based index from the top of the stack (0 swaps with the top itself)
85
+ */
86
+ swap(position) {
87
+ if (this._len <= position) {
88
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
89
+ }
90
+ const head = this._len - 1;
91
+ const i = head - position;
92
+ const storageCached = this._store;
93
+ const tmp = storageCached[head];
94
+ storageCached[head] = storageCached[i];
95
+ storageCached[i] = tmp;
96
+ }
97
+ // I would say that we do not need this method any more
98
+ // since you can't copy a primitive data type
99
+ // Nevertheless not sure if we "loose" something here?
100
+ // Will keep commented out for now
101
+ /**
102
+ * Pushes a copy of an item deeper in the stack.
103
+ * @param position - One-based index of the item to duplicate
104
+ */
105
+ dup(position) {
106
+ const len = this._len;
107
+ if (len < position) {
108
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
109
+ }
110
+ // Note: this code is borrowed from `push()` (avoids a call)
111
+ if (len >= this._maxHeight) {
112
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_OVERFLOW);
113
+ }
114
+ const i = len - position;
115
+ this._store[this._len++] = this._store[i];
116
+ }
117
+ /**
118
+ * Swaps two arbitrary entries relative to the top of the stack.
119
+ * @param swap1 - Distance from the top (0 = top element) for the first entry
120
+ * @param swap2 - Distance from the top for the second entry
121
+ */
122
+ exchange(swap1, swap2) {
123
+ const headIndex = this._len - 1;
124
+ const exchangeIndex1 = headIndex - swap1;
125
+ const exchangeIndex2 = headIndex - swap2;
126
+ // Stack underflow is not possible in EOF
127
+ if (exchangeIndex1 < 0 || exchangeIndex2 < 0) {
128
+ throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.STACK_UNDERFLOW);
129
+ }
130
+ const cache = this._store[exchangeIndex2];
131
+ this._store[exchangeIndex2] = this._store[exchangeIndex1];
132
+ this._store[exchangeIndex1] = cache;
133
+ }
134
+ /**
135
+ * Returns a copy of the current stack. This represents the actual state of the stack
136
+ * (not the internal state of the stack, which might have unreachable elements in it)
137
+ */
138
+ getStack() {
139
+ return this._store.slice(0, this._len);
140
+ }
141
+ }
142
+ exports.Stack = Stack;
143
+ //# sourceMappingURL=stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/stack.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAEtC;;GAEG;AACH,MAAa,KAAK;IAOhB,YAAY,SAAkB;QAFtB,SAAI,GAAW,CAAC,CAAA;QAGtB,0EAA0E;QAC1E,qGAAqG;QACrG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,IAAI,IAAI,CAAA;IACrC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,IAAI,C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eta } from './binaryTreeAccessWitness.ts';
3
+ export declare class StemCache {
4
+ cache: Map<PrefixedHexString, BinaryStemAccessEvent & BinaryStemMeta>;
5
+ constructor();
6
+ set(stemKey: PrefixedHexString, accessedStem: BinaryStemAccessEvent & BinaryStemMeta): void;
7
+ get(stemHex: PrefixedHexString): (BinaryStemAccessEvent & BinaryStemMeta) | undefined;
8
+ del(stemHex: PrefixedHexString): void;
9
+ commit(): [PrefixedHexString, BinaryStemAccessEvent & BinaryStemMeta][];
10
+ /**
11
+ * Clear cache
12
+ */
13
+ clear(): void;
14
+ /**
15
+ * Returns the size of the cache
16
+ * @returns Number of cached stems currently stored
17
+ */
18
+ size(): number;
19
+ }
20
+ //# sourceMappingURL=stemCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stemCache.d.ts","sourceRoot":"","sources":["../../src/stemCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAEzF,qBAAa,SAAS;IACpB,KAAK,EAAE,GAAG,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,cAAc,CAAC,CAAA;;IAMrE,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,qBAAqB,GAAG,cAAc;IAIpF,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,CAAC,qBAAqB,GAAG,cAAc,CAAC,GAAG,SAAS;IAIrF,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAIrC,MAAM,IAAI,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,cAAc,CAAC,EAAE;IAQvE;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI;CAGL"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StemCache = void 0;
4
+ class StemCache {
5
+ constructor() {
6
+ this.cache = new Map();
7
+ }
8
+ set(stemKey, accessedStem) {
9
+ this.cache.set(stemKey, accessedStem);
10
+ }
11
+ get(stemHex) {
12
+ return this.cache.get(stemHex);
13
+ }
14
+ del(stemHex) {
15
+ this.cache.delete(stemHex);
16
+ }
17
+ commit() {
18
+ const items = Array.from(this.cache.entries());
19
+ this.clear();
20
+ return items;
21
+ }
22
+ /**
23
+ * Clear cache
24
+ */
25
+ clear() {
26
+ this.cache.clear();
27
+ }
28
+ /**
29
+ * Returns the size of the cache
30
+ * @returns Number of cached stems currently stored
31
+ */
32
+ size() {
33
+ return this.cache.size;
34
+ }
35
+ }
36
+ exports.StemCache = StemCache;
37
+ //# sourceMappingURL=stemCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stemCache.js","sourceRoot":"","sources":["../../src/stemCache.ts"],"names":[],"mappings":";;;AAGA,MAAa,SAAS;IAGpB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAA6D,CAAA;IACnF,CAAC;IAED,GAAG,CAAC,OAA0B,EAAE,YAAoD;QAClF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,OAA0B;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,GAAG,CAAC,OAA0B;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM;QACJ,MAAM,KAAK,GAAkE,KAAK,CAAC,IAAI,CACrF,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CACrB,CAAA;QACD,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;CACF;AAzCD,8BAyCC"}
@@ -0,0 +1,54 @@
1
+ import type { Address } from '@feelyourprotocol/util';
2
+ import type { TransientStorageInterface } from './types.ts';
3
+ export declare class TransientStorage implements TransientStorageInterface {
4
+ /**
5
+ * The current values of the transient storage, keyed by contract address and then slot
6
+ */
7
+ private _storage;
8
+ /**
9
+ * Each change to storage is recorded in the journal. This is never cleared.
10
+ */
11
+ private _changeJournal;
12
+ /**
13
+ * The length of the journal at the beginning of each call in the call stack.
14
+ */
15
+ private _indices;
16
+ /**
17
+ * Get the value for the given address and key
18
+ * @param addr the address for which transient storage is accessed
19
+ * @param key the key of the address to get
20
+ */
21
+ get(addr: Address, key: Uint8Array): Uint8Array;
22
+ /**
23
+ * Put the given value for the address and key
24
+ * @param addr the address of the contract for which the key is being set
25
+ * @param key the slot to set for the address
26
+ * @param value the new value of the transient storage slot to set
27
+ */
28
+ put(addr: Address, key: Uint8Array, value: Uint8Array): void;
29
+ /**
30
+ * Commit all the changes since the last checkpoint
31
+ */
32
+ commit(): void;
33
+ /**
34
+ * To be called whenever entering a new context. If revert is called after checkpoint, all changes after the latest checkpoint are reverted.
35
+ */
36
+ checkpoint(): void;
37
+ /**
38
+ * Revert transient storage to the last checkpoint
39
+ */
40
+ revert(): void;
41
+ /**
42
+ * Create a JSON representation of the current transient storage state
43
+ */
44
+ toJSON(): {
45
+ [address: string]: {
46
+ [key: string]: string;
47
+ };
48
+ };
49
+ /**
50
+ * Clear transient storage state.
51
+ */
52
+ clear(): void;
53
+ }
54
+ //# sourceMappingURL=transientStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transientStorage.d.ts","sourceRoot":"","sources":["../../src/transientStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAY3D,qBAAa,gBAAiB,YAAW,yBAAyB;IAChE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAqC;IACrD;;OAEG;IACH,OAAO,CAAC,cAAc,CAA8B;IACpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAgB;IAEhC;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU;IAYtD;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IA2B5D;;OAEG;IACI,MAAM,IAAI,IAAI;IAMrB;;OAEG;IACI,UAAU,IAAI,IAAI;IAIzB;;OAEG;IACI,MAAM;IAWb;;OAEG;IACI,MAAM,IAAI;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE;IAWjE;;OAEG;IACI,KAAK,IAAI,IAAI;CAIrB"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransientStorage = void 0;
4
+ const util_1 = require("@feelyourprotocol/util");
5
+ class TransientStorage {
6
+ constructor() {
7
+ /**
8
+ * The current values of the transient storage, keyed by contract address and then slot
9
+ */
10
+ this._storage = new Map();
11
+ /**
12
+ * Each change to storage is recorded in the journal. This is never cleared.
13
+ */
14
+ this._changeJournal = [];
15
+ /**
16
+ * The length of the journal at the beginning of each call in the call stack.
17
+ */
18
+ this._indices = [0];
19
+ }
20
+ /**
21
+ * Get the value for the given address and key
22
+ * @param addr the address for which transient storage is accessed
23
+ * @param key the key of the address to get
24
+ */
25
+ get(addr, key) {
26
+ const map = this._storage.get(addr.toString());
27
+ if (!map) {
28
+ return new Uint8Array(32);
29
+ }
30
+ const value = map.get((0, util_1.bytesToHex)(key));
31
+ if (!value) {
32
+ return new Uint8Array(32);
33
+ }
34
+ return value;
35
+ }
36
+ /**
37
+ * Put the given value for the address and key
38
+ * @param addr the address of the contract for which the key is being set
39
+ * @param key the slot to set for the address
40
+ * @param value the new value of the transient storage slot to set
41
+ */
42
+ put(addr, key, value) {
43
+ if (key.length !== 32) {
44
+ throw (0, util_1.EthereumJSErrorWithoutCode)('Transient storage key must be 32 bytes long');
45
+ }
46
+ if (value.length > 32) {
47
+ throw (0, util_1.EthereumJSErrorWithoutCode)('Transient storage value cannot be longer than 32 bytes');
48
+ }
49
+ const addrString = addr.toString();
50
+ if (!this._storage.has(addrString)) {
51
+ this._storage.set(addrString, new Map());
52
+ }
53
+ const map = this._storage.get(addrString);
54
+ const keyStr = (0, util_1.bytesToHex)(key);
55
+ const prevValue = map.get(keyStr) ?? new Uint8Array(32);
56
+ this._changeJournal.push({
57
+ addr: addrString,
58
+ key: keyStr,
59
+ prevValue,
60
+ });
61
+ map.set(keyStr, value);
62
+ }
63
+ /**
64
+ * Commit all the changes since the last checkpoint
65
+ */
66
+ commit() {
67
+ if (this._indices.length === 0)
68
+ throw (0, util_1.EthereumJSErrorWithoutCode)('Nothing to commit');
69
+ // by discarding the length of the array from the last time checkpoint was called, all changes are included in the last stack
70
+ this._indices.pop();
71
+ }
72
+ /**
73
+ * To be called whenever entering a new context. If revert is called after checkpoint, all changes after the latest checkpoint are reverted.
74
+ */
75
+ checkpoint() {
76
+ this._indices.push(this._changeJournal.length);
77
+ }
78
+ /**
79
+ * Revert transient storage to the last checkpoint
80
+ */
81
+ revert() {
82
+ const lastCheckpoint = this._indices.pop();
83
+ if (typeof lastCheckpoint === 'undefined')
84
+ throw (0, util_1.EthereumJSErrorWithoutCode)('Nothing to revert');
85
+ for (let i = this._changeJournal.length - 1; i >= lastCheckpoint; i--) {
86
+ const { key, prevValue, addr } = this._changeJournal[i];
87
+ this._storage.get(addr).set(key, prevValue);
88
+ }
89
+ this._changeJournal.splice(lastCheckpoint, this._changeJournal.length - lastCheckpoint);
90
+ }
91
+ /**
92
+ * Create a JSON representation of the current transient storage state
93
+ */
94
+ toJSON() {
95
+ const result = {};
96
+ for (const [address, map] of this._storage.entries()) {
97
+ result[address] = {};
98
+ for (const [key, value] of map.entries()) {
99
+ result[address][key] = (0, util_1.bytesToHex)(value);
100
+ }
101
+ }
102
+ return result;
103
+ }
104
+ /**
105
+ * Clear transient storage state.
106
+ */
107
+ clear() {
108
+ this._storage = new Map();
109
+ this._changeJournal = [];
110
+ }
111
+ }
112
+ exports.TransientStorage = TransientStorage;
113
+ //# sourceMappingURL=transientStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transientStorage.js","sourceRoot":"","sources":["../../src/transientStorage.ts"],"names":[],"mappings":";;;AAAA,2CAAyE;AAezE,MAAa,gBAAgB;IAA7B;QACE;;WAEG;QACK,aAAQ,GAA4B,IAAI,GAAG,EAAE,CAAA;QACrD;;WAEG;QACK,mBAAc,GAA4B,EAAE,CAAA;QACpD;;WAEG;QACK,aAAQ,GAAa,CAAC,CAAC,CAAC,CAAA;IAuGlC,CAAC;IArGC;;;;OAIG;IACI,GAAG,CAAC,IAAa,EAAE,GAAe;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;QAC3B,CAAC;QACD,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,IAAA,iBAAU,EAAC,GAAG,CAAC,CAAC,CAAA;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;QAC3B,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,IAAa,EAAE,GAAe,EAAE,KAAiB;QAC1D,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE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