@ohos-ports/azle 0.33.0-beta.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/.scripts/add_metadata_to_dfx_json.js +54 -0
- package/.scripts/cargo_expand.sh +17 -0
- package/.scripts/class_migration/add_example_dependency.js +54 -0
- package/.scripts/class_migration/change_to_custom_candid_gen.js +76 -0
- package/.scripts/class_migration/clean_package.js +27 -0
- package/.scripts/class_migration/copy_generated_candid_from_example.js +90 -0
- package/.scripts/class_migration/delete_tests_file.js +22 -0
- package/.scripts/class_migration/do_all_packages.js +61 -0
- package/.scripts/class_migration/modify_pretest.js +57 -0
- package/.scripts/class_migration/name_package.js +62 -0
- package/.scripts/class_migration/update_test.js +38 -0
- package/.scripts/class_migration/update_ts_config.js +48 -0
- package/.scripts/class_migration/update_typescript.js +99 -0
- package/.scripts/clean_all_projects.ts +91 -0
- package/.scripts/delete_git_branches.sh +20 -0
- package/.scripts/dev_dependencies/add_dev_dependencies.js +53 -0
- package/.scripts/dev_dependencies/remove_dev_dependencies.js +44 -0
- package/.scripts/examples-survey.json +5651 -0
- package/.scripts/file_generator/bin.js +4 -0
- package/.scripts/file_generator/index.ts +59 -0
- package/.scripts/file_generator/main.ts +55 -0
- package/.scripts/find_multiline_files.ts +101 -0
- package/.scripts/hash_file.ts +9 -0
- package/.scripts/hash_file_by_parts/bin.js +4 -0
- package/.scripts/hash_file_by_parts/index.ts +48 -0
- package/.scripts/hash_file_by_parts/main.ts +10 -0
- package/.scripts/jest_isolate_modules.js +29 -0
- package/.scripts/jest_migration.sh +31 -0
- package/.scripts/reorder_dfx_json.js +72 -0
- package/.scripts/setup_release_branch.sh +34 -0
- package/.scripts/simplify_tsconfig.js +37 -0
- package/.scripts/survey_examples.ts +396 -0
- package/.scripts/tsx_migration/ts_node_to_tsx.js +76 -0
- package/.scripts/update_candid.sh +40 -0
- package/.scripts/update_dfx_json_main.js +66 -0
- package/.scripts/update_dfx_json_with_optimize.py +22 -0
- package/.scripts/update_jest_configs.ts +248 -0
- package/LICENSE +21 -0
- package/LICENSE_EXTENSION.md +42 -0
- package/NOTICE +222 -0
- package/README.md +78 -0
- package/dist/canister_templates/experimental.wasm +0 -0
- package/dist/canister_templates/licenses.yml +29186 -0
- package/dist/canister_templates/stable.wasm +0 -0
- package/examples/README.md +22 -0
- package/examples/experimental/demo/hello_world_http_server/README.md +120 -0
- package/examples/experimental/demo/hello_world_http_server/benchmarks.json +42 -0
- package/examples/experimental/demo/hello_world_http_server/benchmarks.md +28 -0
- package/examples/experimental/demo/hello_world_http_server/dfx.json +13 -0
- package/examples/experimental/demo/hello_world_http_server/env.d.ts +9 -0
- package/examples/experimental/demo/hello_world_http_server/jest.config.js +10 -0
- package/examples/experimental/demo/hello_world_http_server/package-lock.json +8409 -0
- package/examples/experimental/demo/hello_world_http_server/package.json +20 -0
- package/examples/experimental/demo/hello_world_http_server/src/backend/index.ts +23 -0
- package/examples/experimental/demo/hello_world_http_server/src/frontend/index.html +16 -0
- package/examples/experimental/demo/hello_world_http_server/src/frontend/index.ts +62 -0
- package/examples/experimental/demo/hello_world_http_server/test/pretest.ts +13 -0
- package/examples/experimental/demo/hello_world_http_server/test/test.ts +9 -0
- package/examples/experimental/demo/hello_world_http_server/test/tests.ts +27 -0
- package/examples/experimental/demo/hello_world_http_server/tsconfig.json +13 -0
- package/examples/package-lock.json +8746 -0
- package/examples/package.json +17 -0
- package/examples/stable/demo/hello_world/README.md +97 -0
- package/examples/stable/demo/hello_world/benchmarks.json +28 -0
- package/examples/stable/demo/hello_world/benchmarks.md +26 -0
- package/examples/stable/demo/hello_world/dfx.json +12 -0
- package/examples/stable/demo/hello_world/jest.config.js +10 -0
- package/examples/stable/demo/hello_world/package-lock.json +5524 -0
- package/examples/stable/demo/hello_world/package.json +14 -0
- package/examples/stable/demo/hello_world/src/index.ts +15 -0
- package/examples/stable/demo/hello_world/test/pretest.ts +17 -0
- package/examples/stable/demo/hello_world/test/test.ts +15 -0
- package/examples/stable/demo/hello_world/test/tests.ts +27 -0
- package/examples/stable/demo/hello_world/tsconfig.json +10 -0
- package/jest.config.dev.js +10 -0
- package/package.json +102 -0
- package/src/build.ts +98 -0
- package/src/experimental/build/assert_experimental.ts +5 -0
- package/src/experimental/build/commands/build/candid_and_method_meta.ts +30 -0
- package/src/experimental/build/commands/build/custom_js_modules/acorn/acorn.ts +6 -0
- package/src/experimental/build/commands/build/custom_js_modules/acorn/walk.ts +6 -0
- package/src/experimental/build/commands/build/custom_js_modules/async_hooks.ts +11 -0
- package/src/experimental/build/commands/build/custom_js_modules/https.ts +6 -0
- package/src/experimental/build/commands/build/custom_js_modules/perf_hooks.ts +12 -0
- package/src/experimental/build/commands/build/file_watcher/file_watcher.ts +152 -0
- package/src/experimental/build/commands/build/file_watcher/file_watcher_loader.js +9 -0
- package/src/experimental/build/commands/build/file_watcher/setup_file_watcher.ts +61 -0
- package/src/experimental/build/commands/build/get_context.ts +61 -0
- package/src/experimental/build/commands/build/index.ts +87 -0
- package/src/experimental/build/commands/build/javascript.ts +194 -0
- package/src/experimental/build/commands/build/wasm_binary/index.ts +32 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/Cargo.toml +26 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/autoreload.rs +46 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/benchmarking.rs +35 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/candid.rs +106 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/chunk.rs +11 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/execute_method_js.rs +46 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/guards.rs +9 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/accept_message.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/call_raw.rs +265 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_compiler.rs +19 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_decode.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_encode.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_cycle_balance.rs +12 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_self.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_version.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/certified_data_set.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/clear_timer.rs +18 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/cycles_burn.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/data_certificate.rs +13 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/debug_print.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/drain_microtasks.rs +23 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/in_replicated_execution.rs +8 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/is_controller.rs +16 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/mod.rs +351 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_arg_data.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_caller.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_accept.rs +17 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_available.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_refunded.rs +10 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_method_name.rs +8 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject.rs +16 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject_code.rs +8 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject_msg.rs +8 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reply.rs +19 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/notify_raw.rs +65 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/performance_counter.rs +19 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/rand_bytes.rs +25 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/rand_seed.rs +30 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/set_timer.rs +83 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/set_timer_interval.rs +66 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_contains_key.rs +32 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_get.rs +36 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_init.rs +29 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_insert.rs +46 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_is_empty.rs +23 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_items.rs +59 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_keys.rs +54 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_len.rs +23 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_remove.rs +36 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_values.rs +54 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/time.rs +8 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/trap.rs +14 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/init_and_post_upgrade.rs +212 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/internal_canister_methods.rs +142 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/lib.rs +35 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/stable_b_tree_map.rs +50 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/bytes_to_human_readable.rs +20 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/file_info.rs +60 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/hash.rs +111 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/mod.rs +20 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/reset.rs +15 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/upload_file_chunk.rs +88 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/wasm_binary_manipulation.rs +276 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/instantiate.rs +195 -0
- package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/mod.rs +24 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/bytes_to_human_readable.ts +27 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/expand_paths.ts +50 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/get_files_to_upload.ts +21 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/incomplete_files.ts +28 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/index.ts +43 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/on_before_exit.ts +34 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/upload_file.ts +91 -0
- package/src/experimental/build/commands/upload_assets/file_uploader/uploader_actor.ts +51 -0
- package/src/experimental/build/commands/upload_assets/index.ts +16 -0
- package/src/experimental/build/commands/upload_assets/uploader_identity.ts +23 -0
- package/src/experimental/build/index.ts +61 -0
- package/src/experimental/build/utils/dfx.ts +212 -0
- package/src/experimental/build/utils/filter_async.ts +14 -0
- package/src/experimental/build/utils/find_project_root.ts +67 -0
- package/src/experimental/build/utils/global_paths.ts +8 -0
- package/src/experimental/build/utils/log_success.ts +18 -0
- package/src/experimental/build/utils/types.ts +34 -0
- package/src/experimental/lib/assert_experimental.ts +19 -0
- package/src/experimental/lib/fetch/file.ts +15 -0
- package/src/experimental/lib/fetch/headers.ts +85 -0
- package/src/experimental/lib/fetch/http.ts +293 -0
- package/src/experimental/lib/fetch/icp.ts +98 -0
- package/src/experimental/lib/fetch/index.ts +97 -0
- package/src/experimental/lib/fetch/response.ts +171 -0
- package/src/experimental/lib/fetch/url.ts +15 -0
- package/src/experimental/lib/globals.ts +146 -0
- package/src/experimental/lib/http_client/fetch_ic/actor.ts +131 -0
- package/src/experimental/lib/http_client/fetch_ic/agent.ts +20 -0
- package/src/experimental/lib/http_client/fetch_ic/call.ts +257 -0
- package/src/experimental/lib/http_client/fetch_ic/get_canister_id.ts +25 -0
- package/src/experimental/lib/http_client/fetch_ic/host.ts +30 -0
- package/src/experimental/lib/http_client/fetch_ic/identity.ts +52 -0
- package/src/experimental/lib/http_client/fetch_ic/index.ts +95 -0
- package/src/experimental/lib/http_client/fetch_ic/response.ts +8 -0
- package/src/experimental/lib/http_client/index.ts +6 -0
- package/src/experimental/lib/http_client/to_jwt.ts +6 -0
- package/src/experimental/lib/ic/azle_ic_experimental.ts +92 -0
- package/src/experimental/lib/ic/candid_compiler.ts +14 -0
- package/src/experimental/lib/ic/index.ts +10 -0
- package/src/experimental/lib/ic/set_outgoing_http_options.ts +18 -0
- package/src/experimental/lib/index.ts +7 -0
- package/src/experimental/lib/server.ts +279 -0
- package/src/experimental/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts +45 -0
- package/src/experimental/lib/threshold_wallet/ecdsa_public_key.ts +33 -0
- package/src/experimental/lib/threshold_wallet/index.ts +7 -0
- package/src/experimental/lib/threshold_wallet/register_get_url.ts +36 -0
- package/src/experimental/lib/threshold_wallet/sign_with_ecdsa.ts +28 -0
- package/src/experimental/lib/threshold_wallet/wallet.ts +99 -0
- package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts +113 -0
- package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/index.ts +73 -0
- package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts +28 -0
- package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/simple_candid_definition_arb.ts +116 -0
- package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/types.ts +117 -0
- package/src/experimental/test/property/arbitraries/candid/candid_return_type_arb.ts +22 -0
- package/src/experimental/test/property/arbitraries/candid/candid_type.ts +83 -0
- package/src/experimental/test/property/arbitraries/candid/candid_value_and_meta_arb.ts +84 -0
- package/src/experimental/test/property/arbitraries/candid/candid_value_and_meta_arb_generator.ts +63 -0
- package/src/experimental/test/property/arbitraries/candid/candid_values_arb.ts +173 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/definition_arb.ts +11 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/index.ts +19 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/values_arb.ts +11 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/definition_arb.ts +172 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/index.ts +29 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/values_arb.ts +88 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/definition_arb.ts +184 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/index.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/values_arb.ts +95 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/definition_arb.ts +159 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/index.ts +31 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/values_arbs.ts +76 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/definition_arbs.ts +257 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/index.ts +37 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/values_arb.ts +92 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/definition_arb.ts +203 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/index.ts +39 -0
- package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/values_arb.ts +257 -0
- package/src/experimental/test/property/arbitraries/candid/corresponding_js_type.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/bool_arb.ts +28 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/floats/float32_arb.ts +56 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/floats/float64_arb.ts +56 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/index.ts +11 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/int16_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/int32_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/int64_arb.ts +41 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/int8_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/ints/int_arb.ts +39 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/index.ts +11 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat16_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat32_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat64_arb.ts +41 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat8_arb.ts +34 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat_arb.ts +39 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/null_arb.ts +33 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/text_arb.ts +47 -0
- package/src/experimental/test/property/arbitraries/candid/primitive/void_arb.ts +33 -0
- package/src/experimental/test/property/arbitraries/candid/recursive/definition_arb.ts +125 -0
- package/src/experimental/test/property/arbitraries/candid/recursive/index.ts +35 -0
- package/src/experimental/test/property/arbitraries/candid/recursive/values_arb.ts +43 -0
- package/src/experimental/test/property/arbitraries/candid/reference/func_arb/definition_arb.ts +198 -0
- package/src/experimental/test/property/arbitraries/candid/reference/func_arb/index.ts +23 -0
- package/src/experimental/test/property/arbitraries/candid/reference/func_arb/values_arb.ts +70 -0
- package/src/experimental/test/property/arbitraries/candid/reference/principal_arb.ts +43 -0
- package/src/experimental/test/property/arbitraries/candid/reference/service_arb/definition_arb.ts +163 -0
- package/src/experimental/test/property/arbitraries/candid/reference/service_arb/index.ts +41 -0
- package/src/experimental/test/property/arbitraries/candid/reference/service_arb/service_method_arb.ts +110 -0
- package/src/experimental/test/property/arbitraries/candid/reference/service_arb/values_arb.ts +20 -0
- package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/candid_type_to_azle_candid_type.ts +66 -0
- package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/definition_arb.ts +95 -0
- package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/values_arb.ts +19 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/bigint.ts +5 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/blob.ts +5 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/boolean.ts +5 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/float.ts +18 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/null.ts +5 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/number.ts +5 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/principal.ts +7 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/string.ts +12 -0
- package/src/experimental/test/property/arbitraries/candid/to_src_literal/void.ts +5 -0
- package/src/experimental/test/property/arbitraries/canister_arb.ts +195 -0
- package/src/experimental/test/property/arbitraries/canister_methods/index.ts +79 -0
- package/src/experimental/test/property/arbitraries/canister_methods/init_method_arb.ts +127 -0
- package/src/experimental/test/property/arbitraries/canister_methods/inspect_message_method_arb.ts +55 -0
- package/src/experimental/test/property/arbitraries/canister_methods/post_upgrade_method_arb.ts +133 -0
- package/src/experimental/test/property/arbitraries/canister_methods/pre_upgrade_method_arb.ts +57 -0
- package/src/experimental/test/property/arbitraries/canister_methods/query_method_arb.ts +141 -0
- package/src/experimental/test/property/arbitraries/canister_methods/update_method_arb.ts +158 -0
- package/src/experimental/test/property/arbitraries/config.ts +4 -0
- package/src/experimental/test/property/arbitraries/http/body_arb.ts +7 -0
- package/src/experimental/test/property/arbitraries/http/headers_arb.ts +22 -0
- package/src/experimental/test/property/arbitraries/http/request_arb.ts +158 -0
- package/src/experimental/test/property/arbitraries/http/response_arb.ts +192 -0
- package/src/experimental/test/property/arbitraries/js_name_arb.ts +144 -0
- package/src/experimental/test/property/arbitraries/stable_b_tree_map_arb.ts +55 -0
- package/src/experimental/test/property/arbitraries/types.ts +24 -0
- package/src/experimental/test/property/arbitraries/unique_identifier_arb.ts +38 -0
- package/src/experimental/test/property/arbitraries/unique_primitive_arb.ts +22 -0
- package/src/experimental/test/property/are_params_correctly_ordered.ts +19 -0
- package/src/experimental/test/property/get_actor.ts +39 -0
- package/src/experimental/test/property/index.ts +141 -0
- package/src/experimental/test/property/test/index.ts +226 -0
- package/src/experimental/test/property/visitors/LICENCE +201 -0
- package/src/experimental/test/property/visitors/cli-string-visitor.ts +138 -0
- package/src/experimental/test/set_experimental.ts +1 -0
- package/src/exports/_internal/dfx.ts +1 -0
- package/src/exports/_internal/globals.ts +1 -0
- package/src/exports/_internal/test/candid_deep_equal.ts +1 -0
- package/src/exports/_internal/test.ts +1 -0
- package/src/exports/_internal/type_tests/assert_type.ts +1 -0
- package/src/exports/_internal.ts +1 -0
- package/src/exports/canisters/ck_btc_ledger/idl.ts +1 -0
- package/src/exports/canisters/ck_eth_ledger/idl.ts +1 -0
- package/src/exports/canisters/cycles_ledger/idl.ts +1 -0
- package/src/exports/canisters/evm_rpc/idl.ts +1 -0
- package/src/exports/canisters/exchange_rate/idl.ts +1 -0
- package/src/exports/canisters/http_gateway/idl.ts +1 -0
- package/src/exports/canisters/icrc_1/idl.ts +1 -0
- package/src/exports/canisters/icrc_10/idl.ts +1 -0
- package/src/exports/canisters/icrc_2/idl.ts +1 -0
- package/src/exports/canisters/icrc_3/idl.ts +1 -0
- package/src/exports/canisters/icrc_37/idl.ts +1 -0
- package/src/exports/canisters/icrc_7/idl.ts +1 -0
- package/src/exports/canisters/llm/idl.ts +1 -0
- package/src/exports/canisters/management/idl.ts +1 -0
- package/src/exports/canisters/nns_cycles_minting/idl.ts +1 -0
- package/src/exports/canisters/nns_governance/idl.ts +1 -0
- package/src/exports/canisters/nns_icp_ledger/idl.ts +1 -0
- package/src/exports/canisters/nns_internet_identity/idl.ts +1 -0
- package/src/exports/canisters/nns_registry/idl.ts +1 -0
- package/src/exports/canisters/nns_sns_w/idl.ts +1 -0
- package/src/exports/experimental/_internal/dfx.ts +1 -0
- package/src/exports/experimental/_internal/globals.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_definition_arb/types.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_definition_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_return_type_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_value_and_meta_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_value_and_meta_arb_generator.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_values_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/blob_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/opt_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/record_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/tuple_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/variant_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/vec_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/corresponding_js_type.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/bool_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/floats/float32_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/floats/float64_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int16_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int32_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int64_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int8_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat16_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat32_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat64_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat8_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/null_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/text_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/void_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/recursive.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/func_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/principal_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/service_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/init_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/inspect_message_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/post_upgrade_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/pre_upgrade_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/query_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/update_method_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/config.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/http/body_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/http/headers_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/http/request_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/http/response_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/stable_b_tree_map_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/types.ts +1 -0
- package/src/exports/experimental/_internal/test/property/arbitraries/unique_identifier_arb.ts +1 -0
- package/src/exports/experimental/_internal/test/property/are_params_correctly_ordered.ts +1 -0
- package/src/exports/experimental/_internal/test/property/test.ts +1 -0
- package/src/exports/experimental/_internal/test/property.ts +1 -0
- package/src/exports/experimental/_internal/test/set_experimental.ts +1 -0
- package/src/exports/experimental/_internal.ts +8 -0
- package/src/exports/experimental/http_client.ts +1 -0
- package/src/exports/experimental.ts +3 -0
- package/src/stable/build/commands/build/candid_and_method_meta/execute.ts +134 -0
- package/src/stable/build/commands/build/candid_and_method_meta/index.ts +27 -0
- package/src/stable/build/commands/build/get_context.ts +79 -0
- package/src/stable/build/commands/build/index.ts +48 -0
- package/src/stable/build/commands/build/javascript.ts +259 -0
- package/src/stable/build/commands/build/wasm_binary/compile.ts +27 -0
- package/src/stable/build/commands/build/wasm_binary/index.ts +30 -0
- package/src/stable/build/commands/build/wasm_binary/manipulate.ts +268 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/Cargo.toml +23 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/benchmarking.rs +45 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/candid_and_method_meta.rs +49 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/execute_method_js.rs +65 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/guards.rs +11 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/call_raw.rs +362 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/candid_decode.rs +18 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/candid_encode.rs +19 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_cycle_balance.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_self.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_version.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/certified_data_set.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/clear_timer.rs +15 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/cycles_burn.rs +17 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/data_certificate.rs +13 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/debug_print.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/drain_microtasks.rs +22 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/in_replicated_execution.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/is_controller.rs +11 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/mod.rs +219 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_arg_data.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_caller.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_accept.rs +17 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_available.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_refunded.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_method_name.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject_code.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject_msg.rs +6 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reply.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/notify_raw.rs +62 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/performance_counter.rs +17 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/rand_bytes.rs +21 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/rand_seed.rs +26 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/set_timer.rs +92 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/set_timer_interval.rs +62 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_contains_key.rs +18 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_get.rs +21 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_init.rs +19 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_insert.rs +44 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_is_empty.rs +11 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_items.rs +48 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_keys.rs +43 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_len.rs +16 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_remove.rs +21 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_values.rs +43 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/time.rs +8 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/trap.rs +22 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/init_and_post_upgrade.rs +98 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/initialize_context.rs +102 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/internal_canister_methods.rs +122 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/lib.rs +39 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/call_with_error_handling.rs +26 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/error.rs +27 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/mod.rs +7 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/with_ctx.rs +24 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/stable_b_tree_map.rs +84 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/state.rs +55 -0
- package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/wasm_binary_manipulation.rs +296 -0
- package/src/stable/build/commands/clean.ts +15 -0
- package/src/stable/build/commands/dev/audit.ts +39 -0
- package/src/stable/build/commands/dev/setup/index.ts +41 -0
- package/src/stable/build/commands/dev/setup/install_cargo-audit.sh +11 -0
- package/src/stable/build/commands/dev/setup/install_cargo-auditable.sh +16 -0
- package/src/stable/build/commands/dev/setup/install_cargo-bundle-licenses.sh +11 -0
- package/src/stable/build/commands/dev/setup/install_cargo-deny.sh +11 -0
- package/src/stable/build/commands/dev/setup/install_dfx.sh +36 -0
- package/src/stable/build/commands/dev/setup/install_node.sh +25 -0
- package/src/stable/build/commands/dev/setup/install_rust.sh +24 -0
- package/src/stable/build/commands/dev/setup/install_wasi2ic.sh +11 -0
- package/src/stable/build/commands/dev/template/experimental.ts +28 -0
- package/src/stable/build/commands/dev/template/generate_licenses.ts +28 -0
- package/src/stable/build/commands/dev/template/stable.ts +27 -0
- package/src/stable/build/commands/extension/install.ts +25 -0
- package/src/stable/build/commands/generate/index.ts +21 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/Cargo.toml +12 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/build.sh +9 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/licenses.md +1 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js.d.ts +18 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js.js +144 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js_bg.wasm +0 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js_bg.wasm.d.ts +9 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/package.json +11 -0
- package/src/stable/build/commands/generate/rust/candid_to_ts_js/src/lib.rs +31 -0
- package/src/stable/build/commands/new.ts +165 -0
- package/src/stable/build/commands/version.ts +5 -0
- package/src/stable/build/dfx_extension/extension.json +36 -0
- package/src/stable/build/dfx_extension/install.sh +10 -0
- package/src/stable/build/index.ts +282 -0
- package/src/stable/build/utils/dfx.ts +10 -0
- package/src/stable/build/utils/dfx_root.ts +34 -0
- package/src/stable/build/utils/exec_sync_pretty.ts +17 -0
- package/src/stable/build/utils/experimental_message.ts +19 -0
- package/src/stable/build/utils/get_canister_config.ts +52 -0
- package/src/stable/build/utils/global_paths.ts +26 -0
- package/src/stable/build/utils/types.ts +87 -0
- package/src/stable/lib/canister_methods/heartbeat.ts +29 -0
- package/src/stable/lib/canister_methods/index.ts +405 -0
- package/src/stable/lib/canister_methods/init.ts +71 -0
- package/src/stable/lib/canister_methods/inspect_message.ts +79 -0
- package/src/stable/lib/canister_methods/on_low_wasm_memory.ts +27 -0
- package/src/stable/lib/canister_methods/post_upgrade.ts +73 -0
- package/src/stable/lib/canister_methods/pre_upgrade.ts +27 -0
- package/src/stable/lib/canister_methods/query.ts +69 -0
- package/src/stable/lib/canister_methods/update.ts +66 -0
- package/src/stable/lib/canisters/NOTICE +15 -0
- package/src/stable/lib/canisters/ck_btc_ledger/idl/README.md +9 -0
- package/src/stable/lib/canisters/ck_btc_ledger/idl/index.did +289 -0
- package/src/stable/lib/canisters/ck_btc_ledger/idl/index.ts +1143 -0
- package/src/stable/lib/canisters/ck_eth_ledger/idl/README.md +9 -0
- package/src/stable/lib/canisters/ck_eth_ledger/idl/index.did +289 -0
- package/src/stable/lib/canisters/ck_eth_ledger/idl/index.ts +1143 -0
- package/src/stable/lib/canisters/cycles_ledger/idl/README.md +9 -0
- package/src/stable/lib/canisters/cycles_ledger/idl/index.did +272 -0
- package/src/stable/lib/canisters/cycles_ledger/idl/index.ts +978 -0
- package/src/stable/lib/canisters/evm_rpc/idl/README.md +9 -0
- package/src/stable/lib/canisters/evm_rpc/idl/index.did +311 -0
- package/src/stable/lib/canisters/evm_rpc/idl/index.ts +1028 -0
- package/src/stable/lib/canisters/exchange_rate/idl/README.md +9 -0
- package/src/stable/lib/canisters/exchange_rate/idl/index.did +83 -0
- package/src/stable/lib/canisters/exchange_rate/idl/index.ts +165 -0
- package/src/stable/lib/canisters/http_gateway/idl/README.md +9 -0
- package/src/stable/lib/canisters/http_gateway/idl/http-gateway.did +49 -0
- package/src/stable/lib/canisters/http_gateway/idl/index.ts +120 -0
- package/src/stable/lib/canisters/icrc_1/idl/ICRC-1.did +63 -0
- package/src/stable/lib/canisters/icrc_1/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_1/idl/index.ts +151 -0
- package/src/stable/lib/canisters/icrc_10/idl/ICRC-10.did +8 -0
- package/src/stable/lib/canisters/icrc_10/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_10/idl/index.ts +32 -0
- package/src/stable/lib/canisters/icrc_2/idl/ICRC-2.did +76 -0
- package/src/stable/lib/canisters/icrc_2/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_2/idl/index.ts +226 -0
- package/src/stable/lib/canisters/icrc_3/idl/ICRC-3.did +59 -0
- package/src/stable/lib/canisters/icrc_3/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_3/idl/index.ts +156 -0
- package/src/stable/lib/canisters/icrc_37/idl/ICRC-37.did +152 -0
- package/src/stable/lib/canisters/icrc_37/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_37/idl/index.ts +466 -0
- package/src/stable/lib/canisters/icrc_7/idl/ICRC-7.did +67 -0
- package/src/stable/lib/canisters/icrc_7/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/icrc_7/idl/index.ts +213 -0
- package/src/stable/lib/canisters/llm/idl/README.md +9 -0
- package/src/stable/lib/canisters/llm/idl/index.did +21 -0
- package/src/stable/lib/canisters/llm/idl/index.ts +43 -0
- package/src/stable/lib/canisters/management/idl/README.md +10 -0
- package/src/stable/lib/canisters/management/idl/ic.did +502 -0
- package/src/stable/lib/canisters/management/idl/index.ts +1257 -0
- package/src/stable/lib/canisters/nns_cycles_minting/idl/README.md +9 -0
- package/src/stable/lib/canisters/nns_cycles_minting/idl/index.did +241 -0
- package/src/stable/lib/canisters/nns_cycles_minting/idl/index.ts +394 -0
- package/src/stable/lib/canisters/nns_governance/idl/README.md +9 -0
- package/src/stable/lib/canisters/nns_governance/idl/index.did +1316 -0
- package/src/stable/lib/canisters/nns_governance/idl/index.ts +3599 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/LICENSE +202 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/NOTICE +14 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/README.md +18 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/address/index.ts +82 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/index.did +264 -0
- package/src/stable/lib/canisters/nns_icp_ledger/idl/index.ts +1020 -0
- package/src/stable/lib/canisters/nns_internet_identity/idl/README.md +9 -0
- package/src/stable/lib/canisters/nns_internet_identity/idl/index.did +779 -0
- package/src/stable/lib/canisters/nns_internet_identity/idl/index.ts +1509 -0
- package/src/stable/lib/canisters/nns_registry/idl/README.md +9 -0
- package/src/stable/lib/canisters/nns_registry/idl/index.did +493 -0
- package/src/stable/lib/canisters/nns_registry/idl/index.ts +1421 -0
- package/src/stable/lib/canisters/nns_sns_w/idl/README.md +9 -0
- package/src/stable/lib/canisters/nns_sns_w/idl/index.did +352 -0
- package/src/stable/lib/canisters/nns_sns_w/idl/index.ts +887 -0
- package/src/stable/lib/did_file/idl_to_string.ts +79 -0
- package/src/stable/lib/did_file/index.ts +2 -0
- package/src/stable/lib/did_file/visitor/did_visitor.ts +135 -0
- package/src/stable/lib/did_file/visitor/escape_candid_name.ts +100 -0
- package/src/stable/lib/did_file/visitor/extract_candid.ts +31 -0
- package/src/stable/lib/did_file/visitor/index.ts +1 -0
- package/src/stable/lib/did_file/visitor/visit/func.ts +31 -0
- package/src/stable/lib/did_file/visitor/visit/opt.ts +16 -0
- package/src/stable/lib/did_file/visitor/visit/primitive.ts +11 -0
- package/src/stable/lib/did_file/visitor/visit/record.ts +24 -0
- package/src/stable/lib/did_file/visitor/visit/recursive.ts +32 -0
- package/src/stable/lib/did_file/visitor/visit/service.ts +107 -0
- package/src/stable/lib/did_file/visitor/visit/tuple.ts +20 -0
- package/src/stable/lib/did_file/visitor/visit/variant.ts +26 -0
- package/src/stable/lib/did_file/visitor/visit/vec.ts +16 -0
- package/src/stable/lib/error.ts +55 -0
- package/src/stable/lib/execute_and_reply_with_candid_serde.ts +245 -0
- package/src/stable/lib/func.ts +7 -0
- package/src/stable/lib/globals.ts +250 -0
- package/src/stable/lib/ic_apis/NOTICE +203 -0
- package/src/stable/lib/ic_apis/azle_ic_stable.ts +86 -0
- package/src/stable/lib/ic_apis/call.ts +397 -0
- package/src/stable/lib/ic_apis/candid_decode.ts +26 -0
- package/src/stable/lib/ic_apis/candid_encode.ts +27 -0
- package/src/stable/lib/ic_apis/canister_cycle_balance.ts +28 -0
- package/src/stable/lib/ic_apis/canister_self.ts +25 -0
- package/src/stable/lib/ic_apis/canister_version.ts +33 -0
- package/src/stable/lib/ic_apis/certified_data_set.ts +35 -0
- package/src/stable/lib/ic_apis/chunk.ts +42 -0
- package/src/stable/lib/ic_apis/clear_timer.ts +53 -0
- package/src/stable/lib/ic_apis/cycles_burn.ts +32 -0
- package/src/stable/lib/ic_apis/data_certificate.ts +30 -0
- package/src/stable/lib/ic_apis/in_replicated_execution.ts +20 -0
- package/src/stable/lib/ic_apis/index.ts +37 -0
- package/src/stable/lib/ic_apis/is_controller.ts +31 -0
- package/src/stable/lib/ic_apis/msg_arg_data.ts +28 -0
- package/src/stable/lib/ic_apis/msg_caller.ts +32 -0
- package/src/stable/lib/ic_apis/msg_cycles_accept.ts +27 -0
- package/src/stable/lib/ic_apis/msg_cycles_available.ts +25 -0
- package/src/stable/lib/ic_apis/msg_cycles_refunded.ts +25 -0
- package/src/stable/lib/ic_apis/msg_method_name.ts +21 -0
- package/src/stable/lib/ic_apis/msg_reject.ts +28 -0
- package/src/stable/lib/ic_apis/msg_reject_code.ts +40 -0
- package/src/stable/lib/ic_apis/msg_reject_msg.ts +24 -0
- package/src/stable/lib/ic_apis/msg_reply.ts +34 -0
- package/src/stable/lib/ic_apis/performance_counter.ts +31 -0
- package/src/stable/lib/ic_apis/rand_seed.ts +40 -0
- package/src/stable/lib/ic_apis/set_timer.ts +80 -0
- package/src/stable/lib/ic_apis/set_timer_interval.ts +87 -0
- package/src/stable/lib/ic_apis/time.ts +26 -0
- package/src/stable/lib/ic_apis/trap.ts +29 -0
- package/src/stable/lib/index.ts +16 -0
- package/src/stable/lib/json.ts +39 -0
- package/src/stable/lib/stable_structures/stable_b_tree_map.ts +488 -0
- package/src/stable/lib/stable_structures/stable_json.ts +254 -0
- package/src/stable/lib/state.ts +322 -0
- package/src/stable/test/benchmarks/_azle_get_benchmarks.did +9 -0
- package/src/stable/test/benchmarks/index.ts +273 -0
- package/src/stable/test/candid_deep_equal.ts +99 -0
- package/src/stable/test/canister_names.ts +36 -0
- package/src/stable/test/fuzz.ts +102 -0
- package/src/stable/test/get_canister_actor.ts +45 -0
- package/src/stable/test/global_state.ts +202 -0
- package/src/stable/test/index.ts +274 -0
- package/src/stable/test/memory_state.ts +187 -0
- package/src/stable/test/property/default_prop_test_params.ts +36 -0
- package/src/stable/test/type/assert_type.ts +9 -0
- package/tsconfig.dev.json +10 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
use crate::chunk;
|
|
2
|
+
use crate::upload_file::bytes_to_human_readable;
|
|
3
|
+
use crate::upload_file::file_info;
|
|
4
|
+
use crate::upload_file::hash;
|
|
5
|
+
use crate::upload_file::reset;
|
|
6
|
+
use crate::upload_file::Timestamp;
|
|
7
|
+
|
|
8
|
+
pub async fn upload_file_chunk(
|
|
9
|
+
dest_path: String,
|
|
10
|
+
timestamp: u64,
|
|
11
|
+
start_index: u64,
|
|
12
|
+
file_bytes: Vec<u8>,
|
|
13
|
+
total_file_len: u64,
|
|
14
|
+
) {
|
|
15
|
+
let is_latest_version = check_if_latest_version(&dest_path, timestamp);
|
|
16
|
+
|
|
17
|
+
if !is_latest_version {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let uploaded_file_len =
|
|
22
|
+
write_chunk(&dest_path, file_bytes, start_index, total_file_len).unwrap();
|
|
23
|
+
|
|
24
|
+
let percentage_complete = uploaded_file_len as f64 / total_file_len.max(1) as f64 * 100.0;
|
|
25
|
+
ic_cdk::println!(
|
|
26
|
+
"Received chunk: {} | {}/{} : {:.2}%",
|
|
27
|
+
dest_path,
|
|
28
|
+
bytes_to_human_readable::bytes_to_human_readable(uploaded_file_len),
|
|
29
|
+
bytes_to_human_readable::bytes_to_human_readable(total_file_len),
|
|
30
|
+
percentage_complete
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if uploaded_file_len == total_file_len {
|
|
34
|
+
chunk::chunk().await;
|
|
35
|
+
hash::hash_file(&dest_path).await;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fn check_if_latest_version(dest_path: &str, current_timestamp: Timestamp) -> bool {
|
|
40
|
+
let last_recorded_timestamp = file_info::get_timestamp(dest_path);
|
|
41
|
+
|
|
42
|
+
if current_timestamp < last_recorded_timestamp {
|
|
43
|
+
// The request is from an earlier upload attempt. Disregard
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if current_timestamp > last_recorded_timestamp {
|
|
48
|
+
// The request is from a newer upload attempt. Clean up the previous attempt.
|
|
49
|
+
reset::reset_for_new_upload(dest_path, current_timestamp).unwrap();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Adds the given file_bytes to the chunked file at the chunk number position.
|
|
56
|
+
// Returns the new total length of chunked file after the addition
|
|
57
|
+
fn write_chunk(
|
|
58
|
+
path: &str,
|
|
59
|
+
file_bytes: Vec<u8>,
|
|
60
|
+
start_index: u64,
|
|
61
|
+
file_len: u64,
|
|
62
|
+
) -> std::io::Result<u64> {
|
|
63
|
+
match std::path::Path::new(path).parent() {
|
|
64
|
+
Some(dir_path) => std::fs::create_dir_all(dir_path)?,
|
|
65
|
+
None => (), //Dir doesn't need to be created
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let mut file: std::fs::File = match std::fs::OpenOptions::new().write(true).open(path) {
|
|
69
|
+
Ok(file) => file,
|
|
70
|
+
Err(_) => init_file(path, file_len)?,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
std::io::Seek::seek(&mut file, std::io::SeekFrom::Start(start_index))?;
|
|
74
|
+
std::io::Write::write_all(&mut file, &file_bytes)?;
|
|
75
|
+
drop(file);
|
|
76
|
+
|
|
77
|
+
Ok(file_info::set_bytes_received(path, file_bytes.len()))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn init_file(path: &str, file_len: u64) -> std::io::Result<std::fs::File> {
|
|
81
|
+
let new_file = std::fs::OpenOptions::new()
|
|
82
|
+
.create(true)
|
|
83
|
+
.write(true)
|
|
84
|
+
.truncate(true)
|
|
85
|
+
.open(&path)?;
|
|
86
|
+
new_file.set_len(file_len)?;
|
|
87
|
+
Ok(new_file)
|
|
88
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
use core::ptr::read_volatile;
|
|
2
|
+
|
|
3
|
+
use serde::{Deserialize, Serialize};
|
|
4
|
+
|
|
5
|
+
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
6
|
+
pub struct WasmData {
|
|
7
|
+
#[serde(rename = "envVars")]
|
|
8
|
+
pub env_vars: Vec<(String, String)>,
|
|
9
|
+
#[serde(rename = "mainJsPath")]
|
|
10
|
+
pub main_js_path: String,
|
|
11
|
+
#[serde(rename = "managementDid")]
|
|
12
|
+
pub management_did: String,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[inline(never)]
|
|
16
|
+
#[unsafe(no_mangle)]
|
|
17
|
+
extern "C" fn init_js_passive_data(js_vec_location: i32) {
|
|
18
|
+
// Without something like this to make the function bodies different,
|
|
19
|
+
// the init_js_passive_data and init_wasm_data_passive_data functions
|
|
20
|
+
// seem to be optimized into the same function in the Wasm binary
|
|
21
|
+
// This causes problems during Wasm binary manipulation
|
|
22
|
+
let _ = format!("prevent init_js_passive_data and init_wasm_data_passive_data optimization");
|
|
23
|
+
|
|
24
|
+
// This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
|
|
25
|
+
unsafe { read_volatile(&js_vec_location) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Used to provide a safe value for the read_volatile and to differentiate between the
|
|
29
|
+
// js_passive_data_size and wasm_data_passive_data_size function bodies
|
|
30
|
+
// Without this problems happen during Wasm binary manipulation
|
|
31
|
+
static JS_PASSIVE_DATA_SIZE: usize = 0;
|
|
32
|
+
|
|
33
|
+
#[inline(never)]
|
|
34
|
+
#[unsafe(no_mangle)]
|
|
35
|
+
extern "C" fn js_passive_data_size() -> usize {
|
|
36
|
+
// This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
|
|
37
|
+
unsafe { read_volatile(&JS_PASSIVE_DATA_SIZE) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Inspired from: https://github.com/adambratschikaye/wasm-inject-data/blob/main/src/static_wasm.rs
|
|
41
|
+
// Most likely a derivative work licensed under the Apache License, Version 2.0: https://github.com/adambratschikaye/wasm-inject-data/blob/main/LICENSE
|
|
42
|
+
pub fn get_js_code() -> Vec<u8> {
|
|
43
|
+
let size = js_passive_data_size();
|
|
44
|
+
let mut js_vec = vec![243; size];
|
|
45
|
+
let js_vec_location = js_vec.as_mut_ptr() as i32;
|
|
46
|
+
|
|
47
|
+
init_js_passive_data(js_vec_location);
|
|
48
|
+
|
|
49
|
+
js_vec
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[inline(never)]
|
|
53
|
+
#[unsafe(no_mangle)]
|
|
54
|
+
extern "C" fn init_wasm_data_passive_data(wasm_data_vec_location: i32) {
|
|
55
|
+
// This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
|
|
56
|
+
unsafe { read_volatile(&wasm_data_vec_location) };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Used to provide a safe value for the read_volatile and to differentiate between the
|
|
60
|
+
// js_passive_data_size and wasm_data_passive_data_size function bodies
|
|
61
|
+
// Without this problems happen during Wasm binary manipulation
|
|
62
|
+
static WASM_DATA_PASSIVE_DATA_SIZE: usize = 0;
|
|
63
|
+
|
|
64
|
+
#[inline(never)]
|
|
65
|
+
#[unsafe(no_mangle)]
|
|
66
|
+
extern "C" fn wasm_data_passive_data_size() -> usize {
|
|
67
|
+
// This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
|
|
68
|
+
unsafe { read_volatile(&WASM_DATA_PASSIVE_DATA_SIZE) }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Inspired from: https://github.com/adambratschikaye/wasm-inject-data/blob/main/src/static_wasm.rs
|
|
72
|
+
// Most likely a derivative work licensed under the Apache License, Version 2.0: https://github.com/adambratschikaye/wasm-inject-data/blob/main/LICENSE
|
|
73
|
+
pub fn get_wasm_data() -> WasmData {
|
|
74
|
+
let size = wasm_data_passive_data_size();
|
|
75
|
+
let mut wasm_data_vec = vec![243; size];
|
|
76
|
+
let wasm_data_vec_location = wasm_data_vec.as_mut_ptr() as i32;
|
|
77
|
+
|
|
78
|
+
init_wasm_data_passive_data(wasm_data_vec_location);
|
|
79
|
+
|
|
80
|
+
serde_json::from_str(std::str::from_utf8(&wasm_data_vec).unwrap()).unwrap()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// For get_js_code and get_wasm_data above:
|
|
84
|
+
|
|
85
|
+
// Copyright © 2024 DFINITY Foundation
|
|
86
|
+
|
|
87
|
+
// Each file in this repository is licensed under the license as
|
|
88
|
+
// described in the LICENSE file in the same directory that contains the
|
|
89
|
+
// file or, if that doesn't exist, the first LICENSE file in any
|
|
90
|
+
// higher-level directory.
|
|
91
|
+
|
|
92
|
+
// Unless stated otherwise as described above, all files in this
|
|
93
|
+
// directory are licensed under the Apache License, Version 2.0 (the
|
|
94
|
+
// "License"); you may not use these files except in compliance with the
|
|
95
|
+
// License. You may obtain a copy of the License at
|
|
96
|
+
|
|
97
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
98
|
+
|
|
99
|
+
// The Apache-2.0 license is also copied below:
|
|
100
|
+
|
|
101
|
+
// Apache License
|
|
102
|
+
// Version 2.0, January 2004
|
|
103
|
+
// http://www.apache.org/licenses/
|
|
104
|
+
|
|
105
|
+
// TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
106
|
+
|
|
107
|
+
// 1. Definitions.
|
|
108
|
+
|
|
109
|
+
// "License" shall mean the terms and conditions for use, reproduction,
|
|
110
|
+
// and distribution as defined by Sections 1 through 9 of this document.
|
|
111
|
+
|
|
112
|
+
// "Licensor" shall mean the copyright owner or entity authorized by
|
|
113
|
+
// the copyright owner that is granting the License.
|
|
114
|
+
|
|
115
|
+
// "Legal Entity" shall mean the union of the acting entity and all
|
|
116
|
+
// other entities that control, are controlled by, or are under common
|
|
117
|
+
// control with that entity. For the purposes of this definition,
|
|
118
|
+
// "control" means (i) the power, direct or indirect, to cause the
|
|
119
|
+
// direction or management of such entity, whether by contract or
|
|
120
|
+
// otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
121
|
+
// outstanding shares, or (iii) beneficial ownership of such entity.
|
|
122
|
+
|
|
123
|
+
// "You" (or "Your") shall mean an individual or Legal Entity
|
|
124
|
+
// exercising permissions granted by this License.
|
|
125
|
+
|
|
126
|
+
// "Source" form shall mean the preferred form for making modifications,
|
|
127
|
+
// including but not limited to software source code, documentation
|
|
128
|
+
// source, and configuration files.
|
|
129
|
+
|
|
130
|
+
// "Object" form shall mean any form resulting from mechanical
|
|
131
|
+
// transformation or translation of a Source form, including but
|
|
132
|
+
// not limited to compiled object code, generated documentation,
|
|
133
|
+
// and conversions to other media types.
|
|
134
|
+
|
|
135
|
+
// "Work" shall mean the work of authorship, whether in Source or
|
|
136
|
+
// Object form, made available under the License, as indicated by a
|
|
137
|
+
// copyright notice that is included in or attached to the work
|
|
138
|
+
// (an example is provided in the Appendix below).
|
|
139
|
+
|
|
140
|
+
// "Derivative Works" shall mean any work, whether in Source or Object
|
|
141
|
+
// form, that is based on (or derived from) the Work and for which the
|
|
142
|
+
// editorial revisions, annotations, elaborations, or other modifications
|
|
143
|
+
// represent, as a whole, an original work of authorship. For the purposes
|
|
144
|
+
// of this License, Derivative Works shall not include works that remain
|
|
145
|
+
// separable from, or merely link (or bind by name) to the interfaces of,
|
|
146
|
+
// the Work and Derivative Works thereof.
|
|
147
|
+
|
|
148
|
+
// "Contribution" shall mean any work of authorship, including
|
|
149
|
+
// the original version of the Work and any modifications or additions
|
|
150
|
+
// to that Work or Derivative Works thereof, that is intentionally
|
|
151
|
+
// submitted to Licensor for inclusion in the Work by the copyright owner
|
|
152
|
+
// or by an individual or Legal Entity authorized to submit on behalf of
|
|
153
|
+
// the copyright owner. For the purposes of this definition, "submitted"
|
|
154
|
+
// means any form of electronic, verbal, or written communication sent
|
|
155
|
+
// to the Licensor or its representatives, including but not limited to
|
|
156
|
+
// communication on electronic mailing lists, source code control systems,
|
|
157
|
+
// and issue tracking systems that are managed by, or on behalf of, the
|
|
158
|
+
// Licensor for the purpose of discussing and improving the Work, but
|
|
159
|
+
// excluding communication that is conspicuously marked or otherwise
|
|
160
|
+
// designated in writing by the copyright owner as "Not a Contribution."
|
|
161
|
+
|
|
162
|
+
// "Contributor" shall mean Licensor and any individual or Legal Entity
|
|
163
|
+
// on behalf of whom a Contribution has been received by Licensor and
|
|
164
|
+
// subsequently incorporated within the Work.
|
|
165
|
+
|
|
166
|
+
// 2. Grant of Copyright License. Subject to the terms and conditions of
|
|
167
|
+
// this License, each Contributor hereby grants to You a perpetual,
|
|
168
|
+
// worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
169
|
+
// copyright license to reproduce, prepare Derivative Works of,
|
|
170
|
+
// publicly display, publicly perform, sublicense, and distribute the
|
|
171
|
+
// Work and such Derivative Works in Source or Object form.
|
|
172
|
+
|
|
173
|
+
// 3. Grant of Patent License. Subject to the terms and conditions of
|
|
174
|
+
// this License, each Contributor hereby grants to You a perpetual,
|
|
175
|
+
// worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
176
|
+
// (except as stated in this section) patent license to make, have made,
|
|
177
|
+
// use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
178
|
+
// where such license applies only to those patent claims licensable
|
|
179
|
+
// by such Contributor that are necessarily infringed by their
|
|
180
|
+
// Contribution(s) alone or by combination of their Contribution(s)
|
|
181
|
+
// with the Work to which such Contribution(s) was submitted. If You
|
|
182
|
+
// institute patent litigation against any entity (including a
|
|
183
|
+
// cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
184
|
+
// or a Contribution incorporated within the Work constitutes direct
|
|
185
|
+
// or contributory patent infringement, then any patent licenses
|
|
186
|
+
// granted to You under this License for that Work shall terminate
|
|
187
|
+
// as of the date such litigation is filed.
|
|
188
|
+
|
|
189
|
+
// 4. Redistribution. You may reproduce and distribute copies of the
|
|
190
|
+
// Work or Derivative Works thereof in any medium, with or without
|
|
191
|
+
// modifications, and in Source or Object form, provided that You
|
|
192
|
+
// meet the following conditions:
|
|
193
|
+
|
|
194
|
+
// (a) You must give any other recipients of the Work or
|
|
195
|
+
// Derivative Works a copy of this License; and
|
|
196
|
+
|
|
197
|
+
// (b) You must cause any modified files to carry prominent notices
|
|
198
|
+
// stating that You changed the files; and
|
|
199
|
+
|
|
200
|
+
// (c) You must retain, in the Source form of any Derivative Works
|
|
201
|
+
// that You distribute, all copyright, patent, trademark, and
|
|
202
|
+
// attribution notices from the Source form of the Work,
|
|
203
|
+
// excluding those notices that do not pertain to any part of
|
|
204
|
+
// the Derivative Works; and
|
|
205
|
+
|
|
206
|
+
// (d) If the Work includes a "NOTICE" text file as part of its
|
|
207
|
+
// distribution, then any Derivative Works that You distribute must
|
|
208
|
+
// include a readable copy of the attribution notices contained
|
|
209
|
+
// within such NOTICE file, excluding those notices that do not
|
|
210
|
+
// pertain to any part of the Derivative Works, in at least one
|
|
211
|
+
// of the following places: within a NOTICE text file distributed
|
|
212
|
+
// as part of the Derivative Works; within the Source form or
|
|
213
|
+
// documentation, if provided along with the Derivative Works; or,
|
|
214
|
+
// within a display generated by the Derivative Works, if and
|
|
215
|
+
// wherever such third-party notices normally appear. The contents
|
|
216
|
+
// of the NOTICE file are for informational purposes only and
|
|
217
|
+
// do not modify the License. You may add Your own attribution
|
|
218
|
+
// notices within Derivative Works that You distribute, alongside
|
|
219
|
+
// or as an addendum to the NOTICE text from the Work, provided
|
|
220
|
+
// that such additional attribution notices cannot be construed
|
|
221
|
+
// as modifying the License.
|
|
222
|
+
|
|
223
|
+
// You may add Your own copyright statement to Your modifications and
|
|
224
|
+
// may provide additional or different license terms and conditions
|
|
225
|
+
// for use, reproduction, or distribution of Your modifications, or
|
|
226
|
+
// for any such Derivative Works as a whole, provided Your use,
|
|
227
|
+
// reproduction, and distribution of the Work otherwise complies with
|
|
228
|
+
// the conditions stated in this License.
|
|
229
|
+
|
|
230
|
+
// 5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
231
|
+
// any Contribution intentionally submitted for inclusion in the Work
|
|
232
|
+
// by You to the Licensor shall be under the terms and conditions of
|
|
233
|
+
// this License, without any additional terms or conditions.
|
|
234
|
+
// Notwithstanding the above, nothing herein shall supersede or modify
|
|
235
|
+
// the terms of any separate license agreement you may have executed
|
|
236
|
+
// with Licensor regarding such Contributions.
|
|
237
|
+
|
|
238
|
+
// 6. Trademarks. This License does not grant permission to use the trade
|
|
239
|
+
// names, trademarks, service marks, or product names of the Licensor,
|
|
240
|
+
// except as required for reasonable and customary use in describing the
|
|
241
|
+
// origin of the Work and reproducing the content of the NOTICE file.
|
|
242
|
+
|
|
243
|
+
// 7. Disclaimer of Warranty. Unless required by applicable law or
|
|
244
|
+
// agreed to in writing, Licensor provides the Work (and each
|
|
245
|
+
// Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
246
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
247
|
+
// implied, including, without limitation, any warranties or conditions
|
|
248
|
+
// of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
249
|
+
// PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
250
|
+
// appropriateness of using or redistributing the Work and assume any
|
|
251
|
+
// risks associated with Your exercise of permissions under this License.
|
|
252
|
+
|
|
253
|
+
// 8. Limitation of Liability. In no event and under no legal theory,
|
|
254
|
+
// whether in tort (including negligence), contract, or otherwise,
|
|
255
|
+
// unless required by applicable law (such as deliberate and grossly
|
|
256
|
+
// negligent acts) or agreed to in writing, shall any Contributor be
|
|
257
|
+
// liable to You for damages, including any direct, indirect, special,
|
|
258
|
+
// incidental, or consequential damages of any character arising as a
|
|
259
|
+
// result of this License or out of the use or inability to use the
|
|
260
|
+
// Work (including but not limited to damages for loss of goodwill,
|
|
261
|
+
// work stoppage, computer failure or malfunction, or any and all
|
|
262
|
+
// other commercial damages or losses), even if such Contributor
|
|
263
|
+
// has been advised of the possibility of such damages.
|
|
264
|
+
|
|
265
|
+
// 9. Accepting Warranty or Additional Liability. While redistributing
|
|
266
|
+
// the Work or Derivative Works thereof, You may choose to offer,
|
|
267
|
+
// and charge a fee for, acceptance of support, warranty, indemnity,
|
|
268
|
+
// or other liability obligations and/or rights consistent with this
|
|
269
|
+
// License. However, in accepting such obligations, You may act only
|
|
270
|
+
// on Your own behalf and on Your sole responsibility, not on behalf
|
|
271
|
+
// of any other Contributor, and only if You agree to indemnify,
|
|
272
|
+
// defend, and hold each Contributor harmless for any liability
|
|
273
|
+
// incurred by, or claims asserted against, such Contributor by reason
|
|
274
|
+
// of your accepting any such warranty or additional liability.
|
|
275
|
+
|
|
276
|
+
// END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
use wasmedge_quickjs::{AsObject, Context, JsFn, JsValue};
|
|
2
|
+
|
|
3
|
+
use crate::web_assembly::WASM_INSTANCES;
|
|
4
|
+
|
|
5
|
+
// TODO technically this should return a promise because that the official API
|
|
6
|
+
pub struct NativeFunction;
|
|
7
|
+
impl JsFn for NativeFunction {
|
|
8
|
+
fn call(context: &mut Context, _this_val: JsValue, argv: &[JsValue]) -> JsValue {
|
|
9
|
+
let instance_uuid = if let JsValue::String(js_string) = argv.get(0).unwrap() {
|
|
10
|
+
js_string.to_string()
|
|
11
|
+
} else {
|
|
12
|
+
panic!("conversion from JsValue to JsString failed")
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let wasm_bytes = if let JsValue::ArrayBuffer(js_array_buffer) = argv.get(1).unwrap() {
|
|
16
|
+
js_array_buffer.to_vec()
|
|
17
|
+
} else {
|
|
18
|
+
panic!("conversion from JsValue to JsArrayBuffer failed")
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let engine = wasmi::Engine::default();
|
|
22
|
+
let module = wasmi::Module::new(&engine, &mut &wasm_bytes[..]).unwrap();
|
|
23
|
+
|
|
24
|
+
let linker = <wasmi::Linker<()>>::new(&engine);
|
|
25
|
+
|
|
26
|
+
let mut store = wasmi::Store::new(&engine, ());
|
|
27
|
+
|
|
28
|
+
let instance = linker
|
|
29
|
+
.instantiate(&mut store, &module)
|
|
30
|
+
.unwrap()
|
|
31
|
+
.start(&mut store)
|
|
32
|
+
.unwrap();
|
|
33
|
+
|
|
34
|
+
let mut exports_js_object = context.new_object();
|
|
35
|
+
|
|
36
|
+
for export in instance.exports(&mut store) {
|
|
37
|
+
let export_name = export.name();
|
|
38
|
+
|
|
39
|
+
exports_js_object.set(
|
|
40
|
+
export_name,
|
|
41
|
+
context
|
|
42
|
+
.wrap_function(
|
|
43
|
+
export_name,
|
|
44
|
+
move |_context: &mut Context, this_val: JsValue, argv: &[JsValue]| {
|
|
45
|
+
let this_val_js_object = this_val.to_obj().unwrap();
|
|
46
|
+
|
|
47
|
+
let instance_uuid = this_val_js_object
|
|
48
|
+
.get("instanceUuid")
|
|
49
|
+
.to_string()
|
|
50
|
+
.unwrap()
|
|
51
|
+
.to_string();
|
|
52
|
+
|
|
53
|
+
let export_name_string = this_val_js_object
|
|
54
|
+
.get("exportName")
|
|
55
|
+
.to_string()
|
|
56
|
+
.unwrap()
|
|
57
|
+
.to_string();
|
|
58
|
+
|
|
59
|
+
// TODO dealing with the host import types seems the hardest now
|
|
60
|
+
// This global static variable is required to gain access to the Wasm
|
|
61
|
+
// instance from within this native function
|
|
62
|
+
WASM_INSTANCES.with(|instances| {
|
|
63
|
+
let mut instances = instances.borrow_mut();
|
|
64
|
+
|
|
65
|
+
// TODO removing probably isn't the best way to get ownership
|
|
66
|
+
let (instance, mut the_store) =
|
|
67
|
+
instances.remove(&instance_uuid).unwrap();
|
|
68
|
+
|
|
69
|
+
let export = instance
|
|
70
|
+
.get_export(&mut the_store, &export_name_string)
|
|
71
|
+
.unwrap();
|
|
72
|
+
|
|
73
|
+
let func = export.into_func().unwrap();
|
|
74
|
+
|
|
75
|
+
let func_ty = func.ty(&mut the_store);
|
|
76
|
+
let func_param_types = func_ty.params();
|
|
77
|
+
|
|
78
|
+
// TODO check all of these conversions, they are bad
|
|
79
|
+
let params: Vec<wasmi::Val> = func_param_types
|
|
80
|
+
.iter()
|
|
81
|
+
.enumerate()
|
|
82
|
+
.map(|(index, param_value_type)| match param_value_type {
|
|
83
|
+
wasmi::core::ValType::I32 => {
|
|
84
|
+
let param_i32 = if let JsValue::Int(int) =
|
|
85
|
+
argv.get(index).unwrap()
|
|
86
|
+
{
|
|
87
|
+
int
|
|
88
|
+
} else {
|
|
89
|
+
panic!("conversion from JsValue to i32 failed")
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
wasmi::Val::I32(*param_i32)
|
|
93
|
+
}
|
|
94
|
+
wasmi::core::ValType::I64 => {
|
|
95
|
+
let param_i64 = if let JsValue::Int(int) =
|
|
96
|
+
argv.get(index).unwrap()
|
|
97
|
+
{
|
|
98
|
+
int
|
|
99
|
+
} else {
|
|
100
|
+
panic!("conversion from JsValue to i32 failed")
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
wasmi::Val::I64(*param_i64 as i64)
|
|
104
|
+
}
|
|
105
|
+
wasmi::core::ValType::F32 => {
|
|
106
|
+
let param_f64 = if let JsValue::Float(float) =
|
|
107
|
+
argv.get(index).unwrap()
|
|
108
|
+
{
|
|
109
|
+
float
|
|
110
|
+
} else {
|
|
111
|
+
panic!("conversion from JsValue to f64 failed")
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
wasmi::Val::F32((*param_f64 as f32).into())
|
|
115
|
+
}
|
|
116
|
+
wasmi::core::ValType::F64 => {
|
|
117
|
+
let param_f64 = if let JsValue::Float(float) =
|
|
118
|
+
argv.get(index).unwrap()
|
|
119
|
+
{
|
|
120
|
+
float
|
|
121
|
+
} else {
|
|
122
|
+
panic!("conversion from JsValue to f64 failed")
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
wasmi::Val::F64((*param_f64).into())
|
|
126
|
+
}
|
|
127
|
+
wasmi::core::ValType::FuncRef => todo!(),
|
|
128
|
+
wasmi::core::ValType::ExternRef => todo!(),
|
|
129
|
+
wasmi::core::ValType::V128 => todo!(),
|
|
130
|
+
})
|
|
131
|
+
.collect();
|
|
132
|
+
|
|
133
|
+
// TODO Can a Wasm exported function return more than one result?
|
|
134
|
+
// TODO I am confused on this point, for now I'll just return
|
|
135
|
+
// TODO the first result
|
|
136
|
+
let func_result_types = func_ty.results();
|
|
137
|
+
|
|
138
|
+
let mut buf: Vec<wasmi::Val> =
|
|
139
|
+
vec![
|
|
140
|
+
wasmi::Val::default(wasmi::core::ValType::I32);
|
|
141
|
+
func_result_types.len()
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
func.call(&mut the_store, ¶ms, &mut buf[..]).unwrap();
|
|
145
|
+
|
|
146
|
+
// TODO this probably is not the most elegant way to get ownership
|
|
147
|
+
instances.insert(instance_uuid, (instance, the_store));
|
|
148
|
+
|
|
149
|
+
// TODO check all of these conversions, they are bad
|
|
150
|
+
match func_result_types.get(0).unwrap() {
|
|
151
|
+
wasmi::core::ValType::I32 => {
|
|
152
|
+
JsValue::Int(buf.get(0).unwrap().i32().unwrap())
|
|
153
|
+
}
|
|
154
|
+
wasmi::core::ValType::I64 => {
|
|
155
|
+
JsValue::Int(buf.get(0).unwrap().i64().unwrap() as i32)
|
|
156
|
+
// TODO should this not be a bigint?
|
|
157
|
+
}
|
|
158
|
+
wasmi::core::ValType::F32 => {
|
|
159
|
+
let f32_val = buf.get(0).unwrap().f32().unwrap();
|
|
160
|
+
let native_f32: f32 = f32_val.into();
|
|
161
|
+
JsValue::Float(f64::from(native_f32))
|
|
162
|
+
}
|
|
163
|
+
wasmi::core::ValType::F64 => {
|
|
164
|
+
let f64_val = buf.get(0).unwrap().f64().unwrap();
|
|
165
|
+
|
|
166
|
+
JsValue::Float(f64_val.into())
|
|
167
|
+
}
|
|
168
|
+
wasmi::core::ValType::FuncRef => todo!(),
|
|
169
|
+
wasmi::core::ValType::ExternRef => todo!(),
|
|
170
|
+
wasmi::core::ValType::V128 => todo!(),
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
)
|
|
175
|
+
.into(),
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
WASM_INSTANCES.with(|instances| {
|
|
180
|
+
let mut instances = instances.borrow_mut();
|
|
181
|
+
|
|
182
|
+
instances.insert(instance_uuid, (instance, store));
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
let mut instance_js_object = context.new_object();
|
|
186
|
+
|
|
187
|
+
instance_js_object.set("exports", exports_js_object.into());
|
|
188
|
+
|
|
189
|
+
let mut instantiated_source_js_object = context.new_object();
|
|
190
|
+
|
|
191
|
+
instantiated_source_js_object.set("instance", instance_js_object.into());
|
|
192
|
+
|
|
193
|
+
instantiated_source_js_object.into()
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
use std::{cell::RefCell, collections::HashMap};
|
|
2
|
+
use wasmedge_quickjs::AsObject;
|
|
3
|
+
|
|
4
|
+
mod instantiate;
|
|
5
|
+
|
|
6
|
+
thread_local! {
|
|
7
|
+
static WASM_INSTANCES: RefCell<HashMap<String, (wasmi::Instance, wasmi::Store<()>)>> = RefCell::new(HashMap::new());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#[allow(unused)]
|
|
11
|
+
pub fn register(context: &mut wasmedge_quickjs::Context) {
|
|
12
|
+
let mut web_assembly = context.new_object();
|
|
13
|
+
|
|
14
|
+
web_assembly.set(
|
|
15
|
+
"instantiate",
|
|
16
|
+
context
|
|
17
|
+
.new_function::<instantiate::NativeFunction>("instantiate")
|
|
18
|
+
.into(),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
context
|
|
22
|
+
.get_global()
|
|
23
|
+
.set("_azleWebAssembly", web_assembly.into());
|
|
24
|
+
}
|
package/src/experimental/build/commands/upload_assets/file_uploader/bytes_to_human_readable.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import '#experimental/build/assert_experimental';
|
|
2
|
+
|
|
3
|
+
export function bytesToHumanReadable(sizeInBytes: number): string {
|
|
4
|
+
const suffixes = ['B', 'KiB', 'MiB', 'GiB'];
|
|
5
|
+
|
|
6
|
+
const result = suffixes.reduce(
|
|
7
|
+
(acc, suffix) => {
|
|
8
|
+
if (acc.done) {
|
|
9
|
+
return acc;
|
|
10
|
+
}
|
|
11
|
+
if (acc.size < 1024.0) {
|
|
12
|
+
return {
|
|
13
|
+
...acc,
|
|
14
|
+
unit: suffix,
|
|
15
|
+
done: true
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...acc,
|
|
20
|
+
size: acc.size / 1024.0
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
{ size: sizeInBytes, unit: '', done: false }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return `${result.size.toFixed(2)} ${result.unit}`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import '#experimental/build/assert_experimental';
|
|
2
|
+
|
|
3
|
+
import { readdir, stat } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { Dest, Src } from '.';
|
|
7
|
+
|
|
8
|
+
export async function expandPaths(
|
|
9
|
+
paths: [Src, Dest][]
|
|
10
|
+
): Promise<[string, string][]> {
|
|
11
|
+
return paths.reduce(
|
|
12
|
+
async (accPromise: Promise<[Src, Dest][]>, [srcPath, destPath]) => {
|
|
13
|
+
const acc = await accPromise;
|
|
14
|
+
return [...acc, ...(await expandPath(srcPath, destPath))];
|
|
15
|
+
},
|
|
16
|
+
Promise.resolve([])
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function expandPath(
|
|
21
|
+
srcPath: Src,
|
|
22
|
+
destPath: Dest
|
|
23
|
+
): Promise<[Src, Dest][]> {
|
|
24
|
+
const stats = await stat(srcPath);
|
|
25
|
+
if (stats.isDirectory()) {
|
|
26
|
+
return await expandDirectory(srcPath, destPath);
|
|
27
|
+
} else {
|
|
28
|
+
return [[srcPath, destPath]];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function expandDirectory(
|
|
33
|
+
srcDir: string,
|
|
34
|
+
destDir: string
|
|
35
|
+
): Promise<[Src, Dest][]> {
|
|
36
|
+
try {
|
|
37
|
+
const contents = await readdir(srcDir);
|
|
38
|
+
return contents.reduce(
|
|
39
|
+
async (accPromise: Promise<[Src, Dest][]>, name) => {
|
|
40
|
+
const acc = await accPromise;
|
|
41
|
+
const srcPath = join(srcDir, name);
|
|
42
|
+
const destPath = join(destDir, name);
|
|
43
|
+
return [...acc, ...(await expandPath(srcPath, destPath))];
|
|
44
|
+
},
|
|
45
|
+
Promise.resolve([])
|
|
46
|
+
);
|
|
47
|
+
} catch (error: any) {
|
|
48
|
+
throw new Error(`Error reading directory: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|