@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.
Files changed (629) hide show
  1. package/.scripts/add_metadata_to_dfx_json.js +54 -0
  2. package/.scripts/cargo_expand.sh +17 -0
  3. package/.scripts/class_migration/add_example_dependency.js +54 -0
  4. package/.scripts/class_migration/change_to_custom_candid_gen.js +76 -0
  5. package/.scripts/class_migration/clean_package.js +27 -0
  6. package/.scripts/class_migration/copy_generated_candid_from_example.js +90 -0
  7. package/.scripts/class_migration/delete_tests_file.js +22 -0
  8. package/.scripts/class_migration/do_all_packages.js +61 -0
  9. package/.scripts/class_migration/modify_pretest.js +57 -0
  10. package/.scripts/class_migration/name_package.js +62 -0
  11. package/.scripts/class_migration/update_test.js +38 -0
  12. package/.scripts/class_migration/update_ts_config.js +48 -0
  13. package/.scripts/class_migration/update_typescript.js +99 -0
  14. package/.scripts/clean_all_projects.ts +91 -0
  15. package/.scripts/delete_git_branches.sh +20 -0
  16. package/.scripts/dev_dependencies/add_dev_dependencies.js +53 -0
  17. package/.scripts/dev_dependencies/remove_dev_dependencies.js +44 -0
  18. package/.scripts/examples-survey.json +5651 -0
  19. package/.scripts/file_generator/bin.js +4 -0
  20. package/.scripts/file_generator/index.ts +59 -0
  21. package/.scripts/file_generator/main.ts +55 -0
  22. package/.scripts/find_multiline_files.ts +101 -0
  23. package/.scripts/hash_file.ts +9 -0
  24. package/.scripts/hash_file_by_parts/bin.js +4 -0
  25. package/.scripts/hash_file_by_parts/index.ts +48 -0
  26. package/.scripts/hash_file_by_parts/main.ts +10 -0
  27. package/.scripts/jest_isolate_modules.js +29 -0
  28. package/.scripts/jest_migration.sh +31 -0
  29. package/.scripts/reorder_dfx_json.js +72 -0
  30. package/.scripts/setup_release_branch.sh +34 -0
  31. package/.scripts/simplify_tsconfig.js +37 -0
  32. package/.scripts/survey_examples.ts +396 -0
  33. package/.scripts/tsx_migration/ts_node_to_tsx.js +76 -0
  34. package/.scripts/update_candid.sh +40 -0
  35. package/.scripts/update_dfx_json_main.js +66 -0
  36. package/.scripts/update_dfx_json_with_optimize.py +22 -0
  37. package/.scripts/update_jest_configs.ts +248 -0
  38. package/LICENSE +21 -0
  39. package/LICENSE_EXTENSION.md +42 -0
  40. package/NOTICE +222 -0
  41. package/README.md +78 -0
  42. package/dist/canister_templates/experimental.wasm +0 -0
  43. package/dist/canister_templates/licenses.yml +29186 -0
  44. package/dist/canister_templates/stable.wasm +0 -0
  45. package/examples/README.md +22 -0
  46. package/examples/experimental/demo/hello_world_http_server/README.md +120 -0
  47. package/examples/experimental/demo/hello_world_http_server/benchmarks.json +42 -0
  48. package/examples/experimental/demo/hello_world_http_server/benchmarks.md +28 -0
  49. package/examples/experimental/demo/hello_world_http_server/dfx.json +13 -0
  50. package/examples/experimental/demo/hello_world_http_server/env.d.ts +9 -0
  51. package/examples/experimental/demo/hello_world_http_server/jest.config.js +10 -0
  52. package/examples/experimental/demo/hello_world_http_server/package-lock.json +8409 -0
  53. package/examples/experimental/demo/hello_world_http_server/package.json +20 -0
  54. package/examples/experimental/demo/hello_world_http_server/src/backend/index.ts +23 -0
  55. package/examples/experimental/demo/hello_world_http_server/src/frontend/index.html +16 -0
  56. package/examples/experimental/demo/hello_world_http_server/src/frontend/index.ts +62 -0
  57. package/examples/experimental/demo/hello_world_http_server/test/pretest.ts +13 -0
  58. package/examples/experimental/demo/hello_world_http_server/test/test.ts +9 -0
  59. package/examples/experimental/demo/hello_world_http_server/test/tests.ts +27 -0
  60. package/examples/experimental/demo/hello_world_http_server/tsconfig.json +13 -0
  61. package/examples/package-lock.json +8746 -0
  62. package/examples/package.json +17 -0
  63. package/examples/stable/demo/hello_world/README.md +97 -0
  64. package/examples/stable/demo/hello_world/benchmarks.json +28 -0
  65. package/examples/stable/demo/hello_world/benchmarks.md +26 -0
  66. package/examples/stable/demo/hello_world/dfx.json +12 -0
  67. package/examples/stable/demo/hello_world/jest.config.js +10 -0
  68. package/examples/stable/demo/hello_world/package-lock.json +5524 -0
  69. package/examples/stable/demo/hello_world/package.json +14 -0
  70. package/examples/stable/demo/hello_world/src/index.ts +15 -0
  71. package/examples/stable/demo/hello_world/test/pretest.ts +17 -0
  72. package/examples/stable/demo/hello_world/test/test.ts +15 -0
  73. package/examples/stable/demo/hello_world/test/tests.ts +27 -0
  74. package/examples/stable/demo/hello_world/tsconfig.json +10 -0
  75. package/jest.config.dev.js +10 -0
  76. package/package.json +102 -0
  77. package/src/build.ts +98 -0
  78. package/src/experimental/build/assert_experimental.ts +5 -0
  79. package/src/experimental/build/commands/build/candid_and_method_meta.ts +30 -0
  80. package/src/experimental/build/commands/build/custom_js_modules/acorn/acorn.ts +6 -0
  81. package/src/experimental/build/commands/build/custom_js_modules/acorn/walk.ts +6 -0
  82. package/src/experimental/build/commands/build/custom_js_modules/async_hooks.ts +11 -0
  83. package/src/experimental/build/commands/build/custom_js_modules/https.ts +6 -0
  84. package/src/experimental/build/commands/build/custom_js_modules/perf_hooks.ts +12 -0
  85. package/src/experimental/build/commands/build/file_watcher/file_watcher.ts +152 -0
  86. package/src/experimental/build/commands/build/file_watcher/file_watcher_loader.js +9 -0
  87. package/src/experimental/build/commands/build/file_watcher/setup_file_watcher.ts +61 -0
  88. package/src/experimental/build/commands/build/get_context.ts +61 -0
  89. package/src/experimental/build/commands/build/index.ts +87 -0
  90. package/src/experimental/build/commands/build/javascript.ts +194 -0
  91. package/src/experimental/build/commands/build/wasm_binary/index.ts +32 -0
  92. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/Cargo.toml +26 -0
  93. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/autoreload.rs +46 -0
  94. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/benchmarking.rs +35 -0
  95. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/candid.rs +106 -0
  96. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/chunk.rs +11 -0
  97. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/execute_method_js.rs +46 -0
  98. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/guards.rs +9 -0
  99. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/accept_message.rs +10 -0
  100. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/call_raw.rs +265 -0
  101. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_compiler.rs +19 -0
  102. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_decode.rs +17 -0
  103. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/candid_encode.rs +17 -0
  104. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_cycle_balance.rs +12 -0
  105. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_self.rs +10 -0
  106. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/canister_version.rs +10 -0
  107. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/certified_data_set.rs +17 -0
  108. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/clear_timer.rs +18 -0
  109. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/cycles_burn.rs +17 -0
  110. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/data_certificate.rs +13 -0
  111. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/debug_print.rs +17 -0
  112. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/drain_microtasks.rs +23 -0
  113. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/in_replicated_execution.rs +8 -0
  114. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/is_controller.rs +16 -0
  115. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/mod.rs +351 -0
  116. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_arg_data.rs +10 -0
  117. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_caller.rs +10 -0
  118. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_accept.rs +17 -0
  119. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_available.rs +10 -0
  120. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_cycles_refunded.rs +10 -0
  121. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_method_name.rs +8 -0
  122. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject.rs +16 -0
  123. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject_code.rs +8 -0
  124. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reject_msg.rs +8 -0
  125. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/msg_reply.rs +19 -0
  126. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/notify_raw.rs +65 -0
  127. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/performance_counter.rs +19 -0
  128. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/rand_bytes.rs +25 -0
  129. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/rand_seed.rs +30 -0
  130. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/set_timer.rs +83 -0
  131. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/set_timer_interval.rs +66 -0
  132. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_contains_key.rs +32 -0
  133. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_get.rs +36 -0
  134. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_init.rs +29 -0
  135. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_insert.rs +46 -0
  136. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_is_empty.rs +23 -0
  137. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_items.rs +59 -0
  138. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_keys.rs +54 -0
  139. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_len.rs +23 -0
  140. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_remove.rs +36 -0
  141. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/stable_b_tree_map_values.rs +54 -0
  142. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/time.rs +8 -0
  143. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/trap.rs +14 -0
  144. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/init_and_post_upgrade.rs +212 -0
  145. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/internal_canister_methods.rs +142 -0
  146. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/lib.rs +35 -0
  147. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/stable_b_tree_map.rs +50 -0
  148. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/bytes_to_human_readable.rs +20 -0
  149. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/file_info.rs +60 -0
  150. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/hash.rs +111 -0
  151. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/mod.rs +20 -0
  152. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/reset.rs +15 -0
  153. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/upload_file/upload_file_chunk.rs +88 -0
  154. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/wasm_binary_manipulation.rs +276 -0
  155. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/instantiate.rs +195 -0
  156. package/src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/mod.rs +24 -0
  157. package/src/experimental/build/commands/upload_assets/file_uploader/bytes_to_human_readable.ts +27 -0
  158. package/src/experimental/build/commands/upload_assets/file_uploader/expand_paths.ts +50 -0
  159. package/src/experimental/build/commands/upload_assets/file_uploader/get_files_to_upload.ts +21 -0
  160. package/src/experimental/build/commands/upload_assets/file_uploader/incomplete_files.ts +28 -0
  161. package/src/experimental/build/commands/upload_assets/file_uploader/index.ts +43 -0
  162. package/src/experimental/build/commands/upload_assets/file_uploader/on_before_exit.ts +34 -0
  163. package/src/experimental/build/commands/upload_assets/file_uploader/upload_file.ts +91 -0
  164. package/src/experimental/build/commands/upload_assets/file_uploader/uploader_actor.ts +51 -0
  165. package/src/experimental/build/commands/upload_assets/index.ts +16 -0
  166. package/src/experimental/build/commands/upload_assets/uploader_identity.ts +23 -0
  167. package/src/experimental/build/index.ts +61 -0
  168. package/src/experimental/build/utils/dfx.ts +212 -0
  169. package/src/experimental/build/utils/filter_async.ts +14 -0
  170. package/src/experimental/build/utils/find_project_root.ts +67 -0
  171. package/src/experimental/build/utils/global_paths.ts +8 -0
  172. package/src/experimental/build/utils/log_success.ts +18 -0
  173. package/src/experimental/build/utils/types.ts +34 -0
  174. package/src/experimental/lib/assert_experimental.ts +19 -0
  175. package/src/experimental/lib/fetch/file.ts +15 -0
  176. package/src/experimental/lib/fetch/headers.ts +85 -0
  177. package/src/experimental/lib/fetch/http.ts +293 -0
  178. package/src/experimental/lib/fetch/icp.ts +98 -0
  179. package/src/experimental/lib/fetch/index.ts +97 -0
  180. package/src/experimental/lib/fetch/response.ts +171 -0
  181. package/src/experimental/lib/fetch/url.ts +15 -0
  182. package/src/experimental/lib/globals.ts +146 -0
  183. package/src/experimental/lib/http_client/fetch_ic/actor.ts +131 -0
  184. package/src/experimental/lib/http_client/fetch_ic/agent.ts +20 -0
  185. package/src/experimental/lib/http_client/fetch_ic/call.ts +257 -0
  186. package/src/experimental/lib/http_client/fetch_ic/get_canister_id.ts +25 -0
  187. package/src/experimental/lib/http_client/fetch_ic/host.ts +30 -0
  188. package/src/experimental/lib/http_client/fetch_ic/identity.ts +52 -0
  189. package/src/experimental/lib/http_client/fetch_ic/index.ts +95 -0
  190. package/src/experimental/lib/http_client/fetch_ic/response.ts +8 -0
  191. package/src/experimental/lib/http_client/index.ts +6 -0
  192. package/src/experimental/lib/http_client/to_jwt.ts +6 -0
  193. package/src/experimental/lib/ic/azle_ic_experimental.ts +92 -0
  194. package/src/experimental/lib/ic/candid_compiler.ts +14 -0
  195. package/src/experimental/lib/ic/index.ts +10 -0
  196. package/src/experimental/lib/ic/set_outgoing_http_options.ts +18 -0
  197. package/src/experimental/lib/index.ts +7 -0
  198. package/src/experimental/lib/server.ts +279 -0
  199. package/src/experimental/lib/threshold_wallet/calculate_rsv_for_tecdsa.ts +45 -0
  200. package/src/experimental/lib/threshold_wallet/ecdsa_public_key.ts +33 -0
  201. package/src/experimental/lib/threshold_wallet/index.ts +7 -0
  202. package/src/experimental/lib/threshold_wallet/register_get_url.ts +36 -0
  203. package/src/experimental/lib/threshold_wallet/sign_with_ecdsa.ts +28 -0
  204. package/src/experimental/lib/threshold_wallet/wallet.ts +99 -0
  205. package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/complex_candid_definition_memo.ts +113 -0
  206. package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/index.ts +73 -0
  207. package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/recursive_candid_definition_memo.ts +28 -0
  208. package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/simple_candid_definition_arb.ts +116 -0
  209. package/src/experimental/test/property/arbitraries/candid/candid_definition_arb/types.ts +117 -0
  210. package/src/experimental/test/property/arbitraries/candid/candid_return_type_arb.ts +22 -0
  211. package/src/experimental/test/property/arbitraries/candid/candid_type.ts +83 -0
  212. package/src/experimental/test/property/arbitraries/candid/candid_value_and_meta_arb.ts +84 -0
  213. package/src/experimental/test/property/arbitraries/candid/candid_value_and_meta_arb_generator.ts +63 -0
  214. package/src/experimental/test/property/arbitraries/candid/candid_values_arb.ts +173 -0
  215. package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/definition_arb.ts +11 -0
  216. package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/index.ts +19 -0
  217. package/src/experimental/test/property/arbitraries/candid/constructed/blob_arb/values_arb.ts +11 -0
  218. package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/definition_arb.ts +172 -0
  219. package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/index.ts +29 -0
  220. package/src/experimental/test/property/arbitraries/candid/constructed/opt_arb/values_arb.ts +88 -0
  221. package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/definition_arb.ts +184 -0
  222. package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/index.ts +34 -0
  223. package/src/experimental/test/property/arbitraries/candid/constructed/record_arb/values_arb.ts +95 -0
  224. package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/definition_arb.ts +159 -0
  225. package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/index.ts +31 -0
  226. package/src/experimental/test/property/arbitraries/candid/constructed/tuple_arb/values_arbs.ts +76 -0
  227. package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/definition_arbs.ts +257 -0
  228. package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/index.ts +37 -0
  229. package/src/experimental/test/property/arbitraries/candid/constructed/variant_arb/values_arb.ts +92 -0
  230. package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/definition_arb.ts +203 -0
  231. package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/index.ts +39 -0
  232. package/src/experimental/test/property/arbitraries/candid/constructed/vec_arb/values_arb.ts +257 -0
  233. package/src/experimental/test/property/arbitraries/candid/corresponding_js_type.ts +34 -0
  234. package/src/experimental/test/property/arbitraries/candid/primitive/bool_arb.ts +28 -0
  235. package/src/experimental/test/property/arbitraries/candid/primitive/floats/float32_arb.ts +56 -0
  236. package/src/experimental/test/property/arbitraries/candid/primitive/floats/float64_arb.ts +56 -0
  237. package/src/experimental/test/property/arbitraries/candid/primitive/ints/index.ts +11 -0
  238. package/src/experimental/test/property/arbitraries/candid/primitive/ints/int16_arb.ts +34 -0
  239. package/src/experimental/test/property/arbitraries/candid/primitive/ints/int32_arb.ts +34 -0
  240. package/src/experimental/test/property/arbitraries/candid/primitive/ints/int64_arb.ts +41 -0
  241. package/src/experimental/test/property/arbitraries/candid/primitive/ints/int8_arb.ts +34 -0
  242. package/src/experimental/test/property/arbitraries/candid/primitive/ints/int_arb.ts +39 -0
  243. package/src/experimental/test/property/arbitraries/candid/primitive/nats/index.ts +11 -0
  244. package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat16_arb.ts +34 -0
  245. package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat32_arb.ts +34 -0
  246. package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat64_arb.ts +41 -0
  247. package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat8_arb.ts +34 -0
  248. package/src/experimental/test/property/arbitraries/candid/primitive/nats/nat_arb.ts +39 -0
  249. package/src/experimental/test/property/arbitraries/candid/primitive/null_arb.ts +33 -0
  250. package/src/experimental/test/property/arbitraries/candid/primitive/text_arb.ts +47 -0
  251. package/src/experimental/test/property/arbitraries/candid/primitive/void_arb.ts +33 -0
  252. package/src/experimental/test/property/arbitraries/candid/recursive/definition_arb.ts +125 -0
  253. package/src/experimental/test/property/arbitraries/candid/recursive/index.ts +35 -0
  254. package/src/experimental/test/property/arbitraries/candid/recursive/values_arb.ts +43 -0
  255. package/src/experimental/test/property/arbitraries/candid/reference/func_arb/definition_arb.ts +198 -0
  256. package/src/experimental/test/property/arbitraries/candid/reference/func_arb/index.ts +23 -0
  257. package/src/experimental/test/property/arbitraries/candid/reference/func_arb/values_arb.ts +70 -0
  258. package/src/experimental/test/property/arbitraries/candid/reference/principal_arb.ts +43 -0
  259. package/src/experimental/test/property/arbitraries/candid/reference/service_arb/definition_arb.ts +163 -0
  260. package/src/experimental/test/property/arbitraries/candid/reference/service_arb/index.ts +41 -0
  261. package/src/experimental/test/property/arbitraries/candid/reference/service_arb/service_method_arb.ts +110 -0
  262. package/src/experimental/test/property/arbitraries/candid/reference/service_arb/values_arb.ts +20 -0
  263. package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/candid_type_to_azle_candid_type.ts +66 -0
  264. package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/definition_arb.ts +95 -0
  265. package/src/experimental/test/property/arbitraries/candid/simple_type_arbs/values_arb.ts +19 -0
  266. package/src/experimental/test/property/arbitraries/candid/to_src_literal/bigint.ts +5 -0
  267. package/src/experimental/test/property/arbitraries/candid/to_src_literal/blob.ts +5 -0
  268. package/src/experimental/test/property/arbitraries/candid/to_src_literal/boolean.ts +5 -0
  269. package/src/experimental/test/property/arbitraries/candid/to_src_literal/float.ts +18 -0
  270. package/src/experimental/test/property/arbitraries/candid/to_src_literal/null.ts +5 -0
  271. package/src/experimental/test/property/arbitraries/candid/to_src_literal/number.ts +5 -0
  272. package/src/experimental/test/property/arbitraries/candid/to_src_literal/principal.ts +7 -0
  273. package/src/experimental/test/property/arbitraries/candid/to_src_literal/string.ts +12 -0
  274. package/src/experimental/test/property/arbitraries/candid/to_src_literal/void.ts +5 -0
  275. package/src/experimental/test/property/arbitraries/canister_arb.ts +195 -0
  276. package/src/experimental/test/property/arbitraries/canister_methods/index.ts +79 -0
  277. package/src/experimental/test/property/arbitraries/canister_methods/init_method_arb.ts +127 -0
  278. package/src/experimental/test/property/arbitraries/canister_methods/inspect_message_method_arb.ts +55 -0
  279. package/src/experimental/test/property/arbitraries/canister_methods/post_upgrade_method_arb.ts +133 -0
  280. package/src/experimental/test/property/arbitraries/canister_methods/pre_upgrade_method_arb.ts +57 -0
  281. package/src/experimental/test/property/arbitraries/canister_methods/query_method_arb.ts +141 -0
  282. package/src/experimental/test/property/arbitraries/canister_methods/update_method_arb.ts +158 -0
  283. package/src/experimental/test/property/arbitraries/config.ts +4 -0
  284. package/src/experimental/test/property/arbitraries/http/body_arb.ts +7 -0
  285. package/src/experimental/test/property/arbitraries/http/headers_arb.ts +22 -0
  286. package/src/experimental/test/property/arbitraries/http/request_arb.ts +158 -0
  287. package/src/experimental/test/property/arbitraries/http/response_arb.ts +192 -0
  288. package/src/experimental/test/property/arbitraries/js_name_arb.ts +144 -0
  289. package/src/experimental/test/property/arbitraries/stable_b_tree_map_arb.ts +55 -0
  290. package/src/experimental/test/property/arbitraries/types.ts +24 -0
  291. package/src/experimental/test/property/arbitraries/unique_identifier_arb.ts +38 -0
  292. package/src/experimental/test/property/arbitraries/unique_primitive_arb.ts +22 -0
  293. package/src/experimental/test/property/are_params_correctly_ordered.ts +19 -0
  294. package/src/experimental/test/property/get_actor.ts +39 -0
  295. package/src/experimental/test/property/index.ts +141 -0
  296. package/src/experimental/test/property/test/index.ts +226 -0
  297. package/src/experimental/test/property/visitors/LICENCE +201 -0
  298. package/src/experimental/test/property/visitors/cli-string-visitor.ts +138 -0
  299. package/src/experimental/test/set_experimental.ts +1 -0
  300. package/src/exports/_internal/dfx.ts +1 -0
  301. package/src/exports/_internal/globals.ts +1 -0
  302. package/src/exports/_internal/test/candid_deep_equal.ts +1 -0
  303. package/src/exports/_internal/test.ts +1 -0
  304. package/src/exports/_internal/type_tests/assert_type.ts +1 -0
  305. package/src/exports/_internal.ts +1 -0
  306. package/src/exports/canisters/ck_btc_ledger/idl.ts +1 -0
  307. package/src/exports/canisters/ck_eth_ledger/idl.ts +1 -0
  308. package/src/exports/canisters/cycles_ledger/idl.ts +1 -0
  309. package/src/exports/canisters/evm_rpc/idl.ts +1 -0
  310. package/src/exports/canisters/exchange_rate/idl.ts +1 -0
  311. package/src/exports/canisters/http_gateway/idl.ts +1 -0
  312. package/src/exports/canisters/icrc_1/idl.ts +1 -0
  313. package/src/exports/canisters/icrc_10/idl.ts +1 -0
  314. package/src/exports/canisters/icrc_2/idl.ts +1 -0
  315. package/src/exports/canisters/icrc_3/idl.ts +1 -0
  316. package/src/exports/canisters/icrc_37/idl.ts +1 -0
  317. package/src/exports/canisters/icrc_7/idl.ts +1 -0
  318. package/src/exports/canisters/llm/idl.ts +1 -0
  319. package/src/exports/canisters/management/idl.ts +1 -0
  320. package/src/exports/canisters/nns_cycles_minting/idl.ts +1 -0
  321. package/src/exports/canisters/nns_governance/idl.ts +1 -0
  322. package/src/exports/canisters/nns_icp_ledger/idl.ts +1 -0
  323. package/src/exports/canisters/nns_internet_identity/idl.ts +1 -0
  324. package/src/exports/canisters/nns_registry/idl.ts +1 -0
  325. package/src/exports/canisters/nns_sns_w/idl.ts +1 -0
  326. package/src/exports/experimental/_internal/dfx.ts +1 -0
  327. package/src/exports/experimental/_internal/globals.ts +1 -0
  328. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_definition_arb/types.ts +1 -0
  329. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_definition_arb.ts +1 -0
  330. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_return_type_arb.ts +1 -0
  331. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_value_and_meta_arb.ts +1 -0
  332. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_value_and_meta_arb_generator.ts +1 -0
  333. package/src/exports/experimental/_internal/test/property/arbitraries/candid/candid_values_arb.ts +1 -0
  334. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/blob_arb.ts +1 -0
  335. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/opt_arb.ts +1 -0
  336. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/record_arb.ts +1 -0
  337. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/tuple_arb.ts +1 -0
  338. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/variant_arb.ts +1 -0
  339. package/src/exports/experimental/_internal/test/property/arbitraries/candid/constructed/vec_arb.ts +1 -0
  340. package/src/exports/experimental/_internal/test/property/arbitraries/candid/corresponding_js_type.ts +1 -0
  341. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/bool_arb.ts +1 -0
  342. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/floats/float32_arb.ts +1 -0
  343. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/floats/float64_arb.ts +1 -0
  344. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int16_arb.ts +1 -0
  345. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int32_arb.ts +1 -0
  346. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int64_arb.ts +1 -0
  347. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int8_arb.ts +1 -0
  348. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/ints/int_arb.ts +1 -0
  349. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat16_arb.ts +1 -0
  350. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat32_arb.ts +1 -0
  351. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat64_arb.ts +1 -0
  352. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat8_arb.ts +1 -0
  353. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/nats/nat_arb.ts +1 -0
  354. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/null_arb.ts +1 -0
  355. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/text_arb.ts +1 -0
  356. package/src/exports/experimental/_internal/test/property/arbitraries/candid/primitive/void_arb.ts +1 -0
  357. package/src/exports/experimental/_internal/test/property/arbitraries/candid/recursive.ts +1 -0
  358. package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/func_arb.ts +1 -0
  359. package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/principal_arb.ts +1 -0
  360. package/src/exports/experimental/_internal/test/property/arbitraries/candid/reference/service_arb.ts +1 -0
  361. package/src/exports/experimental/_internal/test/property/arbitraries/canister_arb.ts +1 -0
  362. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/init_method_arb.ts +1 -0
  363. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/inspect_message_method_arb.ts +1 -0
  364. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/post_upgrade_method_arb.ts +1 -0
  365. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/pre_upgrade_method_arb.ts +1 -0
  366. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/query_method_arb.ts +1 -0
  367. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods/update_method_arb.ts +1 -0
  368. package/src/exports/experimental/_internal/test/property/arbitraries/canister_methods.ts +1 -0
  369. package/src/exports/experimental/_internal/test/property/arbitraries/config.ts +1 -0
  370. package/src/exports/experimental/_internal/test/property/arbitraries/http/body_arb.ts +1 -0
  371. package/src/exports/experimental/_internal/test/property/arbitraries/http/headers_arb.ts +1 -0
  372. package/src/exports/experimental/_internal/test/property/arbitraries/http/request_arb.ts +1 -0
  373. package/src/exports/experimental/_internal/test/property/arbitraries/http/response_arb.ts +1 -0
  374. package/src/exports/experimental/_internal/test/property/arbitraries/stable_b_tree_map_arb.ts +1 -0
  375. package/src/exports/experimental/_internal/test/property/arbitraries/types.ts +1 -0
  376. package/src/exports/experimental/_internal/test/property/arbitraries/unique_identifier_arb.ts +1 -0
  377. package/src/exports/experimental/_internal/test/property/are_params_correctly_ordered.ts +1 -0
  378. package/src/exports/experimental/_internal/test/property/test.ts +1 -0
  379. package/src/exports/experimental/_internal/test/property.ts +1 -0
  380. package/src/exports/experimental/_internal/test/set_experimental.ts +1 -0
  381. package/src/exports/experimental/_internal.ts +8 -0
  382. package/src/exports/experimental/http_client.ts +1 -0
  383. package/src/exports/experimental.ts +3 -0
  384. package/src/stable/build/commands/build/candid_and_method_meta/execute.ts +134 -0
  385. package/src/stable/build/commands/build/candid_and_method_meta/index.ts +27 -0
  386. package/src/stable/build/commands/build/get_context.ts +79 -0
  387. package/src/stable/build/commands/build/index.ts +48 -0
  388. package/src/stable/build/commands/build/javascript.ts +259 -0
  389. package/src/stable/build/commands/build/wasm_binary/compile.ts +27 -0
  390. package/src/stable/build/commands/build/wasm_binary/index.ts +30 -0
  391. package/src/stable/build/commands/build/wasm_binary/manipulate.ts +268 -0
  392. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/Cargo.toml +23 -0
  393. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/benchmarking.rs +45 -0
  394. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/candid_and_method_meta.rs +49 -0
  395. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/execute_method_js.rs +65 -0
  396. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/guards.rs +11 -0
  397. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs +6 -0
  398. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/call_raw.rs +362 -0
  399. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/candid_decode.rs +18 -0
  400. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/candid_encode.rs +19 -0
  401. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_cycle_balance.rs +8 -0
  402. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_self.rs +8 -0
  403. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/canister_version.rs +8 -0
  404. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/certified_data_set.rs +8 -0
  405. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/clear_timer.rs +15 -0
  406. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/cycles_burn.rs +17 -0
  407. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/data_certificate.rs +13 -0
  408. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/debug_print.rs +8 -0
  409. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/drain_microtasks.rs +22 -0
  410. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/in_replicated_execution.rs +6 -0
  411. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/is_controller.rs +11 -0
  412. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/mod.rs +219 -0
  413. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_arg_data.rs +8 -0
  414. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_caller.rs +8 -0
  415. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_accept.rs +17 -0
  416. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_available.rs +8 -0
  417. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_cycles_refunded.rs +8 -0
  418. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_method_name.rs +6 -0
  419. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject.rs +6 -0
  420. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject_code.rs +6 -0
  421. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reject_msg.rs +6 -0
  422. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/msg_reply.rs +8 -0
  423. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/notify_raw.rs +62 -0
  424. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/performance_counter.rs +17 -0
  425. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/rand_bytes.rs +21 -0
  426. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/rand_seed.rs +26 -0
  427. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/set_timer.rs +92 -0
  428. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/set_timer_interval.rs +62 -0
  429. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_contains_key.rs +18 -0
  430. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_get.rs +21 -0
  431. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_init.rs +19 -0
  432. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_insert.rs +44 -0
  433. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_is_empty.rs +11 -0
  434. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_items.rs +48 -0
  435. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_keys.rs +43 -0
  436. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_len.rs +16 -0
  437. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_remove.rs +21 -0
  438. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/stable_b_tree_map_values.rs +43 -0
  439. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/time.rs +8 -0
  440. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/trap.rs +22 -0
  441. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/init_and_post_upgrade.rs +98 -0
  442. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/initialize_context.rs +102 -0
  443. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/internal_canister_methods.rs +122 -0
  444. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/lib.rs +39 -0
  445. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/call_with_error_handling.rs +26 -0
  446. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/error.rs +27 -0
  447. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/mod.rs +7 -0
  448. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/rquickjs_utils/with_ctx.rs +24 -0
  449. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/stable_b_tree_map.rs +84 -0
  450. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/state.rs +55 -0
  451. package/src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/wasm_binary_manipulation.rs +296 -0
  452. package/src/stable/build/commands/clean.ts +15 -0
  453. package/src/stable/build/commands/dev/audit.ts +39 -0
  454. package/src/stable/build/commands/dev/setup/index.ts +41 -0
  455. package/src/stable/build/commands/dev/setup/install_cargo-audit.sh +11 -0
  456. package/src/stable/build/commands/dev/setup/install_cargo-auditable.sh +16 -0
  457. package/src/stable/build/commands/dev/setup/install_cargo-bundle-licenses.sh +11 -0
  458. package/src/stable/build/commands/dev/setup/install_cargo-deny.sh +11 -0
  459. package/src/stable/build/commands/dev/setup/install_dfx.sh +36 -0
  460. package/src/stable/build/commands/dev/setup/install_node.sh +25 -0
  461. package/src/stable/build/commands/dev/setup/install_rust.sh +24 -0
  462. package/src/stable/build/commands/dev/setup/install_wasi2ic.sh +11 -0
  463. package/src/stable/build/commands/dev/template/experimental.ts +28 -0
  464. package/src/stable/build/commands/dev/template/generate_licenses.ts +28 -0
  465. package/src/stable/build/commands/dev/template/stable.ts +27 -0
  466. package/src/stable/build/commands/extension/install.ts +25 -0
  467. package/src/stable/build/commands/generate/index.ts +21 -0
  468. package/src/stable/build/commands/generate/rust/candid_to_ts_js/Cargo.toml +12 -0
  469. package/src/stable/build/commands/generate/rust/candid_to_ts_js/build.sh +9 -0
  470. package/src/stable/build/commands/generate/rust/candid_to_ts_js/licenses.md +1 -0
  471. package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js.d.ts +18 -0
  472. package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js.js +144 -0
  473. package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js_bg.wasm +0 -0
  474. package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/candid_to_ts_js_bg.wasm.d.ts +9 -0
  475. package/src/stable/build/commands/generate/rust/candid_to_ts_js/pkg/package.json +11 -0
  476. package/src/stable/build/commands/generate/rust/candid_to_ts_js/src/lib.rs +31 -0
  477. package/src/stable/build/commands/new.ts +165 -0
  478. package/src/stable/build/commands/version.ts +5 -0
  479. package/src/stable/build/dfx_extension/extension.json +36 -0
  480. package/src/stable/build/dfx_extension/install.sh +10 -0
  481. package/src/stable/build/index.ts +282 -0
  482. package/src/stable/build/utils/dfx.ts +10 -0
  483. package/src/stable/build/utils/dfx_root.ts +34 -0
  484. package/src/stable/build/utils/exec_sync_pretty.ts +17 -0
  485. package/src/stable/build/utils/experimental_message.ts +19 -0
  486. package/src/stable/build/utils/get_canister_config.ts +52 -0
  487. package/src/stable/build/utils/global_paths.ts +26 -0
  488. package/src/stable/build/utils/types.ts +87 -0
  489. package/src/stable/lib/canister_methods/heartbeat.ts +29 -0
  490. package/src/stable/lib/canister_methods/index.ts +405 -0
  491. package/src/stable/lib/canister_methods/init.ts +71 -0
  492. package/src/stable/lib/canister_methods/inspect_message.ts +79 -0
  493. package/src/stable/lib/canister_methods/on_low_wasm_memory.ts +27 -0
  494. package/src/stable/lib/canister_methods/post_upgrade.ts +73 -0
  495. package/src/stable/lib/canister_methods/pre_upgrade.ts +27 -0
  496. package/src/stable/lib/canister_methods/query.ts +69 -0
  497. package/src/stable/lib/canister_methods/update.ts +66 -0
  498. package/src/stable/lib/canisters/NOTICE +15 -0
  499. package/src/stable/lib/canisters/ck_btc_ledger/idl/README.md +9 -0
  500. package/src/stable/lib/canisters/ck_btc_ledger/idl/index.did +289 -0
  501. package/src/stable/lib/canisters/ck_btc_ledger/idl/index.ts +1143 -0
  502. package/src/stable/lib/canisters/ck_eth_ledger/idl/README.md +9 -0
  503. package/src/stable/lib/canisters/ck_eth_ledger/idl/index.did +289 -0
  504. package/src/stable/lib/canisters/ck_eth_ledger/idl/index.ts +1143 -0
  505. package/src/stable/lib/canisters/cycles_ledger/idl/README.md +9 -0
  506. package/src/stable/lib/canisters/cycles_ledger/idl/index.did +272 -0
  507. package/src/stable/lib/canisters/cycles_ledger/idl/index.ts +978 -0
  508. package/src/stable/lib/canisters/evm_rpc/idl/README.md +9 -0
  509. package/src/stable/lib/canisters/evm_rpc/idl/index.did +311 -0
  510. package/src/stable/lib/canisters/evm_rpc/idl/index.ts +1028 -0
  511. package/src/stable/lib/canisters/exchange_rate/idl/README.md +9 -0
  512. package/src/stable/lib/canisters/exchange_rate/idl/index.did +83 -0
  513. package/src/stable/lib/canisters/exchange_rate/idl/index.ts +165 -0
  514. package/src/stable/lib/canisters/http_gateway/idl/README.md +9 -0
  515. package/src/stable/lib/canisters/http_gateway/idl/http-gateway.did +49 -0
  516. package/src/stable/lib/canisters/http_gateway/idl/index.ts +120 -0
  517. package/src/stable/lib/canisters/icrc_1/idl/ICRC-1.did +63 -0
  518. package/src/stable/lib/canisters/icrc_1/idl/LICENSE +202 -0
  519. package/src/stable/lib/canisters/icrc_1/idl/index.ts +151 -0
  520. package/src/stable/lib/canisters/icrc_10/idl/ICRC-10.did +8 -0
  521. package/src/stable/lib/canisters/icrc_10/idl/LICENSE +202 -0
  522. package/src/stable/lib/canisters/icrc_10/idl/index.ts +32 -0
  523. package/src/stable/lib/canisters/icrc_2/idl/ICRC-2.did +76 -0
  524. package/src/stable/lib/canisters/icrc_2/idl/LICENSE +202 -0
  525. package/src/stable/lib/canisters/icrc_2/idl/index.ts +226 -0
  526. package/src/stable/lib/canisters/icrc_3/idl/ICRC-3.did +59 -0
  527. package/src/stable/lib/canisters/icrc_3/idl/LICENSE +202 -0
  528. package/src/stable/lib/canisters/icrc_3/idl/index.ts +156 -0
  529. package/src/stable/lib/canisters/icrc_37/idl/ICRC-37.did +152 -0
  530. package/src/stable/lib/canisters/icrc_37/idl/LICENSE +202 -0
  531. package/src/stable/lib/canisters/icrc_37/idl/index.ts +466 -0
  532. package/src/stable/lib/canisters/icrc_7/idl/ICRC-7.did +67 -0
  533. package/src/stable/lib/canisters/icrc_7/idl/LICENSE +202 -0
  534. package/src/stable/lib/canisters/icrc_7/idl/index.ts +213 -0
  535. package/src/stable/lib/canisters/llm/idl/README.md +9 -0
  536. package/src/stable/lib/canisters/llm/idl/index.did +21 -0
  537. package/src/stable/lib/canisters/llm/idl/index.ts +43 -0
  538. package/src/stable/lib/canisters/management/idl/README.md +10 -0
  539. package/src/stable/lib/canisters/management/idl/ic.did +502 -0
  540. package/src/stable/lib/canisters/management/idl/index.ts +1257 -0
  541. package/src/stable/lib/canisters/nns_cycles_minting/idl/README.md +9 -0
  542. package/src/stable/lib/canisters/nns_cycles_minting/idl/index.did +241 -0
  543. package/src/stable/lib/canisters/nns_cycles_minting/idl/index.ts +394 -0
  544. package/src/stable/lib/canisters/nns_governance/idl/README.md +9 -0
  545. package/src/stable/lib/canisters/nns_governance/idl/index.did +1316 -0
  546. package/src/stable/lib/canisters/nns_governance/idl/index.ts +3599 -0
  547. package/src/stable/lib/canisters/nns_icp_ledger/idl/LICENSE +202 -0
  548. package/src/stable/lib/canisters/nns_icp_ledger/idl/NOTICE +14 -0
  549. package/src/stable/lib/canisters/nns_icp_ledger/idl/README.md +18 -0
  550. package/src/stable/lib/canisters/nns_icp_ledger/idl/address/index.ts +82 -0
  551. package/src/stable/lib/canisters/nns_icp_ledger/idl/index.did +264 -0
  552. package/src/stable/lib/canisters/nns_icp_ledger/idl/index.ts +1020 -0
  553. package/src/stable/lib/canisters/nns_internet_identity/idl/README.md +9 -0
  554. package/src/stable/lib/canisters/nns_internet_identity/idl/index.did +779 -0
  555. package/src/stable/lib/canisters/nns_internet_identity/idl/index.ts +1509 -0
  556. package/src/stable/lib/canisters/nns_registry/idl/README.md +9 -0
  557. package/src/stable/lib/canisters/nns_registry/idl/index.did +493 -0
  558. package/src/stable/lib/canisters/nns_registry/idl/index.ts +1421 -0
  559. package/src/stable/lib/canisters/nns_sns_w/idl/README.md +9 -0
  560. package/src/stable/lib/canisters/nns_sns_w/idl/index.did +352 -0
  561. package/src/stable/lib/canisters/nns_sns_w/idl/index.ts +887 -0
  562. package/src/stable/lib/did_file/idl_to_string.ts +79 -0
  563. package/src/stable/lib/did_file/index.ts +2 -0
  564. package/src/stable/lib/did_file/visitor/did_visitor.ts +135 -0
  565. package/src/stable/lib/did_file/visitor/escape_candid_name.ts +100 -0
  566. package/src/stable/lib/did_file/visitor/extract_candid.ts +31 -0
  567. package/src/stable/lib/did_file/visitor/index.ts +1 -0
  568. package/src/stable/lib/did_file/visitor/visit/func.ts +31 -0
  569. package/src/stable/lib/did_file/visitor/visit/opt.ts +16 -0
  570. package/src/stable/lib/did_file/visitor/visit/primitive.ts +11 -0
  571. package/src/stable/lib/did_file/visitor/visit/record.ts +24 -0
  572. package/src/stable/lib/did_file/visitor/visit/recursive.ts +32 -0
  573. package/src/stable/lib/did_file/visitor/visit/service.ts +107 -0
  574. package/src/stable/lib/did_file/visitor/visit/tuple.ts +20 -0
  575. package/src/stable/lib/did_file/visitor/visit/variant.ts +26 -0
  576. package/src/stable/lib/did_file/visitor/visit/vec.ts +16 -0
  577. package/src/stable/lib/error.ts +55 -0
  578. package/src/stable/lib/execute_and_reply_with_candid_serde.ts +245 -0
  579. package/src/stable/lib/func.ts +7 -0
  580. package/src/stable/lib/globals.ts +250 -0
  581. package/src/stable/lib/ic_apis/NOTICE +203 -0
  582. package/src/stable/lib/ic_apis/azle_ic_stable.ts +86 -0
  583. package/src/stable/lib/ic_apis/call.ts +397 -0
  584. package/src/stable/lib/ic_apis/candid_decode.ts +26 -0
  585. package/src/stable/lib/ic_apis/candid_encode.ts +27 -0
  586. package/src/stable/lib/ic_apis/canister_cycle_balance.ts +28 -0
  587. package/src/stable/lib/ic_apis/canister_self.ts +25 -0
  588. package/src/stable/lib/ic_apis/canister_version.ts +33 -0
  589. package/src/stable/lib/ic_apis/certified_data_set.ts +35 -0
  590. package/src/stable/lib/ic_apis/chunk.ts +42 -0
  591. package/src/stable/lib/ic_apis/clear_timer.ts +53 -0
  592. package/src/stable/lib/ic_apis/cycles_burn.ts +32 -0
  593. package/src/stable/lib/ic_apis/data_certificate.ts +30 -0
  594. package/src/stable/lib/ic_apis/in_replicated_execution.ts +20 -0
  595. package/src/stable/lib/ic_apis/index.ts +37 -0
  596. package/src/stable/lib/ic_apis/is_controller.ts +31 -0
  597. package/src/stable/lib/ic_apis/msg_arg_data.ts +28 -0
  598. package/src/stable/lib/ic_apis/msg_caller.ts +32 -0
  599. package/src/stable/lib/ic_apis/msg_cycles_accept.ts +27 -0
  600. package/src/stable/lib/ic_apis/msg_cycles_available.ts +25 -0
  601. package/src/stable/lib/ic_apis/msg_cycles_refunded.ts +25 -0
  602. package/src/stable/lib/ic_apis/msg_method_name.ts +21 -0
  603. package/src/stable/lib/ic_apis/msg_reject.ts +28 -0
  604. package/src/stable/lib/ic_apis/msg_reject_code.ts +40 -0
  605. package/src/stable/lib/ic_apis/msg_reject_msg.ts +24 -0
  606. package/src/stable/lib/ic_apis/msg_reply.ts +34 -0
  607. package/src/stable/lib/ic_apis/performance_counter.ts +31 -0
  608. package/src/stable/lib/ic_apis/rand_seed.ts +40 -0
  609. package/src/stable/lib/ic_apis/set_timer.ts +80 -0
  610. package/src/stable/lib/ic_apis/set_timer_interval.ts +87 -0
  611. package/src/stable/lib/ic_apis/time.ts +26 -0
  612. package/src/stable/lib/ic_apis/trap.ts +29 -0
  613. package/src/stable/lib/index.ts +16 -0
  614. package/src/stable/lib/json.ts +39 -0
  615. package/src/stable/lib/stable_structures/stable_b_tree_map.ts +488 -0
  616. package/src/stable/lib/stable_structures/stable_json.ts +254 -0
  617. package/src/stable/lib/state.ts +322 -0
  618. package/src/stable/test/benchmarks/_azle_get_benchmarks.did +9 -0
  619. package/src/stable/test/benchmarks/index.ts +273 -0
  620. package/src/stable/test/candid_deep_equal.ts +99 -0
  621. package/src/stable/test/canister_names.ts +36 -0
  622. package/src/stable/test/fuzz.ts +102 -0
  623. package/src/stable/test/get_canister_actor.ts +45 -0
  624. package/src/stable/test/global_state.ts +202 -0
  625. package/src/stable/test/index.ts +274 -0
  626. package/src/stable/test/memory_state.ts +187 -0
  627. package/src/stable/test/property/default_prop_test_params.ts +36 -0
  628. package/src/stable/test/type/assert_type.ts +9 -0
  629. package/tsconfig.dev.json +10 -0
