@aztec/foundation 0.0.0-test.0
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 +1 -0
- package/dest/array/array.d.ts +71 -0
- package/dest/array/array.d.ts.map +1 -0
- package/dest/array/array.js +100 -0
- package/dest/array/index.d.ts +2 -0
- package/dest/array/index.d.ts.map +1 -0
- package/dest/array/index.js +1 -0
- package/dest/async-map/index.d.ts +13 -0
- package/dest/async-map/index.d.ts.map +1 -0
- package/dest/async-map/index.js +17 -0
- package/dest/async-pool/index.d.ts +3 -0
- package/dest/async-pool/index.d.ts.map +1 -0
- package/dest/async-pool/index.js +47 -0
- package/dest/bigint-buffer/index.d.ts +42 -0
- package/dest/bigint-buffer/index.d.ts.map +1 -0
- package/dest/bigint-buffer/index.js +76 -0
- package/dest/buffer/buffer32.d.ts +91 -0
- package/dest/buffer/buffer32.d.ts.map +1 -0
- package/dest/buffer/buffer32.js +115 -0
- package/dest/buffer/index.d.ts +2 -0
- package/dest/buffer/index.d.ts.map +1 -0
- package/dest/buffer/index.js +1 -0
- package/dest/collection/array.d.ts +101 -0
- package/dest/collection/array.d.ts.map +1 -0
- package/dest/collection/array.js +164 -0
- package/dest/collection/index.d.ts +3 -0
- package/dest/collection/index.d.ts.map +1 -0
- package/dest/collection/index.js +2 -0
- package/dest/collection/object.d.ts +14 -0
- package/dest/collection/object.d.ts.map +1 -0
- package/dest/collection/object.js +32 -0
- package/dest/committable/committable.d.ts +28 -0
- package/dest/committable/committable.d.ts.map +1 -0
- package/dest/committable/committable.js +36 -0
- package/dest/committable/index.d.ts +2 -0
- package/dest/committable/index.d.ts.map +1 -0
- package/dest/committable/index.js +1 -0
- package/dest/config/env_var.d.ts +2 -0
- package/dest/config/env_var.d.ts.map +1 -0
- package/dest/config/env_var.js +1 -0
- package/dest/config/index.d.ts +66 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +125 -0
- package/dest/crypto/aes128/index.d.ts +34 -0
- package/dest/crypto/aes128/index.d.ts.map +1 -0
- package/dest/crypto/aes128/index.js +49 -0
- package/dest/crypto/ecdsa/index.d.ts +39 -0
- package/dest/crypto/ecdsa/index.d.ts.map +1 -0
- package/dest/crypto/ecdsa/index.js +88 -0
- package/dest/crypto/ecdsa/signature.d.ts +71 -0
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -0
- package/dest/crypto/ecdsa/signature.js +92 -0
- package/dest/crypto/grumpkin/index.d.ts +47 -0
- package/dest/crypto/grumpkin/index.d.ts.map +1 -0
- package/dest/crypto/grumpkin/index.js +154 -0
- package/dest/crypto/index.d.ts +15 -0
- package/dest/crypto/index.d.ts.map +1 -0
- package/dest/crypto/index.js +14 -0
- package/dest/crypto/keccak/index.d.ts +28 -0
- package/dest/crypto/keccak/index.d.ts.map +1 -0
- package/dest/crypto/keccak/index.js +248 -0
- package/dest/crypto/keys/index.d.ts +5 -0
- package/dest/crypto/keys/index.d.ts.map +1 -0
- package/dest/crypto/keys/index.js +7 -0
- package/dest/crypto/pedersen/index.d.ts +2 -0
- package/dest/crypto/pedersen/index.d.ts.map +1 -0
- package/dest/crypto/pedersen/index.js +1 -0
- package/dest/crypto/pedersen/pedersen.elliptic.d.ts +13 -0
- package/dest/crypto/pedersen/pedersen.elliptic.d.ts.map +1 -0
- package/dest/crypto/pedersen/pedersen.elliptic.js +582 -0
- package/dest/crypto/pedersen/pedersen.noble.d.ts +11 -0
- package/dest/crypto/pedersen/pedersen.noble.d.ts.map +1 -0
- package/dest/crypto/pedersen/pedersen.noble.js +558 -0
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +21 -0
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -0
- package/dest/crypto/pedersen/pedersen.wasm.js +41 -0
- package/dest/crypto/poseidon/index.d.ts +26 -0
- package/dest/crypto/poseidon/index.d.ts.map +1 -0
- package/dest/crypto/poseidon/index.js +58 -0
- package/dest/crypto/random/index.d.ts +25 -0
- package/dest/crypto/random/index.d.ts.map +1 -0
- package/dest/crypto/random/index.js +70 -0
- package/dest/crypto/random/randomness_singleton.d.ts +25 -0
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -0
- package/dest/crypto/random/randomness_singleton.js +55 -0
- package/dest/crypto/schnorr/index.d.ts +30 -0
- package/dest/crypto/schnorr/index.d.ts.map +1 -0
- package/dest/crypto/schnorr/index.js +68 -0
- package/dest/crypto/schnorr/signature.d.ts +70 -0
- package/dest/crypto/schnorr/signature.d.ts.map +1 -0
- package/dest/crypto/schnorr/signature.js +93 -0
- package/dest/crypto/secp256k1/index.d.ts +32 -0
- package/dest/crypto/secp256k1/index.d.ts.map +1 -0
- package/dest/crypto/secp256k1/index.js +116 -0
- package/dest/crypto/secp256k1-signer/index.d.ts +3 -0
- package/dest/crypto/secp256k1-signer/index.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/index.js +2 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts +24 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.js +30 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts +40 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/utils.js +84 -0
- package/dest/crypto/serialize.d.ts +53 -0
- package/dest/crypto/serialize.d.ts.map +1 -0
- package/dest/crypto/serialize.js +68 -0
- package/dest/crypto/sha256/index.d.ts +20 -0
- package/dest/crypto/sha256/index.d.ts.map +1 -0
- package/dest/crypto/sha256/index.js +166 -0
- package/dest/crypto/sha512/index.d.ts +11 -0
- package/dest/crypto/sha512/index.d.ts.map +1 -0
- package/dest/crypto/sha512/index.js +12 -0
- package/dest/crypto/signature/index.d.ts +19 -0
- package/dest/crypto/signature/index.d.ts.map +1 -0
- package/dest/crypto/signature/index.js +3 -0
- package/dest/crypto/sync/index.d.ts +3 -0
- package/dest/crypto/sync/index.d.ts.map +1 -0
- package/dest/crypto/sync/index.js +4 -0
- package/dest/crypto/sync/pedersen/index.d.ts +21 -0
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -0
- package/dest/crypto/sync/pedersen/index.js +38 -0
- package/dest/crypto/sync/poseidon/index.d.ts +26 -0
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -0
- package/dest/crypto/sync/poseidon/index.js +53 -0
- package/dest/decorators/index.d.ts +2 -0
- package/dest/decorators/index.d.ts.map +1 -0
- package/dest/decorators/index.js +1 -0
- package/dest/decorators/memoize.d.ts +2 -0
- package/dest/decorators/memoize.d.ts.map +1 -0
- package/dest/decorators/memoize.js +11 -0
- package/dest/error/index.d.ts +21 -0
- package/dest/error/index.d.ts.map +1 -0
- package/dest/error/index.js +17 -0
- package/dest/eth-address/index.d.ts +134 -0
- package/dest/eth-address/index.d.ts.map +1 -0
- package/dest/eth-address/index.js +198 -0
- package/dest/eth-signature/eth_signature.d.ts +62 -0
- package/dest/eth-signature/eth_signature.d.ts.map +1 -0
- package/dest/eth-signature/eth_signature.js +91 -0
- package/dest/eth-signature/index.d.ts +2 -0
- package/dest/eth-signature/index.d.ts.map +1 -0
- package/dest/eth-signature/index.js +1 -0
- package/dest/fields/coordinate.d.ts +68 -0
- package/dest/fields/coordinate.d.ts.map +1 -0
- package/dest/fields/coordinate.js +96 -0
- package/dest/fields/fields.d.ts +176 -0
- package/dest/fields/fields.d.ts.map +1 -0
- package/dest/fields/fields.js +383 -0
- package/dest/fields/index.d.ts +4 -0
- package/dest/fields/index.d.ts.map +1 -0
- package/dest/fields/index.js +3 -0
- package/dest/fields/point.d.ts +175 -0
- package/dest/fields/point.d.ts.map +1 -0
- package/dest/fields/point.js +260 -0
- package/dest/fs/index.d.ts +2 -0
- package/dest/fs/index.d.ts.map +1 -0
- package/dest/fs/index.js +1 -0
- package/dest/fs/run_in_dir.d.ts +2 -0
- package/dest/fs/run_in_dir.d.ts.map +1 -0
- package/dest/fs/run_in_dir.js +31 -0
- package/dest/index.d.ts +31 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +31 -0
- package/dest/iterable/all.d.ts +9 -0
- package/dest/iterable/all.d.ts.map +1 -0
- package/dest/iterable/all.js +18 -0
- package/dest/iterable/filter.d.ts +10 -0
- package/dest/iterable/filter.d.ts.map +1 -0
- package/dest/iterable/filter.js +48 -0
- package/dest/iterable/index.d.ts +8 -0
- package/dest/iterable/index.d.ts.map +1 -0
- package/dest/iterable/index.js +7 -0
- package/dest/iterable/isAsyncIt.d.ts +7 -0
- package/dest/iterable/isAsyncIt.d.ts.map +1 -0
- package/dest/iterable/isAsyncIt.js +7 -0
- package/dest/iterable/map.d.ts +12 -0
- package/dest/iterable/map.d.ts.map +1 -0
- package/dest/iterable/map.js +36 -0
- package/dest/iterable/peek.d.ts +19 -0
- package/dest/iterable/peek.d.ts.map +1 -0
- package/dest/iterable/peek.js +33 -0
- package/dest/iterable/sort.d.ts +14 -0
- package/dest/iterable/sort.d.ts.map +1 -0
- package/dest/iterable/sort.js +15 -0
- package/dest/iterable/take.d.ts +10 -0
- package/dest/iterable/take.d.ts.map +1 -0
- package/dest/iterable/take.js +32 -0
- package/dest/iterable/toArray.d.ts +2 -0
- package/dest/iterable/toArray.d.ts.map +1 -0
- package/dest/iterable/toArray.js +7 -0
- package/dest/jest/setup.js +7 -0
- package/dest/json-rpc/client/fetch.d.ts +32 -0
- package/dest/json-rpc/client/fetch.d.ts.map +1 -0
- package/dest/json-rpc/client/fetch.js +77 -0
- package/dest/json-rpc/client/index.d.ts +3 -0
- package/dest/json-rpc/client/index.d.ts.map +1 -0
- package/dest/json-rpc/client/index.js +2 -0
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +26 -0
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -0
- package/dest/json-rpc/client/safe_json_rpc_client.js +57 -0
- package/dest/json-rpc/client/undici.d.ts +5 -0
- package/dest/json-rpc/client/undici.d.ts.map +1 -0
- package/dest/json-rpc/client/undici.js +63 -0
- package/dest/json-rpc/convert.d.ts +27 -0
- package/dest/json-rpc/convert.d.ts.map +1 -0
- package/dest/json-rpc/convert.js +48 -0
- package/dest/json-rpc/fixtures/class_a.d.ts +11 -0
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/class_a.js +20 -0
- package/dest/json-rpc/fixtures/class_b.d.ts +11 -0
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/class_b.js +20 -0
- package/dest/json-rpc/fixtures/test_state.d.ts +89 -0
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/test_state.js +131 -0
- package/dest/json-rpc/index.d.ts +2 -0
- package/dest/json-rpc/index.d.ts.map +1 -0
- package/dest/json-rpc/index.js +1 -0
- package/dest/json-rpc/js_utils.d.ts +13 -0
- package/dest/json-rpc/js_utils.d.ts.map +1 -0
- package/dest/json-rpc/js_utils.js +16 -0
- package/dest/json-rpc/server/index.d.ts +2 -0
- package/dest/json-rpc/server/index.d.ts.map +1 -0
- package/dest/json-rpc/server/index.js +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +140 -0
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.js +346 -0
- package/dest/json-rpc/server/telemetry.d.ts +2 -0
- package/dest/json-rpc/server/telemetry.d.ts.map +1 -0
- package/dest/json-rpc/server/telemetry.js +0 -0
- package/dest/json-rpc/test/index.d.ts +2 -0
- package/dest/json-rpc/test/index.d.ts.map +1 -0
- package/dest/json-rpc/test/index.js +1 -0
- package/dest/json-rpc/test/integration.d.ts +15 -0
- package/dest/json-rpc/test/integration.d.ts.map +1 -0
- package/dest/json-rpc/test/integration.js +21 -0
- package/dest/log/console.d.ts +11 -0
- package/dest/log/console.d.ts.map +1 -0
- package/dest/log/console.js +36 -0
- package/dest/log/debug.d.ts +56 -0
- package/dest/log/debug.d.ts.map +1 -0
- package/dest/log/debug.js +75 -0
- package/dest/log/gcloud-logger-config.d.ts +14 -0
- package/dest/log/gcloud-logger-config.d.ts.map +1 -0
- package/dest/log/gcloud-logger-config.js +66 -0
- package/dest/log/index.d.ts +7 -0
- package/dest/log/index.d.ts.map +1 -0
- package/dest/log/index.js +6 -0
- package/dest/log/libp2p_logger.d.ts +7 -0
- package/dest/log/libp2p_logger.d.ts.map +1 -0
- package/dest/log/libp2p_logger.js +55 -0
- package/dest/log/log-filters.d.ts +7 -0
- package/dest/log/log-filters.d.ts.map +1 -0
- package/dest/log/log-filters.js +59 -0
- package/dest/log/log-levels.d.ts +3 -0
- package/dest/log/log-levels.d.ts.map +1 -0
- package/dest/log/log-levels.js +10 -0
- package/dest/log/log_fn.d.ts +7 -0
- package/dest/log/log_fn.d.ts.map +1 -0
- package/dest/log/log_fn.js +1 -0
- package/dest/log/log_history.d.ts +31 -0
- package/dest/log/log_history.d.ts.map +1 -0
- package/dest/log/log_history.js +38 -0
- package/dest/log/pino-logger.d.ts +57 -0
- package/dest/log/pino-logger.d.ts.map +1 -0
- package/dest/log/pino-logger.js +207 -0
- package/dest/message/index.d.ts +32 -0
- package/dest/message/index.d.ts.map +1 -0
- package/dest/message/index.js +27 -0
- package/dest/mutex/index.d.ts +53 -0
- package/dest/mutex/index.d.ts.map +1 -0
- package/dest/mutex/index.js +78 -0
- package/dest/mutex/mutex_database.d.ts +10 -0
- package/dest/mutex/mutex_database.d.ts.map +1 -0
- package/dest/mutex/mutex_database.js +4 -0
- package/dest/noir/index.d.ts +2 -0
- package/dest/noir/index.d.ts.map +1 -0
- package/dest/noir/index.js +1 -0
- package/dest/noir/noir_package_config.d.ts +129 -0
- package/dest/noir/noir_package_config.d.ts.map +1 -0
- package/dest/noir/noir_package_config.js +36 -0
- package/dest/promise/index.d.ts +3 -0
- package/dest/promise/index.d.ts.map +1 -0
- package/dest/promise/index.js +2 -0
- package/dest/promise/running-promise.d.ts +47 -0
- package/dest/promise/running-promise.d.ts.map +1 -0
- package/dest/promise/running-promise.js +110 -0
- package/dest/promise/utils.d.ts +12 -0
- package/dest/promise/utils.d.ts.map +1 -0
- package/dest/promise/utils.js +20 -0
- package/dest/queue/base_memory_queue.d.ts +65 -0
- package/dest/queue/base_memory_queue.d.ts.map +1 -0
- package/dest/queue/base_memory_queue.js +116 -0
- package/dest/queue/batch_queue.d.ts +47 -0
- package/dest/queue/batch_queue.d.ts.map +1 -0
- package/dest/queue/batch_queue.js +105 -0
- package/dest/queue/bounded_serial_queue.d.ts +56 -0
- package/dest/queue/bounded_serial_queue.d.ts.map +1 -0
- package/dest/queue/bounded_serial_queue.js +84 -0
- package/dest/queue/fifo_memory_queue.d.ts +21 -0
- package/dest/queue/fifo_memory_queue.d.ts.map +1 -0
- package/dest/queue/fifo_memory_queue.js +29 -0
- package/dest/queue/index.d.ts +7 -0
- package/dest/queue/index.d.ts.map +1 -0
- package/dest/queue/index.js +6 -0
- package/dest/queue/priority_memory_queue.d.ts +13 -0
- package/dest/queue/priority_memory_queue.d.ts.map +1 -0
- package/dest/queue/priority_memory_queue.js +16 -0
- package/dest/queue/priority_queue.d.ts +14 -0
- package/dest/queue/priority_queue.d.ts.map +1 -0
- package/dest/queue/priority_queue.js +29 -0
- package/dest/queue/semaphore.d.ts +23 -0
- package/dest/queue/semaphore.d.ts.map +1 -0
- package/dest/queue/semaphore.js +26 -0
- package/dest/queue/serial_queue.d.ts +49 -0
- package/dest/queue/serial_queue.d.ts.map +1 -0
- package/dest/queue/serial_queue.js +72 -0
- package/dest/retry/index.d.ts +44 -0
- package/dest/retry/index.d.ts.map +1 -0
- package/dest/retry/index.js +93 -0
- package/dest/running-promise/index.d.ts +2 -0
- package/dest/running-promise/index.d.ts.map +1 -0
- package/dest/running-promise/index.js +1 -0
- package/dest/schemas/api.d.ts +21 -0
- package/dest/schemas/api.d.ts.map +1 -0
- package/dest/schemas/api.js +3 -0
- package/dest/schemas/index.d.ts +6 -0
- package/dest/schemas/index.d.ts.map +1 -0
- package/dest/schemas/index.js +5 -0
- package/dest/schemas/parse.d.ts +9 -0
- package/dest/schemas/parse.d.ts.map +1 -0
- package/dest/schemas/parse.js +22 -0
- package/dest/schemas/schemas.d.ts +45 -0
- package/dest/schemas/schemas.d.ts.map +1 -0
- package/dest/schemas/schemas.js +38 -0
- package/dest/schemas/types.d.ts +3 -0
- package/dest/schemas/types.d.ts.map +1 -0
- package/dest/schemas/types.js +1 -0
- package/dest/schemas/utils.d.ts +53 -0
- package/dest/schemas/utils.d.ts.map +1 -0
- package/dest/schemas/utils.js +60 -0
- package/dest/serialize/buffer_reader.d.ts +239 -0
- package/dest/serialize/buffer_reader.d.ts.map +1 -0
- package/dest/serialize/buffer_reader.js +290 -0
- package/dest/serialize/field_reader.d.ts +112 -0
- package/dest/serialize/field_reader.d.ts.map +1 -0
- package/dest/serialize/field_reader.js +147 -0
- package/dest/serialize/free_funcs.d.ts +105 -0
- package/dest/serialize/free_funcs.d.ts.map +1 -0
- package/dest/serialize/free_funcs.js +189 -0
- package/dest/serialize/index.d.ts +7 -0
- package/dest/serialize/index.d.ts.map +1 -0
- package/dest/serialize/index.js +6 -0
- package/dest/serialize/serialize.d.ts +182 -0
- package/dest/serialize/serialize.d.ts.map +1 -0
- package/dest/serialize/serialize.js +248 -0
- package/dest/serialize/type_registry.d.ts +23 -0
- package/dest/serialize/type_registry.d.ts.map +1 -0
- package/dest/serialize/type_registry.js +61 -0
- package/dest/serialize/types.d.ts +33 -0
- package/dest/serialize/types.d.ts.map +1 -0
- package/dest/serialize/types.js +21 -0
- package/dest/sleep/index.d.ts +51 -0
- package/dest/sleep/index.d.ts.map +1 -0
- package/dest/sleep/index.js +67 -0
- package/dest/string/index.d.ts +11 -0
- package/dest/string/index.d.ts.map +1 -0
- package/dest/string/index.js +24 -0
- package/dest/testing/files/index.d.ts +20 -0
- package/dest/testing/files/index.d.ts.map +1 -0
- package/dest/testing/files/index.js +58 -0
- package/dest/testing/index.d.ts +4 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +3 -0
- package/dest/testing/port_allocator.d.ts +10 -0
- package/dest/testing/port_allocator.d.ts.map +1 -0
- package/dest/testing/port_allocator.js +29 -0
- package/dest/testing/snapshot_serializer.d.ts +5 -0
- package/dest/testing/snapshot_serializer.d.ts.map +1 -0
- package/dest/testing/snapshot_serializer.js +32 -0
- package/dest/testing/test_data.d.ts +7 -0
- package/dest/testing/test_data.d.ts.map +1 -0
- package/dest/testing/test_data.js +29 -0
- package/dest/timer/date.d.ts +13 -0
- package/dest/timer/date.d.ts.map +1 -0
- package/dest/timer/date.js +24 -0
- package/dest/timer/elapsed.d.ts +13 -0
- package/dest/timer/elapsed.d.ts.map +1 -0
- package/dest/timer/elapsed.js +25 -0
- package/dest/timer/index.d.ts +5 -0
- package/dest/timer/index.d.ts.map +1 -0
- package/dest/timer/index.js +4 -0
- package/dest/timer/timeout.d.ts +41 -0
- package/dest/timer/timeout.d.ts.map +1 -0
- package/dest/timer/timeout.js +66 -0
- package/dest/timer/timer.d.ts +37 -0
- package/dest/timer/timer.d.ts.map +1 -0
- package/dest/timer/timer.js +40 -0
- package/dest/transport/browser/index.d.ts +5 -0
- package/dest/transport/browser/index.d.ts.map +1 -0
- package/dest/transport/browser/index.js +4 -0
- package/dest/transport/browser/message_port_socket.d.ts +37 -0
- package/dest/transport/browser/message_port_socket.d.ts.map +1 -0
- package/dest/transport/browser/message_port_socket.js +42 -0
- package/dest/transport/browser/shared_worker_connector.d.ts +19 -0
- package/dest/transport/browser/shared_worker_connector.d.ts.map +1 -0
- package/dest/transport/browser/shared_worker_connector.js +19 -0
- package/dest/transport/browser/shared_worker_listener.d.ts +38 -0
- package/dest/transport/browser/shared_worker_listener.d.ts.map +1 -0
- package/dest/transport/browser/shared_worker_listener.js +33 -0
- package/dest/transport/browser/worker_connector.d.ts +26 -0
- package/dest/transport/browser/worker_connector.d.ts.map +1 -0
- package/dest/transport/browser/worker_connector.js +30 -0
- package/dest/transport/browser/worker_listener.d.ts +39 -0
- package/dest/transport/browser/worker_listener.d.ts.map +1 -0
- package/dest/transport/browser/worker_listener.js +35 -0
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +25 -0
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +1 -0
- package/dest/transport/dispatch/create_dispatch_fn.js +17 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +102 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -0
- package/dest/transport/dispatch/create_dispatch_proxy.js +59 -0
- package/dest/transport/dispatch/messages.d.ts +52 -0
- package/dest/transport/dispatch/messages.d.ts.map +1 -0
- package/dest/transport/dispatch/messages.js +13 -0
- package/dest/transport/index.d.ts +12 -0
- package/dest/transport/index.d.ts.map +1 -0
- package/dest/transport/index.js +11 -0
- package/dest/transport/interface/connector.d.ts +8 -0
- package/dest/transport/interface/connector.d.ts.map +1 -0
- package/dest/transport/interface/connector.js +3 -0
- package/dest/transport/interface/listener.d.ts +13 -0
- package/dest/transport/interface/listener.d.ts.map +1 -0
- package/dest/transport/interface/listener.js +4 -0
- package/dest/transport/interface/socket.d.ts +13 -0
- package/dest/transport/interface/socket.d.ts.map +1 -0
- package/dest/transport/interface/socket.js +7 -0
- package/dest/transport/interface/transferable.d.ts +68 -0
- package/dest/transport/interface/transferable.d.ts.map +1 -0
- package/dest/transport/interface/transferable.js +63 -0
- package/dest/transport/node/index.d.ts +3 -0
- package/dest/transport/node/index.d.ts.map +1 -0
- package/dest/transport/node/index.js +2 -0
- package/dest/transport/node/node_connector.d.ts +28 -0
- package/dest/transport/node/node_connector.d.ts.map +1 -0
- package/dest/transport/node/node_connector.js +26 -0
- package/dest/transport/node/node_connector_socket.d.ts +42 -0
- package/dest/transport/node/node_connector_socket.d.ts.map +1 -0
- package/dest/transport/node/node_connector_socket.js +44 -0
- package/dest/transport/node/node_listener.d.ts +26 -0
- package/dest/transport/node/node_listener.d.ts.map +1 -0
- package/dest/transport/node/node_listener.js +26 -0
- package/dest/transport/node/node_listener_socket.d.ts +37 -0
- package/dest/transport/node/node_listener_socket.d.ts.map +1 -0
- package/dest/transport/node/node_listener_socket.js +40 -0
- package/dest/transport/transport_client.d.ts +61 -0
- package/dest/transport/transport_client.d.ts.map +1 -0
- package/dest/transport/transport_client.js +96 -0
- package/dest/transport/transport_server.d.ts +56 -0
- package/dest/transport/transport_server.d.ts.map +1 -0
- package/dest/transport/transport_server.js +114 -0
- package/dest/trees/hasher.d.ts +39 -0
- package/dest/trees/hasher.d.ts.map +1 -0
- package/dest/trees/hasher.js +5 -0
- package/dest/trees/index.d.ts +11 -0
- package/dest/trees/index.d.ts.map +1 -0
- package/dest/trees/index.js +10 -0
- package/dest/trees/indexed_merkle_tree.d.ts +13 -0
- package/dest/trees/indexed_merkle_tree.d.ts.map +1 -0
- package/dest/trees/indexed_merkle_tree.js +27 -0
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +23 -0
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/indexed_merkle_tree_calculator.js +83 -0
- package/dest/trees/indexed_tree_leaf.d.ts +57 -0
- package/dest/trees/indexed_tree_leaf.d.ts.map +1 -0
- package/dest/trees/indexed_tree_leaf.js +5 -0
- package/dest/trees/membership_witness.d.ts +62 -0
- package/dest/trees/membership_witness.d.ts.map +1 -0
- package/dest/trees/membership_witness.js +70 -0
- package/dest/trees/merkle_tree.d.ts +18 -0
- package/dest/trees/merkle_tree.d.ts.map +1 -0
- package/dest/trees/merkle_tree.js +58 -0
- package/dest/trees/merkle_tree_calculator.d.ts +16 -0
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/merkle_tree_calculator.js +61 -0
- package/dest/trees/sibling_path.d.ts +132 -0
- package/dest/trees/sibling_path.d.ts.map +1 -0
- package/dest/trees/sibling_path.js +144 -0
- package/dest/trees/unbalanced_merkle_tree.d.ts +17 -0
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -0
- package/dest/trees/unbalanced_merkle_tree.js +100 -0
- package/dest/trees/unbalanced_tree_store.d.ts +19 -0
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -0
- package/dest/trees/unbalanced_tree_store.js +94 -0
- package/dest/types/index.d.ts +19 -0
- package/dest/types/index.d.ts.map +1 -0
- package/dest/types/index.js +3 -0
- package/dest/url/index.d.ts +9 -0
- package/dest/url/index.d.ts.map +1 -0
- package/dest/url/index.js +62 -0
- package/dest/validation/index.d.ts +9 -0
- package/dest/validation/index.d.ts.map +1 -0
- package/dest/validation/index.js +15 -0
- package/dest/wasm/empty_wasi_sdk.d.ts +130 -0
- package/dest/wasm/empty_wasi_sdk.d.ts.map +1 -0
- package/dest/wasm/empty_wasi_sdk.js +148 -0
- package/dest/wasm/index.d.ts +2 -0
- package/dest/wasm/index.d.ts.map +1 -0
- package/dest/wasm/index.js +1 -0
- package/dest/wasm/wasm_module.d.ts +136 -0
- package/dest/wasm/wasm_module.d.ts.map +1 -0
- package/dest/wasm/wasm_module.js +196 -0
- package/dest/worker/browser/index.d.ts +3 -0
- package/dest/worker/browser/index.d.ts.map +1 -0
- package/dest/worker/browser/index.js +2 -0
- package/dest/worker/browser/start_web_module.d.ts +7 -0
- package/dest/worker/browser/start_web_module.d.ts.map +1 -0
- package/dest/worker/browser/start_web_module.js +27 -0
- package/dest/worker/browser/web_data_store.d.ts +24 -0
- package/dest/worker/browser/web_data_store.d.ts.map +1 -0
- package/dest/worker/browser/web_data_store.js +29 -0
- package/dest/worker/browser/web_worker.d.ts +10 -0
- package/dest/worker/browser/web_worker.d.ts.map +1 -0
- package/dest/worker/browser/web_worker.js +25 -0
- package/dest/worker/data_store.d.ts +21 -0
- package/dest/worker/data_store.d.ts.map +1 -0
- package/dest/worker/data_store.js +3 -0
- package/dest/worker/index.d.ts +3 -0
- package/dest/worker/index.d.ts.map +1 -0
- package/dest/worker/index.js +1 -0
- package/dest/worker/node/index.d.ts +3 -0
- package/dest/worker/node/index.d.ts.map +1 -0
- package/dest/worker/node/index.js +2 -0
- package/dest/worker/node/node_data_store.d.ts +13 -0
- package/dest/worker/node/node_data_store.d.ts.map +1 -0
- package/dest/worker/node/node_data_store.js +20 -0
- package/dest/worker/node/node_worker.d.ts +6 -0
- package/dest/worker/node/node_worker.d.ts.map +1 -0
- package/dest/worker/node/node_worker.js +22 -0
- package/dest/worker/node/start_node_module.d.ts +7 -0
- package/dest/worker/node/start_node_module.d.ts.map +1 -0
- package/dest/worker/node/start_node_module.js +31 -0
- package/dest/worker/wasm_worker.d.ts +9 -0
- package/dest/worker/wasm_worker.d.ts.map +1 -0
- package/dest/worker/wasm_worker.js +3 -0
- package/dest/worker/worker_pool.d.ts +40 -0
- package/dest/worker/worker_pool.d.ts.map +1 -0
- package/dest/worker/worker_pool.js +51 -0
- package/package.json +176 -0
- package/src/array/array.ts +150 -0
- package/src/array/index.ts +1 -0
- package/src/async-map/index.ts +18 -0
- package/src/async-pool/index.ts +50 -0
- package/src/bigint-buffer/index.ts +87 -0
- package/src/buffer/buffer32.ts +144 -0
- package/src/buffer/index.ts +1 -0
- package/src/collection/array.ts +203 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/object.ts +52 -0
- package/src/committable/committable.ts +46 -0
- package/src/committable/index.ts +1 -0
- package/src/config/env_var.ts +207 -0
- package/src/config/index.ts +167 -0
- package/src/crypto/aes128/index.ts +59 -0
- package/src/crypto/ecdsa/index.ts +70 -0
- package/src/crypto/ecdsa/signature.ts +100 -0
- package/src/crypto/grumpkin/index.ts +97 -0
- package/src/crypto/index.ts +14 -0
- package/src/crypto/keccak/index.ts +283 -0
- package/src/crypto/keys/index.ts +10 -0
- package/src/crypto/pedersen/index.ts +1 -0
- package/src/crypto/pedersen/pedersen.elliptic.ts +584 -0
- package/src/crypto/pedersen/pedersen.noble.ts +573 -0
- package/src/crypto/pedersen/pedersen.wasm.ts +48 -0
- package/src/crypto/poseidon/index.ts +77 -0
- package/src/crypto/random/index.ts +85 -0
- package/src/crypto/random/randomness_singleton.ts +62 -0
- package/src/crypto/schnorr/index.ts +55 -0
- package/src/crypto/schnorr/signature.ts +116 -0
- package/src/crypto/secp256k1/index.ts +57 -0
- package/src/crypto/secp256k1-signer/index.ts +2 -0
- package/src/crypto/secp256k1-signer/secp256k1_signer.ts +38 -0
- package/src/crypto/secp256k1-signer/utils.ts +99 -0
- package/src/crypto/serialize.ts +85 -0
- package/src/crypto/sha256/index.ts +147 -0
- package/src/crypto/sha512/index.ts +16 -0
- package/src/crypto/signature/index.ts +17 -0
- package/src/crypto/sync/index.ts +6 -0
- package/src/crypto/sync/pedersen/index.ts +45 -0
- package/src/crypto/sync/poseidon/index.ts +76 -0
- package/src/decorators/index.ts +1 -0
- package/src/decorators/memoize.ts +11 -0
- package/src/error/index.ts +22 -0
- package/src/eth-address/index.ts +241 -0
- package/src/eth-signature/eth_signature.ts +128 -0
- package/src/eth-signature/index.ts +1 -0
- package/src/fields/coordinate.ts +104 -0
- package/src/fields/fields.ts +505 -0
- package/src/fields/index.ts +3 -0
- package/src/fields/point.ts +300 -0
- package/src/fs/index.ts +1 -0
- package/src/fs/run_in_dir.ts +33 -0
- package/src/index.ts +31 -0
- package/src/iterable/all.ts +32 -0
- package/src/iterable/filter.ts +77 -0
- package/src/iterable/index.ts +7 -0
- package/src/iterable/isAsyncIt.ts +8 -0
- package/src/iterable/map.ts +66 -0
- package/src/iterable/peek.ts +58 -0
- package/src/iterable/sort.ts +39 -0
- package/src/iterable/take.ts +54 -0
- package/src/iterable/toArray.ts +9 -0
- package/src/jest/setup.mjs +9 -0
- package/src/json-rpc/README.md +55 -0
- package/src/json-rpc/client/fetch.ts +103 -0
- package/src/json-rpc/client/index.ts +2 -0
- package/src/json-rpc/client/safe_json_rpc_client.ts +67 -0
- package/src/json-rpc/client/undici.ts +75 -0
- package/src/json-rpc/convert.ts +61 -0
- package/src/json-rpc/fixtures/class_a.ts +15 -0
- package/src/json-rpc/fixtures/class_b.ts +15 -0
- package/src/json-rpc/fixtures/test_state.ts +143 -0
- package/src/json-rpc/index.ts +1 -0
- package/src/json-rpc/js_utils.ts +21 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +376 -0
- package/src/json-rpc/server/telemetry.ts +0 -0
- package/src/json-rpc/test/index.ts +1 -0
- package/src/json-rpc/test/integration.ts +35 -0
- package/src/log/console.ts +39 -0
- package/src/log/debug.ts +104 -0
- package/src/log/gcloud-logger-config.ts +71 -0
- package/src/log/index.ts +6 -0
- package/src/log/libp2p_logger.ts +67 -0
- package/src/log/log-filters.ts +63 -0
- package/src/log/log-levels.ts +3 -0
- package/src/log/log_fn.ts +5 -0
- package/src/log/log_history.ts +44 -0
- package/src/log/pino-logger.ts +243 -0
- package/src/message/index.ts +43 -0
- package/src/mutex/index.ts +84 -0
- package/src/mutex/mutex_database.ts +12 -0
- package/src/noir/index.ts +1 -0
- package/src/noir/noir_package_config.ts +54 -0
- package/src/promise/index.ts +2 -0
- package/src/promise/running-promise.ts +125 -0
- package/src/promise/utils.ts +29 -0
- package/src/queue/base_memory_queue.ts +138 -0
- package/src/queue/batch_queue.ts +120 -0
- package/src/queue/bounded_serial_queue.ts +100 -0
- package/src/queue/fifo_memory_queue.ts +39 -0
- package/src/queue/index.ts +6 -0
- package/src/queue/priority_memory_queue.ts +20 -0
- package/src/queue/priority_queue.ts +34 -0
- package/src/queue/semaphore.ts +33 -0
- package/src/queue/serial_queue.ts +86 -0
- package/src/retry/index.ts +100 -0
- package/src/running-promise/index.ts +1 -0
- package/src/schemas/api.ts +47 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/parse.ts +29 -0
- package/src/schemas/schemas.ts +64 -0
- package/src/schemas/types.ts +3 -0
- package/src/schemas/utils.ts +112 -0
- package/src/serialize/buffer_reader.ts +383 -0
- package/src/serialize/field_reader.ts +184 -0
- package/src/serialize/free_funcs.ts +204 -0
- package/src/serialize/index.ts +6 -0
- package/src/serialize/serialize.ts +336 -0
- package/src/serialize/type_registry.ts +75 -0
- package/src/serialize/types.ts +40 -0
- package/src/sleep/index.ts +75 -0
- package/src/string/index.ts +31 -0
- package/src/testing/files/index.ts +69 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/port_allocator.ts +31 -0
- package/src/testing/snapshot_serializer.ts +33 -0
- package/src/testing/test_data.ts +36 -0
- package/src/timer/date.ts +24 -0
- package/src/timer/elapsed.ts +23 -0
- package/src/timer/index.ts +4 -0
- package/src/timer/timeout.ts +70 -0
- package/src/timer/timer.ts +48 -0
- package/src/transport/browser/index.ts +4 -0
- package/src/transport/browser/message_port_socket.ts +48 -0
- package/src/transport/browser/shared_worker_connector.ts +21 -0
- package/src/transport/browser/shared_worker_listener.ts +53 -0
- package/src/transport/browser/worker_connector.ts +30 -0
- package/src/transport/browser/worker_listener.ts +54 -0
- package/src/transport/dispatch/create_dispatch_fn.ts +35 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +141 -0
- package/src/transport/dispatch/messages.ts +58 -0
- package/src/transport/index.ts +11 -0
- package/src/transport/interface/connector.ts +9 -0
- package/src/transport/interface/listener.ts +16 -0
- package/src/transport/interface/socket.ts +15 -0
- package/src/transport/interface/transferable.ts +125 -0
- package/src/transport/node/index.ts +2 -0
- package/src/transport/node/node_connector.ts +30 -0
- package/src/transport/node/node_connector_socket.ts +52 -0
- package/src/transport/node/node_listener.ts +34 -0
- package/src/transport/node/node_listener_socket.ts +48 -0
- package/src/transport/transport_client.ts +131 -0
- package/src/transport/transport_server.ts +108 -0
- package/src/trees/hasher.ts +39 -0
- package/src/trees/index.ts +10 -0
- package/src/trees/indexed_merkle_tree.ts +36 -0
- package/src/trees/indexed_merkle_tree_calculator.ts +94 -0
- package/src/trees/indexed_tree_leaf.ts +56 -0
- package/src/trees/membership_witness.ts +99 -0
- package/src/trees/merkle_tree.ts +72 -0
- package/src/trees/merkle_tree_calculator.ts +67 -0
- package/src/trees/sibling_path.ts +183 -0
- package/src/trees/unbalanced_merkle_tree.ts +103 -0
- package/src/trees/unbalanced_tree_store.ts +102 -0
- package/src/types/index.ts +25 -0
- package/src/url/index.ts +73 -0
- package/src/validation/index.ts +18 -0
- package/src/wasm/README.md +6 -0
- package/src/wasm/empty_wasi_sdk.ts +166 -0
- package/src/wasm/fixtures/gcd.wasm +0 -0
- package/src/wasm/fixtures/gcd.wat +27 -0
- package/src/wasm/index.ts +1 -0
- package/src/wasm/wasm_module.ts +260 -0
- package/src/worker/browser/index.ts +2 -0
- package/src/worker/browser/start_web_module.ts +24 -0
- package/src/worker/browser/web_data_store.ts +38 -0
- package/src/worker/browser/web_worker.ts +25 -0
- package/src/worker/data_store.ts +19 -0
- package/src/worker/index.ts +2 -0
- package/src/worker/node/index.ts +2 -0
- package/src/worker/node/node_data_store.ts +27 -0
- package/src/worker/node/node_worker.ts +23 -0
- package/src/worker/node/start_node_module.ts +30 -0
- package/src/worker/wasm_worker.ts +7 -0
- package/src/worker/worker_pool.ts +73 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { Tuple } from '../serialize/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pads an array to the target length by appending an element to its end. Throws if target length exceeds the input array length. Does not modify the input array.
|
|
6
|
+
* @param arr - Array with elements to pad.
|
|
7
|
+
* @param elem - Element to use for padding.
|
|
8
|
+
* @param length - Target length.
|
|
9
|
+
* @param errorMsg - Error message to throw if target length exceeds the input array length.
|
|
10
|
+
* @returns A new padded array.
|
|
11
|
+
*/
|
|
12
|
+
export declare function padArrayEnd<T, N extends number>(arr: T[], elem: T, length: N, errorMsg?: string): Tuple<T, N>;
|
|
13
|
+
/** Removes the right-padding for an array. Does not modify original array. */
|
|
14
|
+
export declare function removeArrayPaddingEnd<T>(arr: T[], isEmpty: (item: T) => boolean): T[];
|
|
15
|
+
/**
|
|
16
|
+
* Pads an array to the target length by prepending elements at the beginning. Throws if target length exceeds the input array length. Does not modify the input array.
|
|
17
|
+
* @param arr - Array with elements to pad.
|
|
18
|
+
* @param elem - Element to use for padding.
|
|
19
|
+
* @param length - Target length.
|
|
20
|
+
* @returns A new padded array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function padArrayStart<T, N extends number>(arr: T[], elem: T, length: N): Tuple<T, N>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns if an array is composed of empty items.
|
|
25
|
+
* @param arr - Array to check.
|
|
26
|
+
* @returns True if every item in the array isEmpty.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isArrayEmpty<T>(arr: T[], isEmpty: (item: T) => boolean): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the number of non-empty items in an array.
|
|
31
|
+
* @param arr - Array to check.
|
|
32
|
+
* @returns Number of non-empty items in an array.
|
|
33
|
+
*/
|
|
34
|
+
export declare function arrayNonEmptyLength<T>(arr: T[], isEmpty: (item: T) => boolean): number;
|
|
35
|
+
/**
|
|
36
|
+
* Executes the given function n times and returns the results in an array.
|
|
37
|
+
* @param n - How many times to repeat.
|
|
38
|
+
* @param fn - Mapper from index to value.
|
|
39
|
+
* @returns The array with the result from all executions.
|
|
40
|
+
*/
|
|
41
|
+
export declare function times<T>(n: number, fn: (i: number) => T): T[];
|
|
42
|
+
/**
|
|
43
|
+
* Executes the given async function n times and returns the results in an array. Awaits each execution before starting the next one.
|
|
44
|
+
* @param n - How many times to repeat.
|
|
45
|
+
* @param fn - Mapper from index to value.
|
|
46
|
+
* @returns The array with the result from all executions.
|
|
47
|
+
*/
|
|
48
|
+
export declare function timesAsync<T>(n: number, fn: (i: number) => Promise<T>): Promise<T[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Executes the given async function n times in parallel and returns the results in an array.
|
|
51
|
+
* @param n - How many times to repeat.
|
|
52
|
+
* @param fn - Mapper from index to value.
|
|
53
|
+
* @returns The array with the result from all executions.
|
|
54
|
+
*/
|
|
55
|
+
export declare function timesParallel<T>(n: number, fn: (i: number) => Promise<T>): Promise<T[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the serialized size of all non-empty items in an array.
|
|
58
|
+
* @param arr - Array
|
|
59
|
+
* @returns The serialized size in bytes.
|
|
60
|
+
*/
|
|
61
|
+
export declare function arraySerializedSizeOfNonEmpty(arr: (({
|
|
62
|
+
isZero: () => boolean;
|
|
63
|
+
} | {
|
|
64
|
+
isEmpty: () => boolean;
|
|
65
|
+
}) & {
|
|
66
|
+
toBuffer: () => Buffer;
|
|
67
|
+
})[]): number;
|
|
68
|
+
/**
|
|
69
|
+
* Removes duplicates from the given array.
|
|
70
|
+
* @param arr - The array.
|
|
71
|
+
* @returns A new array.
|
|
72
|
+
*/
|
|
73
|
+
export declare function unique<T>(arr: T[]): T[];
|
|
74
|
+
/**
|
|
75
|
+
* Removes all undefined elements from the array.
|
|
76
|
+
* @param arr - The array.
|
|
77
|
+
* @returns A new array.
|
|
78
|
+
*/
|
|
79
|
+
export declare function compactArray<T>(arr: (T | undefined)[]): T[];
|
|
80
|
+
/**
|
|
81
|
+
* Returns whether two arrays are equal. The arrays are equal if they have the same length and all elements are equal.
|
|
82
|
+
*/
|
|
83
|
+
export declare function areArraysEqual<T>(a: T[], b: T[], eq?: (a: T, b: T) => boolean): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the element of the array that has the maximum value of the given function.
|
|
86
|
+
* In case of a tie, returns the first element with the maximum value.
|
|
87
|
+
* @param arr - The array.
|
|
88
|
+
* @param fn - The function to get the value to compare.
|
|
89
|
+
*/
|
|
90
|
+
export declare function maxBy<T>(arr: T[], fn: (x: T) => number): T | undefined;
|
|
91
|
+
/** Computes the sum of a numeric array. */
|
|
92
|
+
export declare function sum(arr: number[]): number;
|
|
93
|
+
/** Computes the median of a numeric array. Returns undefined if array is empty. */
|
|
94
|
+
export declare function median(arr: number[]): number | undefined;
|
|
95
|
+
/** Computes the mean of a numeric array. Returns undefined if the array is empty. */
|
|
96
|
+
export declare function mean(values: number[]): number | undefined;
|
|
97
|
+
/** Computes the variance of a numeric array. Returns undefined if there are less than 2 points. */
|
|
98
|
+
export declare function variance(values: number[]): number | undefined;
|
|
99
|
+
/** Computes the standard deviation of a numeric array. Returns undefined if there are less than 2 points. */
|
|
100
|
+
export declare function stdDev(values: number[]): number | undefined;
|
|
101
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/collection/array.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAC7C,GAAG,EAAE,CAAC,EAAE,EACR,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,EACT,QAAQ,SAAqC,GAC5C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAMb;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,EAAE,CAGrF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAM5F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAOhF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAEtF;AAED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,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,SAAS,CAEtE;AAED,2CAA2C;AAC3C,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAEzC;AAED,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,sBAOnC;AAED,qFAAqF;AACrF,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,sBAKpC;AAED,mGAAmG;AACnG,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,sBAOxC;AAED,6GAA6G;AAC7G,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,sBAKtC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pads an array to the target length by appending an element to its end. Throws if target length exceeds the input array length. Does not modify the input array.
|
|
3
|
+
* @param arr - Array with elements to pad.
|
|
4
|
+
* @param elem - Element to use for padding.
|
|
5
|
+
* @param length - Target length.
|
|
6
|
+
* @param errorMsg - Error message to throw if target length exceeds the input array length.
|
|
7
|
+
* @returns A new padded array.
|
|
8
|
+
*/ export function padArrayEnd(arr, elem, length, errorMsg = 'Array size exceeds target length') {
|
|
9
|
+
if (arr.length > length) {
|
|
10
|
+
throw new Error(errorMsg);
|
|
11
|
+
}
|
|
12
|
+
// Since typescript cannot always deduce that something is a tuple, we cast
|
|
13
|
+
return [
|
|
14
|
+
...arr,
|
|
15
|
+
...Array(length - arr.length).fill(elem)
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/** Removes the right-padding for an array. Does not modify original array. */ export function removeArrayPaddingEnd(arr, isEmpty) {
|
|
19
|
+
const lastNonEmptyIndex = arr.reduce((last, item, i)=>isEmpty(item) ? last : i, -1);
|
|
20
|
+
return lastNonEmptyIndex === -1 ? [] : arr.slice(0, lastNonEmptyIndex + 1);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Pads an array to the target length by prepending elements at the beginning. Throws if target length exceeds the input array length. Does not modify the input array.
|
|
24
|
+
* @param arr - Array with elements to pad.
|
|
25
|
+
* @param elem - Element to use for padding.
|
|
26
|
+
* @param length - Target length.
|
|
27
|
+
* @returns A new padded array.
|
|
28
|
+
*/ export function padArrayStart(arr, elem, length) {
|
|
29
|
+
if (arr.length > length) {
|
|
30
|
+
throw new Error(`Array size exceeds target length`);
|
|
31
|
+
}
|
|
32
|
+
// Since typescript cannot always deduce that something is a tuple, we cast
|
|
33
|
+
return [
|
|
34
|
+
...Array(length - arr.length).fill(elem),
|
|
35
|
+
...arr
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns if an array is composed of empty items.
|
|
40
|
+
* @param arr - Array to check.
|
|
41
|
+
* @returns True if every item in the array isEmpty.
|
|
42
|
+
*/ export function isArrayEmpty(arr, isEmpty) {
|
|
43
|
+
for (const item of arr){
|
|
44
|
+
if (!isEmpty(item)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the number of non-empty items in an array.
|
|
52
|
+
* @param arr - Array to check.
|
|
53
|
+
* @returns Number of non-empty items in an array.
|
|
54
|
+
*/ export function arrayNonEmptyLength(arr, isEmpty) {
|
|
55
|
+
return arr.reduce((sum, item)=>isEmpty(item) ? sum : sum + 1, 0);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Executes the given function n times and returns the results in an array.
|
|
59
|
+
* @param n - How many times to repeat.
|
|
60
|
+
* @param fn - Mapper from index to value.
|
|
61
|
+
* @returns The array with the result from all executions.
|
|
62
|
+
*/ export function times(n, fn) {
|
|
63
|
+
return [
|
|
64
|
+
...Array(n).keys()
|
|
65
|
+
].map((i)=>fn(i));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Executes the given async function n times and returns the results in an array. Awaits each execution before starting the next one.
|
|
69
|
+
* @param n - How many times to repeat.
|
|
70
|
+
* @param fn - Mapper from index to value.
|
|
71
|
+
* @returns The array with the result from all executions.
|
|
72
|
+
*/ export async function timesAsync(n, fn) {
|
|
73
|
+
const results = [];
|
|
74
|
+
for(let i = 0; i < n; i++){
|
|
75
|
+
results.push(await fn(i));
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Executes the given async function n times in parallel and returns the results in an array.
|
|
81
|
+
* @param n - How many times to repeat.
|
|
82
|
+
* @param fn - Mapper from index to value.
|
|
83
|
+
* @returns The array with the result from all executions.
|
|
84
|
+
*/ export async function timesParallel(n, fn) {
|
|
85
|
+
const results = await Promise.all(Array(n).fill(0).map((_, i)=>fn(i)));
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the serialized size of all non-empty items in an array.
|
|
90
|
+
* @param arr - Array
|
|
91
|
+
* @returns The serialized size in bytes.
|
|
92
|
+
*/ export function arraySerializedSizeOfNonEmpty(arr) {
|
|
93
|
+
return arr.filter((x)=>x && ('isZero' in x ? !x.isZero() : !x.isEmpty())).map((x)=>x.toBuffer().length).reduce((a, b)=>a + b, 0);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Removes duplicates from the given array.
|
|
97
|
+
* @param arr - The array.
|
|
98
|
+
* @returns A new array.
|
|
99
|
+
*/ export function unique(arr) {
|
|
100
|
+
return [
|
|
101
|
+
...new Set(arr)
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Removes all undefined elements from the array.
|
|
106
|
+
* @param arr - The array.
|
|
107
|
+
* @returns A new array.
|
|
108
|
+
*/ export function compactArray(arr) {
|
|
109
|
+
return arr.filter((x)=>x !== undefined);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns whether two arrays are equal. The arrays are equal if they have the same length and all elements are equal.
|
|
113
|
+
*/ export function areArraysEqual(a, b, eq = (a, b)=>a === b) {
|
|
114
|
+
if (a.length !== b.length) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
for(let i = 0; i < a.length; i++){
|
|
118
|
+
if (!eq(a[i], b[i])) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns the element of the array that has the maximum value of the given function.
|
|
126
|
+
* In case of a tie, returns the first element with the maximum value.
|
|
127
|
+
* @param arr - The array.
|
|
128
|
+
* @param fn - The function to get the value to compare.
|
|
129
|
+
*/ export function maxBy(arr, fn) {
|
|
130
|
+
return arr.reduce((max, x)=>fn(x) > fn(max) ? x : max, arr[0]);
|
|
131
|
+
}
|
|
132
|
+
/** Computes the sum of a numeric array. */ export function sum(arr) {
|
|
133
|
+
return arr.reduce((a, b)=>a + b, 0);
|
|
134
|
+
}
|
|
135
|
+
/** Computes the median of a numeric array. Returns undefined if array is empty. */ export function median(arr) {
|
|
136
|
+
if (arr.length === 0) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const sorted = [
|
|
140
|
+
...arr
|
|
141
|
+
].sort((a, b)=>a - b);
|
|
142
|
+
const mid = Math.floor(sorted.length / 2);
|
|
143
|
+
return sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
144
|
+
}
|
|
145
|
+
/** Computes the mean of a numeric array. Returns undefined if the array is empty. */ export function mean(values) {
|
|
146
|
+
if (values.length === 0) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
return values.reduce((a, b)=>a + b, 0) / values.length;
|
|
150
|
+
}
|
|
151
|
+
/** Computes the variance of a numeric array. Returns undefined if there are less than 2 points. */ export function variance(values) {
|
|
152
|
+
if (values.length < 2) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
const avg = mean(values);
|
|
156
|
+
const points = values.map((value)=>value * value + avg * avg - 2 * value * avg);
|
|
157
|
+
return sum(points) / (values.length - 1);
|
|
158
|
+
}
|
|
159
|
+
/** Computes the standard deviation of a numeric array. Returns undefined if there are less than 2 points. */ export function stdDev(values) {
|
|
160
|
+
if (values.length < 2) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
return Math.sqrt(variance(values));
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collection/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Returns a new object with the same keys and where each value has been passed through the mapping function. */
|
|
2
|
+
export declare function mapValues<K extends string | number | symbol, T, U>(obj: Record<K, T>, fn: (value: T, key: K) => U): Record<K, U>;
|
|
3
|
+
export declare function mapValues<K extends string | number | symbol, T, U>(obj: Partial<Record<K, T>>, fn: (value: T, key: K) => U): Partial<Record<K, U>>;
|
|
4
|
+
/** Returns a new object where all keys with undefined values have been removed. */
|
|
5
|
+
export declare function compact<T extends object>(obj: T): {
|
|
6
|
+
[P in keyof T]+?: Exclude<T[P], undefined>;
|
|
7
|
+
};
|
|
8
|
+
/** Returns a new object by picking the given keys. */
|
|
9
|
+
export declare function pick<T extends object, U extends keyof T>(object: T, ...props: U[]): Pick<T, U>;
|
|
10
|
+
export declare function pick<T extends object>(object: T, ...props: string[]): Partial<T>;
|
|
11
|
+
/** Returns a new object by omitting the given keys. */
|
|
12
|
+
export declare function omit<T extends object, K extends keyof T>(object: T, ...props: K[]): Omit<T, K>;
|
|
13
|
+
export declare function omit<T extends object>(object: T, ...props: string[]): Partial<T>;
|
|
14
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRo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S,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAChG,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Returns a new object with the same keys and where each value has been passed through the mapping function. */ export function mapValues(obj, fn) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for(const key in obj){
|
|
4
|
+
result[key] = fn(obj[key], key);
|
|
5
|
+
}
|
|
6
|
+
return result;
|
|
7
|
+
}
|
|
8
|
+
/** Returns a new object where all keys with undefined values have been removed. */ export function compact(obj) {
|
|
9
|
+
const result = {};
|
|
10
|
+
for(const key in obj){
|
|
11
|
+
if (obj[key] !== undefined) {
|
|
12
|
+
result[key] = obj[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
export function pick(object, ...props) {
|
|
18
|
+
const obj = {};
|
|
19
|
+
for (const prop of props){
|
|
20
|
+
obj[prop] = object[prop];
|
|
21
|
+
}
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
export function omit(object, ...props) {
|
|
25
|
+
const obj = {
|
|
26
|
+
...object
|
|
27
|
+
};
|
|
28
|
+
for (const prop of props){
|
|
29
|
+
delete obj[prop];
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class that allows for a value to be committed or rolled back.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Committable<T> {
|
|
5
|
+
private currentValue;
|
|
6
|
+
private nextValue;
|
|
7
|
+
constructor(initialValue: T);
|
|
8
|
+
/**
|
|
9
|
+
* Commits the uncommitted value.
|
|
10
|
+
*/
|
|
11
|
+
commit(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Rolls back the uncommitted value.
|
|
14
|
+
*/
|
|
15
|
+
rollback(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the current value.
|
|
18
|
+
* @param includeUncommitted - Whether to include the uncommitted value.
|
|
19
|
+
* @returns The current value if includeUncommitted is false, otherwise the uncommitted value.
|
|
20
|
+
*/
|
|
21
|
+
get(includeUncommitted?: boolean): T;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the next value to be committed to.
|
|
24
|
+
* @param value - The new value to be set.
|
|
25
|
+
*/
|
|
26
|
+
set(value: T): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=committable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"committable.d.ts","sourceRoot":"","sources":["../../src/committable/committable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,SAAS,CAA4B;gBAEjC,YAAY,EAAE,CAAC;IAI3B;;OAEG;IACI,MAAM;IAQb;;OAEG;IACI,QAAQ;IAIf;;;;OAIG;IACI,GAAG,CAAC,kBAAkB,GAAE,OAAe,GAAG,CAAC;IAIlD;;;OAGG;IACI,GAAG,CAAC,KAAK,EAAE,CAAC;CAGpB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class that allows for a value to be committed or rolled back.
|
|
3
|
+
*/ export class Committable {
|
|
4
|
+
currentValue;
|
|
5
|
+
nextValue = undefined;
|
|
6
|
+
constructor(initialValue){
|
|
7
|
+
this.currentValue = initialValue;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Commits the uncommitted value.
|
|
11
|
+
*/ commit() {
|
|
12
|
+
if (this.nextValue === undefined) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.currentValue = this.nextValue;
|
|
16
|
+
this.nextValue = undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Rolls back the uncommitted value.
|
|
20
|
+
*/ rollback() {
|
|
21
|
+
this.nextValue === undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the current value.
|
|
25
|
+
* @param includeUncommitted - Whether to include the uncommitted value.
|
|
26
|
+
* @returns The current value if includeUncommitted is false, otherwise the uncommitted value.
|
|
27
|
+
*/ get(includeUncommitted = false) {
|
|
28
|
+
return includeUncommitted && this.nextValue ? this.nextValue : this.currentValue;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sets the next value to be committed to.
|
|
32
|
+
* @param value - The new value to be set.
|
|
33
|
+
*/ set(value) {
|
|
34
|
+
this.nextValue = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/committable/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './committable.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type EnvVar = 'ACVM_BINARY_PATH' | 'ACVM_WORKING_DIRECTORY' | 'GOVERNANCE_CONTRACT_ADDRESS' | 'API_KEY' | 'API_PREFIX' | 'ARCHIVER_MAX_LOGS' | 'ARCHIVER_POLLING_INTERVAL_MS' | 'ARCHIVER_URL' | 'ARCHIVER_VIEM_POLLING_INTERVAL_MS' | 'ARCHIVER_BATCH_SIZE' | 'ASSUME_PROVEN_THROUGH_BLOCK_NUMBER' | 'AZTEC_NODE_URL' | 'AZTEC_PORT' | 'BB_BINARY_PATH' | 'BB_SKIP_CLEANUP' | 'BB_WORKING_DIRECTORY' | 'BOOTSTRAP_NODES' | 'BLOB_SINK_ARCHIVE_API_URL' | 'BLOB_SINK_PORT' | 'BLOB_SINK_URL' | 'BOT_DA_GAS_LIMIT' | 'BOT_FEE_PAYMENT_METHOD' | 'BOT_FLUSH_SETUP_TRANSACTIONS' | 'BOT_FOLLOW_CHAIN' | 'BOT_L2_GAS_LIMIT' | 'BOT_MAX_PENDING_TXS' | 'BOT_NO_START' | 'BOT_NO_WAIT_FOR_TRANSFERS' | 'BOT_L1_MNEMONIC' | 'BOT_L1_PRIVATE_KEY' | 'BOT_PRIVATE_KEY' | 'BOT_PRIVATE_TRANSFERS_PER_TX' | 'BOT_PUBLIC_TRANSFERS_PER_TX' | 'BOT_PXE_URL' | 'BOT_RECIPIENT_ENCRYPTION_SECRET' | 'BOT_SKIP_PUBLIC_SIMULATION' | 'BOT_TOKEN_CONTRACT' | 'BOT_TOKEN_SALT' | 'BOT_TX_INTERVAL_SECONDS' | 'BOT_TX_MINED_WAIT_SECONDS' | 'BOT_MAX_CONSECUTIVE_ERRORS' | 'BOT_STOP_WHEN_UNHEALTHY' | 'COINBASE' | 'DATA_DIRECTORY' | 'DATA_STORE_MAP_SIZE_KB' | 'DEBUG' | 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY' | 'DEPLOY_AZTEC_CONTRACTS_SALT' | 'DEPLOY_AZTEC_CONTRACTS' | 'ENFORCE_FEES' | 'ETHEREUM_HOSTS' | 'FEE_JUICE_CONTRACT_ADDRESS' | 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS' | 'FEE_RECIPIENT' | 'FORCE_COLOR' | 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS' | 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS' | 'INBOX_CONTRACT_ADDRESS' | 'L1_CHAIN_ID' | 'L1_CONSENSUS_HOST_URL' | 'L1_CONSENSUS_HOST_API_KEY' | 'L1_CONSENSUS_HOST_API_KEY_HEADER' | 'L1_PRIVATE_KEY' | 'LOG_JSON' | 'LOG_MULTILINE' | 'LOG_LEVEL' | 'MNEMONIC' | 'NETWORK_NAME' | 'NETWORK' | 'NO_PXE' | 'COIN_ISSUER_CONTRACT_ADDRESS' | 'USE_GCLOUD_LOGGING' | 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT' | 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' | 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT' | 'OTEL_COLLECT_INTERVAL_MS' | 'OTEL_EXCLUDE_METRICS' | 'OTEL_EXPORT_TIMEOUT_MS' | 'OUTBOX_CONTRACT_ADDRESS' | 'P2P_BLOCK_CHECK_INTERVAL_MS' | 'P2P_BLOCK_REQUEST_BATCH_SIZE' | 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK' | 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS' | 'P2P_ENABLED' | 'P2P_GOSSIPSUB_D' | 'P2P_GOSSIPSUB_DHI' | 'P2P_GOSSIPSUB_DLO' | 'P2P_GOSSIPSUB_DLAZY' | 'P2P_GOSSIPSUB_FLOOD_PUBLISH' | 'P2P_GOSSIPSUB_INTERVAL_MS' | 'P2P_GOSSIPSUB_MCACHE_GOSSIP' | 'P2P_GOSSIPSUB_MCACHE_LENGTH' | 'P2P_GOSSIPSUB_TX_INVALID_MESSAGE_DELIVERIES_DECAY' | 'P2P_GOSSIPSUB_TX_INVALID_MESSAGE_DELIVERIES_WEIGHT' | 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT' | 'P2P_L2_QUEUE_SIZE' | 'P2P_MAX_PEERS' | 'P2P_PEER_CHECK_INTERVAL_MS' | 'P2P_PEER_PENALTY_VALUES' | 'P2P_QUERY_FOR_IP' | 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS' | 'P2P_REQRESP_OVERALL_REQUEST_TIMEOUT_MS' | 'P2P_DOUBLE_SPEND_SEVERE_PEER_PENALTY_WINDOW' | 'P2P_TCP_LISTEN_ADDR' | 'P2P_TCP_ANNOUNCE_ADDR' | 'P2P_TX_POOL_KEEP_PROVEN_FOR' | 'P2P_ATTESTATION_POOL_KEEP_FOR' | 'P2P_UDP_ANNOUNCE_ADDR' | 'P2P_UDP_LISTEN_ADDR' | 'P2P_ARCHIVED_TX_LIMIT' | 'PEER_ID_PRIVATE_KEY' | 'PROVER_AGENT_CONCURRENCY' | 'PROVER_AGENT_COUNT' | 'PROVER_AGENT_PROOF_TYPES' | 'PROVER_AGENT_POLL_INTERVAL_MS' | 'PROVER_BROKER_HOST' | 'PROVER_BROKER_ENABLED' | 'PROVER_BROKER_JOB_TIMEOUT_MS' | 'PROVER_BROKER_POLL_INTERVAL_MS' | 'PROVER_BROKER_JOB_MAX_RETRIES' | 'PROVER_BROKER_BATCH_INTERVAL_MS' | 'PROVER_BROKER_BATCH_SIZE' | 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR' | 'PROVER_COORDINATION_NODE_URL' | 'PROVER_FAILED_PROOF_STORE' | 'PROVER_ID' | 'PROVER_JOB_TIMEOUT_MS' | 'PROVER_NODE_POLLING_INTERVAL_MS' | 'PROVER_NODE_MAX_PENDING_JOBS' | 'PROVER_NODE_MAX_PARALLEL_BLOCKS_PER_EPOCH' | 'PROVER_NODE_TX_GATHERING_TIMEOUT_MS' | 'PROVER_NODE_TX_GATHERING_INTERVAL_MS' | 'PROVER_NODE_TX_GATHERING_MAX_PARALLEL_REQUESTS' | 'PROVER_PUBLISH_RETRY_INTERVAL_MS' | 'PROVER_PUBLISHER_PRIVATE_KEY' | 'PROVER_REAL_PROOFS' | 'PROVER_TEST_DELAY_FACTOR' | 'PROVER_TEST_DELAY_MS' | 'PROVER_TEST_DELAY_TYPE' | 'PXE_L2_STARTING_BLOCK' | 'PXE_PROVER_ENABLED' | 'REGISTRY_CONTRACT_ADDRESS' | 'ROLLUP_CONTRACT_ADDRESS' | 'SEQ_ALLOWED_SETUP_FN' | 'SEQ_MAX_BLOCK_SIZE_IN_BYTES' | 'SEQ_MAX_TX_PER_BLOCK' | 'SEQ_MIN_TX_PER_BLOCK' | 'SEQ_MAX_DA_BLOCK_GAS' | 'SEQ_MAX_L2_BLOCK_GAS' | 'SEQ_PUBLISH_RETRY_INTERVAL_MS' | 'SEQ_PUBLISHER_PRIVATE_KEY' | 'SEQ_TX_POLLING_INTERVAL_MS' | 'SEQ_ENFORCE_TIME_TABLE' | 'SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOT' | 'SLASH_FACTORY_CONTRACT_ADDRESS' | 'STAKING_ASSET_CONTRACT_ADDRESS' | 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS' | 'TELEMETRY' | 'TEST_ACCOUNTS' | 'TX_GOSSIP_VERSION' | 'TXE_PORT' | 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS' | 'VALIDATOR_DISABLED' | 'VALIDATOR_PRIVATE_KEY' | 'VALIDATOR_REEXECUTE' | 'VERSION' | 'WS_BLOCK_CHECK_INTERVAL_MS' | 'WS_PROVEN_BLOCKS_ONLY' | 'WS_BLOCK_REQUEST_BATCH_SIZE' | 'VERIFIER_VIEM_POLLING_INTERVAL_MS' | 'L1_READER_VIEM_POLLING_INTERVAL_MS' | 'PROVER_VIEM_POLLING_INTERVAL_MS' | 'SEQ_VIEM_POLLING_INTERVAL_MS' | 'WS_DB_MAP_SIZE_KB' | 'WS_DATA_DIRECTORY' | 'WS_NUM_HISTORIC_BLOCKS' | 'ETHEREUM_SLOT_DURATION' | 'AZTEC_SLOT_DURATION' | 'AZTEC_EPOCH_DURATION' | 'AZTEC_TARGET_COMMITTEE_SIZE' | 'AZTEC_PROOF_SUBMISSION_WINDOW' | 'AZTEC_MINIMUM_STAKE' | 'AZTEC_SLASHING_QUORUM' | 'AZTEC_SLASHING_ROUND_SIZE' | 'AZTEC_GOVERNANCE_PROPOSER_QUORUM' | 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE' | 'L1_GAS_LIMIT_BUFFER_PERCENTAGE' | 'L1_GAS_PRICE_MIN' | 'L1_GAS_PRICE_MAX' | 'L1_BLOB_FEE_PER_GAS_MAX' | 'L1_PRIORITY_FEE_BUMP_PERCENTAGE' | 'L1_PRIORITY_FEE_RETRY_BUMP_PERCENTAGE' | 'L1_FIXED_PRIORITY_FEE_PER_GAS' | 'L1_TX_MONITOR_MAX_ATTEMPTS' | 'L1_TX_MONITOR_CHECK_INTERVAL_MS' | 'L1_TX_MONITOR_STALL_TIME_MS' | 'L1_TX_MONITOR_TX_TIMEOUT_MS' | 'L1_TX_PROPAGATION_MAX_QUERY_ATTEMPTS' | 'FAUCET_MNEMONIC_ACCOUNT_INDEX' | 'FAUCET_ETH_AMOUNT' | 'FAUCET_INTERVAL_MS' | 'FAUCET_L1_ASSETS' | 'K8S_POD_NAME' | 'K8S_POD_UID' | 'K8S_NAMESPACE_NAME' | 'CUSTOM_FORWARDER_CONTRACT_ADDRESS';
|
|
2
|
+
//# sourceMappingURL=env_var.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env_var.d.ts","sourceRoot":"","sources":["../../src/config/env_var.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd,kBAAkB,GAClB,wBAAwB,GACxB,6BAA6B,GAC7B,SAAS,GACT,YAAY,GACZ,mBAAmB,GACnB,8BAA8B,GAC9B,cAAc,GACd,mCAAmC,GACnC,qBAAqB,GACrB,oCAAoC,GACpC,gBAAgB,GAChB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,sBAAsB,GACtB,iBAAiB,GACjB,2BAA2B,GAC3B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,wBAAwB,GACxB,8BAA8B,GAC9B,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,cAAc,GACd,2BAA2B,GAC3B,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,8BAA8B,GAC9B,6BAA6B,GAC7B,aAAa,GACb,iCAAiC,GACjC,4BAA4B,GAC5B,oBAAoB,GACpB,gBAAgB,GAChB,yBAAyB,GACzB,2BAA2B,GAC3B,4BAA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from './env_var.js';
|
|
2
|
+
export { type EnvVar } from './env_var.js';
|
|
3
|
+
export interface ConfigMapping {
|
|
4
|
+
env?: EnvVar;
|
|
5
|
+
parseEnv?: (val: string) => any;
|
|
6
|
+
defaultValue?: any;
|
|
7
|
+
printDefault?: (val: any) => string;
|
|
8
|
+
description: string;
|
|
9
|
+
isBoolean?: boolean;
|
|
10
|
+
nested?: Record<string, ConfigMapping>;
|
|
11
|
+
}
|
|
12
|
+
export declare function isBooleanConfigValue<T>(obj: T, key: keyof T): boolean;
|
|
13
|
+
export type ConfigMappingsType<T> = Record<keyof T, ConfigMapping>;
|
|
14
|
+
export declare function getConfigFromMappings<T>(configMappings: ConfigMappingsType<T>): T;
|
|
15
|
+
/**
|
|
16
|
+
* Filters out a service's config mappings to exclude certain keys.
|
|
17
|
+
* @param configMappings - The service's config mappings
|
|
18
|
+
* @param keysToFilter - The keys to filter out
|
|
19
|
+
* @returns The filtered config mappings
|
|
20
|
+
*/
|
|
21
|
+
export declare function omitConfigMappings<T, K extends keyof T>(configMappings: ConfigMappingsType<T>, keysToFilter: K[]): ConfigMappingsType<Omit<T, K>>;
|
|
22
|
+
/**
|
|
23
|
+
* Generates parseEnv and default values for a numerical config value.
|
|
24
|
+
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
25
|
+
* @returns Object with parseEnv and default values for a numerical config value
|
|
26
|
+
*/
|
|
27
|
+
export declare function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'>;
|
|
28
|
+
/**
|
|
29
|
+
* Generates parseEnv and default values for a numerical config value.
|
|
30
|
+
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
31
|
+
* @returns Object with parseEnv and default values for a numerical config value
|
|
32
|
+
*/
|
|
33
|
+
export declare function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'>;
|
|
34
|
+
/**
|
|
35
|
+
* Generates parseEnv for an optional numerical config value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function optionalNumberConfigHelper(): Pick<ConfigMapping, 'parseEnv'>;
|
|
38
|
+
/**
|
|
39
|
+
* Generates parseEnv and default values for a boolean config value.
|
|
40
|
+
* @param defaultVal - The default value to use if the environment variable is not set or is invalid
|
|
41
|
+
* @returns Object with parseEnv and default values for a boolean config value
|
|
42
|
+
*/
|
|
43
|
+
export declare function booleanConfigHelper(defaultVal?: boolean): Required<Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
|
|
44
|
+
parseVal: (val: string) => boolean;
|
|
45
|
+
}>;
|
|
46
|
+
/** Parses an env var as boolean. Returns true only if value is 1, true, or TRUE. */
|
|
47
|
+
export declare function parseBooleanEnv(val: string | undefined): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Picks specific keys from the given configuration mappings.
|
|
50
|
+
*
|
|
51
|
+
* @template T - The type of the full configuration object.
|
|
52
|
+
* @template K - The keys to pick from the configuration object.
|
|
53
|
+
* @param {ConfigMappingsType<T>} configMappings - The full configuration mappings object.
|
|
54
|
+
* @param {K[]} keys - The keys to pick from the configuration mappings.
|
|
55
|
+
* @returns {ConfigMappingsType<Pick<T, K>>} - A new configuration mappings object containing only the specified keys.
|
|
56
|
+
*/
|
|
57
|
+
export declare function pickConfigMappings<T, K extends keyof T>(configMappings: ConfigMappingsType<T>, keys: K[]): ConfigMappingsType<Pick<T, K>>;
|
|
58
|
+
/**
|
|
59
|
+
* Extracts the default configuration values from the given configuration mappings.
|
|
60
|
+
*
|
|
61
|
+
* @template T - The type of the configuration object.
|
|
62
|
+
* @param {ConfigMappingsType<T>} configMappings - The configuration mappings object.
|
|
63
|
+
* @returns {T} - The configuration object with default values.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getDefaultConfig<T>(configMappings: ConfigMappingsType<T>): T;
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"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I,CAAC,aAAa,EAAE,UAAU,GAAG,cAAc,CAAC,CAUxG;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAU5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,UAAQ,GACjB,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,cAAc,GAAG,WAAW,CAAC,GAAG;IAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAAC,CAQnH;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEhE;AAcD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EACrD,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC,EACrC,IAAI,EAAE,CAAC,EAAE,GACR,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAEhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAU5E"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export function isBooleanConfigValue(obj, key) {
|
|
2
|
+
return typeof obj[key] === 'boolean';
|
|
3
|
+
}
|
|
4
|
+
export function getConfigFromMappings(configMappings) {
|
|
5
|
+
const config = {};
|
|
6
|
+
for(const key in configMappings){
|
|
7
|
+
const { env, parseEnv, defaultValue: def, nested } = configMappings[key];
|
|
8
|
+
if (nested) {
|
|
9
|
+
config[key] = getConfigFromMappings(nested);
|
|
10
|
+
} else {
|
|
11
|
+
const val = env ? process.env[env] : undefined;
|
|
12
|
+
if (val !== undefined) {
|
|
13
|
+
config[key] = parseEnv ? parseEnv(val) : val;
|
|
14
|
+
} else if (def !== undefined) {
|
|
15
|
+
config[key] = def;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Filters out a service's config mappings to exclude certain keys.
|
|
23
|
+
* @param configMappings - The service's config mappings
|
|
24
|
+
* @param keysToFilter - The keys to filter out
|
|
25
|
+
* @returns The filtered config mappings
|
|
26
|
+
*/ export function omitConfigMappings(configMappings, keysToFilter) {
|
|
27
|
+
return Object.fromEntries(Object.entries(configMappings).filter(([key])=>!keysToFilter.includes(key)));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generates parseEnv and default values for a numerical config value.
|
|
31
|
+
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
32
|
+
* @returns Object with parseEnv and default values for a numerical config value
|
|
33
|
+
*/ export function numberConfigHelper(defaultVal) {
|
|
34
|
+
return {
|
|
35
|
+
parseEnv: (val)=>safeParseNumber(val, defaultVal),
|
|
36
|
+
defaultValue: defaultVal
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates parseEnv and default values for a numerical config value.
|
|
41
|
+
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
42
|
+
* @returns Object with parseEnv and default values for a numerical config value
|
|
43
|
+
*/ export function bigintConfigHelper(defaultVal) {
|
|
44
|
+
return {
|
|
45
|
+
parseEnv: (val)=>{
|
|
46
|
+
if (val === '') {
|
|
47
|
+
return defaultVal;
|
|
48
|
+
}
|
|
49
|
+
return BigInt(val);
|
|
50
|
+
},
|
|
51
|
+
defaultValue: defaultVal
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generates parseEnv for an optional numerical config value.
|
|
56
|
+
*/ export function optionalNumberConfigHelper() {
|
|
57
|
+
return {
|
|
58
|
+
parseEnv: (val)=>{
|
|
59
|
+
if (val !== undefined && val.length > 0) {
|
|
60
|
+
const parsedValue = parseInt(val);
|
|
61
|
+
return Number.isSafeInteger(parsedValue) ? parsedValue : undefined;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generates parseEnv and default values for a boolean config value.
|
|
69
|
+
* @param defaultVal - The default value to use if the environment variable is not set or is invalid
|
|
70
|
+
* @returns Object with parseEnv and default values for a boolean config value
|
|
71
|
+
*/ export function booleanConfigHelper(defaultVal = false) {
|
|
72
|
+
const parse = (val)=>typeof val === 'boolean' ? val : parseBooleanEnv(val);
|
|
73
|
+
return {
|
|
74
|
+
parseEnv: parse,
|
|
75
|
+
parseVal: parse,
|
|
76
|
+
defaultValue: defaultVal,
|
|
77
|
+
isBoolean: true
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Parses an env var as boolean. Returns true only if value is 1, true, or TRUE. */ export function parseBooleanEnv(val) {
|
|
81
|
+
return val !== undefined && [
|
|
82
|
+
'1',
|
|
83
|
+
'true',
|
|
84
|
+
'TRUE'
|
|
85
|
+
].includes(val);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Safely parses a number from a string.
|
|
89
|
+
* If the value is not a number or is not a safe integer, the default value is returned.
|
|
90
|
+
* @param value - The string value to parse
|
|
91
|
+
* @param defaultValue - The default value to return
|
|
92
|
+
* @returns Either parsed value or default value
|
|
93
|
+
*/ function safeParseNumber(value, defaultValue) {
|
|
94
|
+
const parsedValue = parseInt(value, 10);
|
|
95
|
+
return Number.isSafeInteger(parsedValue) ? parsedValue : defaultValue;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Picks specific keys from the given configuration mappings.
|
|
99
|
+
*
|
|
100
|
+
* @template T - The type of the full configuration object.
|
|
101
|
+
* @template K - The keys to pick from the configuration object.
|
|
102
|
+
* @param {ConfigMappingsType<T>} configMappings - The full configuration mappings object.
|
|
103
|
+
* @param {K[]} keys - The keys to pick from the configuration mappings.
|
|
104
|
+
* @returns {ConfigMappingsType<Pick<T, K>>} - A new configuration mappings object containing only the specified keys.
|
|
105
|
+
*/ export function pickConfigMappings(configMappings, keys) {
|
|
106
|
+
return Object.fromEntries(keys.map((key)=>[
|
|
107
|
+
key,
|
|
108
|
+
configMappings[key]
|
|
109
|
+
]));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Extracts the default configuration values from the given configuration mappings.
|
|
113
|
+
*
|
|
114
|
+
* @template T - The type of the configuration object.
|
|
115
|
+
* @param {ConfigMappingsType<T>} configMappings - The configuration mappings object.
|
|
116
|
+
* @returns {T} - The configuration object with default values.
|
|
117
|
+
*/ export function getDefaultConfig(configMappings) {
|
|
118
|
+
const defaultConfig = {};
|
|
119
|
+
for(const key in configMappings){
|
|
120
|
+
if (configMappings[key] && configMappings[key].defaultValue !== undefined) {
|
|
121
|
+
defaultConfig[key] = configMappings[key].defaultValue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return defaultConfig;
|
|
125
|
+
}
|