diff --git a/scripts/bind.sh b/scripts/bind.sh deleted file mode 100755 index 606372b02f..0000000000 --- a/scripts/bind.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -[[ "${1:-}" != "--help" ]] || { - cat <<-EOF - Generates candid files and bindings. - - Prerequisites: - - Git is clean. This is to ensure that the automated code changes are easy to audit. - - Note: It is recommended also to have the code formatted before generating bindings. - - Deploy all canisters to the 'local' network. Or otherwise ensure that: - - Wasm for each canister is at: '.dfx/local/canisters/$CANISTER/$CANISTER.wasm.gz' - Note: You may need to set '"gzip": true' for canisters in 'dfx.json'. - - Candid for each canister is at: '.dfx/local/canisters/$CANISTER/$CANISTER.did' - - Usage: - $(basename "$0") [--check] - Generates bindings. Optionally checks whether the bindings have changed. - EOF - - exit 0 -} - -# Ensure that git is clean -if git status --porcelain --untracked-files=no | grep -q .; then - echo "ERROR: Git is not clean. Please commit all changes before automated code generation." - exit 1 -fi -# Generate bindings -scripts/bind/rust.sh -# Format -scripts/format.sh -# Check whether any files have changed. -[[ "${1:-}" != "--check" ]] || { - if git status --porcelain --untracked-files=no | grep -q .; then - echo "ERROR: Bindings are not up to date. Please run: '$0'" - exit 1 - fi -} diff --git a/scripts/bind/rust.sh b/scripts/bind/rust.sh deleted file mode 100755 index e9ed8e1514..0000000000 --- a/scripts/bind/rust.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -[[ "${1:-}" != "--help" ]] || { - cat <<-EOF - Generates rust canister bindings. - - Prerequisites: - - Rust crates at src/\$canister/{tyes,client,pic}/ - - Usage: - $(basename $0) [canister_name..] - - Properties: - - Creates Rust bindings files at src/\$canister/{types,client,pic}/src/lib.rs - EOF - - exit 0 -} - -# If no canisters are specified, generate bindings for all. -if (($# == 0)); then - mapfile -t canisters < <(jq -r '.canisters|keys|.[]' dfx.json) -else - canisters=("${@}") -fi - -for canister in "${canisters[@]}"; do - for binding in types; do # TODO: Generation for client & pic is in future PRs. - # Paths: - canister_binding_config="./scripts/bind/rust/${canister}.${binding}.toml" - candid_file=".dfx/local/canisters/$canister/${canister}.did" - generated_file="src/$canister/$binding/src/lib.rs" - # Generate: - if test -f "$canister_binding_config"; then - echo "INFO: Creating rust $binding for $canister..." - test -f "$candid_file" || { - echo "ERROR: Candid file missing from: '$candid_file'" - echo " You may need to run: dfx deploy $canister" - exit 1 - } >&2 - mkdir -p "src/backend/src/bind" - didc bind -t rs "$candid_file" --config "$canister_binding_config" >"$generated_file" || { - echo "ERROR: Failed to generate $binding for $canister." - echo " Candid: $candid_file" - echo " Configuration: $canister_binding_config" - exit 1 - } >&2 - else - echo "INFO: No rust binding script for $canister at $canister_binding_config" - fi - done -done - -# Format -scripts/format.rust.sh diff --git a/scripts/bind/rust/cycles_ledger.types.toml b/scripts/bind/rust/cycles_ledger.types.toml deleted file mode 100644 index 942541f598..0000000000 --- a/scripts/bind/rust/cycles_ledger.types.toml +++ /dev/null @@ -1,10 +0,0 @@ -[didc.rust] -target = "custom" -template = "scripts/bind/rust/types.hbs" -# any tags mentioned from hbs -candid_crate = "candid" -canister_name = "cycles_ledger" - -[rust] -visibility = "pub" -attributes = "#[derive(CandidType, Deserialize, Debug, Eq, PartialEq, Clone)]" diff --git a/scripts/bind/rust/types.hbs b/scripts/bind/rust/types.hbs deleted file mode 100644 index 0bbacab077..0000000000 --- a/scripts/bind/rust/types.hbs +++ /dev/null @@ -1,15 +0,0 @@ -//! Bindings to the `{{ canister_name }}` canister, generated by `./scripts/bind/rust.sh` -//! -//! Binding configuration: `./scripts/bind/rust/{{ canister_name }}.types.toml` -//! -//! Adapted from: -#![allow(dead_code, unused_imports, clippy::all, clippy::missing_errors_doc)] -use {{candid_crate}}::{self, CandidType, Deserialize, Principal}; -use ic_cdk::api::call::CallResult; - -{{#if submodule}} -/// Manually maintained methods -pub mod {{submodule}}; -{{/if}} - -{{type_defs}}