zkcloudworker 0.18.1 → 0.18.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (406) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +2 -4
  3. package/dist/ts/cloud/config.js.map +1 -0
  4. package/dist/ts/cloud/index.js.map +1 -0
  5. package/dist/ts/cloud/networks.js.map +1 -0
  6. package/dist/ts/cloud/utils/base64.js.map +1 -0
  7. package/dist/ts/cloud/utils/graphql.js.map +1 -0
  8. package/dist/ts/cloud/utils/index.js.map +1 -0
  9. package/dist/ts/cloud/utils/utils.js.map +1 -0
  10. package/dist/ts/cloud/worker/cloud.js.map +1 -0
  11. package/dist/ts/cloud/worker/index.js.map +1 -0
  12. package/{lib → dist}/ts/cloud/worker/job.js.map +1 -1
  13. package/{lib → dist}/ts/cloud/worker/task.js.map +1 -1
  14. package/dist/ts/cloud/worker/transaction.js.map +1 -0
  15. package/dist/ts/cloud/worker/worker.js.map +1 -0
  16. package/dist/ts/index.js.map +1 -0
  17. package/dist/ts/mina/api/api.js.map +1 -0
  18. package/dist/ts/mina/index.js.map +1 -0
  19. package/dist/ts/mina/local/local.js.map +1 -0
  20. package/dist/ts/mina/storage/index.js.map +1 -0
  21. package/dist/ts/mina/storage/ipfs.js.map +1 -0
  22. package/dist/ts/mina/storage/pinata.js.map +1 -0
  23. package/dist/ts/mina/storage/storage.js.map +1 -0
  24. package/dist/ts/mina/token/FungibleToken.js.map +1 -0
  25. package/dist/ts/mina/token/FungibleTokenAdmin.js.map +1 -0
  26. package/dist/ts/mina/token/api.js.map +1 -0
  27. package/dist/ts/mina/token/index.js.map +1 -0
  28. package/dist/ts/mina/token/vk.js.map +1 -0
  29. package/dist/ts/mina/token/whitelist.js.map +1 -0
  30. package/dist/ts/mina/transactions/account.js.map +1 -0
  31. package/dist/ts/mina/transactions/blockberry.js.map +1 -0
  32. package/dist/ts/mina/transactions/chain.js.map +1 -0
  33. package/dist/ts/mina/transactions/index.js.map +1 -0
  34. package/dist/ts/mina/transactions/nonce.js.map +1 -0
  35. package/dist/ts/mina/transactions/send.js.map +1 -0
  36. package/dist/ts/mina/transactions/tiny-contract.js.map +1 -0
  37. package/dist/ts/mina/transactions/transaction.js.map +1 -0
  38. package/dist/ts/mina/transactions/txstatus.js.map +1 -0
  39. package/dist/ts/mina/utils/base64.js.map +1 -0
  40. package/dist/ts/mina/utils/fee.js.map +1 -0
  41. package/dist/ts/mina/utils/fetch.js.map +1 -0
  42. package/dist/ts/mina/utils/fields.js.map +1 -0
  43. package/dist/ts/mina/utils/index.js.map +1 -0
  44. package/dist/ts/mina/utils/indexed-map.js.map +1 -0
  45. package/dist/ts/mina/utils/mina.js.map +1 -0
  46. package/dist/ts/mina/verification/index.js.map +1 -0
  47. package/dist/ts/mina/verification/verification.js.map +1 -0
  48. package/dist/tsconfig.web.tsbuildinfo +1 -0
  49. package/dist/web/cloud/config.js.map +1 -0
  50. package/dist/web/cloud/index.js.map +1 -0
  51. package/dist/web/cloud/networks.js.map +1 -0
  52. package/dist/web/cloud/utils/base64.js.map +1 -0
  53. package/dist/web/cloud/utils/graphql.js.map +1 -0
  54. package/dist/web/cloud/utils/index.js.map +1 -0
  55. package/dist/web/cloud/utils/utils.js.map +1 -0
  56. package/dist/web/cloud/worker/cloud.js.map +1 -0
  57. package/dist/web/cloud/worker/index.js.map +1 -0
  58. package/{lib → dist}/web/cloud/worker/job.js.map +1 -1
  59. package/{lib → dist}/web/cloud/worker/task.js.map +1 -1
  60. package/dist/web/cloud/worker/transaction.js.map +1 -0
  61. package/dist/web/cloud/worker/worker.js.map +1 -0
  62. package/dist/web/index.js.map +1 -0
  63. package/dist/web/mina/api/api.js.map +1 -0
  64. package/dist/web/mina/index.js.map +1 -0
  65. package/dist/web/mina/local/local.js.map +1 -0
  66. package/dist/web/mina/storage/index.js.map +1 -0
  67. package/dist/web/mina/storage/ipfs.js.map +1 -0
  68. package/dist/web/mina/storage/pinata.js.map +1 -0
  69. package/dist/web/mina/storage/storage.js.map +1 -0
  70. package/dist/web/mina/token/FungibleToken.js.map +1 -0
  71. package/dist/web/mina/token/FungibleTokenAdmin.js.map +1 -0
  72. package/dist/web/mina/token/api.js.map +1 -0
  73. package/dist/web/mina/token/index.js.map +1 -0
  74. package/dist/web/mina/token/vk.js.map +1 -0
  75. package/dist/web/mina/token/whitelist.js.map +1 -0
  76. package/dist/web/mina/transactions/account.js.map +1 -0
  77. package/dist/web/mina/transactions/blockberry.js.map +1 -0
  78. package/dist/web/mina/transactions/chain.js.map +1 -0
  79. package/dist/web/mina/transactions/index.js.map +1 -0
  80. package/dist/web/mina/transactions/nonce.js.map +1 -0
  81. package/dist/web/mina/transactions/send.js.map +1 -0
  82. package/dist/web/mina/transactions/tiny-contract.js.map +1 -0
  83. package/dist/web/mina/transactions/transaction.js.map +1 -0
  84. package/dist/web/mina/transactions/txstatus.js.map +1 -0
  85. package/dist/web/mina/utils/base64.js.map +1 -0
  86. package/dist/web/mina/utils/fee.js.map +1 -0
  87. package/dist/web/mina/utils/fetch.js.map +1 -0
  88. package/dist/web/mina/utils/fields.js.map +1 -0
  89. package/dist/web/mina/utils/index.js.map +1 -0
  90. package/dist/web/mina/utils/indexed-map.js.map +1 -0
  91. package/dist/web/mina/utils/mina.js.map +1 -0
  92. package/dist/web/mina/verification/index.js.map +1 -0
  93. package/dist/web/mina/verification/verification.js.map +1 -0
  94. package/package.json +32 -20
  95. package/src/cloud/config.ts +10 -0
  96. package/src/cloud/index.ts +4 -0
  97. package/src/cloud/networks.ts +130 -0
  98. package/src/cloud/utils/base64.ts +87 -0
  99. package/src/cloud/utils/graphql.ts +252 -0
  100. package/src/cloud/utils/index.ts +3 -0
  101. package/src/cloud/utils/utils.ts +79 -0
  102. package/src/cloud/worker/cloud.ts +326 -0
  103. package/src/cloud/worker/index.ts +5 -0
  104. package/src/cloud/worker/job.ts +123 -0
  105. package/src/cloud/worker/task.ts +45 -0
  106. package/src/cloud/worker/transaction.ts +12 -0
  107. package/src/cloud/worker/worker.ts +62 -0
  108. package/src/index.ts +2 -0
  109. package/src/mina/api/api.ts +597 -0
  110. package/src/mina/index.ts +8 -0
  111. package/src/mina/local/local.ts +651 -0
  112. package/src/mina/storage/index.ts +3 -0
  113. package/src/mina/storage/ipfs.ts +20 -0
  114. package/src/mina/storage/pinata.ts +52 -0
  115. package/src/mina/storage/storage.ts +55 -0
  116. package/src/mina/token/FungibleToken.ts +316 -0
  117. package/src/mina/token/FungibleTokenAdmin.ts +95 -0
  118. package/src/mina/token/api.ts +182 -0
  119. package/src/mina/token/index.ts +5 -0
  120. package/src/mina/token/vk.ts +42 -0
  121. package/src/mina/token/whitelist.ts +178 -0
  122. package/src/mina/transactions/account.ts +57 -0
  123. package/src/mina/transactions/blockberry.ts +166 -0
  124. package/src/mina/transactions/chain.ts +1 -0
  125. package/src/mina/transactions/index.ts +8 -0
  126. package/src/mina/transactions/nonce.ts +120 -0
  127. package/src/mina/transactions/send.ts +186 -0
  128. package/src/mina/transactions/tiny-contract.ts +9 -0
  129. package/src/mina/transactions/transaction.ts +255 -0
  130. package/src/mina/transactions/txstatus.ts +26 -0
  131. package/src/mina/utils/base64.ts +34 -0
  132. package/src/mina/utils/fee.ts +11 -0
  133. package/src/mina/utils/fetch.ts +126 -0
  134. package/src/mina/utils/fields.ts +39 -0
  135. package/src/mina/utils/index.ts +6 -0
  136. package/src/mina/utils/indexed-map.ts +169 -0
  137. package/src/mina/utils/mina.ts +175 -0
  138. package/src/mina/verification/index.ts +1 -0
  139. package/src/mina/verification/verification.ts +23 -0
  140. package/lib/ts/cloud/config.js.map +0 -1
  141. package/lib/ts/cloud/index.js.map +0 -1
  142. package/lib/ts/cloud/networks.js.map +0 -1
  143. package/lib/ts/cloud/utils/base64.js.map +0 -1
  144. package/lib/ts/cloud/utils/graphql.js.map +0 -1
  145. package/lib/ts/cloud/utils/index.js.map +0 -1
  146. package/lib/ts/cloud/utils/utils.js.map +0 -1
  147. package/lib/ts/cloud/worker/cloud.js.map +0 -1
  148. package/lib/ts/cloud/worker/index.js.map +0 -1
  149. package/lib/ts/cloud/worker/transaction.js.map +0 -1
  150. package/lib/ts/cloud/worker/worker.js.map +0 -1
  151. package/lib/ts/index.js.map +0 -1
  152. package/lib/ts/mina/api/api.js.map +0 -1
  153. package/lib/ts/mina/index.js.map +0 -1
  154. package/lib/ts/mina/local/local.js.map +0 -1
  155. package/lib/ts/mina/storage/index.js.map +0 -1
  156. package/lib/ts/mina/storage/ipfs.js.map +0 -1
  157. package/lib/ts/mina/storage/pinata.js.map +0 -1
  158. package/lib/ts/mina/storage/storage.js.map +0 -1
  159. package/lib/ts/mina/token/FungibleToken.js.map +0 -1
  160. package/lib/ts/mina/token/FungibleTokenAdmin.js.map +0 -1
  161. package/lib/ts/mina/token/api.js.map +0 -1
  162. package/lib/ts/mina/token/index.js.map +0 -1
  163. package/lib/ts/mina/token/vk.js.map +0 -1
  164. package/lib/ts/mina/token/whitelist.js.map +0 -1
  165. package/lib/ts/mina/transactions/account.js.map +0 -1
  166. package/lib/ts/mina/transactions/blockberry.js.map +0 -1
  167. package/lib/ts/mina/transactions/chain.js.map +0 -1
  168. package/lib/ts/mina/transactions/index.js.map +0 -1
  169. package/lib/ts/mina/transactions/nonce.js.map +0 -1
  170. package/lib/ts/mina/transactions/send.js.map +0 -1
  171. package/lib/ts/mina/transactions/tiny-contract.js.map +0 -1
  172. package/lib/ts/mina/transactions/transaction.js.map +0 -1
  173. package/lib/ts/mina/transactions/txstatus.js.map +0 -1
  174. package/lib/ts/mina/utils/base64.js.map +0 -1
  175. package/lib/ts/mina/utils/fee.js.map +0 -1
  176. package/lib/ts/mina/utils/fetch.js.map +0 -1
  177. package/lib/ts/mina/utils/fields.js.map +0 -1
  178. package/lib/ts/mina/utils/index.js.map +0 -1
  179. package/lib/ts/mina/utils/indexed-map.js.map +0 -1
  180. package/lib/ts/mina/utils/mina.js.map +0 -1
  181. package/lib/ts/mina/verification/index.js.map +0 -1
  182. package/lib/ts/mina/verification/verification.js.map +0 -1
  183. package/lib/tsconfig.web.tsbuildinfo +0 -1
  184. package/lib/web/cloud/config.js.map +0 -1
  185. package/lib/web/cloud/index.js.map +0 -1
  186. package/lib/web/cloud/networks.js.map +0 -1
  187. package/lib/web/cloud/utils/base64.js.map +0 -1
  188. package/lib/web/cloud/utils/graphql.js.map +0 -1
  189. package/lib/web/cloud/utils/index.js.map +0 -1
  190. package/lib/web/cloud/utils/utils.js.map +0 -1
  191. package/lib/web/cloud/worker/cloud.js.map +0 -1
  192. package/lib/web/cloud/worker/index.js.map +0 -1
  193. package/lib/web/cloud/worker/transaction.js.map +0 -1
  194. package/lib/web/cloud/worker/worker.js.map +0 -1
  195. package/lib/web/index.js.map +0 -1
  196. package/lib/web/mina/api/api.js.map +0 -1
  197. package/lib/web/mina/index.js.map +0 -1
  198. package/lib/web/mina/local/local.js.map +0 -1
  199. package/lib/web/mina/storage/index.js.map +0 -1
  200. package/lib/web/mina/storage/ipfs.js.map +0 -1
  201. package/lib/web/mina/storage/pinata.js.map +0 -1
  202. package/lib/web/mina/storage/storage.js.map +0 -1
  203. package/lib/web/mina/token/FungibleToken.js.map +0 -1
  204. package/lib/web/mina/token/FungibleTokenAdmin.js.map +0 -1
  205. package/lib/web/mina/token/api.js.map +0 -1
  206. package/lib/web/mina/token/index.js.map +0 -1
  207. package/lib/web/mina/token/vk.js.map +0 -1
  208. package/lib/web/mina/token/whitelist.js.map +0 -1
  209. package/lib/web/mina/transactions/account.js.map +0 -1
  210. package/lib/web/mina/transactions/blockberry.js.map +0 -1
  211. package/lib/web/mina/transactions/chain.js.map +0 -1
  212. package/lib/web/mina/transactions/index.js.map +0 -1
  213. package/lib/web/mina/transactions/nonce.js.map +0 -1
  214. package/lib/web/mina/transactions/send.js.map +0 -1
  215. package/lib/web/mina/transactions/tiny-contract.js.map +0 -1
  216. package/lib/web/mina/transactions/transaction.js.map +0 -1
  217. package/lib/web/mina/transactions/txstatus.js.map +0 -1
  218. package/lib/web/mina/utils/base64.js.map +0 -1
  219. package/lib/web/mina/utils/fee.js.map +0 -1
  220. package/lib/web/mina/utils/fetch.js.map +0 -1
  221. package/lib/web/mina/utils/fields.js.map +0 -1
  222. package/lib/web/mina/utils/index.js.map +0 -1
  223. package/lib/web/mina/utils/indexed-map.js.map +0 -1
  224. package/lib/web/mina/utils/mina.js.map +0 -1
  225. package/lib/web/mina/verification/index.js.map +0 -1
  226. package/lib/web/mina/verification/verification.js.map +0 -1
  227. /package/{lib → dist}/ts/cloud/config.d.ts +0 -0
  228. /package/{lib → dist}/ts/cloud/config.js +0 -0
  229. /package/{lib → dist}/ts/cloud/index.d.ts +0 -0
  230. /package/{lib → dist}/ts/cloud/index.js +0 -0
  231. /package/{lib → dist}/ts/cloud/networks.d.ts +0 -0
  232. /package/{lib → dist}/ts/cloud/networks.js +0 -0
  233. /package/{lib → dist}/ts/cloud/utils/base64.d.ts +0 -0
  234. /package/{lib → dist}/ts/cloud/utils/base64.js +0 -0
  235. /package/{lib → dist}/ts/cloud/utils/graphql.d.ts +0 -0
  236. /package/{lib → dist}/ts/cloud/utils/graphql.js +0 -0
  237. /package/{lib → dist}/ts/cloud/utils/index.d.ts +0 -0
  238. /package/{lib → dist}/ts/cloud/utils/index.js +0 -0
  239. /package/{lib → dist}/ts/cloud/utils/utils.d.ts +0 -0
  240. /package/{lib → dist}/ts/cloud/utils/utils.js +0 -0
  241. /package/{lib → dist}/ts/cloud/worker/cloud.d.ts +0 -0
  242. /package/{lib → dist}/ts/cloud/worker/cloud.js +0 -0
  243. /package/{lib → dist}/ts/cloud/worker/index.d.ts +0 -0
  244. /package/{lib → dist}/ts/cloud/worker/index.js +0 -0
  245. /package/{lib → dist}/ts/cloud/worker/job.d.ts +0 -0
  246. /package/{lib → dist}/ts/cloud/worker/job.js +0 -0
  247. /package/{lib → dist}/ts/cloud/worker/task.d.ts +0 -0
  248. /package/{lib → dist}/ts/cloud/worker/task.js +0 -0
  249. /package/{lib → dist}/ts/cloud/worker/transaction.d.ts +0 -0
  250. /package/{lib → dist}/ts/cloud/worker/transaction.js +0 -0
  251. /package/{lib → dist}/ts/cloud/worker/worker.d.ts +0 -0
  252. /package/{lib → dist}/ts/cloud/worker/worker.js +0 -0
  253. /package/{lib → dist}/ts/index.d.ts +0 -0
  254. /package/{lib → dist}/ts/index.js +0 -0
  255. /package/{lib → dist}/ts/mina/api/api.d.ts +0 -0
  256. /package/{lib → dist}/ts/mina/api/api.js +0 -0
  257. /package/{lib → dist}/ts/mina/index.d.ts +0 -0
  258. /package/{lib → dist}/ts/mina/index.js +0 -0
  259. /package/{lib → dist}/ts/mina/local/local.d.ts +0 -0
  260. /package/{lib → dist}/ts/mina/local/local.js +0 -0
  261. /package/{lib → dist}/ts/mina/storage/index.d.ts +0 -0
  262. /package/{lib → dist}/ts/mina/storage/index.js +0 -0
  263. /package/{lib → dist}/ts/mina/storage/ipfs.d.ts +0 -0
  264. /package/{lib → dist}/ts/mina/storage/ipfs.js +0 -0
  265. /package/{lib → dist}/ts/mina/storage/pinata.d.ts +0 -0
  266. /package/{lib → dist}/ts/mina/storage/pinata.js +0 -0
  267. /package/{lib → dist}/ts/mina/storage/storage.d.ts +0 -0
  268. /package/{lib → dist}/ts/mina/storage/storage.js +0 -0
  269. /package/{lib → dist}/ts/mina/token/FungibleToken.d.ts +0 -0
  270. /package/{lib → dist}/ts/mina/token/FungibleToken.js +0 -0
  271. /package/{lib → dist}/ts/mina/token/FungibleTokenAdmin.d.ts +0 -0
  272. /package/{lib → dist}/ts/mina/token/FungibleTokenAdmin.js +0 -0
  273. /package/{lib → dist}/ts/mina/token/api.d.ts +0 -0
  274. /package/{lib → dist}/ts/mina/token/api.js +0 -0
  275. /package/{lib → dist}/ts/mina/token/index.d.ts +0 -0
  276. /package/{lib → dist}/ts/mina/token/index.js +0 -0
  277. /package/{lib → dist}/ts/mina/token/vk.d.ts +0 -0
  278. /package/{lib → dist}/ts/mina/token/vk.js +0 -0
  279. /package/{lib → dist}/ts/mina/token/whitelist.d.ts +0 -0
  280. /package/{lib → dist}/ts/mina/token/whitelist.js +0 -0
  281. /package/{lib → dist}/ts/mina/transactions/account.d.ts +0 -0
  282. /package/{lib → dist}/ts/mina/transactions/account.js +0 -0
  283. /package/{lib → dist}/ts/mina/transactions/blockberry.d.ts +0 -0
  284. /package/{lib → dist}/ts/mina/transactions/blockberry.js +0 -0
  285. /package/{lib → dist}/ts/mina/transactions/chain.d.ts +0 -0
  286. /package/{lib → dist}/ts/mina/transactions/chain.js +0 -0
  287. /package/{lib → dist}/ts/mina/transactions/index.d.ts +0 -0
  288. /package/{lib → dist}/ts/mina/transactions/index.js +0 -0
  289. /package/{lib → dist}/ts/mina/transactions/nonce.d.ts +0 -0
  290. /package/{lib → dist}/ts/mina/transactions/nonce.js +0 -0
  291. /package/{lib → dist}/ts/mina/transactions/send.d.ts +0 -0
  292. /package/{lib → dist}/ts/mina/transactions/send.js +0 -0
  293. /package/{lib → dist}/ts/mina/transactions/tiny-contract.d.ts +0 -0
  294. /package/{lib → dist}/ts/mina/transactions/tiny-contract.js +0 -0
  295. /package/{lib → dist}/ts/mina/transactions/transaction.d.ts +0 -0
  296. /package/{lib → dist}/ts/mina/transactions/transaction.js +0 -0
  297. /package/{lib → dist}/ts/mina/transactions/txstatus.d.ts +0 -0
  298. /package/{lib → dist}/ts/mina/transactions/txstatus.js +0 -0
  299. /package/{lib → dist}/ts/mina/utils/base64.d.ts +0 -0
  300. /package/{lib → dist}/ts/mina/utils/base64.js +0 -0
  301. /package/{lib → dist}/ts/mina/utils/fee.d.ts +0 -0
  302. /package/{lib → dist}/ts/mina/utils/fee.js +0 -0
  303. /package/{lib → dist}/ts/mina/utils/fetch.d.ts +0 -0
  304. /package/{lib → dist}/ts/mina/utils/fetch.js +0 -0
  305. /package/{lib → dist}/ts/mina/utils/fields.d.ts +0 -0
  306. /package/{lib → dist}/ts/mina/utils/fields.js +0 -0
  307. /package/{lib → dist}/ts/mina/utils/index.d.ts +0 -0
  308. /package/{lib → dist}/ts/mina/utils/index.js +0 -0
  309. /package/{lib → dist}/ts/mina/utils/indexed-map.d.ts +0 -0
  310. /package/{lib → dist}/ts/mina/utils/indexed-map.js +0 -0
  311. /package/{lib → dist}/ts/mina/utils/mina.d.ts +0 -0
  312. /package/{lib → dist}/ts/mina/utils/mina.js +0 -0
  313. /package/{lib → dist}/ts/mina/verification/index.d.ts +0 -0
  314. /package/{lib → dist}/ts/mina/verification/index.js +0 -0
  315. /package/{lib → dist}/ts/mina/verification/verification.d.ts +0 -0
  316. /package/{lib → dist}/ts/mina/verification/verification.js +0 -0
  317. /package/{lib → dist}/web/cloud/config.d.ts +0 -0
  318. /package/{lib → dist}/web/cloud/config.js +0 -0
  319. /package/{lib → dist}/web/cloud/index.d.ts +0 -0
  320. /package/{lib → dist}/web/cloud/index.js +0 -0
  321. /package/{lib → dist}/web/cloud/networks.d.ts +0 -0
  322. /package/{lib → dist}/web/cloud/networks.js +0 -0
  323. /package/{lib → dist}/web/cloud/utils/base64.d.ts +0 -0
  324. /package/{lib → dist}/web/cloud/utils/base64.js +0 -0
  325. /package/{lib → dist}/web/cloud/utils/graphql.d.ts +0 -0
  326. /package/{lib → dist}/web/cloud/utils/graphql.js +0 -0
  327. /package/{lib → dist}/web/cloud/utils/index.d.ts +0 -0
  328. /package/{lib → dist}/web/cloud/utils/index.js +0 -0
  329. /package/{lib → dist}/web/cloud/utils/utils.d.ts +0 -0
  330. /package/{lib → dist}/web/cloud/utils/utils.js +0 -0
  331. /package/{lib → dist}/web/cloud/worker/cloud.d.ts +0 -0
  332. /package/{lib → dist}/web/cloud/worker/cloud.js +0 -0
  333. /package/{lib → dist}/web/cloud/worker/index.d.ts +0 -0
  334. /package/{lib → dist}/web/cloud/worker/index.js +0 -0
  335. /package/{lib → dist}/web/cloud/worker/job.d.ts +0 -0
  336. /package/{lib → dist}/web/cloud/worker/job.js +0 -0
  337. /package/{lib → dist}/web/cloud/worker/task.d.ts +0 -0
  338. /package/{lib → dist}/web/cloud/worker/task.js +0 -0
  339. /package/{lib → dist}/web/cloud/worker/transaction.d.ts +0 -0
  340. /package/{lib → dist}/web/cloud/worker/transaction.js +0 -0
  341. /package/{lib → dist}/web/cloud/worker/worker.d.ts +0 -0
  342. /package/{lib → dist}/web/cloud/worker/worker.js +0 -0
  343. /package/{lib → dist}/web/index.d.ts +0 -0
  344. /package/{lib → dist}/web/index.js +0 -0
  345. /package/{lib → dist}/web/mina/api/api.d.ts +0 -0
  346. /package/{lib → dist}/web/mina/api/api.js +0 -0
  347. /package/{lib → dist}/web/mina/index.d.ts +0 -0
  348. /package/{lib → dist}/web/mina/index.js +0 -0
  349. /package/{lib → dist}/web/mina/local/local.d.ts +0 -0
  350. /package/{lib → dist}/web/mina/local/local.js +0 -0
  351. /package/{lib → dist}/web/mina/storage/index.d.ts +0 -0
  352. /package/{lib → dist}/web/mina/storage/index.js +0 -0
  353. /package/{lib → dist}/web/mina/storage/ipfs.d.ts +0 -0
  354. /package/{lib → dist}/web/mina/storage/ipfs.js +0 -0
  355. /package/{lib → dist}/web/mina/storage/pinata.d.ts +0 -0
  356. /package/{lib → dist}/web/mina/storage/pinata.js +0 -0
  357. /package/{lib → dist}/web/mina/storage/storage.d.ts +0 -0
  358. /package/{lib → dist}/web/mina/storage/storage.js +0 -0
  359. /package/{lib → dist}/web/mina/token/FungibleToken.d.ts +0 -0
  360. /package/{lib → dist}/web/mina/token/FungibleToken.js +0 -0
  361. /package/{lib → dist}/web/mina/token/FungibleTokenAdmin.d.ts +0 -0
  362. /package/{lib → dist}/web/mina/token/FungibleTokenAdmin.js +0 -0
  363. /package/{lib → dist}/web/mina/token/api.d.ts +0 -0
  364. /package/{lib → dist}/web/mina/token/api.js +0 -0
  365. /package/{lib → dist}/web/mina/token/index.d.ts +0 -0
  366. /package/{lib → dist}/web/mina/token/index.js +0 -0
  367. /package/{lib → dist}/web/mina/token/vk.d.ts +0 -0
  368. /package/{lib → dist}/web/mina/token/vk.js +0 -0
  369. /package/{lib → dist}/web/mina/token/whitelist.d.ts +0 -0
  370. /package/{lib → dist}/web/mina/token/whitelist.js +0 -0
  371. /package/{lib → dist}/web/mina/transactions/account.d.ts +0 -0
  372. /package/{lib → dist}/web/mina/transactions/account.js +0 -0
  373. /package/{lib → dist}/web/mina/transactions/blockberry.d.ts +0 -0
  374. /package/{lib → dist}/web/mina/transactions/blockberry.js +0 -0
  375. /package/{lib → dist}/web/mina/transactions/chain.d.ts +0 -0
  376. /package/{lib → dist}/web/mina/transactions/chain.js +0 -0
  377. /package/{lib → dist}/web/mina/transactions/index.d.ts +0 -0
  378. /package/{lib → dist}/web/mina/transactions/index.js +0 -0
  379. /package/{lib → dist}/web/mina/transactions/nonce.d.ts +0 -0
  380. /package/{lib → dist}/web/mina/transactions/nonce.js +0 -0
  381. /package/{lib → dist}/web/mina/transactions/send.d.ts +0 -0
  382. /package/{lib → dist}/web/mina/transactions/send.js +0 -0
  383. /package/{lib → dist}/web/mina/transactions/tiny-contract.d.ts +0 -0
  384. /package/{lib → dist}/web/mina/transactions/tiny-contract.js +0 -0
  385. /package/{lib → dist}/web/mina/transactions/transaction.d.ts +0 -0
  386. /package/{lib → dist}/web/mina/transactions/transaction.js +0 -0
  387. /package/{lib → dist}/web/mina/transactions/txstatus.d.ts +0 -0
  388. /package/{lib → dist}/web/mina/transactions/txstatus.js +0 -0
  389. /package/{lib → dist}/web/mina/utils/base64.d.ts +0 -0
  390. /package/{lib → dist}/web/mina/utils/base64.js +0 -0
  391. /package/{lib → dist}/web/mina/utils/fee.d.ts +0 -0
  392. /package/{lib → dist}/web/mina/utils/fee.js +0 -0
  393. /package/{lib → dist}/web/mina/utils/fetch.d.ts +0 -0
  394. /package/{lib → dist}/web/mina/utils/fetch.js +0 -0
  395. /package/{lib → dist}/web/mina/utils/fields.d.ts +0 -0
  396. /package/{lib → dist}/web/mina/utils/fields.js +0 -0
  397. /package/{lib → dist}/web/mina/utils/index.d.ts +0 -0
  398. /package/{lib → dist}/web/mina/utils/index.js +0 -0
  399. /package/{lib → dist}/web/mina/utils/indexed-map.d.ts +0 -0
  400. /package/{lib → dist}/web/mina/utils/indexed-map.js +0 -0
  401. /package/{lib → dist}/web/mina/utils/mina.d.ts +0 -0
  402. /package/{lib → dist}/web/mina/utils/mina.js +0 -0
  403. /package/{lib → dist}/web/mina/verification/index.d.ts +0 -0
  404. /package/{lib → dist}/web/mina/verification/index.js +0 -0
  405. /package/{lib → dist}/web/mina/verification/verification.d.ts +0 -0
  406. /package/{lib → dist}/web/mina/verification/verification.js +0 -0
