zkcloudworker 0.18.2 → 0.18.5
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/{lib → dist}/ts/mina/token/whitelist.d.ts +1 -1
- package/{lib/web → dist/ts}/mina/token/whitelist.js +5 -1
- 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/{lib → dist}/web/mina/token/whitelist.d.ts +1 -1
- package/{lib/ts → dist/web}/mina/token/whitelist.js +5 -1
- 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/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/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,186 @@
|
|
1
|
+
import { checkZkappTransaction } from "o1js";
|
2
|
+
import { Mina } from "o1js";
|
3
|
+
import { sleep, blockchain } from "../../cloud/index.js";
|
4
|
+
import { fetchMinaAccount, getCurrentNetwork } from "../index.js";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* The function `sendTx` sends a transaction, checks account updates, and waits for
|
8
|
+
* confirmation on the blockchain.
|
9
|
+
* @param params The parameters object
|
10
|
+
* @param params.tx The transaction to send
|
11
|
+
* @param params.description A description of the transaction
|
12
|
+
* @param params.verbose Whether to log verbose information
|
13
|
+
* @param params.wait Whether to wait for the transaction to be included in a block
|
14
|
+
* @param params.chain The blockchain to send the transaction on
|
15
|
+
* @returns The `sendTx` function returns a `Mina.IncludedTransaction`, `Mina.PendingTransaction`,
|
16
|
+
* `Mina.RejectedTransaction`, or `undefined` if there was an error during the process.
|
17
|
+
*/
|
18
|
+
export async function sendTx(params: {
|
19
|
+
tx: Mina.Transaction<false, true> | Mina.Transaction<true, true>;
|
20
|
+
description?: string;
|
21
|
+
verbose?: boolean;
|
22
|
+
wait?: boolean;
|
23
|
+
chain?: blockchain;
|
24
|
+
}): Promise<
|
25
|
+
| Mina.IncludedTransaction
|
26
|
+
| Mina.PendingTransaction
|
27
|
+
| Mina.RejectedTransaction
|
28
|
+
| undefined
|
29
|
+
> {
|
30
|
+
const {
|
31
|
+
tx,
|
32
|
+
description = "",
|
33
|
+
verbose = true,
|
34
|
+
wait = true,
|
35
|
+
chain = getCurrentNetwork().network.chainId,
|
36
|
+
} = params;
|
37
|
+
// flatten accountUpdates
|
38
|
+
const accountUpdates = JSON.parse(tx.toJSON()).accountUpdates;
|
39
|
+
const auCount: {
|
40
|
+
publicKey: string;
|
41
|
+
tokenId: string | undefined;
|
42
|
+
count: number;
|
43
|
+
}[] = [];
|
44
|
+
let proofAuthorizationCount = 0;
|
45
|
+
// Calculate the number of account updates for each { publicKey, tokenId }
|
46
|
+
for (const au of accountUpdates) {
|
47
|
+
const { publicKey, tokenId, authorizationKind } = au.body;
|
48
|
+
if (au.authorization.proof) {
|
49
|
+
proofAuthorizationCount++;
|
50
|
+
if (authorizationKind.isProved === false)
|
51
|
+
console.error("Proof authorization exists but isProved is false");
|
52
|
+
} else if (authorizationKind.isProved === true)
|
53
|
+
console.error("isProved is true but no proof authorization");
|
54
|
+
const index = auCount.findIndex(
|
55
|
+
(item) => item.publicKey === publicKey && item.tokenId === tokenId
|
56
|
+
);
|
57
|
+
if (index === -1) auCount.push({ publicKey, tokenId, count: 1 });
|
58
|
+
else auCount[index].count++;
|
59
|
+
}
|
60
|
+
if (verbose)
|
61
|
+
console.log(
|
62
|
+
`Account updates for ${description ?? "tx"}: ${
|
63
|
+
auCount.length
|
64
|
+
}, proof authorizations: ${proofAuthorizationCount}`
|
65
|
+
);
|
66
|
+
for (const au of auCount) {
|
67
|
+
if (au.count > 1)
|
68
|
+
if (verbose)
|
69
|
+
console.log(
|
70
|
+
`DUPLICATE AU ${description ?? ""}: ${au.publicKey} ${
|
71
|
+
au.tokenId !== "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf"
|
72
|
+
? "tokenId: " + au.tokenId
|
73
|
+
: ""
|
74
|
+
} count: ${au.count}`
|
75
|
+
);
|
76
|
+
}
|
77
|
+
try {
|
78
|
+
let txSent;
|
79
|
+
let sent = false;
|
80
|
+
while (!sent) {
|
81
|
+
txSent = await tx.safeSend();
|
82
|
+
if (txSent.status == "pending") {
|
83
|
+
sent = true;
|
84
|
+
if (verbose)
|
85
|
+
console.log(
|
86
|
+
`${description ?? ""} tx sent: hash: ${txSent.hash} status: ${
|
87
|
+
txSent.status
|
88
|
+
}`
|
89
|
+
);
|
90
|
+
} else if (chain === "zeko") {
|
91
|
+
if (verbose) console.log("Retrying Zeko tx");
|
92
|
+
await sleep(10000);
|
93
|
+
} else {
|
94
|
+
console.error(
|
95
|
+
`${description} tx NOT sent: hash: ${txSent?.hash} status: ${txSent?.status}`,
|
96
|
+
txSent.errors
|
97
|
+
);
|
98
|
+
return txSent;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
if (txSent === undefined) throw new Error("txSent is undefined");
|
102
|
+
if (txSent.errors.length > 0) {
|
103
|
+
console.error(
|
104
|
+
`${description ?? ""} tx error: hash: ${txSent.hash} status: ${
|
105
|
+
txSent.status
|
106
|
+
} errors: ${txSent.errors}`
|
107
|
+
);
|
108
|
+
}
|
109
|
+
|
110
|
+
if (txSent.status === "pending" && wait !== false && chain !== "zeko") {
|
111
|
+
if (verbose) console.log(`Waiting for tx inclusion...`);
|
112
|
+
const txIncluded = await txSent.safeWait();
|
113
|
+
if (txIncluded.status === "included")
|
114
|
+
if (verbose)
|
115
|
+
console.log(
|
116
|
+
`${description ?? ""} tx included into block: hash: ${
|
117
|
+
txIncluded.hash
|
118
|
+
} status: ${txIncluded.status}`
|
119
|
+
);
|
120
|
+
else
|
121
|
+
console.error(
|
122
|
+
`${description ?? ""} tx NOT included into block: hash: ${
|
123
|
+
txIncluded.hash
|
124
|
+
} status: ${txIncluded.status}`
|
125
|
+
);
|
126
|
+
if (chain !== "local") {
|
127
|
+
// we still wait for the tx to be included in the block by checking the nonce
|
128
|
+
// even in the case of tx NOT included
|
129
|
+
// because the tx might still be included in the block in the case of devnet instability
|
130
|
+
const { publicKey, nonce } = tx.transaction.feePayer.body;
|
131
|
+
const started = Date.now();
|
132
|
+
while (Date.now() - started < 1000 * 60 * 10) {
|
133
|
+
const newNonce = (
|
134
|
+
await fetchMinaAccount({
|
135
|
+
publicKey,
|
136
|
+
force: true,
|
137
|
+
})
|
138
|
+
).account?.nonce;
|
139
|
+
if (
|
140
|
+
newNonce &&
|
141
|
+
Number(newNonce.toBigint()) > Number(nonce.toBigint())
|
142
|
+
)
|
143
|
+
return txIncluded;
|
144
|
+
if (verbose)
|
145
|
+
console.log(
|
146
|
+
`Waiting for ${chain} to update state for ${Math.floor(
|
147
|
+
(Date.now() - started) / 1000
|
148
|
+
)} sec...`
|
149
|
+
);
|
150
|
+
await sleep(10000);
|
151
|
+
}
|
152
|
+
// finally, if the tx is still not included, show an error
|
153
|
+
console.error(
|
154
|
+
`${chain} do not reflect nonce update for tx ${txIncluded.hash} with status ${txIncluded.status}`
|
155
|
+
);
|
156
|
+
}
|
157
|
+
return txIncluded;
|
158
|
+
} else return txSent;
|
159
|
+
} catch (error) {
|
160
|
+
if (chain !== "zeko") console.error("Error sending tx", error);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
export async function getTxStatusFast(params: {
|
165
|
+
hash: string;
|
166
|
+
chain?: blockchain;
|
167
|
+
}): Promise<{ success: boolean; result?: boolean; error?: string }> {
|
168
|
+
const { hash, chain = getCurrentNetwork().network.chainId } = params;
|
169
|
+
if (chain === "local" || chain === "zeko")
|
170
|
+
return { success: true, result: true };
|
171
|
+
|
172
|
+
try {
|
173
|
+
const txStatus = await checkZkappTransaction(hash);
|
174
|
+
return {
|
175
|
+
success: true,
|
176
|
+
result: txStatus?.success ?? false,
|
177
|
+
};
|
178
|
+
} catch (error: any) {
|
179
|
+
console.error(
|
180
|
+
"getTxStatusFast error while getting tx status - catch",
|
181
|
+
hash,
|
182
|
+
error
|
183
|
+
);
|
184
|
+
return { success: false, error: error?.message ?? "Cannot get tx status" };
|
185
|
+
}
|
186
|
+
}
|
@@ -0,0 +1,255 @@
|
|
1
|
+
import { Field, PublicKey, Transaction, Mina, UInt64 } from "o1js";
|
2
|
+
import { fieldToBase64, fieldFromBase64 } from "../utils/base64.js";
|
3
|
+
|
4
|
+
interface ForestSerialized {
|
5
|
+
length: number;
|
6
|
+
restoredItems?: number;
|
7
|
+
items: {
|
8
|
+
h?: string; // hash
|
9
|
+
p?: string; // previousHash
|
10
|
+
i?: number; // id
|
11
|
+
c?: string; // callData
|
12
|
+
}[];
|
13
|
+
}
|
14
|
+
|
15
|
+
export function transactionParams(
|
16
|
+
serializedTransaction: string,
|
17
|
+
signedJson: any
|
18
|
+
): {
|
19
|
+
fee: UInt64;
|
20
|
+
sender: PublicKey;
|
21
|
+
nonce: number;
|
22
|
+
memo: string;
|
23
|
+
} {
|
24
|
+
const { sender, nonce, tx } = JSON.parse(serializedTransaction);
|
25
|
+
const transaction = Mina.Transaction.fromJSON(JSON.parse(tx));
|
26
|
+
const memo = transaction.transaction.memo;
|
27
|
+
return {
|
28
|
+
fee: UInt64.from(signedJson.zkappCommand.feePayer.body.fee),
|
29
|
+
sender: PublicKey.fromBase58(sender),
|
30
|
+
nonce: Number(signedJson.zkappCommand.feePayer.body.nonce),
|
31
|
+
memo,
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
export function deserializeTransaction(
|
36
|
+
serializedTransaction: string,
|
37
|
+
txNew: Mina.Transaction<false, false>,
|
38
|
+
signedJson: any
|
39
|
+
): Transaction<false, true> {
|
40
|
+
//console.log("new transaction", txNew);
|
41
|
+
const { tx, blindingValues, length, forestJSONs } = JSON.parse(
|
42
|
+
serializedTransaction
|
43
|
+
);
|
44
|
+
const transaction = Mina.Transaction.fromJSON(JSON.parse(tx));
|
45
|
+
const forests: ForestSerialized[] = forestJSONs.map(
|
46
|
+
(f: string) => JSON.parse(f) as ForestSerialized
|
47
|
+
);
|
48
|
+
//console.log("transaction", transaction);
|
49
|
+
if (length !== txNew.transaction.accountUpdates.length) {
|
50
|
+
throw new Error("New Transaction length mismatch");
|
51
|
+
}
|
52
|
+
if (length !== transaction.transaction.accountUpdates.length) {
|
53
|
+
throw new Error("Serialized Transaction length mismatch");
|
54
|
+
}
|
55
|
+
for (let i = 0; i < length; i++) {
|
56
|
+
transaction.transaction.accountUpdates[i].lazyAuthorization =
|
57
|
+
txNew.transaction.accountUpdates[i].lazyAuthorization;
|
58
|
+
if (blindingValues[i] !== "") {
|
59
|
+
if (
|
60
|
+
transaction.transaction.accountUpdates[i].lazyAuthorization ===
|
61
|
+
undefined ||
|
62
|
+
(transaction.transaction.accountUpdates[i].lazyAuthorization as any)
|
63
|
+
.blindingValue === undefined
|
64
|
+
) {
|
65
|
+
throw new Error(
|
66
|
+
`Lazy authorization blinding value is undefined for item ${i}`
|
67
|
+
);
|
68
|
+
}
|
69
|
+
(
|
70
|
+
transaction.transaction.accountUpdates[i].lazyAuthorization as any
|
71
|
+
).blindingValue = Field.fromJSON(blindingValues[i]);
|
72
|
+
}
|
73
|
+
if (forests[i].length > 0) {
|
74
|
+
if (
|
75
|
+
transaction.transaction.accountUpdates[i].lazyAuthorization ===
|
76
|
+
undefined ||
|
77
|
+
(transaction.transaction.accountUpdates[i].lazyAuthorization as any)
|
78
|
+
.args === undefined
|
79
|
+
) {
|
80
|
+
throw new Error(`Lazy authorization args is undefined for item ${i}`);
|
81
|
+
}
|
82
|
+
deserializeLazyAuthorization(
|
83
|
+
(transaction.transaction.accountUpdates[i].lazyAuthorization as any)
|
84
|
+
.args,
|
85
|
+
forests[i]
|
86
|
+
);
|
87
|
+
if (forests[i].restoredItems !== forests[i].length) {
|
88
|
+
throw new Error(`Forest ${i} not fully restored`);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
transaction.transaction.feePayer.authorization =
|
93
|
+
signedJson.zkappCommand.feePayer.authorization;
|
94
|
+
transaction.transaction.feePayer.body.fee = UInt64.from(
|
95
|
+
signedJson.zkappCommand.feePayer.body.fee
|
96
|
+
);
|
97
|
+
for (let i = 0; i < length; i++) {
|
98
|
+
const signature =
|
99
|
+
signedJson.zkappCommand.accountUpdates[i].authorization.signature;
|
100
|
+
if (signature !== undefined && signature !== null) {
|
101
|
+
transaction.transaction.accountUpdates[i].authorization.signature =
|
102
|
+
signedJson.zkappCommand.accountUpdates[i].authorization.signature;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
return transaction;
|
106
|
+
}
|
107
|
+
|
108
|
+
export function serializeTransaction(
|
109
|
+
tx: Mina.Transaction<false, false>
|
110
|
+
): string {
|
111
|
+
const length = tx.transaction.accountUpdates.length;
|
112
|
+
let i;
|
113
|
+
const blindingValues = [];
|
114
|
+
const forests: ForestSerialized[] = [];
|
115
|
+
for (i = 0; i < length; i++) {
|
116
|
+
const la = tx.transaction.accountUpdates[i].lazyAuthorization;
|
117
|
+
if (
|
118
|
+
la !== undefined &&
|
119
|
+
(la as any).blindingValue !== undefined &&
|
120
|
+
la.kind === "lazy-proof"
|
121
|
+
)
|
122
|
+
blindingValues.push(la.blindingValue.toJSON());
|
123
|
+
else blindingValues.push("");
|
124
|
+
const forest: ForestSerialized = { length: 0, items: [] };
|
125
|
+
serializeLazyAuthorization(
|
126
|
+
(tx.transaction.accountUpdates[i].lazyAuthorization as any)?.args,
|
127
|
+
forest
|
128
|
+
);
|
129
|
+
forests.push(forest);
|
130
|
+
}
|
131
|
+
const serializedTransaction = JSON.stringify(
|
132
|
+
{
|
133
|
+
tx: tx.toJSON(),
|
134
|
+
blindingValues,
|
135
|
+
forestJSONs: forests.map((f) => JSON.stringify(f)),
|
136
|
+
length,
|
137
|
+
fee: tx.transaction.feePayer.body.fee.toJSON(),
|
138
|
+
sender: tx.transaction.feePayer.body.publicKey.toBase58(),
|
139
|
+
nonce: tx.transaction.feePayer.body.nonce.toBigint().toString(),
|
140
|
+
},
|
141
|
+
null,
|
142
|
+
2
|
143
|
+
);
|
144
|
+
return serializedTransaction;
|
145
|
+
}
|
146
|
+
|
147
|
+
function serializeLazyAuthorization(
|
148
|
+
lazyAuthorization: any,
|
149
|
+
serialized: ForestSerialized
|
150
|
+
): void {
|
151
|
+
if (lazyAuthorization?.hash !== undefined && lazyAuthorization.hash.toJSON) {
|
152
|
+
serialized.items.push({
|
153
|
+
h: fieldToBase64(lazyAuthorization.hash),
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
if (
|
158
|
+
lazyAuthorization?.previousHash !== undefined &&
|
159
|
+
lazyAuthorization.previousHash.toJSON
|
160
|
+
) {
|
161
|
+
serialized.items.push({
|
162
|
+
p: fieldToBase64(lazyAuthorization.previousHash),
|
163
|
+
});
|
164
|
+
}
|
165
|
+
if (
|
166
|
+
lazyAuthorization?.callData !== undefined &&
|
167
|
+
lazyAuthorization.callData.toJSON
|
168
|
+
) {
|
169
|
+
serialized.items.push({
|
170
|
+
c: fieldToBase64(lazyAuthorization.callData),
|
171
|
+
});
|
172
|
+
}
|
173
|
+
|
174
|
+
if (lazyAuthorization?.id !== undefined) {
|
175
|
+
serialized.items.push({
|
176
|
+
i: lazyAuthorization.id,
|
177
|
+
});
|
178
|
+
}
|
179
|
+
|
180
|
+
if (Array.isArray(lazyAuthorization)) {
|
181
|
+
for (const item of lazyAuthorization) {
|
182
|
+
serializeLazyAuthorization(item, serialized);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
if (typeof lazyAuthorization === "object") {
|
186
|
+
for (const key in lazyAuthorization) {
|
187
|
+
serializeLazyAuthorization(lazyAuthorization[key], serialized);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
serialized.length = serialized.items.length;
|
191
|
+
}
|
192
|
+
|
193
|
+
function deserializeLazyAuthorization(
|
194
|
+
lazyAuthorization: any,
|
195
|
+
serialized: ForestSerialized
|
196
|
+
): void {
|
197
|
+
if (serialized.restoredItems === undefined) serialized.restoredItems = 0;
|
198
|
+
if (lazyAuthorization?.hash !== undefined && lazyAuthorization.hash.toJSON) {
|
199
|
+
if (serialized.restoredItems >= serialized.length)
|
200
|
+
throw new Error("Restored more items than expected");
|
201
|
+
const hash = serialized.items[serialized.restoredItems].h;
|
202
|
+
if (hash === undefined)
|
203
|
+
throw new Error(`Hash is undefined for item ${serialized.restoredItems}`);
|
204
|
+
lazyAuthorization.hash = fieldFromBase64(hash);
|
205
|
+
|
206
|
+
serialized.restoredItems++;
|
207
|
+
}
|
208
|
+
if (
|
209
|
+
lazyAuthorization?.previousHash !== undefined &&
|
210
|
+
lazyAuthorization.previousHash.toJSON
|
211
|
+
) {
|
212
|
+
if (serialized.restoredItems >= serialized.length)
|
213
|
+
throw new Error("Restored more items than expected");
|
214
|
+
const previousHash = serialized.items[serialized.restoredItems].p;
|
215
|
+
if (previousHash === undefined)
|
216
|
+
throw new Error(
|
217
|
+
`Previous hash is undefined for item ${serialized.restoredItems}`
|
218
|
+
);
|
219
|
+
lazyAuthorization.previousHash = fieldFromBase64(previousHash);
|
220
|
+
serialized.restoredItems++;
|
221
|
+
}
|
222
|
+
if (
|
223
|
+
lazyAuthorization?.callData !== undefined &&
|
224
|
+
lazyAuthorization.callData.toJSON
|
225
|
+
) {
|
226
|
+
if (serialized.restoredItems >= serialized.length)
|
227
|
+
throw new Error("Restored more items than expected");
|
228
|
+
const callData = serialized.items[serialized.restoredItems].c;
|
229
|
+
if (callData === undefined)
|
230
|
+
throw new Error(
|
231
|
+
`Call data is undefined for item ${serialized.restoredItems}`
|
232
|
+
);
|
233
|
+
lazyAuthorization.callData = fieldFromBase64(callData);
|
234
|
+
serialized.restoredItems++;
|
235
|
+
}
|
236
|
+
if (lazyAuthorization?.id !== undefined) {
|
237
|
+
if (serialized.restoredItems >= serialized.length)
|
238
|
+
throw new Error("Restored more items than expected");
|
239
|
+
const id = serialized.items[serialized.restoredItems].i;
|
240
|
+
if (id === undefined)
|
241
|
+
throw new Error(`Id is undefined for item ${serialized.restoredItems}`);
|
242
|
+
lazyAuthorization.id = id;
|
243
|
+
serialized.restoredItems++;
|
244
|
+
}
|
245
|
+
if (Array.isArray(lazyAuthorization)) {
|
246
|
+
for (const item of lazyAuthorization) {
|
247
|
+
deserializeLazyAuthorization(item, serialized);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
if (typeof lazyAuthorization === "object") {
|
251
|
+
for (const key in lazyAuthorization) {
|
252
|
+
deserializeLazyAuthorization(lazyAuthorization[key], serialized);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { BlockBerryChain } from "./chain.js";
|
2
|
+
import { getZkAppTxFromBlockBerry } from "./blockberry.js";
|
3
|
+
const TIMEOUT = 1000 * 60 * 21;
|
4
|
+
|
5
|
+
export async function txStatusBlockberry(params: {
|
6
|
+
hash: string;
|
7
|
+
time: number;
|
8
|
+
chain: BlockBerryChain;
|
9
|
+
blockBerryApiKey: string;
|
10
|
+
timeout?: number;
|
11
|
+
}): Promise<string> {
|
12
|
+
const { hash, chain, time, blockBerryApiKey } = params;
|
13
|
+
|
14
|
+
const tx = await getZkAppTxFromBlockBerry({ hash, chain, blockBerryApiKey });
|
15
|
+
if (tx?.txStatus) return tx?.txStatus;
|
16
|
+
if (Date.now() - time > (params.timeout ?? TIMEOUT)) {
|
17
|
+
console.error(
|
18
|
+
"txStatus: Timeout while checking tx with blockberry",
|
19
|
+
chain,
|
20
|
+
hash
|
21
|
+
);
|
22
|
+
return "replaced";
|
23
|
+
} else {
|
24
|
+
return "pending";
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Field } from "o1js";
|
2
|
+
import { toBase, fromBase } from "../../cloud/utils/base64.js";
|
3
|
+
|
4
|
+
// URL friendly base64 encoding
|
5
|
+
const TABLE =
|
6
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
7
|
+
|
8
|
+
export function fieldToBase56(field: Field): string {
|
9
|
+
const digits = toBase(field.toBigInt(), 56n);
|
10
|
+
//console.log("digits:", digits);
|
11
|
+
const str = digits.map((x) => TABLE[Number(x)]).join("");
|
12
|
+
//console.log("str:", str);
|
13
|
+
return str;
|
14
|
+
}
|
15
|
+
|
16
|
+
export function fieldFromBase56(str: string): Field {
|
17
|
+
const base56Digits = str.split("").map((x) => BigInt(TABLE.indexOf(x)));
|
18
|
+
const x = fromBase(base56Digits, 56n);
|
19
|
+
return Field(x);
|
20
|
+
}
|
21
|
+
|
22
|
+
export function fieldToBase64(field: Field): string {
|
23
|
+
const digits = toBase(field.toBigInt(), 64n);
|
24
|
+
//console.log("digits:", digits);
|
25
|
+
const str = digits.map((x) => TABLE[Number(x)]).join("");
|
26
|
+
//console.log("str:", str);
|
27
|
+
return str;
|
28
|
+
}
|
29
|
+
|
30
|
+
export function fieldFromBase64(str: string): Field {
|
31
|
+
const base64Digits = str.split("").map((x) => BigInt(TABLE.indexOf(x)));
|
32
|
+
const x = fromBase(base64Digits, 64n);
|
33
|
+
return Field(x);
|
34
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { UInt64 } from "o1js";
|
2
|
+
import config from "../../cloud/config.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Calculate the fee for a transaction
|
6
|
+
* @returns the fee for a transaction
|
7
|
+
*/
|
8
|
+
export async function fee(): Promise<UInt64> {
|
9
|
+
//TODO: update after mainnet launch and resolution of the issue https://github.com/o1-labs/o1js/issues/1626
|
10
|
+
return UInt64.fromJSON(config.MINAFEE);
|
11
|
+
}
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import {
|
2
|
+
PublicKey,
|
3
|
+
Field,
|
4
|
+
Mina,
|
5
|
+
fetchAccount,
|
6
|
+
checkZkappTransaction,
|
7
|
+
} from "o1js";
|
8
|
+
import { sleep } from "../../cloud/utils/index.js";
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Fetches the Mina account for a given public key with error handling
|
12
|
+
* @param params the parameters for fetching the account
|
13
|
+
* @param params.publicKey the public key of the account
|
14
|
+
* @param params.tokenId the token id of the account
|
15
|
+
* @param params.force whether to force the fetch - use it only if you are sure the account exists
|
16
|
+
* @returns the account object
|
17
|
+
*/
|
18
|
+
export async function fetchMinaAccount(params: {
|
19
|
+
publicKey: string | PublicKey;
|
20
|
+
tokenId?: string | Field | undefined;
|
21
|
+
force?: boolean;
|
22
|
+
}) {
|
23
|
+
const { publicKey, tokenId, force = false } = params;
|
24
|
+
const timeout = 1000 * 60 * 3; // 3 minutes
|
25
|
+
let attempt = 0;
|
26
|
+
const startTime = Date.now();
|
27
|
+
let result = { account: undefined };
|
28
|
+
while (Date.now() - startTime < timeout) {
|
29
|
+
try {
|
30
|
+
const result = await fetchAccount({
|
31
|
+
publicKey,
|
32
|
+
tokenId,
|
33
|
+
});
|
34
|
+
return result;
|
35
|
+
} catch (error: any) {
|
36
|
+
if (force === true)
|
37
|
+
console.log("Error in fetchMinaAccount:", {
|
38
|
+
error,
|
39
|
+
publicKey:
|
40
|
+
typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
|
41
|
+
tokenId: tokenId?.toString(),
|
42
|
+
force,
|
43
|
+
});
|
44
|
+
else {
|
45
|
+
console.log("fetchMinaAccount error", {
|
46
|
+
error,
|
47
|
+
publicKey:
|
48
|
+
typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
|
49
|
+
tokenId: tokenId?.toString(),
|
50
|
+
force,
|
51
|
+
});
|
52
|
+
return result;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
attempt++;
|
56
|
+
await sleep(1000 * 6 * attempt); // to handle rate limit we increase the interval
|
57
|
+
}
|
58
|
+
if (force === true)
|
59
|
+
throw new Error(
|
60
|
+
`fetchMinaAccount timeout
|
61
|
+
${{
|
62
|
+
publicKey:
|
63
|
+
typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
|
64
|
+
tokenId: tokenId?.toString(),
|
65
|
+
force,
|
66
|
+
}}`
|
67
|
+
);
|
68
|
+
else
|
69
|
+
console.log(
|
70
|
+
"fetchMinaAccount timeout",
|
71
|
+
typeof publicKey === "string" ? publicKey : publicKey.toBase58(),
|
72
|
+
tokenId?.toString(),
|
73
|
+
force
|
74
|
+
);
|
75
|
+
return result;
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Fetches the Mina actions for a given public key with error handling
|
80
|
+
* @param publicKey the public key of the contract
|
81
|
+
* @param fromActionState the starting action state
|
82
|
+
* @param endActionState the ending action state
|
83
|
+
* @returns the actions array
|
84
|
+
*/
|
85
|
+
|
86
|
+
export async function fetchMinaActions(
|
87
|
+
publicKey: PublicKey,
|
88
|
+
fromActionState: Field,
|
89
|
+
endActionState?: Field
|
90
|
+
) {
|
91
|
+
const timeout = 1000 * 60 * 600; // 10 hours
|
92
|
+
const startTime = Date.now();
|
93
|
+
while (Date.now() - startTime < timeout) {
|
94
|
+
try {
|
95
|
+
let actions = await Mina.fetchActions(publicKey, {
|
96
|
+
fromActionState,
|
97
|
+
endActionState,
|
98
|
+
});
|
99
|
+
if (Array.isArray(actions)) return actions;
|
100
|
+
else console.log("Cannot fetch actions - wrong format");
|
101
|
+
} catch (error: any) {
|
102
|
+
console.log(
|
103
|
+
"Error in fetchMinaActions",
|
104
|
+
error.toString().substring(0, 300)
|
105
|
+
);
|
106
|
+
}
|
107
|
+
await sleep(1000 * 60 * 2);
|
108
|
+
}
|
109
|
+
console.log("Timeout in fetchMinaActions");
|
110
|
+
return undefined;
|
111
|
+
}
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Fetches the Mina transaction for a given hash with error handling
|
115
|
+
* @param hash the hash of the transaction
|
116
|
+
* @returns the transaction object
|
117
|
+
*/
|
118
|
+
export async function checkMinaZkappTransaction(hash: string) {
|
119
|
+
try {
|
120
|
+
const result = await checkZkappTransaction(hash);
|
121
|
+
return result;
|
122
|
+
} catch (error) {
|
123
|
+
console.error("Error in checkZkappTransaction:", error);
|
124
|
+
return { success: false };
|
125
|
+
}
|
126
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Field, Poseidon } from "o1js";
|
2
|
+
import { fieldToBase64, fieldFromBase64 } from "./base64.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Serialize fields to a string using base64 URL-friendly encoding
|
6
|
+
* @param fields the fields array to serialize
|
7
|
+
* @returns the serialized string
|
8
|
+
*/
|
9
|
+
export function serializeFields(fields: Field[]): string {
|
10
|
+
const hash = Poseidon.hash(fields);
|
11
|
+
const value = [Field(fields.length), hash, ...fields];
|
12
|
+
//return value.map((f) => f.toBigInt().toString(36)).join(".");
|
13
|
+
return value.map((f) => fieldToBase64(f)).join(".");
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Deserialize fields from a string using base64 URL-friendly encoding
|
18
|
+
* @param s the string to deserialize
|
19
|
+
* @returns the deserialized fields array
|
20
|
+
*/
|
21
|
+
export function deserializeFields(s: string): Field[] {
|
22
|
+
try {
|
23
|
+
//const value = s.split(".").map((n) => Field(BigInt(convert(n, 36))));
|
24
|
+
const value = s.split(".").map((n) => fieldFromBase64(n));
|
25
|
+
const length = value[0];
|
26
|
+
if (
|
27
|
+
Field(value.length - 2)
|
28
|
+
.equals(length)
|
29
|
+
.toBoolean() === false
|
30
|
+
)
|
31
|
+
throw new Error("deserializeFields: invalid length");
|
32
|
+
const hash = Poseidon.hash(value.slice(2));
|
33
|
+
if (hash.equals(value[1]).toBoolean()) {
|
34
|
+
return value.slice(2);
|
35
|
+
} else throw new Error("deserializeFields: invalid hash: data mismatch");
|
36
|
+
} catch (e: any) {
|
37
|
+
throw new Error(`deserializeFields: invalid string: ${s}: ${e}`);
|
38
|
+
}
|
39
|
+
}
|