zerc20-client-sdk 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -1
- package/dist/decider/__tests__/prover.test.d.ts +2 -0
- package/dist/decider/__tests__/prover.test.d.ts.map +1 -0
- package/dist/decider/__tests__/prover.test.js +246 -0
- package/dist/decider/__tests__/prover.test.js.map +1 -0
- package/dist/decider/prover.d.ts +36 -4
- package/dist/decider/prover.d.ts.map +1 -1
- package/dist/decider/prover.js +48 -38
- package/dist/decider/prover.js.map +1 -1
- package/dist/ic/__tests__/candid.test.d.ts +2 -0
- package/dist/ic/__tests__/candid.test.d.ts.map +1 -0
- package/dist/ic/__tests__/candid.test.js +44 -0
- package/dist/ic/__tests__/candid.test.js.map +1 -0
- package/dist/ic/__tests__/client.test.d.ts +2 -0
- package/dist/ic/__tests__/client.test.d.ts.map +1 -0
- package/dist/ic/__tests__/client.test.js +522 -0
- package/dist/ic/__tests__/client.test.js.map +1 -0
- package/dist/ic/__tests__/config.test.d.ts +2 -0
- package/dist/ic/__tests__/config.test.d.ts.map +1 -0
- package/dist/ic/__tests__/config.test.js +72 -0
- package/dist/ic/__tests__/config.test.js.map +1 -0
- package/dist/ic/__tests__/connections.test.d.ts +2 -0
- package/dist/ic/__tests__/connections.test.d.ts.map +1 -0
- package/dist/ic/__tests__/connections.test.js +385 -0
- package/dist/ic/__tests__/connections.test.js.map +1 -0
- package/dist/ic/__tests__/invoice.test.d.ts +2 -0
- package/dist/ic/__tests__/invoice.test.d.ts.map +1 -0
- package/dist/ic/__tests__/invoice.test.js +95 -0
- package/dist/ic/__tests__/invoice.test.js.map +1 -0
- package/dist/ic/authorization.d.ts +28 -0
- package/dist/ic/authorization.d.ts.map +1 -1
- package/dist/ic/authorization.js +24 -0
- package/dist/ic/authorization.js.map +1 -1
- package/dist/ic/candid.d.ts +72 -0
- package/dist/ic/candid.d.ts.map +1 -0
- package/dist/ic/candid.js +35 -0
- package/dist/ic/candid.js.map +1 -0
- package/dist/ic/client.d.ts +57 -59
- package/dist/ic/client.d.ts.map +1 -1
- package/dist/ic/client.js +59 -81
- package/dist/ic/client.js.map +1 -1
- package/dist/ic/config.d.ts +27 -0
- package/dist/ic/config.d.ts.map +1 -1
- package/dist/ic/config.js +27 -0
- package/dist/ic/config.js.map +1 -1
- package/dist/ic/connections.d.ts +99 -4
- package/dist/ic/connections.d.ts.map +1 -1
- package/dist/ic/connections.js +222 -30
- package/dist/ic/connections.js.map +1 -1
- package/dist/ic/encryption.d.ts +33 -0
- package/dist/ic/encryption.d.ts.map +1 -1
- package/dist/ic/encryption.js +21 -0
- package/dist/ic/encryption.js.map +1 -1
- package/dist/ic/errors.d.ts +15 -0
- package/dist/ic/errors.d.ts.map +1 -1
- package/dist/ic/errors.js +15 -0
- package/dist/ic/errors.js.map +1 -1
- package/dist/ic/idl.d.ts +26 -0
- package/dist/ic/idl.d.ts.map +1 -0
- package/dist/ic/idl.js +84 -0
- package/dist/ic/idl.js.map +1 -0
- package/dist/ic/index.d.ts +1 -1
- package/dist/ic/index.d.ts.map +1 -1
- package/dist/ic/index.js +1 -1
- package/dist/ic/index.js.map +1 -1
- package/dist/ic/invoice.d.ts.map +1 -1
- package/dist/ic/invoice.js.map +1 -1
- package/dist/ic/types.d.ts +42 -0
- package/dist/ic/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/onchain/__tests__/contracts.test.d.ts +2 -0
- package/dist/onchain/__tests__/contracts.test.d.ts.map +1 -0
- package/dist/onchain/__tests__/contracts.test.js +42 -0
- package/dist/onchain/__tests__/contracts.test.js.map +1 -0
- package/dist/onchain/contracts.d.ts +22 -0
- package/dist/onchain/contracts.d.ts.map +1 -1
- package/dist/onchain/contracts.js +22 -0
- package/dist/onchain/contracts.js.map +1 -1
- package/dist/operations/__tests__/invoice.test.d.ts +2 -0
- package/dist/operations/__tests__/invoice.test.d.ts.map +1 -0
- package/dist/operations/__tests__/invoice.test.js +261 -0
- package/dist/operations/__tests__/invoice.test.js.map +1 -0
- package/dist/operations/__tests__/privateSend.test.d.ts +2 -0
- package/dist/operations/__tests__/privateSend.test.d.ts.map +1 -0
- package/dist/operations/__tests__/privateSend.test.js +135 -0
- package/dist/operations/__tests__/privateSend.test.js.map +1 -0
- package/dist/operations/__tests__/reexports.test.d.ts +2 -0
- package/dist/operations/__tests__/reexports.test.d.ts.map +1 -0
- package/dist/operations/__tests__/reexports.test.js +22 -0
- package/dist/operations/__tests__/reexports.test.js.map +1 -0
- package/dist/operations/__tests__/scanner.test.d.ts +2 -0
- package/dist/operations/__tests__/scanner.test.d.ts.map +1 -0
- package/dist/operations/__tests__/scanner.test.js +201 -0
- package/dist/operations/__tests__/scanner.test.js.map +1 -0
- package/dist/operations/__tests__/teleport.test.d.ts +2 -0
- package/dist/operations/__tests__/teleport.test.d.ts.map +1 -0
- package/dist/operations/__tests__/teleport.test.js +35 -0
- package/dist/operations/__tests__/teleport.test.js.map +1 -0
- package/dist/operations/__tests__/teleportProof.test.d.ts +2 -0
- package/dist/operations/__tests__/teleportProof.test.d.ts.map +1 -0
- package/dist/operations/__tests__/teleportProof.test.js +126 -0
- package/dist/operations/__tests__/teleportProof.test.js.map +1 -0
- package/dist/operations/invoice.d.ts +44 -0
- package/dist/operations/invoice.d.ts.map +1 -1
- package/dist/operations/invoice.js +30 -0
- package/dist/operations/invoice.js.map +1 -1
- package/dist/operations/liquidityManager/__tests__/balance.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/balance.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/balance.test.js +104 -0
- package/dist/operations/liquidityManager/__tests__/balance.test.js.map +1 -0
- package/dist/operations/liquidityManager/__tests__/crossUnwrap.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/crossUnwrap.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/crossUnwrap.test.js +198 -0
- package/dist/operations/liquidityManager/__tests__/crossUnwrap.test.js.map +1 -0
- package/dist/operations/liquidityManager/__tests__/helpers.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/helpers.test.js +126 -0
- package/dist/operations/liquidityManager/__tests__/helpers.test.js.map +1 -0
- package/dist/operations/liquidityManager/__tests__/unwrap.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/unwrap.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/unwrap.test.js +224 -0
- package/dist/operations/liquidityManager/__tests__/unwrap.test.js.map +1 -0
- package/dist/operations/liquidityManager/__tests__/wrap.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/wrap.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/wrap.test.js +144 -0
- package/dist/operations/liquidityManager/__tests__/wrap.test.js.map +1 -0
- package/dist/operations/liquidityManager/balance.d.ts +19 -0
- package/dist/operations/liquidityManager/balance.d.ts.map +1 -0
- package/dist/operations/liquidityManager/balance.js +62 -0
- package/dist/operations/liquidityManager/balance.js.map +1 -0
- package/dist/operations/liquidityManager/crossUnwrap.d.ts +73 -0
- package/dist/operations/liquidityManager/crossUnwrap.d.ts.map +1 -0
- package/dist/operations/liquidityManager/crossUnwrap.js +189 -0
- package/dist/operations/liquidityManager/crossUnwrap.js.map +1 -0
- package/dist/operations/liquidityManager/helpers.d.ts +15521 -0
- package/dist/operations/liquidityManager/helpers.d.ts.map +1 -0
- package/dist/operations/liquidityManager/helpers.js +81 -0
- package/dist/operations/liquidityManager/helpers.js.map +1 -0
- package/dist/operations/liquidityManager/index.d.ts +12 -0
- package/dist/operations/liquidityManager/index.d.ts.map +1 -0
- package/dist/operations/liquidityManager/index.js +9 -0
- package/dist/operations/liquidityManager/index.js.map +1 -0
- package/dist/operations/liquidityManager/types.d.ts +90 -0
- package/dist/operations/liquidityManager/types.d.ts.map +1 -0
- package/dist/operations/liquidityManager/types.js +5 -0
- package/dist/operations/liquidityManager/types.js.map +1 -0
- package/dist/operations/liquidityManager/unwrap.d.ts +54 -0
- package/dist/operations/liquidityManager/unwrap.d.ts.map +1 -0
- package/dist/operations/liquidityManager/unwrap.js +80 -0
- package/dist/operations/liquidityManager/unwrap.js.map +1 -0
- package/dist/operations/liquidityManager/wrap.d.ts +38 -0
- package/dist/operations/liquidityManager/wrap.d.ts.map +1 -0
- package/dist/operations/liquidityManager/wrap.js +53 -0
- package/dist/operations/liquidityManager/wrap.js.map +1 -0
- package/dist/operations/liquidityManager.d.ts +3 -104
- package/dist/operations/liquidityManager.d.ts.map +1 -1
- package/dist/operations/liquidityManager.js +3 -343
- package/dist/operations/liquidityManager.js.map +1 -1
- package/dist/operations/privateSend.d.ts +26 -0
- package/dist/operations/privateSend.d.ts.map +1 -1
- package/dist/operations/privateSend.js +11 -0
- package/dist/operations/privateSend.js.map +1 -1
- package/dist/operations/receive/__tests__/announcementStatus.test.d.ts +2 -0
- package/dist/operations/receive/__tests__/announcementStatus.test.d.ts.map +1 -0
- package/dist/operations/receive/__tests__/announcementStatus.test.js +223 -0
- package/dist/operations/receive/__tests__/announcementStatus.test.js.map +1 -0
- package/dist/operations/receive/__tests__/cache.test.d.ts +2 -0
- package/dist/operations/receive/__tests__/cache.test.d.ts.map +1 -0
- package/dist/operations/receive/__tests__/cache.test.js +339 -0
- package/dist/operations/receive/__tests__/cache.test.js.map +1 -0
- package/dist/operations/receive/__tests__/helpers.test.d.ts +2 -0
- package/dist/operations/receive/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/operations/receive/__tests__/helpers.test.js +80 -0
- package/dist/operations/receive/__tests__/helpers.test.js.map +1 -0
- package/dist/operations/receive/__tests__/redeemContext.test.d.ts +2 -0
- package/dist/operations/receive/__tests__/redeemContext.test.d.ts.map +1 -0
- package/dist/operations/receive/__tests__/redeemContext.test.js +230 -0
- package/dist/operations/receive/__tests__/redeemContext.test.js.map +1 -0
- package/dist/operations/receive/announcementStatus.d.ts +12 -0
- package/dist/operations/receive/announcementStatus.d.ts.map +1 -0
- package/dist/operations/receive/announcementStatus.js +56 -0
- package/dist/operations/receive/announcementStatus.js.map +1 -0
- package/dist/operations/receive/cache.d.ts +69 -0
- package/dist/operations/receive/cache.d.ts.map +1 -0
- package/dist/operations/receive/cache.js +105 -0
- package/dist/operations/receive/cache.js.map +1 -0
- package/dist/operations/receive/helpers.d.ts +16 -0
- package/dist/operations/receive/helpers.d.ts.map +1 -0
- package/dist/operations/receive/helpers.js +33 -0
- package/dist/operations/receive/helpers.js.map +1 -0
- package/dist/operations/receive/index.d.ts +9 -0
- package/dist/operations/receive/index.d.ts.map +1 -0
- package/dist/operations/receive/index.js +9 -0
- package/dist/operations/receive/index.js.map +1 -0
- package/dist/operations/receive/redeemContext.d.ts +16 -0
- package/dist/operations/receive/redeemContext.d.ts.map +1 -0
- package/dist/operations/receive/redeemContext.js +107 -0
- package/dist/operations/receive/redeemContext.js.map +1 -0
- package/dist/operations/receive/types.d.ts +141 -0
- package/dist/operations/receive/types.d.ts.map +1 -0
- package/dist/operations/receive/types.js +5 -0
- package/dist/operations/receive/types.js.map +1 -0
- package/dist/operations/receive.d.ts +5 -66
- package/dist/operations/receive.d.ts.map +1 -1
- package/dist/operations/receive.js +5 -173
- package/dist/operations/receive.js.map +1 -1
- package/dist/operations/scanner.d.ts +37 -0
- package/dist/operations/scanner.d.ts.map +1 -1
- package/dist/operations/scanner.js +21 -0
- package/dist/operations/scanner.js.map +1 -1
- package/dist/operations/teleport.d.ts +5 -0
- package/dist/operations/teleport.d.ts.map +1 -1
- package/dist/operations/teleport.js +5 -0
- package/dist/operations/teleport.js.map +1 -1
- package/dist/operations/teleportProof.d.ts +34 -0
- package/dist/operations/teleportProof.d.ts.map +1 -1
- package/dist/operations/teleportProof.js +16 -0
- package/dist/operations/teleportProof.js.map +1 -1
- package/dist/registry/__tests__/helpers.test.d.ts +2 -0
- package/dist/registry/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/registry/__tests__/helpers.test.js +98 -0
- package/dist/registry/__tests__/helpers.test.js.map +1 -0
- package/dist/registry/__tests__/loader.test.d.ts +2 -0
- package/dist/registry/__tests__/loader.test.d.ts.map +1 -0
- package/dist/registry/__tests__/loader.test.js +300 -0
- package/dist/registry/__tests__/loader.test.js.map +1 -0
- package/dist/registry/__tests__/normalize.test.d.ts +2 -0
- package/dist/registry/__tests__/normalize.test.d.ts.map +1 -0
- package/dist/registry/__tests__/normalize.test.js +180 -0
- package/dist/registry/__tests__/normalize.test.js.map +1 -0
- package/dist/registry/__tests__/parsing.test.d.ts +2 -0
- package/dist/registry/__tests__/parsing.test.d.ts.map +1 -0
- package/dist/registry/__tests__/parsing.test.js +188 -0
- package/dist/registry/__tests__/parsing.test.js.map +1 -0
- package/dist/registry/helpers.d.ts +14 -0
- package/dist/registry/helpers.d.ts.map +1 -0
- package/dist/registry/helpers.js +29 -0
- package/dist/registry/helpers.js.map +1 -0
- package/dist/registry/index.d.ts +13 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +15 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/loader.d.ts +57 -0
- package/dist/registry/loader.d.ts.map +1 -0
- package/dist/registry/loader.js +188 -0
- package/dist/registry/loader.js.map +1 -0
- package/dist/registry/normalize.d.ts +29 -0
- package/dist/registry/normalize.d.ts.map +1 -0
- package/dist/registry/normalize.js +81 -0
- package/dist/registry/normalize.js.map +1 -0
- package/dist/registry/parsing.d.ts +55 -0
- package/dist/registry/parsing.d.ts.map +1 -0
- package/dist/registry/parsing.js +139 -0
- package/dist/registry/parsing.js.map +1 -0
- package/dist/registry/tokens.d.ts +6 -42
- package/dist/registry/tokens.d.ts.map +1 -1
- package/dist/registry/tokens.js +6 -231
- package/dist/registry/tokens.js.map +1 -1
- package/dist/registry/types.d.ts +81 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +2 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/sdk.d.ts +57 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +21 -0
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.publicApi.test.d.ts +2 -0
- package/dist/sdk.publicApi.test.d.ts.map +1 -0
- package/dist/sdk.publicApi.test.js +78 -0
- package/dist/sdk.publicApi.test.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/__tests__/branded.test.d.ts +2 -0
- package/dist/utils/__tests__/branded.test.d.ts.map +1 -0
- package/dist/utils/__tests__/branded.test.js +293 -0
- package/dist/utils/__tests__/branded.test.js.map +1 -0
- package/dist/utils/__tests__/fees.test.d.ts +2 -0
- package/dist/utils/__tests__/fees.test.d.ts.map +1 -0
- package/dist/utils/__tests__/fees.test.js +84 -0
- package/dist/utils/__tests__/fees.test.js.map +1 -0
- package/dist/utils/__tests__/hex.test.d.ts +2 -0
- package/dist/utils/__tests__/hex.test.d.ts.map +1 -0
- package/dist/utils/__tests__/hex.test.js +252 -0
- package/dist/utils/__tests__/hex.test.js.map +1 -0
- package/dist/utils/__tests__/http.test.d.ts +2 -0
- package/dist/utils/__tests__/http.test.d.ts.map +1 -0
- package/dist/utils/__tests__/http.test.js +295 -0
- package/dist/utils/__tests__/http.test.js.map +1 -0
- package/dist/utils/branded.d.ts +154 -0
- package/dist/utils/branded.d.ts.map +1 -0
- package/dist/utils/branded.js +177 -0
- package/dist/utils/branded.js.map +1 -0
- package/dist/utils/fees.d.ts +6 -0
- package/dist/utils/fees.d.ts.map +1 -1
- package/dist/utils/fees.js +4 -0
- package/dist/utils/fees.js.map +1 -1
- package/dist/utils/hex.d.ts +37 -0
- package/dist/utils/hex.d.ts.map +1 -1
- package/dist/utils/hex.js +30 -0
- package/dist/utils/hex.js.map +1 -1
- package/dist/utils/http.d.ts +100 -0
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/http.js +158 -0
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/merkle.d.ts +26 -0
- package/dist/utils/merkle.d.ts.map +1 -1
- package/dist/utils/merkle.js +26 -0
- package/dist/utils/merkle.js.map +1 -1
- package/dist/wasm/__tests__/artifacts.test.d.ts +2 -0
- package/dist/wasm/__tests__/artifacts.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/artifacts.test.js +437 -0
- package/dist/wasm/__tests__/artifacts.test.js.map +1 -0
- package/dist/wasm/__tests__/functions.test.d.ts +2 -0
- package/dist/wasm/__tests__/functions.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/functions.test.js +34 -0
- package/dist/wasm/__tests__/functions.test.js.map +1 -0
- package/dist/wasm/__tests__/helpers.test.d.ts +2 -0
- package/dist/wasm/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/helpers.test.js +128 -0
- package/dist/wasm/__tests__/helpers.test.js.map +1 -0
- package/dist/wasm/__tests__/loader.test.d.ts +2 -0
- package/dist/wasm/__tests__/loader.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/loader.test.js +201 -0
- package/dist/wasm/__tests__/loader.test.js.map +1 -0
- package/dist/wasm/__tests__/runtime.test.d.ts +2 -0
- package/dist/wasm/__tests__/runtime.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/runtime.test.js +335 -0
- package/dist/wasm/__tests__/runtime.test.js.map +1 -0
- package/dist/wasm/__tests__/serialization.test.d.ts +2 -0
- package/dist/wasm/__tests__/serialization.test.d.ts.map +1 -0
- package/dist/wasm/__tests__/serialization.test.js +226 -0
- package/dist/wasm/__tests__/serialization.test.js.map +1 -0
- package/dist/wasm/__tests__/validation.test.js +15 -15
- package/dist/wasm/__tests__/validation.test.js.map +1 -1
- package/dist/wasm/artifacts.d.ts +121 -3
- package/dist/wasm/artifacts.d.ts.map +1 -1
- package/dist/wasm/artifacts.js +175 -50
- package/dist/wasm/artifacts.js.map +1 -1
- package/dist/wasm/functions.d.ts +77 -0
- package/dist/wasm/functions.d.ts.map +1 -0
- package/dist/wasm/functions.js +120 -0
- package/dist/wasm/functions.js.map +1 -0
- package/dist/wasm/helpers.d.ts +32 -0
- package/dist/wasm/helpers.d.ts.map +1 -0
- package/dist/wasm/helpers.js +79 -0
- package/dist/wasm/helpers.js.map +1 -0
- package/dist/wasm/index.d.ts +13 -68
- package/dist/wasm/index.d.ts.map +1 -1
- package/dist/wasm/index.js +14 -514
- package/dist/wasm/index.js.map +1 -1
- package/dist/wasm/loader.d.ts +76 -0
- package/dist/wasm/loader.d.ts.map +1 -0
- package/dist/wasm/loader.js +145 -0
- package/dist/wasm/loader.js.map +1 -0
- package/dist/wasm/runtime.d.ts +65 -0
- package/dist/wasm/runtime.d.ts.map +1 -0
- package/dist/wasm/runtime.js +227 -0
- package/dist/wasm/runtime.js.map +1 -0
- package/dist/wasm/serialization.d.ts +113 -0
- package/dist/wasm/serialization.d.ts.map +1 -0
- package/dist/wasm/serialization.js +188 -0
- package/dist/wasm/serialization.js.map +1 -0
- package/dist/wasm/types.d.ts +30 -0
- package/dist/wasm/types.d.ts.map +1 -0
- package/dist/wasm/types.js +2 -0
- package/dist/wasm/types.js.map +1 -0
- package/dist/zkp/__tests__/proofService.test.d.ts +2 -0
- package/dist/zkp/__tests__/proofService.test.d.ts.map +1 -0
- package/dist/zkp/__tests__/proofService.test.js +283 -0
- package/dist/zkp/__tests__/proofService.test.js.map +1 -0
- package/dist/zkp/__tests__/proofUtils.test.js +86 -0
- package/dist/zkp/__tests__/proofUtils.test.js.map +1 -1
- package/dist/zkp/__tests__/runNovaProver.test.js +13 -1
- package/dist/zkp/__tests__/runNovaProver.test.js.map +1 -1
- package/dist/zkp/__tests__/workerClient.test.d.ts +2 -0
- package/dist/zkp/__tests__/workerClient.test.d.ts.map +1 -0
- package/dist/zkp/__tests__/workerClient.test.js +415 -0
- package/dist/zkp/__tests__/workerClient.test.js.map +1 -0
- package/dist/zkp/index.d.ts +1 -1
- package/dist/zkp/index.d.ts.map +1 -1
- package/dist/zkp/index.js +1 -1
- package/dist/zkp/index.js.map +1 -1
- package/dist/zkp/proofService.d.ts +27 -0
- package/dist/zkp/proofService.d.ts.map +1 -1
- package/dist/zkp/proofService.js +29 -21
- package/dist/zkp/proofService.js.map +1 -1
- package/dist/zkp/proofUtils.d.ts +36 -0
- package/dist/zkp/proofUtils.d.ts.map +1 -1
- package/dist/zkp/proofUtils.js +50 -0
- package/dist/zkp/proofUtils.js.map +1 -1
- package/dist/zkp/workerClient.d.ts +65 -0
- package/dist/zkp/workerClient.d.ts.map +1 -1
- package/dist/zkp/workerClient.js +135 -61
- package/dist/zkp/workerClient.js.map +1 -1
- package/dist/zkp/workerTypes.d.ts +27 -0
- package/dist/zkp/workerTypes.d.ts.map +1 -1
- package/package.json +7 -3
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# zerc20-client-sdk
|
|
2
|
+
|
|
3
|
+
Client SDK for interacting with zERC20 privacy-preserving token system from browser or Node.js environments.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
zERC20 is a privacy-preserving, cross-chain ERC-20 token system that enables:
|
|
8
|
+
|
|
9
|
+
- Private transfers using zero-knowledge proofs (Nova and Groth16 circuits)
|
|
10
|
+
- Stealth transactions via a messaging layer on the Internet Computer (ICP)
|
|
11
|
+
- Cross-chain functionality using LayerZero as the interoperability protocol
|
|
12
|
+
|
|
13
|
+
This SDK provides TypeScript bindings for all client-side operations.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install zerc20-client-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Node.js >= 18
|
|
24
|
+
- Browser with WebAssembly support
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createSdk, preparePrivateSend, scanReceivings } from "zerc20-client-sdk";
|
|
30
|
+
|
|
31
|
+
// Initialize SDK
|
|
32
|
+
const sdk = createSdk({
|
|
33
|
+
// configuration options
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Create a stealth client for ICP communication
|
|
37
|
+
const client = sdk.createStealthClient({
|
|
38
|
+
agent,
|
|
39
|
+
storageCanisterId,
|
|
40
|
+
keyManagerCanisterId,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Prepare a private send
|
|
44
|
+
const prepared = await preparePrivateSend({
|
|
45
|
+
client,
|
|
46
|
+
seed,
|
|
47
|
+
recipientChainId,
|
|
48
|
+
recipientAddress,
|
|
49
|
+
// ...
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Scan for received payments
|
|
53
|
+
const announcements = await scanReceivings({
|
|
54
|
+
client,
|
|
55
|
+
vetKey,
|
|
56
|
+
// ...
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Architecture
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
src/
|
|
64
|
+
├── ic/ # Internet Computer (ICP) integration
|
|
65
|
+
│ ├── client.ts # StealthCanisterClient for canister communication
|
|
66
|
+
│ ├── idl.ts # Candid IDL factory definitions
|
|
67
|
+
│ ├── encryption.ts # IBE + AES-GCM encryption
|
|
68
|
+
│ ├── authorization.ts # EIP-191 signing & VetKD authorization
|
|
69
|
+
│ └── keys.ts # View key derivation
|
|
70
|
+
├── operations/ # High-level protocol operations
|
|
71
|
+
│ ├── privateSend.ts # Private payment flow
|
|
72
|
+
│ ├── receive/ # Receive/scan announcements
|
|
73
|
+
│ ├── invoice.ts # Invoice creation
|
|
74
|
+
│ ├── teleport.ts # Single teleport proof
|
|
75
|
+
│ ├── teleportProof.ts # Batch teleport proof (Nova + Decider)
|
|
76
|
+
│ └── liquidityManager/ # Wrap/unwrap with slippage protection
|
|
77
|
+
├── wasm/ # WASM runtime & bindings
|
|
78
|
+
│ ├── index.ts # WasmRuntime class
|
|
79
|
+
│ ├── loader.ts # WASM bindings loader (browser/Node.js)
|
|
80
|
+
│ └── serialization.ts # Type conversion utilities
|
|
81
|
+
├── zkp/ # Zero-knowledge proof orchestration
|
|
82
|
+
├── decider/ # Decider proof generation (HTTP client)
|
|
83
|
+
├── registry/ # Token & hub configuration
|
|
84
|
+
├── onchain/ # Viem contract bindings
|
|
85
|
+
└── utils/ # Shared utilities
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Key Modules
|
|
89
|
+
|
|
90
|
+
### WasmRuntime
|
|
91
|
+
|
|
92
|
+
Manages WASM module loading with dual runtime support (Browser/Node.js):
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { WasmRuntime, getDefaultWasmRuntime } from "zerc20-client-sdk";
|
|
96
|
+
|
|
97
|
+
// Use default singleton
|
|
98
|
+
const runtime = getDefaultWasmRuntime();
|
|
99
|
+
await runtime.ready();
|
|
100
|
+
|
|
101
|
+
// Or create a custom instance
|
|
102
|
+
const customRuntime = new WasmRuntime({
|
|
103
|
+
url: "https://example.com/zerc20_wasm_bg.wasm",
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### StealthCanisterClient
|
|
108
|
+
|
|
109
|
+
Communicates with ICP canisters for announcements and invoices:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { StealthCanisterClient } from "zerc20-client-sdk";
|
|
113
|
+
|
|
114
|
+
const client = new StealthCanisterClient(agent, storageCanisterId, keyManagerCanisterId);
|
|
115
|
+
|
|
116
|
+
// Submit an announcement
|
|
117
|
+
await client.submitAnnouncement(announcementInput);
|
|
118
|
+
|
|
119
|
+
// List announcements
|
|
120
|
+
const page = await client.listAnnouncements(startAfter, limit);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Liquidity Manager
|
|
124
|
+
|
|
125
|
+
Wrap and unwrap tokens with slippage protection:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import {
|
|
129
|
+
unwrapWithLiquidityManager,
|
|
130
|
+
buildCrossUnwrapQuote,
|
|
131
|
+
applySlippage,
|
|
132
|
+
} from "zerc20-client-sdk";
|
|
133
|
+
|
|
134
|
+
// Local unwrap with slippage protection
|
|
135
|
+
await unwrapWithLiquidityManager({
|
|
136
|
+
walletClient,
|
|
137
|
+
liquidityManagerAddress,
|
|
138
|
+
zerc20TokenAddress,
|
|
139
|
+
amount: 1000n,
|
|
140
|
+
minAmountOut: 950n, // Reject if output < 950
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Cross-chain unwrap with slippage tolerance (basis points)
|
|
144
|
+
const quote = await buildCrossUnwrapQuote({
|
|
145
|
+
sourceToken,
|
|
146
|
+
destinationToken,
|
|
147
|
+
amount: 1000n,
|
|
148
|
+
account,
|
|
149
|
+
slippageBps: 50, // 0.5% slippage tolerance
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Proof Generation
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import {
|
|
157
|
+
HttpDeciderClient,
|
|
158
|
+
createTeleportProofClient,
|
|
159
|
+
getDefaultWasmRuntime,
|
|
160
|
+
} from "zerc20-client-sdk";
|
|
161
|
+
|
|
162
|
+
const runtime = getDefaultWasmRuntime();
|
|
163
|
+
await runtime.ready();
|
|
164
|
+
|
|
165
|
+
const proofClient = createTeleportProofClient({ wasm: runtime });
|
|
166
|
+
|
|
167
|
+
// Single teleport proof (Groth16)
|
|
168
|
+
const singleProof = await proofClient.createSingleTeleportProof(/* ... */);
|
|
169
|
+
|
|
170
|
+
// Batch teleport proof (Nova + Decider)
|
|
171
|
+
const decider = new HttpDeciderClient("https://decider.example.com");
|
|
172
|
+
const batchProof = await proofClient.createBatchTeleportProof({
|
|
173
|
+
decider,
|
|
174
|
+
// ... other inputs
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
### Build
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npm run build
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Test
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm test
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Type Check
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm run typecheck
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Tests
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm test
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Current (as of 2026-02-06): 755 passed, 2 skipped**
|
|
205
|
+
Note: This number will drift over time; treat `npm test` output as the source of truth.
|
|
206
|
+
|
|
207
|
+
### Skipped Tests
|
|
208
|
+
|
|
209
|
+
1. **`src/zkp/__tests__/runNovaProver.test.ts`**
|
|
210
|
+
- Skipped when artifact files are missing
|
|
211
|
+
- Artifacts are expected under `public/artifacts/`:
|
|
212
|
+
- `withdraw_local_groth16_pk.bin`
|
|
213
|
+
- `withdraw_local_groth16_vk.bin`
|
|
214
|
+
- `withdraw_global_groth16_pk.bin`
|
|
215
|
+
- `withdraw_global_groth16_vk.bin`
|
|
216
|
+
- `withdraw_local_nova_pp.bin`
|
|
217
|
+
- `withdraw_local_nova_vp.bin`
|
|
218
|
+
- `withdraw_global_nova_pp.bin`
|
|
219
|
+
- `withdraw_global_nova_vp.bin`
|
|
220
|
+
|
|
221
|
+
2. **`src/ic/__tests__/storage_localnet.test.ts`**
|
|
222
|
+
- Skipped by design
|
|
223
|
+
- Requires running local ICP replica (`dfx start`)
|
|
224
|
+
|
|
225
|
+
## API Stability and Refactoring Policy
|
|
226
|
+
|
|
227
|
+
`zerc20-client-sdk` is published and used by downstream applications (e.g. `zerc20-frontend`). As a rule, prefer non-breaking refactors.
|
|
228
|
+
|
|
229
|
+
- Prefer importing from the package root (`import { ... } from "zerc20-client-sdk"`). Subpath imports are considered internal and may change.
|
|
230
|
+
- Avoid changing the public surface (notably `src/index.ts` exports and re-exports) unless necessary.
|
|
231
|
+
- Avoid breaking changes to the public surface (notably `src/index.ts` exports).
|
|
232
|
+
- When a rename/restructure is desired, keep the old entrypoint and mark it `@deprecated`, and introduce the new API in parallel.
|
|
233
|
+
- Deprecation guideline:
|
|
234
|
+
- Keep deprecated entrypoints for at least one minor release (or a clearly communicated timeframe) before removal.
|
|
235
|
+
- Removal (or behavioral changes) should only happen in a major version bump, with a migration note.
|
|
236
|
+
- If a breaking change is unavoidable:
|
|
237
|
+
- Provide a migration note (old → new) in the release/PR description.
|
|
238
|
+
- Bump the version appropriately (SemVer).
|
|
239
|
+
- Validate against downstream usage (at minimum run TypeScript typecheck/build in `zerc20-frontend`).
|
|
240
|
+
|
|
241
|
+
### Downstream Verification (Recommended)
|
|
242
|
+
|
|
243
|
+
Before merging changes that touch public exports/types, validate against the downstream app:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# In zerc20-frontend
|
|
247
|
+
npm run typecheck
|
|
248
|
+
npm run build
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Dependencies
|
|
252
|
+
|
|
253
|
+
- `@dfinity/*` - Internet Computer SDK
|
|
254
|
+
- `viem` - Ethereum library
|
|
255
|
+
- `@noble/curves` - Cryptographic primitives
|
|
256
|
+
- `poseidon-lite` - Poseidon hash function
|
|
257
|
+
- `pako` - Compression (gzip)
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global protocol and SDK defaults.
|
|
3
|
+
* @remarks
|
|
4
|
+
* These constants are part of the public API. Changing them may affect proof compatibility,
|
|
5
|
+
* indexer interactions, and IC storage routing.
|
|
6
|
+
*/
|
|
7
|
+
/** Height of the aggregation tree (number of levels). */
|
|
1
8
|
export declare const AGGREGATION_TREE_HEIGHT = 6;
|
|
9
|
+
/** Height of the per-chain transfer tree (number of levels). */
|
|
2
10
|
export declare const TRANSFER_TREE_HEIGHT = 40;
|
|
11
|
+
/** Height of the global transfer tree (aggregation + transfer). */
|
|
3
12
|
export declare const GLOBAL_TRANSFER_TREE_HEIGHT: number;
|
|
13
|
+
/** Number of burn addresses in a batch invoice. */
|
|
4
14
|
export declare const NUM_BATCH_INVOICES = 10;
|
|
15
|
+
/** Default max number of events to fetch per indexer request. */
|
|
5
16
|
export declare const DEFAULT_INDEXER_FETCH_LIMIT = 20;
|
|
17
|
+
/** Default block span used when querying aggregation state (in blocks). */
|
|
6
18
|
export declare const DEFAULT_EVENT_BLOCK_SPAN = 5000n;
|
|
19
|
+
/** Default timeout for decider jobs (milliseconds). */
|
|
7
20
|
export declare const DEFAULT_DECIDER_TIMEOUT_MS: number;
|
|
21
|
+
/** Default polling interval for decider job status checks (milliseconds). */
|
|
8
22
|
export declare const DEFAULT_DECIDER_POLL_INTERVAL_MS = 1000;
|
|
23
|
+
/** Default IC storage tag used when no tag is provided. */
|
|
9
24
|
export declare const DEFAULT_ZSTORAGE_TAG = "v1";
|
|
10
25
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,2BAA2B,QAAiD,CAAC;AAC1F,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,0BAA0B,QAAgB,CAAC;AACxD,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,eAAO,MAAM,oBAAoB,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,QAAiD,CAAC;AAC1F,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,iEAAiE;AACjE,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,uDAAuD;AACvD,eAAO,MAAM,0BAA0B,QAAgB,CAAC;AACxD,6EAA6E;AAC7E,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,OAAO,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global protocol and SDK defaults.
|
|
3
|
+
* @remarks
|
|
4
|
+
* These constants are part of the public API. Changing them may affect proof compatibility,
|
|
5
|
+
* indexer interactions, and IC storage routing.
|
|
6
|
+
*/
|
|
7
|
+
/** Height of the aggregation tree (number of levels). */
|
|
1
8
|
export const AGGREGATION_TREE_HEIGHT = 6;
|
|
9
|
+
/** Height of the per-chain transfer tree (number of levels). */
|
|
2
10
|
export const TRANSFER_TREE_HEIGHT = 40;
|
|
11
|
+
/** Height of the global transfer tree (aggregation + transfer). */
|
|
3
12
|
export const GLOBAL_TRANSFER_TREE_HEIGHT = TRANSFER_TREE_HEIGHT + AGGREGATION_TREE_HEIGHT;
|
|
13
|
+
/** Number of burn addresses in a batch invoice. */
|
|
4
14
|
export const NUM_BATCH_INVOICES = 10;
|
|
15
|
+
/** Default max number of events to fetch per indexer request. */
|
|
5
16
|
export const DEFAULT_INDEXER_FETCH_LIMIT = 20;
|
|
17
|
+
/** Default block span used when querying aggregation state (in blocks). */
|
|
6
18
|
export const DEFAULT_EVENT_BLOCK_SPAN = 5000n;
|
|
19
|
+
/** Default timeout for decider jobs (milliseconds). */
|
|
7
20
|
export const DEFAULT_DECIDER_TIMEOUT_MS = 5 * 60 * 1000;
|
|
21
|
+
/** Default polling interval for decider job status checks (milliseconds). */
|
|
8
22
|
export const DEFAULT_DECIDER_POLL_INTERVAL_MS = 1_000;
|
|
23
|
+
/** Default IC storage tag used when no tag is provided. */
|
|
9
24
|
export const DEFAULT_ZSTORAGE_TAG = "v1";
|
|
10
25
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAM,CAAC;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACxD,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,gEAAgE;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,mEAAmE;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;AAC1F,mDAAmD;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,iEAAiE;AACjE,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAM,CAAC;AAC/C,uDAAuD;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACxD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AACtD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prover.test.d.ts","sourceRoot":"","sources":["../../../src/decider/__tests__/prover.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { HttpDeciderClient } from "../prover.js";
|
|
3
|
+
function createMockFetch(responses) {
|
|
4
|
+
let callIndex = 0;
|
|
5
|
+
return vi.fn().mockImplementation(() => {
|
|
6
|
+
const response = responses[callIndex] ?? responses[responses.length - 1];
|
|
7
|
+
callIndex++;
|
|
8
|
+
return Promise.resolve({
|
|
9
|
+
ok: response.ok,
|
|
10
|
+
status: response.status ?? (response.ok ? 200 : 500),
|
|
11
|
+
json: response.json ?? (() => Promise.resolve({})),
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function createCompletedResponse(result) {
|
|
16
|
+
return {
|
|
17
|
+
ok: true,
|
|
18
|
+
json: () => Promise.resolve({
|
|
19
|
+
job_id: "test-job",
|
|
20
|
+
circuit: "root",
|
|
21
|
+
status: "completed",
|
|
22
|
+
result,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function createQueuedResponse() {
|
|
27
|
+
return {
|
|
28
|
+
ok: true,
|
|
29
|
+
json: () => Promise.resolve({
|
|
30
|
+
job_id: "test-job",
|
|
31
|
+
circuit: "root",
|
|
32
|
+
status: "queued",
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createProcessingResponse() {
|
|
37
|
+
return {
|
|
38
|
+
ok: true,
|
|
39
|
+
json: () => Promise.resolve({
|
|
40
|
+
job_id: "test-job",
|
|
41
|
+
circuit: "root",
|
|
42
|
+
status: "processing",
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function createFailedResponse(error) {
|
|
47
|
+
return {
|
|
48
|
+
ok: true,
|
|
49
|
+
json: () => Promise.resolve({
|
|
50
|
+
job_id: "test-job",
|
|
51
|
+
circuit: "root",
|
|
52
|
+
status: "failed",
|
|
53
|
+
error,
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
describe("HttpDeciderClient", () => {
|
|
58
|
+
describe("constructor", () => {
|
|
59
|
+
test("normalizes base URL without trailing slash", () => {
|
|
60
|
+
const mockFetch = createMockFetch([{ ok: true }, createCompletedResponse("AAAA")]);
|
|
61
|
+
const client = new HttpDeciderClient("https://example.com/api", {
|
|
62
|
+
fetchImpl: mockFetch,
|
|
63
|
+
pollIntervalMs: 1,
|
|
64
|
+
});
|
|
65
|
+
// Trigger a request to verify URL construction
|
|
66
|
+
client.produceDeciderProof("root", new Uint8Array([1, 2, 3]));
|
|
67
|
+
expect(mockFetch).toHaveBeenCalledWith("https://example.com/api/jobs", expect.any(Object));
|
|
68
|
+
});
|
|
69
|
+
test("handles base URL with trailing slash", () => {
|
|
70
|
+
const mockFetch = createMockFetch([{ ok: true }, createCompletedResponse("AAAA")]);
|
|
71
|
+
const client = new HttpDeciderClient("https://example.com/api/", {
|
|
72
|
+
fetchImpl: mockFetch,
|
|
73
|
+
pollIntervalMs: 1,
|
|
74
|
+
});
|
|
75
|
+
client.produceDeciderProof("root", new Uint8Array([1, 2, 3]));
|
|
76
|
+
expect(mockFetch).toHaveBeenCalledWith("https://example.com/api/jobs", expect.any(Object));
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("produceDeciderProof", () => {
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
vi.clearAllMocks();
|
|
82
|
+
});
|
|
83
|
+
test("submits job and returns result on immediate completion", async () => {
|
|
84
|
+
// Base64 for [1, 2, 3]
|
|
85
|
+
const resultBase64 = "AQID";
|
|
86
|
+
const mockFetch = createMockFetch([
|
|
87
|
+
{ ok: true }, // submit
|
|
88
|
+
createCompletedResponse(resultBase64), // status
|
|
89
|
+
]);
|
|
90
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
91
|
+
fetchImpl: mockFetch,
|
|
92
|
+
pollIntervalMs: 1,
|
|
93
|
+
});
|
|
94
|
+
const result = await client.produceDeciderProof("root", new Uint8Array([1, 2, 3]));
|
|
95
|
+
expect(result).toEqual(new Uint8Array([1, 2, 3]));
|
|
96
|
+
expect(mockFetch).toHaveBeenCalledTimes(2);
|
|
97
|
+
});
|
|
98
|
+
test("polls until job completes", async () => {
|
|
99
|
+
const resultBase64 = "AQID";
|
|
100
|
+
const mockFetch = createMockFetch([
|
|
101
|
+
{ ok: true }, // submit
|
|
102
|
+
createQueuedResponse(), // first poll
|
|
103
|
+
createProcessingResponse(), // second poll
|
|
104
|
+
createCompletedResponse(resultBase64), // third poll
|
|
105
|
+
]);
|
|
106
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
107
|
+
fetchImpl: mockFetch,
|
|
108
|
+
pollIntervalMs: 1,
|
|
109
|
+
});
|
|
110
|
+
const result = await client.produceDeciderProof("root", new Uint8Array([1, 2, 3]));
|
|
111
|
+
expect(result).toEqual(new Uint8Array([1, 2, 3]));
|
|
112
|
+
expect(mockFetch).toHaveBeenCalledTimes(4);
|
|
113
|
+
});
|
|
114
|
+
test("accepts hex string as ivc proof", async () => {
|
|
115
|
+
const resultBase64 = "AQID";
|
|
116
|
+
const mockFetch = createMockFetch([{ ok: true }, createCompletedResponse(resultBase64)]);
|
|
117
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
118
|
+
fetchImpl: mockFetch,
|
|
119
|
+
pollIntervalMs: 1,
|
|
120
|
+
});
|
|
121
|
+
const result = await client.produceDeciderProof("root", "0x010203");
|
|
122
|
+
expect(result).toEqual(new Uint8Array([1, 2, 3]));
|
|
123
|
+
});
|
|
124
|
+
test("throws on job submission failure", async () => {
|
|
125
|
+
const mockFetch = createMockFetch([{ ok: false, status: 500 }]);
|
|
126
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
127
|
+
fetchImpl: mockFetch,
|
|
128
|
+
pollIntervalMs: 1,
|
|
129
|
+
});
|
|
130
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("decider job submission failed");
|
|
131
|
+
});
|
|
132
|
+
test("throws on job status check failure", async () => {
|
|
133
|
+
const mockFetch = createMockFetch([
|
|
134
|
+
{ ok: true }, // submit
|
|
135
|
+
{ ok: false, status: 404 }, // status check
|
|
136
|
+
]);
|
|
137
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
138
|
+
fetchImpl: mockFetch,
|
|
139
|
+
pollIntervalMs: 1,
|
|
140
|
+
});
|
|
141
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("decider job status check failed");
|
|
142
|
+
});
|
|
143
|
+
test("throws on job failure", async () => {
|
|
144
|
+
const mockFetch = createMockFetch([
|
|
145
|
+
{ ok: true },
|
|
146
|
+
createFailedResponse("proof generation error"),
|
|
147
|
+
]);
|
|
148
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
149
|
+
fetchImpl: mockFetch,
|
|
150
|
+
pollIntervalMs: 1,
|
|
151
|
+
});
|
|
152
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("decider job");
|
|
153
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("proof generation error");
|
|
154
|
+
});
|
|
155
|
+
test("throws on job completion without result", async () => {
|
|
156
|
+
const mockFetch = createMockFetch([
|
|
157
|
+
{ ok: true },
|
|
158
|
+
{
|
|
159
|
+
ok: true,
|
|
160
|
+
json: () => Promise.resolve({
|
|
161
|
+
job_id: "test-job",
|
|
162
|
+
circuit: "root",
|
|
163
|
+
status: "completed",
|
|
164
|
+
result: null,
|
|
165
|
+
}),
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
169
|
+
fetchImpl: mockFetch,
|
|
170
|
+
pollIntervalMs: 1,
|
|
171
|
+
});
|
|
172
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("completed without result");
|
|
173
|
+
});
|
|
174
|
+
test("throws on timeout", async () => {
|
|
175
|
+
const mockFetch = createMockFetch([
|
|
176
|
+
{ ok: true },
|
|
177
|
+
createQueuedResponse(),
|
|
178
|
+
createQueuedResponse(),
|
|
179
|
+
createQueuedResponse(),
|
|
180
|
+
]);
|
|
181
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
182
|
+
fetchImpl: mockFetch,
|
|
183
|
+
pollIntervalMs: 1,
|
|
184
|
+
timeoutMs: 10, // Very short timeout
|
|
185
|
+
});
|
|
186
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("timed out");
|
|
187
|
+
});
|
|
188
|
+
test("throws on fetch error", async () => {
|
|
189
|
+
const mockFetch = vi.fn().mockRejectedValue(new Error("Network error"));
|
|
190
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
191
|
+
fetchImpl: mockFetch,
|
|
192
|
+
pollIntervalMs: 1,
|
|
193
|
+
});
|
|
194
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("decider job submission failed");
|
|
195
|
+
await expect(client.produceDeciderProof("root", new Uint8Array([1, 2, 3]))).rejects.toThrow("Network error");
|
|
196
|
+
});
|
|
197
|
+
test("sends correct request body", async () => {
|
|
198
|
+
const mockFetch = createMockFetch([{ ok: true }, createCompletedResponse("AAAA")]);
|
|
199
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
200
|
+
fetchImpl: mockFetch,
|
|
201
|
+
pollIntervalMs: 1,
|
|
202
|
+
});
|
|
203
|
+
await client.produceDeciderProof("withdraw_local", new Uint8Array([1, 2, 3]));
|
|
204
|
+
expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
|
|
205
|
+
method: "POST",
|
|
206
|
+
headers: { "Content-Type": "application/json" },
|
|
207
|
+
body: expect.stringContaining('"circuit":"withdraw_local"'),
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
test("handles different circuit kinds", async () => {
|
|
211
|
+
const circuits = [
|
|
212
|
+
"root",
|
|
213
|
+
"withdraw_local",
|
|
214
|
+
"withdraw_global",
|
|
215
|
+
];
|
|
216
|
+
for (const circuit of circuits) {
|
|
217
|
+
const mockFetch = createMockFetch([{ ok: true }, createCompletedResponse("AAAA")]);
|
|
218
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
219
|
+
fetchImpl: mockFetch,
|
|
220
|
+
pollIntervalMs: 1,
|
|
221
|
+
});
|
|
222
|
+
await client.produceDeciderProof(circuit, new Uint8Array([1]));
|
|
223
|
+
expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
|
|
224
|
+
body: expect.stringContaining(`"circuit":"${circuit}"`),
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
test("throws for invalid hex string", async () => {
|
|
229
|
+
const mockFetch = createMockFetch([]);
|
|
230
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
231
|
+
fetchImpl: mockFetch,
|
|
232
|
+
pollIntervalMs: 1,
|
|
233
|
+
});
|
|
234
|
+
await expect(client.produceDeciderProof("root", "0x123")).rejects.toThrow("hex input must have even length");
|
|
235
|
+
});
|
|
236
|
+
test("throws for non-hex non-Uint8Array input", async () => {
|
|
237
|
+
const mockFetch = createMockFetch([]);
|
|
238
|
+
const client = new HttpDeciderClient("https://example.com", {
|
|
239
|
+
fetchImpl: mockFetch,
|
|
240
|
+
pollIntervalMs: 1,
|
|
241
|
+
});
|
|
242
|
+
await expect(client.produceDeciderProof("root", "not hex")).rejects.toThrow("ivc proof must be Uint8Array or 0x-prefixed hex string");
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
//# sourceMappingURL=prover.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prover.test.js","sourceRoot":"","sources":["../../../src/decider/__tests__/prover.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,SAAS,eAAe,CACtB,SAAiF;IAEjF,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE;QACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzE,SAAS,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YACpD,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,E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AA+B,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,SAAS,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;YAEtC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,qBAAqB,EAAE;gBAC1D,SAAS,EAAE,SAAS;gBACpB,cAAc,EAAE,CAAC;aAClB,CAAC,CAAC;YAEH,MAAM,MAAM,CACV,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC5C,CAAC,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,SAAS,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;YAEtC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,qBAAqB,EAAE;gBAC1D,SAAS,EAAE,SAAS;gBACpB,cAAc,EAAE,CAAC;aAClB,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACzE,wDAAwD,CACzD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/decider/prover.d.ts
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported circuit kinds for the decider service.
|
|
3
|
+
*/
|
|
1
4
|
export type CircuitKind = "root" | "withdraw_local" | "withdraw_global";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for {@link HttpDeciderClient}.
|
|
7
|
+
*/
|
|
2
8
|
export interface DeciderClientOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Poll interval (milliseconds) used while waiting for job completion.
|
|
11
|
+
* @defaultValue `DEFAULT_DECIDER_POLL_INTERVAL_MS`
|
|
12
|
+
*/
|
|
3
13
|
pollIntervalMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Max time (milliseconds) to wait for a job to complete before failing.
|
|
16
|
+
* @defaultValue `DEFAULT_DECIDER_TIMEOUT_MS`
|
|
17
|
+
*/
|
|
4
18
|
timeoutMs?: number;
|
|
19
|
+
/** Optional custom fetch implementation (useful for tests or environments without global fetch). */
|
|
5
20
|
fetchImpl?: typeof fetch;
|
|
6
21
|
}
|
|
7
22
|
export declare class HttpDeciderClient {
|
|
8
|
-
private readonly
|
|
23
|
+
private readonly http;
|
|
9
24
|
private readonly pollInterval;
|
|
10
25
|
private readonly timeout;
|
|
11
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Create a decider client.
|
|
28
|
+
* @param baseUrl - Decider service base URL.
|
|
29
|
+
* @param options - Polling and fetch options.
|
|
30
|
+
*/
|
|
12
31
|
constructor(baseUrl: string, options?: DeciderClientOptions);
|
|
13
|
-
|
|
14
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Submit an IVC proof to the decider service and poll until the decider proof is produced.
|
|
34
|
+
* @remarks
|
|
35
|
+
* This method:
|
|
36
|
+
* - Submits a job via `POST /jobs`
|
|
37
|
+
* - Polls `GET /jobs/:id` until status is `completed` or `failed`
|
|
38
|
+
*
|
|
39
|
+
* There is no retry/backoff strategy beyond fixed-interval polling.
|
|
40
|
+
* Network and non-OK HTTP responses are surfaced as thrown errors.
|
|
41
|
+
*
|
|
42
|
+
* @param circuit - Circuit kind to run on the service.
|
|
43
|
+
* @param ivcProof - IVC proof bytes. Accepts `Uint8Array` or a `0x`-prefixed hex string.
|
|
44
|
+
* @returns Decider proof bytes (`Uint8Array`).
|
|
45
|
+
* @throws If job submission fails, status polling fails, job fails, or timeout is reached.
|
|
46
|
+
*/
|
|
15
47
|
produceDeciderProof(circuit: CircuitKind, ivcProof: Uint8Array | string): Promise<Uint8Array>;
|
|
16
48
|
}
|
|
17
49
|
//# sourceMappingURL=prover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover.d.ts","sourceRoot":"","sources":["../../src/decider/prover.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"prover.d.ts","sourceRoot":"","sources":["../../src/decider/prover.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oGAAoG;IACpG,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAuDD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB;IAS/D;;;;;;;;;;;;;;OAcG;IACG,mBAAmB,CACvB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,UAAU,GAAG,MAAM,GAC5B,OAAO,CAAC,UAAU,CAAC;CAkDvB"}
|