@@ -0,0 +1,651 @@
1
+ import {
2
+ makeString,
3
+ blockchain,
4
+ TransactionMetadata,
5
+ CloudTransaction,
6
+ DeployerKeyPair,
7
+ TaskData,
8
+ JobData,
9
+ JobEvent,
10
+ Cloud,
11
+ Local,
12
+ zkCloudWorker,
13
+ } from "../../cloud/index.js";
14
+ import { ApiCommand } from "../api/api.js";
15
+
16
+ /**
17
+ * LocalCloud is a cloud that runs on the local machine for testing and development
18
+ * It uses LocalStorage to store jobs, tasks, transactions, and data
19
+ * It uses a localWorker to execute the tasks
20
+ * It can be used to test the cloud functionality without deploying to the cloud
21
+ * @param localWorker the worker to execute the tasks
22
+ */
23
+ export class LocalCloud extends Cloud {
24
+ readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
25
+
26
+ /**
27
+ * Constructor for LocalCloud
28
+ * @param params the parameters to create the LocalCloud
29
+ * @param params.job the job data
30
+ * @param params.chain the blockchain to execute the job on, can be any blockchain, not only local
31
+ * @param params.cache the cache folder
32
+ * @param params.stepId the step id
33
+ * @param params.localWorker the worker to execute the tasks
34
+ */
35
+ constructor(params: {
36
+ job: JobData;
37
+ chain: blockchain;
38
+ cache?: string;
39
+ stepId?: string;
40
+ localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
41
+ }) {
42
+ const { job, chain, cache, stepId, localWorker } = params;
43
+
44
+ const { id, jobId, developer, repo, task, userId, args, metadata, taskId } =
45
+ job;
46
+ super({
47
+ id: id,
48
+ jobId: jobId,
49
+ stepId: stepId ?? "stepId",
50
+ taskId: taskId ?? "taskId",
51
+ cache: cache ?? "./cache",
52
+ developer: developer,
53
+ repo: repo,
54
+ task: task,
55
+ userId: userId,
56
+ args: args,
57
+ metadata: metadata,
58
+ isLocalCloud: true,
59
+ chain,
60
+ });
61
+ this.localWorker = localWorker;
62
+ }
63
+
64
+ /**
65
+ * Provides the deployer key pair for testing and development
66
+ * @returns the deployer key pair
67
+ */
68
+ public async getDeployer(): Promise<DeployerKeyPair | undefined> {
69
+ const privateKey = process.env.DEPLOYER_PRIVATE_KEY;
70
+ const publicKey = process.env.DEPLOYER_PUBLIC_KEY;
71
+ try {
72
+ return privateKey === undefined || publicKey === undefined
73
+ ? undefined
74
+ : ({
75
+ privateKey,
76
+ publicKey,
77
+ } as DeployerKeyPair);
78
+ } catch (error) {
79
+ console.error(
80
+ `getDeployer: error getting deployer key pair: ${error}`,
81
+ error
82
+ );
83
+ return undefined;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Releases the deployer key pair
89
+ */
90
+ public async releaseDeployer(params: {
91
+ publicKey: string;
92
+ txsHashes: string[];
93
+ }): Promise<void> {
94
+ console.log("LocalCloud: releaseDeployer", params);
95
+ }
96
+
97
+ /**
98
+ * Gets the data by key
99
+ * @param key the key to get the data
100
+ * @returns the data
101
+ */
102
+ public async getDataByKey(key: string): Promise<string | undefined> {
103
+ const value = LocalStorage.data[key];
104
+ return value;
105
+ }
106
+
107
+ /**
108
+ * Saves the data by key
109
+ * @param key the key to save the data
110
+ * @param value the value to save
111
+ */
112
+ public async saveDataByKey(
113
+ key: string,
114
+ value: string | undefined
115
+ ): Promise<void> {
116
+ if (value !== undefined) LocalStorage.data[key] = value;
117
+ else delete LocalStorage.data[key];
118
+ }
119
+
120
+ /**
121
+ * Saves the file
122
+ * @param filename the filename to save
123
+ * @param value the value to save
124
+ */
125
+ public async saveFile(filename: string, value: Buffer): Promise<void> {
126
+ LocalStorage.files[filename] = value;
127
+ //throw new Error("Method not implemented.");
128
+ //await saveBinaryFile({ data: value, filename });
129
+ }
130
+
131
+ /**
132
+ * Loads the file
133
+ * @param filename
134
+ * @returns the file data
135
+ */
136
+ public async loadFile(filename: string): Promise<Buffer | undefined> {
137
+ return LocalStorage.files[filename];
138
+ //throw new Error("Method not implemented.");
139
+ //const data = await loadBinaryFile(filename);
140
+ //return data;
141
+ }
142
+
143
+ /**
144
+ * Encrypts the data
145
+ * @param params
146
+ * @param params.data the data
147
+ * @param params.context the context
148
+ * @param params.keyId the key id, optional
149
+ * @returns encrypted data
150
+ */
151
+ public async encrypt(params: {
152
+ data: string;
153
+ context: string;
154
+ keyId?: string;
155
+ }): Promise<string | undefined> {
156
+ return JSON.stringify(params);
157
+ }
158
+
159
+ /**
160
+ * Decrypts the data
161
+ * @param params
162
+ * @param params.data the data
163
+ * @param params.context the context
164
+ * @param params.keyId the key id, optional
165
+ * @returns
166
+ */
167
+ public async decrypt(params: {
168
+ data: string;
169
+ context: string;
170
+ keyId?: string;
171
+ }): Promise<string | undefined> {
172
+ const { data, context, keyId } = JSON.parse(params.data);
173
+ if (context !== params.context) {
174
+ console.error("decrypt: context mismatch");
175
+ return undefined;
176
+ }
177
+ if (keyId !== params.keyId) {
178
+ console.error("decrypt: keyId mismatch");
179
+ return undefined;
180
+ }
181
+ return data;
182
+ }
183
+
184
+ /**
185
+ * Generates an id for local cloud
186
+ * @returns generated unique id
187
+ */
188
+ private static generateId(tx: string | undefined = undefined): string {
189
+ //const data =
190
+ // tx ?? JSON.stringify({ time: Date.now(), data: makeString(32) });
191
+ //return stringHash(data);
192
+ return Date.now() + "." + makeString(32);
193
+ }
194
+
195
+ /**
196
+ * Send transactions to the local cloud
197
+ * @param transactions the transactions to add
198
+ * @returns the transaction ids
199
+ */
200
+ public async sendTransactions(
201
+ transactions: string[]
202
+ ): Promise<CloudTransaction[]> {
203
+ return await LocalCloud.addTransactions(transactions);
204
+ }
205
+
206
+ /**
207
+ * Adds transactions to the local cloud
208
+ * @param transactions the transactions to add
209
+ * @returns the transaction ids
210
+ */
211
+ public static async addTransactions(
212
+ transactions: string[] | CloudTransaction[]
213
+ ): Promise<CloudTransaction[]> {
214
+ const timeReceived = Date.now();
215
+ const txs: CloudTransaction[] = [];
216
+ transactions.forEach((tx) => {
217
+ if (typeof tx === "string") {
218
+ const txId = LocalCloud.generateId(
219
+ JSON.stringify({ tx, time: timeReceived })
220
+ );
221
+ const transaction: CloudTransaction = {
222
+ txId,
223
+ transaction: tx,
224
+ timeReceived,
225
+ status: "accepted",
226
+ };
227
+ LocalStorage.transactions[txId] = transaction;
228
+ txs.push(transaction);
229
+ } else {
230
+ LocalStorage.transactions[tx.txId] = tx;
231
+ txs.push(tx);
232
+ }
233
+ });
234
+ return txs;
235
+ }
236
+
237
+ /**
238
+ * Deletes a transaction from the local cloud
239
+ * @param txId the transaction id to delete
240
+ */
241
+ public async deleteTransaction(txId: string): Promise<void> {
242
+ if (LocalStorage.transactions[txId] === undefined)
243
+ throw new Error(`deleteTransaction: Transaction ${txId} not found`);
244
+ delete LocalStorage.transactions[txId];
245
+ }
246
+
247
+ public async getTransactions(): Promise<CloudTransaction[]> {
248
+ const txs = Object.keys(LocalStorage.transactions).map((txId) => {
249
+ return LocalStorage.transactions[txId];
250
+ });
251
+ return txs;
252
+ }
253
+
254
+ /**
255
+ * Publish the transaction metadata in human-readable format
256
+ * @param params
257
+ * @param params.txId the transaction id
258
+ * @param params.metadata the metadata
259
+ */
260
+ public async publishTransactionMetadata(params: {
261
+ txId: string;
262
+ metadata: TransactionMetadata;
263
+ }): Promise<void> {
264
+ console.log("publishTransactionMetadata:", params);
265
+ }
266
+
267
+ /**
268
+ * Runs the worker in the local cloud
269
+ * @param params the parameters to run the worker
270
+ * @param params.command the command to run
271
+ * @param params.data the data to use
272
+ * @param params.chain the blockchain to execute the job on
273
+ * @param params.localWorker the worker to execute the tasks
274
+ * @returns the job id
275
+ */
276
+ public static async run(params: {
277
+ command: ApiCommand;
278
+ data: {
279
+ developer: string;
280
+ repo: string;
281
+ transactions: string[];
282
+ task: string;
283
+ userId?: string;
284
+ args?: string;
285
+ metadata?: string;
286
+ };
287
+ chain: blockchain;
288
+ localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
289
+ }): Promise<string> {
290
+ const { command, data, chain, localWorker } = params;
291
+ const { developer, repo, transactions, task, userId, args, metadata } =
292
+ data;
293
+
294
+ const timeCreated = Date.now();
295
+ const jobId = LocalCloud.generateId();
296
+ const job: JobData = {
297
+ id: "local",
298
+ jobId,
299
+ developer,
300
+ repo,
301
+ task,
302
+ userId,
303
+ args,
304
+ metadata,
305
+ txNumber: command === "recursiveProof" ? transactions.length : 1,
306
+ timeCreated,
307
+ timeStarted: timeCreated,
308
+ chain,
309
+ } as JobData;
310
+ const cloud = new LocalCloud({
311
+ job,
312
+ chain,
313
+ localWorker,
314
+ });
315
+ const worker = await localWorker(cloud);
316
+ if (worker === undefined) throw new Error("worker is undefined");
317
+ const result =
318
+ command === "recursiveProof"
319
+ ? await LocalCloud.sequencer({
320
+ worker,
321
+ data,
322
+ })
323
+ : command === "execute"
324
+ ? await worker.execute(transactions)
325
+ : undefined;
326
+
327
+ const timeFinished = Date.now();
328
+ if (result !== undefined) {
329
+ LocalStorage.jobEvents[jobId] = {
330
+ jobId,
331
+ jobStatus: "finished",
332
+ eventTime: timeFinished,
333
+ result,
334
+ };
335
+ job.timeFinished = timeFinished;
336
+ job.jobStatus = "finished";
337
+ job.result = result;
338
+ } else {
339
+ LocalStorage.jobEvents[jobId] = {
340
+ jobId,
341
+ jobStatus: "failed",
342
+ eventTime: timeFinished,
343
+ };
344
+ job.timeFailed = timeFinished;
345
+ job.jobStatus = "failed";
346
+ }
347
+ job.billedDuration = timeFinished - timeCreated;
348
+ LocalStorage.jobs[jobId] = job;
349
+ return jobId;
350
+ }
351
+
352
+ /**
353
+ * Runs the recursive proof in the local cloud
354
+ * @param data the data to use
355
+ * @param data.transactions the transactions to process
356
+ * @param data.task the task to execute
357
+ * @param data.userId the user id
358
+ * @param data.args the arguments for the job
359
+ * @param data.metadata the metadata for the job
360
+ * @returns the job id
361
+ */
362
+ public async recursiveProof(data: {
363
+ transactions: string[];
364
+ task?: string;
365
+ userId?: string;
366
+ args?: string;
367
+ metadata?: string;
368
+ }): Promise<string> {
369
+ return await LocalCloud.run({
370
+ command: "recursiveProof",
371
+ data: {
372
+ developer: this.developer,
373
+ repo: this.repo,
374
+ transactions: data.transactions,
375
+ task: data.task ?? "recursiveProof",
376
+ userId: data.userId,
377
+ args: data.args,
378
+ metadata: data.metadata,
379
+ },
380
+ chain: this.chain,
381
+ localWorker: this.localWorker,
382
+ });
383
+ }
384
+
385
+ /**
386
+ * Executes the task in the local cloud
387
+ * @param data the data to use
388
+ * @param data.transactions the transactions to process
389
+ * @param data.task the task to execute
390
+ * @param data.userId the user id
391
+ * @param data.args the arguments for the job
392
+ * @param data.metadata the metadata for the job
393
+ * @returns the job id
394
+ */
395
+ public async execute(data: {
396
+ transactions: string[];
397
+ task: string;
398
+ userId?: string;
399
+ args?: string;
400
+ metadata?: string;
401
+ }): Promise<string> {
402
+ return await LocalCloud.run({
403
+ command: "execute",
404
+ data: {
405
+ developer: this.developer,
406
+ repo: this.repo,
407
+ transactions: data.transactions,
408
+ task: data.task,
409
+ userId: data.userId,
410
+ args: data.args,
411
+ metadata: data.metadata,
412
+ },
413
+ chain: this.chain,
414
+ localWorker: this.localWorker,
415
+ });
416
+ }
417
+
418
+ /**
419
+ * Gets the job result
420
+ * @param jobId the job id
421
+ * @returns the job data
422
+ */
423
+ public async jobResult(jobId: string): Promise<JobData | undefined> {
424
+ return LocalStorage.jobs[jobId];
425
+ }
426
+
427
+ /**
428
+ * Adds a task to the local cloud
429
+ * @param data the data to use
430
+ * @param data.task the task to execute
431
+ * @param data.startTime the start time for the task
432
+ * @param data.userId the user id
433
+ * @param data.args the arguments for the job
434
+ * @param data.metadata the metadata for the job
435
+ * @returns the task id
436
+ */
437
+ public async addTask(data: {
438
+ task: string;
439
+ startTime?: number;
440
+ userId?: string;
441
+ args?: string;
442
+ metadata?: string;
443
+ }): Promise<string> {
444
+ const taskId = LocalCloud.generateId();
445
+ LocalStorage.tasks[taskId] = {
446
+ ...data,
447
+ id: "local",
448
+ taskId,
449
+ timeCreated: Date.now(),
450
+ developer: this.developer,
451
+ repo: this.repo,
452
+ chain: this.chain,
453
+ } as TaskData;
454
+ return taskId;
455
+ }
456
+
457
+ /**
458
+ * Deletes a task from the local cloud
459
+ * @param taskId the task id to delete
460
+ */
461
+ public async deleteTask(taskId: string): Promise<void> {
462
+ if (LocalStorage.tasks[taskId] === undefined)
463
+ throw new Error(`deleteTask: Task ${taskId} not found`);
464
+ delete LocalStorage.tasks[taskId];
465
+ }
466
+
467
+ /**
468
+ * Processes the tasks in the local cloud
469
+ */
470
+ public async processTasks(): Promise<void> {
471
+ await LocalCloud.processLocalTasks({
472
+ developer: this.developer,
473
+ repo: this.repo,
474
+ localWorker: this.localWorker,
475
+ chain: this.chain,
476
+ });
477
+ }
478
+
479
+ /**
480
+ * Processes the local tasks
481
+ * @param params the parameters to process the local tasks
482
+ * @param params.developer the developer of the repo
483
+ * @param params.repo the repo
484
+ * @param params.localWorker the worker to execute the tasks
485
+ * @param params.chain the blockchain to execute the job on
486
+ */
487
+ static async processLocalTasks(params: {
488
+ developer: string;
489
+ repo: string;
490
+ localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
491
+ chain: blockchain;
492
+ }): Promise<number> {
493
+ const { developer, repo, localWorker, chain } = params;
494
+ for (const taskId in LocalStorage.tasks) {
495
+ const data = LocalStorage.tasks[taskId];
496
+ const jobId = LocalCloud.generateId();
497
+ const timeCreated = Date.now();
498
+ if (data.startTime !== undefined && data.startTime < timeCreated)
499
+ continue;
500
+ const job = {
501
+ id: "local",
502
+ jobId: jobId,
503
+ taskId: taskId,
504
+ developer,
505
+ repo,
506
+ task: data.task,
507
+ userId: data.userId,
508
+ args: data.args,
509
+ metadata: data.metadata,
510
+ txNumber: 1,
511
+ timeCreated: timeCreated,
512
+ } as JobData;
513
+ const cloud = new LocalCloud({
514
+ job,
515
+ chain,
516
+ localWorker,
517
+ });
518
+ const worker = await localWorker(cloud);
519
+ const result = await worker.task();
520
+ const timeFinished = Date.now();
521
+ if (result !== undefined) {
522
+ LocalStorage.jobEvents[jobId] = {
523
+ jobId,
524
+ jobStatus: "finished",
525
+ eventTime: timeFinished,
526
+ result,
527
+ };
528
+ job.timeFinished = timeFinished;
529
+ } else {
530
+ LocalStorage.jobEvents[jobId] = {
531
+ jobId,
532
+ jobStatus: "failed",
533
+ eventTime: timeFinished,
534
+ };
535
+ job.timeFailed = timeFinished;
536
+ }
537
+ job.billedDuration = timeFinished - timeCreated;
538
+ LocalStorage.jobs[jobId] = job;
539
+ }
540
+ let count = 0;
541
+ for (const task in LocalStorage.tasks) count++;
542
+ return count;
543
+ }
544
+
545
+ /**
546
+ * Runs the sequencer in the local cloud
547
+ * @param params the parameters to run the sequencer
548
+ * @param params.worker the worker to execute the tasks
549
+ * @param params.data the data to use
550
+ * @returns the proof
551
+ */
552
+ static async sequencer(params: {
553
+ worker: zkCloudWorker;
554
+ data: {
555
+ developer: string;
556
+ repo: string;
557
+ transactions: string[];
558
+ task?: string;
559
+ userId?: string;
560
+ args?: string;
561
+ metadata?: string;
562
+ };
563
+ }): Promise<string> {
564
+ const { worker, data } = params;
565
+ const { transactions } = data;
566
+ if (transactions.length === 0)
567
+ throw new Error("No transactions to process");
568
+ const proofs: string[] = [];
569
+ for (const transaction of transactions) {
570
+ const result = await worker.create(transaction);
571
+ if (result === undefined) throw new Error("Failed to create proof");
572
+ proofs.push(result);
573
+ }
574
+ let proof = proofs[0];
575
+ for (let i = 1; i < proofs.length; i++) {
576
+ const result = await worker.merge(proof, proofs[i]);
577
+ if (result === undefined) throw new Error("Failed to merge proofs");
578
+ proof = result;
579
+ }
580
+ return proof;
581
+ }
582
+
583
+ /**
584
+ * forces the worker to restart
585
+ */
586
+ async forceWorkerRestart(): Promise<void> {
587
+ throw new Error("forceWorkerRestart called in LocalCloud");
588
+ }
589
+ }
590
+
591
+ /**
592
+ * LocalStorage is a local storage for the local cloud.
593
+ * It stores jobs, tasks, transactions, and data.
594
+ * It can be used to test the cloud functionality without deploying to the cloud.
595
+ */
596
+ export class LocalStorage {
597
+ /** The jobs */
598
+ static jobs: { [key: string]: JobData } = {};
599
+
600
+ /** The job events */
601
+ static jobEvents: { [key: string]: JobEvent } = {};
602
+
603
+ /** The data */
604
+ static data: { [key: string]: string } = {};
605
+
606
+ /** The files */
607
+ static files: { [key: string]: Buffer } = {};
608
+
609
+ /** The transactions */
610
+ static transactions: {
611
+ [key: string]: CloudTransaction;
612
+ } = {};
613
+
614
+ /** The tasks */
615
+ static tasks: { [key: string]: TaskData } = {};
616
+
617
+ /**
618
+ * Saves the data.
619
+ * @param name The name to save the data under.
620
+ * @throws Error Method not implemented to keep web compatibility.
621
+ */
622
+ static async saveData(name: string): Promise<void> {
623
+ throw new Error("Method not implemented to keep web compatibility.");
624
+ const data = {
625
+ jobs: LocalStorage.jobs,
626
+ data: LocalStorage.data,
627
+ transactions: LocalStorage.transactions,
628
+ tasks: LocalStorage.tasks,
629
+ };
630
+ const filename = name + ".cloud";
631
+ // await saveFile({ data, filename });
632
+ }
633
+
634
+ /**
635
+ * Loads the data.
636
+ * @param name The name to load the data from.
637
+ * @throws Error Method not implemented to keep web compatibility.
638
+ */
639
+ static async loadData(name: string): Promise<void> {
640
+ throw new Error("Method not implemented to keep web compatibility.");
641
+ const filename = name + ".cloud";
642
+ /*
643
+ const data = await loadFile(filename);
644
+ if (data === undefined) return;
645
+ LocalStorage.jobs = data.jobs;
646
+ LocalStorage.data = data.data;
647
+ LocalStorage.transactions = data.transactions;
648
+ LocalStorage.tasks = data.tasks;
649
+ */
650
+ }
651
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./ipfs.js";
2
+ export * from "./pinata.js";
3
+ export * from "./storage.js";
@@ -0,0 +1,20 @@
1
+ export function createIpfsURL(params: {
2
+ hash: string;
3
+ gateway?: string;
4
+ apiToken?: string;
5
+ }): string {
6
+ let { hash, gateway, apiToken } = params;
7
+ gateway ??=
8
+ process.env.PINATA_IPFS_GATEWAY ??
9
+ process.env.NEXT_PUBLIC_PINATA_IPFS_GATEWAY ??
10
+ process.env.REACT_APP_PINATA_IPFS_GATEWAY;
11
+ apiToken ??=
12
+ process.env.PINATA_GATEWAY_TOKEN ??
13
+ process.env.NEXT_PUBLIC_PINATA_GATEWAY_TOKEN ??
14
+ process.env.REACT_APP_PINATA_GATEWAY_TOKEN;
15
+
16
+ if (!gateway) {
17
+ gateway = "https://gateway.pinata.cloud/ipfs/";
18
+ }
19
+ return gateway + hash + (apiToken ? "?pinataGatewayToken=" + apiToken : "");
20
+ }