@midnames/sdk 1.0.3 → 1.0.5

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 (312) hide show
  1. package/dist/provider.js +1 -1
  2. package/node_modules/@midnames/ns/package.json +14 -14
  3. package/package.json +13 -11
  4. package/node_modules/@midnames/ns/.env +0 -10
  5. package/node_modules/@midnames/ns/.env.example +0 -11
  6. package/node_modules/@midnames/ns/.turbo/turbo-build.log +0 -2
  7. package/node_modules/@midnames/ns/.turbo/turbo-test.log +0 -13
  8. package/node_modules/@midnames/ns/midnight-level-db/000005.ldb +0 -0
  9. package/node_modules/@midnames/ns/midnight-level-db/000008.ldb +0 -0
  10. package/node_modules/@midnames/ns/midnight-level-db/000011.ldb +0 -0
  11. package/node_modules/@midnames/ns/midnight-level-db/000014.ldb +0 -0
  12. package/node_modules/@midnames/ns/midnight-level-db/000019.ldb +0 -0
  13. package/node_modules/@midnames/ns/midnight-level-db/000024.ldb +0 -0
  14. package/node_modules/@midnames/ns/midnight-level-db/000031.ldb +0 -0
  15. package/node_modules/@midnames/ns/midnight-level-db/000034.ldb +0 -0
  16. package/node_modules/@midnames/ns/midnight-level-db/000037.ldb +0 -0
  17. package/node_modules/@midnames/ns/midnight-level-db/000040.ldb +0 -0
  18. package/node_modules/@midnames/ns/midnight-level-db/000045.ldb +0 -0
  19. package/node_modules/@midnames/ns/midnight-level-db/000050.ldb +0 -0
  20. package/node_modules/@midnames/ns/midnight-level-db/000059.ldb +0 -0
  21. package/node_modules/@midnames/ns/midnight-level-db/000064.ldb +0 -0
  22. package/node_modules/@midnames/ns/midnight-level-db/000069.ldb +0 -0
  23. package/node_modules/@midnames/ns/midnight-level-db/000074.ldb +0 -0
  24. package/node_modules/@midnames/ns/midnight-level-db/000083.ldb +0 -0
  25. package/node_modules/@midnames/ns/midnight-level-db/000088.ldb +0 -0
  26. package/node_modules/@midnames/ns/midnight-level-db/000093.ldb +0 -0
  27. package/node_modules/@midnames/ns/midnight-level-db/000098.ldb +0 -0
  28. package/node_modules/@midnames/ns/midnight-level-db/000107.ldb +0 -0
  29. package/node_modules/@midnames/ns/midnight-level-db/000112.ldb +0 -0
  30. package/node_modules/@midnames/ns/midnight-level-db/000121.ldb +0 -0
  31. package/node_modules/@midnames/ns/midnight-level-db/000126.ldb +0 -0
  32. package/node_modules/@midnames/ns/midnight-level-db/000135.ldb +0 -0
  33. package/node_modules/@midnames/ns/midnight-level-db/000140.ldb +0 -0
  34. package/node_modules/@midnames/ns/midnight-level-db/000149.ldb +0 -0
  35. package/node_modules/@midnames/ns/midnight-level-db/000154.ldb +0 -0
  36. package/node_modules/@midnames/ns/midnight-level-db/000163.ldb +0 -0
  37. package/node_modules/@midnames/ns/midnight-level-db/000168.ldb +0 -0
  38. package/node_modules/@midnames/ns/midnight-level-db/000177.ldb +0 -0
  39. package/node_modules/@midnames/ns/midnight-level-db/000182.ldb +0 -0
  40. package/node_modules/@midnames/ns/midnight-level-db/000187.ldb +0 -0
  41. package/node_modules/@midnames/ns/midnight-level-db/000192.ldb +0 -0
  42. package/node_modules/@midnames/ns/midnight-level-db/000201.ldb +0 -0
  43. package/node_modules/@midnames/ns/midnight-level-db/000206.ldb +0 -0
  44. package/node_modules/@midnames/ns/midnight-level-db/000215.ldb +0 -0
  45. package/node_modules/@midnames/ns/midnight-level-db/000220.ldb +0 -0
  46. package/node_modules/@midnames/ns/midnight-level-db/000229.ldb +0 -0
  47. package/node_modules/@midnames/ns/midnight-level-db/000234.ldb +0 -0
  48. package/node_modules/@midnames/ns/midnight-level-db/000243.ldb +0 -0
  49. package/node_modules/@midnames/ns/midnight-level-db/000248.ldb +0 -0
  50. package/node_modules/@midnames/ns/midnight-level-db/000257.ldb +0 -0
  51. package/node_modules/@midnames/ns/midnight-level-db/000262.ldb +0 -0
  52. package/node_modules/@midnames/ns/midnight-level-db/000271.ldb +0 -0
  53. package/node_modules/@midnames/ns/midnight-level-db/000276.ldb +0 -0
  54. package/node_modules/@midnames/ns/midnight-level-db/000281.ldb +0 -0
  55. package/node_modules/@midnames/ns/midnight-level-db/000286.ldb +0 -0
  56. package/node_modules/@midnames/ns/midnight-level-db/000295.ldb +0 -0
  57. package/node_modules/@midnames/ns/midnight-level-db/000300.ldb +0 -0
  58. package/node_modules/@midnames/ns/midnight-level-db/000305.ldb +0 -0
  59. package/node_modules/@midnames/ns/midnight-level-db/000310.ldb +0 -0
  60. package/node_modules/@midnames/ns/midnight-level-db/000313.log +0 -0
  61. package/node_modules/@midnames/ns/midnight-level-db/000319.ldb +0 -0
  62. package/node_modules/@midnames/ns/midnight-level-db/000324.ldb +0 -0
  63. package/node_modules/@midnames/ns/midnight-level-db/000329.ldb +0 -0
  64. package/node_modules/@midnames/ns/midnight-level-db/000334.ldb +0 -0
  65. package/node_modules/@midnames/ns/midnight-level-db/000343.ldb +0 -0
  66. package/node_modules/@midnames/ns/midnight-level-db/000348.ldb +0 -0
  67. package/node_modules/@midnames/ns/midnight-level-db/000357.ldb +0 -0
  68. package/node_modules/@midnames/ns/midnight-level-db/000362.ldb +0 -0
  69. package/node_modules/@midnames/ns/midnight-level-db/000371.ldb +0 -0
  70. package/node_modules/@midnames/ns/midnight-level-db/000376.ldb +0 -0
  71. package/node_modules/@midnames/ns/midnight-level-db/000385.ldb +0 -0
  72. package/node_modules/@midnames/ns/midnight-level-db/000390.ldb +0 -0
  73. package/node_modules/@midnames/ns/midnight-level-db/000393.log +0 -0
  74. package/node_modules/@midnames/ns/midnight-level-db/CURRENT +0 -1
  75. package/node_modules/@midnames/ns/midnight-level-db/LOCK +0 -0
  76. package/node_modules/@midnames/ns/midnight-level-db/LOG +0 -3
  77. package/node_modules/@midnames/ns/midnight-level-db/LOG.old +0 -6
  78. package/node_modules/@midnames/ns/midnight-level-db/MANIFEST-000312 +0 -0
  79. package/node_modules/@midnames/ns/midnight-level-db/MANIFEST-000392 +0 -0
  80. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/README.md +0 -32
  81. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/built-ins.d.ts +0 -133
  82. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/built-ins.js +0 -216
  83. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/built-ins.js.map +0 -1
  84. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/casts.d.ts +0 -15
  85. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/casts.js +0 -65
  86. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/casts.js.map +0 -1
  87. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/circuit-context.d.ts +0 -66
  88. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/circuit-context.js +0 -150
  89. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/circuit-context.js.map +0 -1
  90. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/compact-types.d.ts +0 -209
  91. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/compact-types.js +0 -374
  92. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/compact-types.js.map +0 -1
  93. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constants.d.ts +0 -13
  94. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constants.js +0 -29
  95. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constants.js.map +0 -1
  96. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constructor-context.d.ts +0 -39
  97. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constructor-context.js +0 -26
  98. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/constructor-context.js.map +0 -1
  99. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/contract-dependencies.d.ts +0 -175
  100. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/contract-dependencies.js +0 -288
  101. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/contract-dependencies.js.map +0 -1
  102. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/error.d.ts +0 -16
  103. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/error.js +0 -43
  104. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/error.js.map +0 -1
  105. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/index.d.ts +0 -15
  106. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/index.js +0 -30
  107. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/index.js.map +0 -1
  108. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/proof-data.d.ts +0 -27
  109. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/proof-data.js +0 -16
  110. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/proof-data.js.map +0 -1
  111. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/utils.d.ts +0 -19
  112. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/utils.js +0 -41
  113. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/utils.js.map +0 -1
  114. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/version.d.ts +0 -2
  115. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/version.js +0 -18
  116. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/version.js.map +0 -1
  117. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/witness.d.ts +0 -24
  118. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/witness.js +0 -26
  119. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/witness.js.map +0 -1
  120. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/zswap.d.ts +0 -172
  121. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/zswap.js +0 -141
  122. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/dist/zswap.js.map +0 -1
  123. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/compact-runtime/package.json +0 -57
  124. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/ledger-v8.d.ts +0 -3079
  125. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/midnight_ledger_wasm.js +0 -5
  126. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/midnight_ledger_wasm_bg.js +0 -10056
  127. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/midnight_ledger_wasm_bg.wasm +0 -0
  128. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/midnight_ledger_wasm_fs.js +0 -69
  129. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/package-lock.json +0 -12
  130. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/package.json +0 -34
  131. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline0.js +0 -1
  132. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline1.js +0 -1
  133. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline10.js +0 -1
  134. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline11.js +0 -1
  135. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline12.js +0 -1
  136. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline13.js +0 -1
  137. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline14.js +0 -1
  138. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline15.js +0 -1
  139. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline16.js +0 -1
  140. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline17.js +0 -1
  141. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline18.js +0 -1
  142. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline19.js +0 -1
  143. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline2.js +0 -1
  144. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline20.js +0 -1
  145. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline21.js +0 -1
  146. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline22.js +0 -1
  147. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline23.js +0 -1
  148. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline3.js +0 -1
  149. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline4.js +0 -1
  150. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline5.js +0 -1
  151. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline6.js +0 -1
  152. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline7.js +0 -1
  153. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline8.js +0 -1
  154. package/node_modules/@midnames/ns/node_modules/@midnight-ntwrk/ledger-v8/snippets/midnight-ledger-wasm-a0cc58108d931982/inline9.js +0 -1
  155. package/node_modules/@midnames/ns/reports/report.xml +0 -33
  156. package/node_modules/@midnames/ns/src/index.ts +0 -13
  157. package/node_modules/@midnames/ns/src/leaf.compact +0 -290
  158. package/node_modules/@midnames/ns/src/managed/leaf/compiler/contract-info.json +0 -534
  159. package/node_modules/@midnames/ns/src/managed/leaf/contract/index.d.ts +0 -197
  160. package/node_modules/@midnames/ns/src/managed/leaf/contract/index.js +0 -3094
  161. package/node_modules/@midnames/ns/src/managed/leaf/contract/index.js.map +0 -8
  162. package/node_modules/@midnames/ns/src/managed/leaf/keys/add_multiple_fields.prover +0 -0
  163. package/node_modules/@midnames/ns/src/managed/leaf/keys/add_multiple_fields.verifier +0 -0
  164. package/node_modules/@midnames/ns/src/managed/leaf/keys/buy_domain_for.prover +0 -0
  165. package/node_modules/@midnames/ns/src/managed/leaf/keys/buy_domain_for.verifier +0 -0
  166. package/node_modules/@midnames/ns/src/managed/leaf/keys/change_owner.prover +0 -0
  167. package/node_modules/@midnames/ns/src/managed/leaf/keys/change_owner.verifier +0 -0
  168. package/node_modules/@midnames/ns/src/managed/leaf/keys/clear_all_fields.prover +0 -0
  169. package/node_modules/@midnames/ns/src/managed/leaf/keys/clear_all_fields.verifier +0 -0
  170. package/node_modules/@midnames/ns/src/managed/leaf/keys/clear_field.prover +0 -0
  171. package/node_modules/@midnames/ns/src/managed/leaf/keys/clear_field.verifier +0 -0
  172. package/node_modules/@midnames/ns/src/managed/leaf/keys/insert_field.prover +0 -0
  173. package/node_modules/@midnames/ns/src/managed/leaf/keys/insert_field.verifier +0 -0
  174. package/node_modules/@midnames/ns/src/managed/leaf/keys/register_domain_for.prover +0 -0
  175. package/node_modules/@midnames/ns/src/managed/leaf/keys/register_domain_for.verifier +0 -0
  176. package/node_modules/@midnames/ns/src/managed/leaf/keys/set_resolver.prover +0 -0
  177. package/node_modules/@midnames/ns/src/managed/leaf/keys/set_resolver.verifier +0 -0
  178. package/node_modules/@midnames/ns/src/managed/leaf/keys/transfer_domain.prover +0 -0
  179. package/node_modules/@midnames/ns/src/managed/leaf/keys/transfer_domain.verifier +0 -0
  180. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_color.prover +0 -0
  181. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_color.verifier +0 -0
  182. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_costs.prover +0 -0
  183. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_costs.verifier +0 -0
  184. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_domain_target.prover +0 -0
  185. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_domain_target.verifier +0 -0
  186. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_target_and_fields.prover +0 -0
  187. package/node_modules/@midnames/ns/src/managed/leaf/keys/update_target_and_fields.verifier +0 -0
  188. package/node_modules/@midnames/ns/src/managed/leaf/zkir/add_multiple_fields.bzkir +0 -0
  189. package/node_modules/@midnames/ns/src/managed/leaf/zkir/add_multiple_fields.zkir +0 -424
  190. package/node_modules/@midnames/ns/src/managed/leaf/zkir/buy_domain_for.bzkir +0 -0
  191. package/node_modules/@midnames/ns/src/managed/leaf/zkir/buy_domain_for.zkir +0 -1456
  192. package/node_modules/@midnames/ns/src/managed/leaf/zkir/change_owner.bzkir +0 -0
  193. package/node_modules/@midnames/ns/src/managed/leaf/zkir/change_owner.zkir +0 -57
  194. package/node_modules/@midnames/ns/src/managed/leaf/zkir/clear_all_fields.bzkir +0 -0
  195. package/node_modules/@midnames/ns/src/managed/leaf/zkir/clear_all_fields.zkir +0 -53
  196. package/node_modules/@midnames/ns/src/managed/leaf/zkir/clear_field.bzkir +0 -0
  197. package/node_modules/@midnames/ns/src/managed/leaf/zkir/clear_field.zkir +0 -58
  198. package/node_modules/@midnames/ns/src/managed/leaf/zkir/insert_field.bzkir +0 -0
  199. package/node_modules/@midnames/ns/src/managed/leaf/zkir/insert_field.zkir +0 -65
  200. package/node_modules/@midnames/ns/src/managed/leaf/zkir/register_domain_for.bzkir +0 -0
  201. package/node_modules/@midnames/ns/src/managed/leaf/zkir/register_domain_for.zkir +0 -401
  202. package/node_modules/@midnames/ns/src/managed/leaf/zkir/set_resolver.bzkir +0 -0
  203. package/node_modules/@midnames/ns/src/managed/leaf/zkir/set_resolver.zkir +0 -109
  204. package/node_modules/@midnames/ns/src/managed/leaf/zkir/transfer_domain.bzkir +0 -0
  205. package/node_modules/@midnames/ns/src/managed/leaf/zkir/transfer_domain.zkir +0 -212
  206. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_color.bzkir +0 -0
  207. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_color.zkir +0 -58
  208. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_costs.bzkir +0 -0
  209. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_costs.zkir +0 -88
  210. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_domain_target.bzkir +0 -0
  211. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_domain_target.zkir +0 -66
  212. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_target_and_fields.bzkir +0 -0
  213. package/node_modules/@midnames/ns/src/managed/leaf/zkir/update_target_and_fields.zkir +0 -450
  214. package/node_modules/@midnames/ns/src/test/batch-config.ts +0 -13
  215. package/node_modules/@midnames/ns/src/test/batch-deploy.ts +0 -914
  216. package/node_modules/@midnames/ns/src/test/contract.ts +0 -1228
  217. package/node_modules/@midnames/ns/src/test/derive_seed.ts +0 -102
  218. package/node_modules/@midnames/ns/src/test/example-deploy.config.ts +0 -76
  219. package/node_modules/@midnames/ns/src/test/midnight-level-db/000005.ldb +0 -0
  220. package/node_modules/@midnames/ns/src/test/midnight-level-db/000011.ldb +0 -0
  221. package/node_modules/@midnames/ns/src/test/midnight-level-db/000014.ldb +0 -0
  222. package/node_modules/@midnames/ns/src/test/midnight-level-db/000025.ldb +0 -0
  223. package/node_modules/@midnames/ns/src/test/midnight-level-db/000039.ldb +0 -0
  224. package/node_modules/@midnames/ns/src/test/midnight-level-db/000049.ldb +0 -0
  225. package/node_modules/@midnames/ns/src/test/midnight-level-db/000064.ldb +0 -0
  226. package/node_modules/@midnames/ns/src/test/midnight-level-db/000078.ldb +0 -0
  227. package/node_modules/@midnames/ns/src/test/midnight-level-db/000092.ldb +0 -0
  228. package/node_modules/@midnames/ns/src/test/midnight-level-db/000106.ldb +0 -0
  229. package/node_modules/@midnames/ns/src/test/midnight-level-db/000121.ldb +0 -0
  230. package/node_modules/@midnames/ns/src/test/midnight-level-db/000135.ldb +0 -0
  231. package/node_modules/@midnames/ns/src/test/midnight-level-db/000146.ldb +0 -0
  232. package/node_modules/@midnames/ns/src/test/midnight-level-db/000160.ldb +0 -0
  233. package/node_modules/@midnames/ns/src/test/midnight-level-db/000174.ldb +0 -0
  234. package/node_modules/@midnames/ns/src/test/midnight-level-db/000188.ldb +0 -0
  235. package/node_modules/@midnames/ns/src/test/midnight-level-db/000203.ldb +0 -0
  236. package/node_modules/@midnames/ns/src/test/midnight-level-db/000217.ldb +0 -0
  237. package/node_modules/@midnames/ns/src/test/midnight-level-db/000232.ldb +0 -0
  238. package/node_modules/@midnames/ns/src/test/midnight-level-db/000242.ldb +0 -0
  239. package/node_modules/@midnames/ns/src/test/midnight-level-db/000256.ldb +0 -0
  240. package/node_modules/@midnames/ns/src/test/midnight-level-db/000263.ldb +0 -0
  241. package/node_modules/@midnames/ns/src/test/midnight-level-db/000267.ldb +0 -0
  242. package/node_modules/@midnames/ns/src/test/midnight-level-db/000276.ldb +0 -0
  243. package/node_modules/@midnames/ns/src/test/midnight-level-db/000281.ldb +0 -0
  244. package/node_modules/@midnames/ns/src/test/midnight-level-db/000286.ldb +0 -0
  245. package/node_modules/@midnames/ns/src/test/midnight-level-db/000291.ldb +0 -0
  246. package/node_modules/@midnames/ns/src/test/midnight-level-db/000300.ldb +0 -0
  247. package/node_modules/@midnames/ns/src/test/midnight-level-db/000305.ldb +0 -0
  248. package/node_modules/@midnames/ns/src/test/midnight-level-db/000314.ldb +0 -0
  249. package/node_modules/@midnames/ns/src/test/midnight-level-db/000319.ldb +0 -0
  250. package/node_modules/@midnames/ns/src/test/midnight-level-db/000328.ldb +0 -0
  251. package/node_modules/@midnames/ns/src/test/midnight-level-db/000333.ldb +0 -0
  252. package/node_modules/@midnames/ns/src/test/midnight-level-db/000342.ldb +0 -0
  253. package/node_modules/@midnames/ns/src/test/midnight-level-db/000347.ldb +0 -0
  254. package/node_modules/@midnames/ns/src/test/midnight-level-db/000356.ldb +0 -0
  255. package/node_modules/@midnames/ns/src/test/midnight-level-db/000361.ldb +0 -0
  256. package/node_modules/@midnames/ns/src/test/midnight-level-db/000370.ldb +0 -0
  257. package/node_modules/@midnames/ns/src/test/midnight-level-db/000375.ldb +0 -0
  258. package/node_modules/@midnames/ns/src/test/midnight-level-db/000380.ldb +0 -0
  259. package/node_modules/@midnames/ns/src/test/midnight-level-db/000385.ldb +0 -0
  260. package/node_modules/@midnames/ns/src/test/midnight-level-db/000392.ldb +0 -0
  261. package/node_modules/@midnames/ns/src/test/midnight-level-db/000397.ldb +0 -0
  262. package/node_modules/@midnames/ns/src/test/midnight-level-db/000400.ldb +0 -0
  263. package/node_modules/@midnames/ns/src/test/midnight-level-db/000403.ldb +0 -0
  264. package/node_modules/@midnames/ns/src/test/midnight-level-db/000408.ldb +0 -0
  265. package/node_modules/@midnames/ns/src/test/midnight-level-db/000413.ldb +0 -0
  266. package/node_modules/@midnames/ns/src/test/midnight-level-db/000422.ldb +0 -0
  267. package/node_modules/@midnames/ns/src/test/midnight-level-db/000427.ldb +0 -0
  268. package/node_modules/@midnames/ns/src/test/midnight-level-db/000432.ldb +0 -0
  269. package/node_modules/@midnames/ns/src/test/midnight-level-db/000437.ldb +0 -0
  270. package/node_modules/@midnames/ns/src/test/midnight-level-db/000446.ldb +0 -0
  271. package/node_modules/@midnames/ns/src/test/midnight-level-db/000451.ldb +0 -0
  272. package/node_modules/@midnames/ns/src/test/midnight-level-db/000456.ldb +0 -0
  273. package/node_modules/@midnames/ns/src/test/midnight-level-db/000461.ldb +0 -0
  274. package/node_modules/@midnames/ns/src/test/midnight-level-db/000470.ldb +0 -0
  275. package/node_modules/@midnames/ns/src/test/midnight-level-db/000475.ldb +0 -0
  276. package/node_modules/@midnames/ns/src/test/midnight-level-db/000480.ldb +0 -0
  277. package/node_modules/@midnames/ns/src/test/midnight-level-db/000485.ldb +0 -0
  278. package/node_modules/@midnames/ns/src/test/midnight-level-db/000494.ldb +0 -0
  279. package/node_modules/@midnames/ns/src/test/midnight-level-db/000499.ldb +0 -0
  280. package/node_modules/@midnames/ns/src/test/midnight-level-db/000504.ldb +0 -0
  281. package/node_modules/@midnames/ns/src/test/midnight-level-db/000509.ldb +0 -0
  282. package/node_modules/@midnames/ns/src/test/midnight-level-db/000518.ldb +0 -0
  283. package/node_modules/@midnames/ns/src/test/midnight-level-db/000523.ldb +0 -0
  284. package/node_modules/@midnames/ns/src/test/midnight-level-db/000528.ldb +0 -0
  285. package/node_modules/@midnames/ns/src/test/midnight-level-db/000533.ldb +0 -0
  286. package/node_modules/@midnames/ns/src/test/midnight-level-db/000542.ldb +0 -0
  287. package/node_modules/@midnames/ns/src/test/midnight-level-db/000547.ldb +0 -0
  288. package/node_modules/@midnames/ns/src/test/midnight-level-db/000552.ldb +0 -0
  289. package/node_modules/@midnames/ns/src/test/midnight-level-db/000557.ldb +0 -0
  290. package/node_modules/@midnames/ns/src/test/midnight-level-db/000566.ldb +0 -0
  291. package/node_modules/@midnames/ns/src/test/midnight-level-db/000571.ldb +0 -0
  292. package/node_modules/@midnames/ns/src/test/midnight-level-db/000576.ldb +0 -0
  293. package/node_modules/@midnames/ns/src/test/midnight-level-db/000581.ldb +0 -0
  294. package/node_modules/@midnames/ns/src/test/midnight-level-db/000590.ldb +0 -0
  295. package/node_modules/@midnames/ns/src/test/midnight-level-db/000595.ldb +0 -0
  296. package/node_modules/@midnames/ns/src/test/midnight-level-db/000600.ldb +0 -0
  297. package/node_modules/@midnames/ns/src/test/midnight-level-db/000605.ldb +0 -0
  298. package/node_modules/@midnames/ns/src/test/midnight-level-db/000608.log +0 -0
  299. package/node_modules/@midnames/ns/src/test/midnight-level-db/CURRENT +0 -1
  300. package/node_modules/@midnames/ns/src/test/midnight-level-db/LOCK +0 -0
  301. package/node_modules/@midnames/ns/src/test/midnight-level-db/LOG +0 -3
  302. package/node_modules/@midnames/ns/src/test/midnight-level-db/LOG.old +0 -6
  303. package/node_modules/@midnames/ns/src/test/midnight-level-db/MANIFEST-000607 +0 -0
  304. package/node_modules/@midnames/ns/src/test/ns-simulator.ts +0 -115
  305. package/node_modules/@midnames/ns/src/test/ns.test.ts +0 -132
  306. package/node_modules/@midnames/ns/src/test/profile-fields.ts +0 -148
  307. package/node_modules/@midnames/ns/src/test/wallet.ts +0 -289
  308. package/node_modules/@midnames/ns/src/utils.ts +0 -16
  309. package/node_modules/@midnames/ns/src/witnesses.ts +0 -6
  310. package/node_modules/@midnames/ns/tsconfig.build.json +0 -5
  311. package/node_modules/@midnames/ns/tsconfig.json +0 -12
  312. package/node_modules/@midnames/ns/vitest.config.ts +0 -30
