zkcloudworker 0.18.2 → 0.18.4
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +2 -4
- package/dist/ts/cloud/config.js.map +1 -0
- package/dist/ts/cloud/index.js.map +1 -0
- package/dist/ts/cloud/networks.js.map +1 -0
- package/dist/ts/cloud/utils/base64.js.map +1 -0
- package/dist/ts/cloud/utils/graphql.js.map +1 -0
- package/dist/ts/cloud/utils/index.js.map +1 -0
- package/dist/ts/cloud/utils/utils.js.map +1 -0
- package/dist/ts/cloud/worker/cloud.js.map +1 -0
- package/dist/ts/cloud/worker/index.js.map +1 -0
- package/{lib → dist}/ts/cloud/worker/job.js.map +1 -1
- package/{lib → dist}/ts/cloud/worker/task.js.map +1 -1
- package/dist/ts/cloud/worker/transaction.js.map +1 -0
- package/dist/ts/cloud/worker/worker.js.map +1 -0
- package/dist/ts/index.js.map +1 -0
- package/dist/ts/mina/api/api.js.map +1 -0
- package/dist/ts/mina/index.js.map +1 -0
- package/dist/ts/mina/local/local.js.map +1 -0
- package/dist/ts/mina/storage/index.js.map +1 -0
- package/dist/ts/mina/storage/ipfs.js.map +1 -0
- package/dist/ts/mina/storage/pinata.js.map +1 -0
- package/dist/ts/mina/storage/storage.js.map +1 -0
- package/dist/ts/mina/token/FungibleToken.js.map +1 -0
- package/dist/ts/mina/token/FungibleTokenAdmin.js.map +1 -0
- package/dist/ts/mina/token/api.js.map +1 -0
- package/dist/ts/mina/token/index.js.map +1 -0
- package/dist/ts/mina/token/vk.js.map +1 -0
- package/dist/ts/mina/token/whitelist.js.map +1 -0
- package/dist/ts/mina/transactions/account.js.map +1 -0
- package/dist/ts/mina/transactions/blockberry.js.map +1 -0
- package/dist/ts/mina/transactions/chain.js.map +1 -0
- package/dist/ts/mina/transactions/index.js.map +1 -0
- package/dist/ts/mina/transactions/nonce.js.map +1 -0
- package/dist/ts/mina/transactions/send.js.map +1 -0
- package/dist/ts/mina/transactions/tiny-contract.js.map +1 -0
- package/dist/ts/mina/transactions/transaction.js.map +1 -0
- package/dist/ts/mina/transactions/txstatus.js.map +1 -0
- package/dist/ts/mina/utils/base64.js.map +1 -0
- package/dist/ts/mina/utils/fee.js.map +1 -0
- package/dist/ts/mina/utils/fetch.js.map +1 -0
- package/dist/ts/mina/utils/fields.js.map +1 -0
- package/dist/ts/mina/utils/index.js.map +1 -0
- package/dist/ts/mina/utils/indexed-map.js.map +1 -0
- package/dist/ts/mina/utils/mina.js.map +1 -0
- package/dist/ts/mina/verification/index.js.map +1 -0
- package/dist/ts/mina/verification/verification.js.map +1 -0
- package/dist/tsconfig.web.tsbuildinfo +1 -0
- package/dist/web/cloud/config.js.map +1 -0
- package/dist/web/cloud/index.js.map +1 -0
- package/dist/web/cloud/networks.js.map +1 -0
- package/dist/web/cloud/utils/base64.js.map +1 -0
- package/dist/web/cloud/utils/graphql.js.map +1 -0
- package/dist/web/cloud/utils/index.js.map +1 -0
- package/dist/web/cloud/utils/utils.js.map +1 -0
- package/dist/web/cloud/worker/cloud.js.map +1 -0
- package/dist/web/cloud/worker/index.js.map +1 -0
- package/{lib → dist}/web/cloud/worker/job.js.map +1 -1
- package/{lib → dist}/web/cloud/worker/task.js.map +1 -1
- package/dist/web/cloud/worker/transaction.js.map +1 -0
- package/dist/web/cloud/worker/worker.js.map +1 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/mina/api/api.js.map +1 -0
- package/dist/web/mina/index.js.map +1 -0
- package/dist/web/mina/local/local.js.map +1 -0
- package/dist/web/mina/storage/index.js.map +1 -0
- package/dist/web/mina/storage/ipfs.js.map +1 -0
- package/dist/web/mina/storage/pinata.js.map +1 -0
- package/dist/web/mina/storage/storage.js.map +1 -0
- package/dist/web/mina/token/FungibleToken.js.map +1 -0
- package/dist/web/mina/token/FungibleTokenAdmin.js.map +1 -0
- package/dist/web/mina/token/api.js.map +1 -0
- package/dist/web/mina/token/index.js.map +1 -0
- package/dist/web/mina/token/vk.js.map +1 -0
- package/dist/web/mina/token/whitelist.js.map +1 -0
- package/dist/web/mina/transactions/account.js.map +1 -0
- package/dist/web/mina/transactions/blockberry.js.map +1 -0
- package/dist/web/mina/transactions/chain.js.map +1 -0
- package/dist/web/mina/transactions/index.js.map +1 -0
- package/dist/web/mina/transactions/nonce.js.map +1 -0
- package/dist/web/mina/transactions/send.js.map +1 -0
- package/dist/web/mina/transactions/tiny-contract.js.map +1 -0
- package/dist/web/mina/transactions/transaction.js.map +1 -0
- package/dist/web/mina/transactions/txstatus.js.map +1 -0
- package/dist/web/mina/utils/base64.js.map +1 -0
- package/dist/web/mina/utils/fee.js.map +1 -0
- package/dist/web/mina/utils/fetch.js.map +1 -0
- package/dist/web/mina/utils/fields.js.map +1 -0
- package/dist/web/mina/utils/index.js.map +1 -0
- package/dist/web/mina/utils/indexed-map.js.map +1 -0
- package/dist/web/mina/utils/mina.js.map +1 -0
- package/dist/web/mina/verification/index.js.map +1 -0
- package/dist/web/mina/verification/verification.js.map +1 -0
- package/package.json +32 -20
- package/src/cloud/config.ts +10 -0
- package/src/cloud/index.ts +4 -0
- package/src/cloud/networks.ts +130 -0
- package/src/cloud/utils/base64.ts +87 -0
- package/src/cloud/utils/graphql.ts +252 -0
- package/src/cloud/utils/index.ts +3 -0
- package/src/cloud/utils/utils.ts +79 -0
- package/src/cloud/worker/cloud.ts +326 -0
- package/src/cloud/worker/index.ts +5 -0
- package/src/cloud/worker/job.ts +123 -0
- package/src/cloud/worker/task.ts +45 -0
- package/src/cloud/worker/transaction.ts +12 -0
- package/src/cloud/worker/worker.ts +62 -0
- package/src/index.ts +2 -0
- package/src/mina/api/api.ts +597 -0
- package/src/mina/index.ts +8 -0
- package/src/mina/local/local.ts +651 -0
- package/src/mina/storage/index.ts +3 -0
- package/src/mina/storage/ipfs.ts +20 -0
- package/src/mina/storage/pinata.ts +52 -0
- package/src/mina/storage/storage.ts +55 -0
- package/src/mina/token/FungibleToken.ts +316 -0
- package/src/mina/token/FungibleTokenAdmin.ts +95 -0
- package/src/mina/token/api.ts +182 -0
- package/src/mina/token/index.ts +5 -0
- package/src/mina/token/vk.ts +42 -0
- package/src/mina/token/whitelist.ts +178 -0
- package/src/mina/transactions/account.ts +57 -0
- package/src/mina/transactions/blockberry.ts +166 -0
- package/src/mina/transactions/chain.ts +1 -0
- package/src/mina/transactions/index.ts +8 -0
- package/src/mina/transactions/nonce.ts +120 -0
- package/src/mina/transactions/send.ts +186 -0
- package/src/mina/transactions/tiny-contract.ts +9 -0
- package/src/mina/transactions/transaction.ts +255 -0
- package/src/mina/transactions/txstatus.ts +26 -0
- package/src/mina/utils/base64.ts +34 -0
- package/src/mina/utils/fee.ts +11 -0
- package/src/mina/utils/fetch.ts +126 -0
- package/src/mina/utils/fields.ts +39 -0
- package/src/mina/utils/index.ts +6 -0
- package/src/mina/utils/indexed-map.ts +169 -0
- package/src/mina/utils/mina.ts +175 -0
- package/src/mina/verification/index.ts +1 -0
- package/src/mina/verification/verification.ts +23 -0
- package/lib/ts/cloud/config.js.map +0 -1
- package/lib/ts/cloud/index.js.map +0 -1
- package/lib/ts/cloud/networks.js.map +0 -1
- package/lib/ts/cloud/utils/base64.js.map +0 -1
- package/lib/ts/cloud/utils/graphql.js.map +0 -1
- package/lib/ts/cloud/utils/index.js.map +0 -1
- package/lib/ts/cloud/utils/utils.js.map +0 -1
- package/lib/ts/cloud/worker/cloud.js.map +0 -1
- package/lib/ts/cloud/worker/index.js.map +0 -1
- package/lib/ts/cloud/worker/transaction.js.map +0 -1
- package/lib/ts/cloud/worker/worker.js.map +0 -1
- package/lib/ts/index.js.map +0 -1
- package/lib/ts/mina/api/api.js.map +0 -1
- package/lib/ts/mina/index.js.map +0 -1
- package/lib/ts/mina/local/local.js.map +0 -1
- package/lib/ts/mina/storage/index.js.map +0 -1
- package/lib/ts/mina/storage/ipfs.js.map +0 -1
- package/lib/ts/mina/storage/pinata.js.map +0 -1
- package/lib/ts/mina/storage/storage.js.map +0 -1
- package/lib/ts/mina/token/FungibleToken.js.map +0 -1
- package/lib/ts/mina/token/FungibleTokenAdmin.js.map +0 -1
- package/lib/ts/mina/token/api.js.map +0 -1
- package/lib/ts/mina/token/index.js.map +0 -1
- package/lib/ts/mina/token/vk.js.map +0 -1
- package/lib/ts/mina/token/whitelist.js.map +0 -1
- package/lib/ts/mina/transactions/account.js.map +0 -1
- package/lib/ts/mina/transactions/blockberry.js.map +0 -1
- package/lib/ts/mina/transactions/chain.js.map +0 -1
- package/lib/ts/mina/transactions/index.js.map +0 -1
- package/lib/ts/mina/transactions/nonce.js.map +0 -1
- package/lib/ts/mina/transactions/send.js.map +0 -1
- package/lib/ts/mina/transactions/tiny-contract.js.map +0 -1
- package/lib/ts/mina/transactions/transaction.js.map +0 -1
- package/lib/ts/mina/transactions/txstatus.js.map +0 -1
- package/lib/ts/mina/utils/base64.js.map +0 -1
- package/lib/ts/mina/utils/fee.js.map +0 -1
- package/lib/ts/mina/utils/fetch.js.map +0 -1
- package/lib/ts/mina/utils/fields.js.map +0 -1
- package/lib/ts/mina/utils/index.js.map +0 -1
- package/lib/ts/mina/utils/indexed-map.js.map +0 -1
- package/lib/ts/mina/utils/mina.js.map +0 -1
- package/lib/ts/mina/verification/index.js.map +0 -1
- package/lib/ts/mina/verification/verification.js.map +0 -1
- package/lib/tsconfig.web.tsbuildinfo +0 -1
- package/lib/web/cloud/config.js.map +0 -1
- package/lib/web/cloud/index.js.map +0 -1
- package/lib/web/cloud/networks.js.map +0 -1
- package/lib/web/cloud/utils/base64.js.map +0 -1
- package/lib/web/cloud/utils/graphql.js.map +0 -1
- package/lib/web/cloud/utils/index.js.map +0 -1
- package/lib/web/cloud/utils/utils.js.map +0 -1
- package/lib/web/cloud/worker/cloud.js.map +0 -1
- package/lib/web/cloud/worker/index.js.map +0 -1
- package/lib/web/cloud/worker/transaction.js.map +0 -1
- package/lib/web/cloud/worker/worker.js.map +0 -1
- package/lib/web/index.js.map +0 -1
- package/lib/web/mina/api/api.js.map +0 -1
- package/lib/web/mina/index.js.map +0 -1
- package/lib/web/mina/local/local.js.map +0 -1
- package/lib/web/mina/storage/index.js.map +0 -1
- package/lib/web/mina/storage/ipfs.js.map +0 -1
- package/lib/web/mina/storage/pinata.js.map +0 -1
- package/lib/web/mina/storage/storage.js.map +0 -1
- package/lib/web/mina/token/FungibleToken.js.map +0 -1
- package/lib/web/mina/token/FungibleTokenAdmin.js.map +0 -1
- package/lib/web/mina/token/api.js.map +0 -1
- package/lib/web/mina/token/index.js.map +0 -1
- package/lib/web/mina/token/vk.js.map +0 -1
- package/lib/web/mina/token/whitelist.js.map +0 -1
- package/lib/web/mina/transactions/account.js.map +0 -1
- package/lib/web/mina/transactions/blockberry.js.map +0 -1
- package/lib/web/mina/transactions/chain.js.map +0 -1
- package/lib/web/mina/transactions/index.js.map +0 -1
- package/lib/web/mina/transactions/nonce.js.map +0 -1
- package/lib/web/mina/transactions/send.js.map +0 -1
- package/lib/web/mina/transactions/tiny-contract.js.map +0 -1
- package/lib/web/mina/transactions/transaction.js.map +0 -1
- package/lib/web/mina/transactions/txstatus.js.map +0 -1
- package/lib/web/mina/utils/base64.js.map +0 -1
- package/lib/web/mina/utils/fee.js.map +0 -1
- package/lib/web/mina/utils/fetch.js.map +0 -1
- package/lib/web/mina/utils/fields.js.map +0 -1
- package/lib/web/mina/utils/index.js.map +0 -1
- package/lib/web/mina/utils/indexed-map.js.map +0 -1
- package/lib/web/mina/utils/mina.js.map +0 -1
- package/lib/web/mina/verification/index.js.map +0 -1
- package/lib/web/mina/verification/verification.js.map +0 -1
- /package/{lib → dist}/ts/cloud/config.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/config.js +0 -0
- /package/{lib → dist}/ts/cloud/index.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/index.js +0 -0
- /package/{lib → dist}/ts/cloud/networks.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/networks.js +0 -0
- /package/{lib → dist}/ts/cloud/utils/base64.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/utils/base64.js +0 -0
- /package/{lib → dist}/ts/cloud/utils/graphql.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/utils/graphql.js +0 -0
- /package/{lib → dist}/ts/cloud/utils/index.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/utils/index.js +0 -0
- /package/{lib → dist}/ts/cloud/utils/utils.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/utils/utils.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/cloud.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/cloud.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/index.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/index.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/job.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/job.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/task.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/task.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/transaction.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/transaction.js +0 -0
- /package/{lib → dist}/ts/cloud/worker/worker.d.ts +0 -0
- /package/{lib → dist}/ts/cloud/worker/worker.js +0 -0
- /package/{lib → dist}/ts/index.d.ts +0 -0
- /package/{lib → dist}/ts/index.js +0 -0
- /package/{lib → dist}/ts/mina/api/api.d.ts +0 -0
- /package/{lib → dist}/ts/mina/api/api.js +0 -0
- /package/{lib → dist}/ts/mina/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/index.js +0 -0
- /package/{lib → dist}/ts/mina/local/local.d.ts +0 -0
- /package/{lib → dist}/ts/mina/local/local.js +0 -0
- /package/{lib → dist}/ts/mina/storage/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/storage/index.js +0 -0
- /package/{lib → dist}/ts/mina/storage/ipfs.d.ts +0 -0
- /package/{lib → dist}/ts/mina/storage/ipfs.js +0 -0
- /package/{lib → dist}/ts/mina/storage/pinata.d.ts +0 -0
- /package/{lib → dist}/ts/mina/storage/pinata.js +0 -0
- /package/{lib → dist}/ts/mina/storage/storage.d.ts +0 -0
- /package/{lib → dist}/ts/mina/storage/storage.js +0 -0
- /package/{lib → dist}/ts/mina/token/FungibleToken.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/FungibleToken.js +0 -0
- /package/{lib → dist}/ts/mina/token/FungibleTokenAdmin.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/FungibleTokenAdmin.js +0 -0
- /package/{lib → dist}/ts/mina/token/api.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/api.js +0 -0
- /package/{lib → dist}/ts/mina/token/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/index.js +0 -0
- /package/{lib → dist}/ts/mina/token/vk.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/vk.js +0 -0
- /package/{lib → dist}/ts/mina/token/whitelist.d.ts +0 -0
- /package/{lib → dist}/ts/mina/token/whitelist.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/account.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/account.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/blockberry.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/blockberry.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/chain.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/chain.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/index.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/nonce.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/nonce.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/send.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/send.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/tiny-contract.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/tiny-contract.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/transaction.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/transaction.js +0 -0
- /package/{lib → dist}/ts/mina/transactions/txstatus.d.ts +0 -0
- /package/{lib → dist}/ts/mina/transactions/txstatus.js +0 -0
- /package/{lib → dist}/ts/mina/utils/base64.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/base64.js +0 -0
- /package/{lib → dist}/ts/mina/utils/fee.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/fee.js +0 -0
- /package/{lib → dist}/ts/mina/utils/fetch.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/fetch.js +0 -0
- /package/{lib → dist}/ts/mina/utils/fields.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/fields.js +0 -0
- /package/{lib → dist}/ts/mina/utils/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/index.js +0 -0
- /package/{lib → dist}/ts/mina/utils/indexed-map.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/indexed-map.js +0 -0
- /package/{lib → dist}/ts/mina/utils/mina.d.ts +0 -0
- /package/{lib → dist}/ts/mina/utils/mina.js +0 -0
- /package/{lib → dist}/ts/mina/verification/index.d.ts +0 -0
- /package/{lib → dist}/ts/mina/verification/index.js +0 -0
- /package/{lib → dist}/ts/mina/verification/verification.d.ts +0 -0
- /package/{lib → dist}/ts/mina/verification/verification.js +0 -0
- /package/{lib → dist}/web/cloud/config.d.ts +0 -0
- /package/{lib → dist}/web/cloud/config.js +0 -0
- /package/{lib → dist}/web/cloud/index.d.ts +0 -0
- /package/{lib → dist}/web/cloud/index.js +0 -0
- /package/{lib → dist}/web/cloud/networks.d.ts +0 -0
- /package/{lib → dist}/web/cloud/networks.js +0 -0
- /package/{lib → dist}/web/cloud/utils/base64.d.ts +0 -0
- /package/{lib → dist}/web/cloud/utils/base64.js +0 -0
- /package/{lib → dist}/web/cloud/utils/graphql.d.ts +0 -0
- /package/{lib → dist}/web/cloud/utils/graphql.js +0 -0
- /package/{lib → dist}/web/cloud/utils/index.d.ts +0 -0
- /package/{lib → dist}/web/cloud/utils/index.js +0 -0
- /package/{lib → dist}/web/cloud/utils/utils.d.ts +0 -0
- /package/{lib → dist}/web/cloud/utils/utils.js +0 -0
- /package/{lib → dist}/web/cloud/worker/cloud.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/cloud.js +0 -0
- /package/{lib → dist}/web/cloud/worker/index.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/index.js +0 -0
- /package/{lib → dist}/web/cloud/worker/job.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/job.js +0 -0
- /package/{lib → dist}/web/cloud/worker/task.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/task.js +0 -0
- /package/{lib → dist}/web/cloud/worker/transaction.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/transaction.js +0 -0
- /package/{lib → dist}/web/cloud/worker/worker.d.ts +0 -0
- /package/{lib → dist}/web/cloud/worker/worker.js +0 -0
- /package/{lib → dist}/web/index.d.ts +0 -0
- /package/{lib → dist}/web/index.js +0 -0
- /package/{lib → dist}/web/mina/api/api.d.ts +0 -0
- /package/{lib → dist}/web/mina/api/api.js +0 -0
- /package/{lib → dist}/web/mina/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/index.js +0 -0
- /package/{lib → dist}/web/mina/local/local.d.ts +0 -0
- /package/{lib → dist}/web/mina/local/local.js +0 -0
- /package/{lib → dist}/web/mina/storage/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/storage/index.js +0 -0
- /package/{lib → dist}/web/mina/storage/ipfs.d.ts +0 -0
- /package/{lib → dist}/web/mina/storage/ipfs.js +0 -0
- /package/{lib → dist}/web/mina/storage/pinata.d.ts +0 -0
- /package/{lib → dist}/web/mina/storage/pinata.js +0 -0
- /package/{lib → dist}/web/mina/storage/storage.d.ts +0 -0
- /package/{lib → dist}/web/mina/storage/storage.js +0 -0
- /package/{lib → dist}/web/mina/token/FungibleToken.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/FungibleToken.js +0 -0
- /package/{lib → dist}/web/mina/token/FungibleTokenAdmin.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/FungibleTokenAdmin.js +0 -0
- /package/{lib → dist}/web/mina/token/api.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/api.js +0 -0
- /package/{lib → dist}/web/mina/token/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/index.js +0 -0
- /package/{lib → dist}/web/mina/token/vk.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/vk.js +0 -0
- /package/{lib → dist}/web/mina/token/whitelist.d.ts +0 -0
- /package/{lib → dist}/web/mina/token/whitelist.js +0 -0
- /package/{lib → dist}/web/mina/transactions/account.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/account.js +0 -0
- /package/{lib → dist}/web/mina/transactions/blockberry.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/blockberry.js +0 -0
- /package/{lib → dist}/web/mina/transactions/chain.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/chain.js +0 -0
- /package/{lib → dist}/web/mina/transactions/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/index.js +0 -0
- /package/{lib → dist}/web/mina/transactions/nonce.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/nonce.js +0 -0
- /package/{lib → dist}/web/mina/transactions/send.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/send.js +0 -0
- /package/{lib → dist}/web/mina/transactions/tiny-contract.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/tiny-contract.js +0 -0
- /package/{lib → dist}/web/mina/transactions/transaction.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/transaction.js +0 -0
- /package/{lib → dist}/web/mina/transactions/txstatus.d.ts +0 -0
- /package/{lib → dist}/web/mina/transactions/txstatus.js +0 -0
- /package/{lib → dist}/web/mina/utils/base64.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/base64.js +0 -0
- /package/{lib → dist}/web/mina/utils/fee.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/fee.js +0 -0
- /package/{lib → dist}/web/mina/utils/fetch.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/fetch.js +0 -0
- /package/{lib → dist}/web/mina/utils/fields.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/fields.js +0 -0
- /package/{lib → dist}/web/mina/utils/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/index.js +0 -0
- /package/{lib → dist}/web/mina/utils/indexed-map.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/indexed-map.js +0 -0
- /package/{lib → dist}/web/mina/utils/mina.d.ts +0 -0
- /package/{lib → dist}/web/mina/utils/mina.js +0 -0
- /package/{lib → dist}/web/mina/verification/index.d.ts +0 -0
- /package/{lib → dist}/web/mina/verification/index.js +0 -0
- /package/{lib → dist}/web/mina/verification/verification.d.ts +0 -0
- /package/{lib → dist}/web/mina/verification/verification.js +0 -0
@@ -0,0 +1,597 @@
|
|
1
|
+
import axios, { all } from "axios";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import { sleep } from "../../cloud/utils/index.js";
|
4
|
+
import { LocalCloud, LocalStorage } from "../local/local.js";
|
5
|
+
import config from "../../cloud/config.js";
|
6
|
+
import { zkCloudWorker, Cloud, JobData } from "../../cloud/worker/index.js";
|
7
|
+
import { blockchain } from "../../cloud/networks.js";
|
8
|
+
const { ZKCLOUDWORKER_AUTH, ZKCLOUDWORKER_API } = config;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* The APICommand type for interacting with the zkCloudWorker
|
12
|
+
* @typedef { "recursiveProof" | "execute" | "sendTransactions" | "jobResult" | "deploy" | "getBalance" | "queryBilling" } ApiCommand
|
13
|
+
* @property recursiveProof The command for the recursiveProof calculation
|
14
|
+
* @property execute The command for the execute function call (sync or async)
|
15
|
+
* @property sendTransactions The command for sending transactions to the cloud
|
16
|
+
* @property jobResult The command for getting the result of the job
|
17
|
+
* @property deploy The command for deploying the code to the cloud, it is recommended use CLI tools for deployment
|
18
|
+
* @property getBalance The command for getting the balance of the user's account with zkCloudWorker
|
19
|
+
* @property queryBilling The command for getting the billing report of the user's account with zkCloudWorker
|
20
|
+
*/
|
21
|
+
export type ApiCommand =
|
22
|
+
| "recursiveProof"
|
23
|
+
| "execute"
|
24
|
+
| "sendTransactions"
|
25
|
+
| "jobResult"
|
26
|
+
| "deploy"
|
27
|
+
| "getBalance"
|
28
|
+
| "queryBilling";
|
29
|
+
|
30
|
+
/**
|
31
|
+
* API class for interacting with the zkCloudWorker
|
32
|
+
* @property jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
33
|
+
* @property endpoint The endpoint of the serverless api
|
34
|
+
* @property chain The blockchain network to use
|
35
|
+
* @property webhook The webhook for the serverless api to get the results
|
36
|
+
* @property localWorker The local worker for the serverless api to test the code locally
|
37
|
+
*/
|
38
|
+
export class zkCloudWorkerClient {
|
39
|
+
readonly jwt: string;
|
40
|
+
readonly endpoint?: string;
|
41
|
+
readonly chain: blockchain;
|
42
|
+
readonly webhook?: string;
|
43
|
+
readonly localWorker?: (cloud: Cloud) => Promise<zkCloudWorker>;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Constructor for the API class
|
47
|
+
* @param params the parameters for the API class
|
48
|
+
* @param params.jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
49
|
+
* @param params.zkcloudworker The local worker for the serverless api to test the code locally
|
50
|
+
* @param params.chain The blockchain network to use
|
51
|
+
* @param params.webhook The webhook for the serverless api to get the results
|
52
|
+
*/
|
53
|
+
constructor(params: {
|
54
|
+
jwt: string;
|
55
|
+
zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker>;
|
56
|
+
chain?: blockchain;
|
57
|
+
webhook?: string;
|
58
|
+
}) {
|
59
|
+
const { jwt, zkcloudworker, webhook } = params;
|
60
|
+
this.jwt = jwt;
|
61
|
+
|
62
|
+
const chain = params.chain ?? "devnet";
|
63
|
+
this.chain = chain;
|
64
|
+
this.endpoint =
|
65
|
+
chain === "devnet" || chain === "zeko"
|
66
|
+
? ZKCLOUDWORKER_API + chain
|
67
|
+
: undefined;
|
68
|
+
this.webhook = webhook;
|
69
|
+
if (jwt === "local") {
|
70
|
+
if (zkcloudworker === undefined)
|
71
|
+
throw new Error("worker is required for local mode");
|
72
|
+
this.localWorker = zkcloudworker;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Starts a new job for the proof calculation using serverless api call
|
78
|
+
* @param data the data for the proof call
|
79
|
+
* @param data.developer the developer
|
80
|
+
* @param data.repo the repo to use
|
81
|
+
* @param data.transactions the transactions
|
82
|
+
* @param data.task the task of the job
|
83
|
+
* @param data.userId the userId of the job
|
84
|
+
* @param data.args the arguments of the job, should be serialized JSON or string
|
85
|
+
* @param data.metadata the metadata of the job, should be serialized JSON or string
|
86
|
+
* @param data.webhook the webhook for the job
|
87
|
+
* @returns { success: boolean, error?: string, jobId?: string }
|
88
|
+
* where jonId is the jobId of the job
|
89
|
+
*
|
90
|
+
* The developers repo should provide a zkcloudworker function
|
91
|
+
* that can be called with the given parameters, see the examples
|
92
|
+
*/
|
93
|
+
public async recursiveProof(data: {
|
94
|
+
developer: string;
|
95
|
+
repo: string;
|
96
|
+
transactions: string[];
|
97
|
+
task?: string;
|
98
|
+
userId?: string;
|
99
|
+
args?: string;
|
100
|
+
metadata?: string;
|
101
|
+
webhook?: string;
|
102
|
+
}): Promise<{
|
103
|
+
success: boolean;
|
104
|
+
error?: string;
|
105
|
+
jobId?: string;
|
106
|
+
}> {
|
107
|
+
const result = await this.apiHub("recursiveProof", data);
|
108
|
+
if (
|
109
|
+
result.data === "error" ||
|
110
|
+
(typeof result.data === "string" && result.data.startsWith("error"))
|
111
|
+
)
|
112
|
+
return {
|
113
|
+
success: false,
|
114
|
+
error: result.error,
|
115
|
+
};
|
116
|
+
else if (result.success === false || result.data?.success === false)
|
117
|
+
return {
|
118
|
+
success: false,
|
119
|
+
error:
|
120
|
+
result.error ?? result.data?.error ?? "recursiveProof call failed",
|
121
|
+
};
|
122
|
+
else if (
|
123
|
+
result.success === true &&
|
124
|
+
result.data?.success === true &&
|
125
|
+
result.data?.jobId !== undefined
|
126
|
+
)
|
127
|
+
return {
|
128
|
+
success: result.success,
|
129
|
+
jobId: result.data.jobId,
|
130
|
+
error: result.error,
|
131
|
+
};
|
132
|
+
else
|
133
|
+
return {
|
134
|
+
success: false,
|
135
|
+
error: "recursiveProof call error",
|
136
|
+
};
|
137
|
+
}
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Starts a new job for the function call using serverless api call
|
141
|
+
* @param data the data for the proof call
|
142
|
+
* @param data.developer the developer
|
143
|
+
* @param data.repo the repo to use
|
144
|
+
* @param data.transactions the transactions
|
145
|
+
* @param data.task the task of the job
|
146
|
+
* @param data.userId the userId of the job
|
147
|
+
* @param data.args the arguments of the job
|
148
|
+
* @param data.metadata the metadata of the job
|
149
|
+
* @param data.mode the mode of the job execution: "sync" will not create a job, it will execute the function synchronously within 30 seconds and with the memory limit of 256 MB
|
150
|
+
* @returns { success: boolean, error?: string, jobId?: string, result?: any }
|
151
|
+
* where jonId is the jobId of the job (for async calls), result is the result of the job (for sync calls)
|
152
|
+
*/
|
153
|
+
public async execute(data: {
|
154
|
+
developer: string;
|
155
|
+
repo: string;
|
156
|
+
transactions: string[];
|
157
|
+
task: string;
|
158
|
+
userId?: string;
|
159
|
+
args?: string;
|
160
|
+
metadata?: string;
|
161
|
+
mode?: string;
|
162
|
+
}): Promise<{
|
163
|
+
success: boolean;
|
164
|
+
error?: string;
|
165
|
+
jobId?: string;
|
166
|
+
result?: any;
|
167
|
+
}> {
|
168
|
+
const result = await this.apiHub("execute", data);
|
169
|
+
if (
|
170
|
+
result.data === "error" ||
|
171
|
+
(typeof result.data === "string" && result.data.startsWith("error"))
|
172
|
+
)
|
173
|
+
return {
|
174
|
+
success: false,
|
175
|
+
error: result.error,
|
176
|
+
};
|
177
|
+
else if (result.success === false || result.data?.success === false)
|
178
|
+
return {
|
179
|
+
success: false,
|
180
|
+
error: result.error ?? result.data?.error ?? "execute call failed",
|
181
|
+
};
|
182
|
+
else if (
|
183
|
+
result.success === true &&
|
184
|
+
data.mode === "sync" &&
|
185
|
+
result.data !== undefined
|
186
|
+
)
|
187
|
+
return {
|
188
|
+
success: result.success,
|
189
|
+
jobId: undefined,
|
190
|
+
result: result.data,
|
191
|
+
error: result.error,
|
192
|
+
};
|
193
|
+
else if (
|
194
|
+
result.success === true &&
|
195
|
+
data.mode !== "sync" &&
|
196
|
+
result.data?.success === true &&
|
197
|
+
result.data?.jobId !== undefined
|
198
|
+
)
|
199
|
+
return {
|
200
|
+
success: result.success,
|
201
|
+
jobId: result.data.jobId,
|
202
|
+
result: undefined,
|
203
|
+
error: result.error,
|
204
|
+
};
|
205
|
+
else
|
206
|
+
return {
|
207
|
+
success: false,
|
208
|
+
error: "execute call error",
|
209
|
+
};
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Sends transactions to the blockchain using serverless api call
|
214
|
+
* @param data the data for the proof call
|
215
|
+
* @param data.developer the developer
|
216
|
+
* @param data.repo the repo to use
|
217
|
+
* @param data.transactions the transactions
|
218
|
+
* @returns { success: boolean, error?: string, txId?: string[] }
|
219
|
+
* where txId is the transaction id of the transaction, in the sequence of the input transactions
|
220
|
+
*/
|
221
|
+
public async sendTransactions(data: {
|
222
|
+
developer: string;
|
223
|
+
repo: string;
|
224
|
+
transactions: string[];
|
225
|
+
}): Promise<{
|
226
|
+
success: boolean;
|
227
|
+
error?: string;
|
228
|
+
txId?: string[];
|
229
|
+
}> {
|
230
|
+
const result = await this.apiHub("sendTransactions", data);
|
231
|
+
if (result.data === "error")
|
232
|
+
// TODO: check if this is correct in AWS code
|
233
|
+
return {
|
234
|
+
success: false,
|
235
|
+
error: result.error,
|
236
|
+
};
|
237
|
+
else
|
238
|
+
return {
|
239
|
+
success: result.success,
|
240
|
+
txId: result.data,
|
241
|
+
error: result.error,
|
242
|
+
};
|
243
|
+
}
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Gets the result of the job using serverless api call
|
247
|
+
* @param data the data for the jobResult call
|
248
|
+
* @param data.jobId the jobId of the job
|
249
|
+
* @param data.includeLogs include logs in the result, default is false
|
250
|
+
* @returns { success: boolean, error?: string, result?: any }
|
251
|
+
* where result is the result of the job
|
252
|
+
* if the job is not finished yet, the result will be undefined
|
253
|
+
* if the job failed, the result will be undefined and error will be set
|
254
|
+
* if the job is finished, the result will be set and error will be undefined
|
255
|
+
* if the job is not found, the result will be undefined and error will be set
|
256
|
+
*/
|
257
|
+
public async jobResult(data: {
|
258
|
+
jobId: string;
|
259
|
+
includeLogs?: boolean;
|
260
|
+
}): Promise<
|
261
|
+
| {
|
262
|
+
success: false;
|
263
|
+
error?: string;
|
264
|
+
result?: string;
|
265
|
+
}
|
266
|
+
| {
|
267
|
+
success: true;
|
268
|
+
error?: string;
|
269
|
+
result: JobData;
|
270
|
+
}
|
271
|
+
> {
|
272
|
+
const result = await this.apiHub("jobResult", data);
|
273
|
+
if (this.isError(result.data))
|
274
|
+
return {
|
275
|
+
success: false,
|
276
|
+
error: result.error,
|
277
|
+
result: result.data,
|
278
|
+
};
|
279
|
+
else
|
280
|
+
return {
|
281
|
+
success: result.success,
|
282
|
+
error: result.error,
|
283
|
+
result: result.success ? (result.data as JobData) : result.data,
|
284
|
+
};
|
285
|
+
}
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Deploys the code to the cloud using serverless api call
|
289
|
+
* @param data the data for the deploy call
|
290
|
+
* @param data.repo the repo to use
|
291
|
+
* @param data.developer the developer
|
292
|
+
* @param data.packageManager the package manager to use
|
293
|
+
* @returns { success: boolean, error?: string, jobId?: string}
|
294
|
+
* where jobId is the jobId of the job
|
295
|
+
*/
|
296
|
+
public async deploy(data: {
|
297
|
+
repo: string;
|
298
|
+
developer: string;
|
299
|
+
packageManager: string;
|
300
|
+
}): Promise<{
|
301
|
+
success: boolean;
|
302
|
+
error?: string;
|
303
|
+
jobId?: string;
|
304
|
+
}> {
|
305
|
+
// TODO: encrypt env.json
|
306
|
+
const { repo, developer, packageManager } = data;
|
307
|
+
const result = await this.apiHub("deploy", {
|
308
|
+
developer,
|
309
|
+
repo,
|
310
|
+
args: packageManager,
|
311
|
+
});
|
312
|
+
if (
|
313
|
+
result.data === "error" ||
|
314
|
+
(typeof result.data === "string" && result.data.startsWith("error"))
|
315
|
+
)
|
316
|
+
return {
|
317
|
+
success: false,
|
318
|
+
error: result.error,
|
319
|
+
};
|
320
|
+
else
|
321
|
+
return {
|
322
|
+
success: result.success && result.data?.success,
|
323
|
+
jobId: result.data?.jobId,
|
324
|
+
error: result.error,
|
325
|
+
};
|
326
|
+
}
|
327
|
+
|
328
|
+
/**
|
329
|
+
* Gets the billing report for the jobs sent using JWT
|
330
|
+
* @returns { success: boolean, error?: string, result?: any }
|
331
|
+
* where result is the billing report
|
332
|
+
*/
|
333
|
+
public async queryBilling(): Promise<{
|
334
|
+
success: boolean;
|
335
|
+
error?: string;
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
337
|
+
result?: any;
|
338
|
+
}> {
|
339
|
+
const result = await this.apiHub("queryBilling", {});
|
340
|
+
if (this.isError(result.data))
|
341
|
+
return {
|
342
|
+
success: false,
|
343
|
+
error: result.error,
|
344
|
+
result: result.data,
|
345
|
+
};
|
346
|
+
else
|
347
|
+
return {
|
348
|
+
success: result.success,
|
349
|
+
error: result.error,
|
350
|
+
result: result.data,
|
351
|
+
};
|
352
|
+
}
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Gets the remaining balance
|
356
|
+
* @returns { success: boolean, error?: string, result?: any }
|
357
|
+
* where result is the balance
|
358
|
+
*/
|
359
|
+
public async getBalance(): Promise<{
|
360
|
+
success: boolean;
|
361
|
+
error?: string;
|
362
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
363
|
+
result?: any;
|
364
|
+
}> {
|
365
|
+
const result = await this.apiHub("getBalance", {});
|
366
|
+
if (this.isError(result.data))
|
367
|
+
return {
|
368
|
+
success: false,
|
369
|
+
error: result.error,
|
370
|
+
result: result.data,
|
371
|
+
};
|
372
|
+
else
|
373
|
+
return {
|
374
|
+
success: result.success,
|
375
|
+
error: result.error,
|
376
|
+
result: result.data,
|
377
|
+
};
|
378
|
+
}
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Waits for the job to finish
|
382
|
+
* @param data the data for the waitForJobResult call
|
383
|
+
* @param data.jobId the jobId of the job
|
384
|
+
* @param data.maxAttempts the maximum number of attempts, default is 360 (2 hours)
|
385
|
+
* @param data.interval the interval between attempts, default is 20000 (20 seconds)
|
386
|
+
* @param data.maxErrors the maximum number of network errors, default is 10
|
387
|
+
* @param data.printLogs print logs, default is true
|
388
|
+
* @returns { success: boolean, error?: string, result?: any }
|
389
|
+
* where result is the result of the job
|
390
|
+
*/
|
391
|
+
public async waitForJobResult(data: {
|
392
|
+
jobId: string;
|
393
|
+
maxAttempts?: number;
|
394
|
+
interval?: number;
|
395
|
+
maxErrors?: number;
|
396
|
+
printLogs?: boolean; // print logs, default is true
|
397
|
+
}): Promise<{
|
398
|
+
success: boolean;
|
399
|
+
error?: string;
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
401
|
+
result?: any;
|
402
|
+
}> {
|
403
|
+
if (this.jwt === "local") return this.jobResult({ jobId: data.jobId });
|
404
|
+
const maxAttempts = data?.maxAttempts ?? 360; // 1 hour
|
405
|
+
const interval = data?.interval ?? 10000;
|
406
|
+
const maxErrors = data?.maxErrors ?? 10;
|
407
|
+
const errorDelay = 30000; // 30 seconds
|
408
|
+
const printedLogs: string[] = [];
|
409
|
+
const printLogs: boolean = data.printLogs ?? true;
|
410
|
+
|
411
|
+
function print(logs: string[]) {
|
412
|
+
logs.forEach((log) => {
|
413
|
+
if (printedLogs.includes(log) === false) {
|
414
|
+
printedLogs.push(log);
|
415
|
+
if (printLogs) {
|
416
|
+
// replace all occurrences of "error" with red color
|
417
|
+
const text = log.replace(/error/gi, (matched) =>
|
418
|
+
chalk.red(matched)
|
419
|
+
);
|
420
|
+
console.log(text);
|
421
|
+
}
|
422
|
+
}
|
423
|
+
});
|
424
|
+
}
|
425
|
+
let attempts = 0;
|
426
|
+
let errors = 0;
|
427
|
+
while (attempts < maxAttempts) {
|
428
|
+
const result = await this.apiHub("jobResult", {
|
429
|
+
jobId: data.jobId,
|
430
|
+
includeLogs: printLogs,
|
431
|
+
});
|
432
|
+
const isAllLogsFetched =
|
433
|
+
result?.data?.isFullLog === true || printLogs === false;
|
434
|
+
if (
|
435
|
+
printLogs === true &&
|
436
|
+
result?.data?.logs !== undefined &&
|
437
|
+
result?.data?.logs !== null &&
|
438
|
+
Array.isArray(result.data.logs) === true
|
439
|
+
)
|
440
|
+
print(result.data.logs);
|
441
|
+
if (result.success === false) {
|
442
|
+
errors++;
|
443
|
+
if (errors > maxErrors) {
|
444
|
+
return {
|
445
|
+
success: false,
|
446
|
+
error: "Too many network errors",
|
447
|
+
result: undefined,
|
448
|
+
};
|
449
|
+
}
|
450
|
+
await sleep(errorDelay * errors);
|
451
|
+
} else {
|
452
|
+
if (this.isError(result.data) && isAllLogsFetched)
|
453
|
+
return {
|
454
|
+
success: false,
|
455
|
+
error: result.error,
|
456
|
+
result: result.data,
|
457
|
+
};
|
458
|
+
else if (result.data?.result !== undefined && isAllLogsFetched) {
|
459
|
+
return {
|
460
|
+
success: result.success,
|
461
|
+
error: result.error,
|
462
|
+
result: result.data,
|
463
|
+
};
|
464
|
+
} else if (result.data?.jobStatus === "failed" && isAllLogsFetched) {
|
465
|
+
return {
|
466
|
+
success: false,
|
467
|
+
error: "Job failed",
|
468
|
+
result: result.data,
|
469
|
+
};
|
470
|
+
}
|
471
|
+
await sleep(interval);
|
472
|
+
}
|
473
|
+
attempts++;
|
474
|
+
}
|
475
|
+
return {
|
476
|
+
success: false,
|
477
|
+
error: "Timeout",
|
478
|
+
result: undefined,
|
479
|
+
};
|
480
|
+
}
|
481
|
+
|
482
|
+
/**
|
483
|
+
* Calls the serverless API
|
484
|
+
* @param command the command of the API
|
485
|
+
* @param data the data of the API
|
486
|
+
* */
|
487
|
+
private async apiHub(
|
488
|
+
command: ApiCommand,
|
489
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
490
|
+
data: any
|
491
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
492
|
+
): Promise<{ success: boolean; data?: any; error?: any }> {
|
493
|
+
if (this.jwt === "local") {
|
494
|
+
if (this.localWorker === undefined)
|
495
|
+
throw new Error("localWorker is undefined");
|
496
|
+
|
497
|
+
switch (command) {
|
498
|
+
case "recursiveProof": {
|
499
|
+
const jobId = await LocalCloud.run({
|
500
|
+
command: "recursiveProof",
|
501
|
+
data,
|
502
|
+
chain: this.chain,
|
503
|
+
localWorker: this.localWorker,
|
504
|
+
});
|
505
|
+
return {
|
506
|
+
success: true,
|
507
|
+
data: { success: true, jobId },
|
508
|
+
};
|
509
|
+
}
|
510
|
+
case "execute": {
|
511
|
+
const jobId = await LocalCloud.run({
|
512
|
+
command: "execute",
|
513
|
+
data,
|
514
|
+
chain: this.chain,
|
515
|
+
localWorker: this.localWorker,
|
516
|
+
});
|
517
|
+
if (data.mode === "sync")
|
518
|
+
return {
|
519
|
+
success: true,
|
520
|
+
data: LocalStorage.jobEvents[jobId].result,
|
521
|
+
};
|
522
|
+
else
|
523
|
+
return {
|
524
|
+
success: true,
|
525
|
+
data: { success: true, jobId },
|
526
|
+
};
|
527
|
+
}
|
528
|
+
case "jobResult": {
|
529
|
+
const job = LocalStorage.jobs[data.jobId];
|
530
|
+
if (job === undefined) {
|
531
|
+
return {
|
532
|
+
success: false,
|
533
|
+
error: "local job not found",
|
534
|
+
};
|
535
|
+
} else {
|
536
|
+
return {
|
537
|
+
success: true,
|
538
|
+
data: job,
|
539
|
+
};
|
540
|
+
}
|
541
|
+
}
|
542
|
+
case "sendTransactions": {
|
543
|
+
return {
|
544
|
+
success: true,
|
545
|
+
data: await LocalCloud.addTransactions(data.transactions),
|
546
|
+
};
|
547
|
+
}
|
548
|
+
case "deploy":
|
549
|
+
return {
|
550
|
+
success: true,
|
551
|
+
data: "local_deploy",
|
552
|
+
};
|
553
|
+
case "queryBilling":
|
554
|
+
return {
|
555
|
+
success: true,
|
556
|
+
data: "local_queryBilling",
|
557
|
+
};
|
558
|
+
default:
|
559
|
+
return {
|
560
|
+
success: false,
|
561
|
+
error: "local_error",
|
562
|
+
};
|
563
|
+
}
|
564
|
+
} else {
|
565
|
+
if (this.endpoint === undefined)
|
566
|
+
throw new Error(
|
567
|
+
"zkCloudWorker supports only devnet and zeko chains in the cloud."
|
568
|
+
);
|
569
|
+
const apiData = {
|
570
|
+
auth: ZKCLOUDWORKER_AUTH,
|
571
|
+
command: command,
|
572
|
+
jwtToken: this.jwt,
|
573
|
+
data: data,
|
574
|
+
chain: this.chain,
|
575
|
+
webhook: this.webhook, // TODO: implement webhook code on AWS
|
576
|
+
};
|
577
|
+
|
578
|
+
try {
|
579
|
+
const response = await axios.post(this.endpoint, apiData);
|
580
|
+
return { success: true, data: response.data };
|
581
|
+
} catch (error: any) {
|
582
|
+
console.error("apiHub error:", error.message ?? error);
|
583
|
+
return { success: false, error: error };
|
584
|
+
}
|
585
|
+
}
|
586
|
+
}
|
587
|
+
|
588
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
589
|
+
private isError(data: any): boolean {
|
590
|
+
if (data === "error") return true;
|
591
|
+
if (data?.jobStatus === "failed") return true;
|
592
|
+
if (typeof data === "string" && data.toLowerCase().startsWith("error"))
|
593
|
+
return true;
|
594
|
+
if (data !== undefined && data.error !== undefined) return true;
|
595
|
+
return false;
|
596
|
+
}
|
597
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export * from "./api/api.js";
|
2
|
+
//export * from "./encryption";
|
3
|
+
export * from "./utils/index.js";
|
4
|
+
export * from "./local/local.js";
|
5
|
+
export * from "./verification/index.js";
|
6
|
+
export * from "./token/index.js";
|
7
|
+
export * from "./transactions/index.js";
|
8
|
+
export * from "./storage/index.js";
|