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,52 @@
1
+ export async function pinJSON(params: {
2
+ data: string | object;
3
+ name?: string;
4
+ keyvalues?: object;
5
+ auth?: string;
6
+ }): Promise<string | undefined> {
7
+ const {
8
+ data,
9
+ name = "data.json",
10
+ keyvalues = [{ key: "library", value: "zkcloudworker" }],
11
+ } = params;
12
+ const auth =
13
+ params.auth ??
14
+ process.env.PINATA_JWT ??
15
+ process.env.NEXT_PUBLIC_PINATA_JWT ??
16
+ process.env.REACT_APP_PINATA_JWT;
17
+
18
+ try {
19
+ const pinataData = {
20
+ pinataOptions: {
21
+ cidVersion: 1,
22
+ },
23
+ pinataMetadata: {
24
+ name,
25
+ keyvalues,
26
+ },
27
+ pinataContent: data,
28
+ };
29
+
30
+ const res = await fetch("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ Authorization: "Bearer " + auth,
35
+ },
36
+ body: JSON.stringify(pinataData),
37
+ });
38
+
39
+ if (!res.ok) {
40
+ throw new Error(`Pinata error: status: ${res.status} ${res.statusText}`);
41
+ }
42
+
43
+ const responseData = await res.json();
44
+ console.log("saveToIPFS result:", responseData);
45
+ return (
46
+ responseData as unknown as { IpfsHash: string | undefined } | undefined
47
+ )?.IpfsHash;
48
+ } catch (error: any) {
49
+ console.error("saveToIPFS error:", error?.message);
50
+ return undefined;
51
+ }
52
+ }
@@ -0,0 +1,55 @@
1
+ import { Field, Bool, Struct, Encoding, Provable } from "o1js";
2
+
3
+ /**
4
+ * Represents the off-chain storage information,
5
+ * such as an IPFS hash.
6
+ */
7
+ export class Storage extends Struct({
8
+ url: Provable.Array(Field, 2),
9
+ }) {
10
+ constructor(value: { url: [Field, Field] }) {
11
+ super(value);
12
+ }
13
+
14
+ /**
15
+ * Asserts that two Storage instances are equal.
16
+ * @param a The first Storage instance.
17
+ * @param b The second Storage instance.
18
+ */
19
+ static assertEquals(a: Storage, b: Storage) {
20
+ a.url[0].assertEquals(b.url[0]);
21
+ a.url[1].assertEquals(b.url[1]);
22
+ }
23
+
24
+ /**
25
+ * Checks if two Storage instances are equal.
26
+ * @param a The first Storage instance.
27
+ * @param b The second Storage instance.
28
+ * @returns A Bool indicating whether the two instances are equal.
29
+ */
30
+ static equals(a: Storage, b: Storage): Bool {
31
+ return a.url[0].equals(b.url[0]).and(a.url[1].equals(b.url[1]));
32
+ }
33
+
34
+ /**
35
+ * Creates a Storage instance from a string.
36
+ * @param url The string representing the storage URL.
37
+ * @returns A new Storage instance.
38
+ */
39
+ static fromString(url: string): Storage {
40
+ const fields = Encoding.stringToFields(url);
41
+ if (fields.length !== 2) throw new Error("Invalid string length");
42
+ return new Storage({ url: [fields[0], fields[1]] });
43
+ }
44
+
45
+ /**
46
+ * Converts the Storage instance to a string.
47
+ * @returns The string representation of the storage URL.
48
+ */
49
+ toString(): string {
50
+ if (this.url[0].toBigInt() === 0n && this.url[1].toBigInt() === 0n) {
51
+ throw new Error("Invalid string");
52
+ }
53
+ return Encoding.stringFromFields([this.url[0], this.url[1]]);
54
+ }
55
+ }
@@ -0,0 +1,316 @@
1
+ import {
2
+ AccountUpdate,
3
+ AccountUpdateForest,
4
+ assert,
5
+ Bool,
6
+ DeployArgs,
7
+ Field,
8
+ Int64,
9
+ method,
10
+ Permissions,
11
+ Provable,
12
+ PublicKey,
13
+ State,
14
+ state,
15
+ Struct,
16
+ TokenContract,
17
+ Types,
18
+ UInt64,
19
+ UInt8,
20
+ VerificationKey,
21
+ } from "o1js";
22
+ import {
23
+ FungibleTokenAdmin,
24
+ FungibleTokenAdminBase,
25
+ } from "./FungibleTokenAdmin.js";
26
+
27
+ interface FungibleTokenDeployProps extends Exclude<DeployArgs, undefined> {
28
+ /** The token symbol. */
29
+ symbol: string;
30
+ /** A source code reference, which is placed within the `zkappUri` of the contract account.
31
+ * Typically a link to a file on github. */
32
+ src: string;
33
+ }
34
+
35
+ export const FungibleTokenErrors = {
36
+ noAdminKey: "could not fetch admin contract key",
37
+ noPermissionToChangeAdmin: "Not allowed to change admin contract",
38
+ tokenPaused: "Token is currently paused",
39
+ noPermissionToMint: "Not allowed to mint tokens",
40
+ noPermissionToPause: "Not allowed to pause token",
41
+ noPermissionToResume: "Not allowed to resume token",
42
+ noTransferFromCirculation: "Can't transfer to/from the circulation account",
43
+ noPermissionChangeAllowed:
44
+ "Can't change permissions for access or receive on token accounts",
45
+ flashMinting:
46
+ "Flash-minting or unbalanced transaction detected. Please make sure that your transaction is balanced, and that your `AccountUpdate`s are ordered properly, so that tokens are not received before they are sent.",
47
+ unbalancedTransaction: "Transaction is unbalanced",
48
+ };
49
+
50
+ export class FungibleToken extends TokenContract {
51
+ @state(UInt8)
52
+ decimals = State<UInt8>();
53
+ @state(PublicKey)
54
+ admin = State<PublicKey>();
55
+ @state(Bool)
56
+ paused = State<Bool>();
57
+
58
+ // This defines the type of the contract that is used to control access to administrative actions.
59
+ // If you want to have a custom contract, overwrite this by setting FungibleToken.AdminContract to
60
+ // your own implementation of FungibleTokenAdminBase.
61
+ static AdminContract: new (...args: any) => FungibleTokenAdminBase =
62
+ FungibleTokenAdmin;
63
+
64
+ readonly events = {
65
+ SetAdmin: SetAdminEvent,
66
+ Pause: PauseEvent,
67
+ Mint: MintEvent,
68
+ Burn: BurnEvent,
69
+ BalanceChange: BalanceChangeEvent,
70
+ };
71
+
72
+ async deploy(props: FungibleTokenDeployProps) {
73
+ await super.deploy(props);
74
+ this.paused.set(Bool(true));
75
+ this.account.zkappUri.set(props.src);
76
+ this.account.tokenSymbol.set(props.symbol);
77
+
78
+ this.account.permissions.set({
79
+ ...Permissions.default(),
80
+ setVerificationKey:
81
+ Permissions.VerificationKey.impossibleDuringCurrentVersion(),
82
+ setPermissions: Permissions.impossible(),
83
+ access: Permissions.proof(),
84
+ });
85
+ }
86
+
87
+ /** Update the verification key.
88
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
89
+ */
90
+ @method
91
+ async updateVerificationKey(vk: VerificationKey) {
92
+ this.account.verificationKey.set(vk);
93
+ }
94
+
95
+ /** Initializes the account for tracking total circulation.
96
+ * @argument {PublicKey} admin - public key where the admin contract is deployed
97
+ * @argument {UInt8} decimals - number of decimals for the token
98
+ * @argument {Bool} startPaused - if set to `Bool(true), the contract will start in a mode where token minting and transfers are paused. This should be used for non-atomic deployments
99
+ */
100
+ @method
101
+ async initialize(admin: PublicKey, decimals: UInt8, startPaused: Bool) {
102
+ this.account.provedState.requireEquals(Bool(false));
103
+
104
+ this.admin.set(admin);
105
+ this.decimals.set(decimals);
106
+ this.paused.set(Bool(false));
107
+
108
+ this.paused.set(startPaused);
109
+
110
+ const accountUpdate = AccountUpdate.createSigned(
111
+ this.address,
112
+ this.deriveTokenId()
113
+ );
114
+ let permissions = Permissions.default();
115
+ // This is necessary in order to allow token holders to burn.
116
+ permissions.send = Permissions.none();
117
+ permissions.setPermissions = Permissions.impossible();
118
+ accountUpdate.account.permissions.set(permissions);
119
+ }
120
+
121
+ public async getAdminContract(): Promise<FungibleTokenAdminBase> {
122
+ const admin = await Provable.witnessAsync(PublicKey, async () => {
123
+ let pk = await this.admin.fetch();
124
+ assert(pk !== undefined, FungibleTokenErrors.noAdminKey);
125
+ return pk;
126
+ });
127
+ this.admin.requireEquals(admin);
128
+ return new FungibleToken.AdminContract(admin);
129
+ }
130
+
131
+ @method
132
+ async setAdmin(admin: PublicKey) {
133
+ const adminContract = await this.getAdminContract();
134
+ const canChangeAdmin = await adminContract.canChangeAdmin(admin);
135
+ canChangeAdmin.assertTrue(FungibleTokenErrors.noPermissionToChangeAdmin);
136
+ this.admin.set(admin);
137
+ this.emitEvent("SetAdmin", new SetAdminEvent({ adminKey: admin }));
138
+ }
139
+
140
+ @method.returns(AccountUpdate)
141
+ async mint(recipient: PublicKey, amount: UInt64): Promise<AccountUpdate> {
142
+ this.paused
143
+ .getAndRequireEquals()
144
+ .assertFalse(FungibleTokenErrors.tokenPaused);
145
+ const accountUpdate = this.internal.mint({ address: recipient, amount });
146
+ const adminContract = await this.getAdminContract();
147
+ const canMint = await adminContract.canMint(accountUpdate);
148
+ canMint.assertTrue(FungibleTokenErrors.noPermissionToMint);
149
+ recipient
150
+ .equals(this.address)
151
+ .assertFalse(FungibleTokenErrors.noTransferFromCirculation);
152
+ this.approve(accountUpdate);
153
+ this.emitEvent("Mint", new MintEvent({ recipient, amount }));
154
+ const circulationUpdate = AccountUpdate.create(
155
+ this.address,
156
+ this.deriveTokenId()
157
+ );
158
+ circulationUpdate.balanceChange = Int64.fromUnsigned(amount);
159
+ return accountUpdate;
160
+ }
161
+
162
+ @method.returns(AccountUpdate)
163
+ async burn(from: PublicKey, amount: UInt64): Promise<AccountUpdate> {
164
+ this.paused
165
+ .getAndRequireEquals()
166
+ .assertFalse(FungibleTokenErrors.tokenPaused);
167
+ const accountUpdate = this.internal.burn({ address: from, amount });
168
+ const circulationUpdate = AccountUpdate.create(
169
+ this.address,
170
+ this.deriveTokenId()
171
+ );
172
+ from
173
+ .equals(this.address)
174
+ .assertFalse(FungibleTokenErrors.noTransferFromCirculation);
175
+ circulationUpdate.balanceChange = Int64.fromUnsigned(amount).neg();
176
+ this.emitEvent("Burn", new BurnEvent({ from, amount }));
177
+ return accountUpdate;
178
+ }
179
+
180
+ @method
181
+ async pause() {
182
+ const adminContract = await this.getAdminContract();
183
+ const canPause = await adminContract.canPause();
184
+ canPause.assertTrue(FungibleTokenErrors.noPermissionToPause);
185
+ this.paused.set(Bool(true));
186
+ this.emitEvent("Pause", new PauseEvent({ isPaused: Bool(true) }));
187
+ }
188
+
189
+ @method
190
+ async resume() {
191
+ const adminContract = await this.getAdminContract();
192
+ const canResume = await adminContract.canResume();
193
+ canResume.assertTrue(FungibleTokenErrors.noPermissionToResume);
194
+ this.paused.set(Bool(false));
195
+ this.emitEvent("Pause", new PauseEvent({ isPaused: Bool(false) }));
196
+ }
197
+
198
+ @method
199
+ async transfer(from: PublicKey, to: PublicKey, amount: UInt64) {
200
+ this.paused
201
+ .getAndRequireEquals()
202
+ .assertFalse(FungibleTokenErrors.tokenPaused);
203
+ from
204
+ .equals(this.address)
205
+ .assertFalse(FungibleTokenErrors.noTransferFromCirculation);
206
+ to.equals(this.address).assertFalse(
207
+ FungibleTokenErrors.noTransferFromCirculation
208
+ );
209
+ this.internal.send({ from, to, amount });
210
+ }
211
+
212
+ private checkPermissionsUpdate(update: AccountUpdate) {
213
+ let permissions = update.update.permissions;
214
+
215
+ let { access, receive } = permissions.value;
216
+ let accessIsNone = Provable.equal(
217
+ Types.AuthRequired,
218
+ access,
219
+ Permissions.none()
220
+ );
221
+ let receiveIsNone = Provable.equal(
222
+ Types.AuthRequired,
223
+ receive,
224
+ Permissions.none()
225
+ );
226
+ let updateAllowed = accessIsNone.and(receiveIsNone);
227
+
228
+ assert(
229
+ updateAllowed.or(permissions.isSome.not()),
230
+ FungibleTokenErrors.noPermissionChangeAllowed
231
+ );
232
+ }
233
+
234
+ /** Approve `AccountUpdate`s that have been created outside of the token contract.
235
+ *
236
+ * @argument {AccountUpdateForest} updates - The `AccountUpdate`s to approve. Note that the forest size is limited by the base token contract, @see TokenContractV2.MAX_ACCOUNT_UPDATES The current limit is 9.
237
+ */
238
+ @method
239
+ async approveBase(updates: AccountUpdateForest): Promise<void> {
240
+ this.paused
241
+ .getAndRequireEquals()
242
+ .assertFalse(FungibleTokenErrors.tokenPaused);
243
+ let totalBalance = Int64.from(0);
244
+ this.forEachUpdate(updates, (update, usesToken) => {
245
+ // Make sure that the account permissions are not changed
246
+ this.checkPermissionsUpdate(update);
247
+ this.emitEventIf(
248
+ usesToken,
249
+ "BalanceChange",
250
+ new BalanceChangeEvent({
251
+ address: update.publicKey,
252
+ amount: update.balanceChange,
253
+ })
254
+ );
255
+ // Don't allow transfers to/from the account that's tracking circulation
256
+ update.publicKey
257
+ .equals(this.address)
258
+ .and(usesToken)
259
+ .assertFalse(FungibleTokenErrors.noTransferFromCirculation);
260
+ totalBalance = Provable.if(
261
+ usesToken,
262
+ totalBalance.add(update.balanceChange),
263
+ totalBalance
264
+ );
265
+ totalBalance.isPositive().assertFalse(FungibleTokenErrors.flashMinting);
266
+ });
267
+ totalBalance.assertEquals(
268
+ Int64.zero,
269
+ FungibleTokenErrors.unbalancedTransaction
270
+ );
271
+ }
272
+
273
+ @method.returns(UInt64)
274
+ async getBalanceOf(address: PublicKey): Promise<UInt64> {
275
+ const account = AccountUpdate.create(address, this.deriveTokenId()).account;
276
+ const balance = account.balance.get();
277
+ account.balance.requireEquals(balance);
278
+ return balance;
279
+ }
280
+
281
+ /** Reports the current circulating supply
282
+ * This does take into account currently unreduced actions.
283
+ */
284
+ async getCirculating(): Promise<UInt64> {
285
+ let circulating = await this.getBalanceOf(this.address);
286
+ return circulating;
287
+ }
288
+
289
+ @method.returns(UInt8)
290
+ async getDecimals(): Promise<UInt8> {
291
+ return this.decimals.getAndRequireEquals();
292
+ }
293
+ }
294
+
295
+ export class SetAdminEvent extends Struct({
296
+ adminKey: PublicKey,
297
+ }) {}
298
+
299
+ export class PauseEvent extends Struct({
300
+ isPaused: Bool,
301
+ }) {}
302
+
303
+ export class MintEvent extends Struct({
304
+ recipient: PublicKey,
305
+ amount: UInt64,
306
+ }) {}
307
+
308
+ export class BurnEvent extends Struct({
309
+ from: PublicKey,
310
+ amount: UInt64,
311
+ }) {}
312
+
313
+ export class BalanceChangeEvent extends Struct({
314
+ address: PublicKey,
315
+ amount: Int64,
316
+ }) {}
@@ -0,0 +1,95 @@
1
+ import {
2
+ AccountUpdate,
3
+ assert,
4
+ Bool,
5
+ DeployArgs,
6
+ method,
7
+ Permissions,
8
+ Provable,
9
+ PublicKey,
10
+ SmartContract,
11
+ State,
12
+ state,
13
+ VerificationKey,
14
+ } from "o1js";
15
+
16
+ export type FungibleTokenAdminBase = SmartContract & {
17
+ canMint(accountUpdate: AccountUpdate): Promise<Bool>;
18
+ canChangeAdmin(admin: PublicKey): Promise<Bool>;
19
+ canPause(): Promise<Bool>;
20
+ canResume(): Promise<Bool>;
21
+ };
22
+
23
+ export interface FungibleTokenAdminDeployProps
24
+ extends Exclude<DeployArgs, undefined> {
25
+ adminPublicKey: PublicKey;
26
+ }
27
+
28
+ /** A contract that grants permissions for administrative actions on a token.
29
+ *
30
+ * We separate this out into a dedicated contract. That way, when issuing a token, a user can
31
+ * specify their own rules for administrative actions, without changing the token contract itself.
32
+ *
33
+ * The advantage is that third party applications that only use the token in a non-privileged way
34
+ * can integrate against the unchanged token contract.
35
+ */
36
+ export class FungibleTokenAdmin
37
+ extends SmartContract
38
+ implements FungibleTokenAdminBase
39
+ {
40
+ @state(PublicKey)
41
+ private adminPublicKey = State<PublicKey>();
42
+
43
+ async deploy(props: FungibleTokenAdminDeployProps) {
44
+ await super.deploy(props);
45
+ this.adminPublicKey.set(props.adminPublicKey);
46
+ this.account.permissions.set({
47
+ ...Permissions.default(),
48
+ setVerificationKey:
49
+ Permissions.VerificationKey.impossibleDuringCurrentVersion(),
50
+ setPermissions: Permissions.impossible(),
51
+ });
52
+ }
53
+
54
+ /** Update the verification key.
55
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
56
+ */
57
+ @method
58
+ async updateVerificationKey(vk: VerificationKey) {
59
+ this.account.verificationKey.set(vk);
60
+ }
61
+
62
+ private async ensureAdminSignature() {
63
+ const admin = await Provable.witnessAsync(PublicKey, async () => {
64
+ let pk = await this.adminPublicKey.fetch();
65
+ assert(pk !== undefined, "could not fetch admin public key");
66
+ return pk;
67
+ });
68
+ this.adminPublicKey.requireEquals(admin);
69
+ return AccountUpdate.createSigned(admin);
70
+ }
71
+
72
+ @method.returns(Bool)
73
+ public async canMint(_accountUpdate: AccountUpdate) {
74
+ await this.ensureAdminSignature();
75
+ return Bool(true);
76
+ }
77
+
78
+ @method.returns(Bool)
79
+ public async canChangeAdmin(_admin: PublicKey) {
80
+ await this.ensureAdminSignature();
81
+ return Bool(true);
82
+ }
83
+
84
+ @method.returns(Bool)
85
+ public async canPause(): Promise<Bool> {
86
+ await this.ensureAdminSignature();
87
+ return Bool(true);
88
+ }
89
+
90
+ @method.returns(Bool)
91
+ public async canResume(): Promise<Bool> {
92
+ await this.ensureAdminSignature();
93
+ return Bool(true);
94
+ }
95
+ }
@@ -0,0 +1,182 @@
1
+ import { blockchain, Cloud, JobStatus } from "../../cloud/index.js";
2
+ import { zkCloudWorkerClient } from "../api/api.js";
3
+ import { zkCloudWorker } from "../../cloud/worker/index.js";
4
+
5
+ export interface FungibleTokenDeployParams {
6
+ txType: "deploy";
7
+ tokenAddress: string;
8
+ adminContractAddress: string;
9
+ senderAddress: string;
10
+ chain: string;
11
+ symbol: string;
12
+ uri: string;
13
+ serializedTransaction: string;
14
+ signedData: string;
15
+ sendTransaction: boolean;
16
+ developerAddress?: string;
17
+ developerFee?: number;
18
+ }
19
+
20
+ export type FungibleTokenTransactionType =
21
+ | "mint"
22
+ | "transfer"
23
+ | "bid"
24
+ | "offer"
25
+ | "buy"
26
+ | "sell"
27
+ | "withdrawBid"
28
+ | "withdrawOffer";
29
+ export interface FungibleTokenTransactionParams {
30
+ txType: FungibleTokenTransactionType;
31
+ tokenAddress: string;
32
+ chain: string;
33
+ serializedTransaction: string;
34
+ signedData: string;
35
+ from: string;
36
+ to: string;
37
+ amount: number;
38
+ price?: number;
39
+ sendTransaction: boolean;
40
+ developerAddress?: string;
41
+ developerFee?: number;
42
+ symbol?: string;
43
+ }
44
+
45
+ export interface FungibleTokenJobResult {
46
+ success: boolean;
47
+ jobStatus?: JobStatus;
48
+ tx?: string;
49
+ hash?: string;
50
+ error?: string;
51
+ }
52
+
53
+ export class TokenAPI {
54
+ readonly client: zkCloudWorkerClient;
55
+
56
+ constructor(params: {
57
+ jwt: string;
58
+ zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker>;
59
+ chain: blockchain;
60
+ }) {
61
+ const { jwt, zkcloudworker, chain } = params;
62
+ if (jwt === undefined) throw new Error("jwt is undefined");
63
+
64
+ this.client = new zkCloudWorkerClient({
65
+ jwt,
66
+ chain,
67
+ zkcloudworker,
68
+ });
69
+ }
70
+
71
+ async sendDeployTransaction(
72
+ params: FungibleTokenDeployParams
73
+ ): Promise<string | undefined> {
74
+ const { symbol } = params;
75
+
76
+ const transaction = JSON.stringify(params, null, 2);
77
+
78
+ const answer = await this.client.execute({
79
+ developer: "DFST",
80
+ repo: "token-launchpad",
81
+ transactions: [transaction],
82
+ task: "deploy",
83
+ args: JSON.stringify({ tokenAddress: params.tokenAddress }),
84
+ metadata: `deploy token ${symbol}`,
85
+ });
86
+
87
+ const jobId = answer.jobId;
88
+ if (jobId === undefined)
89
+ console.error("Deploy Job ID is undefined", { answer, symbol });
90
+ return jobId;
91
+ }
92
+
93
+ async sendTransaction(
94
+ params: FungibleTokenTransactionParams
95
+ ): Promise<string | undefined> {
96
+ const { txType, symbol } = params;
97
+
98
+ const transaction = JSON.stringify(params, null, 2);
99
+
100
+ const answer = await this.client.execute({
101
+ developer: "DFST",
102
+ repo: "token-launchpad",
103
+ transactions: [transaction],
104
+ task: txType,
105
+ args: JSON.stringify({ tokenAddress: params.tokenAddress }),
106
+ metadata: `${txType} token${symbol ? ` ${symbol}` : ""}`,
107
+ });
108
+ const jobId = answer.jobId;
109
+ if (jobId === undefined)
110
+ console.error("Job ID is undefined", { answer, txType, symbol });
111
+ return jobId;
112
+ }
113
+
114
+ // Warning: this function will block the thread until the job is done and will print logs to the console
115
+ // Do not use it in "use server" functions, use getResult instead
116
+ async waitForJobResult(params: {
117
+ jobId: string;
118
+ maxAttempts?: number;
119
+ interval?: number;
120
+ maxErrors?: number;
121
+ printLogs?: boolean;
122
+ }): Promise<string | undefined> {
123
+ const deployResult = await this.client.waitForJobResult(params);
124
+ console.log(
125
+ "waitForJobResult result:",
126
+ deployResult?.result?.result?.slice(0, 50)
127
+ );
128
+ return deployResult?.result?.result ?? "error";
129
+ }
130
+
131
+ async getResult(jobId: string): Promise<FungibleTokenJobResult> {
132
+ try {
133
+ const callResult = await this.client.jobResult({ jobId });
134
+ const jobStatus: JobStatus | undefined =
135
+ callResult?.success === true
136
+ ? callResult?.result?.jobStatus
137
+ : undefined;
138
+ if (!callResult.success) {
139
+ return {
140
+ success: false,
141
+ error: callResult?.error,
142
+ jobStatus,
143
+ };
144
+ }
145
+ const jobResult = callResult.result?.result;
146
+ if (callResult.error)
147
+ return {
148
+ success: false,
149
+ error: callResult.error,
150
+ jobStatus,
151
+ };
152
+ if (!jobResult) return { success: true, jobStatus };
153
+
154
+ if (jobResult.toLowerCase().startsWith("error"))
155
+ return {
156
+ success: false,
157
+ error: jobResult,
158
+ jobStatus,
159
+ };
160
+
161
+ try {
162
+ const { success, tx, hash, error } = JSON.parse(jobResult);
163
+ if (success === undefined)
164
+ return {
165
+ success: false,
166
+ tx,
167
+ hash,
168
+ error,
169
+ jobStatus,
170
+ };
171
+ return { success, tx, hash, error, jobStatus };
172
+ } catch (e) {
173
+ return {
174
+ success: false,
175
+ error: `Error parsing job result: ${jobResult}`,
176
+ };
177
+ }
178
+ } catch (e) {
179
+ return { success: false, error: `Error getting job result: ${e}` };
180
+ }
181
+ }
182
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./FungibleToken.js";
2
+ export * from "./FungibleTokenAdmin.js";
3
+ export * from "./api.js";
4
+ export * from "./vk.js";
5
+ export * from "./whitelist.js";