@@ -1,3079 +0,0 @@
1
- /**
2
- * An onchain data value, in field-aligned binary format.
3
- */
4
- export type Value = Array<Uint8Array>;
5
- /**
6
- * The alignment of an onchain field-aligned binary data value.
7
- */
8
- export type Alignment = AlignmentSegment[];
9
- /**
10
- * A segment in a larger {@link Alignment}.
11
- */
12
- export type AlignmentSegment = { tag: 'option', value: Alignment[] } | { tag: 'atom', value: AlignmentAtom };
13
- /**
14
- * A atom in a larger {@link Alignment}.
15
- */
16
- export type AlignmentAtom = { tag: 'compress' } | { tag: 'field' } | { tag: 'bytes', length: number };
17
- /**
18
- * An onchain data value, in field-aligned binary format, annotated with its
19
- * alignment.
20
- */
21
- export type AlignedValue = { value: Value, alignment: Alignment };
22
- /**
23
- * A Zswap nullifier, as a hex-encoded 256-bit bitstring
24
- */
25
- export type Nullifier = string;
26
- /**
27
- * A Zswap coin commitment, as a hex-encoded 256-bit bitstring
28
- */
29
- export type CoinCommitment = string;
30
- /**
31
- * A contract address, as a hex-encoded 35-byte string
32
- */
33
- export type ContractAddress = string;
34
- /**
35
- * A user public key address, as a hex-encoded 35-byte string
36
- */
37
- export type UserAddress = string;
38
- /**
39
- * The internal identifier attached to a {@link TokenType}, as a hex-encoded string.
40
- */
41
- export type RawTokenType = string;
42
-
43
- /**
44
- * Unshielded token type (or color), as a hex-encoded 35-byte string
45
- */
46
- export type UnshieldedTokenType = { tag: 'unshielded', raw: RawTokenType };
47
- /**
48
- * Shielded token type (or color), as a hex-encoded 35-byte string
49
- */
50
- export type ShieldedTokenType = { tag: 'shielded', raw: RawTokenType };
51
- /**
52
- * Dust token type
53
- */
54
- export type DustTokenType = { tag: 'dust' };
55
- /**
56
- * A token type (or color), as a hex-encoded 35-byte string, shielded, unshielded, or Dust
57
- */
58
- export type TokenType = UnshieldedTokenType | ShieldedTokenType | DustTokenType;
59
- /**
60
- * A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray
61
- */
62
- export type DomainSeparator = Uint8Array;
63
- /**
64
- * A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte
65
- * string
66
- */
67
- export type CoinPublicKey = string;
68
- /**
69
- * A running tally of synthetic resource costs.
70
- */
71
- export type RunningCost = {
72
- /**
73
- * The amount of (modelled) time spent reading from disk, measured in picoseconds.
74
- */
75
- readTime: bigint,
76
- /**
77
- * The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
78
- */
79
- computeTime: bigint,
80
- /**
81
- * The number of (modelled) bytes written.
82
- */
83
- bytesWritten: bigint,
84
- /**
85
- * The number of (modelled) bytes deleted.
86
- */
87
- bytesDeleted: bigint,
88
- };
89
-
90
- /**
91
- * The fee prices for transaction
92
- */
93
- export type FeePrices = {
94
- /**
95
- * The overall price of a full block in an average cost dimension.
96
- */
97
- overallPrice: number,
98
- /**
99
- * The price factor of time spent reading from disk.
100
- */
101
- readFactor: number,
102
- /**
103
- * The price factor of time spent in single-threaded compute.
104
- */
105
- computeFactor: number,
106
- /**
107
- * The price factor of block usage.
108
- */
109
- blockUsageFactor: number,
110
- /**
111
- * The price factor of time spent writing to disk.
112
- */
113
- writeFactor: number,
114
- }
115
-
116
- /**
117
- * Holds the coin secret key of a user, serialized as a hex-encoded 32-byte string
118
- */
119
- export class CoinSecretKey {
120
- private constructor();
121
-
122
- /**
123
- * Clears the coin secret key, so that it is no longer usable nor held in memory
124
- */
125
- clear(): void;
126
-
127
- yesIKnowTheSecurityImplicationsOfThis_serialize(): Uint8Array;
128
-
129
- static deserialize(raw: Uint8Array): CoinSecretKey
130
- }
131
-
132
- /**
133
- * A Zswap nonce, as a hex-encoded 256-bit string
134
- */
135
- export type Nonce = string;
136
- /**
137
- * A hex-encoded signature BIP-340 verifying key, with a 3-byte version prefix
138
- */
139
- export type SignatureVerifyingKey = string;
140
- /**
141
- * A hex-encoded signature BIP-340 signing key, with a 3-byte version prefix
142
- */
143
- export type SigningKey = string;
144
- /**
145
- * A hex-encoded signature BIP-340 signature, with a 3-byte version prefix
146
- */
147
- export type Signature = string;
148
- /**
149
- * An internal encoding of a value of the proof systems scalar field
150
- */
151
- export type Fr = Uint8Array;
152
- /**
153
- * Information required to create a new coin, alongside details about the
154
- * recipient
155
- */
156
- export type ShieldedCoinInfo = {
157
- /**
158
- * The coin's type, identifying the currency it represents
159
- */
160
- type: RawTokenType,
161
- /**
162
- * The coin's randomness, preventing it from colliding with other coins
163
- */
164
- nonce: Nonce,
165
- /**
166
- * The coin's value, in atomic units dependent on the currency
167
- *
168
- * Bounded to be a non-negative 64-bit integer
169
- */
170
- value: bigint,
171
- };
172
- /**
173
- * Information required to spend an existing coin, alongside authorization of
174
- * the owner
175
- */
176
- export type QualifiedShieldedCoinInfo = {
177
- /**
178
- * The coin's type, identifying the currency it represents
179
- */
180
- type: RawTokenType,
181
- /**
182
- * The coin's randomness, preventing it from colliding with other coins
183
- */
184
- nonce: Nonce,
185
- /**
186
- * The coin's value, in atomic units dependent on the currency
187
- *
188
- * Bounded to be a non-negative 64-bit integer
189
- */
190
- value: bigint,
191
- /**
192
- * The coin's location in the chain's Merkle tree of coin commitments
193
- *
194
- * Bounded to be a non-negative 64-bit integer
195
- */
196
- mt_index: bigint,
197
- };
198
-
199
- /**
200
- * A key used to index into an array or map in the onchain VM
201
- */
202
- export type Key = { tag: 'value', value: AlignedValue } | { tag: 'stack' };
203
- /**
204
- * An individual operation in the onchain VM
205
- *
206
- * @typeParam R - `null` or {@link AlignedValue}, for gathering and verifying
207
- * mode respectively
208
- */
209
- export type Op<R> = { noop: { n: number } } |
210
- 'lt' |
211
- 'eq' |
212
- 'type' |
213
- 'size' |
214
- 'new' |
215
- 'and' |
216
- 'or' |
217
- 'neg' |
218
- 'log' |
219
- 'root' |
220
- 'pop' |
221
- { popeq: { cached: boolean, result: R } } |
222
- { addi: { immediate: number } } |
223
- { subi: { immediate: number } } |
224
- { push: { storage: boolean, value: EncodedStateValue } } |
225
- { branch: { skip: number } } |
226
- { jmp: { skip: number } } |
227
- 'add' |
228
- 'sub' |
229
- { concat: { cached: boolean, n: number } } |
230
- 'member' |
231
- { rem: { cached: boolean } } |
232
- { dup: { n: number } } |
233
- { swap: { n: number } } |
234
- { idx: { cached: boolean, pushPath: boolean, path: Key[] } } |
235
- { ins: { cached: boolean, n: number } } |
236
- 'ckpt';
237
- /**
238
- * An individual result of observing the results of a non-verifying VM program
239
- * execution
240
- */
241
- export type GatherResult = { tag: 'read', content: AlignedValue } |
242
- { tag: 'log', content: EncodedStateValue };
243
- /**
244
- * An alternative encoding of {@link StateValue} for use in {@link Op} for
245
- * technical reasons
246
- */
247
- export type EncodedStateValue = { tag: 'null' } |
248
- { tag: 'cell', content: AlignedValue } |
249
- { tag: 'map', content: Map<AlignedValue, EncodedStateValue> } |
250
- { tag: 'array', content: EncodedStateValue[] } |
251
- { tag: 'boundedMerkleTree', content: [number, Map<bigint, [Uint8Array, undefined]>] };
252
- /**
253
- * A transcript of operations, to be recorded in a transaction
254
- */
255
- export type Transcript<R> = {
256
- /**
257
- * The execution budget for this transcript, which {@link program} must not
258
- * exceed
259
- */
260
- gas: RunningCost,
261
- /**
262
- * The effects of the transcript, which are checked before execution, and
263
- * must match those constructed by {@link program}
264
- */
265
- effects: Effects,
266
- /**
267
- * The sequence of operations that this transcript captured
268
- */
269
- program: Op<R>[],
270
- };
271
- /**
272
- * A public address that an entity can be identified by
273
- */
274
- export type PublicAddress = { tag: 'user', address: UserAddress } | { tag: 'contract', address: ContractAddress }
275
- /**
276
- * The context information of a call provided to the VM.
277
- */
278
- export type CallContext = {
279
- ownAddress: ContractAddress,
280
- /**
281
- * The commitment indices map accessible to the contract.
282
- */
283
- comIndices: Map<CoinCommitment, number>
284
- /**
285
- * The seconds since the UNIX epoch that have elapsed
286
- */
287
- secondsSinceEpoch: bigint,
288
- /**
289
- * The maximum error on {@link secondsSinceEpoch} that should occur, as a
290
- * positive seconds value
291
- */
292
- secondsSinceEpochErr: number,
293
- /**
294
- * The hash of the block prior to this transaction, as a hex-encoded string
295
- */
296
- parentBlockHash: string,
297
- /**
298
- * The balances held by the called contract at the time it was called.
299
- */
300
- balance: Map<TokenType, bigint>,
301
- /**
302
- * A public address identifying an entity.
303
- */
304
- caller?: PublicAddress,
305
- /**
306
- * The {@link secondsSinceEpoch} of the previous block
307
- */
308
- lastBlockTime: bigint,
309
- };
310
- /**
311
- * Context information about the block forwarded to {@link CallContext}.
312
- */
313
- export type BlockContext = {
314
- /**
315
- * The seconds since the UNIX epoch that have elapsed
316
- */
317
- secondsSinceEpoch: bigint,
318
- /**
319
- * The maximum error on {@link secondsSinceEpoch} that should occur, as a
320
- * positive seconds value
321
- */
322
- secondsSinceEpochErr: number,
323
- /**
324
- * The hash of the block prior to this transaction, as a hex-encoded string
325
- */
326
- parentBlockHash: string,
327
- /**
328
- * The {@link secondsSinceEpoch} of the previous block
329
- */
330
- lastBlockTime: bigint,
331
- };
332
- /**
333
- * The contract-external effects of a transcript.
334
- */
335
- export type Effects = {
336
- /**
337
- * The nullifiers (spends) this contract call requires
338
- */
339
- claimedNullifiers: Nullifier[],
340
- /**
341
- * The coin commitments (outputs) this contract call requires, as coins
342
- * received
343
- */
344
- claimedShieldedReceives: CoinCommitment[],
345
- /**
346
- * The coin commitments (outputs) this contract call requires, as coins
347
- * sent
348
- */
349
- claimedShieldedSpends: CoinCommitment[],
350
- /**
351
- * The contracts called from this contract. The values are, in order:
352
- *
353
- * - The sequence number of this call
354
- * - The contract being called
355
- * - The entry point being called
356
- * - The communications commitment
357
- */
358
- claimedContractCalls: Array<[bigint, ContractAddress, string, Fr]>,
359
- /**
360
- * The shielded tokens minted in this call, as a map from hex-encoded 256-bit domain
361
- * separators to unsigned 64-bit integers.
362
- */
363
- shieldedMints: Map<string, bigint>,
364
- /**
365
- * The unshielded tokens minted in this call, as a map from hex-encoded 256-bit domain
366
- * separators to unsigned 64-bit integers.
367
- */
368
- unshieldedMints: Map<string, bigint>,
369
- /**
370
- * The unshielded inputs this contract expects.
371
- */
372
- unshieldedInputs: Map<TokenType, bigint>,
373
- /**
374
- * The unshielded outputs this contract authorizes.
375
- */
376
- unshieldedOutputs: Map<TokenType, bigint>,
377
- /**
378
- * The unshielded UTXO outputs this contract expects to be present.
379
- */
380
- claimedUnshieldedSpends: Map<[TokenType, PublicAddress], bigint>,
381
- };
382
-
383
- /**
384
- * A hex-encoded commitment of data shared between two contracts in a call
385
- */
386
- export type CommunicationCommitment = string;
387
- /**
388
- * The hex-encoded randomness to {@link CommunicationCommitment}
389
- */
390
- export type CommunicationCommitmentRand = string;
391
-
392
- /**
393
- * Samples a new {@link CommunicationCommitmentRand} uniformly
394
- */
395
- export function communicationCommitmentRandomness(): CommunicationCommitmentRand;
396
-
397
- /**
398
- * Computes the communication commitment corresponding to an input/output pair and randomness.
399
- */
400
- export function communicationCommitment(input: AlignedValue, output: AlignedValue, rand: CommunicationCommitmentRand): CommunicationCommitment;
401
-
402
- /**
403
- * Computes the (hex-encoded) hash of a given contract entry point. Used in
404
- * composable contracts to reference the called contract's entry point ID
405
- * in-circuit.
406
- */
407
- export function entryPointHash(entryPoint: string | Uint8Array): string;
408
-
409
- /**
410
- * Randomly samples a {@link SigningKey}.
411
- */
412
- export function sampleSigningKey(): SigningKey;
413
-
414
- /**
415
- * Creates a {@link SigningKey} from provided Bip340 private key.
416
- */
417
- export function signingKeyFromBip340(data: Uint8Array): SigningKey;
418
-
419
- /**
420
- * Signs arbitrary data with the given signing key.
421
- *
422
- * WARNING: Do not expose access to this function for valuable keys for data
423
- * that is not strictly controlled!
424
- */
425
- export function signData(key: SigningKey, data: Uint8Array): Signature;
426
-
427
- /**
428
- * Returns the verifying key for a given signing key
429
- */
430
- export function signatureVerifyingKey(sk: SigningKey): SignatureVerifyingKey;
431
-
432
- /**
433
- * Verifies if a signature is correct
434
- */
435
- export function verifySignature(vk: SignatureVerifyingKey, data: Uint8Array, signature: Signature): boolean;
436
-
437
- /**
438
- * Encode a raw {@link RawTokenType} into a `Uint8Array` for use in Compact's
439
- * `RawTokenType` type
440
- */
441
- export function encodeRawTokenType(tt: RawTokenType): Uint8Array;
442
-
443
- /**
444
- * Decode a raw {@link RawTokenType} from a `Uint8Array` originating from Compact's
445
- * `RawTokenType` type
446
- */
447
- export function decodeRawTokenType(tt: Uint8Array): RawTokenType;
448
-
449
- /**
450
- * Encode a {@link ContractAddress} into a `Uint8Array` for use in Compact's
451
- * `ContractAddress` type
452
- */
453
- export function encodeContractAddress(addr: ContractAddress): Uint8Array;
454
-
455
- /**
456
- * Decode a {@link ContractAddress} from a `Uint8Array` originating from
457
- * Compact's `ContractAddress` type
458
- */
459
- export function decodeContractAddress(addr: Uint8Array): ContractAddress;
460
-
461
- /**
462
- * Encode a {@link UserAddress} into a `Uint8Array` for use in Compact's
463
- * `UserAddress` type
464
- */
465
- export function encodeUserAddress(addr: UserAddress): Uint8Array;
466
-
467
- /**
468
- * Decode a {@link UserAddress} from a `Uint8Array` originating from
469
- * Compact's `UserAddress` type
470
- */
471
- export function decodeUserAddress(addr: Uint8Array): UserAddress;
472
-
473
- /**
474
- * Encode a {@link CoinPublicKey} into a `Uint8Array` for use in Compact's
475
- * `CoinPublicKey` type
476
- */
477
- export function encodeCoinPublicKey(pk: CoinPublicKey): Uint8Array;
478
-
479
- /**
480
- * Decode a {@link CoinPublicKey} from a `Uint8Array` originating from Compact's
481
- * `CoinPublicKey` type
482
- */
483
- export function decodeCoinPublicKey(pk: Uint8Array): CoinPublicKey;
484
-
485
- /**
486
- * Encode a {@link ShieldedCoinInfo} into a Compact's `ShieldedCoinInfo` TypeScript
487
- * representation
488
- */
489
- export function encodeShieldedCoinInfo(coin: ShieldedCoinInfo): { color: Uint8Array, nonce: Uint8Array, value: bigint };
490
-
491
- /**
492
- * Encode a {@link QualifiedShieldedCoinInfo} into a Compact's `QualifiedShieldedCoinInfo`
493
- * TypeScript representation
494
- */
495
- export function encodeQualifiedShieldedCoinInfo(coin: QualifiedShieldedCoinInfo): {
496
- color: Uint8Array,
497
- nonce: Uint8Array,
498
- value: bigint,
499
- mt_index: bigint
500
- };
501
-
502
- /**
503
- * Decode a {@link ShieldedCoinInfo} from Compact's `ShieldedCoinInfo` TypeScript representation
504
- */
505
- export function decodeShieldedCoinInfo(coin: { color: Uint8Array, nonce: Uint8Array, value: bigint }): ShieldedCoinInfo;
506
-
507
- /**
508
- * Decode a {@link QualifiedShieldedCoinInfo} from Compact's `QualifiedShieldedCoinInfo`
509
- * TypeScript representation
510
- */
511
- export function decodeQualifiedShieldedCoinInfo(coin: {
512
- color: Uint8Array,
513
- nonce: Uint8Array,
514
- value: bigint,
515
- mt_index: bigint
516
- }): QualifiedShieldedCoinInfo;
517
-
518
- /**
519
- * Derives the raw {@link RawTokenType} associated with a particular
520
- * {@link DomainSeparator} and contract.
521
- */
522
- export function rawTokenType(domain_sep: DomainSeparator, contract: ContractAddress): RawTokenType;
523
-
524
- /**
525
- * Samples a uniform contract address, for use in testing
526
- */
527
- export function sampleContractAddress(): ContractAddress;
528
-
529
- /**
530
- * Samples a uniform user address, for use in testing
531
- */
532
- export function sampleUserAddress(): UserAddress;
533
-
534
- /**
535
- * Samples a uniform raw token type, for use in testing to construct
536
- * both the shielded and unshielded token types.
537
- */
538
- export function sampleRawTokenType(): RawTokenType;
539
-
540
- /**
541
- * A sample contract address
542
- */
543
- export function dummyContractAddress(): ContractAddress;
544
-
545
- /**
546
- * A sample user address
547
- */
548
- export function dummyUserAddress(): UserAddress;
549
-
550
- /**
551
- * Internal implementation of the runtime's coin commitment primitive.
552
- * @internal
553
- */
554
- export function runtimeCoinCommitment(coin: AlignedValue, recipient: AlignedValue): AlignedValue;
555
-
556
- /**
557
- * Internal implementation of the runtime's coin nullifier primitive.
558
- * @internal
559
- */
560
- export function runtimeCoinNullifier(coin: AlignedValue, sender_evidence: AlignedValue): AlignedValue;
561
-
562
- /**
563
- * Internal implementation of the Merkle tree leaf hash primitive.
564
- * @internal
565
- */
566
- export function leafHash(value: AlignedValue): AlignedValue;
567
-
568
- /**
569
- * Internal implementation of the max aligned size primitive.
570
- * @internal
571
- */
572
- export function maxAlignedSize(alignment: Alignment): bigint;
573
-
574
- /**
575
- * Returns the maximum representable value in the proof systems scalar field
576
- * (that is, 1 less than the prime modulus)
577
- */
578
- export function maxField(): bigint;
579
-
580
- /**
581
- * Converts input, output, and transcript information into a proof preimage
582
- * suitable to pass to a `ProvingProvider`.
583
- *
584
- * The `key_location` parameter is a string used to identify the circuit by
585
- * proving machinery, for backwards-compatibility, if unset it defaults to
586
- * `'dummy'`.
587
- */
588
- export function proofDataIntoSerializedPreimage(
589
- input: AlignedValue,
590
- output: AlignedValue,
591
- public_transcript: Op<AlignedValue>[],
592
- private_transcript_outputs: AlignedValue[],
593
- key_location?: string,
594
- ): Uint8Array;
595
-
596
- /**
597
- * Takes a bigint modulus the proof systems scalar field
598
- */
599
- export function bigIntModFr(x: bigint): bigint;
600
-
601
- /**
602
- * Internal conversion between field-aligned binary values and bigints within
603
- * the scalar field
604
- * @internal
605
- * @throws If the value does not encode a field element
606
- */
607
- export function valueToBigInt(x: Value): bigint;
608
-
609
- /**
610
- * Internal conversion between bigints and their field-aligned binary
611
- * representation
612
- * @internal
613
- */
614
- export function bigIntToValue(x: bigint): Value;
615
-
616
- /**
617
- * Internal implementation of the transient hash primitive
618
- * @internal
619
- * @throws If {@link val} does not have alignment {@link align}
620
- */
621
- export function transientHash(align: Alignment, val: Value): Value;
622
-
623
- /**
624
- * Internal implementation of the transient commitment primitive
625
- * @internal
626
- * @throws If {@link val} does not have alignment {@link align}, or
627
- * {@link opening} does not encode a field element
628
- */
629
- export function transientCommit(align: Alignment, val: Value, opening: Value): Value;
630
-
631
- /**
632
- * Internal implementation of the persistent hash primitive
633
- * @internal
634
- * @throws If {@link val} does not have alignment {@link align}, or any
635
- * component has a compress alignment
636
- */
637
- export function persistentHash(align: Alignment, val: Value): Value;
638
-
639
- /**
640
- * Internal implementation of the persistent commitment primitive
641
- * @internal
642
- * @throws If {@link val} does not have alignment {@link align},
643
- * {@link opening} does not encode a 32-byte bytestring, or any component has a
644
- * compress alignment
645
- */
646
- export function persistentCommit(align: Alignment, val: Value, opening: Value): Value;
647
-
648
- /**
649
- * Internal implementation of the degrade to transient primitive
650
- * @internal
651
- * @throws If {@link persistent} does not encode a 32-byte bytestring
652
- */
653
- export function degradeToTransient(persistent: Value): Value;
654
-
655
- /**
656
- * Internal implementation of the upgrade from transient primitive
657
- * @internal
658
- * @throws If {@link transient} does not encode a field element
659
- */
660
- export function upgradeFromTransient(transient: Value): Value;
661
-
662
- /**
663
- * Internal implementation of the hash to curve primitive
664
- * @internal
665
- * @throws If {@link val} does not have alignment {@link align}
666
- */
667
- export function hashToCurve(align: Alignment, val: Value): Value;
668
-
669
- /**
670
- * Internal implementation of the elliptic curve addition primitive
671
- * @internal
672
- * @throws If either input does not encode an elliptic curve point
673
- */
674
- export function ecAdd(a: Value, b: Value): Value;
675
-
676
- /**
677
- * Internal implementation of the elliptic curve multiplication primitive
678
- * @internal
679
- * @throws If {@link a} does not encode an elliptic curve point or {@link b}
680
- * does not encode a field element
681
- */
682
- export function ecMul(a: Value, b: Value): Value;
683
-
684
- /**
685
- * Internal implementation of the elliptic curve generator multiplication
686
- * primitive
687
- * @internal
688
- * @throws if {@link val} does not encode a field element
689
- */
690
- export function ecMulGenerator(val: Value): Value;
691
-
692
- /**
693
- * Runs a VM program against an initial stack, with an optional gas limit
694
- */
695
- export function runProgram(initial: VmStack, ops: Op<null>[], cost_model: CostModel, gas_limit?: RunningCost): VmResults;
696
-
697
- /**
698
- * An individual operation, or entry point of a contract, consisting primarily
699
- * of a ZK verifier keys, potentially for different versions of the proving
700
- * system.
701
- *
702
- * Only the latest available version is exposed to this API.
703
- *
704
- * Note that the serialized form of the key is checked on initialization
705
- */
706
- export class ContractOperation {
707
- constructor();
708
-
709
- verifierKey: Uint8Array;
710
-
711
- serialize(): Uint8Array;
712
-
713
- static deserialize(raw: Uint8Array): ContractOperation;
714
-
715
- toString(compact?: boolean): string;
716
- }
717
-
718
- /**
719
- * A committee permitted to make changes to this contract. If a threshold of
720
- * the public keys in this committee sign off, they can change the rules of
721
- * this contract, or recompile it for a new version.
722
- *
723
- * If the threshold is greater than the number of committee members, it is
724
- * impossible for them to sign anything.
725
- */
726
- export class ContractMaintenanceAuthority {
727
- /**
728
- * Constructs a new authority from its components
729
- *
730
- * If not supplied, `counter` will default to `0n`. Values should be
731
- * non-negative, and at most 2^32 - 1.
732
- *
733
- * At deployment, `counter` must be `0n`, and any subsequent update should
734
- * set counter to exactly one greater than the current value.
735
- */
736
- constructor(committee: Array<SignatureVerifyingKey>, threshold: number, counter?: bigint);
737
-
738
- /**
739
- * The committee public keys
740
- */
741
- readonly committee: Array<SignatureVerifyingKey>;
742
- /**
743
- * How many keys must sign rule changes
744
- */
745
- readonly threshold: number;
746
- /**
747
- * The replay protection counter
748
- */
749
- readonly counter: bigint;
750
-
751
- serialize(): Uint8Array;
752
-
753
- static deserialize(raw: Uint8Array): ContractState;
754
-
755
- toString(compact?: boolean): string;
756
- }
757
-
758
- /**
759
- * The state of a contract, consisting primarily of the {@link data} accessible
760
- * directly to the contract, and the map of {@link ContractOperation}s that can
761
- * be called on it, the keys of which can be accessed with {@link operations},
762
- * and the individual operations can be read with {@link operation} and written
763
- * to with {@link setOperation}.
764
- */
765
- export class ContractState {
766
- /**
767
- * Creates a blank contract state
768
- */
769
- constructor();
770
-
771
- /**
772
- * Return a list of the entry points currently registered on this contract
773
- */
774
- operations(): Array<string | Uint8Array>
775
-
776
- /**
777
- * Get the operation at a specific entry point name
778
- */
779
- operation(operation: string | Uint8Array): ContractOperation | undefined;
780
-
781
- /**
782
- * Set a specific entry point name to contain a given operation
783
- */
784
- setOperation(operation: string | Uint8Array, value: ContractOperation): void;
785
-
786
- /**
787
- * Runs a series of operations against the current state, and returns the
788
- * results
789
- */
790
- query(query: Op<null>[], cost_model: CostModel): GatherResult[];
791
-
792
- serialize(): Uint8Array;
793
-
794
- static deserialize(raw: Uint8Array): ContractState;
795
-
796
- toString(compact?: boolean): string;
797
-
798
- /**
799
- * The current value of the primary state of the contract
800
- */
801
- data: ChargedState;
802
- /**
803
- * The maintenance authority associated with this contract
804
- */
805
- maintenanceAuthority: ContractMaintenanceAuthority;
806
- /**
807
- * The public balances held by this contract
808
- */
809
- balance: Map<TokenType, bigint>;
810
- }
811
-
812
- /**
813
- * Provides the information needed to fully process a transaction, including
814
- * information about the rest of the transaction, and the state of the chain at
815
- * the time of execution.
816
- */
817
- export class QueryContext {
818
- /**
819
- * Construct a basic context from a contract's address and current state
820
- * value
821
- */
822
- constructor(state: ChargedState, address: ContractAddress);
823
-
824
- /**
825
- * Register a given coin commitment as being accessible at a specific index,
826
- * for use when receiving coins in-contract, and needing to record their
827
- * index to later spend them
828
- */
829
- insertCommitment(comm: CoinCommitment, index: bigint): QueryContext;
830
-
831
- /**
832
- * Internal counterpart to {@link insertCommitment}; upgrades an encoded
833
- * {@link ShieldedCoinInfo} to an encoded {@link QualifiedShieldedCoinInfo} using the
834
- * inserted commitments
835
- * @internal
836
- */
837
- qualify(coin: Value): Value | undefined;
838
-
839
- /**
840
- * Runs a transcript in verifying mode against the current query context,
841
- * outputting a new query context, with the {@link state} and {@link effects}
842
- * from after the execution.
843
- */
844
- runTranscript(transcript: Transcript<AlignedValue>, cost_model: CostModel): QueryContext;
845
-
846
- /**
847
- * Runs a sequence of operations in gather mode, returning the results of the
848
- * gather.
849
- */
850
- query(ops: Op<null>[], cost_model: CostModel, gas_limit?: RunningCost): QueryResults;
851
-
852
- /**
853
- * Converts the QueryContext to {@link VmStack}.
854
- */
855
- toVmStack(): VmStack;
856
-
857
- toString(compact?: boolean): string;
858
-
859
- /**
860
- * The address of the contract
861
- */
862
- readonly address: ContractAddress;
863
- /**
864
- * The block-level information accessible to the contract
865
- */
866
- block: CallContext;
867
- /**
868
- * The commitment indices map accessible to the contract, primarily via
869
- * {@link qualify}
870
- */
871
- readonly comIndices: Map<CoinCommitment, bigint>;
872
- /**
873
- * The effects that occurred during execution against this context, should
874
- * match those declared in a {@link Transcript}
875
- */
876
- effects: Effects;
877
- /**
878
- * The current contract state retained in the context
879
- */
880
- readonly state: ChargedState;
881
- }
882
-
883
- /**
884
- * A cost model for calculating transaction fees
885
- */
886
- export class CostModel {
887
- private constructor();
888
-
889
- /**
890
- * The initial cost model of Midnight
891
- */
892
- static initialCostModel(): CostModel;
893
-
894
- toString(compact?: boolean): string;
895
- }
896
-
897
- /**
898
- * The results of making a query against a specific state or context
899
- */
900
- export class QueryResults {
901
- private constructor();
902
-
903
- toString(compact?: boolean): string;
904
-
905
- /**
906
- * The context state after executing the query. This can be used to execute
907
- * further queries
908
- */
909
- readonly context: QueryContext;
910
- /**
911
- * Any events/results that occurred during or from the query
912
- */
913
- readonly events: GatherResult[];
914
- /**
915
- * The measured cost of executing the query
916
- */
917
- readonly gasCost: RunningCost;
918
- }
919
-
920
- /**
921
- * Represents a fixed-depth Merkle tree storing hashed data, whose preimages
922
- * are unknown
923
- */
924
- export class StateBoundedMerkleTree {
925
- /**
926
- * Create a blank tree with the given height
927
- */
928
- constructor(height: number);
929
-
930
- /**
931
- * Internal implementation of the merkle tree root primitive.
932
- * Returns undefined if the tree has not been fully hashed.
933
- * @internal
934
- */
935
- root(): AlignedValue | undefined;
936
-
937
- /**
938
- * Internal implementation of the finding path primitive.
939
- * Returns undefined if the leaf is not in the tree.
940
- * @internal
941
- */
942
- findPathForLeaf(leaf: AlignedValue): AlignedValue | undefined;
943
-
944
- /**
945
- * Internal implementation of the path construction primitive
946
- * @internal
947
- * @throws If the index is out-of-bounds for the tree
948
- */
949
- pathForLeaf(index: bigint, leaf: AlignedValue): AlignedValue;
950
-
951
- /**
952
- * Inserts a value into the Merkle tree, returning the updated tree
953
- * @throws If the index is out-of-bounds for the tree
954
- */
955
- update(index: bigint, leaf: AlignedValue): StateBoundedMerkleTree;
956
-
957
- /**
958
- * Rehashes the tree, updating all internal hashes and ensuring all
959
- * node hashes are present. Necessary because the onchain runtime does
960
- * not automatically rehash trees.
961
- */
962
- rehash(): StateBoundedMerkleTree;
963
-
964
- /**
965
- * Erases all but necessary hashes between, and inclusive of, `start` and
966
- * `end` inidices @internal
967
- * @throws If the indices are out-of-bounds for the tree, or `end < start`
968
- */
969
- collapse(start: bigint, end: bigint): StateBoundedMerkleTree;
970
-
971
- toString(compact?: boolean): string;
972
-
973
- readonly height: number;
974
- }
975
-
976
- /**
977
- * Represents a key-value map, where keys are {@link AlignedValue}s, and values
978
- * are {@link StateValue}s.
979
- */
980
- export class StateMap {
981
- constructor();
982
-
983
- keys(): AlignedValue[];
984
-
985
- get(key: AlignedValue): StateValue | undefined;
986
-
987
- insert(key: AlignedValue, value: StateValue): StateMap;
988
-
989
- remove(key: AlignedValue): StateMap;
990
-
991
- toString(compact?: boolean): string;
992
- }
993
-
994
- /**
995
- * Represents a {@link StateValue} with storage annotations.
996
- *
997
- * These track the state usage that has been charged for so far.
998
- */
999
- export class ChargedState {
1000
- constructor(state: StateValue);
1001
- readonly state: StateValue;
1002
- toString(compact?: boolean): string;
1003
- }
1004
-
1005
- /**
1006
- * Represents the core of a contract's state, and recursively represents each
1007
- * of its components.
1008
- *
1009
- * There are different *classes* of state values:
1010
- * - `null`
1011
- * - Cells of {@link AlignedValue}s
1012
- * - Maps from {@link AlignedValue}s to state values
1013
- * - Bounded Merkle trees containing {@link AlignedValue} leaves
1014
- * - Short (\<= 15 element) arrays of state values
1015
- *
1016
- * State values are *immutable*, any operations that mutate states will return
1017
- * a new state instead.
1018
- */
1019
- export class StateValue {
1020
- private constructor();
1021
-
1022
- type(): 'null' | 'cell' | 'map' | 'array' | 'boundedMerkleTree';
1023
-
1024
- static newNull(): StateValue;
1025
-
1026
- static newCell(value: AlignedValue): StateValue;
1027
-
1028
- static newMap(map: StateMap): StateValue;
1029
-
1030
- static newBoundedMerkleTree(tree: StateBoundedMerkleTree): StateValue;
1031
-
1032
- static newArray(): StateValue;
1033
-
1034
- arrayPush(value: StateValue): StateValue;
1035
-
1036
- asCell(): AlignedValue;
1037
-
1038
- asMap(): StateMap | undefined;
1039
-
1040
- asBoundedMerkleTree(): StateBoundedMerkleTree | undefined;
1041
-
1042
- asArray(): StateValue[] | undefined;
1043
-
1044
- logSize(): number;
1045
-
1046
- toString(compact?: boolean): string;
1047
-
1048
- /**
1049
- * @internal
1050
- */
1051
- encode(): EncodedStateValue;
1052
-
1053
- /**
1054
- * @internal
1055
- */
1056
- static decode(value: EncodedStateValue): StateValue;
1057
- }
1058
-
1059
- /**
1060
- * Represents the results of a VM call
1061
- */
1062
- export class VmResults {
1063
- private constructor();
1064
-
1065
- toString(compact?: boolean): string;
1066
-
1067
- /**
1068
- * The events that got emitted by this VM invocation
1069
- */
1070
- readonly events: GatherResult[];
1071
- /**
1072
- * The computed gas cost of running this VM invocation
1073
- */
1074
- readonly gasCost: RunningCost;
1075
- /**
1076
- * The VM stack at the end of the VM invocation
1077
- */
1078
- readonly stack: VmStack;
1079
- }
1080
-
1081
- /**
1082
- * Represents the state of the VM's stack at a specific point. The stack is an
1083
- * array of {@link StateValue}s, each of which is also annotated with whether
1084
- * it is "strong" or "weak"; that is, whether it is permitted to be stored
1085
- * on-chain or not.
1086
- */
1087
- export class VmStack {
1088
- constructor();
1089
-
1090
- push(value: StateValue, is_strong: boolean): void;
1091
-
1092
- removeLast(): void;
1093
-
1094
- length(): number;
1095
-
1096
- get(idx: number): StateValue | undefined;
1097
-
1098
- isStrong(idx: number): boolean | undefined;
1099
-
1100
- toString(compact?: boolean): string;
1101
- }
1102
-
1103
-
1104
- /**
1105
- * A zero-knowledge proof.
1106
- */
1107
- export class Proof {
1108
- constructor(data: String);
1109
- serialize(): Uint8Array;
1110
- static deserialize(raw: Uint8Array): Proof;
1111
- toString(compact?: boolean): string;
1112
- instance: 'proof';
1113
- private type_: 'proof';
1114
- }
1115
-
1116
- /**
1117
- * The preimage, or data required to produce, a {@link Proof}.
1118
- */
1119
- export class PreProof {
1120
- constructor(data: String);
1121
- serialize(): Uint8Array;
1122
- static deserialize(raw: Uint8Array): PreProof;
1123
- toString(compact?: boolean): string;
1124
- instance: 'pre-proof';
1125
- private type_: 'pre-proof';
1126
- }
1127
-
1128
- /**
1129
- * A unit type used to indicate the absence of proofs.
1130
- */
1131
- export class NoProof {
1132
- constructor();
1133
- toString(compact?: boolean): string;
1134
- instance: 'no-proof';
1135
- private type_: 'no-proof';
1136
- }
1137
-
1138
- /**
1139
- * How proofs are currently being represented, between:
1140
- * - Actual zero-knowledge proofs, as should be transmitted to the network
1141
- * - The data required to *produce* proofs, for constructing and preparing
1142
- * transactions.
1143
- * - Proofs not being provided, largely for testing use or replaying already
1144
- * validated transactions.
1145
- */
1146
- export type Proofish = Proof | PreProof | NoProof;
1147
-
1148
- /**
1149
- * A Fiat-Shamir proof of exponent binding (or ephemerally signing) an
1150
- * {@link Intent}.
1151
- */
1152
- export class Binding {
1153
- constructor(data: String);
1154
- serialize(): Uint8Array;
1155
- static deserialize(raw: Uint8Array): Binding;
1156
- toString(compact?: boolean): string;
1157
- instance: 'binding';
1158
- private type_: 'binding';
1159
- }
1160
-
1161
- /**
1162
- * Information that will be used to bind an {@link Intent} in the future, but
1163
- * does not yet prevent modification of it.
1164
- */
1165
- export class PreBinding {
1166
- constructor(data: String);
1167
- serialize(): Uint8Array;
1168
- static deserialize(raw: Uint8Array): PreBinding;
1169
- toString(compact?: boolean): string;
1170
- instance: 'pre-binding';
1171
- private type_: 'pre-binding';
1172
- }
1173
-
1174
- export class NoBinding {
1175
- constructor(data: String);
1176
- serialize(): Uint8Array;
1177
- static deserialize(raw: Uint8Array): NoBinding;
1178
- toString(compact?: boolean): string;
1179
- instance: 'no-binding';
1180
- private type_: 'no-binding';
1181
- }
1182
-
1183
- /**
1184
- * Whether an intent has binding cryptography applied or not. An intent's
1185
- * content can no longer be modified after it is {@link Binding}.
1186
- */
1187
- export type Bindingish = Binding | PreBinding | NoBinding;
1188
-
1189
- export class SignatureEnabled {
1190
- constructor(data: Signature);
1191
- serialize(): Uint8Array;
1192
- static deserialize(raw: Uint8Array): SignatureEnabled;
1193
- toString(compact?: boolean): string;
1194
- readonly instance: 'signature';
1195
- private type_: 'signature';
1196
- }
1197
-
1198
- export class SignatureErased {
1199
- constructor();
1200
- toString(compact?: boolean): string;
1201
- readonly instance: 'signature-erased';
1202
- private type_: 'signature-erased';
1203
- }
1204
-
1205
- export type Signaturish = SignatureEnabled | SignatureErased;
1206
-
1207
- /**
1208
- * A type representing a transaction that has not been proven yet
1209
- */
1210
- export type UnprovenInput = ZswapInput<PreProof>;
1211
-
1212
- /**
1213
- * A type representing a transaction output that has not been proven yet.
1214
- */
1215
- export type UnprovenOutput = ZswapOutput<PreProof>;
1216
-
1217
- /**
1218
- * A type representing a transaction transient that has not been proven yet.
1219
- */
1220
- export type UnprovenTransient = ZswapTransient<PreProof>;
1221
-
1222
- /**
1223
- * A type representing an offer that has not been proven yet.
1224
- */
1225
- export type UnprovenOffer = ZswapOffer<PreProof>;
1226
-
1227
- /**
1228
- * A type representing an intent that has not been proven yet.
1229
- */
1230
- export type UnprovenIntent = Intent<SignatureEnabled, PreProof, PreBinding>;
1231
-
1232
- /**
1233
- * An interactions with a contract
1234
- */
1235
- export type ContractAction<P extends Proofish> = ContractCall<P> | ContractDeploy | MaintenanceUpdate;
1236
-
1237
- /**
1238
- * Strictness criteria for evaluating transaction well-formedness, used for
1239
- * disabling parts of transaction validation for testing.
1240
- */
1241
- export class WellFormedStrictness {
1242
- constructor();
1243
-
1244
- /**
1245
- * Whether to require the transaction to have a non-negative balance
1246
- */
1247
- enforceBalancing: boolean;
1248
- /**
1249
- * Whether to validate Midnight-native (non-contract) proofs in the transaction
1250
- */
1251
- verifyNativeProofs: boolean;
1252
- /**
1253
- * Whether to validate contract proofs in the transaction
1254
- */
1255
- verifyContractProofs: boolean;
1256
- /**
1257
- * Whether to enforce the transaction byte limit
1258
- */
1259
- enforceLimits: boolean;
1260
- /**
1261
- * Whether to enforce the signature verification
1262
- */
1263
- verifySignatures: boolean;
1264
- }
1265
-
1266
- /**
1267
- * Contains the raw file contents required for proving
1268
- */
1269
- export type ProvingKeyMaterial = {
1270
- proverKey: Uint8Array,
1271
- verifierKey: Uint8Array,
1272
- ir: Uint8Array,
1273
- };
1274
-
1275
- /**
1276
- * A modelled cost of a transaction or block.
1277
- */
1278
- export type SyntheticCost = {
1279
- /**
1280
- * The amount of (modelled) time spent reading from disk, measured in picoseconds.
1281
- */
1282
- readTime: bigint,
1283
- /**
1284
- * The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
1285
- */
1286
- computeTime: bigint,
1287
- /**
1288
- * The number of bytes of blockspace used
1289
- */
1290
- blockUsage: bigint,
1291
- /**
1292
- * The net number of (modelled) bytes written, i.e. max(0, absolute written bytes less deleted bytes).
1293
- */
1294
- bytesWritten: bigint,
1295
- /**
1296
- * The number of (modelled) bytes written temporarily or overwritten.
1297
- */
1298
- bytesChurned: bigint,
1299
- };
1300
-
1301
- /**
1302
- * A normalized form of {@link SyntheticCost}.
1303
- */
1304
- export type NormalizedCost = {
1305
- /**
1306
- * The amount of (modelled) time spent reading from disk, measured in picoseconds.
1307
- */
1308
- readTime: number,
1309
- /**
1310
- * The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
1311
- */
1312
- computeTime: number,
1313
- /**
1314
- * The number of bytes of blockspace used
1315
- */
1316
- blockUsage: number,
1317
- /**
1318
- * The net number of (modelled) bytes written, i.e. max(0, absolute written bytes less deleted bytes).
1319
- */
1320
- bytesWritten: number,
1321
- /**
1322
- * The number of (modelled) bytes written temporarily or overwritten.
1323
- */
1324
- bytesChurned: number,
1325
- };
1326
-
1327
- /**
1328
- * An event emitted by the ledger
1329
- */
1330
- export class Event {
1331
- private constructor();
1332
- serialize(): Uint8Array;
1333
- static deserialize(raw: Uint8Array): Event;
1334
- toString(compact?: boolean): string;
1335
- }
1336
-
1337
- /**
1338
- * A secret key for the Dust, used to derive Dust UTxO nonces and prove credentials to spend Dust UTxOs
1339
- */
1340
- export class DustSecretKey {
1341
- private constructor();
1342
-
1343
- /**
1344
- * Temporary method to create an instance of {@link DustSecretKey} from a bigint (its natural representation)
1345
- * @param bigint
1346
- */
1347
- static fromBigint(bigint: bigint): DustSecretKey;
1348
-
1349
- /**
1350
- * Create an instance of {@link DustSecretKey} from a seed.
1351
- * @param seed
1352
- */
1353
- static fromSeed(seed: Uint8Array): DustSecretKey;
1354
-
1355
- publicKey: DustPublicKey;
1356
-
1357
- /**
1358
- * Clears the dust secret key, so that it is no longer usable nor held in memory
1359
- */
1360
- clear(): void;
1361
- }
1362
-
1363
- // TODO: Doc comments
1364
- export type DustPublicKey = bigint;
1365
- export type DustInitialNonce = string;
1366
- export type DustNonce = bigint;
1367
- export type DustCommitment = bigint;
1368
- export type DustNullifier = bigint;
1369
-
1370
- export function sampleDustSecretKey(): DustSecretKey;
1371
-
1372
- export function updatedValue(ctime: Date, initialValue: bigint, genInfo: DustGenerationInfo, now: Date, params: DustParameters): bigint;
1373
-
1374
- export type DustOutput = {
1375
- initialValue: bigint,
1376
- owner: DustPublicKey,
1377
- nonce: DustNonce,
1378
- seq: number,
1379
- ctime: Date,
1380
- backingNight: DustInitialNonce,
1381
- };
1382
-
1383
- export type QualifiedDustOutput = {
1384
- initialValue: bigint,
1385
- owner: DustPublicKey,
1386
- nonce: DustNonce,
1387
- seq: number,
1388
- ctime: Date,
1389
- backingNight: DustInitialNonce,
1390
- mtIndex: bigint,
1391
- };
1392
-
1393
- export type DustGenerationInfo = {
1394
- value: bigint,
1395
- owner: DustPublicKey,
1396
- nonce: DustInitialNonce,
1397
- dtime: Date | undefined,
1398
- };
1399
-
1400
- export type DustGenerationUniquenessInfo = {
1401
- value: bigint,
1402
- owner: DustPublicKey,
1403
- nonce: DustInitialNonce,
1404
- };
1405
-
1406
- export class DustSpend<P extends Proofish> {
1407
- private constructor();
1408
- serialize(): Uint8Array;
1409
- static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): DustSpend<P>;
1410
- toString(compact?: boolean): string;
1411
- readonly vFee: bigint;
1412
- readonly oldNullifier: DustNullifier;
1413
- readonly newCommitment: DustCommitment;
1414
- readonly proof: P;
1415
- }
1416
-
1417
- export class DustRegistration<S extends Signaturish> {
1418
- constructor(markerS: S['instance'], nightKey: SignatureVerifyingKey, dustAddress: DustPublicKey | undefined, allowFeePayment: bigint, signature?: S);
1419
- serialize(): Uint8Array;
1420
- static deserialize<S extends Signaturish>(markerS: S['instance'], raw: Uint8Array): DustRegistration<S>;
1421
- toString(compact?: boolean): string;
1422
- nightKey: SignatureVerifyingKey;
1423
- dustAddress: DustPublicKey | undefined;
1424
- allowFeePayment: bigint;
1425
- signature: S;
1426
- }
1427
-
1428
- export class DustActions<S extends Signaturish, P extends Proofish> {
1429
- constructor(markerS: S['instance'], markerP: P['instance'], ctime: Date, spends?: DustSpend<P>[], registrations?: DustRegistration<S>[]);
1430
- serialize(): Uint8Array;
1431
- static deserialize<S extends Signaturish, P extends Proofish>(markerS: S['instance'], markerP: P['instance'], raw: Uint8Array): DustActions<S, P>;
1432
- toString(compact?: boolean): string;
1433
- spends: DustSpend<P>[];
1434
- registrations: DustRegistration<S>[];
1435
- ctime: Date;
1436
- }
1437
-
1438
- export class DustParameters {
1439
- constructor(nightDustRatio: bigint, generationDecayRate: bigint, dustGracePeriodSeconds: bigint);
1440
- serialize(): Uint8Array;
1441
- static deserialize(raw: Uint8Array): DustParameters;
1442
- toString(compact?: boolean): string;
1443
- nightDustRatio: bigint;
1444
- generationDecayRate: bigint;
1445
- dustGracePeriodSeconds: bigint;
1446
- readonly timeToCapSeconds: bigint;
1447
- }
1448
-
1449
- export class DustUtxoState {
1450
- constructor();
1451
- serialize(): Uint8Array;
1452
- static deserialize(raw: Uint8Array): DustUtxoState;
1453
- toString(compact?: boolean): string;
1454
- }
1455
-
1456
- export class DustGenerationState {
1457
- constructor();
1458
- serialize(): Uint8Array;
1459
- static deserialize(raw: Uint8Array): DustGenerationState;
1460
- toString(compact?: boolean): string;
1461
- }
1462
-
1463
- export class DustState {
1464
- constructor();
1465
- serialize(): Uint8Array;
1466
- static deserialize(raw: Uint8Array): DustState;
1467
- toString(compact?: boolean): string;
1468
- readonly utxo: DustUtxoState;
1469
- readonly generation: DustGenerationState;
1470
- }
1471
-
1472
- export class DustStateChanges {
1473
- private constructor();
1474
- /**
1475
- * The source of the state change, as a hex-encoded string
1476
- */
1477
- readonly source: string;
1478
- /**
1479
- * The UTXOs that were received in this state change
1480
- */
1481
- readonly receivedUtxos: QualifiedDustOutput[];
1482
- /**
1483
- * The UTXOs that were spent in this state change
1484
- */
1485
- readonly spentUtxos: QualifiedDustOutput[];
1486
- }
1487
-
1488
- export class DustLocalStateWithChanges {
1489
- private constructor();
1490
- /**
1491
- * The updated local state after replaying events
1492
- */
1493
- readonly state: DustLocalState;
1494
- /**
1495
- * The state changes that occurred during the replay
1496
- */
1497
- readonly changes: DustStateChanges[];
1498
- }
1499
-
1500
- export class DustLocalState {
1501
- constructor(params: DustParameters);
1502
- walletBalance(time: Date): bigint;
1503
- generationInfo(qdo: QualifiedDustOutput): DustGenerationInfo | undefined;
1504
- spend(sk: DustSecretKey, utxo: QualifiedDustOutput, vFee: bigint, ctime: Date): [DustLocalState, DustSpend<PreProof>];
1505
- processTtls(time: Date): DustLocalState;
1506
- replayEvents(sk: DustSecretKey, events: Event[]): DustLocalState;
1507
- replayEventsWithChanges(sk: DustSecretKey, events: Event[]): DustLocalStateWithChanges;
1508
- serialize(): Uint8Array;
1509
- static deserialize(raw: Uint8Array): DustLocalState;
1510
- toString(compact?: boolean): string;
1511
- readonly utxos: QualifiedDustOutput[];
1512
- readonly params: DustParameters;
1513
- readonly syncTime: Date;
1514
- }
1515
-
1516
- /**
1517
- * Creates a payload for proving a specific transaction through the proof server
1518
- * @deprecated Use `Transaction.prove` instead.
1519
- */
1520
- export function createProvingTransactionPayload(
1521
- transaction: UnprovenTransaction,
1522
- proving_data: Map<string, ProvingKeyMaterial>,
1523
- ): Uint8Array;
1524
-
1525
- /**
1526
- * Creates a payload for proving a specific proof through the proof server
1527
- */
1528
- export function createProvingPayload(
1529
- serializedPreimage: Uint8Array,
1530
- overwriteBindingInput: bigint | undefined,
1531
- keyMaterial?: ProvingKeyMaterial,
1532
- ): Uint8Array;
1533
-
1534
- /**
1535
- * Creates a payload for checking a specific proof through the proof server
1536
- */
1537
- export function createCheckPayload(
1538
- serializedPreimage: Uint8Array,
1539
- ir?: Uint8Array,
1540
- ): Uint8Array;
1541
-
1542
- /**
1543
- * Parses the result of a proof-server check call
1544
- */
1545
- export function parseCheckResult(result: Uint8Array): (bigint | undefined)[]
1546
-
1547
- /**
1548
- * The state of the Midnight ledger
1549
- */
1550
- export class LedgerState {
1551
- /**
1552
- * Intializes from a Zswap state, with an empty contract set
1553
- */
1554
- constructor(network_id: string, zswap: ZswapChainState);
1555
-
1556
- /**
1557
- * A fully blank state
1558
- */
1559
- static blank(network_id: string): LedgerState;
1560
-
1561
- /**
1562
- * Applies a {@link Transaction}
1563
- */
1564
- apply(
1565
- transaction: VerifiedTransaction,
1566
- context: TransactionContext
1567
- ): [LedgerState, TransactionResult];
1568
-
1569
- /**
1570
- * Applies a system transaction to this ledger state.
1571
- */
1572
- applySystemTx(transaction: SystemTransaction, tblock: Date): [LedgerState, Event[]];
1573
-
1574
- /**
1575
- * Indexes into the contract state map with a given contract address
1576
- */
1577
- index(address: ContractAddress): ContractState | undefined;
1578
-
1579
- /**
1580
- * Sets the state of a given contract address from a {@link ChargedState}
1581
- */
1582
- updateIndex(address: ContractAddress, state: ChargedState, balance: Map<TokenType, bigint>): LedgerState;
1583
-
1584
- serialize(): Uint8Array;
1585
-
1586
- static deserialize(raw: Uint8Array): LedgerState;
1587
-
1588
- toString(compact?: boolean): string;
1589
-
1590
- /**
1591
- * Carries out a post-block update, which does amortized bookkeeping that
1592
- * only needs to be done once per state change.
1593
- *
1594
- * Typically, `postBlockUpdate` should be run after any (sequence of)
1595
- * (system)-transaction application(s).
1596
- */
1597
- postBlockUpdate(tblock: Date, detailedBlockFullness?: NormalizedCost, overallBlockFullness?: number): LedgerState;
1598
-
1599
- /**
1600
- * Retrieves the balance of the treasury for a specific token type.
1601
- */
1602
- treasuryBalance(token_type: TokenType): bigint;
1603
-
1604
- /**
1605
- * How much in block rewards a recipient is owed and can claim.
1606
- */
1607
- unclaimedBlockRewards(recipient: UserAddress): bigint;
1608
-
1609
- /**
1610
- * How much in bridged night a recipient is owed and can claim.
1611
- */
1612
- bridgeReceiving(recipient: UserAddress): bigint;
1613
-
1614
- /**
1615
- * Allows distributing the specified amount of Night to the recipient's address.
1616
- * Use is for testing purposes only.
1617
- */
1618
- testingDistributeNight(recipient: UserAddress, amount: bigint, tblock: Date): LedgerState;
1619
-
1620
- /**
1621
- * The remaining size of the locked Night pool.
1622
- */
1623
- readonly lockedPool: bigint;
1624
-
1625
- /**
1626
- * The size of the reserve Night pool
1627
- */
1628
- readonly reservePool: bigint;
1629
-
1630
- /**
1631
- * How much in bridged night a recipient is owed and can claim.
1632
- */
1633
- bridgeReceiving(recipient: UserAddress): bigint;
1634
-
1635
- /**
1636
- * The remaining unrewarded supply of native tokens.
1637
- */
1638
- readonly blockRewardPool: bigint;
1639
- /**
1640
- * The Zswap part of the ledger state
1641
- */
1642
- readonly zswap: ZswapChainState;
1643
- /**
1644
- * The unshielded utxos present
1645
- */
1646
- readonly utxo: UtxoState;
1647
- /**
1648
- * The dust subsystem state
1649
- */
1650
- readonly dust: DustState;
1651
- /**
1652
- * The parameters of the ledger
1653
- */
1654
- parameters: LedgerParameters;
1655
- }
1656
-
1657
- /**
1658
- * An unspent transaction output
1659
- */
1660
- export type Utxo = {
1661
- /**
1662
- * The amount of tokens this UTXO represents
1663
- */
1664
- value: bigint,
1665
- /**
1666
- * The address owning these tokens.
1667
- */
1668
- owner: UserAddress,
1669
- /**
1670
- * The token type of this UTXO
1671
- */
1672
- type: RawTokenType,
1673
- /**
1674
- * The hash of the intent outputting this UTXO
1675
- */
1676
- intentHash: IntentHash,
1677
- /**
1678
- * The output number of this UTXO in its parent {@link Intent}.
1679
- */
1680
- outputNo: number,
1681
- };
1682
-
1683
- /**
1684
- * An output appearing in an {@link Intent}.
1685
- */
1686
- export type UtxoOutput = {
1687
- /**
1688
- * The amount of tokens this UTXO represents
1689
- */
1690
- value: bigint,
1691
- /**
1692
- * The address owning these tokens.
1693
- */
1694
- owner: UserAddress,
1695
- /**
1696
- * The token type of this UTXO
1697
- */
1698
- type: RawTokenType,
1699
- };
1700
-
1701
- /**
1702
- * Converts a bare signature public key to its corresponding address.
1703
- */
1704
- export function addressFromKey(key: SignatureVerifyingKey): UserAddress;
1705
-
1706
- /**
1707
- * An input appearing in an {@link Intent}, or a user's local book-keeping.
1708
- */
1709
- export type UtxoSpend = {
1710
- /**
1711
- * The amount of tokens this UTXO represents
1712
- */
1713
- value: bigint,
1714
- /**
1715
- * The signing key owning these tokens.
1716
- */
1717
- owner: SignatureVerifyingKey,
1718
- /**
1719
- * The token type of this UTXO
1720
- */
1721
- type: RawTokenType,
1722
- /**
1723
- * The hash of the intent outputting this UTXO
1724
- */
1725
- intentHash: IntentHash,
1726
- /**
1727
- * The output number of this UTXO in its parent {@link Intent}.
1728
- */
1729
- outputNo: number,
1730
- };
1731
-
1732
- /**
1733
- * Metadata about a specific UTXO
1734
- */
1735
- export class UtxoMeta {
1736
- constructor(ctime: Date);
1737
- /**
1738
- * The creation time of the UTXO, that is, when it was inserted into the state.
1739
- */
1740
- ctime: Date;
1741
- }
1742
- /**
1743
- * The sub-state for unshielded UTXOs
1744
- */
1745
- export class UtxoState {
1746
- static new(utxos: Map<Utxo, UtxoMeta>): UtxoState;
1747
- /**
1748
- * Lookup the metadata for a specific UTXO.
1749
- */
1750
- lookupMeta(utxo: Utxo): UtxoMeta | undefined;
1751
-
1752
- /**
1753
- * The set of valid UTXOs
1754
- */
1755
- readonly utxos: Set<Utxo>;
1756
-
1757
- /**
1758
- * Filters out the UTXOs owned by a specific user address
1759
- */
1760
- filter(addr: UserAddress): Set<Utxo>;
1761
-
1762
- /**
1763
- * Given a prior UTXO state, produce the set differences `this \ prior`, and
1764
- * `prior \ this`, optionally filtered by a further condition.
1765
- *
1766
- * Note that this should be more efficient than iterating or manifesting the
1767
- * {@link utxos} value, as the low-level implementation can avoid traversing
1768
- * shared sub-structures.
1769
- */
1770
- delta(prior: UtxoState, filterBy?: (utxo: Utxo) => boolean): [Set<Utxo>, Set<Utxo>];
1771
- }
1772
-
1773
- /**
1774
- * A single contract call segment
1775
- */
1776
- export class ContractCall<P extends Proofish> {
1777
- private constructor();
1778
-
1779
- toString(compact?: boolean): string;
1780
-
1781
- /**
1782
- * The address being called
1783
- */
1784
- readonly address: ContractAddress;
1785
- /**
1786
- * The communication commitment of this call
1787
- */
1788
- readonly communicationCommitment: CommunicationCommitment;
1789
- /**
1790
- * The entry point being called
1791
- */
1792
- readonly entryPoint: Uint8Array | string;
1793
- /**
1794
- * The fallible execution stage transcript
1795
- */
1796
- readonly fallibleTranscript: Transcript<AlignedValue> | undefined;
1797
- /**
1798
- * The guaranteed execution stage transcript
1799
- */
1800
- readonly guaranteedTranscript: Transcript<AlignedValue> | undefined;
1801
- /**
1802
- * The proof attached to this call
1803
- */
1804
- readonly proof: P;
1805
- }
1806
-
1807
- /**
1808
- * A {@link ContractCall} prior to being partitioned into guarnateed and
1809
- * fallible parts, for use with {@link Transaction.addCalls}.
1810
- *
1811
- * Note that this is similar, but not the same as {@link ContractCall}, which
1812
- * assumes {@link partitionTranscripts} was already used. {@link
1813
- * Transaction.addCalls} is a replacement for this that also handles
1814
- * Zswap components, and creates relevant intents when needed.
1815
- */
1816
- export class PrePartitionContractCall {
1817
- constructor(
1818
- address: ContractAddress,
1819
- entry_point: Uint8Array | string,
1820
- op: ContractOperation,
1821
- pre_transcript: PreTranscript,
1822
- private_transcript_outputs: AlignedValue[],
1823
- input: AlignedValue,
1824
- output: AlignedValue,
1825
- communication_commitment_rand: CommunicationCommitmentRand,
1826
- key_location: string
1827
- );
1828
- toString(compact?: boolean): string;
1829
- }
1830
-
1831
- /**
1832
- * A {@link ContractCall} still being assembled
1833
- */
1834
- export class ContractCallPrototype {
1835
- /**
1836
- * @param address - The address being called
1837
- * @param entry_point - The entry point being called
1838
- * @param op - The operation expected at this entry point
1839
- * @param guaranteed_public_transcript - The guaranteed transcript computed
1840
- * for this call
1841
- * @param fallible_public_transcript - The fallible transcript computed for
1842
- * this call
1843
- * @param private_transcript_outputs - The private transcript recorded for
1844
- * this call
1845
- * @param input - The input(s) provided to this call
1846
- * @param output - The output(s) computed from this call
1847
- * @param communication_commitment_rand - The communication randomness used
1848
- * for this call
1849
- * @param key_location - An identifier for how the key for this call may be
1850
- * looked up
1851
- */
1852
- constructor(
1853
- address: ContractAddress,
1854
- entry_point: Uint8Array | string,
1855
- op: ContractOperation,
1856
- guaranteed_public_transcript: Transcript<AlignedValue> | undefined,
1857
- fallible_public_transcript: Transcript<AlignedValue> | undefined,
1858
- private_transcript_outputs: AlignedValue[],
1859
- input: AlignedValue,
1860
- output: AlignedValue,
1861
- communication_commitment_rand: CommunicationCommitmentRand,
1862
- key_location: string
1863
- );
1864
-
1865
- toString(compact?: boolean): string;
1866
-
1867
- intoCall(parentBinding: PreBinding): ContractCall<PreProof>;
1868
- }
1869
-
1870
- /**
1871
- * An intent is a potentially unbalanced partial transaction, that may be
1872
- * combined with other intents to form a whole.
1873
- */
1874
- export class Intent<S extends Signaturish, P extends Proofish, B extends Bindingish> {
1875
- private constructor();
1876
-
1877
- static new(ttl: Date): UnprovenIntent;
1878
-
1879
- serialize(): Uint8Array;
1880
-
1881
- static deserialize<S extends Signaturish, P extends Proofish, B extends Bindingish>(
1882
- markerS: S['instance'],
1883
- markerP: P['instance'],
1884
- markerB: B['instance'],
1885
- raw: Uint8Array,
1886
-
1887
- ): Intent<S, P, B>;
1888
-
1889
- toString(compact?: boolean): string;
1890
-
1891
- /**
1892
- * Returns the hash of this intent, for it's given segment ID.
1893
- */
1894
- intentHash(segmentId: number): IntentHash;
1895
-
1896
- /**
1897
- * Adds a contract call to this intent.
1898
- */
1899
- addCall(call: ContractCallPrototype): Intent<S, PreProof, PreBinding>;
1900
-
1901
- /**
1902
- * Adds a contract deploy to this intent.
1903
- */
1904
- addDeploy(deploy: ContractDeploy): Intent<S, PreProof, PreBinding>;
1905
-
1906
- /**
1907
- * Adds a maintenance update to this intent.
1908
- */
1909
- addMaintenanceUpdate(update: MaintenanceUpdate): Intent<S, PreProof, PreBinding>;
1910
-
1911
- /**
1912
- * Enforces binding for this intent. This is irreversible.
1913
- * @throws If `segmentId` is not a valid segment ID.
1914
- */
1915
- bind(segmentId: number): Intent<S, P, Binding>;
1916
-
1917
- /**
1918
- * Removes proofs from this intent.
1919
- */
1920
- eraseProofs(): Intent<S, NoProof, NoBinding>;
1921
-
1922
- /**
1923
- * Removes signatures from this intent.
1924
- */
1925
- eraseSignatures(): Intent<SignatureErased, P, B>;
1926
-
1927
- /**
1928
- * The raw data that is signed for unshielded inputs in this intent.
1929
- */
1930
- signatureData(segmentId: number): Uint8Array;
1931
-
1932
- /**
1933
- * The UTXO inputs and outputs in the guaranteed section of this intent.
1934
- * @throws Writing throws if `B` is {@link Binding}, unless the only change
1935
- * is in the signature set.
1936
- */
1937
- guaranteedUnshieldedOffer: UnshieldedOffer<S> | undefined;
1938
- /**
1939
- * The UTXO inputs and outputs in the fallible section of this intent.
1940
- * @throws Writing throws if `B` is {@link Binding}, unless the only change
1941
- * is in the signature set.
1942
- */
1943
- fallibleUnshieldedOffer: UnshieldedOffer<S> | undefined;
1944
- /**
1945
- * The action sequence of this intent.
1946
- * @throws Writing throws if `B` is {@link Binding}.
1947
- */
1948
- actions: ContractAction<P>[];
1949
- /**
1950
- * The DUST interactions made by this intent
1951
- * @throws Writing throws if `B` is {@link Binding}.
1952
- */
1953
- dustActions: DustActions<S, P> | undefined;
1954
- /**
1955
- * The time this intent expires.
1956
- * @throws Writing throws if `B` is {@link Binding}.
1957
- */
1958
- ttl: Date;
1959
- readonly binding: B;
1960
- }
1961
-
1962
- /**
1963
- * An unshielded offer consists of inputs, outputs, and signatures that
1964
- * authorize the inputs. The data the signatures sign is provided by {@link
1965
- * Intent.signatureData}.
1966
- */
1967
- export class UnshieldedOffer<S extends Signaturish> {
1968
- private constructor();
1969
-
1970
- static new(inputs: UtxoSpend[], outputs: UtxoOutput[], signatures: Signature[]): UnshieldedOffer<SignatureEnabled>;
1971
-
1972
- addSignatures(signatures: Signature[]): UnshieldedOffer<S>;
1973
-
1974
- eraseSignatures(): UnshieldedOffer<SignatureErased>;
1975
-
1976
- toString(compact?: boolean): string;
1977
-
1978
- readonly inputs: UtxoSpend[];
1979
- readonly outputs: UtxoOutput[];
1980
- readonly signatures: Signature[];
1981
- }
1982
-
1983
- /**
1984
- * The context against which a transaction is run.
1985
- */
1986
- export class TransactionContext {
1987
- /**
1988
- * @param ref_state - A past ledger state that is used as a reference point
1989
- * for 'static' data.
1990
- * @param block_context - Information about the block this transaction is, or
1991
- * will be, contained in.
1992
- * @param whitelist - A list of contracts that are being tracked, or
1993
- * `undefined` to track all contracts.
1994
- */
1995
- constructor(ref_state: LedgerState, block_context: BlockContext, whitelist?: Set<ContractAddress>);
1996
-
1997
- toString(compact?: boolean): string;
1998
- }
1999
-
2000
- /**
2001
- * The result status of applying a transaction.
2002
- * Includes an error message if the transaction failed, or partially failed.
2003
- */
2004
- export class TransactionResult {
2005
- private constructor();
2006
-
2007
- readonly type: 'success' | 'partialSuccess' | 'failure';
2008
- readonly successfulSegments?: Map<number, boolean>;
2009
- readonly error?: string;
2010
- readonly events: Event[];
2011
-
2012
- toString(compact?: boolean): string;
2013
- }
2014
-
2015
- /**
2016
- * The result status of applying a transaction, without error message
2017
- */
2018
- export type ErasedTransactionResult = {
2019
- type: 'success' | 'partialSuccess' | 'failure',
2020
- successfulSegments?: Map<number, boolean>,
2021
- };
2022
-
2023
- /**
2024
- * A single update instruction in a {@link MaintenanceUpdate}.
2025
- */
2026
- export type SingleUpdate = ReplaceAuthority | VerifierKeyRemove | VerifierKeyInsert;
2027
-
2028
- /**
2029
- * The version associated with a {@link ContractOperation}
2030
- */
2031
- export class ContractOperationVersion {
2032
- constructor(version: 'v3');
2033
-
2034
- readonly version: 'v3';
2035
-
2036
- toString(compact?: boolean): string;
2037
- }
2038
-
2039
- /**
2040
- * A versioned verifier key to be associated with a {@link ContractOperation}.
2041
- */
2042
- export class ContractOperationVersionedVerifierKey {
2043
- constructor(version: 'v3', rawVk: Uint8Array);
2044
-
2045
- readonly version: 'v3';
2046
- readonly rawVk: Uint8Array;
2047
-
2048
- toString(compact?: boolean): string;
2049
- }
2050
-
2051
- /**
2052
- * An update instruction to replace the current contract maintenance authority
2053
- * with a new one.
2054
- */
2055
- export class ReplaceAuthority {
2056
- constructor(authority: ContractMaintenanceAuthority);
2057
-
2058
- readonly authority: ContractMaintenanceAuthority;
2059
-
2060
- toString(compact?: boolean): string;
2061
- }
2062
-
2063
- /**
2064
- * An update instruction to remove a verifier key of a specific operation and
2065
- * version.
2066
- */
2067
- export class VerifierKeyRemove {
2068
- constructor(operation: string | Uint8Array, version: ContractOperationVersion);
2069
-
2070
- readonly operation: string | Uint8Array;
2071
- readonly version: ContractOperationVersion;
2072
-
2073
- toString(compact?: boolean): string;
2074
- }
2075
-
2076
- /**
2077
- * An update instruction to insert a verifier key at a specific operation and
2078
- * version.
2079
- */
2080
- export class VerifierKeyInsert {
2081
- constructor(operation: string | Uint8Array, vk: ContractOperationVersionedVerifierKey);
2082
-
2083
- readonly operation: string | Uint8Array;
2084
- readonly vk: ContractOperationVersionedVerifierKey;
2085
-
2086
- toString(compact?: boolean): string;
2087
- }
2088
-
2089
- /**
2090
- * A contract maintenance update, updating associated operations, or
2091
- * changing the maintenance authority.
2092
- */
2093
- export class MaintenanceUpdate {
2094
- constructor(address: ContractAddress, updates: SingleUpdate[], counter: bigint);
2095
-
2096
- /**
2097
- * Adds a new signature to this update
2098
- */
2099
- addSignature(idx: bigint, signature: Signature): MaintenanceUpdate;
2100
-
2101
- toString(compact?: boolean): string;
2102
-
2103
- /**
2104
- * The raw data any valid signature must be over to approve this update.
2105
- */
2106
- readonly dataToSign: Uint8Array;
2107
- /**
2108
- * The address this deployment will attempt to create
2109
- */
2110
- readonly address: ContractAddress;
2111
- /**
2112
- * The updates to carry out
2113
- */
2114
- readonly updates: SingleUpdate[];
2115
- /**
2116
- * The counter this update is valid against
2117
- */
2118
- readonly counter: bigint;
2119
- /**
2120
- * The signatures on this update
2121
- */
2122
- readonly signatures: [bigint, Signature][];
2123
- }
2124
-
2125
- /**
2126
- * A contract deployment segment, instructing the creation of a new contract
2127
- * address, if not already present
2128
- */
2129
- export class ContractDeploy {
2130
- /**
2131
- * Creates a deployment for an arbitrary contract state
2132
- *
2133
- * The deployment and its address are randomised.
2134
- */
2135
- constructor(initial_state: ContractState);
2136
-
2137
- toString(compact?: boolean): string;
2138
-
2139
- /**
2140
- * The address this deployment will attempt to create
2141
- */
2142
- readonly address: ContractAddress;
2143
- readonly initialState: ContractState;
2144
- }
2145
-
2146
- export type ProvingProvider = {
2147
- check(
2148
- serializedPreimage: Uint8Array,
2149
- keyLocation: string,
2150
- ): Promise<(bigint | undefined)[]>;
2151
- prove(
2152
- serializedPreimage: Uint8Array,
2153
- keyLocation: string,
2154
- overwriteBindingInput?: bigint,
2155
- ): Promise<Uint8Array>;
2156
- };
2157
-
2158
- /**
2159
- * Specifies where something should execute in a transaction.
2160
- *
2161
- * Options are:
2162
- * - As the first thing (alias for `{ tag: 'specific', value: 1 }`)
2163
- * - In any physical segment, but only utilising the guaranteed logical segment
2164
- * - In a random segment (ideal for merging with other intents)
2165
- * - In a specific directly provided segment (in the range 1..65535)
2166
- */
2167
- export type SegmentSpecifier = { tag: 'first' } | { tag: 'guaranteedOnly' } | { tag: 'random' } | { tag: 'specific', value: number };
2168
-
2169
- /**
2170
- * A transaction that has been validated with `wellFormed`.
2171
- **/
2172
- export class VerifiedTransaction {
2173
- private constructor();
2174
-
2175
- /**
2176
- * The actual underlying transaction
2177
- **/
2178
- readonly transaction: Transaction<SignatureErased, NoProof, NoBinding>;
2179
- }
2180
-
2181
- /**
2182
- * A Midnight transaction, consisting a section of {@link
2183
- * ContractAction}s, and a guaranteed and fallible {@link ZswapOffer}.
2184
- *
2185
- * The guaranteed section are run first, and fee payment is taken during this
2186
- * part. If it succeeds, the fallible section is also run, and atomically
2187
- * rolled back if it fails.
2188
- */
2189
- export class Transaction<S extends Signaturish, P extends Proofish, B extends Bindingish> {
2190
- private constructor();
2191
-
2192
- /**
2193
- * Creates a transaction from its parts.
2194
- */
2195
- static fromParts(network_id: string, guaranteed?: UnprovenOffer, fallible?: UnprovenOffer, intent?: UnprovenIntent): UnprovenTransaction;
2196
-
2197
- /**
2198
- * Creates a transaction from its parts, randomizing the segment ID to better
2199
- * allow merging.
2200
- */
2201
- static fromPartsRandomized(network_id: string, guaranteed?: UnprovenOffer, fallible?: UnprovenOffer, intent?: UnprovenIntent): UnprovenTransaction;
2202
-
2203
- /**
2204
- * Creates a rewards claim transaction, the funds claimed must have been
2205
- * legitimately rewarded previously.
2206
- */
2207
- static fromRewards<S extends Signaturish>(rewards: ClaimRewardsTransaction<S>): Transaction<S, PreProof, Binding>;
2208
-
2209
- /**
2210
- * Mocks proving, producing a 'proven' transaction that, while it will
2211
- * *not* verify, is accurate for fee computation purposes.
2212
- *
2213
- * Due to the variability in proof sizes, this *only* works for transactions
2214
- * that do not contain unproven contract calls.
2215
- *
2216
- * @throws If called on bound, proven, or proof-erased transactions, or if the
2217
- * transaction contains unproven contract calls.
2218
- */
2219
- mockProve(): Transaction<S, Proof, Binding>;
2220
- /**
2221
- * Proves the transaction, with access to a low-level proving provider.
2222
- * This may *only* be called for `P = PreProof`.
2223
- *
2224
- * @throws If called on bound, proven, or proof-erased transactions.
2225
- */
2226
- prove(provider: ProvingProvider, cost_model: CostModel): Promise<Transaction<S, Proof, B>>;
2227
-
2228
- /**
2229
- * Adds a set of new calls to the transaction.
2230
- *
2231
- * In contrast to {@link Intent.addCall}, this takes calls *before*
2232
- * transcript partitioning ({@link partitionTranscripts}), will create the
2233
- * target intent where needed, and will ensure that relevant Zswap parts are
2234
- * placed in the same section as contract interactions with them.
2235
- *
2236
- * @throws If called on bound, proven, or proof-erased transactions.
2237
- */
2238
- addCalls(
2239
- segment: SegmentSpecifier,
2240
- calls: PrePartitionContractCall[],
2241
- params: LedgerParameters,
2242
- ttl: Date,
2243
- zswapInputs?: ZswapInput<PreProof>[],
2244
- zswapOutputs?: ZswapOutput<PreProof>[],
2245
- zswapTransient?: ZswapTransient<PreProof>[],
2246
- ): Transaction<S, P, B>;
2247
-
2248
- /**
2249
- * Erases the proofs contained in this transaction
2250
- */
2251
- eraseProofs(): Transaction<S, NoProof, NoBinding>;
2252
-
2253
- /**
2254
- * Removes signatures from this transaction.
2255
- */
2256
- eraseSignatures(): Transaction<SignatureErased, P, B>;
2257
-
2258
- /**
2259
- * Enforces binding for this transaction. This is irreversible.
2260
- */
2261
- bind(): Transaction<S, P, Binding>;
2262
-
2263
- /**
2264
- * Tests well-formedness criteria, optionally including transaction balancing
2265
- *
2266
- * @throws If the transaction is not well-formed for any reason
2267
- */
2268
- wellFormed(ref_state: LedgerState, strictness: WellFormedStrictness, tblock: Date): VerifiedTransaction;
2269
-
2270
- /**
2271
- * Returns the hash associated with this transaction. Due to the ability to
2272
- * merge transactions, this should not be used to watch for a specific
2273
- * transaction.
2274
- */
2275
- transactionHash(): TransactionHash;
2276
-
2277
- /**
2278
- * Returns the set of identifiers contained within this transaction. Any of
2279
- * these *may* be used to watch for a specific transaction.
2280
- */
2281
- identifiers(): TransactionId[];
2282
-
2283
- /**
2284
- * Merges this transaction with another
2285
- *
2286
- * @throws If both transactions have contract interactions, or they spend the
2287
- * same coins
2288
- */
2289
- merge(other: Transaction<S, P, B>): Transaction<S, P, B>;
2290
-
2291
- serialize(): Uint8Array;
2292
-
2293
- static deserialize<S extends Signaturish, P extends Proofish, B extends Bindingish>(
2294
- markerS: S['instance'],
2295
- markerP: P['instance'],
2296
- markerB: B['instance'],
2297
- raw: Uint8Array,
2298
-
2299
- ): Transaction<S, P, B>;
2300
-
2301
- /**
2302
- * For given fees, and a given section (guaranteed/fallible), what the
2303
- * surplus or deficit of this transaction in any token type is.
2304
- *
2305
- * @throws If `segment` is not a valid segment ID
2306
- */
2307
- imbalances(segment: number, fees?: bigint): Map<TokenType, bigint>;
2308
-
2309
- /**
2310
- * The underlying resource cost of this transaction.
2311
- */
2312
- cost(params: LedgerParameters, enforceTimeToDismiss?: boolean): SyntheticCost;
2313
-
2314
- /**
2315
- * The cost of this transaction, in SPECKs.
2316
- *
2317
- * Note that this is *only* accurate when called with proven transactions.
2318
- */
2319
- fees(params: LedgerParameters, enforceTimeToDismiss?: boolean): bigint;
2320
-
2321
- /**
2322
- * The cost of this transaction, in SPECKs, with a safety margin of `n` blocks applied.
2323
- *
2324
- * As with {@link fees}, this is only accurate for proven transactions.
2325
- *
2326
- * Warning: `n` must be a non-negative integer, and it is an exponent, it is
2327
- * very easy to get a completely unreasonable margin here!
2328
- */
2329
- feesWithMargin(params: LedgerParameters, margin: number): bigint;
2330
-
2331
- toString(compact?: boolean): string;
2332
-
2333
- /**
2334
- * The rewards this transaction represents, if applicable
2335
- */
2336
- readonly rewards: ClaimRewardsTransaction<S> | undefined;
2337
- /**
2338
- * The intents contained in this transaction
2339
- *
2340
- * Note that writing to this re-computes binding information if and only if
2341
- * this transaction is unbound *and* unproven. If this is not the case,
2342
- * creating or removing intents will lead to a binding error down the line,
2343
- * but modifying existing intents will succeed.
2344
- *
2345
- * @throws On writing if `B` is {@link Binding} or this is not a standard
2346
- * transaction
2347
- */
2348
- intents: Map<number, Intent<S, P, B>> | undefined;
2349
- /**
2350
- * The fallible Zswap offer
2351
- *
2352
- * Note that writing to this re-computes binding information if and only if
2353
- * this transaction is unbound *and* unproven. If this is not the case,
2354
- * creating or removing offer components will lead to a binding error down
2355
- * the line.
2356
- *
2357
- * @throws On writing if `B` is {@link Binding} or this is not a standard
2358
- * transaction
2359
- */
2360
- fallibleOffer: Map<number, ZswapOffer<P>> | undefined;
2361
- /**
2362
- * The guaranteed Zswap offer
2363
- *
2364
- * Note that writing to this re-computes binding information if and only if
2365
- * this transaction is unbound *and* unproven. If this is not the case,
2366
- * creating or removing offer components will lead to a binding error down
2367
- * the line.
2368
- *
2369
- * @throws On writing if `B` is {@link Binding} or this is not a standard
2370
- * transaction
2371
- */
2372
- guaranteedOffer: ZswapOffer<P> | undefined;
2373
- /**
2374
- * The binding randomness associated with this transaction
2375
- */
2376
- readonly bindingRandomness: bigint;
2377
- }
2378
-
2379
- /**
2380
- * A transcript prior to partitioning, consisting of the context to run it in, the program that
2381
- * will make up the transcript, and optionally a communication commitment to bind calls together.
2382
- */
2383
- export class PreTranscript {
2384
- constructor(context: QueryContext, program: Op<AlignedValue>[], comm_comm?: CommunicationCommitment);
2385
-
2386
- toString(compact?: boolean): string;
2387
- }
2388
-
2389
- export type PartitionedTranscript = [Transcript<AlignedValue> | undefined, Transcript<AlignedValue> | undefined];
2390
-
2391
- /**
2392
- * Computes the communication commitment corresponding to an input/output pair and randomness.
2393
- */
2394
- export function communicationCommitment(input: AlignedValue, output: AlignedValue, rand: CommunicationCommitmentRand): CommunicationCommitment;
2395
-
2396
- /**
2397
- * Finalizes a set of programs against their initial contexts,
2398
- * resulting in guaranteed and fallible {@link Transcript}s, optimally
2399
- * allocated, and heuristically covered for gas fees.
2400
- */
2401
- export function partitionTranscripts(calls: PreTranscript[], params: LedgerParameters): PartitionedTranscript[];
2402
-
2403
- /**
2404
- * The hash of a transaction, as a hex-encoded 256-bit bytestring
2405
- */
2406
- export type TransactionHash = string;
2407
- /**
2408
- * The hash of an intent, as a hex-encoded 256-bit bytestring
2409
- */
2410
- export type IntentHash = string;
2411
- /**
2412
- * A transaction identifier, used to index merged transactions
2413
- */
2414
- export type TransactionId = string;
2415
- /**
2416
- * An encryption public key, used to inform users of new coins sent to them
2417
- */
2418
- export type EncPublicKey = string;
2419
-
2420
- /**
2421
- * Samples a dummy user coin public key, for use in testing
2422
- */
2423
- export function sampleCoinPublicKey(): CoinPublicKey;
2424
-
2425
- /**
2426
- * Samples a dummy user encryption public key, for use in testing
2427
- */
2428
- export function sampleEncryptionPublicKey(): EncPublicKey;
2429
-
2430
- /**
2431
- * Samples a dummy user intent hash, for use in testing
2432
- */
2433
- export function sampleIntentHash(): IntentHash;
2434
-
2435
- /**
2436
- * Creates a new {@link ShieldedCoinInfo}, sampling a uniform nonce
2437
- */
2438
- export function createShieldedCoinInfo(type_: RawTokenType, value: bigint): ShieldedCoinInfo;
2439
-
2440
- /**
2441
- * The base/system token type
2442
- */
2443
- export function nativeToken(): UnshieldedTokenType;
2444
-
2445
- /**
2446
- * The system token type for fees
2447
- */
2448
- export function feeToken(): DustTokenType;
2449
-
2450
- /**
2451
- * Default shielded token type for testing
2452
- */
2453
- export function shieldedToken(): ShieldedTokenType;
2454
-
2455
- /**
2456
- * Default unshielded token type for testing
2457
- */
2458
- export function unshieldedToken(): UnshieldedTokenType;
2459
-
2460
- /**
2461
- * Calculate commitment of a coin owned by a user
2462
- */
2463
- export function coinCommitment(coin: ShieldedCoinInfo, coinPublicKey: CoinPublicKey): CoinCommitment;
2464
-
2465
- /**
2466
- * Calculate nullifier of a coin owned by a user
2467
- */
2468
- export function coinNullifier(coin: ShieldedCoinInfo, coinSecretKey: CoinSecretKey): Nullifier;
2469
-
2470
- /**
2471
- * Parameters used by the Midnight ledger, including transaction fees and
2472
- * bounds
2473
- */
2474
- export class LedgerParameters {
2475
- private constructor();
2476
-
2477
- /**
2478
- * The initial parameters of Midnight
2479
- */
2480
- static initialParameters(): LedgerParameters;
2481
-
2482
- /**
2483
- * The cost model used for transaction fees contained in these parameters
2484
- */
2485
- readonly transactionCostModel: TransactionCostModel;
2486
- /**
2487
- * The parameters associated with DUST.
2488
- */
2489
- readonly dust: DustParameters;
2490
-
2491
- /**
2492
- * The maximum price adjustment per block with the current parameters, as a multiplicative
2493
- * factor (that is: 1.1 would indicate a 10% adjustment). Will always return the positive (>1)
2494
- * adjustment factor. Note that negative adjustments are the additive inverse (1.1 has a
2495
- * corresponding 0.9 downward adjustment), *not* the multiplicative as might reasonably be
2496
- * assumed.
2497
- */
2498
- maxPriceAdjustment(): number;
2499
-
2500
- serialize(): Uint8Array;
2501
-
2502
- static deserialize(raw: Uint8Array): LedgerParameters;
2503
-
2504
- toString(compact?: boolean): string;
2505
-
2506
- /**
2507
- * Normalizes a detailed block fullness cost to the block limits.
2508
- *
2509
- * @throws if any of the block limits is exceeded
2510
- */
2511
- normalizeFullness(fullness: SyntheticCost): NormalizedCost;
2512
-
2513
- /**
2514
- * The fee prices for transaction
2515
- */
2516
- readonly feePrices: FeePrices;
2517
- }
2518
-
2519
- export class TransactionCostModel {
2520
- private constructor();
2521
-
2522
- /**
2523
- * The initial cost model of Midnight
2524
- */
2525
- static initialTransactionCostModel(): TransactionCostModel;
2526
-
2527
- /**
2528
- * The increase in fees to expect from adding a new input to a transaction
2529
- */
2530
- readonly inputFeeOverhead: bigint;
2531
- /**
2532
- * The increase in fees to expect from adding a new output to a transaction
2533
- */
2534
- readonly outputFeeOverhead: bigint;
2535
-
2536
- serialize(): Uint8Array;
2537
-
2538
- static deserialize(raw: Uint8Array): TransactionCostModel;
2539
-
2540
- toString(compact?: boolean): string;
2541
-
2542
- /**
2543
- * A cost model for calculating transaction fees
2544
- */
2545
- readonly runtimeCostModel: CostModel;
2546
-
2547
- /**
2548
- * A baseline cost to begin with
2549
- */
2550
- readonly baselineCost: RunningCost;
2551
- }
2552
-
2553
-
2554
- /**
2555
- * A compact delta on the coin commitments Merkle tree, used to keep local
2556
- * spending trees in sync with the global state without requiring receiving all
2557
- * transactions.
2558
- */
2559
- export class MerkleTreeCollapsedUpdate {
2560
- /**
2561
- * Create a new compact update from a non-compact state, and inclusive
2562
- * `start` and `end` indices
2563
- *
2564
- * @throws If the indices are out-of-bounds for the state, or `end < start`
2565
- */
2566
- constructor(state: ZswapChainState, start: bigint, end: bigint);
2567
-
2568
- serialize(): Uint8Array;
2569
-
2570
- static deserialize(raw: Uint8Array): MerkleTreeCollapsedUpdate;
2571
-
2572
- toString(compact?: boolean): string;
2573
- }
2574
-
2575
- /**
2576
- * Holds the encryption secret key of a user, which may be used to determine if
2577
- * a given offer contains outputs addressed to this user
2578
- */
2579
- export class EncryptionSecretKey {
2580
- private constructor();
2581
-
2582
- /**
2583
- * Clears the encryption secret key, so that it is no longer usable nor held in memory
2584
- */
2585
- clear(): void;
2586
-
2587
- test<P extends Proofish>(offer: ZswapOffer<P>): boolean;
2588
-
2589
- yesIKnowTheSecurityImplicationsOfThis_serialize(): Uint8Array;
2590
- yesIKnowTheSecurityImplicationsOfThis_taggedSerialize(): Uint8Array;
2591
-
2592
- static deserialize(raw: Uint8Array): EncryptionSecretKey
2593
- static taggedDeserialize(raw: Uint8Array): EncryptionSecretKey
2594
- }
2595
-
2596
- export class ZswapSecretKeys {
2597
- private constructor();
2598
-
2599
- /**
2600
- * Derives secret keys from a 32-byte seed
2601
- */
2602
- static fromSeed(seed: Uint8Array): ZswapSecretKeys;
2603
-
2604
- /**
2605
- * Derives secret keys from a 32-byte seed using deprecated implementation.
2606
- * Use only for compatibility purposes
2607
- */
2608
- static fromSeedRng(seed: Uint8Array): ZswapSecretKeys;
2609
-
2610
-
2611
- /**
2612
- * Clears the secret keys, so that they are no longer usable nor held in memory
2613
- * Note: it does not clear copies of the keys - which is particularly relevant for proof preimages
2614
- * Note: this will cause all other operations to fail
2615
- */
2616
- clear(): void;
2617
-
2618
- readonly coinPublicKey: CoinPublicKey;
2619
- readonly coinSecretKey: CoinSecretKey;
2620
- readonly encryptionPublicKey: EncPublicKey;
2621
- readonly encryptionSecretKey: EncryptionSecretKey;
2622
- }
2623
-
2624
- /**
2625
- * The on-chain state of Zswap, consisting of a Merkle tree of coin
2626
- * commitments, a set of nullifiers, an index into the Merkle tree, and a set
2627
- * of valid past Merkle tree roots
2628
- */
2629
- export class ZswapChainState {
2630
- constructor();
2631
-
2632
- serialize(): Uint8Array;
2633
-
2634
- /**
2635
- * The first free index in the coin commitment tree
2636
- */
2637
- readonly firstFree: bigint;
2638
-
2639
- static deserialize(raw: Uint8Array): ZswapChainState;
2640
-
2641
- /**
2642
- * Given a whole ledger serialized state, deserialize only the Zswap portion
2643
- */
2644
- static deserializeFromLedgerState(raw: Uint8Array): ZswapChainState;
2645
-
2646
- /**
2647
- * Carries out a post-block update, which does amortized bookkeeping that
2648
- * only needs to be done once per state change.
2649
- *
2650
- * Typically, `postBlockUpdate` should be run after any (sequence of)
2651
- * (system)-transaction application(s).
2652
- */
2653
- postBlockUpdate(tblock: Date): ZswapChainState;
2654
-
2655
- /**
2656
- * Try to apply an {@link ZswapOffer} to the state, returning the updated state
2657
- * and a map on newly inserted coin commitments to their inserted indices.
2658
- *
2659
- * @param whitelist - A set of contract addresses that are of interest. If
2660
- * set, *only* these addresses are tracked, and all other information is
2661
- * discarded.
2662
- */
2663
- tryApply<P extends Proofish>(offer: ZswapOffer<P>, whitelist?: Set<ContractAddress>): [ZswapChainState, Map<CoinCommitment, bigint>];
2664
-
2665
- toString(compact?: boolean): string;
2666
-
2667
- /**
2668
- * Filters the state to only include coins that are relevant to a given
2669
- * contract address.
2670
- *
2671
- * @param contractAddress
2672
- */
2673
- filter(contractAddress: ContractAddress): ZswapChainState;
2674
- }
2675
-
2676
- export class ZswapStateChanges {
2677
- private constructor();
2678
- /**
2679
- * The source of the state change, as a hex-encoded string
2680
- */
2681
- readonly source: string;
2682
- /**
2683
- * The coins that were received in this state change
2684
- */
2685
- readonly receivedCoins: QualifiedShieldedCoinInfo[];
2686
- /**
2687
- * The coins that were spent in this state change
2688
- */
2689
- readonly spentCoins: QualifiedShieldedCoinInfo[];
2690
- }
2691
-
2692
- export class ZswapLocalStateWithChanges {
2693
- private constructor();
2694
- /**
2695
- * The updated local state after replaying events
2696
- */
2697
- readonly state: ZswapLocalState;
2698
- /**
2699
- * The state changes that occurred during the replay
2700
- */
2701
- readonly changes: ZswapStateChanges[];
2702
- }
2703
-
2704
- /**
2705
- * The local state of a user/wallet, consisting of a set
2706
- * of unspent coins
2707
- *
2708
- * It also keeps track of coins that are in-flight, either expecting to spend
2709
- * or expecting to receive, and a local copy of the global coin commitment
2710
- * Merkle tree to generate proofs against.
2711
- *
2712
- * It does not store keys internally, but accepts them as arguments to various operations.
2713
- */
2714
- export class ZswapLocalState {
2715
- /**
2716
- * Creates a new, empty state
2717
- */
2718
- constructor();
2719
-
2720
- /**
2721
- * Applies a collapsed Merkle tree update to the current local state, fast
2722
- * forwarding through the indices included in it, if it is a correct update.
2723
- *
2724
- * The general flow for usage if Alice is in state A, and wants to ask Bob how to reach the new state B, is:
2725
- * - Find where she left off – what's her firstFree?
2726
- * - Find out where she's going – ask for Bob's firstFree.
2727
- * - Find what contents she does care about – ask Bob for the filtered
2728
- * entries she want to include proper in her tree.
2729
- * - In order, of Merkle tree indices:
2730
- * - Insert (with `apply` offers Alice cares about).
2731
- * - Skip (with this method) sections Alice does not care about, obtaining
2732
- * the collapsed update covering the gap from Bob.
2733
- * Note that `firstFree` is not included in the tree itself, and both ends of
2734
- * updates *are* included.
2735
- */
2736
- applyCollapsedUpdate(update: MerkleTreeCollapsedUpdate): ZswapLocalState;
2737
-
2738
- /**
2739
- * Replays observed events against the current local state. These *must* be replayed
2740
- * in the same order as emitted by the chain being followed.
2741
- */
2742
- replayEvents(secretKeys: ZswapSecretKeys, events: Event[]): ZswapLocalState;
2743
- /**
2744
- * Replays observed events against the current local state, returning both the updated state
2745
- * and the state changes. These *must* be replayed in the same order as emitted by the chain being followed.
2746
- */
2747
- replayEventsWithChanges(secretKeys: ZswapSecretKeys, events: Event[]): ZswapLocalStateWithChanges;
2748
- /**
2749
- * Locally applies an offer to the current state, returning the updated state
2750
- */
2751
- apply<P extends Proofish>(secretKeys: ZswapSecretKeys, offer: ZswapOffer<P>): ZswapLocalState;
2752
- /**
2753
- * Locally reverts pending outputs/spends from an offer known to have failed
2754
- * or which has been discarded.
2755
- */
2756
- applyFailed<P extends Proofish>(offer: ZswapOffer<P>): ZswapLocalState;
2757
- /**
2758
- * Locally reverts all pending outputs/spends from a transaction which has been discarded.
2759
- *
2760
- * Behaves as {@link applyFailed} for the entire transaction.
2761
- */
2762
- revertTransaction<S extends Signaturish, P extends Proofish, B extends Bindingish>(transaction: Transaction<S, P, B>): ZswapLocalState;
2763
- /**
2764
- * Clears pending outputs / spends that have passed their TTL without being included in
2765
- * a block.
2766
- *
2767
- * Note that as TTLs are *from a block perspective*, and there is some
2768
- * latency between the block and the wallet, the time passed in here should
2769
- * not be the current time, but incorporate a latency buffer.
2770
- *
2771
- * NOTE: This API endpoint is currently non-functional and works as a no-op.
2772
- */
2773
- clearPending(time: Date): ZswapLocalState;
2774
-
2775
- /**
2776
- * Initiates a new spend of a specific coin, outputting the corresponding
2777
- * {@link ZswapInput}, and the updated state marking this coin as
2778
- * in-flight.
2779
- */
2780
- spend(secretKeys: ZswapSecretKeys, coin: QualifiedShieldedCoinInfo, segment: number | undefined, ttl?: Date): [ZswapLocalState, UnprovenInput];
2781
-
2782
- /**
2783
- * Initiates a new spend of a new-yet-received output, outputting the
2784
- * corresponding {@link ZswapTransient}, and the updated state marking
2785
- * this coin as in-flight.
2786
- */
2787
- spendFromOutput(secretKeys: ZswapSecretKeys, coin: QualifiedShieldedCoinInfo, segment: number | undefined, output: UnprovenOutput, ttl?: Date): [ZswapLocalState, UnprovenTransient];
2788
-
2789
- /**
2790
- * Adds a coin to the list of coins that are expected to be received
2791
- *
2792
- * This should be used if an output is creating a coin for this wallet, which
2793
- * does not contain a ciphertext to detect it. In this case, the wallet must
2794
- * know the commitment ahead of time to notice the receipt.
2795
- */
2796
- watchFor(coinPublicKey: CoinPublicKey, coin: ShieldedCoinInfo): ZswapLocalState;
2797
-
2798
- serialize(): Uint8Array;
2799
-
2800
- static deserialize(raw: Uint8Array): ZswapLocalState;
2801
-
2802
- toString(compact?: boolean): string;
2803
-
2804
- /**
2805
- * The set of *spendable* coins of this wallet
2806
- */
2807
- readonly coins: Set<QualifiedShieldedCoinInfo>;
2808
- /**
2809
- * The first free index in the internal coin commitments Merkle tree.
2810
- * This may be used to identify which merkle tree updates are necessary.
2811
- */
2812
- readonly firstFree: bigint;
2813
- /**
2814
- * The outputs that this wallet is expecting to receive in the future, with
2815
- * an optional TTL attached.
2816
- */
2817
- readonly pendingOutputs: Map<CoinCommitment, [ShieldedCoinInfo, Date | undefined]>;
2818
- /**
2819
- * The spends that this wallet is expecting to be finalized on-chain in the
2820
- * future. Each has an optional TTL attached.
2821
- */
2822
- readonly pendingSpends: Map<Nullifier, [QualifiedShieldedCoinInfo, Date | undefined]>;
2823
- }
2824
-
2825
- /**
2826
- * A shielded transaction input
2827
- */
2828
- export class ZswapInput<P extends Proofish> {
2829
- private constructor();
2830
-
2831
- static newContractOwned(coin: QualifiedShieldedCoinInfo, segment: number | undefined, contract: ContractAddress, state: ZswapChainState): UnprovenInput;
2832
-
2833
- serialize(): Uint8Array;
2834
-
2835
- static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapInput<P>;
2836
-
2837
- toString(compact?: boolean): string;
2838
-
2839
- /**
2840
- * The contract address receiving the input, if the sender is a contract
2841
- */
2842
- readonly contractAddress: ContractAddress | undefined;
2843
- /**
2844
- * The nullifier of the input
2845
- */
2846
- readonly nullifier: Nullifier;
2847
- /**
2848
- * The proof of this input
2849
- */
2850
- readonly proof: P;
2851
- }
2852
-
2853
- /**
2854
- * A shielded transaction output
2855
- */
2856
- export class ZswapOutput<P extends Proofish> {
2857
- private constructor();
2858
-
2859
- /**
2860
- * Creates a new output, targeted to a user's coin public key.
2861
- *
2862
- * Optionally the output contains a ciphertext encrypted to the user's
2863
- * encryption public key, which may be omitted *only* if the {@link ShieldedCoinInfo}
2864
- * is transferred to the recipient another way
2865
- */
2866
- static new(coin: ShieldedCoinInfo, segment: number | undefined, target_cpk: CoinPublicKey, target_epk: EncPublicKey): UnprovenOutput;
2867
-
2868
- /**
2869
- * Creates a new output, targeted to a smart contract
2870
- *
2871
- * A contract must *also* explicitly receive a coin created in this way for
2872
- * the output to be valid
2873
- */
2874
- static newContractOwned(coin: ShieldedCoinInfo, segment: number | undefined, contract: ContractAddress): UnprovenOutput;
2875
-
2876
- serialize(): Uint8Array;
2877
-
2878
- static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapOutput<P>;
2879
-
2880
- toString(compact?: boolean): string;
2881
-
2882
- /**
2883
- * The commitment of the output
2884
- */
2885
- readonly commitment: CoinCommitment;
2886
- /**
2887
- * The contract address receiving the output, if the recipient is a contract
2888
- */
2889
- readonly contractAddress: ContractAddress | undefined;
2890
- /**
2891
- * The proof of this output
2892
- */
2893
- readonly proof: P;
2894
- }
2895
-
2896
- /**
2897
- * A shielded "transient"; an output that is immediately spent within the same
2898
- * transaction
2899
- */
2900
- export class ZswapTransient<P extends Proofish> {
2901
- private constructor();
2902
-
2903
- /**
2904
- * Creates a new contract-owned transient, from a given output and its coin.
2905
- *
2906
- * The {@link QualifiedShieldedCoinInfo} should have an `mt_index` of `0`
2907
- */
2908
- static newFromContractOwnedOutput(coin: QualifiedShieldedCoinInfo, segment: number | undefined, output: UnprovenOutput): UnprovenTransient;
2909
-
2910
- serialize(): Uint8Array;
2911
-
2912
- static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapTransient<P>;
2913
-
2914
- toString(compact?: boolean): string;
2915
-
2916
- /**
2917
- * The commitment of the transient
2918
- */
2919
- readonly commitment: CoinCommitment;
2920
- /**
2921
- * The contract address creating the transient, if applicable
2922
- */
2923
- readonly contractAddress: ContractAddress | undefined;
2924
- /**
2925
- * The nullifier of the transient
2926
- */
2927
- readonly nullifier: Nullifier;
2928
- /**
2929
- * The input proof of this transient
2930
- */
2931
- readonly inputProof: P;
2932
- /**
2933
- * The output proof of this transient
2934
- */
2935
- readonly outputProof: P;
2936
- }
2937
-
2938
- export type ClaimKind = "Reward" | "CardanoBridge";
2939
-
2940
- /**
2941
- * A request to allocate rewards, authorized by the reward's recipient
2942
- */
2943
- export class ClaimRewardsTransaction<S extends Signaturish> {
2944
- constructor(markerS: S['instance'], network_id: string, value: bigint, owner: SignatureVerifyingKey, nonce: Nonce, signature: S, kind?: ClaimKind);
2945
-
2946
- static new(network_id: string, value: bigint, owner: SignatureVerifyingKey, nonce: Nonce, kind: ClaimKind): ClaimRewardsTransaction<SignatureErased>;
2947
-
2948
- addSignature(signature: Signature): ClaimRewardsTransaction<SignatureEnabled>;
2949
-
2950
- eraseSignatures(): ClaimRewardsTransaction<SignatureErased>;
2951
-
2952
- serialize(): Uint8Array;
2953
-
2954
- static deserialize<S extends Signaturish>(markerS: S['instance'], raw: Uint8Array): ClaimRewardsTransaction<S>;
2955
-
2956
- toString(compact?: boolean): string;
2957
-
2958
- /**
2959
- * The raw data any valid signature must be over to approve this transaction.
2960
- */
2961
- readonly dataToSign: Uint8Array;
2962
-
2963
- /**
2964
- * The rewarded coin's value, in atomic units dependent on the currency
2965
- *
2966
- * Bounded to be a non-negative 64-bit integer
2967
- */
2968
- readonly value: bigint;
2969
-
2970
- /**
2971
- * The signing key owning this coin.
2972
- */
2973
- readonly owner: SignatureVerifyingKey;
2974
-
2975
- /**
2976
- * The rewarded coin's randomness, preventing it from colliding with other coins.
2977
- */
2978
- readonly nonce: Nonce;
2979
-
2980
- /**
2981
- * The signature on this request.
2982
- */
2983
- readonly signature: S;
2984
-
2985
- /**
2986
- * The kind of claim being made, either a `Reward` or a `CardanoBridge` claim.
2987
- */
2988
- readonly kind: ClaimKind
2989
- }
2990
-
2991
- /**
2992
- * A full Zswap offer; the zswap part of a transaction
2993
- *
2994
- * Consists of sets of {@link ZswapInput}s, {@link ZswapOutput}s, and {@link ZswapTransient}s,
2995
- * as well as a {@link deltas} vector of the transaction value
2996
- */
2997
- export class ZswapOffer<P extends Proofish> {
2998
- private constructor();
2999
-
3000
- /**
3001
- * Creates a singleton offer, from an {@link ZswapInput} and its value
3002
- * vector
3003
- *
3004
- * The `type_` and `value` parameters are deprecated and will be ignored.
3005
- */
3006
- static fromInput<P extends Proofish>(input: ZswapInput<P>, type_?: RawTokenType, value?: bigint): ZswapOffer<P>;
3007
-
3008
- /**
3009
- * Creates a singleton offer, from an {@link ZswapOutput} and its value
3010
- * vector
3011
- *
3012
- * The `type_` and `value` parameters are deprecated and will be ignored.
3013
- */
3014
- static fromOutput<P extends Proofish>(output: ZswapOutput<P>, type_?: RawTokenType, value?: bigint): ZswapOffer<P>;
3015
-
3016
- /**
3017
- * Creates a singleton offer, from a {@link ZswapTransient}
3018
- */
3019
- static fromTransient<P extends Proofish>(transient: ZswapTransient<P>): ZswapOffer<P>;
3020
-
3021
- /**
3022
- * Combine this offer with another
3023
- */
3024
- merge(other: ZswapOffer<P>): ZswapOffer<P>;
3025
-
3026
- serialize(): Uint8Array;
3027
-
3028
- static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapOffer<P>;
3029
-
3030
- toString(compact?: boolean): string;
3031
-
3032
- /**
3033
- * The value of this offer for each token type; note that this may be
3034
- * negative
3035
- *
3036
- * This is input coin values - output coin values, for value vectors
3037
- */
3038
- readonly deltas: Map<RawTokenType, bigint>;
3039
- /**
3040
- * The inputs this offer is composed of
3041
- */
3042
- readonly inputs: ZswapInput<P>[];
3043
- /**
3044
- * The outputs this offer is composed of
3045
- */
3046
- readonly outputs: ZswapOutput<P>[];
3047
- /**
3048
- * The transients this offer is composed of
3049
- */
3050
- readonly transients: ZswapTransient<P>[];
3051
- }
3052
-
3053
- /**
3054
- * A privileged transaction issued by the system.
3055
- */
3056
- export class SystemTransaction {
3057
- private constructor();
3058
-
3059
- serialize(): Uint8Array;
3060
-
3061
- static deserialize(raw: Uint8Array): SystemTransaction;
3062
-
3063
- toString(compact?: boolean): string;
3064
- }
3065
-
3066
- /**
3067
- * A transaction that has not yet been proven.
3068
- */
3069
- export type UnprovenTransaction = Transaction<SignatureEnabled, PreProof, PreBinding>;
3070
-
3071
- /**
3072
- * A transaction that has been proven and finalized.
3073
- */
3074
- export type FinalizedTransaction = Transaction<SignatureEnabled, Proof, Binding>;
3075
-
3076
- /**
3077
- * A transaction with proofs erased.
3078
- */
3079
- export type ProofErasedTransaction = Transaction<Signaturish, NoProof, NoBinding>;