@@ -0,0 +1,7 @@
1
+ mod call_with_error_handling;
2
+ mod error;
3
+ mod with_ctx;
4
+
5
+ pub use call_with_error_handling::call_with_error_handling;
6
+ pub use error::{handle_promise_error, trap_on_last_exception};
7
+ pub use with_ctx::with_ctx;
@@ -0,0 +1,24 @@
1
+ use std::error::Error;
2
+
3
+ use rquickjs::Ctx;
4
+
5
+ use crate::CONTEXT_REF_CELL;
6
+
7
+ pub fn with_ctx<F, R>(callback: F) -> Result<R, Box<dyn Error>>
8
+ where
9
+ F: FnOnce(Ctx) -> Result<R, Box<dyn Error>>,
10
+ {
11
+ CONTEXT_REF_CELL.with(|context_ref_cell| {
12
+ let context_ref = context_ref_cell.borrow();
13
+ let context = context_ref
14
+ .as_ref()
15
+ .ok_or("QuickJS context not initialized")?;
16
+
17
+ context.with(|ctx| {
18
+ let result = callback(ctx.clone())
19
+ .map_err(|e| format!("QuickJS callback execution failed: {e}"))?;
20
+
21
+ Ok(result)
22
+ })
23
+ })
24
+ }
@@ -0,0 +1,84 @@
1
+ use std::{borrow::Cow, cell::RefCell, collections::BTreeMap};
2
+
3
+ use ic_stable_structures::{storable::Bound, StableBTreeMap, Storable};
4
+ use rquickjs::{Ctx, Result};
5
+
6
+ use crate::{ic::throw_error, Memory};
7
+
8
+ #[allow(unused)]
9
+ pub type AzleStableBTreeMap =
10
+ StableBTreeMap<AzleStableBTreeMapKey, AzleStableBTreeMapValue, Memory>;
11
+
12
+ thread_local! {
13
+ pub static STABLE_B_TREE_MAPS: RefCell<BTreeMap<u8, AzleStableBTreeMap>> = RefCell::new(BTreeMap::new());
14
+ }
15
+
16
+ #[derive(Ord, PartialOrd, Eq, PartialEq, Clone)]
17
+ pub struct AzleStableBTreeMapKey {
18
+ pub bytes: Vec<u8>,
19
+ }
20
+
21
+ impl Storable for AzleStableBTreeMapKey {
22
+ fn to_bytes(&self) -> Cow<[u8]> {
23
+ Cow::Borrowed(&self.bytes)
24
+ }
25
+
26
+ fn from_bytes(bytes: Cow<[u8]>) -> Self {
27
+ AzleStableBTreeMapKey {
28
+ bytes: bytes.to_vec(),
29
+ }
30
+ }
31
+
32
+ const BOUND: Bound = Bound::Unbounded;
33
+ }
34
+
35
+ #[derive(Ord, PartialOrd, Eq, PartialEq, Clone)]
36
+ pub struct AzleStableBTreeMapValue {
37
+ pub bytes: Vec<u8>,
38
+ }
39
+
40
+ impl Storable for AzleStableBTreeMapValue {
41
+ fn to_bytes(&self) -> Cow<[u8]> {
42
+ Cow::Borrowed(&self.bytes)
43
+ }
44
+
45
+ fn from_bytes(bytes: Cow<[u8]>) -> Self {
46
+ AzleStableBTreeMapValue {
47
+ bytes: bytes.to_vec(),
48
+ }
49
+ }
50
+
51
+ const BOUND: Bound = Bound::Unbounded;
52
+ }
53
+
54
+ pub fn with_stable_b_tree_map<F, R>(ctx: Ctx, memory_id: u8, f: F) -> Result<R>
55
+ where
56
+ F: FnOnce(&AzleStableBTreeMap) -> R,
57
+ {
58
+ STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
59
+ let stable_b_tree_maps = stable_b_tree_maps.borrow();
60
+
61
+ let stable_b_tree_map = stable_b_tree_maps.get(&memory_id).ok_or(throw_error(
62
+ ctx,
63
+ &format!("Could not find StableBTreeMap with memory id {memory_id}"),
64
+ ))?;
65
+
66
+ Ok(f(stable_b_tree_map))
67
+ })
68
+ }
69
+
70
+ pub fn with_stable_b_tree_map_mut<F, R>(ctx: Ctx, memory_id: u8, f: F) -> Result<R>
71
+ where
72
+ F: FnOnce(&mut AzleStableBTreeMap) -> R,
73
+ {
74
+ STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
75
+ let mut stable_b_tree_maps = stable_b_tree_maps.borrow_mut();
76
+
77
+ let stable_b_tree_map = stable_b_tree_maps.get_mut(&memory_id).ok_or(throw_error(
78
+ ctx,
79
+ &format!("Could not find StableBTreeMap with memory id {memory_id}"),
80
+ ))?;
81
+
82
+ Ok(f(stable_b_tree_map))
83
+ })
84
+ }
@@ -0,0 +1,55 @@
1
+ use std::error::Error;
2
+
3
+ use rquickjs::{Ctx, Object, Value};
4
+
5
+ use crate::rquickjs_utils::call_with_error_handling;
6
+
7
+ /// Dispatches an action to the Azle JavaScript runtime.
8
+ ///
9
+ /// This function creates a JavaScript action object with the provided type and payload,
10
+ /// along with location information (filepath and function name), and dispatches it to
11
+ /// the Azle runtime by calling the global `_azleDispatch` function. Actions are used
12
+ /// for important global state changes in Azle.
13
+ ///
14
+ /// # Arguments
15
+ ///
16
+ /// * `ctx` - The QuickJS context in which the action will be created and dispatched
17
+ /// * `action_type` - The type of the action to be dispatched
18
+ /// * `payload` - The payload of the action as a QuickJS Value
19
+ /// * `filepath` - The filepath where the action is being dispatched from
20
+ /// * `function_name` - The name of the function dispatching the action
21
+ ///
22
+ /// # Returns
23
+ ///
24
+ /// * `Ok(())` if the action was successfully dispatched
25
+ /// * `Err` containing the error if any operation fails
26
+ ///
27
+ /// # Errors
28
+ ///
29
+ /// This function may return an error if:
30
+ /// - Creating JavaScript objects fails
31
+ /// - Setting properties on JavaScript objects fails
32
+ /// - Calling the `_azleDispatch` function fails
33
+ pub fn dispatch_action<'a>(
34
+ ctx: Ctx<'a>,
35
+ action_type: &str,
36
+ payload: Value<'a>,
37
+ filepath: &str,
38
+ function_name: &str,
39
+ ) -> Result<(), Box<dyn Error>> {
40
+ let action = Object::new(ctx.clone())?;
41
+
42
+ action.set("type", action_type)?;
43
+ action.set("payload", payload)?;
44
+
45
+ let location = Object::new(ctx.clone())?;
46
+
47
+ location.set("filepath", filepath)?;
48
+ location.set("functionName", function_name)?;
49
+
50
+ action.set("location", location)?;
51
+
52
+ call_with_error_handling(&ctx, &ctx.globals().get("_azleDispatch")?, (action,))?;
53
+
54
+ Ok(())
55
+ }
@@ -0,0 +1,296 @@
1
+ use core::ptr::read_volatile;
2
+ use std::{error::Error, str};
3
+
4
+ use serde::{Deserialize, Serialize};
5
+ use serde_json;
6
+
7
+ #[derive(Debug, Serialize, Deserialize, Clone)]
8
+ pub struct WasmData {
9
+ #[serde(rename = "envVars")]
10
+ pub env_vars: Vec<(String, String)>,
11
+ #[serde(rename = "mainJsPath")]
12
+ pub main_js_path: 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() -> Result<Vec<u8>, Box<dyn Error>> {
43
+ let size = js_passive_data_size();
44
+
45
+ let mut js_vec = vec![243; size];
46
+
47
+ // This cast to usize appears to be well defined and safe
48
+ let js_vec_location = js_vec.as_mut_ptr() as usize;
49
+
50
+ init_js_passive_data(i32::try_from(js_vec_location)?);
51
+
52
+ Ok(js_vec)
53
+ }
54
+
55
+ #[inline(never)]
56
+ #[unsafe(no_mangle)]
57
+ extern "C" fn init_wasm_data_passive_data(wasm_data_vec_location: i32) {
58
+ // This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
59
+ unsafe { read_volatile(&wasm_data_vec_location) };
60
+ }
61
+
62
+ // Used to provide a safe value for the read_volatile and to differentiate between the
63
+ // js_passive_data_size and wasm_data_passive_data_size function bodies
64
+ // Without this problems happen during Wasm binary manipulation
65
+ static WASM_DATA_PASSIVE_DATA_SIZE: usize = 0;
66
+
67
+ #[inline(never)]
68
+ #[unsafe(no_mangle)]
69
+ extern "C" fn wasm_data_passive_data_size() -> usize {
70
+ // This is used to prevent compiler optimizations that interfere with the Wasm binary manipulation
71
+ unsafe { read_volatile(&WASM_DATA_PASSIVE_DATA_SIZE) }
72
+ }
73
+
74
+ // Inspired from: https://github.com/adambratschikaye/wasm-inject-data/blob/main/src/static_wasm.rs
75
+ // Most likely a derivative work licensed under the Apache License, Version 2.0: https://github.com/adambratschikaye/wasm-inject-data/blob/main/LICENSE
76
+ pub fn get_wasm_data() -> Result<WasmData, Box<dyn Error>> {
77
+ let size = wasm_data_passive_data_size();
78
+
79
+ let mut wasm_data_vec = vec![243; size];
80
+
81
+ // This cast to usize appears to be well defined and safe
82
+ let wasm_data_vec_location = wasm_data_vec.as_mut_ptr() as usize;
83
+
84
+ init_wasm_data_passive_data(i32::try_from(wasm_data_vec_location)?);
85
+
86
+ let wasm_data_str = str::from_utf8(&wasm_data_vec).map_err(|e| {
87
+ format!(
88
+ "WasmData conversion failed while converting Vec<u8> to String: {}",
89
+ e
90
+ )
91
+ })?;
92
+
93
+ let wasm_data: WasmData = serde_json::from_str(wasm_data_str).map_err(|e| {
94
+ format!(
95
+ "WasmData conversion failed while converting String to WasmData struct: {}",
96
+ e
97
+ )
98
+ })?;
99
+
100
+ Ok(wasm_data)
101
+ }
102
+
103
+ // For get_js_code and get_wasm_data above:
104
+
105
+ // Copyright © 2024 DFINITY Foundation
106
+
107
+ // Each file in this repository is licensed under the license as
108
+ // described in the LICENSE file in the same directory that contains the
109
+ // file or, if that doesn't exist, the first LICENSE file in any
110
+ // higher-level directory.
111
+
112
+ // Unless stated otherwise as described above, all files in this
113
+ // directory are licensed under the Apache License, Version 2.0 (the
114
+ // "License"); you may not use these files except in compliance with the
115
+ // License. You may obtain a copy of the License at
116
+
117
+ // http://www.apache.org/licenses/LICENSE-2.0
118
+
119
+ // The Apache-2.0 license is also copied below:
120
+
121
+ // Apache License
122
+ // Version 2.0, January 2004
123
+ // http://www.apache.org/licenses/
124
+
125
+ // TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
126
+
127
+ // 1. Definitions.
128
+
129
+ // "License" shall mean the terms and conditions for use, reproduction,
130
+ // and distribution as defined by Sections 1 through 9 of this document.
131
+
132
+ // "Licensor" shall mean the copyright owner or entity authorized by
133
+ // the copyright owner that is granting the License.
134
+
135
+ // "Legal Entity" shall mean the union of the acting entity and all
136
+ // other entities that control, are controlled by, or are under common
137
+ // control with that entity. For the purposes of this definition,
138
+ // "control" means (i) the power, direct or indirect, to cause the
139
+ // direction or management of such entity, whether by contract or
140
+ // otherwise, or (ii) ownership of fifty percent (50%) or more of the
141
+ // outstanding shares, or (iii) beneficial ownership of such entity.
142
+
143
+ // "You" (or "Your") shall mean an individual or Legal Entity
144
+ // exercising permissions granted by this License.
145
+
146
+ // "Source" form shall mean the preferred form for making modifications,
147
+ // including but not limited to software source code, documentation
148
+ // source, and configuration files.
149
+
150
+ // "Object" form shall mean any form resulting from mechanical
151
+ // transformation or translation of a Source form, including but
152
+ // not limited to compiled object code, generated documentation,
153
+ // and conversions to other media types.
154
+
155
+ // "Work" shall mean the work of authorship, whether in Source or
156
+ // Object form, made available under the License, as indicated by a
157
+ // copyright notice that is included in or attached to the work
158
+ // (an example is provided in the Appendix below).
159
+
160
+ // "Derivative Works" shall mean any work, whether in Source or Object
161
+ // form, that is based on (or derived from) the Work and for which the
162
+ // editorial revisions, annotations, elaborations, or other modifications
163
+ // represent, as a whole, an original work of authorship. For the purposes
164
+ // of this License, Derivative Works shall not include works that remain
165
+ // separable from, or merely link (or bind by name) to the interfaces of,
166
+ // the Work and Derivative Works thereof.
167
+
168
+ // "Contribution" shall mean any work of authorship, including
169
+ // the original version of the Work and any modifications or additions
170
+ // to that Work or Derivative Works thereof, that is intentionally
171
+ // submitted to Licensor for inclusion in the Work by the copyright owner
172
+ // or by an individual or Legal Entity authorized to submit on behalf of
173
+ // the copyright owner. For the purposes of this definition, "submitted"
174
+ // means any form of electronic, verbal, or written communication sent
175
+ // to the Licensor or its representatives, including but not limited to
176
+ // communication on electronic mailing lists, source code control systems,
177
+ // and issue tracking systems that are managed by, or on behalf of, the
178
+ // Licensor for the purpose of discussing and improving the Work, but
179
+ // excluding communication that is conspicuously marked or otherwise
180
+ // designated in writing by the copyright owner as "Not a Contribution."
181
+
182
+ // "Contributor" shall mean Licensor and any individual or Legal Entity
183
+ // on behalf of whom a Contribution has been received by Licensor and
184
+ // subsequently incorporated within the Work.
185
+
186
+ // 2. Grant of Copyright License. Subject to the terms and conditions of
187
+ // this License, each Contributor hereby grants to You a perpetual,
188
+ // worldwide, non-exclusive, no-charge, royalty-free, irrevocable
189
+ // copyright license to reproduce, prepare Derivative Works of,
190
+ // publicly display, publicly perform, sublicense, and distribute the
191
+ // Work and such Derivative Works in Source or Object form.
192
+
193
+ // 3. Grant of Patent License. Subject to the terms and conditions of
194
+ // this License, each Contributor hereby grants to You a perpetual,
195
+ // worldwide, non-exclusive, no-charge, royalty-free, irrevocable
196
+ // (except as stated in this section) patent license to make, have made,
197
+ // use, offer to sell, sell, import, and otherwise transfer the Work,
198
+ // where such license applies only to those patent claims licensable
199
+ // by such Contributor that are necessarily infringed by their
200
+ // Contribution(s) alone or by combination of their Contribution(s)
201
+ // with the Work to which such Contribution(s) was submitted. If You
202
+ // institute patent litigation against any entity (including a
203
+ // cross-claim or counterclaim in a lawsuit) alleging that the Work
204
+ // or a Contribution incorporated within the Work constitutes direct
205
+ // or contributory patent infringement, then any patent licenses
206
+ // granted to You under this License for that Work shall terminate
207
+ // as of the date such litigation is filed.
208
+
209
+ // 4. Redistribution. You may reproduce and distribute copies of the
210
+ // Work or Derivative Works thereof in any medium, with or without
211
+ // modifications, and in Source or Object form, provided that You
212
+ // meet the following conditions:
213
+
214
+ // (a) You must give any other recipients of the Work or
215
+ // Derivative Works a copy of this License; and
216
+
217
+ // (b) You must cause any modified files to carry prominent notices
218
+ // stating that You changed the files; and
219
+
220
+ // (c) You must retain, in the Source form of any Derivative Works
221
+ // that You distribute, all copyright, patent, trademark, and
222
+ // attribution notices from the Source form of the Work,
223
+ // excluding those notices that do not pertain to any part of
224
+ // the Derivative Works; and
225
+
226
+ // (d) If the Work includes a "NOTICE" text file as part of its
227
+ // distribution, then any Derivative Works that You distribute must
228
+ // include a readable copy of the attribution notices contained
229
+ // within such NOTICE file, excluding those notices that do not
230
+ // pertain to any part of the Derivative Works, in at least one
231
+ // of the following places: within a NOTICE text file distributed
232
+ // as part of the Derivative Works; within the Source form or
233
+ // documentation, if provided along with the Derivative Works; or,
234
+ // within a display generated by the Derivative Works, if and
235
+ // wherever such third-party notices normally appear. The contents
236
+ // of the NOTICE file are for informational purposes only and
237
+ // do not modify the License. You may add Your own attribution
238
+ // notices within Derivative Works that You distribute, alongside
239
+ // or as an addendum to the NOTICE text from the Work, provided
240
+ // that such additional attribution notices cannot be construed
241
+ // as modifying the License.
242
+
243
+ // You may add Your own copyright statement to Your modifications and
244
+ // may provide additional or different license terms and conditions
245
+ // for use, reproduction, or distribution of Your modifications, or
246
+ // for any such Derivative Works as a whole, provided Your use,
247
+ // reproduction, and distribution of the Work otherwise complies with
248
+ // the conditions stated in this License.
249
+
250
+ // 5. Submission of Contributions. Unless You explicitly state otherwise,
251
+ // any Contribution intentionally submitted for inclusion in the Work
252
+ // by You to the Licensor shall be under the terms and conditions of
253
+ // this License, without any additional terms or conditions.
254
+ // Notwithstanding the above, nothing herein shall supersede or modify
255
+ // the terms of any separate license agreement you may have executed
256
+ // with Licensor regarding such Contributions.
257
+
258
+ // 6. Trademarks. This License does not grant permission to use the trade
259
+ // names, trademarks, service marks, or product names of the Licensor,
260
+ // except as required for reasonable and customary use in describing the
261
+ // origin of the Work and reproducing the content of the NOTICE file.
262
+
263
+ // 7. Disclaimer of Warranty. Unless required by applicable law or
264
+ // agreed to in writing, Licensor provides the Work (and each
265
+ // Contributor provides its Contributions) on an "AS IS" BASIS,
266
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
267
+ // implied, including, without limitation, any warranties or conditions
268
+ // of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
269
+ // PARTICULAR PURPOSE. You are solely responsible for determining the
270
+ // appropriateness of using or redistributing the Work and assume any
271
+ // risks associated with Your exercise of permissions under this License.
272
+
273
+ // 8. Limitation of Liability. In no event and under no legal theory,
274
+ // whether in tort (including negligence), contract, or otherwise,
275
+ // unless required by applicable law (such as deliberate and grossly
276
+ // negligent acts) or agreed to in writing, shall any Contributor be
277
+ // liable to You for damages, including any direct, indirect, special,
278
+ // incidental, or consequential damages of any character arising as a
279
+ // result of this License or out of the use or inability to use the
280
+ // Work (including but not limited to damages for loss of goodwill,
281
+ // work stoppage, computer failure or malfunction, or any and all
282
+ // other commercial damages or losses), even if such Contributor
283
+ // has been advised of the possibility of such damages.
284
+
285
+ // 9. Accepting Warranty or Additional Liability. While redistributing
286
+ // the Work or Derivative Works thereof, You may choose to offer,
287
+ // and charge a fee for, acceptance of support, warranty, indemnity,
288
+ // or other liability obligations and/or rights consistent with this
289
+ // License. However, in accepting such obligations, You may act only
290
+ // on Your own behalf and on Your sole responsibility, not on behalf
291
+ // of any other Contributor, and only if You agree to indemnify,
292
+ // defend, and hold each Contributor harmless for any liability
293
+ // incurred by, or claims asserted against, such Contributor by reason
294
+ // of your accepting any such warranty or additional liability.
295
+
296
+ // END OF TERMS AND CONDITIONS
@@ -0,0 +1,15 @@
1
+ import { rm } from 'fs/promises';
2
+ import { join } from 'path';
3
+
4
+ import { getDfxRoot } from '#utils/dfx_root';
5
+
6
+ export async function runCommand(): Promise<void> {
7
+ const dotAzlePath = join(getDfxRoot(), '.azle');
8
+
9
+ await rm(dotAzlePath, {
10
+ recursive: true,
11
+ force: true
12
+ });
13
+
14
+ console.info(`${dotAzlePath} directory deleted`);
15
+ }
@@ -0,0 +1,39 @@
1
+ import { ExecSyncOptionsWithBufferEncoding, IOType } from 'child_process';
2
+
3
+ import { execSyncPretty } from '#utils/exec_sync_pretty';
4
+ import { AZLE_ROOT } from '#utils/global_paths';
5
+
6
+ export async function runCommand(ioType: IOType = 'inherit'): Promise<void> {
7
+ const options = {
8
+ cwd: AZLE_ROOT,
9
+ stdio: ioType
10
+ };
11
+
12
+ runAuditCommand('npm audit', options);
13
+ runAuditCommand('npm run license-check', options);
14
+
15
+ runAuditCommand('cargo audit', options);
16
+ runAuditCommand('cargo audit bin ~/.cargo/bin/cargo-auditable', options);
17
+ runAuditCommand('cargo audit bin ~/.cargo/bin/cargo-audit', options);
18
+ runAuditCommand(
19
+ 'cargo audit bin ~/.cargo/bin/cargo-bundle-licenses',
20
+ options
21
+ );
22
+ runAuditCommand('cargo audit bin ~/.cargo/bin/cargo-deny', options);
23
+ runAuditCommand('cargo audit bin ~/.cargo/bin/wasi2ic', options);
24
+ runAuditCommand('cargo deny check', options);
25
+
26
+ console.info('\n🎉 All security audit checks completed successfully!');
27
+ }
28
+ /**
29
+ * Runs an audit command and logs a success message
30
+ * @param command - The command to execute
31
+ * @param options - Options to pass to execSyncPretty
32
+ */
33
+ function runAuditCommand(
34
+ command: string,
35
+ options?: ExecSyncOptionsWithBufferEncoding
36
+ ): void {
37
+ execSyncPretty(command, options);
38
+ console.info(`✓ ${command} completed successfully`);
39
+ }
@@ -0,0 +1,41 @@
1
+ import { execSyncPretty } from '#utils/exec_sync_pretty';
2
+ import { AZLE_ROOT } from '#utils/global_paths';
3
+
4
+ import { azle } from '../../../../../../package.json';
5
+
6
+ type DependencyName =
7
+ | 'dfx'
8
+ | 'node'
9
+ | 'rust'
10
+ | 'cargo-auditable'
11
+ | 'cargo-audit'
12
+ | 'cargo-bundle-licenses'
13
+ | 'cargo-deny'
14
+ | 'wasi2ic';
15
+
16
+ type DependencyInstallInfo = {
17
+ [key in DependencyName]: boolean;
18
+ };
19
+
20
+ export async function runCommand(
21
+ dependenciesToInstall: DependencyInstallInfo
22
+ ): Promise<void> {
23
+ for (const key in dependenciesToInstall) {
24
+ const dependency = key as DependencyName;
25
+ if (dependenciesToInstall[dependency] === true) {
26
+ installDependency(dependency);
27
+ }
28
+ }
29
+ }
30
+
31
+ function installDependency(dependency: DependencyName): void {
32
+ console.info(`Installing ${dependency}...`);
33
+ const version = azle.globalDependencies[dependency];
34
+ const script = `install_${dependency}.sh`;
35
+ execSyncPretty(
36
+ `${AZLE_ROOT}/src/stable/build/commands/dev/setup/${script} ${version}`,
37
+ {
38
+ stdio: 'inherit'
39
+ }
40
+ );
41
+ }
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ VERSION=$1
4
+
5
+ if [[ $VERSION =~ ^https?:// ]]; then
6
+ echo "Installing cargo-audit from repository $VERSION"
7
+ cargo auditable install cargo-audit --git "$VERSION"
8
+ else
9
+ echo "Installing cargo-audit version $VERSION"
10
+ cargo auditable install cargo-audit --version "$VERSION"
11
+ fi
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ VERSION=$1
4
+
5
+ # cargo-auditable allows us to run cargo audit bin on our global cargo dependencies.
6
+ # We first install cargo-auditable so that it can be used to install itself.
7
+ # Without this, cargo audit bin would not be able to audit cargo-auditable itself.
8
+ if [[ $VERSION =~ ^https?:// ]]; then
9
+ echo "Installing cargo-auditable from repository $VERSION"
10
+ cargo install cargo-auditable --git "$VERSION" --locked
11
+ cargo auditable install cargo-auditable --git "$VERSION" --locked --force
12
+ else
13
+ echo "Installing cargo-auditable version $VERSION"
14
+ cargo install cargo-auditable --version "$VERSION" --locked
15
+ cargo auditable install cargo-auditable --version "$VERSION" --locked --force
16
+ fi
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ VERSION=$1
4
+
5
+ if [[ $VERSION =~ ^https?:// ]]; then
6
+ echo "Installing cargo-bundle-licenses from repository $VERSION"
7
+ cargo auditable install cargo-bundle-licenses --git "$VERSION" --locked
8
+ else
9
+ echo "Installing cargo-bundle-licenses version $VERSION"
10
+ cargo auditable install cargo-bundle-licenses --version "$VERSION" --locked
11
+ fi
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ VERSION=$1
4
+
5
+ if [[ $VERSION =~ ^https?:// ]]; then
6
+ echo "Installing cargo-deny from repository $VERSION"
7
+ cargo auditable install cargo-deny --git "$VERSION" --locked
8
+ else
9
+ echo "Installing cargo-deny version $VERSION"
10
+ cargo auditable install cargo-deny --version "$VERSION" --locked
11
+ fi
@@ -0,0 +1,36 @@
1
+ #!/bin/bash
2
+
3
+ set -eou pipefail
4
+
5
+ if [ -z "$1" ]; then
6
+ echo "Error: No DFX version specified."
7
+ echo "Usage: ./install_dfx.sh <DFX_VERSION>"
8
+ exit 1
9
+ fi
10
+
11
+ DFX_VERSION=$1
12
+
13
+ # Install or update dfx using the official installation script
14
+ echo "Installing dfx version $DFX_VERSION..."
15
+ DFXVM_INIT_YES=true DFX_VERSION=$DFX_VERSION sh -ci "$(curl --retry 3 -fsSL https://sdk.dfinity.org/install.sh)"
16
+
17
+ # Determine the correct dfx path based on the operating system
18
+ if [[ "$OSTYPE" == "darwin"* ]]; then
19
+ # macOS
20
+ DFX_PATH="$HOME/Library/Application Support/org.dfinity.dfx/bin"
21
+ else
22
+ # Linux and others
23
+ DFX_PATH="$HOME/.local/share/dfx/bin"
24
+ fi
25
+
26
+ # Add dfx to PATH for current session so the installation can be verified
27
+ export PATH="$DFX_PATH:$PATH"
28
+
29
+ # Verify installation
30
+ if ! command -v dfx &> /dev/null; then
31
+ echo "dfx installation verification failed" >&2
32
+ exit 1
33
+ fi
34
+
35
+ echo "dfx $DFX_VERSION installation completed."
36
+ exit 0